Title: [101290] trunk/Source
Revision
101290
Author
bda...@apple.com
Date
2011-11-28 15:06:56 -0800 (Mon, 28 Nov 2011)

Log Message

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.

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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101289 => 101290)


--- trunk/Source/WebCore/ChangeLog	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebCore/ChangeLog	2011-11-28 23:06:56 UTC (rev 101290)
@@ -1,3 +1,38 @@
+2011-11-28  Beth Dakin  <bda...@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  <jchaffr...@webkit.org>
 
         Add limited parsing support for grid-columns and grid-rows

Modified: trunk/Source/WebCore/page/ChromeClient.h (101289 => 101290)


--- trunk/Source/WebCore/page/ChromeClient.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebCore/page/ChromeClient.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -325,6 +325,7 @@
         virtual void didCompleteAnimatedScroll() const { }
         
         virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
+        virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
 
         enum DialogType {
             AlertDialog = 0,

Modified: trunk/Source/WebCore/page/FrameView.cpp (101289 => 101290)


--- trunk/Source/WebCore/page/FrameView.cpp	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebCore/page/FrameView.cpp	2011-11-28 23:06:56 UTC (rev 101290)
@@ -2448,6 +2448,19 @@
     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();

Modified: trunk/Source/WebCore/page/FrameView.h (101289 => 101290)


--- trunk/Source/WebCore/page/FrameView.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebCore/page/FrameView.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -292,6 +292,7 @@
     void flushAnyPendingPostLayoutTasks();
 
     virtual bool shouldSuspendScrollAnimations() const;
+    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
 
     void setAnimatorsAreActive();
 

Modified: trunk/Source/WebCore/platform/ScrollView.cpp (101289 => 101290)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2011-11-28 23:06:56 UTC (rev 101290)
@@ -973,8 +973,11 @@
     return !scrollCornerRect().isEmpty();
 }
 
-void ScrollView::scrollbarStyleChanged()
+void ScrollView::scrollbarStyleChanged(int, bool forceUpdate)
 {
+    if (!forceUpdate)
+        return;
+
     contentsResized();
     updateScrollbars(scrollOffset());
 }

Modified: trunk/Source/WebCore/platform/ScrollView.h (101289 => 101290)


--- trunk/Source/WebCore/platform/ScrollView.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebCore/platform/ScrollView.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -59,7 +59,7 @@
     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);

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (101289 => 101290)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -139,7 +139,7 @@
     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; }

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (101289 => 101290)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2011-11-28 23:06:56 UTC (rev 101290)
@@ -1461,8 +1461,7 @@
 
     // 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);
 }

Modified: trunk/Source/WebKit2/ChangeLog (101289 => 101290)


--- trunk/Source/WebKit2/ChangeLog	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-28 23:06:56 UTC (rev 101290)
@@ -1,3 +1,37 @@
+2011-11-28  Beth Dakin  <bda...@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.palen...@openbossa.org>
 
         [Qt][WK2] Fix panning after r101179

Modified: trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h (101289 => 101290)


--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -122,6 +122,8 @@
     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;

Modified: trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm (101289 => 101290)


--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm	2011-11-28 23:06:56 UTC (rev 101290)
@@ -460,6 +460,34 @@
 #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)];

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (101289 => 101290)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -177,6 +177,7 @@
     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

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (101289 => 101290)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-11-28 23:06:56 UTC (rev 101290)
@@ -3302,6 +3302,13 @@
     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;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (101289 => 101290)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -670,6 +670,7 @@
     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);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (101289 => 101290)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2011-11-28 23:06:56 UTC (rev 101290)
@@ -61,6 +61,7 @@
     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);

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp (101289 => 101290)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-11-28 23:06:56 UTC (rev 101290)
@@ -672,8 +672,11 @@
     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);

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h (101289 => 101290)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -134,7 +134,7 @@
     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.

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (101289 => 101290)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2011-11-28 23:06:56 UTC (rev 101290)
@@ -780,6 +780,11 @@
     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);

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (101289 => 101290)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2011-11-28 23:06:20 UTC (rev 101289)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2011-11-28 23:06:56 UTC (rev 101290)
@@ -214,6 +214,7 @@
     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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to