Title: [91435] trunk/Source
Revision
91435
Author
[email protected]
Date
2011-07-20 18:32:17 -0700 (Wed, 20 Jul 2011)

Log Message

Scrollbar color heuristic needs to be hooked up in WebKit1
https://bugs.webkit.org/show_bug.cgi?id=64220
<rdar://problem/9589140>

Patch by Tim Horton <[email protected]> on 2011-07-20
Reviewed by Darin Adler.

Store the scroller style on ScrollableArea, and recompute it whenever
the document or body element background color changes or the base background
color of the scrollview changes. Also, make sure to repaint the scrollbars
whenever the style changes.

Source/WebCore:

No new tests, since this code is only enabled on future versions of Mac OS X.

* WebCore.exp.in:
* page/Frame.cpp:
(WebCore::Frame::getDocumentBackgroundColor):
* page/Frame.h:
* page/FrameView.cpp:
(WebCore::FrameView::recalculateScrollbarOverlayStyle):
(WebCore::FrameView::setBaseBackgroundColor):
(WebCore::FrameView::documentBackgroundColor): Renamed.
* page/FrameView.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::setScrollbarOverlayStyle):
* platform/ScrollView.h:
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::setScrollbarOverlayStyle):
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::scrollbarOverlayStyle):
* platform/ScrollbarTheme.h:
(WebCore::ScrollbarTheme::updateScrollbarOverlayStyle):
* platform/mac/ScrollViewMac.mm:
(WebCore::toNSScrollerKnobStyle):
(WebCore::ScrollView::platformSetScrollbarOverlayStyle):
* platform/mac/ScrollbarThemeMac.h:
* platform/mac/ScrollbarThemeMac.mm:
(WebCore::toScrollbarPainterKnobStyle):
(WebCore::ScrollbarThemeMac::updateScrollbarOverlayStyle):
(WebCore::ScrollbarThemeMac::paint):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange):

Source/WebKit2:

* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::getDocumentBackgroundColor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91434 => 91435)


--- trunk/Source/WebCore/ChangeLog	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/ChangeLog	2011-07-21 01:32:17 UTC (rev 91435)
@@ -1,3 +1,47 @@
+2011-07-20  Tim Horton  <[email protected]>
+
+        Scrollbar color heuristic needs to be hooked up in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=64220
+        <rdar://problem/9589140>
+
+        Reviewed by Darin Adler.
+
+        Store the scroller style on ScrollableArea, and recompute it whenever
+        the document or body element background color changes or the base background
+        color of the scrollview changes. Also, make sure to repaint the scrollbars
+        whenever the style changes.
+
+        No new tests, since this code is only enabled on future versions of Mac OS X.
+
+        * WebCore.exp.in:
+        * page/Frame.cpp:
+        (WebCore::Frame::getDocumentBackgroundColor):
+        * page/Frame.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::recalculateScrollbarOverlayStyle):
+        (WebCore::FrameView::setBaseBackgroundColor):
+        (WebCore::FrameView::documentBackgroundColor): Renamed.
+        * page/FrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::setScrollbarOverlayStyle):
+        * platform/ScrollView.h:
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::setScrollbarOverlayStyle):
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::scrollbarOverlayStyle):
+        * platform/ScrollbarTheme.h:
+        (WebCore::ScrollbarTheme::updateScrollbarOverlayStyle):
+        * platform/mac/ScrollViewMac.mm:
+        (WebCore::toNSScrollerKnobStyle):
+        (WebCore::ScrollView::platformSetScrollbarOverlayStyle):
+        * platform/mac/ScrollbarThemeMac.h:
+        * platform/mac/ScrollbarThemeMac.mm:
+        (WebCore::toScrollbarPainterKnobStyle):
+        (WebCore::ScrollbarThemeMac::updateScrollbarOverlayStyle):
+        (WebCore::ScrollbarThemeMac::paint):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::styleDidChange):
+
 2011-07-20  Luke Macpherson   <[email protected]>
 
         Implement CSSPropertyWebkitTransformOriginZ and Origin in CSSStyleApplyProperty.

