Title: [240218] trunk/Source/WebCore
Revision
240218
Author
simon.fra...@apple.com
Date
2019-01-20 17:06:52 -0800 (Sun, 20 Jan 2019)

Log Message

On RenderBox, make client sizing be derived from padding box sizing
https://bugs.webkit.org/show_bug.cgi?id=193621

Reviewed by Daniel Bates.

I never liked how clientWidth/Height, an IE-originated term, was used as the basis
for various RenderBox geometry functions.

Fix by adding some functions which return the dimensions of the padding box (which
is the inside of the border and any scrollbar), and define clientWidth/Height in
terms of them.

Also add paddingBoxRectIncludingScrollbar() function that is used by compositing code.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::clientWidth const):
(WebCore::RenderBox::clientHeight const):
* rendering/RenderBox.h:
(WebCore::RenderBox::borderBoxRect const):
(WebCore::RenderBox::computedCSSContentBoxRect const):
(WebCore::RenderBox::contentWidth const):
(WebCore::RenderBox::contentHeight const):
(WebCore::RenderBox::paddingBoxWidth const):
(WebCore::RenderBox::paddingBoxHeight const):
(WebCore::RenderBox::paddingBoxRect const):
(WebCore::RenderBox::paddingBoxRectIncludingScrollbar const):
(WebCore::RenderBox::hasHorizontalOverflow const):
(WebCore::RenderBox::hasVerticalOverflow const):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::computeParentGraphicsLayerRect const):
(WebCore::RenderLayerBacking::updateGeometry):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240217 => 240218)


--- trunk/Source/WebCore/ChangeLog	2019-01-20 21:15:42 UTC (rev 240217)
+++ trunk/Source/WebCore/ChangeLog	2019-01-21 01:06:52 UTC (rev 240218)
@@ -1,3 +1,37 @@
+2019-01-20  Simon Fraser  <simon.fra...@apple.com>
+
+        On RenderBox, make client sizing be derived from padding box sizing
+        https://bugs.webkit.org/show_bug.cgi?id=193621
+
+        Reviewed by Daniel Bates.
+
+        I never liked how clientWidth/Height, an IE-originated term, was used as the basis
+        for various RenderBox geometry functions.
+
+        Fix by adding some functions which return the dimensions of the padding box (which
+        is the inside of the border and any scrollbar), and define clientWidth/Height in
+        terms of them.
+
+        Also add paddingBoxRectIncludingScrollbar() function that is used by compositing code.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::clientWidth const):
+        (WebCore::RenderBox::clientHeight const):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::borderBoxRect const):
+        (WebCore::RenderBox::computedCSSContentBoxRect const):
+        (WebCore::RenderBox::contentWidth const):
+        (WebCore::RenderBox::contentHeight const):
+        (WebCore::RenderBox::paddingBoxWidth const):
+        (WebCore::RenderBox::paddingBoxHeight const):
+        (WebCore::RenderBox::paddingBoxRect const):
+        (WebCore::RenderBox::paddingBoxRectIncludingScrollbar const):
+        (WebCore::RenderBox::hasHorizontalOverflow const):
+        (WebCore::RenderBox::hasVerticalOverflow const):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::computeParentGraphicsLayerRect const):
+        (WebCore::RenderLayerBacking::updateGeometry):
+
 2019-01-20  Michael Catanzaro  <mcatanz...@igalia.com>
 
         Unreviewed, rolling out r238275.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (240217 => 240218)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2019-01-20 21:15:42 UTC (rev 240217)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2019-01-21 01:06:52 UTC (rev 240218)
@@ -526,12 +526,12 @@
 // excluding border and scrollbar.
 LayoutUnit RenderBox::clientWidth() const
 {
-    return width() - borderLeft() - borderRight() - verticalScrollbarWidth();
+    return paddingBoxWidth();
 }
 
 LayoutUnit RenderBox::clientHeight() const
 {
-    return height() - borderTop() - borderBottom() - horizontalScrollbarHeight();
+    return paddingBoxHeight();
 }
 
 int RenderBox::scrollWidth() const

Modified: trunk/Source/WebCore/rendering/RenderBox.h (240217 => 240218)


--- trunk/Source/WebCore/rendering/RenderBox.h	2019-01-20 21:15:42 UTC (rev 240217)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2019-01-21 01:06:52 UTC (rev 240218)
@@ -151,7 +151,6 @@
         return LayoutRect(-marginLeft, -marginTop, size().width() + marginLeft + marginRight, size().height() + marginTop + marginBottom);
     }
     LayoutRect borderBoxRect() const { return LayoutRect(LayoutPoint(), size()); }
-    LayoutRect paddingBoxRect() const { return LayoutRect(borderLeft(), borderTop(), contentWidth() + paddingLeft() + paddingRight(), contentHeight() + paddingTop() + paddingBottom()); }
     LayoutRect borderBoundingBox() const final { return borderBoxRect(); }
 
     WEBCORE_EXPORT RoundedRect::Radii borderRadii() const;
