Fix for <rdar://problem/8492788> Adopt WKScrollbarPainterController
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Feb 2011 20:35:25 +0000 (20:35 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Feb 2011 20:35:25 +0000 (20:35 +0000)
Reviewed by Sam Weinig.

Source/WebCore:

Lots of new WebCoreSystemInterface functions to export.
* WebCore.exp.in:
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Let the scrollAnimator know when the mouse has
moved anywhere inside the page, and when the mouse
has moved in or out of the window.
* page/EventHandler.cpp:
(WebCore::EventHandler::mouseMoved):
(WebCore::EventHandler::updateMouseEventTargetNode):

Let the scrollAnimator know when the window has become
active or inactive.
* page/FocusController.cpp:
(WebCore::FocusController::setActive):

Let the scrollAnimator know when all of these things
are happening.
* page/FrameView.cpp:
(WebCore::FrameView::setContentsSize):
(WebCore::FrameView::didMoveOnscreen):
(WebCore::FrameView::willMoveOffscreen):
(WebCore::FrameView::currentMousePosition):
(WebCore::FrameView::contentsResized):

New functions called through WebKit2 that allow the
scrollAnimator to know when a live resize starts and ends.
(WebCore::FrameView::willStartLiveResize):
(WebCore::FrameView::willEndLiveResize):
* page/FrameView.h:

New functions on ScrollAnimator that pass information
to the WKPainterController when we're using one.
* platform/ScrollAnimator.h:
(WebCore::ScrollAnimator::scrollableArea):
(WebCore::ScrollAnimator::contentAreaWillPaint):
(WebCore::ScrollAnimator::mouseEnteredContentArea):
(WebCore::ScrollAnimator::mouseExitedContentArea):
(WebCore::ScrollAnimator::mouseMovedInContentArea):
(WebCore::ScrollAnimator::willStartLiveResize):
(WebCore::ScrollAnimator::contentsResized):
(WebCore::ScrollAnimator::willEndLiveResize):
(WebCore::ScrollAnimator::contentAreaDidShow):
(WebCore::ScrollAnimator::contentAreaDidHide):
(WebCore::ScrollAnimatorMac::ScrollAnimatorMac):
(WebCore::ScrollAnimatorMac::scrollbarPainterDelegate):
(WebCore::ScrollAnimatorMac::setPainterForPainterController):
(WebCore::ScrollAnimatorMac::removePainterFromPainterController):
(WebCore::ScrollAnimatorMac::notityPositionChanged):
(WebCore::ScrollAnimatorMac::contentAreaWillPaint):
(WebCore::ScrollAnimatorMac::mouseEnteredContentArea):
(WebCore::ScrollAnimatorMac::mouseExitedContentArea):
(WebCore::ScrollAnimatorMac::mouseMovedInContentArea):
(WebCore::ScrollAnimatorMac::willStartLiveResize):
(WebCore::ScrollAnimatorMac::contentsResized):
(WebCore::ScrollAnimatorMac::willEndLiveResize):
(WebCore::ScrollAnimatorMac::contentAreaDidShow):
(WebCore::ScrollAnimatorMac::contentAreaDidHide):

Let the scrollAnimator know when this is happening.
* platform/ScrollView.cpp:
(WebCore::ScrollView::paint):

New function lets the scrollAnimator get the current
mouse position.
* platform/ScrollView.h:
(WebCore::ScrollView::currentMousePosition):

New function that returns the scrollAnimator when needed.
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::scrollAnimator):

Keep track of if we're in a live resize using a new memeber
variable.
* platform/mac/ScrollAnimatorMac.h:
(WebCore::ScrollAnimatorMac::inLiveResize):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::view):

New delegates for the WKPainter and WKPainterController
(-[ScrollbarPainterControllerDelegate initWithScrollAnimator:WebCore::]):
(-[ScrollbarPainterControllerDelegate contentAreaRectForScrollerImpPair:]):
(-[ScrollbarPainterControllerDelegate inLiveResizeForScrollerImpPair:]):
(-[ScrollbarPainterControllerDelegate mouseLocationInContentAreaForScrollerImpPair:]):
(-[ScrollbarPainterControllerDelegate scrollerImpPair:convertContentPoint:toScrollerImp:]):
(-[ScrollbarPainterControllerDelegate scrollerImpPair:setContentAreaNeedsDisplayInRect:]):
(-[ScrollbarPainterControllerDelegate scrollerImpPair:updateScrollerStyleForNewRecommendedScrollerStyle:]):
(-[ScrollKnobAnimation initWithScrollbarPainter:forScrollAnimator:WebCore::animateKnobAlphaTo:duration:]):
(-[ScrollKnobAnimation setCurrentProgress:]):
(-[ScrollbarPainterDelegate initWithScrollAnimator:WebCore::]):
(-[ScrollbarPainterDelegate convertRectToBacking:]):
(-[ScrollbarPainterDelegate convertRectFromBacking:]):
(-[ScrollbarPainterDelegate layer]):
(-[ScrollbarPainterDelegate setUpAnimation:scrollerPainter:animateKnobAlphaTo:duration:]):
(-[ScrollbarPainterDelegate scrollerImp:animateKnobAlphaTo:duration:]):
(-[ScrollbarPainterDelegate scrollerImp:animateTrackAlphaTo:duration:]):
(-[ScrollbarPainterDelegate scrollerImp:overlayScrollerStateChangedTo:]):

Get the WKScrollbarPainterRefs to synch up with the
WKScrollbarPainterControllerRefs when appropriate
* platform/mac/ScrollbarThemeMac.h:
* platform/mac/ScrollbarThemeMac.mm:
(WebCore::ScrollbarThemeMac::registerScrollbar):
(WebCore::ScrollbarThemeMac::unregisterScrollbar):
(WebCore::ScrollbarThemeMac::setNewPainterForScrollbar):
(WebCore::ScrollbarThemeMac::usesOverlayScrollbars):

Implement ScrollableArea's virtual function contentsSize() for access
through the scrollAnimator.
* rendering/RenderLayer.h:
(WebCore::RenderLayer::contentsSize):

Source/WebKit/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKit2:

Implement NSView's viewWillStartLiveResize and
viewDidEndLiveResize and propagate the messages down
to WebCore.
* UIProcess/API/mac/WKView.mm:
(-[WKView viewWillStartLiveResize]):
(-[WKView viewDidEndLiveResize]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::viewWillStartLiveResize):
(WebKit::WebPageProxy::viewWillEndLiveResize):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::viewWillStartLiveResize):
(WebKit::WebPage::viewWillEndLiveResize):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

A bunch of new WebKitSystemInterface functions.
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

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

27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollAnimator.h
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollableArea.cpp
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/platform/mac/ScrollAnimatorMac.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/ScrollbarThemeMac.h
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/rendering/RenderLayer.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

