Fix for https://bugs.webkit.org/show_bug.cgi?id=54991
Scrollbar::nativeTheme()->usesOverlayScrollbars() should not be consulted for CSS
Scrollbars
-and corresponding-
<rdar://problem/9034318>
Reviewed by Sam Weinig.
Instead of consulting the theme directly, callers should ask the Scrollbar or
ScrollableArea if the scrollbars are overlay or not.
* platform/ScrollView.cpp:
(WebCore::ScrollView::visibleContentRect):
(WebCore::ScrollView::scrollContents):
(WebCore::ScrollView::wheelEvent):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::setScrollOffsetFromAnimation):
(WebCore::ScrollableArea::hasOverlayScrollbars):
* platform/ScrollableArea.h:
* platform/Scrollbar.cpp:
(WebCore::Scrollbar::isOverlayScrollbar):
* platform/Scrollbar.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::includeVerticalScrollbarSize):
(WebCore::RenderBox::includeHorizontalScrollbarSize):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::verticalScrollbarWidth):
(WebCore::RenderLayer::horizontalScrollbarHeight):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::verticalScrollbarWidth):
* rendering/RenderScrollbar.h:
(WebCore::RenderScrollbar::isOverlayScrollbar):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79360 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 58be025..dca2ef5 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2011-02-22 Beth Dakin <bdakin@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Fix for https://bugs.webkit.org/show_bug.cgi?id=54991
+ Scrollbar::nativeTheme()->usesOverlayScrollbars() should not be consulted for CSS
+ Scrollbars
+ -and corresponding-
+ <rdar://problem/9034318>
+
+ Instead of consulting the theme directly, callers should ask the Scrollbar or
+ ScrollableArea if the scrollbars are overlay or not.
+
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::visibleContentRect):
+ (WebCore::ScrollView::scrollContents):
+ (WebCore::ScrollView::wheelEvent):
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::setScrollOffsetFromAnimation):
+ (WebCore::ScrollableArea::hasOverlayScrollbars):
+ * platform/ScrollableArea.h:
+ * platform/Scrollbar.cpp:
+ (WebCore::Scrollbar::isOverlayScrollbar):
+ * platform/Scrollbar.h:
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::includeVerticalScrollbarSize):
+ (WebCore::RenderBox::includeHorizontalScrollbarSize):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::verticalScrollbarWidth):
+ (WebCore::RenderLayer::horizontalScrollbarHeight):
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::verticalScrollbarWidth):
+ * rendering/RenderScrollbar.h:
+ (WebCore::RenderScrollbar::isOverlayScrollbar):
+
2011-02-22 Andras Becsi <abecsi@webkit.org>
Reviewed by Csaba Osztrogonác.
diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp
index 8e1577f..eeae4cf 100644
--- a/Source/WebCore/platform/ScrollView.cpp
+++ b/Source/WebCore/platform/ScrollView.cpp
@@ -233,11 +233,10 @@
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;
+ int verticalScrollbarWidth = verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()
+ && !includeScrollbars ? verticalScrollbar()->width() : 0;
+ int horizontalScrollbarHeight = horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()
+ && !includeScrollbars ? horizontalScrollbar()->height() : 0;
return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()),
IntSize(max(0, m_boundsSize.width() - verticalScrollbarWidth),
@@ -598,7 +597,7 @@
// with the clip rect every time to keep it smooth.
IntRect clipRect = windowClipRect();
IntRect scrollViewRect = convertToContainingWindow(IntRect(0, 0, visibleWidth(), visibleHeight()));
- if (ScrollbarTheme::nativeTheme()->usesOverlayScrollbars()) {
+ if (hasOverlayScrollbars()) {
int verticalScrollbarWidth = verticalScrollbar() ? verticalScrollbar()->width() : 0;
int horizontalScrollbarHeight = horizontalScrollbar() ? horizontalScrollbar()->height() : 0;
@@ -860,7 +859,7 @@
{
IntRect cornerRect;
- if (ScrollbarTheme::nativeTheme()->usesOverlayScrollbars())
+ if (hasOverlayScrollbars())
return cornerRect;
if (m_horizontalScrollbar && m_boundsSize.width() - m_horizontalScrollbar->width() > 0) {
@@ -963,9 +962,10 @@
void ScrollView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntRect& verticalOverhangRect)
{
- bool hasOverlayScrollbars = ScrollbarTheme::nativeTheme()->usesOverlayScrollbars();
- int verticalScrollbarWidth = (verticalScrollbar() && !hasOverlayScrollbars) ? verticalScrollbar()->width() : 0;
- int horizontalScrollbarHeight = (horizontalScrollbar() && !hasOverlayScrollbars) ? horizontalScrollbar()->height() : 0;
+ int verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar())
+ ? verticalScrollbar()->width() : 0;
+ int horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar())
+ ? horizontalScrollbar()->height() : 0;
if (scrollY() < 0) {
horizontalOverhangRect = frameRect();
diff --git a/Source/WebCore/platform/ScrollableArea.cpp b/Source/WebCore/platform/ScrollableArea.cpp
index 00017bd..a2d3849 100644
--- a/Source/WebCore/platform/ScrollableArea.cpp
+++ b/Source/WebCore/platform/ScrollableArea.cpp
@@ -128,17 +128,15 @@
// Tell the derived class to scroll its contents.
setScrollOffset(offset);
- bool hasOverlayScrollbars = ScrollbarTheme::nativeTheme()->usesOverlayScrollbars();
-
// Tell the scrollbars to update their thumb postions.
if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
horizontalScrollbar->offsetDidChange();
- if (hasOverlayScrollbars)
+ if (horizontalScrollbar->isOverlayScrollbar())
horizontalScrollbar->invalidate();
}
if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) {
verticalScrollbar->offsetDidChange();
- if (hasOverlayScrollbars)
+ if (verticalScrollbar->isOverlayScrollbar())
verticalScrollbar->invalidate();
}
}
@@ -179,4 +177,10 @@
scrollAnimator()->willRemoveHorizontalScrollbar(scrollbar);
}
+bool ScrollableArea::hasOverlayScrollbars() const
+{
+ return (verticalScrollbar() && verticalScrollbar()->isOverlayScrollbar())
+ || (horizontalScrollbar() && horizontalScrollbar()->isOverlayScrollbar());
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/ScrollableArea.h b/Source/WebCore/platform/ScrollableArea.h
index 5ea937c..f1c1308 100644
--- a/Source/WebCore/platform/ScrollableArea.h
+++ b/Source/WebCore/platform/ScrollableArea.h
@@ -66,6 +66,8 @@
void didAddHorizontalScrollbar(Scrollbar*);
void willRemoveHorizontalScrollbar(Scrollbar*);
+ bool hasOverlayScrollbars() const;
+
ScrollAnimator* scrollAnimator() const { return m_scrollAnimator.get(); }
virtual int scrollSize(ScrollbarOrientation) const = 0;
diff --git a/Source/WebCore/platform/Scrollbar.cpp b/Source/WebCore/platform/Scrollbar.cpp
index 5d9a43d..ba00ab0 100644
--- a/Source/WebCore/platform/Scrollbar.cpp
+++ b/Source/WebCore/platform/Scrollbar.cpp
@@ -433,6 +433,11 @@
invalidate();
}
+bool Scrollbar::isOverlayScrollbar() const
+{
+ return m_theme->usesOverlayScrollbars();
+}
+
bool Scrollbar::isWindowActive() const
{
return m_scrollableArea && m_scrollableArea->isActive();
diff --git a/Source/WebCore/platform/Scrollbar.h b/Source/WebCore/platform/Scrollbar.h
index 5db191a..267eada 100644
--- a/Source/WebCore/platform/Scrollbar.h
+++ b/Source/WebCore/platform/Scrollbar.h
@@ -86,6 +86,8 @@
bool enabled() const { return m_enabled; }
virtual void setEnabled(bool e);
+ virtual bool isOverlayScrollbar() const;
+
bool isWindowActive() const;
// These methods are used for platform scrollbars to give :hover feedback. They will not get called
diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp
index 55a1189..693121a 100644
--- a/Source/WebCore/rendering/RenderBox.cpp
+++ b/Source/WebCore/rendering/RenderBox.cpp
@@ -563,14 +563,14 @@
bool RenderBox::includeVerticalScrollbarSize() const
{
- return !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars()
- && hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO);
+ return hasOverflowClip() && !layer()->hasOverlayScrollbars()
+ && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO);
}
bool RenderBox::includeHorizontalScrollbarSize() const
{
- return !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars()
- && hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO);
+ return hasOverflowClip() && !layer()->hasOverlayScrollbars()
+ && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO);
}
int RenderBox::verticalScrollbarWidth() const
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp
index fdd3c06..9a71be5 100644
--- a/Source/WebCore/rendering/RenderLayer.cpp
+++ b/Source/WebCore/rendering/RenderLayer.cpp
@@ -1901,14 +1901,14 @@
int RenderLayer::verticalScrollbarWidth() const
{
- if (!m_vBar || ScrollbarTheme::nativeTheme()->usesOverlayScrollbars())
+ if (!m_vBar || m_vBar->isOverlayScrollbar())
return 0;
return m_vBar->width();
}
int RenderLayer::horizontalScrollbarHeight() const
{
- if (!m_hBar || ScrollbarTheme::nativeTheme()->usesOverlayScrollbars())
+ if (!m_hBar || m_hBar->isOverlayScrollbar())
return 0;
return m_hBar->height();
}
diff --git a/Source/WebCore/rendering/RenderListBox.cpp b/Source/WebCore/rendering/RenderListBox.cpp
index 5e6bd90..26dfd3a 100644
--- a/Source/WebCore/rendering/RenderListBox.cpp
+++ b/Source/WebCore/rendering/RenderListBox.cpp
@@ -557,7 +557,7 @@
int RenderListBox::verticalScrollbarWidth() const
{
- return m_vBar && !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars() ? m_vBar->width() : 0;
+ return m_vBar && !m_vBar->isOverlayScrollbar() ? m_vBar->width() : 0;
}
// FIXME: We ignore padding in the vertical direction as far as these values are concerned, since that's
diff --git a/Source/WebCore/rendering/RenderScrollbar.h b/Source/WebCore/rendering/RenderScrollbar.h
index 8f4de4f..810c98f 100644
--- a/Source/WebCore/rendering/RenderScrollbar.h
+++ b/Source/WebCore/rendering/RenderScrollbar.h
@@ -60,6 +60,8 @@
int minimumThumbLength();
+ virtual bool isOverlayScrollbar() const { return false; }
+
private:
virtual void setParent(ScrollView*);
virtual void setEnabled(bool);