Skip to content

Commit

Permalink
Avoid some repaints in RenderElement::repaintAfterLayoutIfNeeded()
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264275
rdar://118014812

Reviewed by Alan Baradlay.

In RenderElement::repaintAfterLayoutIfNeeded(), we repaint both the old and the new clippedOverflowRect in the
`fullRepaint` code path. But these rectangles might overlap; we only need to repaint both if one does not
contain the other. The `contains` checks also take care of the equality check.

* LayoutTests/fast/css-grid-layout/grid-element-change-columns-repaint-expected.txt:
* LayoutTests/fast/css-grid-layout/grid-element-change-rows-repaint-expected.txt:
* LayoutTests/fast/css-grid-layout/grid-item-change-column-repaint-expected.txt:
* LayoutTests/fast/css-grid-layout/grid-item-change-row-repaint-expected.txt:
* LayoutTests/fast/repaint/align-items-overflow-change-expected.txt:
* LayoutTests/fast/repaint/border-radius-repaint-2-expected.txt:
* LayoutTests/fast/repaint/focus-ring-repaint-expected.txt:
* LayoutTests/fast/repaint/justify-items-change-expected.txt:
* LayoutTests/fast/repaint/justify-items-legacy-change-expected.txt:
* LayoutTests/fast/repaint/justify-items-overflow-change-expected.txt:
* LayoutTests/fast/repaint/justify-self-change-expected.txt:
* LayoutTests/fast/repaint/reflection-table-layout-expected.txt:
* LayoutTests/fast/repaint/repaint-float-only-and-moves-expected.txt:
* LayoutTests/fast/repaint/text-content-shrinks-repaint-expected.txt:
* LayoutTests/fast/repaint/text-content-shrinks-repaint.html:
* LayoutTests/fast/repaint/transform-table-layout-expected.txt:
* LayoutTests/platform/ios-wk2/fast/repaint/focus-ring-repaint-expected.txt:
* LayoutTests/platform/ios-wk2/fast/repaint/placeholder-after-caps-lock-hidden-expected.txt:
* LayoutTests/platform/ios-wk2/fast/repaint/text-content-shrinks-repaint-expected.txt: Copied from LayoutTests/fast/repaint/text-content-shrinks-repaint-expected.txt.
* LayoutTests/platform/ios/fast/repaint/border-radius-repaint-2-expected.txt:
* LayoutTests/platform/mac-wk1/fast/repaint/border-radius-repaint-2-expected.txt:
* LayoutTests/platform/mac-wk2/fast/repaint/placeholder-after-caps-lock-hidden-expected.txt:
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::repaintAfterLayoutIfNeeded):

Canonical link: https://commits.webkit.org/270370@main
  • Loading branch information
smfr committed Nov 8, 2023
1 parent c150417 commit e1044db
Show file tree
Hide file tree
Showing 28 changed files with 55 additions and 99 deletions.
1 change: 0 additions & 1 deletion LayoutTests/fast/box-shadow/shadow-repaint-expected.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Repaint rects:

