Fix for <rdar://problem/8882916> Overlay scrollers require
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jan 2011 18:49:35 +0000 (18:49 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jan 2011 18:49:35 +0000 (18:49 +0000)
content to layout underneath the scrollbar area

Reviewed by Maciej Stachowiak.

The render tree should not include scrollbar size for
overlay scrollers. This patch will allow scrollers on
the WebView to behave like overflow:overlay.

Treat overlay scrollers the same way as the !includeScrollbars
case.
* platform/ScrollView.cpp:
(WebCore::ScrollView::visibleContentRect):

No corner rect for overlay scrollers.
(WebCore::ScrollView::scrollCornerRect):

usesOverlayScrollbars() currently always returns no.
* platform/ScrollbarTheme.h:
(WebCore::ScrollbarTheme::usesOverlayScrollbars):
* platform/mac/ScrollbarThemeMac.h:
* platform/mac/ScrollbarThemeMac.mm:
(WebCore::ScrollbarThemeMac::usesOverlayScrollbars):

includeVerticalScrollbarSize() and includeHorizontalScrollbarSize()
should return false for overlay scrollers. They already return
false for overflow:overlay.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::includeVerticalScrollbarSize):
(WebCore::RenderBox::includeHorizontalScrollbarSize):
* rendering/RenderBox.h:

In the render tree, always treat overlay scrollers like
they have a width and height of 0.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::verticalScrollbarWidth):
(WebCore::RenderLayer::horizontalScrollbarHeight):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::verticalScrollbarWidth):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollbarTheme.h
Source/WebCore/platform/mac/ScrollbarThemeMac.h
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderListBox.cpp

index e428d33..68ca15b 100644 (file)
@@ -1,3 +1,45 @@
+2011-01-18  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        Fix for <rdar://problem/8882916> Overlay scrollers require 
+        content to layout underneath the scrollbar area
+
+        The render tree should not include scrollbar size for
+        overlay scrollers. This patch will allow scrollers on
+        the WebView to behave like overflow:overlay.
+
+        Treat overlay scrollers the same way as the !includeScrollbars
+        case.
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::visibleContentRect):
+
+        No corner rect for overlay scrollers.
+        (WebCore::ScrollView::scrollCornerRect):
+
+        usesOverlayScrollbars() currently always returns no.
+        * platform/ScrollbarTheme.h:
+        (WebCore::ScrollbarTheme::usesOverlayScrollbars):
+        * platform/mac/ScrollbarThemeMac.h:
+        * platform/mac/ScrollbarThemeMac.mm:
+        (WebCore::ScrollbarThemeMac::usesOverlayScrollbars):
+
+        includeVerticalScrollbarSize() and includeHorizontalScrollbarSize()
+        should return false for overlay scrollers. They already return
+        false for overflow:overlay.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::includeVerticalScrollbarSize):
+        (WebCore::RenderBox::includeHorizontalScrollbarSize):
+        * rendering/RenderBox.h:
+
+        In the render tree, always treat overlay scrollers like
+        they have a width and height of 0.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::verticalScrollbarWidth):
+        (WebCore::RenderLayer::horizontalScrollbarHeight):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::verticalScrollbarWidth):
+
 2011-01-18  Evan Martin  <evan@chromium.org>
 
         Reviewed by Tony Chang.
index 6cf13a4..dad73bf 100644 (file)
@@ -229,9 +229,15 @@ IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
     if (paintsEntireContents())
         return IntRect(IntPoint(0, 0), contentsSize());
 
+    bool hasOverlayScrollbars = ScrollbarTheme::nativeTheme()->usesOverlayScrollbars();
+    int verticalScrollbarWidth = verticalScrollbar() && !hasOverlayScrollbars && !includeScrollbars
+        ? verticalScrollbar()->width() : 0;
+    int horizontalScrollbarHeight = horizontalScrollbar() && !hasOverlayScrollbars && !includeScrollbars
+        ? horizontalScrollbar()->height() : 0;
+
     return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()),
-                   IntSize(max(0, width() - (verticalScrollbar() && !includeScrollbars ? verticalScrollbar()->width() : 0)), 
-                           max(0, height() - (horizontalScrollbar() && !includeScrollbars ? horizontalScrollbar()->height() : 0))));
+                   IntSize(max(0, width() - verticalScrollbarWidth), 
+                           max(0, height() - horizontalScrollbarHeight)));
 }
 #endif
 
