| OLD | NEW |
| 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 Loading... |
| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 m_autoscrollLayoutObject = layoutObject && layoutObject->isBox() | 146 m_autoscrollLayoutObject = layoutObject && layoutObject->isBox() |
| 148 ? toLayoutBox(layoutObject) | 147 ? toLayoutBox(layoutObject) |
| 149 : nullptr; | 148 : nullptr; |
| 150 | 149 |
| 151 if (m_autoscrollType != NoAutoscroll && !m_autoscrollLayoutObject) | 150 if (m_autoscrollType != NoAutoscroll && !m_autoscrollLayoutObject) |
| 152 m_autoscrollType = NoAutoscroll; | 151 m_autoscrollType = NoAutoscroll; |
| 153 } | 152 } |
| 154 | 153 |
| 155 void AutoscrollController::updateDragAndDrop(Node* dropTargetNode, | 154 void AutoscrollController::updateDragAndDrop(Node* dropTargetNode, |
| 156 const IntPoint& eventPosition, | 155 const IntPoint& eventPosition, |
| 157 double eventTime) { | 156 TimeTicks eventTime) { |
| 158 if (!dropTargetNode || !dropTargetNode->layoutObject()) { | 157 if (!dropTargetNode || !dropTargetNode->layoutObject()) { |
| 159 stopAutoscroll(); | 158 stopAutoscroll(); |
| 160 return; | 159 return; |
| 161 } | 160 } |
| 162 | 161 |
| 163 if (m_autoscrollLayoutObject && | 162 if (m_autoscrollLayoutObject && |
| 164 m_autoscrollLayoutObject->frame() != | 163 m_autoscrollLayoutObject->frame() != |
| 165 dropTargetNode->layoutObject()->frame()) | 164 dropTargetNode->layoutObject()->frame()) |
| 166 return; | 165 return; |
| 167 | 166 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return; | 305 return; |
| 307 } | 306 } |
| 308 | 307 |
| 309 EventHandler& eventHandler = | 308 EventHandler& eventHandler = |
| 310 m_autoscrollLayoutObject->frame()->eventHandler(); | 309 m_autoscrollLayoutObject->frame()->eventHandler(); |
| 311 IntSize offset = m_autoscrollLayoutObject->calculateAutoscrollDirection( | 310 IntSize offset = m_autoscrollLayoutObject->calculateAutoscrollDirection( |
| 312 eventHandler.lastKnownMousePosition()); | 311 eventHandler.lastKnownMousePosition()); |
| 313 IntPoint selectionPoint = eventHandler.lastKnownMousePosition() + offset; | 312 IntPoint selectionPoint = eventHandler.lastKnownMousePosition() + offset; |
| 314 switch (m_autoscrollType) { | 313 switch (m_autoscrollType) { |
| 315 case AutoscrollForDragAndDrop: | 314 case AutoscrollForDragAndDrop: |
| 316 if (WTF::monotonicallyIncreasingTime() - | 315 if ((TimeTicks::Now() - m_dragAndDropAutoscrollStartTime) > |
| 317 m_dragAndDropAutoscrollStartTime > | 316 kAutoscrollDelay) |
| 318 autoscrollDelay) | |
| 319 m_autoscrollLayoutObject->autoscroll( | 317 m_autoscrollLayoutObject->autoscroll( |
| 320 m_dragAndDropAutoscrollReferencePosition); | 318 m_dragAndDropAutoscrollReferencePosition); |
| 321 break; | 319 break; |
| 322 case AutoscrollForSelection: | 320 case AutoscrollForSelection: |
| 323 if (!eventHandler.mousePressed()) { | 321 if (!eventHandler.mousePressed()) { |
| 324 stopAutoscroll(); | 322 stopAutoscroll(); |
| 325 return; | 323 return; |
| 326 } | 324 } |
| 327 eventHandler.updateSelectionForMouseDrag(); | 325 eventHandler.updateSelectionForMouseDrag(); |
| 328 m_autoscrollLayoutObject->autoscroll(selectionPoint); | 326 m_autoscrollLayoutObject->autoscroll(selectionPoint); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } else if (east) { | 409 } else if (east) { |
| 412 view->setCursor(eastPanningCursor()); | 410 view->setCursor(eastPanningCursor()); |
| 413 } else if (west) { | 411 } else if (west) { |
| 414 view->setCursor(westPanningCursor()); | 412 view->setCursor(westPanningCursor()); |
| 415 } else { | 413 } else { |
| 416 view->setCursor(middlePanningCursor()); | 414 view->setCursor(middlePanningCursor()); |
| 417 } | 415 } |
| 418 } | 416 } |
| 419 | 417 |
| 420 } // namespace blink | 418 } // namespace blink |
| OLD | NEW |