https://bugs.webkit.org/show_bug.cgi?id=72551
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2011 23:06:56 +0000 (23:06 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2011 23:06:56 +0000 (23:06 +0000)
When the recommended scrollbar style changes, WKView's tracking options should
adjust accordingly
-and corresponding-
<rdar://problem/10409328>

Reviewed by Darin Adler.

Source/WebCore:

This new ChromeClient function is called when the recommended scrollbar style
changes. This way, WebKit can respond to the change by adjusting its mouse
tracking.
* page/ChromeClient.h:
(WebCore::ChromeClient::recommendedScrollbarStyleDidChange):

Existing ScrollableArea function scrollbarStyleChanged() now takes an int
indicating the new scrollbar style and a bool indicating whether it is necessary
to force an update. It used to be the case that this function was ONLY used to
force an update (and only called when an updated was needed), but now that it must
also call into the ChromeClient, it is necessary to include a bool tracking
whether we need to force an update. New implementation on FrameView is responsible
for calling ChromeClient, and then that calls into the pre-existing ScrollView
function for the forceUpdate part.
* page/FrameView.cpp:
(WebCore::FrameView::scrollbarStyleChanged):
* page/FrameView.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView:: scrollbarStyleChanged):
* platform/ScrollView.h:
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::scrollbarStyleChanged):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::updateScrollerStyle):

Source/WebKit2:

These new functions take care of passing along the
recommendedScrollbarStyleDidChange() message that originates in the ChromeClient.
* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::recommendedScrollbarStyleDidChange):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::recommendedScrollbarStyleDidChange):
* WebProcess/WebCoreSupport/WebChromeClient.h:

This is where we actually respond to the recommendedScrollbarStyleDidChange
message. We remove the existing tracking area and create a new tracking area with
the appropriate tracking options.
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):

BuiltInPDFView inherits from WebCore::ScrollableArea, so scrollbarStyleChanged()
must now take two parameters like the one in ScrollableArea.
* WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
(WebKit::BuiltInPDFView::scrollbarStyleChanged):
* WebProcess/Plugins/PDF/BuiltInPDFView.h:

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

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp
Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

index a23bdb6..0b407a7 100755 (executable)
@@ -1,3 +1,38 @@
+2011-11-28  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=72551
+        When the recommended scrollbar style changes, WKView's tracking options should 
+        adjust accordingly
+        -and corresponding-
+        <rdar://problem/10409328>
+
+        Reviewed by Darin Adler.
+
+        This new ChromeClient function is called when the recommended scrollbar style 
+        changes. This way, WebKit can respond to the change by adjusting its mouse 
+        tracking.
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::recommendedScrollbarStyleDidChange):
+
+        Existing ScrollableArea function scrollbarStyleChanged() now takes an int 
+        indicating the new scrollbar style and a bool indicating whether it is necessary 
+        to force an update. It used to be the case that this function was ONLY used to 
+        force an update (and only called when an updated was needed), but now that it must 
+        also call into the ChromeClient, it is necessary to include a bool tracking 
+        whether we need to force an update. New implementation on FrameView is responsible 
+        for calling ChromeClient, and then that calls into the pre-existing ScrollView 
+        function for the forceUpdate part.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollbarStyleChanged):
+        * page/FrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView:: scrollbarStyleChanged):
+        * platform/ScrollView.h:
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::scrollbarStyleChanged):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::updateScrollerStyle):
+
 2011-11-28  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Add limited parsing support for grid-columns and grid-rows
index addcc0a..b6fda68 100644 (file)
@@ -325,6 +325,7 @@ namespace WebCore {
         virtual void didCompleteAnimatedScroll() const { }
         
         virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
+        virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
 
         enum DialogType {
             AlertDialog = 0,
index 84134cb..0328b01 100644 (file)
@@ -2448,6 +2448,19 @@ bool FrameView::shouldSuspendScrollAnimations() const
     return m_frame->loader()->state() != FrameStateComplete;
 }
 
+void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate)
+{
+    Page* page = m_frame->page();
+    if (!page)
+        return;
+    if (page->mainFrame() != m_frame)
+        return;
+    page->chrome()->client()->recommendedScrollbarStyleDidChange(newStyle);
+
+    if (forceUpdate)
+        ScrollView::scrollbarStyleChanged(newStyle, forceUpdate);
+}
+
 void FrameView::setAnimatorsAreActive()
 {
     Page* page = m_frame->page();
index a262be0..96a554b 100644 (file)
@@ -292,6 +292,7 @@ public:
     void flushAnyPendingPostLayoutTasks();
 
     virtual bool shouldSuspendScrollAnimations() const;
+    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
 
     void setAnimatorsAreActive();
 
index 005fc4a..99b98f0 100644 (file)
@@ -973,8 +973,11 @@ bool ScrollView::isScrollCornerVisible() const
     return !scrollCornerRect().isEmpty();
 }
 