index 5cec3474fdfad0c6cb749b642500001ff640d4a2..84c0dc6716ad47ce313e1fc89ac373e339624547 100644 (file)
@@ -1,3 +1,122 @@
+2011-02-01  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Fix for <rdar://problem/8492788> Adopt WKScrollbarPainterController
+
+        Lots of new WebCoreSystemInterface functions to export.
+        * WebCore.exp.in:
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+
+        Let the scrollAnimator know when the mouse has
+        moved anywhere inside the page, and when the mouse 
+        has moved in or out of the window. 
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::mouseMoved):
+        (WebCore::EventHandler::updateMouseEventTargetNode):
+
+        Let the scrollAnimator know when the window has become
+        active or inactive.
+        * page/FocusController.cpp:
+        (WebCore::FocusController::setActive):
+        
+        Let the scrollAnimator know when all of these things
+        are happening.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setContentsSize):
+        (WebCore::FrameView::didMoveOnscreen):
+        (WebCore::FrameView::willMoveOffscreen):
+        (WebCore::FrameView::currentMousePosition):
+        (WebCore::FrameView::contentsResized):
+        
+        New functions called through WebKit2 that allow the
+        scrollAnimator to know when a live resize starts and ends.
+        (WebCore::FrameView::willStartLiveResize):
+        (WebCore::FrameView::willEndLiveResize):
+        * page/FrameView.h:
+        
+        New functions on ScrollAnimator that pass information
+        to the WKPainterController when we're using one.
+        * platform/ScrollAnimator.h:
+        (WebCore::ScrollAnimator::scrollableArea):
+        (WebCore::ScrollAnimator::contentAreaWillPaint):
+        (WebCore::ScrollAnimator::mouseEnteredContentArea):
+        (WebCore::ScrollAnimator::mouseExitedContentArea):
+        (WebCore::ScrollAnimator::mouseMovedInContentArea):
+        (WebCore::ScrollAnimator::willStartLiveResize):
+        (WebCore::ScrollAnimator::contentsResized):
+        (WebCore::ScrollAnimator::willEndLiveResize):
+        (WebCore::ScrollAnimator::contentAreaDidShow):
+        (WebCore::ScrollAnimator::contentAreaDidHide):
+        (WebCore::ScrollAnimatorMac::ScrollAnimatorMac):
+        (WebCore::ScrollAnimatorMac::scrollbarPainterDelegate):
+        (WebCore::ScrollAnimatorMac::setPainterForPainterController):
+        (WebCore::ScrollAnimatorMac::removePainterFromPainterController):
+        (WebCore::ScrollAnimatorMac::notityPositionChanged):
+        (WebCore::ScrollAnimatorMac::contentAreaWillPaint):
+        (WebCore::ScrollAnimatorMac::mouseEnteredContentArea):
+        (WebCore::ScrollAnimatorMac::mouseExitedContentArea):
+        (WebCore::ScrollAnimatorMac::mouseMovedInContentArea):
+        (WebCore::ScrollAnimatorMac::willStartLiveResize):
+        (WebCore::ScrollAnimatorMac::contentsResized):
+        (WebCore::ScrollAnimatorMac::willEndLiveResize):
+        (WebCore::ScrollAnimatorMac::contentAreaDidShow):
+        (WebCore::ScrollAnimatorMac::contentAreaDidHide):
+        
+        Let the scrollAnimator know when this is happening.
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::paint):
+        
+        New function lets the scrollAnimator get the current 
+        mouse position.
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::currentMousePosition):
+        
+        New function that returns the scrollAnimator when needed.
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::scrollAnimator):
+        
+        Keep track of if we're in a live resize using a new memeber
+        variable.
+        * platform/mac/ScrollAnimatorMac.h:
+        (WebCore::ScrollAnimatorMac::inLiveResize):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::view):
+        
+        New delegates for the WKPainter and WKPainterController
+        (-[ScrollbarPainterControllerDelegate initWithScrollAnimator:WebCore::]):
+        (-[ScrollbarPainterControllerDelegate contentAreaRectForScrollerImpPair:]):
+        (-[ScrollbarPainterControllerDelegate inLiveResizeForScrollerImpPair:]):
+        (-[ScrollbarPainterControllerDelegate mouseLocationInContentAreaForScrollerImpPair:]):
+        (-[ScrollbarPainterControllerDelegate scrollerImpPair:convertContentPoint:toScrollerImp:]):
+        (-[ScrollbarPainterControllerDelegate scrollerImpPair:setContentAreaNeedsDisplayInRect:]):
+        (-[ScrollbarPainterControllerDelegate scrollerImpPair:updateScrollerStyleForNewRecommendedScrollerStyle:]):
+        (-[ScrollKnobAnimation initWithScrollbarPainter:forScrollAnimator:WebCore::animateKnobAlphaTo:duration:]):
+        (-[ScrollKnobAnimation setCurrentProgress:]):
+        (-[ScrollbarPainterDelegate initWithScrollAnimator:WebCore::]):
+        (-[ScrollbarPainterDelegate convertRectToBacking:]):
+        (-[ScrollbarPainterDelegate convertRectFromBacking:]):
+        (-[ScrollbarPainterDelegate layer]):
+        (-[ScrollbarPainterDelegate setUpAnimation:scrollerPainter:animateKnobAlphaTo:duration:]):
+        (-[ScrollbarPainterDelegate scrollerImp:animateKnobAlphaTo:duration:]):
+        (-[ScrollbarPainterDelegate scrollerImp:animateTrackAlphaTo:duration:]):
+        (-[ScrollbarPainterDelegate scrollerImp:overlayScrollerStateChangedTo:]):
+
+        Get the WKScrollbarPainterRefs to synch up with the 
+        WKScrollbarPainterControllerRefs when appropriate
+        * platform/mac/ScrollbarThemeMac.h:
+        * platform/mac/ScrollbarThemeMac.mm:
+        (WebCore::ScrollbarThemeMac::registerScrollbar):
+        (WebCore::ScrollbarThemeMac::unregisterScrollbar):
+        (WebCore::ScrollbarThemeMac::setNewPainterForScrollbar):
+        (WebCore::ScrollbarThemeMac::usesOverlayScrollbars):
+
+        Implement ScrollableArea's virtual function contentsSize() for access
+        through the scrollAnimator.
+        * rendering/RenderLayer.h:
+        (WebCore::RenderLayer::contentsSize):
+
 2011-02-01  Carol Szabo  <carol.szabo@nokia.com>
 
         Reviewed by David Hyatt.
index eac0c848b187b1527f1ee6c8789afe554426ee36..459cb83d36b365c230f5efb19f709a72fa702f2c 100644 (file)
@@ -1300,11 +1300,35 @@ _wkSignalCFReadStreamHasBytes
 _wkCreateCTTypesetterWithUniCharProviderAndOptions
 _wkIOSurfaceContextCreate
 _wkIOSurfaceContextCreateImage
-_wkMakeScrollbarPainter
-_wkScrollbarPainterPaint
-_wkScrollbarThickness
 _wkScrollbarMinimumThumbLength
 _wkScrollbarMinimumTotalLengthNeededForThumb
+_wkScrollbarPainterIsHorizontal
+_wkScrollbarPainterKnobAlpha
+_wkScrollbarPainterPaint
+_wkScrollbarPainterSetDelegate
+_wkScrollbarPainterSetOverlayState
+_wkScrollbarPainterUsesOverlayScrollers
+_wkScrollbarThickness
+_wkSetScrollbarPainterKnobAlpha
+_wkMakeScrollbarPainter
+_wkMakeScrollbarReplacementPainter
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+_wkContentAreaDidHide
+_wkContentAreaDidShow
+_wkContentAreaResized
+_wkContentAreaScrolled
+_wkContentAreaWillPaint
+_wkHorizontalScrollbarPainterForController
+_wkMakeScrollbarPainterController
+_wkMouseEnteredContentArea
+_wkMouseExitedContentArea
+_wkMouseMovedInContentArea
+_wkSetPainterForPainterController
+_wkSetScrollbarPainterControllerStyle
+_wkVerticalScrollbarPainterForController
+_wkWillEndLiveResize
+_wkWillStartLiveResize
+#endif
 #endif
 
 #if ENABLE(3D_RENDERING)
index 2cda1e4903c9f0e604a6239117a421e0c550af83..5734f931f99a7672bdc330a454fe841990b7a9be 100644 (file)
@@ -65,6 +65,7 @@
 #include "RenderTextControlSingleLine.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
