Diff
Modified: trunk/LayoutTests/ChangeLog (266802 => 266803)
--- trunk/LayoutTests/ChangeLog 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/ChangeLog 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,3 +1,28 @@
+2020-09-09 Zalan Bujtas <[email protected]>
+
+ [Repaint] styleWillChange may call repaint on the same renderer multiple times.
+ https://bugs.webkit.org/show_bug.cgi?id=216295
+ <rdar://problem/68538666>
+
+ Reviewed by Simon Fraser.
+
+ * compositing/masks/compositing-clip-path-change-no-repaint-expected.txt:
+ * compositing/shared-backing/overflow-scroll/shared-layer-repaint-expected.txt:
+ * fast/css-custom-paint/delay-repaint-expected.txt:
+ * fast/images/async-image-multiple-clients-repaint-expected.txt:
+ * fast/repaint/focus-ring-repaint-expected.txt:
+ * fast/repaint/horizontal-bt-overflow-child-expected.txt:
+ * fast/repaint/horizontal-bt-overflow-parent-expected.txt:
+ * fast/repaint/horizontal-bt-overflow-same-expected.txt:
+ * fast/repaint/mutate-non-visible-expected.txt:
+ * fast/repaint/negative-text-indent-with-overflow-hidden-expected.txt:
+ * fast/repaint/overflow-flipped-writing-mode-table-expected.txt:
+ * fast/repaint/table-row-repaint-expected.txt:
+ * fast/repaint/vertical-overflow-child-expected.txt:
+ * fast/repaint/vertical-overflow-parent-expected.txt:
+ * fast/repaint/vertical-overflow-same-expected.txt:
+ * svg/transforms/svg-transform-foreign-object-repaint-expected.txt:
+
2020-09-09 Sam Weinig <[email protected]>
[WebIDL] Split GlobalEventHandlers partial interface mixins out of base mixin
Modified: trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -30,13 +30,11 @@
(repaint rects
(rect 0.00 0.00 300.00 300.00)
(rect 0.00 0.00 300.00 300.00)
- (rect 0.00 0.00 300.00 300.00)
)
)
(repaint rects
(rect 0.00 0.00 300.00 300.00)
(rect 0.00 0.00 300.00 300.00)
- (rect 0.00 0.00 300.00 300.00)
)
)
)
Modified: trunk/LayoutTests/compositing/shared-backing/overflow-scroll/shared-layer-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/compositing/shared-backing/overflow-scroll/shared-layer-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/compositing/shared-backing/overflow-scroll/shared-layer-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -19,7 +19,6 @@
(repaint rects
(rect 151.00 81.00 71.00 110.00)
(rect 151.00 81.00 71.00 110.00)
- (rect 151.00 81.00 71.00 110.00)
)
)
)
Modified: trunk/LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -2,6 +2,5 @@
(rect 0 0 800 600)
(rect 8 8 150 150)
(rect 8 8 150 150)
- (rect 8 8 150 150)
)
Modified: trunk/LayoutTests/fast/css-custom-paint/delay-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/css-custom-paint/delay-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/css-custom-paint/delay-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -2,6 +2,5 @@
(rect 0 0 800 600)
(rect 8 8 150 150)
(rect 8 8 150 150)
- (rect 8 8 150 150)
)
Modified: trunk/LayoutTests/fast/images/async-image-multiple-clients-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/images/async-image-multiple-clients-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/images/async-image-multiple-clients-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -5,6 +5,5 @@
(rect 8 344 200 100)
(rect 8 344 200 100)
(rect 8 344 200 100)
- (rect 8 344 200 100)
)
Modified: trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -7,7 +7,6 @@
(repaint rects
(rect 5 457 103 67)
- (rect 5 457 103 67)
(rect 5 457 106 70)
(rect 5 542 106 70)
(rect 15 62 36 40)
Modified: trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-child-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-child-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-child-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 29 106 100 100)
(rect 29 106 100 100)
- (rect 29 106 100 100)
)
Modified: trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-parent-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-parent-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-parent-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 29 29 100 100)
(rect 29 29 100 100)
- (rect 29 29 100 100)
)
Modified: trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-same-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-same-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/horizontal-bt-overflow-same-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 29 21 100 100)
(rect 29 21 100 100)
- (rect 29 21 100 100)
)
Modified: trunk/LayoutTests/fast/repaint/mutate-non-visible-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/mutate-non-visible-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/mutate-non-visible-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -2,6 +2,5 @@
(repaint rects
(rect 10 28 100 100)
(rect 10 28 100 100)
- (rect 10 28 100 100)
)
Modified: trunk/LayoutTests/fast/repaint/negative-text-indent-with-overflow-hidden-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/negative-text-indent-with-overflow-hidden-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/negative-text-indent-with-overflow-hidden-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -2,6 +2,5 @@
(repaint rects
(rect 550 8 200 50)
(rect 550 8 200 50)
- (rect 550 8 200 50)
)
Modified: trunk/LayoutTests/fast/repaint/overflow-flipped-writing-mode-table-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/overflow-flipped-writing-mode-table-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/overflow-flipped-writing-mode-table-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 8 8 100 50)
(rect 8 8 100 50)
- (rect 8 8 100 50)
)
Modified: trunk/LayoutTests/fast/repaint/table-row-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/table-row-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/table-row-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 8 61 106 15)
(rect 8 61 106 15)
- (rect 8 61 106 15)
)
Modified: trunk/LayoutTests/fast/repaint/vertical-overflow-child-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/vertical-overflow-child-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/vertical-overflow-child-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 214 21 100 100)
(rect 214 21 100 100)
- (rect 214 21 100 100)
)
Modified: trunk/LayoutTests/fast/repaint/vertical-overflow-parent-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/vertical-overflow-parent-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/vertical-overflow-parent-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 29 29 100 100)
(rect 29 29 100 100)
- (rect 29 29 100 100)
)
Modified: trunk/LayoutTests/fast/repaint/vertical-overflow-same-expected.txt (266802 => 266803)
--- trunk/LayoutTests/fast/repaint/vertical-overflow-same-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/fast/repaint/vertical-overflow-same-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 29 21 100 100)
(rect 29 21 100 100)
- (rect 29 21 100 100)
)
Modified: trunk/LayoutTests/platform/ios/fast/images/async-image-multiple-clients-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/platform/ios/fast/images/async-image-multiple-clients-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/platform/ios/fast/images/async-image-multiple-clients-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -5,6 +5,5 @@
(rect 8 348 200 100)
(rect 8 348 200 100)
(rect 8 348 200 100)
- (rect 8 348 200 100)
)
Modified: trunk/LayoutTests/platform/ios-wk2/compositing/columns/composited-lr-paginated-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/platform/ios-wk2/compositing/columns/composited-lr-paginated-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/platform/ios-wk2/compositing/columns/composited-lr-paginated-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -14,7 +14,6 @@
(repaint rects
(rect 27.00 25.00 52.00 77.00)
(rect 27.00 25.00 52.00 77.00)
- (rect 27.00 25.00 52.00 77.00)
)
)
)
Modified: trunk/LayoutTests/platform/ios-wk2/compositing/columns/composited-rl-paginated-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/platform/ios-wk2/compositing/columns/composited-rl-paginated-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/platform/ios-wk2/compositing/columns/composited-rl-paginated-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -16,7 +16,6 @@
(repaint rects
(rect 27.00 25.00 52.00 77.00)
(rect 27.00 25.00 52.00 77.00)
- (rect 27.00 25.00 52.00 77.00)
)
)
)
Modified: trunk/LayoutTests/platform/ios-wk2/compositing/repaint/repaint-on-layer-grouping-change-expected.txt (266802 => 266803)
--- trunk/LayoutTests/platform/ios-wk2/compositing/repaint/repaint-on-layer-grouping-change-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/platform/ios-wk2/compositing/repaint/repaint-on-layer-grouping-change-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -26,7 +26,6 @@
(drawsContent 1)
(repaint rects
(rect 490.00 190.00 50.00 50.00)
- (rect 490.00 190.00 50.00 50.00)
(rect 0.00 0.00 50.00 50.00)
)
)
Modified: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt (266802 => 266803)
--- trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,6 +1,5 @@
(repaint rects
(rect 58 58 100 100)
(rect 58 58 100 100)
- (rect 58 58 100 100)
)
Modified: trunk/Source/WebCore/ChangeLog (266802 => 266803)
--- trunk/Source/WebCore/ChangeLog 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/Source/WebCore/ChangeLog 2020-09-09 22:45:45 UTC (rev 266803)
@@ -1,3 +1,32 @@
+2020-09-09 Zalan Bujtas <[email protected]>
+
+ [Repaint] styleWillChange may call repaint on the same renderer multiple times.
+ https://bugs.webkit.org/show_bug.cgi?id=216295
+ <rdar://problem/68538666>
+
+ Reviewed by Simon Fraser.
+
+ RenderElement::styleWillChange is a virtual function. This function is called whenever the associated RenderStyle changes.
+ The subclass implementation (e.g. RenderBox::styleWillChange) calls the parent class to make sure the style change is covered properly.
+ Now in certain cases,
+ 1. this may trigger multiple calls to repaint() (e.g one in each ::styleWillChange implementation)
+ 2. paint invalidation requires absolute coordinates
+ 3. geometry does not change during styleWillChange
+ it could end up being redundant/unnecessarily expensive.
+
+ This patch moves all the style-will-change-requires-repaint logic to one single function so that we can limit the number of repaints.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::styleWillChange):
+ * rendering/RenderElement.cpp:
+ (WebCore::RenderElement::issueRepaintBeforeStyleChange):
+ (WebCore::RenderElement::initializeStyle):
+ (WebCore::RenderElement::setStyle):
+ (WebCore::RenderElement::styleWillChange):
+ * rendering/RenderElement.h:
+ * rendering/RenderLayerModelObject.cpp:
+ (WebCore::RenderLayerModelObject::styleWillChange):
+
2020-09-09 Sam Weinig <[email protected]>
[WebIDL] Split GlobalEventHandlers partial interface mixins out of base mixin
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (266802 => 266803)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2020-09-09 22:45:45 UTC (rev 266803)
@@ -269,9 +269,7 @@
// to dirty the render tree using the old position value now.
if (diff == StyleDifference::Layout && parent() && oldStyle->position() != newStyle.position()) {
markContainingBlocksForLayout();
- if (oldStyle->position() == PositionType::Static)
- repaint();
- else if (newStyle.hasOutOfFlowPosition())
+ if (oldStyle->position() != PositionType::Static && newStyle.hasOutOfFlowPosition())
parent()->setChildNeedsLayout();
if (isFloating() && !isOutOfFlowPositioned() && newStyle.hasOutOfFlowPosition())
removeFloatingOrPositionedChildFromBlockLists();
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (266802 => 266803)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2020-09-09 22:45:45 UTC (rev 266803)
@@ -380,6 +380,41 @@
updateImage(oldShapeValue ? oldShapeValue->image() : nullptr, newShapeValue ? newShapeValue->image() : nullptr);
}
+void RenderElement::repaintBeforeStyleChange(StyleDifference diff, const RenderStyle& oldStyle, const RenderStyle& newStyle)
+{
+ auto repaintBeforeStyleChange = [&] {
+ if (!parent()) {
+ // Can't resolve absolute coordinates.
+ return false;
+ }
+ if (shouldRepaintForStyleDifference(diff))
+ return true;
+ if (newStyle.outlineSize() < oldStyle.outlineSize())
+ return true;
+ if (is<RenderLayerModelObject>(*this)) {
+ // If we don't have a layer yet, but we are going to get one because of transform or opacity, then we need to repaint the old position of the object.
+ bool hasLayer = downcast<RenderLayerModelObject>(*this).hasLayer();
+ bool willHaveLayer = newStyle.hasTransform() || newStyle.opacity() < 1 || newStyle.hasFilter() || newStyle.hasBackdropFilter();
+ if (!hasLayer && willHaveLayer)
+ return true;
+ }
+ if (is<RenderBox>(*this)) {
+ if (diff == StyleDifference::Layout && oldStyle.position() != newStyle.position() && oldStyle.position() == PositionType::Static)
+ return true;
+ }
+ if (diff > StyleDifference::RepaintLayer && oldStyle.visibility() != newStyle.visibility()) {
+ if (auto* enclosingLayer = this->enclosingLayer()) {
+ auto rendererWillBeHidden = newStyle.visibility() != Visibility::Visible;
+ if (rendererWillBeHidden && enclosingLayer->hasVisibleContent() && (this == &enclosingLayer->renderer() || enclosingLayer->renderer().style().visibility() != Visibility::Visible))
+ return true;
+ }
+ }
+ return false;
+ }();
+ if (repaintBeforeStyleChange)
+ repaint();
+}
+
void RenderElement::initializeStyle()
{
Style::loadPendingResources(m_style, document(), element());
@@ -413,6 +448,7 @@
Style::loadPendingResources(style, document(), element());
+ repaintBeforeStyleChange(diff, m_style, style);
styleWillChange(diff, style);
auto oldStyle = m_style.replace(WTFMove(style));
bool detachedFromParent = !parent();
@@ -728,11 +764,8 @@
if (RenderLayer* layer = enclosingLayer()) {
if (newStyle.visibility() == Visibility::Visible)
layer->setHasVisibleContent();
- else if (layer->hasVisibleContent() && (this == &layer->renderer() || layer->renderer().style().visibility() != Visibility::Visible)) {
+ else if (layer->hasVisibleContent() && (this == &layer->renderer() || layer->renderer().style().visibility() != Visibility::Visible))
layer->dirtyVisibleContentStatus();
- if (diff > StyleDifference::RepaintLayer)
- repaint();
- }
}
}
@@ -760,9 +793,6 @@
layer->invalidateEventRegion(RenderLayer::EventRegionInvalidationReason::Style);
}
- if (m_parent && (newStyle.outlineSize() < m_style.outlineSize() || shouldRepaintForStyleDifference(diff)))
- repaint();
-
if (isFloating() && m_style.floating() != newStyle.floating()) {
// For changes in float styles, we need to conceivably remove ourselves
// from the floating objects list.
Modified: trunk/Source/WebCore/rendering/RenderElement.h (266802 => 266803)
--- trunk/Source/WebCore/rendering/RenderElement.h 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/Source/WebCore/rendering/RenderElement.h 2020-09-09 22:45:45 UTC (rev 266803)
@@ -259,6 +259,8 @@
void setFirstChild(RenderObject* child) { m_firstChild = child; }
void setLastChild(RenderObject* child) { m_lastChild = child; }
+ void repaintBeforeStyleChange(StyleDifference, const RenderStyle& oldStyle, const RenderStyle& newStyle);
+
virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
Modified: trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp (266802 => 266803)
--- trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp 2020-09-09 22:19:10 UTC (rev 266802)
+++ trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp 2020-09-09 22:45:45 UTC (rev 266803)
@@ -124,8 +124,7 @@
layer()->repaintIncludingDescendants();
if (!(oldStyle->clip() == newStyle.clip()))
layer()->clearClipRectsIncludingDescendants();
- } else if (diff == StyleDifference::Repaint || newStyle.outlineSize() < oldStyle->outlineSize())
- repaint();
+ }
}
if (diff == StyleDifference::Layout || diff == StyleDifference::SimplifiedLayout) {
@@ -141,10 +140,6 @@
|| oldStyle->filter() != newStyle.filter()
)
layer()->repaintIncludingDescendants();
- } else if (newStyle.hasTransform() || newStyle.opacity() < 1 || newStyle.hasFilter() || newStyle.hasBackdropFilter()) {
- // If we don't have a layer yet, but we are going to get one because of transform or opacity,
- // then we need to repaint the old position of the object.
- repaint();
}
}
}