-void ScrollView::scrollbarStyleChanged()
+void ScrollView::scrollbarStyleChanged(int, bool forceUpdate)
 {
+    if (!forceUpdate)
+        return;
+
     contentsResized();
     updateScrollbars(scrollOffset());
 }
index 3a7b8a9..9df9247 100644 (file)
@@ -59,7 +59,7 @@ public:
     virtual void didCompleteRubberBand(const IntSize&) const;
     virtual void notifyPageThatContentAreaWillPaint() const;
     virtual bool isScrollCornerVisible() const;
-    virtual void scrollbarStyleChanged();
+    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
 
     // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
     virtual void scrollTo(const IntSize& newOffset);
index f7fbe6d..44e3732 100644 (file)
@@ -139,7 +139,7 @@ public:
     virtual void didCompleteAnimatedScroll() const { }
     
     virtual bool shouldSuspendScrollAnimations() const { return true; }
-    virtual void scrollbarStyleChanged() { }
+    virtual void scrollbarStyleChanged(int /*newStyle*/, bool /*forceUpdate*/) { }
     virtual void setVisibleScrollerThumbRect(const IntRect&) { }
 
     virtual bool isOnActivePage() const { ASSERT_NOT_REACHED(); return true; }
index 3b872fc..5e2d211 100644 (file)
@@ -1461,8 +1461,7 @@ void ScrollAnimatorMac::updateScrollerStyle()
 
     // If needsScrollerStyleUpdate() is true, then the page is restoring from the page cache, and 
     // a relayout will happen on its own. Otherwise, we must initiate a re-layout ourselves.
-    if (!needsScrollerStyleUpdate())
-        scrollableArea()->scrollbarStyleChanged();
+    scrollableArea()->scrollbarStyleChanged(newStyle, !needsScrollerStyleUpdate());
 
     setNeedsScrollerStyleUpdate(false);
 }
index 3b4bf1f..34cfa96 100644 (file)
@@ -1,3 +1,37 @@
+2011-11-28  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=72551
+        When the recommended scrollbar style changes, WKView's tracking options should 
+        adjust accordingly
+        -and corresponding-
+        <rdar://problem/10409328>
+
+        Reviewed by Darin Adler.
+
+        These new functions take care of passing along the 
+        recommendedScrollbarStyleDidChange() message that originates in the ChromeClient. 
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::recommendedScrollbarStyleDidChange):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::recommendedScrollbarStyleDidChange):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+
+        This is where we actually respond to the recommendedScrollbarStyleDidChange 
+        message. We remove the existing tracking area and create a new tracking area with 
+        the appropriate tracking options.
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
+
+        BuiltInPDFView inherits from WebCore::ScrollableArea, so scrollbarStyleChanged() 
+        must now take two parameters like the one in ScrollableArea.
+        * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
+        (WebKit::BuiltInPDFView::scrollbarStyleChanged):
+        * WebProcess/Plugins/PDF/BuiltInPDFView.h:
+
 2011-11-28  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt][WK2] Fix panning after r101179
index ed30cce..8e3c5b7 100644 (file)
@@ -122,6 +122,8 @@ private:
     virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel);
     virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString);
 
+    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle);
+
     virtual WKView* wkView() const { return m_wkView; }
 
     WKView* m_wkView;
index 1dc2671..c1ae666 100644 (file)
@@ -460,6 +460,34 @@ void PageClientImpl::recordAutocorrectionResponse(EditorClient::AutocorrectionRe
 #endif
 }
 
