Skip to content

Commit

Permalink
WebKit2: Windows 7 Gestures Window Bounce shouldn't require a sync me…
Browse files Browse the repository at this point in the history
…ssage

https://bugs.webkit.org/show_bug.cgi?id=58167
<rdar://problem/9259813>

Reviewed by Adam Roben.

Instead of making GestureDidScroll sync, have WebPageWin call from WebProcess ->
UIProcess when the gesture causes the page to scroll to the beginning or the
end of the document.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::gestureDidScroll): Not a sync message anymore.
(WebKit::WebPageProxy::setGestureScrollingLimitReached): Tell the page client that the gesture
    scrolling limnit was reached.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in: Add a new message.
* UIProcess/win/WebView.cpp:
(WebKit::WebView::WebView): Initialize new variable.
(WebKit::WebView::onGesture): Use the state of the member variable, not the response from
    the sync message.
* UIProcess/win/WebView.h:
(WebKit::WebView::setGestureScrollingLimitReached):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::scrollbarAtTopOfBottomOrDocument): Returns whether or not the scrollbar is at the
    top or bottom of the document.
(WebKit::WebPage::gestureDidScroll): Track whether or not we started at the beginning
    or end of the document, and whether or not we ended at the beginning or end of the document,
    and send a message if the value changed.



Canonical link: https://commits.webkit.org/73231@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83460 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
b-weinstein committed Apr 11, 2011
1 parent 4c7f9e1 commit b684855
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 21 deletions.
34 changes: 34 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,37 @@
2011-04-11 Brian Weinstein <bweinstein@apple.com>

Reviewed by Adam Roben.

WebKit2: Windows 7 Gestures Window Bounce shouldn't require a sync message
https://bugs.webkit.org/show_bug.cgi?id=58167
<rdar://problem/9259813>

Instead of making GestureDidScroll sync, have WebPageWin call from WebProcess ->
UIProcess when the gesture causes the page to scroll to the beginning or the
end of the document.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::gestureDidScroll): Not a sync message anymore.
(WebKit::WebPageProxy::setGestureScrollingLimitReached): Tell the page client that the gesture
scrolling limnit was reached.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in: Add a new message.
* UIProcess/win/WebView.cpp:
(WebKit::WebView::WebView): Initialize new variable.
(WebKit::WebView::onGesture): Use the state of the member variable, not the response from
the sync message.
* UIProcess/win/WebView.h:
(WebKit::WebView::setGestureScrollingLimitReached):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::scrollbarAtTopOfBottomOrDocument): Returns whether or not the scrollbar is at the
top or bottom of the document.
(WebKit::WebPage::gestureDidScroll): Track whether or not we started at the beginning
or end of the document, and whether or not we ended at the beginning or end of the document,
and send a message if the value changed.

2011-04-04 Jer Noble <jer.noble@apple.com>

Reviewed by Maciej Stachowiak.
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/UIProcess/PageClient.h
Expand Up @@ -130,6 +130,7 @@ class PageClient {

#if PLATFORM(WIN)
virtual HWND nativeWindow() = 0;
virtual void setGestureReachedScrollingLimit(bool) = 0;
#endif

#if PLATFORM(MAC)
Expand Down
11 changes: 7 additions & 4 deletions Source/WebKit2/UIProcess/WebPageProxy.cpp
Expand Up @@ -675,17 +675,20 @@ bool WebPageProxy::gestureWillBegin(const IntPoint& point)
return canBeginPanning;
}

bool WebPageProxy::gestureDidScroll(const IntSize& size)
void WebPageProxy::gestureDidScroll(const IntSize& size)
{
bool atBeginningOrEndOfScrollableDocument = false;
process()->sendSync(Messages::WebPage::GestureDidScroll(size), Messages::WebPage::GestureDidScroll::Reply(atBeginningOrEndOfScrollableDocument), m_pageID);
return atBeginningOrEndOfScrollableDocument;
process()->send(Messages::WebPage::GestureDidScroll(size), m_pageID);
}

void WebPageProxy::gestureDidEnd()
{
process()->send(Messages::WebPage::GestureDidEnd(), m_pageID);
}