Modified: trunk/Source/WebCore/WebCore.exp.in (91434 => 91435)


--- trunk/Source/WebCore/WebCore.exp.in	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-07-21 01:32:17 UTC (rev 91435)
@@ -1235,7 +1235,6 @@
 __ZNK7WebCore5Frame15contentRendererEv
 __ZNK7WebCore5Frame15layerTreeAsTextEb
 __ZNK7WebCore5Frame18documentTypeStringEv
-__ZNK7WebCore5Frame26getDocumentBackgroundColorEv
 __ZNK7WebCore5Frame31displayStringModifiedByEncodingERKN3WTF6StringE
 __ZNK7WebCore5Frame8settingsEv
 __ZNK7WebCore5Frame9domWindowEv
@@ -1326,6 +1325,7 @@
 __ZNK7WebCore9FrameView19baseBackgroundColorEv
 __ZNK7WebCore9FrameView20isSoftwareRenderableEv
 __ZNK7WebCore9FrameView22windowClipRectForLayerEPKNS_11RenderLayerEb
+__ZNK7WebCore9FrameView23documentBackgroundColorEv
 __ZNK7WebCore9FrameView28isEnclosedInCompositingLayerEv
 __ZNK7WebCore9PageCache10frameCountEv
 __ZNK7WebCore9PageCache21autoreleasedPageCountEv

Modified: trunk/Source/WebCore/page/Frame.cpp (91434 => 91435)


--- trunk/Source/WebCore/page/Frame.cpp	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/page/Frame.cpp	2011-07-21 01:32:17 UTC (rev 91435)
@@ -507,47 +507,7 @@
     
     return matchLabelsAgainstString(labels, element->getAttribute(idAttr));
 }
-    
-Color Frame::getDocumentBackgroundColor() const
-{
-    // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background color of
-    // the document and the body against the base background color of the frame view.
-    // Background images are unfortunately impractical to include.
 
-    // Return invalid Color objects whenever there is insufficient information.
-    if (!m_doc)
-        return Color();
-
-    Element* htmlElement = m_doc->documentElement();
-    Element* bodyElement = m_doc->body();
-
-    // start as invalid colors
-    Color htmlBackgroundColor;
-    Color bodyBackgroundColor;
-    if (htmlElement && htmlElement->renderer())
-        htmlBackgroundColor = htmlElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
-    if (bodyElement && bodyElement->renderer())
-        bodyBackgroundColor = bodyElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
-    
-    if (!bodyBackgroundColor.isValid()) {
-        if (!htmlBackgroundColor.isValid())
-            return Color();
-        return view()->baseBackgroundColor().blend(htmlBackgroundColor);
-    }
-    
-    if (!htmlBackgroundColor.isValid())
-        return view()->baseBackgroundColor().blend(bodyBackgroundColor);
-    
-    // We take the aggregate of the base background color
-    // the <html> background color, and the <body>
-    // background color to find the document color. The
-    // addition of the base background color is not
-    // technically part of the document background, but it
-    // otherwise poses problems when the aggregate is not
-    // fully opaque.
-    return view()->baseBackgroundColor().blend(htmlBackgroundColor).blend(bodyBackgroundColor);
-}
-
 void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)
 {
     // In setting printing, we should not validate resources already cached for the document.

Modified: trunk/Source/WebCore/page/Frame.h (91434 => 91435)


--- trunk/Source/WebCore/page/Frame.h	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/page/Frame.h	2011-07-21 01:32:17 UTC (rev 91435)
@@ -192,8 +192,6 @@
         String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*, size_t* resultDistanceFromStartOfCell);
         String searchForLabelsBeforeElement(const Vector<String>& labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove);
         String matchLabelsAgainstElement(const Vector<String>& labels, Element*);
-
-        Color getDocumentBackgroundColor() const;
         
 #if PLATFORM(MAC)
         NSString* searchForLabelsBeforeElement(NSArray* labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove);

Modified: trunk/Source/WebCore/page/FrameView.cpp (91434 => 91435)