(repaint rects
(rect 38 30 100 100)
(rect 20 12 156 156)
(rect 8 12 784 18)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
This test checks that changing the grid-template-columns lead to a repaint. The final grid element should be 250px * 50px, the grid item should be 50px * 50px. No trace of the elements before the grid-template-columns change should be seen.
(repaint rects
(rect 8 48 100 50)
(rect 8 48 50 50)
(rect 8 48 250 50)
)

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
This test checks that changing the grid-template-rows lead to a repaint. The final grid element should be 100px * 150px, the grid item should be 100px * 100px. No trace of the elements before the grid-template-rows change should be seen.
(repaint rects
(rect 8 48 100 50)
(rect 8 48 100 100)
(rect 8 48 100 150)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
This test checks that changing the grid-column on a grid item properly repaint. The final grid item should be 50px * 50px. There should be no trace of the grid item at the old position.
(repaint rects
(rect 8 38 100 50)
(rect 8 38 50 50)
(rect 8 38 100 50)
(rect 208 38 50 50)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
This test checks that changing the grid-row on a grid item properly repaint. The final grid item should be 100px * 100px. There should be no trace of the grid item at the old position.
(repaint rects
(rect 8 38 100 50)
(rect 8 38 100 100)
(rect 8 38 100 50)
(rect 8 88 100 100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Tests invalidation on align-items style change (just overflow). Passes if there

(repaint rects
(rect 0 2 200 350)
(rect 0 52 200 300)
(rect 0 2 800 14)
)

2 changes: 0 additions & 2 deletions LayoutTests/fast/repaint/border-radius-repaint-2-expected.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
(repaint rects
(rect 18 44 120 550)
(rect 18 44 120 40)
(rect 8 8 140 622)
(rect 8 8 140 112)
(rect 8 120 769 510)
(rect 0 0 800 600)
(rect 0 0 800 600)
Expand Down
6 changes: 0 additions & 6 deletions LayoutTests/fast/repaint/focus-ring-repaint-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@
(rect 8 545 100 64)
(rect 15 62 36 36)
(rect 18 65 30 30)
(rect 15 62 36 26)
(rect 18 65 30 20)
(rect 5 89 56 10)
(rect 5 35 56 64)
(rect 5 117 36 56)
(rect 8 120 30 50)
(rect 5 117 36 86)
(rect 8 120 30 80)
(rect 5 174 56 30)
(rect 5 120 56 84)
(rect 5 205 56 34)
(rect 5 375 56 34)
(rect 5 457 103 67)
(rect 8 460 100 64)
(rect 8 545 100 64)
(rect 5 542 103 67)
(rect 45 212 36 36)
(rect 48 215 30 30)
Expand Down
1 change: 0 additions & 1 deletion LayoutTests/fast/repaint/justify-items-change-expected.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Tests invalidation on justify-items style change. Passes if there is no red.

(repaint rects
(rect 150 52 50 300)
(rect 150 52 200 300)
(rect 0 52 200 300)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Tests invalidation on justify-items style change (legacy value). Passes if green
(rect 0 52 52 100)
(rect 151 53 50 50)
(rect 150 52 52 100)
(rect 0 52 202 300)
(rect 0 52 251 300)
(rect 0 52 300 400)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Tests invalidation on justify-items style change. Passes if there is no red.

(repaint rects
(rect -60 52 260 300)
(rect 0 52 200 300)
(rect -60 16 60 336)
(rect -60 0 60 352)
)
Expand Down
2 changes: 0 additions & 2 deletions LayoutTests/fast/repaint/justify-self-change-expected.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
Tests invalidation on justify-self style change. Passes if there is no red.

(repaint rects
(rect 24 52 52 300)
(rect 24 52 100 300)
(rect 24 52 52 300)
(rect 0 52 100 300)
(rect 124 52 52 300)
(rect 124 52 100 300)
(rect 124 52 52 300)
(rect 100 52 100 300)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ Tests that the placeholder text is repainted when the caps lock indicator is hid


(repaint rects
(rect 31 50 22 22)
(rect 36 55 12 12)
(rect 8 50 33 23)
(rect 13 55 23 13)
(rect 8 50 45 23)
(rect 13 55 35 13)
(rect 31 50 22 23)
(rect 36 55 12 13)
(rect 8 50 45 23)
(rect 13 55 35 13)
(rect 8 50 33 23)
(rect 13 55 23 13)
(rect 8 50 45 23)
(rect 13 55 35 13)
(rect 26 46 27 27)
(rect 31 51 17 17)
(rect 6 46 47 23)
(rect 11 53 37 13)
(rect 26 46 27 23)
(rect 31 53 17 13)
(rect 6 44 47 27)
(rect 11 51 37 17)
(rect 6 46 47 27)
(rect 11 51 37 17)
(rect 6 48 47 23)
(rect 11 53 37 13)
(rect 6 48 47 23)
(rect 11 53 37 13)
)

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(repaint rects
(rect 7 8 2 1)
(rect 6 8 4 2)
(rect -92 9 200 1)
(rect -92 8 200 2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(repaint rects
(rect 8 8 100 50)
(rect 8 8 200 50)
(rect 8 8 200 50)
(rect 108 8 100 100)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Pass if this line is properly repainted.
PASS
(repaint rects
(rect 8 8 480 23)
)

2 changes: 1 addition & 1 deletion LayoutTests/fast/repaint/text-content-shrinks-repaint.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
var repaintRects = internals.repaintRectsAsText();
internals.stopTrackingRepaints();
var pre = document.createElement('pre');
pre.innerText = repaintRects;
document.body.appendChild(pre);
pre.innerText = repaintRects.indexOf("8 8 108 23") != -1 ? "PASS" : "FAIL";
}

if (window.testRunner)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(repaint rects
(rect 8 108 1 1)
(rect 8 108 2 2)
(rect 8 109 100 1)
(rect 8 108 100 2)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Repaint rects:

(repaint rects
(rect 20 12 156 156)
(rect 8 12 784 18)
)

Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@


(repaint rects
(rect 5 457 103 67)
(rect 5 457 106 70)
(rect 5 542 106 70)
(rect 5 457 103 68)
(rect 5 457 106 66)
(rect 5 457 103 68)
(rect 5 542 106 66)
(rect 8 545 100 65)
(rect 15 62 36 36)
(rect 18 65 30 30)
(rect 15 62 36 26)
(rect 18 65 30 20)
(rect 5 89 56 10)
(rect 5 35 56 64)
(rect 5 117 36 56)
(rect 8 120 30 50)
(rect 5 90 56 10)
(rect 5 35 56 65)
(rect 5 117 36 86)
(rect 8 120 30 80)
(rect 5 174 56 30)
(rect 5 120 56 84)
(rect 5 205 56 34)
(rect 5 375 56 34)
(rect 5 457 103 67)
(rect 8 460 100 64)
(rect 8 545 100 64)
(rect 5 542 103 67)
(rect 5 175 56 30)
(rect 5 120 56 85)
(rect 5 205 56 35)
(rect 5 375 56 35)
(rect 5 457 103 68)
(rect 5 542 103 68)
(rect 45 212 36 36)
(rect 48 215 30 30)
(rect 155 212 36 36)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@ Tests that the placeholder text is repainted when the caps lock indicator is hid
(repaint rects
(rect 31.50 52.50 23 23)
(rect 34.50 55.50 17 17)
(rect 11.50 52.50 26 20)
(rect 14.50 57 20 14)
(rect 11.50 52.50 43 20)
(rect 14.50 57 37 14)
(rect 31.50 52.50 23 20)
(rect 34.50 57 17 14)
(rect 11.50 51 43 23)
(rect 14.50 55.50 37 17)
(rect 11.50 51 43 20)
(rect 14.50 55.50 37 14)
(rect 11.50 52.50 43 23)
(rect 14.50 55.50 37 17)
(rect 11.50 54 43 20)
(rect 14.50 57 37 14)
(rect 11.50 54 26 20)
(rect 14.50 57 20 14)
(rect 11.50 54 43 20)
(rect 14.50 57 37 14)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Pass if this line is properly repainted.
(repaint rects
(rect 8 8 480 21)
)

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
(repaint rects
(rect 18 44 120 550)
(rect 18 44 120 40)
(rect 8 8 140 622)
(rect 8 8 140 112)
(rect 8 120 784 510)
(rect 0 128 800 510)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@ Tests that the placeholder text is repainted when the caps lock indicator is hid
(repaint rects
(rect 25 46 27 27)
(rect 30 51 17 17)
(rect 6 46 29 23)
(rect 11 53 19 13)
(rect 6 46 46 23)
(rect 11 53 36 13)
(rect 25 46 27 23)
(rect 30 53 17 13)
(rect 6 44 46 27)
(rect 11 51 36 17)
(rect 6 44 46 23)
(rect 11 51 36 13)
(rect 6 46 46 27)
(rect 11 51 36 17)
(rect 6 48 46 23)
(rect 11 53 36 13)
(rect 6 48 29 23)
(rect 11 53 19 13)
(rect 6 48 46 23)
(rect 11 53 36 13)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
(repaint rects
(rect 18 44 120 550)
(rect 18 44 120 40)
(rect 8 8 140 622)
(rect 8 8 140 112)
(rect 8 120 769 510)
(rect 0 128 785 510)
(rect 785 0 15 600)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Tests that the placeholder text is repainted when the caps lock indicator is hidden.



This file was deleted.

9 changes: 7 additions & 2 deletions Source/WebCore/rendering/RenderElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,9 +1271,14 @@ bool RenderElement::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* rep
repaintContainer = &view();

if (fullRepaint) {
repaintUsingContainer(repaintContainer, oldClippedOverflowRect);
if (newClippedOverflowRect != oldClippedOverflowRect)
if (newClippedOverflowRect.contains(oldClippedOverflowRect))
repaintUsingContainer(repaintContainer, newClippedOverflowRect);
else if (oldClippedOverflowRect.contains(newClippedOverflowRect))
repaintUsingContainer(repaintContainer, oldClippedOverflowRect);
else {
repaintUsingContainer(repaintContainer, oldClippedOverflowRect);
repaintUsingContainer(repaintContainer, newClippedOverflowRect);
}
return true;
}

Expand Down

0 comments on commit e1044db

Please sign in to comment.