+#include "ScrollAnimator.h"
 #include "Scrollbar.h"
 #include "SelectionController.h"
 #include "Settings.h"
@@ -1447,6 +1448,9 @@ bool EventHandler::mouseMoved(const PlatformMouseEvent& event)
     if (!page)
         return result;
 
+    if (FrameView* frameView = m_frame->view())
+        frameView->scrollAnimator()->mouseMovedInContentArea();  
+
     hoveredNode.setToNonShadowAncestor();
     page->chrome()->mouseDidMoveOverElement(hoveredNode, event.modifierFlags());
     page->chrome()->setToolTip(hoveredNode);
@@ -1854,6 +1858,23 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
 
     // Fire mouseout/mouseover if the mouse has shifted to a different node.
     if (fireMouseOverOut) {
+        // FIXME: This code will only correctly handle transitions between frames with scrollbars,
+        // not transitions between overflow regions, or transitions between two frames
+        // that don't have scrollbars contained within a frame that does.
+        if (m_lastNodeUnderMouse && (!m_nodeUnderMouse || m_nodeUnderMouse->document() != m_frame->document())) {
+            if (Frame* frame = m_lastNodeUnderMouse->document()->frame()) {
+                if (FrameView* frameView = frame->view())
+                    frameView->scrollAnimator()->mouseExitedContentArea();
+            }
+        }
+        
+        if (m_nodeUnderMouse && (!m_lastNodeUnderMouse || m_lastNodeUnderMouse->document() != m_frame->document())) {
+            if (Frame* frame = m_nodeUnderMouse->document()->frame()) {
+                if (FrameView* frameView = frame->view())
+                    frameView->scrollAnimator()->mouseEnteredContentArea();
+            }
+        }
+        
         if (m_lastNodeUnderMouse && m_lastNodeUnderMouse->document() != m_frame->document()) {
             m_lastNodeUnderMouse = 0;
             m_lastScrollbarUnderMouse = 0;
index eda1005777df1f14a2a030c5484d790242a58ea2..679288f4ffa8c68970f1bd7d79321c885dedb41a 100644 (file)
@@ -50,6 +50,7 @@
 #include "RenderLayer.h"
 #include "RenderObject.h"
 #include "RenderWidget.h"
+#include "ScrollAnimator.h"
 #include "SelectionController.h"
 #include "Settings.h"
 #include "SpatialNavigation.h"
@@ -407,6 +408,11 @@ void FocusController::setActive(bool active)
             view->updateLayoutAndStyleIfNeededRecursive();
             view->updateControlTints();
         }
+        // FIXME: This should propogate to all ScrollableAreas.
+        if (!active)
+            view->scrollAnimator()->contentAreaDidHide();
+        else
+            view->scrollAnimator()->contentAreaDidShow();
     }
 
     focusedOrMainFrame()->selection()->pageActivationChanged();
index cc74899dd1edbabf7521e06cdd2f684973ce180a..bbadea61c7b3d356c8b73a92ab1c187db5a45653 100644 (file)
@@ -56,6 +56,7 @@
 #include "RenderScrollbarPart.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "ScrollAnimator.h"
 #include "Settings.h"
 #include "TextResourceDecoder.h"
 #include <wtf/CurrentTime.h>
@@ -431,7 +432,8 @@ void FrameView::setContentsSize(const IntSize& size)
     m_deferSetNeedsLayouts++;
 
     ScrollView::setContentsSize(size);
-
+    scrollAnimator()->contentsResized();
+    
     Page* page = frame() ? frame()->page() : 0;
     if (!page)
         return;
@@ -702,6 +704,7 @@ void FrameView::didMoveOnscreen()
     RenderView* view = m_frame->contentRenderer();
     if (view)
         view->didMoveOnscreen();
+    scrollAnimator()->contentAreaDidShow();
 }
 
 void FrameView::willMoveOffscreen()
@@ -709,6 +712,7 @@ void FrameView::willMoveOffscreen()
     RenderView* view = m_frame->contentRenderer();
     if (view)
         view->willMoveOffscreen();
+    scrollAnimator()->contentAreaDidHide();
 }
 
 RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const
@@ -1074,6 +1078,11 @@ void FrameView::removeFixedObject()
         updateCanBlitOnScrollRecursively();
 }
 
+IntPoint FrameView::currentMousePosition() const
+{
+    return m_frame ? m_frame->eventHandler()->currentMousePosition() : IntPoint();
+}
+
 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
 {
     const size_t fixedObjectThreshold = 5;
@@ -1391,6 +1400,12 @@ void FrameView::repaintContentRectangle(const IntRect& r, bool immediate)
     ScrollView::repaintContentRectangle(r, immediate);
 }
 
+void FrameView::contentsResized()
+{
+    scrollAnimator()->contentsResized();
+    setNeedsLayout();
+}
+
 void FrameView::visibleContentsResized()
 {
     // We check to make sure the view is attached to a frame() as this method can
index 8586f77d3cb303209e9ac31ecbdf6658ff65384e..b606f87c8e7131010953f5cba5bbbd9f564ed902 100644 (file)
@@ -254,6 +254,8 @@ public:
     // On each repaint the delay increses by this amount
     static void setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(double p);
 
+    virtual IntPoint currentMousePosition() const;
+
 protected:
     virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
     virtual void scrollContentsSlowPath(const IntRect& updateRect);
@@ -284,7 +286,7 @@ private:
     void performPostLayoutTasks();
 
     virtual void repaintContentRectangle(const IntRect&, bool immediate);
-    virtual void contentsResized() { setNeedsLayout(); }
+    virtual void contentsResized();
     virtual void visibleContentsResized();
 
     // Override ScrollView methods to do point conversion via renderers, in order to
index 679b13f82e1ccb83ec7b584cbd84680a2ea637a2..e14bb2c0c787e49cbc3d427105e7093b07d11557 100644 (file)
@@ -58,6 +58,8 @@ public:
 
     virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
 
+    ScrollableArea* scrollableArea() const { return m_scrollableArea; }
+
     virtual void handleWheelEvent(PlatformWheelEvent&);
 #if ENABLE(GESTURE_EVENTS)
     virtual void handleGestureEvent(const PlatformGestureEvent&);
@@ -65,10 +67,20 @@ public:
 
     FloatPoint currentPosition() const;
 
+    virtual void contentAreaWillPaint() const { }
+    virtual void mouseEnteredContentArea() const { }
+    virtual void mouseExitedContentArea() const { }
+    virtual void mouseMovedInContentArea() const { }
+    virtual void willStartLiveResize() { }
+    virtual void contentsResized() const { }
+    virtual void willEndLiveResize() { }
+    virtual void contentAreaDidShow() const { }
+    virtual void contentAreaDidHide() const { }
+
 protected:
     ScrollAnimator(ScrollableArea*);
 
-    void notityPositionChanged();
+    virtual void notityPositionChanged();
 
     ScrollableArea* m_scrollableArea;
     float m_currentPosX; // We avoid using a FloatPoint in order to reduce
index 6161090a4bcc4e4bde27d4881f20177f28fdc229..caa3b45fbdb883b0b54ece568fd81da2acfbdba5 100644 (file)
@@ -31,6 +31,7 @@
 #include "HostWindow.h"
 #include "PlatformMouseEvent.h"
 #include "PlatformWheelEvent.h"
+#include "ScrollAnimator.h"
 #include "Scrollbar.h"
 #include "ScrollbarTheme.h"
 #include <wtf/StdLibExtras.h>
@@ -870,6 +871,8 @@ void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
     if (context->paintingDisabled() && !context->updatingControlTints())
         return;
 
+    scrollAnimator()->contentAreaWillPaint();
+    
     IntRect documentDirtyRect = rect;
     documentDirtyRect.intersect(frameRect());
 
index 9c929ab68dcefab0abfb8631c0b216b1f8965164..1dad741988c1e50f9a8fe5e753e1121d87d96cc7 100644 (file)
@@ -42,6 +42,7 @@ namespace WebCore {
 ScrollableArea::ScrollableArea()
     : m_scrollAnimator(ScrollAnimator::create(this))
     , m_constrainsScrollingToContentEdge(true)
+    , m_inLiveResize(false)
 {
 }
 
@@ -133,4 +134,20 @@ void ScrollableArea::setScrollOffsetFromAnimation(const IntPoint& offset)
         verticalScrollbar->offsetDidChange();
 }
 
+void ScrollableArea::willStartLiveResize()
+{
+    if (m_inLiveResize)
+        return;
+    m_inLiveResize = true;
+    scrollAnimator()->willStartLiveResize();
+}
+
+void ScrollableArea::willEndLiveResize()
+{
+    if (!m_inLiveResize)
+        return;
+    m_inLiveResize = false;
+    scrollAnimator()->willEndLiveResize();
+}    
+
 } // namespace WebCore