@@ -167,7 +166,7 @@
 
     // This returns the content area of the box (excluding padding and border). The only difference with contentBoxRect is that computedCSSContentBoxRect
     // does include the intrinsic padding in the content box as this is what some callers expect (like getComputedStyle).
-    LayoutRect computedCSSContentBoxRect() const { return LayoutRect(borderLeft() + computedCSSPaddingLeft(), borderTop() + computedCSSPaddingTop(), clientWidth() - computedCSSPaddingLeft() - computedCSSPaddingRight(), clientHeight() - computedCSSPaddingTop() - computedCSSPaddingBottom()); }
+    LayoutRect computedCSSContentBoxRect() const { return LayoutRect(borderLeft() + computedCSSPaddingLeft(), borderTop() + computedCSSPaddingTop(), paddingBoxWidth() - computedCSSPaddingLeft() - computedCSSPaddingRight(), paddingBoxHeight() - computedCSSPaddingTop() - computedCSSPaddingBottom()); }
 
     // Bounds of the outline box in absolute coords. Respects transforms
     LayoutRect outlineBoundsForRepaint(const RenderLayerModelObject* /*repaintContainer*/, const RenderGeometryMap*) const final;
@@ -213,11 +212,16 @@
     void updateLayerTransform();
 
     LayoutSize contentSize() const { return { contentWidth(), contentHeight() }; }
-    LayoutUnit contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); }
-    LayoutUnit contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); }
+    LayoutUnit contentWidth() const { return paddingBoxWidth() - paddingLeft() - paddingRight(); }
+    LayoutUnit contentHeight() const { return paddingBoxHeight() - paddingTop() - paddingBottom(); }
     LayoutUnit contentLogicalWidth() const { return style().isHorizontalWritingMode() ? contentWidth() : contentHeight(); }
     LayoutUnit contentLogicalHeight() const { return style().isHorizontalWritingMode() ? contentHeight() : contentWidth(); }
 
+    LayoutUnit paddingBoxWidth() const { return width() - borderLeft() - borderRight() - verticalScrollbarWidth(); }
+    LayoutUnit paddingBoxHeight() const { return height() - borderTop() - borderBottom() - horizontalScrollbarHeight(); }
+    LayoutRect paddingBoxRect() const { return LayoutRect(borderLeft(), borderTop(), paddingBoxWidth(), paddingBoxHeight()); }
+    LayoutRect paddingBoxRectIncludingScrollbar() const { return LayoutRect(borderLeft(), borderTop(), width() - borderLeft() - borderRight(), height() - borderTop() - borderBottom()); }
+
     // IE extensions. Used to calculate offsetWidth/Height.  Overridden by inlines (RenderFlow)
     // to return the remaining width on a given line (and the height of a single line).
     LayoutUnit offsetWidth() const override { return width(); }
@@ -447,8 +451,8 @@
     LayoutUnit availableWidth() const { return style().isHorizontalWritingMode() ? availableLogicalWidth() : availableLogicalHeight(IncludeMarginBorderPadding); }
     LayoutUnit availableHeight() const { return style().isHorizontalWritingMode() ? availableLogicalHeight(IncludeMarginBorderPadding) : availableLogicalWidth(); }
 
-    virtual int verticalScrollbarWidth() const;
-    int horizontalScrollbarHeight() const;
+    WEBCORE_EXPORT virtual int verticalScrollbarWidth() const;
+    WEBCORE_EXPORT int horizontalScrollbarHeight() const;
     int intrinsicScrollbarLogicalWidth() const;
     int scrollbarLogicalWidth() const { return style().isHorizontalWritingMode() ? verticalScrollbarWidth() : horizontalScrollbarHeight(); }
     int scrollbarLogicalHeight() const { return style().isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
@@ -472,8 +476,8 @@
     bool scrollsOverflowX() const { return hasOverflowClip() && (style().overflowX() == Overflow::Scroll || style().overflowX() == Overflow::Auto); }
     bool scrollsOverflowY() const { return hasOverflowClip() && (style().overflowY() == Overflow::Scroll || style().overflowY() == Overflow::Auto); }
 
-    bool hasHorizontalOverflow() const { return scrollWidth() != roundToInt(clientWidth()); }
-    bool hasVerticalOverflow() const { return scrollHeight() != roundToInt(clientHeight()); }
+    bool hasHorizontalOverflow() const { return scrollWidth() != roundToInt(paddingBoxWidth()); }
+    bool hasVerticalOverflow() const { return scrollHeight() != roundToInt(paddingBoxHeight()); }
 
     bool hasScrollableOverflowX() const { return scrollsOverflowX() && hasHorizontalOverflow(); }
     bool hasScrollableOverflowY() const { return scrollsOverflowY() && hasVerticalOverflow(); }

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (240217 => 240218)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2019-01-20 21:15:42 UTC (rev 240217)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2019-01-21 01:06:52 UTC (rev 240218)
@@ -950,9 +950,9 @@
     if (compositedAncestor->hasCompositedScrollableOverflow()) {
         LayoutRect ancestorCompositedBounds = ancestorBackingLayer->compositedBounds();
         auto& renderBox = downcast<RenderBox>(compositedAncestor->renderer());
-        LayoutRect paddingBox(renderBox.borderLeft(), renderBox.borderTop(), renderBox.width() - renderBox.borderLeft() - renderBox.borderRight(), renderBox.height() - renderBox.borderTop() - renderBox.borderBottom());
+        LayoutRect paddingBoxIncludingScrollbar = renderBox.paddingBoxRectIncludingScrollbar();
         ScrollOffset scrollOffset = compositedAncestor->scrollOffset();
-        parentGraphicsLayerRect = LayoutRect((paddingBox.location() - toLayoutSize(ancestorCompositedBounds.location()) - toLayoutSize(scrollOffset)), paddingBox.size());
+        parentGraphicsLayerRect = LayoutRect((paddingBoxIncludingScrollbar.location() - toLayoutSize(ancestorCompositedBounds.location()) - toLayoutSize(scrollOffset)), paddingBoxIncludingScrollbar.size());
     }
 #endif
 
@@ -1175,16 +1175,16 @@
     if (m_scrollingLayer) {
         ASSERT(m_scrollingContentsLayer);
         auto& renderBox = downcast<RenderBox>(renderer());
-        LayoutRect paddingBox(renderBox.borderLeft(), renderBox.borderTop(), renderBox.width() - renderBox.borderLeft() - renderBox.borderRight(), renderBox.height() - renderBox.borderTop() - renderBox.borderBottom());
+        LayoutRect paddingBoxIncludingScrollbar = renderBox.paddingBoxRectIncludingScrollbar();
         ScrollOffset scrollOffset = m_owningLayer.scrollOffset();
 
         // FIXME: need to do some pixel snapping here.
-        m_scrollingLayer->setPosition(FloatPoint(paddingBox.location() - compositedBounds().location()));
+        m_scrollingLayer->setPosition(FloatPoint(paddingBoxIncludingScrollbar.location() - compositedBounds().location()));
 
         m_scrollingLayer->setSize(roundedIntSize(LayoutSize(renderBox.clientWidth(), renderBox.clientHeight())));
 #if PLATFORM(IOS_FAMILY)
         FloatSize oldScrollingLayerOffset = m_scrollingLayer->offsetFromRenderer();
-        m_scrollingLayer->setOffsetFromRenderer(FloatPoint() - paddingBox.location());
+        m_scrollingLayer->setOffsetFromRenderer(FloatPoint() - paddingBoxIncludingScrollbar.location());
         bool paddingBoxOffsetChanged = oldScrollingLayerOffset != m_scrollingLayer->offsetFromRenderer();
 
         if (m_owningLayer.isInUserScroll()) {
@@ -1207,17 +1207,17 @@
         m_scrollingContentsLayer->setSize(scrollSize);
         // Scrolling the content layer does not need to trigger a repaint. The offset will be compensated away during painting.
         m_scrollingContentsLayer->setScrollOffset(scrollOffset, GraphicsLayer::DontSetNeedsDisplay);
-        m_scrollingContentsLayer->setOffsetFromRenderer(toLayoutSize(paddingBox.location()), GraphicsLayer::DontSetNeedsDisplay);
+        m_scrollingContentsLayer->setOffsetFromRenderer(toLayoutSize(paddingBoxIncludingScrollbar.location()), GraphicsLayer::DontSetNeedsDisplay);
 #else
         m_scrollingContentsLayer->setPosition(-scrollOffset);
 
         FloatSize oldScrollingLayerOffset = m_scrollingLayer->offsetFromRenderer();
-        m_scrollingLayer->setOffsetFromRenderer(-toFloatSize(paddingBox.location()));
+        m_scrollingLayer->setOffsetFromRenderer(-toFloatSize(paddingBoxIncludingScrollbar.location()));
 
         if (m_childClippingMaskLayer) {
             m_childClippingMaskLayer->setPosition(m_scrollingLayer->position());
             m_childClippingMaskLayer->setSize(m_scrollingLayer->size());
-            m_childClippingMaskLayer->setOffsetFromRenderer(toFloatSize(paddingBox.location()));
+            m_childClippingMaskLayer->setOffsetFromRenderer(toFloatSize(paddingBoxIncludingScrollbar.location()));
         }
 
         bool paddingBoxOffsetChanged = oldScrollingLayerOffset != m_scrollingLayer->offsetFromRenderer();
@@ -1228,7 +1228,7 @@
 
         m_scrollingContentsLayer->setSize(scrollSize);
         m_scrollingContentsLayer->setScrollOffset(scrollOffset, GraphicsLayer::DontSetNeedsDisplay);
-        m_scrollingContentsLayer->setOffsetFromRenderer(toLayoutSize(paddingBox.location()), GraphicsLayer::DontSetNeedsDisplay);
+        m_scrollingContentsLayer->setOffsetFromRenderer(toLayoutSize(paddingBoxIncludingScrollbar.location()), GraphicsLayer::DontSetNeedsDisplay);
 #endif
 
         if (m_foregroundLayer) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to