Title: [276135] trunk
Revision
276135
Author
[email protected]
Date
2021-04-16 06:35:08 -0700 (Fri, 16 Apr 2021)

Log Message

[IFC] Incorrect box height when scrollbar takes padding box space
https://bugs.webkit.org/show_bug.cgi?id=224546
<rdar://problem/76666402>

Reviewed by Antti Koivisto.

Source/WebCore:

This patch fixes the case when a non-overlay scrollbar can't be accomodated in the padding/content box area (e.g <div style="height: 10px; overflow: scroll">...)
In the legacy render tree the non-overlay scrollbar size is already taken into account when calling RenderBox::contentWidth/Height (paddingBoxHeight/Width), so
we just have to check how much space they actully take (currently maximum of 15px).

Test: fast/inline-block/non-overlay-scrollbar-incorrect-padding.html

* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::updateLayoutBoxDimensions):

LayoutTests:

* fast/inline-block/non-overlay-scrollbar-incorrect-padding-expected.txt: Added.
* fast/inline-block/non-overlay-scrollbar-incorrect-padding.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276134 => 276135)


--- trunk/LayoutTests/ChangeLog	2021-04-16 13:08:56 UTC (rev 276134)
+++ trunk/LayoutTests/ChangeLog	2021-04-16 13:35:08 UTC (rev 276135)
@@ -1,3 +1,14 @@
+2021-04-16  Zalan Bujtas  <[email protected]>
+
+        [IFC] Incorrect box height when scrollbar takes padding box space
+        https://bugs.webkit.org/show_bug.cgi?id=224546
+        <rdar://problem/76666402>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline-block/non-overlay-scrollbar-incorrect-padding-expected.txt: Added.
+        * fast/inline-block/non-overlay-scrollbar-incorrect-padding.html: Added.
+
 2021-04-16  Diego Pino Garcia  <[email protected]>
 
         [GLIB] Unreviewed test gardenind. Gardened several flaky failures.

Added: trunk/LayoutTests/fast/inline-block/non-overlay-scrollbar-incorrect-padding-expected.txt (0 => 276135)


--- trunk/LayoutTests/fast/inline-block/non-overlay-scrollbar-incorrect-padding-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/inline-block/non-overlay-scrollbar-incorrect-padding-expected.txt	2021-04-16 13:35:08 UTC (rev 276135)
@@ -0,0 +1 @@
+200

Added: trunk/LayoutTests/fast/inline-block/non-overlay-scrollbar-incorrect-padding.html (0 => 276135)


--- trunk/LayoutTests/fast/inline-block/non-overlay-scrollbar-incorrect-padding.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline-block/non-overlay-scrollbar-incorrect-padding.html	2021-04-16 13:35:08 UTC (rev 276135)
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<style>
+#container {
+  background-color: blue;
+  font-size: 0px;
+}
+.zero_height {
+  display: inline-block;
+  overflow: auto;
+  border: 100px solid green;
+  height: 0px;
+  width: 100px;
+}
+.content {
+  width: 100px;
+  height: 100px;
+}
+</style>
+<div id=container><div class=zero_height><div class=content></div></div></div>
+<pre id=result></pre>
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+result.innerText = container.offsetHeight;
+</script>

Modified: trunk/Source/WebCore/ChangeLog (276134 => 276135)


--- trunk/Source/WebCore/ChangeLog	2021-04-16 13:08:56 UTC (rev 276134)
+++ trunk/Source/WebCore/ChangeLog	2021-04-16 13:35:08 UTC (rev 276135)
@@ -1,3 +1,20 @@
+2021-04-16  Zalan Bujtas  <[email protected]>
+
+        [IFC] Incorrect box height when scrollbar takes padding box space
+        https://bugs.webkit.org/show_bug.cgi?id=224546
+        <rdar://problem/76666402>
+
+        Reviewed by Antti Koivisto.
+
+        This patch fixes the case when a non-overlay scrollbar can't be accomodated in the padding/content box area (e.g <div style="height: 10px; overflow: scroll">...)
+        In the legacy render tree the non-overlay scrollbar size is already taken into account when calling RenderBox::contentWidth/Height (paddingBoxHeight/Width), so
+        we just have to check how much space they actully take (currently maximum of 15px).
+
+        Test: fast/inline-block/non-overlay-scrollbar-incorrect-padding.html
+
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::updateLayoutBoxDimensions):
+
 2021-04-16  Ryosuke Niwa  <[email protected]>
 
         Deploy Ref/RefPtr in ApplyStyleCommand

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (276134 => 276135)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-04-16 13:08:56 UTC (rev 276134)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-04-16 13:35:08 UTC (rev 276135)
@@ -145,11 +145,14 @@
 
     // Always use the physical size here for inline level boxes (this is where the logical vs. physical coords flip happens).
     auto& replacedBoxGeometry = m_layoutState.ensureGeometryForBox(replacedBox);
-    // Scrollbars are placed "between" the border and the padding box and they never stretch the border box. They may shrink the padding box though.
-    auto horizontalSpaceReservedForScrollbar = std::min(replacedOrInlineBlock.width() - replacedOrInlineBlock.paddingBoxWidth(), LayoutUnit(replacedOrInlineBlock.verticalScrollbarWidth()));
+
+    // Scrollbars eat into the padding box area. They never stretch the border box but they may shrink the padding box.
+    // In legacy render tree, RenderBox::contentWidth/contentHeight values are adjusted to accomodate the scrollbar width/height.
+    // e.g. <div style="width: 10px; overflow: scroll;">content</div>, RenderBox::contentWidth() won't be returning the value of 10px but instead 0px (10px - 15px).
+    auto horizontalSpaceReservedForScrollbar = replacedOrInlineBlock.paddingBoxRectIncludingScrollbar().width() - replacedOrInlineBlock.paddingBoxWidth();
     replacedBoxGeometry.setHorizontalSpaceForScrollbar(horizontalSpaceReservedForScrollbar);
 
-    auto verticalSpaceReservedForScrollbar = std::min(replacedOrInlineBlock.height() - replacedOrInlineBlock.paddingBoxHeight(), LayoutUnit(replacedOrInlineBlock.horizontalScrollbarHeight()));
+    auto verticalSpaceReservedForScrollbar = replacedOrInlineBlock.paddingBoxRectIncludingScrollbar().height() - replacedOrInlineBlock.paddingBoxHeight();
     replacedBoxGeometry.setVerticalSpaceForScrollbar(verticalSpaceReservedForScrollbar);
 
     replacedBoxGeometry.setContentBoxWidth(replacedOrInlineBlock.contentWidth());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to