index 178cfc6612e51a70af06cbbf16bc273641f1740a..192d82b2ac0f1f864e57c515f201e8db0f57d6cb 100644 (file)
@@ -60,6 +60,8 @@ public:
     bool constrainsScrollingToContentEdge() const { return m_constrainsScrollingToContentEdge; }
     void setConstrainsScrollingToContentEdge(bool constrainsScrollingToContentEdge) { m_constrainsScrollingToContentEdge = constrainsScrollingToContentEdge; }
 
+    ScrollAnimator* scrollAnimator() const { return m_scrollAnimator.get(); }
+    
     virtual int scrollSize(ScrollbarOrientation) const = 0;
     virtual int scrollPosition(Scrollbar*) const = 0;
     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
@@ -104,9 +106,14 @@ public:
     virtual int visibleWidth() const { ASSERT_NOT_REACHED(); return 0; }
 
     virtual IntSize contentsSize() const { ASSERT_NOT_REACHED(); return IntSize(); }
-
     virtual IntSize overhangAmount() const { ASSERT_NOT_REACHED(); return IntSize(); }
 
+    virtual IntPoint currentMousePosition() const { return IntPoint(); }
+
+    virtual bool inLiveResize() const { return m_inLiveResize; }
+    virtual void willStartLiveResize();
+    virtual void willEndLiveResize();
+
 private:
     // NOTE: Only called from the ScrollAnimator.
     friend class ScrollAnimator;
@@ -114,6 +121,8 @@ private:
 
     OwnPtr<ScrollAnimator> m_scrollAnimator;
     bool m_constrainsScrollingToContentEdge;
+
+    bool m_inLiveResize;
 };
 
 } // namespace WebCore
index e9cdc2f65c663b43a0514d8ab3abe903125c0d6b..c969acabd7d11abe34dcbdef3ba9119241e76866 100644 (file)
 #include "FloatSize.h"
 #include "ScrollAnimator.h"
 #include "Timer.h"
+#include "WebCoreSystemInterface.h"
 #include <wtf/RetainPtr.h>
 
 #ifdef __OBJC__
 @class ScrollAnimationHelperDelegate;
+@class ScrollbarPainterDelegate;
+@class ScrollbarPainterControllerDelegate;
+@class ScrollbarPainterDelegate;
 #else
 class ScrollAnimationHelperDelegate;