+void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+    NSArray *trackingAreas = [m_wkView trackingAreas];
+    NSUInteger count = [trackingAreas count];
+    ASSERT(count == 1);
+    
+    for (NSUInteger i = 0; i < count; ++i)
+        [m_wkView removeTrackingArea:[trackingAreas objectAtIndex:i]];
+
+    // Now re-create a tracking area with the appropriate options given the new scrollbar style
+    NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
+    if (newStyle == NSScrollerStyleLegacy)
+        options |= NSTrackingActiveAlways;
+    else
+        options |= NSTrackingActiveInKeyWindow;
+
+    NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[m_wkView frame]
+                                                                options:options
+                                                                  owner:m_wkView
+                                                               userInfo:nil];
+    [m_wkView addTrackingArea:trackingArea];
+    [trackingArea release];
+#else
+    UNUSED_PARAM(newStyle);
+#endif
+}
+
 bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
 {
     return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)];
index 98727a3..3b1709c 100644 (file)
@@ -177,6 +177,7 @@ public:
     virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) = 0;
     virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel) = 0;
     virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
+    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) = 0;
     
     virtual WKView* wkView() const = 0;
 #endif
index f7acc91..e3599ba 100644 (file)
@@ -3302,6 +3302,13 @@ void WebPageProxy::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThu
     m_visibleScrollerThumbRect = scrollerThumb;
 }
 
+void WebPageProxy::recommendedScrollbarStyleDidChange(int32_t newStyle)
+{
+#if PLATFORM(MAC)
+    m_pageClient->recommendedScrollbarStyleDidChange(newStyle);
+#endif
+}
+
 void WebPageProxy::didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
 {
     m_mainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
index 7fdb970..8212417 100644 (file)
@@ -670,6 +670,7 @@ private:
     void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
     void runModal();
     void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&);
+    void recommendedScrollbarStyleDidChange(int32_t newStyle);
     void didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar);
     void didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide);
     void didChangePageCount(unsigned);
index 1efe284..aab9ea5 100644 (file)
@@ -61,6 +61,7 @@ messages -> WebPageProxy {
     PrintFrame(uint64_t frameID) -> ()
     RunModal()
     NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
+    RecommendedScrollbarStyleDidChange(int32_t newStyle)
     DidChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
     DidChangeScrollOffsetPinningForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
     DidChangePageCount(unsigned pageCount);
index 88b05af..a585cc9 100644 (file)
@@ -672,8 +672,11 @@ bool BuiltInPDFView::isOnActivePage() const
     return !pluginView()->frame()->document()->inPageCache();
 }
 
-void BuiltInPDFView::scrollbarStyleChanged()
+void BuiltInPDFView::scrollbarStyleChanged(int, bool forceUpdate)
 {
+    if (!forceUpdate)
+        return;
+
     // If the PDF was scrolled all the way to bottom right and scrollbars change to overlay style, we don't want to display white rectangles where scrollbars were.
     IntPoint newScrollOffset = IntPoint(m_scrollOffset).shrunkTo(maximumScrollPosition());
     setScrollOffset(newScrollOffset);
index 9960cae..4958e9d 100644 (file)
@@ -134,7 +134,7 @@ private:
     virtual bool isOnActivePage() const;
     virtual void disconnectFromPage() { m_page = 0; }
     virtual bool shouldSuspendScrollAnimations() const { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
-    virtual void scrollbarStyleChanged();
+    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
     virtual void zoomAnimatorTransformChanged(float, float, float, ZoomAnimationState) { }
 
     // FIXME: Implement the other conversion functions; this one is enough to get scrollbar hit testing working.
index 7563ff3..7c3689c 100644 (file)
@@ -780,6 +780,11 @@ void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scroller
     m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
 }
 
+void WebChromeClient::recommendedScrollbarStyleDidChange(int32_t newStyle)
+{
+    m_page->send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(newStyle));
+}
+
 bool WebChromeClient::shouldRubberBandInDirection(WebCore::ScrollDirection direction) const
 {
     ASSERT(direction != WebCore::ScrollUp && direction != WebCore::ScrollDown);
index a8031c3..d0767ba 100644 (file)
@@ -214,6 +214,7 @@ private:
     virtual void didCompleteAnimatedScroll() const OVERRIDE;
 
     virtual void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) OVERRIDE;
+    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) OVERRIDE;
     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE;
     
     virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE;