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

Side by Side Diff: third_party/WebKit/Source/core/page/AutoscrollController.cpp

Issue 2542693002: Use WTF::TimeTicks to represent timestamp in Platform/Core event types (Closed)
Patch Set: Don't fix bug in this patch Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 3 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 6 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 20 matching lines...) Expand all
31 31
32 #include "core/frame/FrameView.h" 32 #include "core/frame/FrameView.h"
33 #include "core/frame/LocalFrame.h" 33 #include "core/frame/LocalFrame.h"
34 #include "core/html/HTMLFrameOwnerElement.h" 34 #include "core/html/HTMLFrameOwnerElement.h"
35 #include "core/input/EventHandler.h" 35 #include "core/input/EventHandler.h"
36 #include "core/layout/HitTestResult.h" 36 #include "core/layout/HitTestResult.h"
37 #include "core/layout/LayoutBox.h" 37 #include "core/layout/LayoutBox.h"
38 #include "core/layout/LayoutListBox.h" 38 #include "core/layout/LayoutListBox.h"
39 #include "core/page/ChromeClient.h" 39 #include "core/page/ChromeClient.h"
40 #include "core/page/Page.h" 40 #include "core/page/Page.h"
41 #include "wtf/CurrentTime.h" 41 #include "wtf/Time.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 // Delay time in second for start autoscroll if pointer is in border edge of 45 // Delay time in second for start autoscroll if pointer is in border edge of
46 // scrollable element. 46 // scrollable element.
47 static double autoscrollDelay = 0.2; 47 static const TimeDelta kAutoscrollDelay = TimeDelta::FromSecondsD(0.2);
48 48
49 AutoscrollController* AutoscrollController::create(Page& page) { 49 AutoscrollController* AutoscrollController::create(Page& page) {
50 return new AutoscrollController(page); 50 return new AutoscrollController(page);
51 } 51 }
52 52
53 AutoscrollController::AutoscrollController(Page& page) 53 AutoscrollController::AutoscrollController(Page& page)
54 : m_page(&page), 54 : m_page(&page),
55 m_autoscrollLayoutObject(nullptr), 55 m_autoscrollLayoutObject(nullptr),
56 m_pressedLayoutObject(nullptr), 56 m_pressedLayoutObject(nullptr),
57 m_autoscrollType(NoAutoscroll), 57 m_autoscrollType(NoAutoscroll),
58 m_dragAndDropAutoscrollStartTime(0),
59 m_didLatchForMiddleClickAutoscroll(false) {} 58 m_didLatchForMiddleClickAutoscroll(false) {}
60 59
61 DEFINE_TRACE(AutoscrollController) { 60 DEFINE_TRACE(AutoscrollController) {
62 visitor->trace(m_page); 61 visitor->trace(m_page);
63 } 62 }
64 63
65 bool AutoscrollController::autoscrollInProgress() const { 64 bool AutoscrollController::autoscrollInProgress() const {
66 return m_autoscrollType == AutoscrollForSelection; 65 return m_autoscrollType == AutoscrollForSelection;
67 } 66 }
68 67
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 m_autoscrollLayoutObject = layoutObject && layoutObject->isBox() 144 m_autoscrollLayoutObject = layoutObject && layoutObject->isBox()
146 ? toLayoutBox(layoutObject) 145 ? toLayoutBox(layoutObject)
147 : nullptr; 146 : nullptr;
148 147
149 if (m_autoscrollType != NoAutoscroll && !m_autoscrollLayoutObject) 148 if (m_autoscrollType != NoAutoscroll && !m_autoscrollLayoutObject)
150 m_autoscrollType = NoAutoscroll; 149 m_autoscrollType = NoAutoscroll;
151 } 150 }
152 151
153 void AutoscrollController::updateDragAndDrop(Node* dropTargetNode, 152 void AutoscrollController::updateDragAndDrop(Node* dropTargetNode,
154 const IntPoint& eventPosition, 153 const IntPoint& eventPosition,
155 double eventTime) { 154 TimeTicks eventTime) {
156 if (!dropTargetNode || !dropTargetNode->layoutObject()) { 155 if (!dropTargetNode || !dropTargetNode->layoutObject()) {
157 stopAutoscroll(); 156 stopAutoscroll();
158 return; 157 return;
159 } 158 }
160 159
161 if (m_autoscrollLayoutObject && 160 if (m_autoscrollLayoutObject &&
162 m_autoscrollLayoutObject->frame() != 161 m_autoscrollLayoutObject->frame() !=
163 dropTargetNode->layoutObject()->frame()) 162 dropTargetNode->layoutObject()->frame())
164 return; 163 return;
165 164
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 return; 299 return;
301 } 300 }
302 301
303 EventHandler& eventHandler = 302 EventHandler& eventHandler =
304 m_autoscrollLayoutObject->frame()->eventHandler(); 303 m_autoscrollLayoutObject->frame()->eventHandler();
305 IntSize offset = m_autoscrollLayoutObject->calculateAutoscrollDirection( 304 IntSize offset = m_autoscrollLayoutObject->calculateAutoscrollDirection(
306 eventHandler.lastKnownMousePosition()); 305 eventHandler.lastKnownMousePosition());
307 IntPoint selectionPoint = eventHandler.lastKnownMousePosition() + offset; 306 IntPoint selectionPoint = eventHandler.lastKnownMousePosition() + offset;
308 switch (m_autoscrollType) { 307 switch (m_autoscrollType) {
309 case AutoscrollForDragAndDrop: 308 case AutoscrollForDragAndDrop:
310 if (WTF::monotonicallyIncreasingTime() - 309 if ((TimeTicks::Now() - m_dragAndDropAutoscrollStartTime) >
311 m_dragAndDropAutoscrollStartTime > 310 kAutoscrollDelay)
312 autoscrollDelay)
313 m_autoscrollLayoutObject->autoscroll( 311 m_autoscrollLayoutObject->autoscroll(
314 m_dragAndDropAutoscrollReferencePosition); 312 m_dragAndDropAutoscrollReferencePosition);
315 break; 313 break;
316 case AutoscrollForSelection: 314 case AutoscrollForSelection:
317 if (!eventHandler.mousePressed()) { 315 if (!eventHandler.mousePressed()) {
318 stopAutoscroll(); 316 stopAutoscroll();
319 return; 317 return;
320 } 318 }
321 eventHandler.updateSelectionForMouseDrag(); 319 eventHandler.updateSelectionForMouseDrag();
322 m_autoscrollLayoutObject->autoscroll(selectionPoint); 320 m_autoscrollLayoutObject->autoscroll(selectionPoint);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } else if (east) { 403 } else if (east) {
406 view->setCursor(eastPanningCursor()); 404 view->setCursor(eastPanningCursor());
407 } else if (west) { 405 } else if (west) {
408 view->setCursor(westPanningCursor()); 406 view->setCursor(westPanningCursor());
409 } else { 407 } else {
410 view->setCursor(middlePanningCursor()); 408 view->setCursor(middlePanningCursor());
411 } 409 }
412 } 410 }
413 411
414 } // namespace blink 412 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698