+class ScrollbarPainterDelegate;
+class ScrollbarPainterControllerDelegate;
+class ScrollbarPainterDelegate;
 #endif
 
 namespace WebCore {
 
+class Scrollbar;
+
 class ScrollAnimatorMac : public ScrollAnimator {
 public:
     ScrollAnimatorMac(ScrollableArea*);
     virtual ~ScrollAnimatorMac();
 
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    void setPainterForPainterController(WKScrollbarPainterRef, bool isHorizontal);
+    void removePainterFromPainterController(ScrollbarOrientation orientation);
+#endif
+
     virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier);
     virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
 
@@ -61,10 +75,29 @@ public:
     void immediateScrollByDeltaX(float deltaX);
     void immediateScrollByDeltaY(float deltaY);
 
+    id scrollbarPainterDelegate();
+    
 private:
     RetainPtr<id> m_scrollAnimationHelper;
     RetainPtr<ScrollAnimationHelperDelegate> m_scrollAnimationHelperDelegate;
 
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    RetainPtr<WKScrollbarPainterControllerRef> m_scrollbarPainterController;
+    RetainPtr<ScrollbarPainterControllerDelegate> m_scrollbarPainterControllerDelegate;
+    RetainPtr<id> m_scrollbarPainterDelegate;
+#endif
+    
+    virtual void notityPositionChanged();
+    virtual void contentAreaWillPaint() const;
+    virtual void mouseEnteredContentArea() const;
+    virtual void mouseExitedContentArea() const;
+    virtual void mouseMovedInContentArea() const;
+    virtual void willStartLiveResize();
+    virtual void contentsResized() const;
+    virtual void willEndLiveResize();
+    virtual void contentAreaDidShow() const;
+    virtual void contentAreaDidHide() const;
+
 #if ENABLE(RUBBER_BANDING)
     bool allowsVerticalStretching() const;
     bool allowsHorizontalStretching() const;
index e56601670e59f59002fc2446ea6cbbfcb1346c02..47ade6e07b504e490e8704abf2dd50c7c940c0e4 100644 (file)
 #include "ScrollAnimatorMac.h"
 
 #include "FloatPoint.h"
-#include "PlatformWheelEvent.h"
+#include "IntRect.h"
 #include "PlatformGestureEvent.h"
+#include "PlatformWheelEvent.h"
+#include "ScrollView.h"
 #include "ScrollableArea.h"
+#include "ScrollbarTheme.h"
+#include "ScrollbarThemeMac.h"
 #include <wtf/PassOwnPtr.h>
+#include <wtf/UnusedParam.h>
 
 @interface NSObject (NSScrollAnimationHelperDetails)
 - (id)initWithDelegate:(id)delegate;
@@ -134,6 +139,232 @@ static NSSize abs(NSSize size)
 
 @end
 
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+@interface ScrollbarPainterControllerDelegate : NSObject
+{
+    WebCore::ScrollAnimatorMac* _animator;
+}
+
+- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator;
+
+- (NSRect)contentAreaRectForScrollerImpPair:(id)scrollerImpPair;
+- (BOOL)inLiveResizeForScrollerImpPair:(id)scrollerImpPair;
+- (NSPoint)mouseLocationInContentAreaForScrollerImpPair:(id)scrollerImpPair;
+- (NSPoint)scrollerImpPair:(id)scrollerImpPair convertContentPoint:(NSPoint)pointInContentArea toScrollerImp:(id)scrollerImp;
+- (void)scrollerImpPair:(id)scrollerImpPair setContentAreaNeedsDisplayInRect:(NSRect)rect;
+- (void)scrollerImpPair:(id)scrollerImpPair updateScrollerStyleForNewRecommendedScrollerStyle:(NSScrollerStyle)newRecommendedScrollerStyle;
+
+@end
+
+@implementation ScrollbarPainterControllerDelegate
+
+- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator
+{
+    self = [super init];
+    if (!self)
+        return nil;
+    
+    _animator = scrollAnimator;
+    return self;
+}
+
+- (NSRect)contentAreaRectForScrollerImpPair:(id)scrollerImpPair
+{
+    UNUSED_PARAM(scrollerImpPair);
+    WebCore::IntSize contentsSize = _animator->scrollableArea()->contentsSize();
+    return CGRectMake(0, 0, contentsSize.width(), contentsSize.height());
+}
+
+- (BOOL)inLiveResizeForScrollerImpPair:(id)scrollerImpPair
+{
+    UNUSED_PARAM(scrollerImpPair);
+    return _animator->inLiveResize();
+}
+
+- (NSPoint)mouseLocationInContentAreaForScrollerImpPair:(id)scrollerImpPair
+{
+    UNUSED_PARAM(scrollerImpPair);
+    return _animator->scrollableArea()->currentMousePosition();
+}
+
+- (NSPoint)scrollerImpPair:(id)scrollerImpPair convertContentPoint:(NSPoint)pointInContentArea toScrollerImp:(id)scrollerImp
+{
+    UNUSED_PARAM(scrollerImpPair);
+    UNUSED_PARAM(scrollerImp);
+    return pointInContentArea;
+}
+
+- (void)scrollerImpPair:(id)scrollerImpPair setContentAreaNeedsDisplayInRect:(NSRect)rect
+{
+    UNUSED_PARAM(scrollerImpPair);
+    UNUSED_PARAM(rect);
+}
+
+- (void)scrollerImpPair:(id)scrollerImpPair updateScrollerStyleForNewRecommendedScrollerStyle:(NSScrollerStyle)newRecommendedScrollerStyle
+{
+    WKScrollbarPainterControllerRef painterController = (WKScrollbarPainterControllerRef)scrollerImpPair;
+    WebCore::ScrollbarThemeMac* macTheme = (WebCore::ScrollbarThemeMac*)WebCore::ScrollbarTheme::nativeTheme();
+
+    WKScrollbarPainterRef oldVerticalPainter = wkVerticalScrollbarPainterForController(painterController);
+    if (oldVerticalPainter) {
+        WebCore::Scrollbar* verticalScrollbar = _animator->scrollableArea()->verticalScrollbar();
+        WKScrollbarPainterRef newVerticalPainter = wkMakeScrollbarReplacementPainter(oldVerticalPainter,
+                                                                                     newRecommendedScrollerStyle,
+                                                                                     verticalScrollbar->controlSize(),
+                                                                                     false);
+        macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainter);
+    }
+
+    WKScrollbarPainterRef oldHorizontalPainter = wkHorizontalScrollbarPainterForController(painterController);
+    if (oldHorizontalPainter) {
+        WebCore::Scrollbar* horizontalScrollbar = _animator->scrollableArea()->horizontalScrollbar();
+        WKScrollbarPainterRef newHorizontalPainter = wkMakeScrollbarReplacementPainter(oldHorizontalPainter,
+                                                                                       newRecommendedScrollerStyle,
+                                                                                       horizontalScrollbar->controlSize(),
+                                                                                       true);
+        macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPainter);
+    }
+
+    wkSetScrollbarPainterControllerStyle(painterController, newRecommendedScrollerStyle);
+}
+
+@end
+
+@interface ScrollKnobAnimation : NSAnimation
+{
+    RetainPtr<WKScrollbarPainterRef> _scrollerPainter;
+    WebCore::ScrollAnimatorMac* _animator;
+    CGFloat _initialKnobAlpha;
+    CGFloat _newKnobAlpha;
+}
+
+- (id)initWithScrollbarPainter:(WKScrollbarPainterRef)scrollerPainter forScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration;
+
+@end
+
+@implementation ScrollKnobAnimation
+
+- (id)initWithScrollbarPainter:(WKScrollbarPainterRef)scrollerPainter forScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration
+{
+    self = [super initWithDuration:duration animationCurve:NSAnimationEaseInOut];
+    if (!self)
+        return nil;
+    
+    _scrollerPainter = scrollerPainter;
+    _animator = scrollAnimator;
+    _initialKnobAlpha = wkScrollbarPainterKnobAlpha(_scrollerPainter.get());
+    _newKnobAlpha = newKnobAlpha;
+    
+    return self;    
+}
+
+- (void)setCurrentProgress:(NSAnimationProgress)progress
+{
+    [super setCurrentProgress:progress];
+
+    CGFloat currentAlpha;
+    if (_initialKnobAlpha > _newKnobAlpha)
+        currentAlpha = 1 - progress;
+    else
+        currentAlpha = progress;
+    wkSetScrollbarPainterKnobAlpha(_scrollerPainter.get(), currentAlpha);
+
+    // Invalidate the scrollbars so that they paint the animation
+    if (WebCore::Scrollbar* verticalScrollbar = _animator->scrollableArea()->verticalScrollbar())
+        _animator->scrollableArea()->invalidateScrollbarRect(verticalScrollbar, WebCore::IntRect(0, 0, verticalScrollbar->width(), verticalScrollbar->height()));
+    if (WebCore::Scrollbar* horizontalScrollbar = _animator->scrollableArea()->horizontalScrollbar())
+        _animator->scrollableArea()->invalidateScrollbarRect(horizontalScrollbar, WebCore::IntRect(0, 0, horizontalScrollbar->width(), horizontalScrollbar->height()));
+}
+
+@end
+
+@interface ScrollbarPainterDelegate : NSObject<NSAnimationDelegate>
+{
+    WebCore::ScrollAnimatorMac* _animator;
+    RetainPtr<ScrollKnobAnimation> _verticalKnobAnimation;
+    RetainPtr<ScrollKnobAnimation> _horizontalKnobAnimation;
+}
+
+- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator;
+
+- (NSRect)convertRectToBacking:(NSRect)aRect;
+- (NSRect)convertRectFromBacking:(NSRect)aRect;
+- (CALayer *)layer;
+
+- (void)scrollerImp:(id)scrollerImp animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration;
+- (void)scrollerImp:(id)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha duration:(NSTimeInterval)duration;
+- (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)newOverlayScrollerState;
+
+@end
+
+@implementation ScrollbarPainterDelegate
+
+- (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator
+{
+    self = [super init];
+    if (!self)
+        return nil;
+    
+    _animator = scrollAnimator;
+    return self;
+}
+
+- (NSRect)convertRectToBacking:(NSRect)aRect
+{
+    return aRect;
+}
+
+- (NSRect)convertRectFromBacking:(NSRect)aRect
+{
+    return aRect;
+}
+
+- (CALayer *)layer
+{
+    return nil;
+}
+
+- (void)setUpAnimation:(RetainPtr<ScrollKnobAnimation>)scrollKnobAnimation scrollerPainter:(WKScrollbarPainterRef)scrollerPainter animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration
+{
+    // If we are currently animating, stop
+    if (scrollKnobAnimation) {
+        [scrollKnobAnimation.get() stopAnimation];
+        scrollKnobAnimation = nil;
+    }
+    
+    scrollKnobAnimation.adoptNS([[ScrollKnobAnimation alloc] initWithScrollbarPainter:scrollerPainter 
+                                                                    forScrollAnimator:_animator 
+                                                                    animateKnobAlphaTo:newKnobAlpha 
+                                                                    duration:duration]);
+    [scrollKnobAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking];
+    [scrollKnobAnimation.get() startAnimation];
+}
+
+- (void)scrollerImp:(id)scrollerImp animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration
+{
+    WKScrollbarPainterRef scrollerPainter = (WKScrollbarPainterRef)scrollerImp;
+
+    if (wkScrollbarPainterIsHorizontal(scrollerPainter))
+        [self setUpAnimation:_horizontalKnobAnimation scrollerPainter:scrollerPainter animateKnobAlphaTo:newKnobAlpha duration:duration];
+    else
+        [self setUpAnimation:_verticalKnobAnimation scrollerPainter:scrollerPainter animateKnobAlphaTo:newKnobAlpha duration:duration];
+}
+
+- (void)scrollerImp:(id)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha duration:(NSTimeInterval)duration
+{
+    // FIXME: Implement.
+    UNUSED_PARAM(scrollerImp);
+    UNUSED_PARAM(newTrackAlpha);
+    UNUSED_PARAM(duration);
+}
+
+- (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)newOverlayScrollerState
+{
+    wkScrollbarPainterSetOverlayState((WKScrollbarPainterRef)scrollerImp, newOverlayScrollerState);
+}
+
+@end
+#endif // #if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
 
 namespace WebCore {
 
@@ -155,12 +386,39 @@ ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea)
 {
     m_scrollAnimationHelperDelegate.adoptNS([[ScrollAnimationHelperDelegate alloc] initWithScrollAnimator:this]);
     m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelper") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]);
+
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    m_scrollbarPainterControllerDelegate.adoptNS([[ScrollbarPainterControllerDelegate alloc] initWithScrollAnimator:this]);
+    m_scrollbarPainterController = wkMakeScrollbarPainterController(m_scrollbarPainterControllerDelegate.get());
+    m_scrollbarPainterDelegate.adoptNS([[ScrollbarPainterDelegate alloc] initWithScrollAnimator:this]);
+#endif
 }
 
 ScrollAnimatorMac::~ScrollAnimatorMac()
 {
 }
 
+id ScrollAnimatorMac::scrollbarPainterDelegate()
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    return m_scrollbarPainterDelegate.get();
+#else
+    return nil;
+#endif
+}
+
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+void ScrollAnimatorMac::setPainterForPainterController(WKScrollbarPainterRef painter, bool isHorizontal)
+{
+    wkSetPainterForPainterController(m_scrollbarPainterController.get(), painter, isHorizontal);
+}
+
+void ScrollAnimatorMac::removePainterFromPainterController(ScrollbarOrientation orientation)
+{
+    wkSetPainterForPainterController(m_scrollbarPainterController.get(), nil, orientation == HorizontalScrollbar);
+}
+#endif // #if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+
 bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier)
 {
     if (![[NSUserDefaults standardUserDefaults] boolForKey:@"AppleScrollAnimationEnabled"])
@@ -210,6 +468,77 @@ void ScrollAnimatorMac::immediateScrollByDeltaY(float deltaY)
     notityPositionChanged();
 }
 
