Skip to content

Commit

Permalink
Collapsed table border colors don't recompute correctly on color sche…
Browse files Browse the repository at this point in the history
…me change

https://bugs.webkit.org/show_bug.cgi?id=261429
rdar://115313292

Reviewed by Antti Koivisto.

Collapsed borders are currently invalidated by comparing `BorderData` whenever
a style change occurs. However, when the used color scheme changes and the border
color is `currentcolor`, it's possible for the `BorderData` to be equivalent,
even though the resolved border color may be different.

To fix, leverage the existing `BorderData::isEquivalentForPainting` helper to
invalidate collapsed table borders whenever a border uses `currentcolor` and
the resolved colors are different.

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/RenderTable.cpp:
(WebCore::RenderTable::styleDidChange):
* Source/WebCore/rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::styleDidChange):
* Source/WebCore/rendering/RenderTableCol.cpp:
(WebCore::RenderTableCol::styleDidChange):
* Source/WebCore/rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::styleDidChange):
* Source/WebCore/rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::styleDidChange):
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
(WebCore::RenderStyle::borderIsEquivalentForPainting const):

Canonical link: https://commits.webkit.org/267993@main
  • Loading branch information
pxlcoder committed Sep 14, 2023
1 parent 7763e29 commit 0b505d6
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -4633,7 +4633,6 @@ webkit.org/b/245347 imported/w3c/web-platform-tests/css/css-color/lch-010.html [
webkit.org/b/245347 imported/w3c/web-platform-tests/css/css-color/oklch-009.html [ ImageOnlyFailure ]
webkit.org/b/245347 imported/w3c/web-platform-tests/css/css-color/oklch-010.html [ ImageOnlyFailure ]
webkit.org/b/214455 imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-visited-link-initial.html [ ImageOnlyFailure ]
webkit.org/b/214455 imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-table-border-currentcolor-responsive.html [ ImageOnlyFailure ]
webkit.org/b/214455 imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-background-mismatch-opaque-cross-origin.sub.html [ ImageOnlyFailure ]
webkit.org/b/214455 imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred.html [ ImageOnlyFailure ]

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void RenderTable::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
}

// If border was changed, invalidate collapsed borders cache.
if (oldStyle && oldStyle->border() != style().border())
if (oldStyle && !oldStyle->borderIsEquivalentForPainting(style()))
invalidateCollapsedBorders();
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTableCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ void RenderTableCell::styleDidChange(StyleDifference diff, const RenderStyle* ol

// If border was changed, notify table.
RenderTable* table = this->table();
if (table && oldStyle && oldStyle->border() != style().border()) {
if (table && oldStyle && !oldStyle->borderIsEquivalentForPainting(style())) {
table->invalidateCollapsedBorders(this);
if (table->collapseBorders() && diff == StyleDifference::Layout) {
markCellDirtyWhenCollapsedBorderChanges(table->cellBelow(this));
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTableCol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void RenderTableCol::styleDidChange(StyleDifference diff, const RenderStyle* old
// If border was changed, notify table.
if (!oldStyle)
return;
if (oldStyle->border() != style().border()) {
if (!oldStyle->borderIsEquivalentForPainting(style())) {
table->invalidateCollapsedBorders();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTableRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void RenderTableRow::styleDidChange(StyleDifference diff, const RenderStyle* old

// If border was changed, notify table.
if (RenderTable* table = this->table()) {
if (oldStyle && oldStyle->border() != style().border())
if (oldStyle && !oldStyle->borderIsEquivalentForPainting(style()))
table->invalidateCollapsedBorders();

if (oldStyle && diff == StyleDifference::Layout && needsLayout() && table->collapseBorders() && borderWidthChanged(oldStyle, &style())) {
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTableSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void RenderTableSection::styleDidChange(StyleDifference diff, const RenderStyle*

// If border was changed, notify table.
RenderTable* table = this->table();
if (table && oldStyle && oldStyle->border() != style().border())
if (table && oldStyle && !oldStyle->borderIsEquivalentForPainting(style()))
table->invalidateCollapsedBorders();
}

Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/rendering/style/RenderStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ class RenderStyle {
float borderStartWidth() const;
float borderEndWidth() const;

inline bool borderIsEquivalentForPainting(const RenderStyle&) const;

float outlineSize() const { return std::max<float>(0, outlineWidth() + outlineOffset()); }
float outlineWidth() const;
inline bool hasOutline() const;
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/style/RenderStyleInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ inline const LengthBox& RenderStyle::borderImageSlices() const { return border()
inline StyleImage* RenderStyle::borderImageSource() const { return border().image().image(); }
inline NinePieceImageRule RenderStyle::borderImageVerticalRule() const { return border().image().verticalRule(); }
inline const LengthBox& RenderStyle::borderImageWidth() const { return border().image().borderSlices(); }
inline bool RenderStyle::borderIsEquivalentForPainting(const RenderStyle& otherStyle) const { return border().isEquivalentForPainting(otherStyle.border(), color() != otherStyle.color()); }
inline const BorderValue& RenderStyle::borderLeft() const { return border().left(); }
inline const StyleColor& RenderStyle::borderLeftColor() const { return border().left().color(); }
inline bool RenderStyle::borderLeftIsTransparent() const { return border().left().isTransparent(); }
Expand Down

0 comments on commit 0b505d6

Please sign in to comment.