void WebPageProxy::setGestureReachedScrollingLimit(bool limitReached)
{
m_pageClient->setGestureReachedScrollingLimit(limitReached);
}
#endif

#if ENABLE(TILED_BACKING_STORE)
Expand Down
4 changes: 3 additions & 1 deletion Source/WebKit2/UIProcess/WebPageProxy.h
Expand Up @@ -276,8 +276,10 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
String getSelectedText();

bool gestureWillBegin(const WebCore::IntPoint&);
bool gestureDidScroll(const WebCore::IntSize&);
void gestureDidScroll(const WebCore::IntSize&);
void gestureDidEnd();

void setGestureReachedScrollingLimit(bool);
#endif
#if ENABLE(TILED_BACKING_STORE)
void setActualVisibleContentRect(const WebCore::IntRect& rect);
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit2/UIProcess/WebPageProxy.messages.in
Expand Up @@ -233,4 +233,9 @@ messages -> WebPageProxy {
DismissCorrectionPanelSoon(int32_t reason) -> (String result)
RecordAutocorrectionResponse(int32_t responseType, String replacedString, String replacementString);
#endif

#if PLATFORM(WIN)
# Windows 7 Gesture Messages
SetGestureReachedScrollingLimit(bool limitReached)
#endif
}
7 changes: 5 additions & 2 deletions Source/WebKit2/UIProcess/win/WebView.cpp
Expand Up @@ -275,6 +275,7 @@ WebView::WebView(RECT rect, WebContext* context, WebPageGroup* pageGroup, HWND p
, m_lastPanX(0)
, m_lastPanY(0)
, m_overPanY(0)
, m_gestureReachedScrollingLimit(false)
{
registerWebViewWindowClass();

Expand Down Expand Up @@ -569,10 +570,12 @@ LRESULT WebView::onGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
// Calculate the overpan for window bounce.
m_overPanY -= deltaY;

bool shouldBounceWindow = m_page->gestureDidScroll(IntSize(deltaX, deltaY));
if (deltaX || deltaY)
m_page->gestureDidScroll(IntSize(deltaX, deltaY));

if (gi.dwFlags & GF_BEGIN) {
BeginPanningFeedbackPtr()(m_window);
m_gestureReachedScrollingLimit = false;
m_overPanY = 0;
} else if (gi.dwFlags & GF_END) {
EndPanningFeedbackPtr()(m_window, true);
Expand All @@ -582,7 +585,7 @@ LRESULT WebView::onGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
// 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>.

if (shouldBounceWindow)
if (m_gestureReachedScrollingLimit)
UpdatePanningFeedbackPtr()(m_window, 0, m_overPanY, gi.dwFlags & GF_INERTIA);

CloseGestureInfoHandlePtr()(gestureHandle);
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit2/UIProcess/win/WebView.h
Expand Up @@ -191,6 +191,8 @@ class WebView : public APIObject, public PageClient, WebCore::WindowMessageListe

virtual HWND nativeWindow();

virtual void setGestureReachedScrollingLimit(bool limitReached) { m_gestureReachedScrollingLimit = limitReached; }

// WebCore::WindowMessageListener
virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);

Expand Down Expand Up @@ -231,6 +233,8 @@ class WebView : public APIObject, public PageClient, WebCore::WindowMessageListe
int m_lastPanY;

int m_overPanY;

bool m_gestureReachedScrollingLimit;
};

} // namespace WebKit
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Expand Up @@ -169,6 +169,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
, m_userSpaceScaleFactor(parameters.userSpaceScaleFactor)
, m_cachedMainFrameIsPinnedToLeftSide(false)
, m_cachedMainFrameIsPinnedToRightSide(false)
#if PLATFORM(WIN)
, m_gestureReachedScrollingLimit(false)
#endif
{
ASSERT(m_pageID);

Expand Down
6 changes: 5 additions & 1 deletion Source/WebKit2/WebProcess/WebPage/WebPage.h
Expand Up @@ -331,7 +331,7 @@ class WebPage : public APIObject, public CoreIPC::MessageSender<WebPage> {
void getSelectedText(WTF::String&);

void gestureWillBegin(const WebCore::IntPoint&, bool& canBeginPanning);
void gestureDidScroll(const WebCore::IntSize&, bool& atBeginningOrEndOfDocument);
void gestureDidScroll(const WebCore::IntSize&);
void gestureDidEnd();
#endif

Expand Down Expand Up @@ -632,6 +632,10 @@ class WebPage : public APIObject, public CoreIPC::MessageSender<WebPage> {

bool m_cachedMainFrameIsPinnedToLeftSide;
bool m_cachedMainFrameIsPinnedToRightSide;

#if PLATFORM(WIN)
bool m_gestureReachedScrollingLimit;
#endif
};

} // namespace WebKit
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Expand Up @@ -204,7 +204,7 @@ messages -> WebPage {
GetSelectedText() -> (WTF::String text)

GestureWillBegin(WebCore::IntPoint point) -> (bool canBeginPanning)
GestureDidScroll(WebCore::IntSize size) -> (bool atBeginningOrEndOfScrollableDocument)
GestureDidScroll(WebCore::IntSize size)
GestureDidEnd()
#endif
#if PLATFORM(QT)
Expand Down
35 changes: 23 additions & 12 deletions Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
Expand Up @@ -28,6 +28,7 @@

#include "FontSmoothingLevel.h"
#include "WebEvent.h"
#include "WebPageProxyMessages.h"
#include "WebPreferencesStore.h"
#include <WebCore/FocusController.h>
#include <WebCore/FontRenderingMode.h>
Expand Down Expand Up @@ -357,6 +358,8 @@ void WebPage::getSelectedText(String& text)

void WebPage::gestureWillBegin(const WebCore::IntPoint& point, bool& canBeginPanning)
{
m_gestureReachedScrollingLimit = false;

bool hitScrollbar = false;

HitTestRequest request(HitTestRequest::ReadOnly);
Expand Down Expand Up @@ -401,28 +404,36 @@ void WebPage::gestureWillBegin(const WebCore::IntPoint& point, bool& canBeginPan
canBeginPanning = false;
}

void WebPage::gestureDidScroll(const IntSize& size, bool& atBeginningOrEndOfScrollableDocument)
static bool scrollbarAtTopOrBottomOfDocument(Scrollbar* scrollbar)
{
atBeginningOrEndOfScrollableDocument = false;
ASSERT_ARG(scrollbar, scrollbar);
return !scrollbar->currentPos() || scrollbar->currentPos() >= scrollbar->maximum();
}

void WebPage::gestureDidScroll(const IntSize& size)
{
ASSERT_ARG(size, !size.isZero());

if (!m_gestureTargetNode || !m_gestureTargetNode->renderer() || !m_gestureTargetNode->renderer()->enclosingLayer())
return;

m_gestureTargetNode->renderer()->enclosingLayer()->scrollByRecursively(size.width(), size.height());
Scrollbar* verticalScrollbar = 0;
if (Frame* frame = m_page->mainFrame()) {
if (ScrollView* view = frame->view())
verticalScrollbar = view->verticalScrollbar();
}

Frame* frame = m_page->mainFrame();
if (!frame)
return;
m_gestureTargetNode->renderer()->enclosingLayer()->scrollByRecursively(size.width(), size.height());
bool gestureReachedScrollingLimit = verticalScrollbar && scrollbarAtTopOrBottomOfDocument(verticalScrollbar);

ScrollView* view = frame->view();
if (!view)
return;
// FIXME: We really only want to update this state if the state was updated via scrolling the main frame,
// not scrolling something in a main frame when the main frame had already reached its scrolling limit.

Scrollbar* verticalScrollbar = view->verticalScrollbar();
if (!verticalScrollbar)
if (gestureReachedScrollingLimit == m_gestureReachedScrollingLimit)
return;

atBeginningOrEndOfScrollableDocument = !verticalScrollbar->currentPos() || verticalScrollbar->currentPos() >= verticalScrollbar->maximum();
send(Messages::WebPageProxy::SetGestureReachedScrollingLimit(gestureReachedScrollingLimit));
m_gestureReachedScrollingLimit = gestureReachedScrollingLimit;
}

void WebPage::gestureDidEnd()
Expand Down

0 comments on commit b684855

Please sign in to comment.