Title: [173668] trunk/Source/WebCore
Revision
173668
Author
[email protected]
Date
2014-09-16 13:32:29 -0700 (Tue, 16 Sep 2014)

Log Message

overflow:scroll should not leave space for a scroll corner with overlay scrollbars
https://bugs.webkit.org/show_bug.cgi?id=136861

Reviewed by Sam Weinig.

overflow:scroll should behave like overflow:auto when the scrollbar will render as 
an overlay scrollbar.

Re-name hasAutoVerticalScrollbar()/Horizontal to 
hasVerticalScrollbarWithAutoBehavior()/Horizontal, and return true for 
overflow:scroll scrollbars that will render as overlay scrollbars.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::hasVerticalScrollbarWithAutoBehavior):
(WebCore::RenderBox::hasHorizontalScrollbarWithAutoBehavior):
* rendering/RenderBox.h:
(WebCore::RenderBox::scrollsOverflowX):
(WebCore::RenderBox::scrollsOverflowY):
(WebCore::RenderBox::hasAutoVerticalScrollbar): Deleted.
(WebCore::RenderBox::hasAutoHorizontalScrollbar): Deleted.

Re-name overflowRequiresScrollbar() to styleRequiresScrollbar() and also re-name 
overflowDefinesAutomaticScrollbar() to styleDefinesAutomaticScrollbar(), and make         
these functions take into account the fact that overflow:scroll should act like 
overflow:auto when the scrollbar will render as an overlay scrollbar.
* rendering/RenderLayer.cpp:
(WebCore::styleRequiresScrollbar):
(WebCore::styleDefinesAutomaticScrollbar):
(WebCore::RenderLayer::updateScrollbarsAfterLayout):
(WebCore::RenderLayer::calculateClipRects):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (173667 => 173668)


--- trunk/Source/WebCore/ChangeLog	2014-09-16 19:54:12 UTC (rev 173667)
+++ trunk/Source/WebCore/ChangeLog	2014-09-16 20:32:29 UTC (rev 173668)
@@ -1,3 +1,35 @@
+2014-09-16  Beth Dakin  <[email protected]>
+
+        overflow:scroll should not leave space for a scroll corner with overlay scrollbars
+        https://bugs.webkit.org/show_bug.cgi?id=136861
+
+        Reviewed by Sam Weinig.
+
+        overflow:scroll should behave like overflow:auto when the scrollbar will render as 
+        an overlay scrollbar.
+
+        Re-name hasAutoVerticalScrollbar()/Horizontal to 
+        hasVerticalScrollbarWithAutoBehavior()/Horizontal, and return true for 
+        overflow:scroll scrollbars that will render as overlay scrollbars.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::hasVerticalScrollbarWithAutoBehavior):
+        (WebCore::RenderBox::hasHorizontalScrollbarWithAutoBehavior):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::scrollsOverflowX):
+        (WebCore::RenderBox::scrollsOverflowY):
+        (WebCore::RenderBox::hasAutoVerticalScrollbar): Deleted.
+        (WebCore::RenderBox::hasAutoHorizontalScrollbar): Deleted.
+
+        Re-name overflowRequiresScrollbar() to styleRequiresScrollbar() and also re-name 
+        overflowDefinesAutomaticScrollbar() to styleDefinesAutomaticScrollbar(), and make         
+        these functions take into account the fact that overflow:scroll should act like 
+        overflow:auto when the scrollbar will render as an overlay scrollbar.
+        * rendering/RenderLayer.cpp:
+        (WebCore::styleRequiresScrollbar):
+        (WebCore::styleDefinesAutomaticScrollbar):
+        (WebCore::RenderLayer::updateScrollbarsAfterLayout):
+        (WebCore::RenderLayer::calculateClipRects):
+
 2014-09-16  [email protected]  <[email protected]>
 
         [Curl] Sometimes incomplete or empty content can be loaded from cache.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (173667 => 173668)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2014-09-16 19:54:12 UTC (rev 173667)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2014-09-16 20:32:29 UTC (rev 173668)
@@ -55,6 +55,7 @@
 #include "RenderTableCell.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "ScrollbarTheme.h"
 #include "TransformState.h"
 #include "htmlediting.h"
 #include <algorithm>
