Title: [100826] trunk/Source
Revision
100826
Author
bda...@apple.com
Date
2011-11-18 16:31:44 -0800 (Fri, 18 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 (100825 => 100826)


--- trunk/Source/WebCore/ChangeLog	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebCore/ChangeLog	2011-11-19 00:31:44 UTC (rev 100826)
@@ -1,3 +1,38 @@
+2011-11-18  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-18  Kelly Norton  <knor...@google.com>
 
         Fixes several more void functions in RenderObject that return values.

Modified: trunk/Source/WebCore/page/ChromeClient.h (100825 => 100826)


--- trunk/Source/WebCore/page/ChromeClient.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebCore/page/ChromeClient.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebCore/page/FrameView.cpp	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebCore/page/FrameView.cpp	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebCore/page/FrameView.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebCore/page/FrameView.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebCore/platform/ScrollView.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebCore/platform/ScrollView.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebKit2/ChangeLog	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-19 00:31:44 UTC (rev 100826)
@@ -1,3 +1,37 @@
+2011-11-18  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-18  Dinu Jacob  <dinu.ja...@nokia.com>
 
         [Qt][Wk2] Add an API test for scroll request from _javascript_

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


--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-11-19 00:31:44 UTC (rev 100826)
@@ -3300,6 +3300,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 (100825 => 100826)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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 (100825 => 100826)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2011-11-19 00:31:44 UTC (rev 100826)
@@ -785,6 +785,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 (100825 => 100826)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2011-11-19 00:29:14 UTC (rev 100825)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2011-11-19 00:31:44 UTC (rev 100826)
@@ -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