@@ -824,7 +830,10 @@ void ScrollView::repaintContentRectangle(const IntRect& rect, bool now)
 IntRect ScrollView::scrollCornerRect() const
 {
     IntRect cornerRect;
-    
+
+    if (ScrollbarTheme::nativeTheme()->usesOverlayScrollbars())
+        return cornerRect;
+
     if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
         cornerRect.unite(IntRect(m_horizontalScrollbar->width(),
                                  height() - m_horizontalScrollbar->height(),
index 0efaf7a..4e9e24b 100644 (file)
@@ -48,6 +48,7 @@ public:
     virtual ScrollbarButtonsPlacement buttonsPlacement() const { return ScrollbarButtonsSingle; }
 
     virtual bool supportsControlTints() const { return false; }
+    virtual bool usesOverlayScrollbars() const { return false; }
 
     virtual void themeChanged() {}
     
index c833ee7..8b5412d 100644 (file)
@@ -40,6 +40,7 @@ public:
     virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
     
     virtual bool supportsControlTints() const { return true; }
+    virtual bool usesOverlayScrollbars() const;
 
     virtual double initialAutoscrollTimerDelay();
     virtual double autoscrollTimerDelay();
index ce3be1a..3266b8f 100644 (file)
@@ -165,6 +165,12 @@ int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize)
     return cScrollbarThickness[controlSize];
 }
 
+bool ScrollbarThemeMac::usesOverlayScrollbars() const
+{
+    // FIXME: This should be enabled when <rdar://problem/8492788> is resolved.
+    return false;
+}
+
 double ScrollbarThemeMac::initialAutoscrollTimerDelay()
 {
     return gInitialButtonDelay;
index 5c0e611..36c24b7 100644 (file)
@@ -47,6 +47,7 @@
 #include "RenderTableCell.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "ScrollbarTheme.h"
 #include "TransformState.h"
 #include <algorithm>
 #include <math.h>
@@ -562,6 +563,18 @@ IntRect RenderBox::reflectedRect(const IntRect& r) const
     return result;
 }
 
+bool RenderBox::includeVerticalScrollbarSize() const
+{
+    return !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars() 
+        && hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO);
+}
+
+bool RenderBox::includeHorizontalScrollbarSize() const
+{
+    return !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars()
+        && hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO);
+}
+
 int RenderBox::verticalScrollbarWidth() const
 {
     return includeVerticalScrollbarSize() ? layer()->verticalScrollbarWidth() : 0;
index e784b93..7bc4910 100644 (file)
@@ -410,8 +410,8 @@ protected:
     virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
 
 private:
-    bool includeVerticalScrollbarSize() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); }
-    bool includeHorizontalScrollbarSize() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO); }
+    bool includeVerticalScrollbarSize() const;
+    bool includeHorizontalScrollbarSize() const;
 
     void paintRootBoxDecorations(PaintInfo&, int tx, int ty);
     // Returns true if we did a full repaint
index df55602..32b4f5b 100644 (file)
@@ -1886,14 +1886,14 @@ void RenderLayer::setHasVerticalScrollbar(bool hasScrollbar)
 
 int RenderLayer::verticalScrollbarWidth() const
 {
-    if (!m_vBar)
+    if (!m_vBar || ScrollbarTheme::nativeTheme()->usesOverlayScrollbars())
         return 0;
     return m_vBar->width();
 }
 
 int RenderLayer::horizontalScrollbarHeight() const
 {
-    if (!m_hBar)
+    if (!m_hBar || ScrollbarTheme::nativeTheme()->usesOverlayScrollbars())
         return 0;
     return m_hBar->height();
 }
index e6ce340..e0cd0af 100644 (file)
@@ -51,6 +51,7 @@
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "Scrollbar.h"
+#include "ScrollbarTheme.h"
 #include "SelectElement.h"
 #include "SelectionController.h"
 #include "NodeRenderStyle.h"
@@ -551,7 +552,7 @@ int RenderListBox::itemHeight() const
 
 int RenderListBox::verticalScrollbarWidth() const
 {
-    return m_vBar ? m_vBar->width() : 0;
+    return m_vBar && !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars() ? m_vBar->width() : 0;
 }
 
 // FIXME: We ignore padding in the vertical direction as far as these values are concerned, since that's