--- trunk/Source/WebCore/page/FrameView.cpp	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/page/FrameView.cpp	2011-07-21 01:32:17 UTC (rev 91435)
@@ -325,21 +325,24 @@
         m_frame->document()->didRemoveWheelEventHandler();
 }
 
-ScrollbarOverlayStyle FrameView::recommendedScrollbarOverlayStyle() const
+void FrameView::recalculateScrollbarOverlayStyle()
 {
-    Color bgColor = m_frame->getDocumentBackgroundColor();
-    if (!bgColor.isValid())
-        return ScrollbarOverlayStyleDefault;
-    
-    // Reduce the background color from RGB to a lightness value
-    // and determine which scrollbar style to use based on a lightness
-    // heuristic.
-    double hue, saturation, lightness;
-    bgColor.getHSL(hue, saturation, lightness);
-    if (lightness > .5)
-        return ScrollbarOverlayStyleDefault;
-    
-    return ScrollbarOverlayStyleLight;
+    ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle();
+    ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault;
+
+    Color backgroundColor = documentBackgroundColor();
+    if (backgroundColor.isValid()) {
+        // Reduce the background color from RGB to a lightness value
+        // and determine which scrollbar style to use based on a lightness
+        // heuristic.
+        double hue, saturation, lightness;
+        backgroundColor.getHSL(hue, saturation, lightness);
+        if (lightness <= .5)
+            overlayStyle = ScrollbarOverlayStyleLight;
+    }
+
+    if (oldOverlayStyle != overlayStyle)
+        setScrollbarOverlayStyle(overlayStyle);
 }
 
 void FrameView::clear()
@@ -1895,6 +1898,8 @@
         m_baseBackgroundColor = Color::white;
     else
         m_baseBackgroundColor = backgroundColor;
+
+    recalculateScrollbarOverlayStyle();
 }
 
 void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool transparent)
@@ -2367,6 +2372,46 @@
     ScrollView::paintScrollCorner(context, cornerRect);
 }
 
+Color FrameView::documentBackgroundColor() const
+{
+    // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background color of
+    // the document and the body against the base background color of the frame view.
+    // Background images are unfortunately impractical to include.
+
+    // Return invalid Color objects whenever there is insufficient information.
+    if (!frame()->document())
+        return Color();
+
+    Element* htmlElement = frame()->document()->documentElement();
+    Element* bodyElement = frame()->document()->body();
+
+    // Start with invalid colors.
+    Color htmlBackgroundColor;
+    Color bodyBackgroundColor;
+    if (htmlElement && htmlElement->renderer())
+        htmlBackgroundColor = htmlElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+    if (bodyElement && bodyElement->renderer())
+        bodyBackgroundColor = bodyElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+
+    if (!bodyBackgroundColor.isValid()) {
+        if (!htmlBackgroundColor.isValid())
+            return Color();
+        return baseBackgroundColor().blend(htmlBackgroundColor);
+    }
+
+    if (!htmlBackgroundColor.isValid())
+        return baseBackgroundColor().blend(bodyBackgroundColor);
+
+    // We take the aggregate of the base background color
+    // the <html> background color, and the <body>
+    // background color to find the document color. The
+    // addition of the base background color is not
+    // technically part of the document background, but it
+    // otherwise poses problems when the aggregate is not
+    // fully opaque.
+    return baseBackgroundColor().blend(htmlBackgroundColor).blend(bodyBackgroundColor);
+}
+
 bool FrameView::hasCustomScrollbars() const
 {
     const HashSet<RefPtr<Widget> >* viewChildren = children();

Modified: trunk/Source/WebCore/page/FrameView.h (91434 => 91435)


--- trunk/Source/WebCore/page/FrameView.h	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/page/FrameView.h	2011-07-21 01:32:17 UTC (rev 91435)
@@ -140,7 +140,7 @@
     void resetScrollbars();
     void resetScrollbarsAndClearContentsSize();
     void detachCustomScrollbars();
-    virtual ScrollbarOverlayStyle recommendedScrollbarOverlayStyle() const;
+    virtual void recalculateScrollbarOverlayStyle();
 
     void clear();
 
@@ -222,6 +222,8 @@
     virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
     virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect);
 
