Chromium Mac: Show scrollbar when doing search
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Aug 2011 22:46:42 +0000 (22:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Aug 2011 22:46:42 +0000 (22:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66209

Patch by Sailesh Agrawal <sail@chromium.org> on 2011-08-18
Reviewed by James Robinson.

Source/WebCore:

Updated the Lion scrollbar drawing code to force the scrollbar to be visible when we have tickmarks for search results.

No tests because there are no Mac 10.7 chromium bots yet.

* platform/chromium/ScrollbarThemeChromiumMac.h:
* platform/chromium/ScrollbarThemeChromiumMac.mm:
(WebCore::ScrollbarThemeChromiumMac::paint):
(WebCore::ScrollbarThemeChromiumMac::paintTickmarks):

Source/WebKit/chromium:

Fixed a bug in invalidateArea where it wouldn't properly invalidate overlay scrollbars. The problem was that it was assuming that the scrollbar was always to the right of the visible scrollbar. This isn't true for overlay scrollbars.

No tests because there are no Mac 10.7 chromium bots yet.

* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::invalidateArea):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h
Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebFrameImpl.cpp

index 0f380ee..6f0133b 100644 (file)
@@ -1,3 +1,19 @@
+2011-08-18  Sailesh Agrawal  <sail@chromium.org>
+
+        Chromium Mac: Show scrollbar when doing search
+        https://bugs.webkit.org/show_bug.cgi?id=66209
+
+        Reviewed by James Robinson.
+
+        Updated the Lion scrollbar drawing code to force the scrollbar to be visible when we have tickmarks for search results.
+
+        No tests because there are no Mac 10.7 chromium bots yet.
+
+        * platform/chromium/ScrollbarThemeChromiumMac.h:
+        * platform/chromium/ScrollbarThemeChromiumMac.mm:
+        (WebCore::ScrollbarThemeChromiumMac::paint):
+        (WebCore::ScrollbarThemeChromiumMac::paintTickmarks):
+
 2011-08-18  James Robinson  <jamesr@chromium.org>
 
         [chromium] Draw the root/"non-composited content" in compositor side
index 078985a..cc9a308 100644 (file)
@@ -80,7 +80,8 @@ protected:
     virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
     virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&);
 
-    virtual void paintTickmarks(GraphicsContext*, Scrollbar*, const IntRect&);
+private:
+    void paintGivenTickmarks(GraphicsContext*, Scrollbar*, const IntRect&, const Vector<IntRect>&);
 
 private:
     RefPtr<Pattern> m_overhangPattern;
index df20832..4af973d 100644 (file)
@@ -498,6 +498,10 @@ void ScrollbarThemeChromiumMac::updateEnabledState(Scrollbar* scrollbar)
 
 bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect)
 {
+    // Get the tickmarks for the frameview.
+    Vector<IntRect> tickmarks;
+    scrollbar->scrollableArea()->getTickmarks(tickmarks);
+
     if (isScrollbarOverlayAPIAvailable()) {
         float value = 0;
         float overhang = 0;
@@ -526,6 +530,16 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con
         scrollAnimator->setIsDrawingIntoLayer(false);
 #endif
 
+        CGFloat oldKnobAlpha = 0;
+        CGFloat oldTrackAlpha = 0;
+        bool hasTickmarks = tickmarks.size() > 0 && scrollbar->orientation() == VerticalScrollbar;
+        if (hasTickmarks) {
+          oldKnobAlpha = wkScrollbarPainterKnobAlpha(painterForScrollbar(scrollbar));
+          wkSetScrollbarPainterKnobAlpha(painterForScrollbar(scrollbar), 1.0);
+          oldTrackAlpha = wkScrollbarPainterTrackAlpha(painterForScrollbar(scrollbar));
+          wkSetScrollbarPainterTrackAlpha(painterForScrollbar(scrollbar), 1.0);
+        }
+
         GraphicsContextStateSaver stateSaver(*context);
         context->clip(damageRect);
         context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y());
@@ -547,11 +561,17 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con
             tickmarkTrackRect.setX(tickmarkTrackRect.x() + 2);
             tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 5);
         }
-        paintTickmarks(context, scrollbar, tickmarkTrackRect);
+        paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks);
 
         wkScrollbarPainterPaintKnob(scrollbarPainter);
 
         scrollAnimator->setIsDrawingIntoLayer(false);