+void ScrollAnimatorMac::notityPositionChanged()
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkContentAreaScrolled(m_scrollbarPainterController.get());
+#endif
+    ScrollAnimator::notityPositionChanged();
+}
+
+void ScrollAnimatorMac::contentAreaWillPaint() const
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkContentAreaWillPaint(m_scrollbarPainterController.get());
+#endif
+}
+
+void ScrollAnimatorMac::mouseEnteredContentArea() const
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkMouseEnteredContentArea(m_scrollbarPainterController.get());
+#endif
+}
+
+void ScrollAnimatorMac::mouseExitedContentArea() const
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkMouseExitedContentArea(m_scrollbarPainterController.get());
+#endif
+}
+
+void ScrollAnimatorMac::mouseMovedInContentArea() const
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkMouseMovedInContentArea(m_scrollbarPainterController.get());
+#endif
+}
+
+void ScrollAnimatorMac::willStartLiveResize()
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkWillStartLiveResize(m_scrollbarPainterController.get());
+#endif
+}
+
+void ScrollAnimatorMac::contentsResized() const
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkContentAreaResized(m_scrollbarPainterController.get());
+#endif
+}
+
+void ScrollAnimatorMac::willEndLiveResize()
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkWillEndLiveResize(m_scrollbarPainterController.get());
+#endif
+}
+
+void ScrollAnimatorMac::contentAreaDidShow() const
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkContentAreaDidShow(m_scrollbarPainterController.get());
+#endif
+}
+
+void ScrollAnimatorMac::contentAreaDidHide() const
+{
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    wkContentAreaDidHide(m_scrollbarPainterController.get());
+#endif
+}
+
 #if ENABLE(RUBBER_BANDING)
 
 static const float scrollVelocityZeroingTimeout = 0.10f;
index 8b5412d3306e9579dbc919a443ad915ac94ea893..b9894cdb3d117b6a66ced39694a4901408a62b3c 100644 (file)
@@ -27,6 +27,7 @@
 #define ScrollbarThemeMac_h
 
 #include "ScrollbarThemeComposite.h"
+#include "WebCoreSystemInterface.h"
 
 namespace WebCore {
 
@@ -50,6 +51,10 @@ public:
     virtual void registerScrollbar(Scrollbar*);
     virtual void unregisterScrollbar(Scrollbar*);
 
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    void setNewPainterForScrollbar(Scrollbar*, WKScrollbarPainterRef);
+#endif
+
 protected:
     virtual bool hasButtons(Scrollbar*);
     virtual bool hasThumb(Scrollbar*);
index e646a731f66866efda9cd2d5c93da37256460d20..9125754a08a5a22ad082f35740aa5f4edbabf6c8 100644 (file)
@@ -29,8 +29,8 @@
 #include "ImageBuffer.h"
 #include "LocalCurrentGraphicsContext.h"
 #include "PlatformMouseEvent.h"
+#include "ScrollAnimatorMac.h"
 #include "ScrollView.h"
-#include "WebCoreSystemInterface.h"
 #include <Carbon/Carbon.h>
 #include <wtf/HashMap.h>
 #include <wtf/StdLibExtras.h>
@@ -161,9 +161,15 @@ static void updateArrowPlacement()
 void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar)
 {
 #if defined(USE_WK_SCROLLBAR_PAINTER)
-    WKScrollbarPainterRef scrollbarPainter = wkMakeScrollbarPainter(scrollbar->controlSize(),
-        scrollbar->orientation() == HorizontalScrollbar);
+    bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar;
+    WKScrollbarPainterRef scrollbarPainter = wkMakeScrollbarPainter(scrollbar->controlSize(), isHorizontal);
     scrollbarMap()->add(scrollbar, scrollbarPainter);
+
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    ScrollAnimatorMac* animator = static_cast<ScrollAnimatorMac*>(scrollbar->scrollableArea()->scrollAnimator());
+    wkScrollbarPainterSetDelegate(scrollbarPainter, animator->scrollbarPainterDelegate());
+    animator->setPainterForPainterController(scrollbarPainter, isHorizontal);
+#endif
 #else
     scrollbarMap()->add(scrollbar);
 #endif
@@ -171,9 +177,21 @@ void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar)
 
 void ScrollbarThemeMac::unregisterScrollbar(Scrollbar* scrollbar)
 {
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    ScrollAnimatorMac* animator = static_cast<ScrollAnimatorMac*>(scrollbar->scrollableArea()->scrollAnimator());
+    animator->removePainterFromPainterController(scrollbar->orientation());
+#endif
+
     scrollbarMap()->remove(scrollbar);
 }
 
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+void ScrollbarThemeMac::setNewPainterForScrollbar(Scrollbar* scrollbar, WKScrollbarPainterRef newPainter)
+{
+    scrollbarMap()->set(scrollbar, newPainter);
+}
+#endif
+
 ScrollbarThemeMac::ScrollbarThemeMac()
 {
     static bool initialized;
@@ -209,8 +227,11 @@ int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize)
 
 bool ScrollbarThemeMac::usesOverlayScrollbars() const
 {
-    // FIXME: This should be enabled when <rdar://problem/8492788> is resolved.
+#if defined(USE_WK_SCROLLBAR_PAINTER)
+    return wkScrollbarPainterUsesOverlayScrollers();
+#else
     return false;
+#endif
 }
 
 double ScrollbarThemeMac::initialAutoscrollTimerDelay()