+    Color documentBackgroundColor() const;
+
     static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
     
     void updateLayoutAndStyleIfNeededRecursive();

Modified: trunk/Source/WebCore/platform/ScrollView.cpp (91434 => 91435)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2011-07-21 01:32:17 UTC (rev 91435)
@@ -779,6 +779,12 @@
     return 0;
 }
 
+void ScrollView::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle)
+{
+    ScrollableArea::setScrollbarOverlayStyle(overlayStyle);
+    platformSetScrollbarOverlayStyle(overlayStyle);
+}
+
 void ScrollView::wheelEvent(PlatformWheelEvent& e)
 {
     // We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
@@ -1279,6 +1285,10 @@
 {
 }
 
+void ScrollView::platformSetScrollbarOverlayStyle(ScrollbarOverlayStyle)
+{
+}
+
 #endif
 
 #if !PLATFORM(MAC) && !PLATFORM(WX)

Modified: trunk/Source/WebCore/platform/ScrollView.h (91434 => 91435)


--- trunk/Source/WebCore/platform/ScrollView.h	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/platform/ScrollView.h	2011-07-21 01:32:17 UTC (rev 91435)
@@ -108,6 +108,8 @@
 
     virtual bool avoidScrollbarCreation() const { return false; }
 
+    virtual void setScrollbarOverlayStyle(ScrollbarOverlayStyle);
+
     // By default you only receive paint events for the area that is visible. In the case of using a
     // tiled backing store, this function can be set, so that the view paints the entire contents.
     bool paintsEntireContents() const { return m_paintsEntireContents; }
@@ -389,6 +391,7 @@
     void platformSetScrollbarsSuppressed(bool repaintOnUnsuppress);
     void platformRepaintContentRectangle(const IntRect&, bool now);
     bool platformIsOffscreen() const;
+    void platformSetScrollbarOverlayStyle(ScrollbarOverlayStyle);
    
     void platformSetScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updatePositionSynchronously);
 

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (91434 => 91435)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2011-07-21 01:32:17 UTC (rev 91435)
@@ -182,6 +182,9 @@
 void ScrollableArea::didAddVerticalScrollbar(Scrollbar* scrollbar)
 {
     scrollAnimator()->didAddVerticalScrollbar(scrollbar);
+
+    // <rdar://problem/9797253> AppKit resets the scrollbar's style when you attach a scrollbar
+    setScrollbarOverlayStyle(scrollbarOverlayStyle());
 }
 
 void ScrollableArea::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
@@ -192,6 +195,9 @@
 void ScrollableArea::didAddHorizontalScrollbar(Scrollbar* scrollbar)
 {
     scrollAnimator()->didAddHorizontalScrollbar(scrollbar);
+
+    // <rdar://problem/9797253> AppKit resets the scrollbar's style when you attach a scrollbar
+    setScrollbarOverlayStyle(scrollbarOverlayStyle());
 }
 
 void ScrollableArea::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
@@ -205,6 +211,21 @@
         || (horizontalScrollbar() && horizontalScrollbar()->isOverlayScrollbar());
 }
 