@@ -928,6 +929,18 @@
         layer()->panScrollFromPoint(source);
 }
 
+bool RenderBox::hasVerticalScrollbarWithAutoBehavior() const
+{
+    bool overflowScrollActsLikeAuto = style().overflowY() == OSCROLL && !style().hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme()->usesOverlayScrollbars();
+    return hasOverflowClip() && (style().overflowY() == OAUTO || style().overflowY() == OOVERLAY || overflowScrollActsLikeAuto);
+}
+
+bool RenderBox::hasHorizontalScrollbarWithAutoBehavior() const
+{
+    bool overflowScrollActsLikeAuto = style().overflowX() == OSCROLL && !style().hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme()->usesOverlayScrollbars();
+    return hasOverflowClip() && (style().overflowX() == OAUTO || style().overflowX() == OOVERLAY || overflowScrollActsLikeAuto);
+}
+
 bool RenderBox::needsPreferredWidthsRecalculation() const
 {
     return style().paddingStart().isPercent() || style().paddingEnd().isPercent();

Modified: trunk/Source/WebCore/rendering/RenderBox.h (173667 => 173668)


--- trunk/Source/WebCore/rendering/RenderBox.h	2014-09-16 19:54:12 UTC (rev 173667)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2014-09-16 20:32:29 UTC (rev 173668)
@@ -466,11 +466,11 @@
     virtual void stopAutoscroll() { }
     virtual void panScroll(const IntPoint&);
 
-    bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style().overflowY() == OAUTO || style().overflowY() == OOVERLAY); }
-    bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style().overflowX() == OAUTO || style().overflowX() == OOVERLAY); }
+    bool hasVerticalScrollbarWithAutoBehavior() const;
+    bool hasHorizontalScrollbarWithAutoBehavior() const;
     bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