index fdd38dcebc3985ca8cd7e1a619e8d193e7b54d2e..a50a8632550938f2c22cce169c0544bf296318b6 100644 (file)
@@ -191,10 +191,37 @@ extern CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
 
 typedef struct __WKScrollbarPainter *WKScrollbarPainterRef;
 extern WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal);
+extern WKScrollbarPainterRef (*wkMakeScrollbarReplacementPainter)(WKScrollbarPainterRef oldPainter, int newStyle, int controlSize, bool isHorizontal);
+extern void (*wkScrollbarPainterSetDelegate)(WKScrollbarPainterRef, id scrollbarPainterDelegate);
 extern void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect);
 extern int (*wkScrollbarThickness)(int controlSize);
 extern int (*wkScrollbarMinimumThumbLength)(WKScrollbarPainterRef);
 extern int (*wkScrollbarMinimumTotalLengthNeededForThumb)(WKScrollbarPainterRef);
+extern CGFloat (*wkScrollbarPainterKnobAlpha)(WKScrollbarPainterRef);
+extern void (*wkSetScrollbarPainterKnobAlpha)(WKScrollbarPainterRef, CGFloat);
+extern bool (*wkScrollbarPainterIsHorizontal)(WKScrollbarPainterRef);
+extern void (*wkScrollbarPainterSetOverlayState)(WKScrollbarPainterRef, int overlayScrollerState);
+
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+typedef struct __WKScrollbarPainterController *WKScrollbarPainterControllerRef;
+extern WKScrollbarPainterControllerRef (*wkMakeScrollbarPainterController)(id painterControllerDelegate);
+extern void (*wkSetPainterForPainterController)(WKScrollbarPainterControllerRef, WKScrollbarPainterRef, bool isHorizontal);
+extern WKScrollbarPainterRef (*wkVerticalScrollbarPainterForController)(WKScrollbarPainterControllerRef);
+extern WKScrollbarPainterRef (*wkHorizontalScrollbarPainterForController)(WKScrollbarPainterControllerRef);
+extern void (*wkSetScrollbarPainterControllerStyle)(WKScrollbarPainterControllerRef, int newStyle);
+extern void (*wkContentAreaScrolled)(WKScrollbarPainterControllerRef);
+extern void (*wkContentAreaWillPaint)(WKScrollbarPainterControllerRef);
+extern void (*wkMouseEnteredContentArea)(WKScrollbarPainterControllerRef);
+extern void (*wkMouseExitedContentArea)(WKScrollbarPainterControllerRef);
+extern void (*wkMouseMovedInContentArea)(WKScrollbarPainterControllerRef);
+extern void (*wkWillStartLiveResize)(WKScrollbarPainterControllerRef);
+extern void (*wkContentAreaResized)(WKScrollbarPainterControllerRef);
+extern void (*wkWillEndLiveResize)(WKScrollbarPainterControllerRef);
+extern void (*wkContentAreaDidShow)(WKScrollbarPainterControllerRef);
+extern void (*wkContentAreaDidHide)(WKScrollbarPainterControllerRef);
+#endif
+
+extern bool (*wkScrollbarPainterUsesOverlayScrollers)(void);
 #endif
 
 }
index e281767aef6cd2ea9c22a21a11ea8f5408de9780..01840d3342008184d5c8753b2ec29fa2ce9fc228 100644 (file)
@@ -129,8 +129,34 @@ CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, u
 CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
 
 WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal);
+WKScrollbarPainterRef (*wkMakeScrollbarReplacementPainter)(WKScrollbarPainterRef oldPainter, int newStyle, int controlSize, bool isHorizontal);
+void (*wkScrollbarPainterSetDelegate)(WKScrollbarPainterRef, id scrollbarPainterDelegate);
 void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect);
 int (*wkScrollbarThickness)(int controlSize);
 int (*wkScrollbarMinimumThumbLength)(WKScrollbarPainterRef);
 int (*wkScrollbarMinimumTotalLengthNeededForThumb)(WKScrollbarPainterRef);
+CGFloat (*wkScrollbarPainterKnobAlpha)(WKScrollbarPainterRef);
+void (*wkSetScrollbarPainterKnobAlpha)(WKScrollbarPainterRef, CGFloat);
+bool (*wkScrollbarPainterIsHorizontal)(WKScrollbarPainterRef);
+void (*wkScrollbarPainterSetOverlayState)(WKScrollbarPainterRef, int overlayScrollerState);
+
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+WKScrollbarPainterControllerRef (*wkMakeScrollbarPainterController)(id painterControllerDelegate);
+void (*wkSetPainterForPainterController)(WKScrollbarPainterControllerRef, WKScrollbarPainterRef, bool isHorizontal);
+WKScrollbarPainterRef (*wkVerticalScrollbarPainterForController)(WKScrollbarPainterControllerRef);
+WKScrollbarPainterRef (*wkHorizontalScrollbarPainterForController)(WKScrollbarPainterControllerRef);
+void (*wkSetScrollbarPainterControllerStyle)(WKScrollbarPainterControllerRef, int newStyle);
+void (*wkContentAreaScrolled)(WKScrollbarPainterControllerRef);
+void (*wkContentAreaWillPaint)(WKScrollbarPainterControllerRef);
+void (*wkMouseEnteredContentArea)(WKScrollbarPainterControllerRef);
+void (*wkMouseExitedContentArea)(WKScrollbarPainterControllerRef);
+void (*wkMouseMovedInContentArea)(WKScrollbarPainterControllerRef);
+void (*wkWillStartLiveResize)(WKScrollbarPainterControllerRef);
+void (*wkContentAreaResized)(WKScrollbarPainterControllerRef);
+void (*wkWillEndLiveResize)(WKScrollbarPainterControllerRef);
+void (*wkContentAreaDidShow)(WKScrollbarPainterControllerRef);
+void (*wkContentAreaDidHide)(WKScrollbarPainterControllerRef);
+#endif
+
+bool (*wkScrollbarPainterUsesOverlayScrollers)(void);
 #endif
index a9a817bf99313591759b142468c9557f1d3316cf..dc0fcba7ce2682c9ac0af60289903e86dbd1d32e 100644 (file)
@@ -524,6 +524,7 @@ private:
     virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const;
     virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const;
     virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const;
+    virtual IntSize contentsSize() const { return size(); }
 
     // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
     void scrollTo(int x, int y);
index 97f5459331220089179f1be8ab7c974703177461..f3c4fa9f2d98bc6cf980abd94e7414304d5440b4 100644 (file)
@@ -1,3 +1,12 @@
+2011-02-01  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Fix for <rdar://problem/8492788> Adopt WKScrollbarPainterController
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2011-02-01  Dave Hyatt  <hyatt@apple.com>
 
         Reviewed by Darin Adler.
index e9bf1a9a339b2ad92e0c7d1f9fefda58c7299500..ce32671303c5b3f867143c000f01c3f96c42b754 100644 (file)
@@ -123,13 +123,35 @@ void InitWebCoreSystemInterface(void)
     INIT(CreateCTLineWithUniCharProvider);
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
-    INIT(IOSurfaceContextCreate);
-    INIT(IOSurfaceContextCreateImage);
     INIT(MakeScrollbarPainter);
+    INIT(ScrollbarPainterSetDelegate);
     INIT(ScrollbarPainterPaint);
     INIT(ScrollbarThickness);
     INIT(ScrollbarMinimumThumbLength);
     INIT(ScrollbarMinimumTotalLengthNeededForThumb);
