Chromium Code Reviews| Index: third_party/WebKit/Source/core/input/MouseEventManager.cpp |
| diff --git a/third_party/WebKit/Source/core/input/MouseEventManager.cpp b/third_party/WebKit/Source/core/input/MouseEventManager.cpp |
| index 69e5522b9c03c87d9e4f5272453d16c18fc9c7e9..be8b40bf8330592b2b0cfb289ad1940997f2de65 100644 |
| --- a/third_party/WebKit/Source/core/input/MouseEventManager.cpp |
| +++ b/third_party/WebKit/Source/core/input/MouseEventManager.cpp |
| @@ -59,20 +59,17 @@ PlatformMouseEvent mouseEventWithRegion(Node* node, |
| // during a scroll. |
| const double kFakeMouseMoveInterval = 0.1; |
| +// TODO(crbug.com/653490): Read these values from the OS. |
| #if OS(MACOSX) |
| +const int kDragThresholdX = 3; |
| +const int kDragThresholdY = 3; |
| const double kTextDragDelay = 0.15; |
| #else |
| +const int kDragThresholdX = 4; |
| +const int kDragThresholdY = 4; |
| const double kTextDragDelay = 0.0; |
| #endif |
| -// The link drag hysteresis is much larger than the others because there |
| -// needs to be enough space to cancel the link press without starting a link |
| -// drag, and because dragging links is rare. |
| -const int kLinkDragHysteresis = 40; |
| -const int kImageDragHysteresis = 5; |
| -const int kTextDragHysteresis = 3; |
| -const int kGeneralDragHysteresis = 3; |
| - |
| } // namespace |
| enum class DragInitiator { Mouse, Touch }; |
| @@ -782,11 +779,11 @@ bool MouseEventManager::handleDrag(const MouseEventWithHitTestResults& event, |
| m_frame->view()->setCursor(pointerCursor()); |
| if (initiator == DragInitiator::Mouse && |
| - !dragHysteresisExceeded(event.event().position())) |
| + !dragThresholdExceeded(event.event().position())) |
| return true; |
| - // Once we're past the hysteresis point, we don't want to treat this gesture |
| - // as a click |
| + // Once we're past the drag threshold, we don't want to treat this gesture as |
| + // a click. |
| invalidateClick(); |
| if (!tryStartDrag(event)) { |
| @@ -930,7 +927,7 @@ DragState& MouseEventManager::dragState() { |
| return state; |
| } |
| -bool MouseEventManager::dragHysteresisExceeded( |
| +bool MouseEventManager::dragThresholdExceeded( |
| const IntPoint& dragLocationInRootFrame) const { |
| FrameView* view = m_frame->view(); |
| if (!view) |
| @@ -938,24 +935,14 @@ bool MouseEventManager::dragHysteresisExceeded( |
| IntPoint dragLocation = view->rootFrameToContents(dragLocationInRootFrame); |
| IntSize delta = dragLocation - m_mouseDownPos; |
| - int threshold = kGeneralDragHysteresis; |
| - switch (dragState().m_dragType) { |
| - case DragSourceActionSelection: |
| - threshold = kTextDragHysteresis; |
| - break; |
| - case DragSourceActionImage: |
| - threshold = kImageDragHysteresis; |
| - break; |
| - case DragSourceActionLink: |
| - threshold = kLinkDragHysteresis; |
| - break; |
| - case DragSourceActionDHTML: |
| - break; |
| - case DragSourceActionNone: |
| - NOTREACHED(); |
| - } |
| + int thresholdX = kDragThresholdX; |
| + int thresholdY = kDragThresholdY; |
|
dcheng
2016/10/20 09:11:55
Nit: maybe just use the constants directly in the
pwnall
2016/10/20 09:47:46
Done.
|
| + |
| + // WebKit's drag thresholds depend on the type of object being dragged. If we |
| + // want to revive that behavior, we can multiply the thresholds above with a |
| + // constant based on dragState().m_dragType. |
| - return abs(delta.width()) >= threshold || abs(delta.height()) >= threshold; |
| + return abs(delta.width()) >= thresholdX || abs(delta.height()) >= thresholdY; |
| } |
| void MouseEventManager::clearDragHeuristicState() { |