-    bool scrollsOverflowX() const { return hasOverflowClip() && (style().overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
-    bool scrollsOverflowY() const { return hasOverflowClip() && (style().overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
+    bool scrollsOverflowX() const { return hasOverflowClip() && (style().overflowX() == OSCROLL || hasHorizontalScrollbarWithAutoBehavior()); }
+    bool scrollsOverflowY() const { return hasOverflowClip() && (style().overflowY() == OSCROLL || hasVerticalScrollbarWithAutoBehavior()); }
     bool hasScrollableOverflowX() const { return scrollsOverflowX() && scrollWidth() != clientWidth(); }
     bool hasScrollableOverflowY() const { return scrollsOverflowY() && scrollHeight() != clientHeight(); }
 

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (173667 => 173668)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-09-16 19:54:12 UTC (rev 173667)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-09-16 20:32:29 UTC (rev 173668)
@@ -3255,6 +3255,20 @@
     return scrollHeight() > renderBox()->pixelSnappedClientHeight();
 }
 
+static bool styleRequiresScrollbar(const RenderStyle& style, ScrollbarOrientation axis)
+{
+    EOverflow overflow = axis == ScrollbarOrientation::HorizontalScrollbar ? style.overflowX() : style.overflowY();
+    bool overflowScrollActsLikeAuto = overflow == OSCROLL && !style.hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme()->usesOverlayScrollbars();
+    return overflow == OSCROLL && !overflowScrollActsLikeAuto;
+}
+
+static bool styleDefinesAutomaticScrollbar(const RenderStyle& style, ScrollbarOrientation axis)
+{
+    EOverflow overflow = axis == ScrollbarOrientation::HorizontalScrollbar ? style.overflowX() : style.overflowY();
+    bool overflowScrollActsLikeAuto = overflow == OSCROLL && !style.hasPseudoStyle(SCROLLBAR) && ScrollbarTheme::theme()->usesOverlayScrollbars();
+    return overflow == OAUTO || overflow == OOVERLAY || overflowScrollActsLikeAuto;
+}
+
 void RenderLayer::updateScrollbarsAfterLayout()
 {
     RenderBox* box = renderBox();
@@ -3267,20 +3281,20 @@
     bool hasHorizontalOverflow = this->hasHorizontalOverflow();
     bool hasVerticalOverflow = this->hasVerticalOverflow();
 
-    // overflow:scroll should just enable/disable.
-    if (renderer().style().overflowX() == OSCROLL)
+    // If overflow requires a scrollbar, then we just need to enable or disable.
+    if (styleRequiresScrollbar(renderer().style(), HorizontalScrollbar))
         m_hBar->setEnabled(hasHorizontalOverflow);
-    if (renderer().style().overflowY() == OSCROLL)
+    if (styleRequiresScrollbar(renderer().style(), VerticalScrollbar))
         m_vBar->setEnabled(hasVerticalOverflow);
 
-    // overflow:auto may need to lay out again if scrollbars got added/removed.
-    bool autoHorizontalScrollBarChanged = box->hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow);
-    bool autoVerticalScrollBarChanged = box->hasAutoVerticalScrollbar() && (hasVerticalScrollbar() != hasVerticalOverflow);
+    // Scrollbars with auto behavior may need to lay out again if scrollbars got added or removed.
+    bool autoHorizontalScrollBarChanged = box->hasHorizontalScrollbarWithAutoBehavior() && (hasHorizontalScrollbar() != hasHorizontalOverflow);
+    bool autoVerticalScrollBarChanged = box->hasVerticalScrollbarWithAutoBehavior() && (hasVerticalScrollbar() != hasVerticalOverflow);
 
     if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) {
-        if (box->hasAutoHorizontalScrollbar())
+        if (box->hasHorizontalScrollbarWithAutoBehavior())
             setHasHorizontalScrollbar(hasHorizontalOverflow);
-        if (box->hasAutoVerticalScrollbar())
+        if (box->hasVerticalScrollbarWithAutoBehavior())
             setHasVerticalScrollbar(hasVerticalOverflow);
 
         updateSelfPaintingLayer();
@@ -6387,16 +6401,6 @@
     }
 }
 
-static bool overflowRequiresScrollbar(EOverflow overflow)
-{
-    return overflow == OSCROLL;
-}
-
-static bool overflowDefinesAutomaticScrollbar(EOverflow overflow)
-{
-    return overflow == OAUTO || overflow == OOVERLAY;
-}
-
 void RenderLayer::updateScrollbarsAfterStyleChange(const RenderStyle* oldStyle)
 {
     // Overflow are a box concept.
@@ -6412,22 +6416,18 @@
     EOverflow overflowY = box->style().overflowY();
 
     // To avoid doing a relayout in updateScrollbarsAfterLayout, we try to keep any automatic scrollbar that was already present.
-    bool needsHorizontalScrollbar = box->hasOverflowClip() && ((hasHorizontalScrollbar() && overflowDefinesAutomaticScrollbar(overflowX)) || overflowRequiresScrollbar(overflowX));
-    bool needsVerticalScrollbar = box->hasOverflowClip() && ((hasVerticalScrollbar() && overflowDefinesAutomaticScrollbar(overflowY)) || overflowRequiresScrollbar(overflowY));
+    bool needsHorizontalScrollbar = box->hasOverflowClip() && ((hasHorizontalScrollbar() && styleDefinesAutomaticScrollbar(box->style(), HorizontalScrollbar)) || styleRequiresScrollbar(box->style(), HorizontalScrollbar));
+    bool needsVerticalScrollbar = box->hasOverflowClip() && ((hasVerticalScrollbar() && styleDefinesAutomaticScrollbar(box->style(), VerticalScrollbar)) || styleRequiresScrollbar(box->style(), VerticalScrollbar));
     setHasHorizontalScrollbar(needsHorizontalScrollbar);
     setHasVerticalScrollbar(needsVerticalScrollbar);
 
-    // With overflow: scroll, scrollbars are always visible but may be disabled.
+    // With non-overlay overflow:scroll, scrollbars are always visible but may be disabled.
     // When switching to another value, we need to re-enable them (see bug 11985).
-    if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL) {
-        ASSERT(hasHorizontalScrollbar());
+    if (m_hBar && needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL)
         m_hBar->setEnabled(true);
-    }
 
-    if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL && overflowY != OSCROLL) {
-        ASSERT(hasVerticalScrollbar());
+    if (m_vBar && needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL && overflowY != OSCROLL)
         m_vBar->setEnabled(true);
-    }
 
     if (!m_scrollDimensionsDirty)
         updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to