+
+        if (hasTickmarks) {
+          wkSetScrollbarPainterKnobAlpha(scrollbarPainter, oldKnobAlpha);
+          wkSetScrollbarPainterTrackAlpha(scrollbarPainter, oldTrackAlpha);
+        }
+
         return true;
     }
 
@@ -620,7 +640,7 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con
     // Inset by 2 on the left and 3 on the right.
     tickmarkTrackRect.setX(tickmarkTrackRect.x() + 2);
     tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 5);
-    paintTickmarks(drawingContext, scrollbar, tickmarkTrackRect);
+    paintGivenTickmarks(drawingContext, scrollbar, tickmarkTrackRect, tickmarks);
 
     if (hasThumb(scrollbar)) {
         PlatformBridge::ThemePaintScrollbarInfo scrollbarInfo;
@@ -645,7 +665,7 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con
     return true;
 }
 
-void ScrollbarThemeChromiumMac::paintTickmarks(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
+void ScrollbarThemeChromiumMac::paintGivenTickmarks(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect, const Vector<IntRect>& tickmarks)
 {
     if (scrollbar->orientation() != VerticalScrollbar)
         return;
@@ -653,25 +673,13 @@ void ScrollbarThemeChromiumMac::paintTickmarks(GraphicsContext* context, Scrollb
     if (rect.height() <= 0 || rect.width() <= 0)
         return;  // nothing to draw on.
 
-    // Get the tickmarks for the frameview.
-    Vector<IntRect> tickmarks;
-    scrollbar->scrollableArea()->getTickmarks(tickmarks);
     if (!tickmarks.size())
         return;
 
-    int alphaInt = 0xFF;
-    if (scrollbarMap()->contains(scrollbar)) {
-        WKScrollbarPainterRef scrollbarPainter = scrollbarMap()->get(scrollbar).get();
-        if (scrollbarPainter)
-            alphaInt = 0xFF * wkScrollbarPainterTrackAlpha(scrollbarPainter);
-    }
-    if (alphaInt == 0)
-        return;
-
     context->save();
     context->setShouldAntialias(false);
-    context->setStrokeColor(Color(0xCC, 0xAA, 0x00, alphaInt), ColorSpaceDeviceRGB);
-    context->setFillColor(Color(0xFF, 0xDD, 0x00, alphaInt), ColorSpaceDeviceRGB);
+    context->setStrokeColor(Color(0xCC, 0xAA, 0x00, 0xFF), ColorSpaceDeviceRGB);
+    context->setFillColor(Color(0xFF, 0xDD, 0x00, 0xFF), ColorSpaceDeviceRGB);
 
     for (Vector<IntRect>::const_iterator i = tickmarks.begin(); i != tickmarks.end(); ++i) {
         // Calculate how far down (in %) the tick-mark should appear.
index aa84b56..1cf8d56 100644 (file)
@@ -1,3 +1,17 @@
+2011-08-18  Sailesh Agrawal  <sail@chromium.org>
+
+        Chromium Mac: Show scrollbar when doing search
+        https://bugs.webkit.org/show_bug.cgi?id=66209
+
+        Reviewed by James Robinson.
+
+        Fixed a bug in invalidateArea where it wouldn't properly invalidate overlay scrollbars. The problem was that it was assuming that the scrollbar was always to the right of the visible scrollbar. This isn't true for overlay scrollbars.
+
+        No tests because there are no Mac 10.7 chromium bots yet.
+
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::invalidateArea):
+
 2011-08-18  James Robinson  <jamesr@chromium.org>
 
         [chromium] Draw the root/"non-composited content" in compositor side
index 6c0617b..3e6f102 100644 (file)
@@ -2167,13 +2167,9 @@ void WebFrameImpl::invalidateArea(AreaToInvalidate area)
 
         if ((area & InvalidateScrollbar) == InvalidateScrollbar) {
             // Invalidate the vertical scroll bar region for the view.
-            IntRect scrollBarVert(
-                view->x() + view->visibleWidth(), view->y(),
-                ScrollbarTheme::nativeTheme()->scrollbarThickness(),
-                view->visibleHeight());
-            IntRect frameRect = view->frameRect();
-            scrollBarVert.move(-frameRect.x(), -frameRect.y());
-            view->invalidateRect(scrollBarVert);
+            Scrollbar* scrollbar = view->verticalScrollbar();
+            if (scrollbar)
+                scrollbar->invalidate();
         }
     }
 }