+    INIT(ScrollbarPainterKnobAlpha);
+    INIT(SetScrollbarPainterKnobAlpha);
+    INIT(ScrollbarPainterIsHorizontal);
+    INIT(ScrollbarPainterSetOverlayState);
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+    INIT(MakeScrollbarPainterController);
+    INIT(MakeScrollbarReplacementPainter);
+    INIT(SetPainterForPainterController);
+    INIT(VerticalScrollbarPainterForController);
+    INIT(HorizontalScrollbarPainterForController);
+    INIT(SetScrollbarPainterControllerStyle);
+    INIT(ContentAreaScrolled);
+    INIT(ContentAreaWillPaint);
+    INIT(MouseEnteredContentArea);
+    INIT(MouseExitedContentArea);
+    INIT(MouseMovedInContentArea);
+    INIT(WillStartLiveResize);
+    INIT(ContentAreaResized);
+    INIT(WillEndLiveResize);
+    INIT(ContentAreaDidShow);
+    INIT(ContentAreaDidHide);
+#endif
+    INIT(ScrollbarPainterUsesOverlayScrollers);
 #endif
 
     didInit = true;
index 9a06458fc3ab83a1d8848ca3d68e49dc4ad5cc10..030e7334e9ebfaf2470b3da72142de1f07c4bdb4 100644 (file)
@@ -1,3 +1,29 @@
+2011-02-01  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Fix for <rdar://problem/8492788> Adopt WKScrollbarPainterController
+
+        Implement NSView's viewWillStartLiveResize and
+        viewDidEndLiveResize and propagate the messages down
+        to WebCore.
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView viewWillStartLiveResize]):
+        (-[WKView viewDidEndLiveResize]):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::viewWillStartLiveResize):
+        (WebKit::WebPageProxy::viewWillEndLiveResize):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::viewWillStartLiveResize):
+        (WebKit::WebPage::viewWillEndLiveResize):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
+        A bunch of new WebKitSystemInterface functions.
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2011-02-01  Dave Hyatt  <hyatt@apple.com>
 
         Reviewed by Darin Adler.
index a8c6cdabb95eca26f65687ba8a6f4127333604eb..1395d14db2c83380acdb444c6b2cc7f1c2b63593 100644 (file)
@@ -279,6 +279,16 @@ static bool useNewDrawingArea()
     return YES;
 }
 
+- (void)viewWillStartLiveResize
+{
+    _data->_page->viewWillStartLiveResize();
+}
+
+- (void)viewDidEndLiveResize
+{
+    _data->_page->viewWillEndLiveResize();
+}
+
 - (BOOL)isFlipped
 {
     return YES;
index 348be78856cfcda7626e228c2529599059457a94..39f7d44ddaaf4e3b3016f94bb9f6f1d4acd16413 100644 (file)
@@ -481,6 +481,16 @@ void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground
         process()->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
 }
 
+void WebPageProxy::viewWillStartLiveResize()
+{
+    process()->send(Messages::WebPage::ViewWillStartLiveResize(), m_pageID);
+}
+
+void WebPageProxy::viewWillEndLiveResize()
+{
+    process()->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
+}
+
 void WebPageProxy::setViewNeedsDisplay(const IntRect& rect)
 {
     m_pageClient->setViewNeedsDisplay(rect);
index c52a39afbf59c0fe95e4937be72f28b58441303e..72e2bbcb86d744008ce53b6c8828abd5cd1bebef 100644 (file)
@@ -172,6 +172,9 @@ public:
     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
     void setDrawsTransparentBackground(bool);
 
+    void viewWillStartLiveResize();
+    void viewWillEndLiveResize();
+
     void setInitialFocus(bool);
     void setWindowResizerSize(const WebCore::IntSize&);
 
index d1efc36621a60fa20c62f82b23b14c0c3b9b0001..8746cf7856e24dd38d05d0dd389427299ce5383c 100644 (file)
@@ -97,10 +97,34 @@ void InitWebCoreSystemInterface(void)
 #if !defined(BUILDING_ON_SNOW_LEOPARD)
         INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
         INIT(MakeScrollbarPainter);
+        INIT(ScrollbarPainterSetDelegate);
         INIT(ScrollbarPainterPaint);
         INIT(ScrollbarThickness);
         INIT(ScrollbarMinimumThumbLength);
         INIT(ScrollbarMinimumTotalLengthNeededForThumb);
+        INIT(ScrollbarPainterKnobAlpha);
+        INIT(SetScrollbarPainterKnobAlpha);
+        INIT(ScrollbarPainterIsHorizontal);
+        INIT(ScrollbarPainterSetOverlayState);
+        INIT(MakeScrollbarReplacementPainter);
+#if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
+        INIT(MakeScrollbarPainterController);
+        INIT(SetPainterForPainterController);
+        INIT(VerticalScrollbarPainterForController);
+        INIT(HorizontalScrollbarPainterForController);
+        INIT(SetScrollbarPainterControllerStyle);
+        INIT(ContentAreaScrolled);
+        INIT(ContentAreaWillPaint);
+        INIT(MouseEnteredContentArea);
+        INIT(MouseExitedContentArea);
+        INIT(MouseMovedInContentArea);
+        INIT(WillStartLiveResize);
+        INIT(ContentAreaResized);
+        INIT(WillEndLiveResize);
+        INIT(ContentAreaDidShow);
+        INIT(ContentAreaDidHide);
+#endif
+        INIT(ScrollbarPainterUsesOverlayScrollers);
 #else
         INIT(GetHyphenationLocationBeforeIndex);
 #endif
index 0d9eb34e8d694e508c103ab91d158c5fe57441b6..cadf1923f21f597e739eec4649f25a3e30924668 100644 (file)
@@ -1051,6 +1051,30 @@ void WebPage::setDrawsTransparentBackground(bool drawsTransparentBackground)
     m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize));
 }
 
+void WebPage::viewWillStartLiveResize()
+{
+    if (!m_page)
+        return;
+
+    // FIXME: This should propagate to all ScrollableAreas.
+    if (Frame* frame = m_page->focusController()->focusedOrMainFrame()) {
+        if (FrameView* view = frame->view())
+            view->willStartLiveResize();
+    }
+}
+
+void WebPage::viewWillEndLiveResize()
+{
+    if (!m_page)
+        return;
+
+    // FIXME: This should propagate to all ScrollableAreas.
+    if (Frame* frame = m_page->focusController()->focusedOrMainFrame()) {
+        if (FrameView* view = frame->view())
+            view->willEndLiveResize();
+    }
+}
+
 void WebPage::setFocused(bool isFocused)
 {
     m_page->focusController()->setFocused(isFocused);
index b8130112175e527a377fd632d15ade74ac19a9fb..1ac47c0b326188ce3b98d6c0c064564f1c61d6a2 100644 (file)
@@ -378,6 +378,9 @@ private:
     void setDrawsBackground(bool);
     void setDrawsTransparentBackground(bool);
 
+    void viewWillStartLiveResize();
+    void viewWillEndLiveResize();
+
     void getContentsAsString(uint64_t callbackID);
     void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID);
     void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID);
index 6ce4c31ecc4aa53fbf1908b9c9e938fc7905fb6b..fe7cd561b58b11c919c99fc61edc5659003c9401 100644 (file)
@@ -29,6 +29,9 @@ messages -> WebPage {
     SetDrawsBackground(bool drawsBackground)
     SetDrawsTransparentBackground(bool drawsTransparentBackground)
 
+    ViewWillStartLiveResize()
+    ViewWillEndLiveResize()
+
     KeyEvent(WebKit::WebKeyboardEvent event)
     MouseEvent(WebKit::WebMouseEvent event)
     WheelEvent(WebKit::WebWheelEvent event)