Commit 1752d5d7 authored by bweinstein@apple.com's avatar bweinstein@apple.com
Browse files

WebKit2: Support window bounce when panning.

https://bugs.webkit.org/show_bug.cgi?id=58065
<rdar://problem/9244367>
        
Reviewed by Adam Roben.

Make gestureDidScroll synchronous, as once we scroll, we need to know
whether or not we are at the beginning or end of the scrollable document.
        
If we are at either end of the scrollable document, we call the Windows 7
API to bounce the window to give an indication that you are past an end
of the document.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::gestureDidScroll): Pass a boolean for the reply, and return it.
* UIProcess/WebPageProxy.h:
* UIProcess/win/WebView.cpp:
(WebKit::WebView::WebView): Inititalize a new variable.
(WebKit::WebView::onGesture): Once we send the message to scroll, check if have gone to
    an end of the document, and if we have, bounce the window.
* UIProcess/win/WebView.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: GestureDidScroll is now sync.
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::WebPage::gestureDidScroll): When we are done scrolling, check if we have a vertical
    scrollbar and if we are at the beginning or the end of the scrollable document.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@83197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d5446357
2011-04-07 Brian Weinstein <bweinstein@apple.com>
Reviewed by Adam Roben.
WebKit2: Support window bounce when panning.
https://bugs.webkit.org/show_bug.cgi?id=58065
<rdar://problem/9244367>
Make gestureDidScroll synchronous, as once we scroll, we need to know
whether or not we are at the beginning or end of the scrollable document.
If we are at either end of the scrollable document, we call the Windows 7
API to bounce the window to give an indication that you are past an end
of the document.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::gestureDidScroll): Pass a boolean for the reply, and return it.
* UIProcess/WebPageProxy.h:
* UIProcess/win/WebView.cpp:
(WebKit::WebView::WebView): Inititalize a new variable.
(WebKit::WebView::onGesture): Once we send the message to scroll, check if have gone to
an end of the document, and if we have, bounce the window.
* UIProcess/win/WebView.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: GestureDidScroll is now sync.
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::WebPage::gestureDidScroll): When we are done scrolling, check if we have a vertical
scrollbar and if we are at the beginning or the end of the scrollable document.
2011-04-07 Chang Shu <cshu@webkit.org>
Reviewed by Darin Adler.
......
......@@ -670,14 +670,16 @@ String WebPageProxy::getSelectedText()
bool WebPageProxy::gestureWillBegin(const IntPoint& point)
{
bool canBeginPanning;
bool canBeginPanning = false;
process()->sendSync(Messages::WebPage::GestureWillBegin(point), Messages::WebPage::GestureWillBegin::Reply(canBeginPanning), m_pageID);
return canBeginPanning;
}
void WebPageProxy::gestureDidScroll(const IntSize& size)
bool WebPageProxy::gestureDidScroll(const IntSize& size)
{
process()->send(Messages::WebPage::GestureDidScroll(size), m_pageID);
bool atBeginningOrEndOfScrollableDocument = false;
process()->sendSync(Messages::WebPage::GestureDidScroll(size), Messages::WebPage::GestureDidScroll::Reply(atBeginningOrEndOfScrollableDocument), m_pageID);
return atBeginningOrEndOfScrollableDocument;
}
void WebPageProxy::gestureDidEnd()
......
......@@ -274,7 +274,7 @@ public:
String getSelectedText();
bool gestureWillBegin(const WebCore::IntPoint&);
void gestureDidScroll(const WebCore::IntSize&);
bool gestureDidScroll(const WebCore::IntSize&);
void gestureDidEnd();
#endif
#if ENABLE(TILED_BACKING_STORE)
......
......@@ -74,6 +74,11 @@ SOFT_LINK_OPTIONAL(USER32, GetGestureInfo, BOOL, WINAPI, (HGESTUREINFO, PGESTURE
SOFT_LINK_OPTIONAL(USER32, SetGestureConfig, BOOL, WINAPI, (HWND, DWORD, UINT, PGESTURECONFIG, UINT));
SOFT_LINK_OPTIONAL(USER32, CloseGestureInfoHandle, BOOL, WINAPI, (HGESTUREINFO));
SOFT_LINK_LIBRARY(Uxtheme);
SOFT_LINK_OPTIONAL(Uxtheme, BeginPanningFeedback, BOOL, WINAPI, (HWND));
SOFT_LINK_OPTIONAL(Uxtheme, EndPanningFeedback, BOOL, WINAPI, (HWND, BOOL));
SOFT_LINK_OPTIONAL(Uxtheme, UpdatePanningFeedback, BOOL, WINAPI, (HWND, LONG, LONG, BOOL));
using namespace WebCore;
namespace WebKit {
......@@ -269,6 +274,7 @@ WebView::WebView(RECT rect, WebContext* context, WebPageGroup* pageGroup, HWND p
, m_findIndicatorCallbackContext(0)
, m_lastPanX(0)
, m_lastPanY(0)
, m_overPanY(0)
{
registerWebViewWindowClass();
......@@ -522,8 +528,11 @@ LRESULT WebView::onGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
{
ASSERT(GetGestureInfoPtr());
ASSERT(CloseGestureInfoHandlePtr());
ASSERT(UpdatePanningFeedbackPtr());
ASSERT(BeginPanningFeedbackPtr());
ASSERT(EndPanningFeedbackPtr());
if (!GetGestureInfoPtr() || !CloseGestureInfoHandlePtr()) {
if (!GetGestureInfoPtr() || !CloseGestureInfoHandlePtr() || !UpdatePanningFeedbackPtr() || !BeginPanningFeedbackPtr() || !EndPanningFeedbackPtr()) {
handled = false;
return 0;
}
......@@ -557,12 +566,24 @@ LRESULT WebView::onGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
m_lastPanX = currentX;
m_lastPanY = currentY;
m_page->gestureDidScroll(IntSize(deltaX, deltaY));
// Calculate the overpan for window bounce.
m_overPanY -= deltaY;
bool shouldBounceWindow = m_page->gestureDidScroll(IntSize(deltaX, deltaY));
if (gi.dwFlags & GF_BEGIN) {
BeginPanningFeedbackPtr()(m_window);
m_overPanY = 0;
} else if (gi.dwFlags & GF_END) {
EndPanningFeedbackPtr()(m_window, true);
m_overPanY = 0;
}
// FIXME: Support horizontal window bounce - <http://webkit.org/b/58068>.
// FIXME: Window Bounce doesn't undo until user releases their finger - <http://webkit.org/b/58069>.
// FIXME <rdar://problem/9244367>: Support window bounce (both horizontal and vertical),
// if the uesr has scrolled past the end of the document. scollByPanGesture would need to
// be a sync message to support this, because we would need to know how far we scrolled
// past the end of the document.
if (shouldBounceWindow)
UpdatePanningFeedbackPtr()(m_window, 0, m_overPanY, gi.dwFlags & GF_INERTIA);
CloseGestureInfoHandlePtr()(gestureHandle);
......
......@@ -226,6 +226,8 @@ private:
int m_lastPanX;
int m_lastPanY;
int m_overPanY;
};
} // namespace WebKit
......
......@@ -323,8 +323,8 @@ public:
void firstRectForCharacterInSelectedRange(const uint64_t characterPosition, WebCore::IntRect& resultRect);
void getSelectedText(WTF::String&);
void gestureWillBegin(const WebCore::IntPoint& point, bool& canBeginPanning);
void gestureDidScroll(const WebCore::IntSize& size);
void gestureWillBegin(const WebCore::IntPoint&, bool& canBeginPanning);
void gestureDidScroll(const WebCore::IntSize&, bool& atBeginningOrEndOfDocument);
void gestureDidEnd();
#endif
......
......@@ -203,7 +203,7 @@ messages -> WebPage {
GetSelectedText() -> (WTF::String text)
GestureWillBegin(WebCore::IntPoint point) -> (bool canBeginPanning)
GestureDidScroll(WebCore::IntSize size)
GestureDidScroll(WebCore::IntSize size) -> (bool atBeginningOrEndOfScrollableDocument)
GestureDidEnd()
#endif
#if PLATFORM(QT)
......
......@@ -401,12 +401,28 @@ void WebPage::gestureWillBegin(const WebCore::IntPoint& point, bool& canBeginPan
canBeginPanning = false;
}
void WebPage::gestureDidScroll(const WebCore::IntSize& size)
void WebPage::gestureDidScroll(const IntSize& size, bool& atBeginningOrEndOfScrollableDocument)
{
atBeginningOrEndOfScrollableDocument = false;
if (!m_gestureTargetNode || !m_gestureTargetNode->renderer() || !m_gestureTargetNode->renderer()->enclosingLayer())
return;
m_gestureTargetNode->renderer()->enclosingLayer()->scrollByRecursively(size.width(), size.height());
Frame* frame = m_page->mainFrame();
if (!frame)
return;
ScrollView* view = frame->view();
if (!view)
return;
Scrollbar* verticalScrollbar = view->verticalScrollbar();
if (!verticalScrollbar)
return;
atBeginningOrEndOfScrollableDocument = !verticalScrollbar->currentPos() || verticalScrollbar->currentPos() >= verticalScrollbar->maximum();
}
void WebPage::gestureDidEnd()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment