Title: [282909] branches/safari-612-branch/Source/WebCore
Revision
282909
Author
repst...@apple.com
Date
2021-09-22 21:29:04 -0700 (Wed, 22 Sep 2021)

Log Message

Cherry-pick r281971. rdar://problem/83429744

    Relative -webkit-scrollbar width value may lead to unstable layout
    https://bugs.webkit.org/show_bug.cgi?id=229833.
    <rdar://80336247>

    Reviewed by Simon Fraser.

    The way we resolve the relative property value for the webkit-scrollbar width (using the owning renderer’s width) can lead to unstable layout with
    circular dependency. While -webkit-scrollbar itself is non-standard, Chrome supports it but not with relative width/height values. They are resolved to 0px.
    Here we use the default platform value instead.

    * rendering/RenderScrollbarPart.cpp:
    (WebCore::calcScrollbarThicknessUsing): Do not try to resolve the relative length value.
    (WebCore::RenderScrollbarPart::computeScrollbarWidth):
    (WebCore::RenderScrollbarPart::computeScrollbarHeight):

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

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (282908 => 282909)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-23 04:29:01 UTC (rev 282908)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-23 04:29:04 UTC (rev 282909)
@@ -1,5 +1,44 @@
 2021-09-22  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r281971. rdar://problem/83429744
+
+    Relative -webkit-scrollbar width value may lead to unstable layout
+    https://bugs.webkit.org/show_bug.cgi?id=229833.
+    <rdar://80336247>
+    
+    Reviewed by Simon Fraser.
+    
+    The way we resolve the relative property value for the webkit-scrollbar width (using the owning renderer’s width) can lead to unstable layout with
+    circular dependency. While -webkit-scrollbar itself is non-standard, Chrome supports it but not with relative width/height values. They are resolved to 0px.
+    Here we use the default platform value instead.
+    
+    * rendering/RenderScrollbarPart.cpp:
+    (WebCore::calcScrollbarThicknessUsing): Do not try to resolve the relative length value.
+    (WebCore::RenderScrollbarPart::computeScrollbarWidth):
+    (WebCore::RenderScrollbarPart::computeScrollbarHeight):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281971 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-02  Alan Bujtas  <za...@apple.com>
+
+            Relative -webkit-scrollbar width value may lead to unstable layout
+            https://bugs.webkit.org/show_bug.cgi?id=229833.
+            <rdar://80336247>
+
+            Reviewed by Simon Fraser.
+
+            The way we resolve the relative property value for the webkit-scrollbar width (using the owning renderer’s width) can lead to unstable layout with
+            circular dependency. While -webkit-scrollbar itself is non-standard, Chrome supports it but not with relative width/height values. They are resolved to 0px.
+            Here we use the default platform value instead.
+
+            * rendering/RenderScrollbarPart.cpp:
+            (WebCore::calcScrollbarThicknessUsing): Do not try to resolve the relative length value.
+            (WebCore::RenderScrollbarPart::computeScrollbarWidth):
+            (WebCore::RenderScrollbarPart::computeScrollbarHeight):
+
+2021-09-22  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r281920. rdar://problem/83429601
 
     Braille display is blank in contenteditable elements when the field is followed by another element.

Modified: branches/safari-612-branch/Source/WebCore/rendering/RenderScrollbarPart.cpp (282908 => 282909)


--- branches/safari-612-branch/Source/WebCore/rendering/RenderScrollbarPart.cpp	2021-09-23 04:29:01 UTC (rev 282908)
+++ branches/safari-612-branch/Source/WebCore/rendering/RenderScrollbarPart.cpp	2021-09-23 04:29:04 UTC (rev 282909)
@@ -80,10 +80,10 @@
     } 
 }
 