+void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle)
+{
+    m_scrollbarOverlayStyle = overlayStyle;
+
+    if (horizontalScrollbar()) {
+        ScrollbarTheme::nativeTheme()->updateScrollbarOverlayStyle(horizontalScrollbar());
+        horizontalScrollbar()->invalidate();
+    }
+    
+    if (verticalScrollbar()) {
+        ScrollbarTheme::nativeTheme()->updateScrollbarOverlayStyle(verticalScrollbar());
+        verticalScrollbar()->invalidate();
+    }
+}
+
 bool ScrollableArea::isPinnedInDirection(const IntSize& scrollDelta) const
 {
     if (scrollDelta.width() < 0 && isHorizontalScrollerPinnedToMinimumPosition())

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (91434 => 91435)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2011-07-21 01:32:17 UTC (rev 91435)
@@ -77,7 +77,8 @@
     virtual void willRemoveHorizontalScrollbar(Scrollbar*);
 
     bool hasOverlayScrollbars() const;
-    virtual ScrollbarOverlayStyle recommendedScrollbarOverlayStyle() const { return ScrollbarOverlayStyleDefault; }
+    virtual void setScrollbarOverlayStyle(ScrollbarOverlayStyle);
+    ScrollbarOverlayStyle scrollbarOverlayStyle() const { return m_scrollbarOverlayStyle; }
 
     ScrollAnimator* scrollAnimator() const;
     const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
@@ -168,6 +169,8 @@
     ScrollElasticity m_verticalScrollElasticity;
     ScrollElasticity m_horizontalScrollElasticity;
 
+    ScrollbarOverlayStyle m_scrollbarOverlayStyle;
+
 protected:
     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
     virtual void invalidateScrollCornerRect(const IntRect&) = 0;

Modified: trunk/Source/WebCore/platform/ScrollbarTheme.h (91434 => 91435)


--- trunk/Source/WebCore/platform/ScrollbarTheme.h	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/platform/ScrollbarTheme.h	2011-07-21 01:32:17 UTC (rev 91435)
@@ -53,6 +53,7 @@
 
     virtual bool supportsControlTints() const { return false; }
     virtual bool usesOverlayScrollbars() const { return false; }
+    virtual void updateScrollbarOverlayStyle(Scrollbar*) { }
 
     virtual void themeChanged() {}
     

Modified: trunk/Source/WebCore/platform/mac/ScrollViewMac.mm (91434 => 91435)


--- trunk/Source/WebCore/platform/mac/ScrollViewMac.mm	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/platform/mac/ScrollViewMac.mm	2011-07-21 01:32:17 UTC (rev 91435)
@@ -203,6 +203,23 @@
     return ![platformWidget() window] || ![[platformWidget() window] isVisible];
 }
 
+static inline NSScrollerKnobStyle toNSScrollerKnobStyle(ScrollbarOverlayStyle style)
+{
+    switch (style) {
+    case ScrollbarOverlayStyleDark:
+        return NSScrollerKnobStyleDark;
+    case ScrollbarOverlayStyleLight:
+        return NSScrollerKnobStyleLight;
+    default:
+        return NSScrollerKnobStyleDefault;
+    }
+}
+
+void ScrollView::platformSetScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle)
+{
+    [scrollView() setScrollerKnobStyle:toNSScrollerKnobStyle(overlayStyle)];
+}
+
 void ScrollView::platformSetScrollOrigin(const IntPoint& origin, bool updatePositionAtAll, bool updatePositionSynchronously)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;

Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h (91434 => 91435)


--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h	2011-07-21 01:32:17 UTC (rev 91435)
@@ -47,6 +47,7 @@
     
     virtual bool supportsControlTints() const { return true; }
     virtual bool usesOverlayScrollbars() const;
+    virtual void updateScrollbarOverlayStyle(Scrollbar*);
 
     virtual double initialAutoscrollTimerDelay();
     virtual double autoscrollTimerDelay();

Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm (91434 => 91435)


--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm	2011-07-21 01:32:17 UTC (rev 91435)
@@ -161,6 +161,7 @@
     WKScrollbarPainterRef scrollbarPainter = wkMakeScrollbarPainter(scrollbar->controlSize(), isHorizontal);
     scrollbarMap()->add(scrollbar, scrollbarPainter);
     updateEnabledState(scrollbar);
+    updateScrollbarOverlayStyle(scrollbar);
 #else
     scrollbarMap()->add(scrollbar);
 #endif
@@ -176,6 +177,7 @@
 {
     scrollbarMap()->set(scrollbar, newPainter);
     updateEnabledState(scrollbar);
+    updateScrollbarOverlayStyle(scrollbar);
 }
 
 WKScrollbarPainterRef ScrollbarThemeMac::painterForScrollbar(Scrollbar* scrollbar)
@@ -226,6 +228,29 @@
 #endif
 }
 
