Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Unified Diff: Source/core/page/EventHandler.cpp

Issue 46353003: Switch AutoscrollController to use animation system instead of timer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@gclient
Patch Set: addresses review feedback Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/core/page/FocusController.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/EventHandler.cpp
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index 530cae3a1d43a9a4888662dc67a9f314cd0b1532..95680b0a9bd6e621fc9d8f355720928109031b08 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -57,6 +57,7 @@
#include "core/html/HTMLInputElement.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
+#include "core/page/AutoscrollController.h"
#include "core/page/BackForwardClient.h"
#include "core/page/Chrome.h"
#include "core/page/DragController.h"
@@ -702,8 +703,8 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
m_mouseDownMayStartDrag = false;
if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) {
- if (Page* page = m_frame->page()) {
- page->startAutoscrollForSelection(renderer);
+ if (AutoscrollController* controller = autoscrollController()) {
+ controller->startAutoscrollForSelection(renderer);
m_mouseDownMayStartAutoscroll = false;
}
}
@@ -800,9 +801,9 @@ void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& event)
{
- Page* page = m_frame->page();
- if (page && page->autoscrollInProgress())
- stopAutoscrollTimer();
+ AutoscrollController* controller = autoscrollController();
+ if (controller && controller->autoscrollInProgress())
+ stopAutoscroll();
// Used to prevent mouseMoveEvent from initiating a drag before
// the mouse is pressed again.
@@ -854,19 +855,25 @@ void EventHandler::startPanScrolling(RenderObject* renderer)
{
if (!renderer->isBox())
return;
- Page* page = m_frame->page();
- if (!page)
+ AutoscrollController* controller = autoscrollController();
+ if (!controller)
return;
- page->startPanScrolling(toRenderBox(renderer), lastKnownMousePosition());
+ controller->startPanScrolling(toRenderBox(renderer), lastKnownMousePosition());
invalidateClick();
}
#endif // OS(WIN)
+AutoscrollController* EventHandler::autoscrollController() const
+{
+ if (Page* page = m_frame->page())
+ return &page->autoscrollController();
+ return 0;
+}
+
bool EventHandler::panScrollInProgress() const
{
- Page* page = m_frame->page();
- return page && page->panScrollInProgress();
+ return autoscrollController() && autoscrollController()->panScrollInProgress();
}
HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding)
@@ -908,12 +915,10 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
return result;
}
-void EventHandler::stopAutoscrollTimer()
+void EventHandler::stopAutoscroll()
{
- Page* page = m_frame->page();
- if (!page)
- return;
- page->stopAutoscrollTimer();
+ if (AutoscrollController* controller = autoscrollController())
+ controller->stopAutoscroll();
}
Node* EventHandler::mousePressNode() const
@@ -1354,10 +1359,10 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
}
#if OS(WIN)
- // We store whether pan scrolling is in progress before calling stopAutoscrollTimer()
+ // We store whether pan scrolling is in progress before calling stopAutoscroll()
// because it will set m_autoscrollType to NoAutoscroll on return.
bool isPanScrollInProgress = panScrollInProgress();
- stopAutoscrollTimer();
+ stopAutoscroll();
if (isPanScrollInProgress) {
// We invalidate the click when exiting pan scrolling so that we don't inadvertently navigate
// away from the current page (e.g. the click was on a hyperlink). See <rdar://problem/6095023>.
@@ -1652,7 +1657,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
#if OS(WIN)
if (Page* page = m_frame->page())
- page->handleMouseReleaseForPanScrolling(m_frame, mouseEvent);
+ page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame, mouseEvent);
#endif
m_mousePressed = false;
@@ -1823,8 +1828,8 @@ bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard*
if (newTarget && newTarget->isTextNode())
newTarget = EventPath::parent(newTarget.get());
- if (Page* page = m_frame->page())
- page->updateDragAndDrop(newTarget.get(), event.position(), event.timestamp());
+ if (AutoscrollController* controller = autoscrollController())
+ controller->updateDragAndDrop(newTarget.get(), event.position(), event.timestamp());
if (m_dragTarget != newTarget) {
// FIXME: this ordering was explicitly chosen to match WinIE. However,
@@ -1909,7 +1914,7 @@ bool EventHandler::performDragAndDrop(const PlatformMouseEvent& event, Clipboard
void EventHandler::clearDragState()
{
- stopAutoscrollTimer();
+ stopAutoscroll();
m_dragTarget = 0;
m_capturingMouseEventsNode = 0;
m_shouldOnlyFireDragOverEvent = false;
@@ -3018,7 +3023,7 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
if (panScrollInProgress()) {
// If a key is pressed while the panScroll is in progress then we want to stop
if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent.type() == PlatformEvent::RawKeyDown)
- stopAutoscrollTimer();
+ stopAutoscroll();
// If we were in panscroll mode, we swallow the key event
return true;
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/core/page/FocusController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698