Title: [267044] branches/safari-610-branch
Revision
267044
Author
[email protected]
Date
2020-09-14 15:17:13 -0700 (Mon, 14 Sep 2020)

Log Message

Cherry-pick r266803. rdar://problem/68881014

    [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.

    Source/WebCore:

    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):

    LayoutTests:

    * 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:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266803 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610-branch/LayoutTests/ChangeLog (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/ChangeLog	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/ChangeLog	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,3 +1,83 @@
+2020-09-14  Alan Coon  <[email protected]>
+
+        Cherry-pick r266803. rdar://problem/68881014
+
+    [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.
+    
+    Source/WebCore:
+    
+    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):
+    
+    LayoutTests:
+    
+    * 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:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266803 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-11  Russell Epstein  <[email protected]>
 
         Cherry-pick r266743. rdar://problem/68652752

Modified: branches/safari-610-branch/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/compositing/shared-backing/overflow-scroll/shared-layer-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/compositing/shared-backing/overflow-scroll/shared-layer-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/compositing/shared-backing/overflow-scroll/shared-layer-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/css-custom-paint/animate-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/fast/css-custom-paint/delay-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/css-custom-paint/delay-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/css-custom-paint/delay-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/fast/images/async-image-multiple-clients-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/images/async-image-multiple-clients-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/images/async-image-multiple-clients-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-child-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-child-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-child-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 29 106 100 100)
   (rect 29 106 100 100)
-  (rect 29 106 100 100)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-parent-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-parent-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-parent-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 29 29 100 100)
   (rect 29 29 100 100)
-  (rect 29 29 100 100)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-same-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-same-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/horizontal-bt-overflow-same-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 29 21 100 100)
   (rect 29 21 100 100)
-  (rect 29 21 100 100)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/mutate-non-visible-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/mutate-non-visible-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/mutate-non-visible-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -2,6 +2,5 @@
 (repaint rects
   (rect 10 28 100 100)
   (rect 10 28 100 100)
-  (rect 10 28 100 100)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/negative-text-indent-with-overflow-hidden-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/negative-text-indent-with-overflow-hidden-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/negative-text-indent-with-overflow-hidden-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -2,6 +2,5 @@
 (repaint rects
   (rect 550 8 200 50)
   (rect 550 8 200 50)
-  (rect 550 8 200 50)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/overflow-flipped-writing-mode-table-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/overflow-flipped-writing-mode-table-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/overflow-flipped-writing-mode-table-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 8 8 100 50)
   (rect 8 8 100 50)
-  (rect 8 8 100 50)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/table-row-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/table-row-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/table-row-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 8 61 106 15)
   (rect 8 61 106 15)
-  (rect 8 61 106 15)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-child-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-child-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-child-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 214 21 100 100)
   (rect 214 21 100 100)
-  (rect 214 21 100 100)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-parent-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-parent-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-parent-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 29 29 100 100)
   (rect 29 29 100 100)
-  (rect 29 29 100 100)
 )
 

Modified: branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-same-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-same-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/fast/repaint/vertical-overflow-same-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 29 21 100 100)
   (rect 29 21 100 100)
-  (rect 29 21 100 100)
 )
 

Modified: branches/safari-610-branch/LayoutTests/platform/ios/fast/images/async-image-multiple-clients-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/platform/ios/fast/images/async-image-multiple-clients-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/platform/ios/fast/images/async-image-multiple-clients-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/columns/composited-lr-paginated-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/columns/composited-lr-paginated-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/columns/composited-lr-paginated-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/columns/composited-rl-paginated-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/columns/composited-rl-paginated-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/columns/composited-rl-paginated-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/repaint/repaint-on-layer-grouping-change-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/repaint/repaint-on-layer-grouping-change-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/platform/ios-wk2/compositing/repaint/repaint-on-layer-grouping-change-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt (267043 => 267044)


--- branches/safari-610-branch/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,6 +1,5 @@
 (repaint rects
   (rect 58 58 100 100)
   (rect 58 58 100 100)
-  (rect 58 58 100 100)
 )
 

Modified: branches/safari-610-branch/Source/WebCore/ChangeLog (267043 => 267044)


--- branches/safari-610-branch/Source/WebCore/ChangeLog	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/Source/WebCore/ChangeLog	2020-09-14 22:17:13 UTC (rev 267044)
@@ -1,5 +1,89 @@
 2020-09-14  Alan Coon  <[email protected]>
 
+        Cherry-pick r266803. rdar://problem/68881014
+
+    [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.
+    
+    Source/WebCore:
+    
+    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):
+    
+    LayoutTests:
+    
+    * 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:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266803 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-14  Alan Coon  <[email protected]>
+
         Cherry-pick r266797. rdar://problem/68881018
 
     Move lazy DisplayLink tear down logic from the WebProcess to the UIProcess

Modified: branches/safari-610-branch/Source/WebCore/rendering/RenderBox.cpp (267043 => 267044)


--- branches/safari-610-branch/Source/WebCore/rendering/RenderBox.cpp	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/Source/WebCore/rendering/RenderBox.cpp	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/Source/WebCore/rendering/RenderElement.cpp (267043 => 267044)


--- branches/safari-610-branch/Source/WebCore/rendering/RenderElement.cpp	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/Source/WebCore/rendering/RenderElement.cpp	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/Source/WebCore/rendering/RenderElement.h (267043 => 267044)


--- branches/safari-610-branch/Source/WebCore/rendering/RenderElement.h	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/Source/WebCore/rendering/RenderElement.h	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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: branches/safari-610-branch/Source/WebCore/rendering/RenderLayerModelObject.cpp (267043 => 267044)


--- branches/safari-610-branch/Source/WebCore/rendering/RenderLayerModelObject.cpp	2020-09-14 22:17:05 UTC (rev 267043)
+++ branches/safari-610-branch/Source/WebCore/rendering/RenderLayerModelObject.cpp	2020-09-14 22:17:13 UTC (rev 267044)
@@ -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();
             }
         }
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to