+#if USE(WK_SCROLLBAR_PAINTER)
+static inline wkScrollerKnobStyle toScrollbarPainterKnobStyle(ScrollbarOverlayStyle style)
+{
+    switch (style) {
+    case ScrollbarOverlayStyleDark:
+        return wkScrollerKnobStyleDark;
+    case ScrollbarOverlayStyleLight:
+        return wkScrollerKnobStyleLight;
+    default:
+        return wkScrollerKnobStyleDefault;
+    }
+}
+#endif
+
+void ScrollbarThemeMac::updateScrollbarOverlayStyle(Scrollbar* scrollbar)
+{
+#if USE(WK_SCROLLBAR_PAINTER)
+    wkSetScrollbarPainterKnobStyle(painterForScrollbar(scrollbar), toScrollbarPainterKnobStyle(scrollbar->scrollableArea()->scrollbarOverlayStyle()));
+#else
+    UNUSED_PARAM(scrollbar);
+#endif
+}
+
 double ScrollbarThemeMac::initialAutoscrollTimerDelay()
 {
     return gInitialButtonDelay;
@@ -432,20 +457,6 @@
     }
 }
 
-#if USE(WK_SCROLLBAR_PAINTER)
-static inline wkScrollerKnobStyle toScrollbarPainterKnobStyle(ScrollbarOverlayStyle style)
-{
-    switch (style) {
-    case ScrollbarOverlayStyleDark:
-        return wkScrollerKnobStyleDark;
-    case ScrollbarOverlayStyleLight:
-        return wkScrollerKnobStyleLight;
-    default:
-        return wkScrollerKnobStyleDefault;
-    }
-}
-#endif
-
 void ScrollbarThemeMac::updateEnabledState(Scrollbar* scrollbar)
 {
 #if USE(WK_SCROLLBAR_PAINTER)
@@ -480,10 +491,6 @@
     
     ScrollAnimatorMac* scrollAnimator = static_cast<ScrollAnimatorMac*>(scrollbar->scrollableArea()->scrollAnimator());
     scrollAnimator->setIsDrawingIntoLayer(context->isCALayerContext());
-
-#if USE(WK_SCROLLBAR_PAINTER)
-    wkSetScrollbarPainterKnobStyle(painterForScrollbar(scrollbar), toScrollbarPainterKnobStyle(scrollbar->scrollableArea()->recommendedScrollbarOverlayStyle()));
-#endif
     
     GraphicsContextStateSaver stateSaver(*context);
     context->clip(damageRect);

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (91434 => 91435)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2011-07-21 01:32:17 UTC (rev 91435)
@@ -337,6 +337,8 @@
             }
             setNeedsLayoutAndPrefWidthsRecalc();
         }
+
+        frame()->view()->recalculateScrollbarOverlayStyle();
     }
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (91434 => 91435)


--- trunk/Source/WebKit2/ChangeLog	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebKit2/ChangeLog	2011-07-21 01:32:17 UTC (rev 91435)
@@ -1,3 +1,19 @@
+2011-07-20  Tim Horton  <[email protected]>
+
+        Scrollbar color heuristic needs to be hooked up in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=64220
+        <rdar://problem/9589140>
+
+        Reviewed by Darin Adler.
+
+        Store the scroller style on ScrollableArea, and recompute it whenever
+        the document or body element background color changes or the base background
+        color of the scrollview changes. Also, make sure to repaint the scrollbars
+        whenever the style changes.
+
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::getDocumentBackgroundColor):
+
 2011-07-20  James Robinson  <[email protected]>
 
         Revert worker and WebKit2 runloops to use currentTime() for scheduling instead of the monotonic clock

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (91434 => 91435)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp	2011-07-21 01:24:10 UTC (rev 91434)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp	2011-07-21 01:32:17 UTC (rev 91435)
@@ -561,7 +561,12 @@
 {
     if (!m_coreFrame)
         return false;
-    Color bgColor = m_coreFrame->getDocumentBackgroundColor();
+
+    FrameView* view = m_coreFrame->view();
+    if (!view)
+        return false;
+
+    Color bgColor = view->documentBackgroundColor();
     if (!bgColor.isValid())
         return false;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to