Title: [281136] trunk
Revision
281136
Author
an...@apple.com
Date
2021-08-17 07:11:22 -0700 (Tue, 17 Aug 2021)

Log Message

Incorrect repaint when inline level box style change triggers line height change
https://bugs.webkit.org/show_bug.cgi?id=229140
<rdar://problem/81980863>

Reviewed by Alan Bujtas.

Source/WebCore:

If an existing block shrinks vertically as a result of layout we fail to invalidate the
old content area for repaint, thus potentially leaving painting artefacts behind.
This is often hidden by the content shift triggering other repaints.

Test: fast/repaint/line-layout-block-shrink.html

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutModernLines):

Adjust the repaint area to include the content size before the layout.

LayoutTests:

* fast/repaint/line-layout-block-shrink-expected.txt: Added.
* fast/repaint/line-layout-block-shrink.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (281135 => 281136)


--- trunk/LayoutTests/ChangeLog	2021-08-17 13:47:41 UTC (rev 281135)
+++ trunk/LayoutTests/ChangeLog	2021-08-17 14:11:22 UTC (rev 281136)
@@ -1,3 +1,14 @@
+2021-08-17  Antti Koivisto  <an...@apple.com>
+
+        Incorrect repaint when inline level box style change triggers line height change
+        https://bugs.webkit.org/show_bug.cgi?id=229140
+        <rdar://problem/81980863>
+
+        Reviewed by Alan Bujtas.
+
+        * fast/repaint/line-layout-block-shrink-expected.txt: Added.
+        * fast/repaint/line-layout-block-shrink.html: Added.
+
 2021-08-17  Jean-Yves Avenard  <j...@apple.com>
 
         Implement API to ensure MediaRemote key mapping is correct

Added: trunk/LayoutTests/fast/repaint/line-layout-block-shrink-expected.txt (0 => 281136)


--- trunk/LayoutTests/fast/repaint/line-layout-block-shrink-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/repaint/line-layout-block-shrink-expected.txt	2021-08-17 14:11:22 UTC (rev 281136)
@@ -0,0 +1,5 @@
+PASS if you see this text only once.
+(repaint rects
+  (rect 8 8 784 404)
+)
+

Added: trunk/LayoutTests/fast/repaint/line-layout-block-shrink.html (0 => 281136)


--- trunk/LayoutTests/fast/repaint/line-layout-block-shrink.html	                        (rev 0)
+++ trunk/LayoutTests/fast/repaint/line-layout-block-shrink.html	2021-08-17 14:11:22 UTC (rev 281136)
@@ -0,0 +1,13 @@
+<script src=""
+<style>
+  img {
+    height: 400px;
+  }
+</style>
+<img id=changeThis>PASS if you see this text only once.
+<script>
+function repaintTest() {
+    changeThis.style.height = "0px";
+}
+_onload_ = runRepaintTest;
+</script>

Modified: trunk/Source/WebCore/ChangeLog (281135 => 281136)


--- trunk/Source/WebCore/ChangeLog	2021-08-17 13:47:41 UTC (rev 281135)
+++ trunk/Source/WebCore/ChangeLog	2021-08-17 14:11:22 UTC (rev 281136)
@@ -1,3 +1,22 @@
+2021-08-17  Antti Koivisto  <an...@apple.com>
+
+        Incorrect repaint when inline level box style change triggers line height change
+        https://bugs.webkit.org/show_bug.cgi?id=229140
+        <rdar://problem/81980863>
+
+        Reviewed by Alan Bujtas.
+
+        If an existing block shrinks vertically as a result of layout we fail to invalidate the
+        old content area for repaint, thus potentially leaving painting artefacts behind.
+        This is often hidden by the content shift triggering other repaints.
+
+        Test: fast/repaint/line-layout-block-shrink.html
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::layoutModernLines):
+
+        Adjust the repaint area to include the content size before the layout.
+
 2021-08-17  Philippe Normand  <pnorm...@igalia.com>
 
         REGRESSION(r218083): [GStreamer] webrtc unexpected failures

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (281135 => 281136)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2021-08-17 13:47:41 UTC (rev 281135)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2021-08-17 14:11:22 UTC (rev 281136)
@@ -3731,24 +3731,33 @@
         renderer.clearNeedsLayout();
     }
 
+    auto contentBoxTop = borderAndPaddingBefore();
+
+    auto computeContentHeight = [&] {
+        if (!hasLines() && hasLineIfEmpty())
+            return lineHeight(true, isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
+
+        return layoutFormattingContextLineLayout.contentLogicalHeight();
+    };
+
+    auto computeBorderBoxBottom = [&] {
+        auto contentBoxBottom = contentBoxTop + computeContentHeight();
+        return contentBoxBottom + borderAndPaddingAfter();
+    };
+
+    auto oldBorderBoxBottom = computeBorderBoxBottom();
+
     layoutFormattingContextLineLayout.layout();
 
     if (view().frameView().layoutContext().layoutState()->isPaginated())
         layoutFormattingContextLineLayout.adjustForPagination();
 
-    auto contentHeight = [&] {
-        if (!hasLines() && hasLineIfEmpty())
-            return lineHeight(true, isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
-        
-        return layoutFormattingContextLineLayout.contentLogicalHeight();
-    }();
-    auto contentBoxTop = borderAndPaddingBefore();
-    auto contentBoxBottom = contentBoxTop + contentHeight;
-    auto borderBoxBottom = contentBoxBottom + borderAndPaddingAfter();
+    auto newBorderBoxBottom = computeBorderBoxBottom();
 
     repaintLogicalTop = contentBoxTop;
-    repaintLogicalBottom = borderBoxBottom;
-    setLogicalHeight(borderBoxBottom);
+    repaintLogicalBottom = std::max(oldBorderBoxBottom, newBorderBoxBottom);
+
+    setLogicalHeight(newBorderBoxBottom);
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to