-static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length, int containingLength)
+static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length)
 {
-    if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto()))
-        return minimumValueForLength(length, containingLength);
+    if ((!length.isPercentOrCalculated() && !length.isIntrinsicOrAuto()) || (sizeType == MinSize && length.isAuto()))
+        return minimumValueForLength(length, { });
     return ScrollbarTheme::theme().scrollbarThickness();
 }
 
@@ -91,17 +91,14 @@
 {
     if (!m_scrollbar->owningRenderer())
         return;
-    // FIXME: We are querying layout information but nothing guarantees that it's up-to-date, especially since we are called at style change.
-    // FIXME: Querying the style's border information doesn't work on table cells with collapsing borders.
-    int visibleSize = m_scrollbar->owningRenderer()->width() - m_scrollbar->owningRenderer()->style().borderLeftWidth() - m_scrollbar->owningRenderer()->style().borderRightWidth();
-    int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style().width(), visibleSize);
-    int minWidth = calcScrollbarThicknessUsing(MinSize, style().minWidth(), visibleSize);
-    int maxWidth = style().maxWidth().isUndefined() ? w : calcScrollbarThicknessUsing(MaxSize, style().maxWidth(), visibleSize);
-    setWidth(std::max(minWidth, std::min(maxWidth, w)));
+    int width = calcScrollbarThicknessUsing(MainOrPreferredSize, style().width());
+    int minWidth = calcScrollbarThicknessUsing(MinSize, style().minWidth());
+    int maxWidth = style().maxWidth().isUndefined() ? width : calcScrollbarThicknessUsing(MaxSize, style().maxWidth());
+    setWidth(std::max(minWidth, std::min(maxWidth, width)));
     
     // Buttons and track pieces can all have margins along the axis of the scrollbar. 
-    m_marginBox.setLeft(minimumValueForLength(style().marginLeft(), visibleSize));
-    m_marginBox.setRight(minimumValueForLength(style().marginRight(), visibleSize));
+    m_marginBox.setLeft(minimumValueForLength(style().marginLeft(), { }));
+    m_marginBox.setRight(minimumValueForLength(style().marginRight(), { }));
 }
 
 void RenderScrollbarPart::computeScrollbarHeight()
@@ -108,17 +105,14 @@
 {
     if (!m_scrollbar->owningRenderer())
         return;
-    // FIXME: We are querying layout information but nothing guarantees that it's up-to-date, especially since we are called at style change.
-    // FIXME: Querying the style's border information doesn't work on table cells with collapsing borders.
-    int visibleSize = m_scrollbar->owningRenderer()->height() -  m_scrollbar->owningRenderer()->style().borderTopWidth() - m_scrollbar->owningRenderer()->style().borderBottomWidth();
-    int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style().height(), visibleSize);
-    int minHeight = calcScrollbarThicknessUsing(MinSize, style().minHeight(), visibleSize);
-    int maxHeight = style().maxHeight().isUndefined() ? h : calcScrollbarThicknessUsing(MaxSize, style().maxHeight(), visibleSize);
-    setHeight(std::max(minHeight, std::min(maxHeight, h)));
+    int height = calcScrollbarThicknessUsing(MainOrPreferredSize, style().height());
+    int minHeight = calcScrollbarThicknessUsing(MinSize, style().minHeight());
+    int maxHeight = style().maxHeight().isUndefined() ? height : calcScrollbarThicknessUsing(MaxSize, style().maxHeight());
+    setHeight(std::max(minHeight, std::min(maxHeight, height)));
 
     // Buttons and track pieces can all have margins along the axis of the scrollbar. 
-    m_marginBox.setTop(minimumValueForLength(style().marginTop(), visibleSize));
-    m_marginBox.setBottom(minimumValueForLength(style().marginBottom(), visibleSize));
+    m_marginBox.setTop(minimumValueForLength(style().marginTop(), { }));
+    m_marginBox.setBottom(minimumValueForLength(style().marginBottom(), { }));
 }
 
 void RenderScrollbarPart::computePreferredLogicalWidths()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to