Commit 3216752b authored by bdakin@apple.com's avatar bdakin@apple.com

Fix for <rdar://problem/8492788> Adopt WKScrollbarPainterController

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: http://svn.webkit.org/repository/webkit/trunk@77274 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 908f9ae2
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.
......@@ -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)
......
......@@ -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;
......
......@@ -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();
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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());
......
......@@ -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
......@@ -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
......
......@@ -32,21 +32,35 @@
#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;
......
......@@ -30,10 +30,15 @@
#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())