OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. |
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 #include "core/events/TextEvent.h" | 49 #include "core/events/TextEvent.h" |
50 #include "core/events/TouchEvent.h" | 50 #include "core/events/TouchEvent.h" |
51 #include "core/events/WheelEvent.h" | 51 #include "core/events/WheelEvent.h" |
52 #include "core/fetch/ImageResource.h" | 52 #include "core/fetch/ImageResource.h" |
53 #include "core/frame/Deprecation.h" | 53 #include "core/frame/Deprecation.h" |
54 #include "core/frame/EventHandlerRegistry.h" | 54 #include "core/frame/EventHandlerRegistry.h" |
55 #include "core/frame/FrameHost.h" | 55 #include "core/frame/FrameHost.h" |
56 #include "core/frame/FrameView.h" | 56 #include "core/frame/FrameView.h" |
57 #include "core/frame/LocalFrame.h" | 57 #include "core/frame/LocalFrame.h" |
58 #include "core/frame/Settings.h" | 58 #include "core/frame/Settings.h" |
59 #include "core/frame/TopControls.h" | |
60 #include "core/frame/UseCounter.h" | 59 #include "core/frame/UseCounter.h" |
61 #include "core/frame/VisualViewport.h" | 60 #include "core/frame/VisualViewport.h" |
62 #include "core/html/HTMLDialogElement.h" | 61 #include "core/html/HTMLDialogElement.h" |
63 #include "core/html/HTMLFrameElementBase.h" | 62 #include "core/html/HTMLFrameElementBase.h" |
64 #include "core/html/HTMLFrameSetElement.h" | 63 #include "core/html/HTMLFrameSetElement.h" |
65 #include "core/html/HTMLInputElement.h" | 64 #include "core/html/HTMLInputElement.h" |
66 #include "core/input/InputDeviceCapabilities.h" | 65 #include "core/input/InputDeviceCapabilities.h" |
67 #include "core/input/TouchActionUtil.h" | 66 #include "core/input/TouchActionUtil.h" |
68 #include "core/layout/HitTestRequest.h" | 67 #include "core/layout/HitTestRequest.h" |
69 #include "core/layout/HitTestResult.h" | 68 #include "core/layout/HitTestResult.h" |
70 #include "core/layout/LayoutPart.h" | 69 #include "core/layout/LayoutPart.h" |
71 #include "core/layout/LayoutTextControlSingleLine.h" | 70 #include "core/layout/LayoutTextControlSingleLine.h" |
72 #include "core/layout/LayoutView.h" | 71 #include "core/layout/LayoutView.h" |
73 #include "core/layout/api/LayoutViewItem.h" | 72 #include "core/layout/api/LayoutViewItem.h" |
74 #include "core/loader/DocumentLoader.h" | 73 #include "core/loader/DocumentLoader.h" |
75 #include "core/loader/FrameLoader.h" | 74 #include "core/loader/FrameLoader.h" |
76 #include "core/loader/FrameLoaderClient.h" | 75 #include "core/loader/FrameLoaderClient.h" |
77 #include "core/page/AutoscrollController.h" | 76 #include "core/page/AutoscrollController.h" |
78 #include "core/page/ChromeClient.h" | 77 #include "core/page/ChromeClient.h" |
79 #include "core/page/DragController.h" | 78 #include "core/page/DragController.h" |
80 #include "core/page/DragState.h" | 79 #include "core/page/DragState.h" |
81 #include "core/page/FocusController.h" | 80 #include "core/page/FocusController.h" |
82 #include "core/page/FrameTree.h" | 81 #include "core/page/FrameTree.h" |
83 #include "core/page/Page.h" | 82 #include "core/page/Page.h" |
84 #include "core/page/SpatialNavigation.h" | 83 #include "core/page/SpatialNavigation.h" |
85 #include "core/page/TouchAdjustment.h" | 84 #include "core/page/TouchAdjustment.h" |
86 #include "core/page/scrolling/OverscrollController.h" | |
87 #include "core/page/scrolling/RootScroller.h" | |
88 #include "core/page/scrolling/ScrollState.h" | 85 #include "core/page/scrolling/ScrollState.h" |
89 #include "core/paint/PaintLayer.h" | 86 #include "core/paint/PaintLayer.h" |
90 #include "core/style/ComputedStyle.h" | 87 #include "core/style/ComputedStyle.h" |
91 #include "core/style/CursorData.h" | 88 #include "core/style/CursorData.h" |
92 #include "core/svg/SVGDocumentExtensions.h" | 89 #include "core/svg/SVGDocumentExtensions.h" |
93 #include "platform/PlatformGestureEvent.h" | 90 #include "platform/PlatformGestureEvent.h" |
94 #include "platform/PlatformKeyboardEvent.h" | 91 #include "platform/PlatformKeyboardEvent.h" |
95 #include "platform/PlatformTouchEvent.h" | 92 #include "platform/PlatformTouchEvent.h" |
96 #include "platform/PlatformWheelEvent.h" | 93 #include "platform/PlatformWheelEvent.h" |
97 #include "platform/RuntimeEnabledFeatures.h" | 94 #include "platform/RuntimeEnabledFeatures.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid get and thus the | 133 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid get and thus the |
137 // event target node can't still be the shadow node. | 134 // event target node can't still be the shadow node. |
138 bool shouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) | 135 bool shouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) |
139 { | 136 { |
140 Node* targetNode = mev.innerNode(); | 137 Node* targetNode = mev.innerNode(); |
141 if (!targetNode || !targetNode->parentNode()) | 138 if (!targetNode || !targetNode->parentNode()) |
142 return true; | 139 return true; |
143 return targetNode->isShadowRoot() && isHTMLInputElement(toShadowRoot(targetN ode)->host()); | 140 return targetNode->isShadowRoot() && isHTMLInputElement(toShadowRoot(targetN ode)->host()); |
144 } | 141 } |
145 | 142 |
146 // TODO(bokan): This method can go away once all scrolls happen through the | |
147 // scroll customization path. | |
148 void computeScrollChainForSingleNode(Node& node, std::deque<int>& scrollChain) | |
149 { | |
150 scrollChain.clear(); | |
151 | |
152 ASSERT(node.layoutObject()); | |
153 Element* element = toElement(&node); | |
154 | |
155 scrollChain.push_front(DOMNodeIds::idForNode(element)); | |
156 } | |
157 | |
158 void recomputeScrollChain(const LocalFrame& frame, const Node& startNode, | |
159 std::deque<int>& scrollChain) | |
160 { | |
161 scrollChain.clear(); | |
162 | |
163 ASSERT(startNode.layoutObject()); | |
164 LayoutBox* curBox = startNode.layoutObject()->enclosingBox(); | |
165 | |
166 // Scrolling propagates along the containing block chain. | |
167 while (curBox && !curBox->isLayoutView()) { | |
168 Node* curNode = curBox->node(); | |
169 // FIXME: this should reject more elements, as part of crbug.com/410974. | |
170 if (curNode && curNode->isElementNode()) { | |
171 Element* curElement = toElement(curNode); | |
172 if (curElement == frame.document()->scrollingElement()) | |
173 break; | |
174 scrollChain.push_front(DOMNodeIds::idForNode(curElement)); | |
175 } | |
176 curBox = curBox->containingBlock(); | |
177 } | |
178 // TODO(tdresser): this should sometimes be excluded, as part of crbug.com/4 10974. | |
179 // We need to ensure that the scrollingElement is always part of | |
180 // the scroll chain. In quirks mode, when the scrollingElement is | |
181 // the body, some elements may use the documentElement as their | |
182 // containingBlock, so we ensure the scrollingElement is added | |
183 // here. | |
184 scrollChain.push_front(DOMNodeIds::idForNode(frame.document()->scrollingElem ent())); | |
185 } | |
186 | |
187 } // namespace | 143 } // namespace |
188 | 144 |
189 using namespace HTMLNames; | 145 using namespace HTMLNames; |
190 | 146 |
191 // The link drag hysteresis is much larger than the others because there | 147 // The link drag hysteresis is much larger than the others because there |
192 // needs to be enough space to cancel the link press without starting a link dra g, | 148 // needs to be enough space to cancel the link press without starting a link dra g, |
193 // and because dragging links is rare. | 149 // and because dragging links is rare. |
194 static const int LinkDragHysteresis = 40; | 150 static const int LinkDragHysteresis = 40; |
195 static const int ImageDragHysteresis = 5; | 151 static const int ImageDragHysteresis = 5; |
196 static const int TextDragHysteresis = 3; | 152 static const int TextDragHysteresis = 3; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 : m_frame(frame) | 198 : m_frame(frame) |
243 , m_mousePressed(false) | 199 , m_mousePressed(false) |
244 , m_capturesDragging(false) | 200 , m_capturesDragging(false) |
245 , m_mouseDownMayStartDrag(false) | 201 , m_mouseDownMayStartDrag(false) |
246 , m_selectionController(SelectionController::create(*frame)) | 202 , m_selectionController(SelectionController::create(*frame)) |
247 , m_hoverTimer(this, &EventHandler::hoverTimerFired) | 203 , m_hoverTimer(this, &EventHandler::hoverTimerFired) |
248 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) | 204 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) |
249 , m_mouseDownMayStartAutoscroll(false) | 205 , m_mouseDownMayStartAutoscroll(false) |
250 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) | 206 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) |
251 , m_svgPan(false) | 207 , m_svgPan(false) |
252 , m_resizeScrollableArea(nullptr) | |
253 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 208 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
254 , m_clickCount(0) | 209 , m_clickCount(0) |
255 , m_shouldOnlyFireDragOverEvent(false) | 210 , m_shouldOnlyFireDragOverEvent(false) |
256 , m_mousePositionIsUnknown(true) | 211 , m_mousePositionIsUnknown(true) |
257 , m_mouseDownTimestamp(0) | 212 , m_mouseDownTimestamp(0) |
258 , m_pointerEventManager(frame) | 213 , m_pointerEventManager(frame) |
259 , m_scrollGestureHandlingNode(nullptr) | 214 , m_scrollManager(frame) |
260 , m_lastGestureScrollOverWidget(false) | |
261 , m_longTapShouldInvokeContextMenu(false) | 215 , m_longTapShouldInvokeContextMenu(false) |
262 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 216 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
263 , m_lastShowPressTimestamp(0) | 217 , m_lastShowPressTimestamp(0) |
264 , m_deltaConsumedForScrollSequence(false) | |
265 { | 218 { |
266 } | 219 } |
267 | 220 |
268 EventHandler::~EventHandler() | 221 EventHandler::~EventHandler() |
269 { | 222 { |
270 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); | 223 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); |
271 } | 224 } |
272 | 225 |
273 DEFINE_TRACE(EventHandler) | 226 DEFINE_TRACE(EventHandler) |
274 { | 227 { |
275 visitor->trace(m_frame); | 228 visitor->trace(m_frame); |
276 visitor->trace(m_mousePressNode); | 229 visitor->trace(m_mousePressNode); |
277 visitor->trace(m_resizeScrollableArea); | |
278 visitor->trace(m_capturingMouseEventsNode); | 230 visitor->trace(m_capturingMouseEventsNode); |
279 visitor->trace(m_nodeUnderMouse); | 231 visitor->trace(m_nodeUnderMouse); |
280 visitor->trace(m_lastMouseMoveEventSubframe); | 232 visitor->trace(m_lastMouseMoveEventSubframe); |
281 visitor->trace(m_lastScrollbarUnderMouse); | 233 visitor->trace(m_lastScrollbarUnderMouse); |
282 visitor->trace(m_clickNode); | 234 visitor->trace(m_clickNode); |
283 visitor->trace(m_dragTarget); | 235 visitor->trace(m_dragTarget); |
284 visitor->trace(m_frameSetBeingResized); | 236 visitor->trace(m_frameSetBeingResized); |
285 visitor->trace(m_scrollbarHandlingScrollGesture); | |
286 visitor->trace(m_scrollGestureHandlingNode); | |
287 visitor->trace(m_previousGestureScrolledNode); | |
288 visitor->trace(m_lastDeferredTapElement); | 237 visitor->trace(m_lastDeferredTapElement); |
289 visitor->trace(m_selectionController); | 238 visitor->trace(m_selectionController); |
290 visitor->trace(m_pointerEventManager); | 239 visitor->trace(m_pointerEventManager); |
240 visitor->trace(m_scrollManager); | |
291 } | 241 } |
292 | 242 |
293 DragState& EventHandler::dragState() | 243 DragState& EventHandler::dragState() |
294 { | 244 { |
295 DEFINE_STATIC_LOCAL(DragState, state, (new DragState)); | 245 DEFINE_STATIC_LOCAL(DragState, state, (new DragState)); |
296 return state; | 246 return state; |
297 } | 247 } |
298 | 248 |
299 void EventHandler::clear() | 249 void EventHandler::clear() |
300 { | 250 { |
301 m_hoverTimer.stop(); | 251 m_hoverTimer.stop(); |
302 m_cursorUpdateTimer.stop(); | 252 m_cursorUpdateTimer.stop(); |
303 m_fakeMouseMoveEventTimer.stop(); | 253 m_fakeMouseMoveEventTimer.stop(); |
304 m_activeIntervalTimer.stop(); | 254 m_activeIntervalTimer.stop(); |
305 m_resizeScrollableArea = nullptr; | |
306 m_nodeUnderMouse = nullptr; | 255 m_nodeUnderMouse = nullptr; |
307 m_lastMouseMoveEventSubframe = nullptr; | 256 m_lastMouseMoveEventSubframe = nullptr; |
308 m_lastScrollbarUnderMouse = nullptr; | 257 m_lastScrollbarUnderMouse = nullptr; |
309 m_clickCount = 0; | 258 m_clickCount = 0; |
310 m_clickNode = nullptr; | 259 m_clickNode = nullptr; |
311 m_frameSetBeingResized = nullptr; | 260 m_frameSetBeingResized = nullptr; |
312 m_dragTarget = nullptr; | 261 m_dragTarget = nullptr; |
313 m_shouldOnlyFireDragOverEvent = false; | 262 m_shouldOnlyFireDragOverEvent = false; |
314 m_mousePositionIsUnknown = true; | 263 m_mousePositionIsUnknown = true; |
315 m_lastKnownMousePosition = IntPoint(); | 264 m_lastKnownMousePosition = IntPoint(); |
316 m_lastKnownMouseGlobalPosition = IntPoint(); | 265 m_lastKnownMouseGlobalPosition = IntPoint(); |
317 m_lastMouseDownUserGestureToken.clear(); | 266 m_lastMouseDownUserGestureToken.clear(); |
318 m_mousePressNode = nullptr; | 267 m_mousePressNode = nullptr; |
319 m_mousePressed = false; | 268 m_mousePressed = false; |
320 m_capturesDragging = false; | 269 m_capturesDragging = false; |
321 m_capturingMouseEventsNode = nullptr; | 270 m_capturingMouseEventsNode = nullptr; |
322 clearGestureScrollState(); | |
323 m_lastGestureScrollOverWidget = false; | |
324 m_scrollbarHandlingScrollGesture = nullptr; | |
325 m_pointerEventManager.clear(); | 271 m_pointerEventManager.clear(); |
272 m_scrollManager.clear(); | |
326 m_mouseDownMayStartDrag = false; | 273 m_mouseDownMayStartDrag = false; |
327 m_lastShowPressTimestamp = 0; | 274 m_lastShowPressTimestamp = 0; |
328 m_lastDeferredTapElement = nullptr; | 275 m_lastDeferredTapElement = nullptr; |
329 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 276 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
330 m_mouseDownMayStartAutoscroll = false; | 277 m_mouseDownMayStartAutoscroll = false; |
331 m_svgPan = false; | 278 m_svgPan = false; |
332 m_mouseDownPos = IntPoint(); | 279 m_mouseDownPos = IntPoint(); |
333 m_mouseDownTimestamp = 0; | 280 m_mouseDownTimestamp = 0; |
334 m_longTapShouldInvokeContextMenu = false; | 281 m_longTapShouldInvokeContextMenu = false; |
335 m_dragStartPos = LayoutPoint(); | 282 m_dragStartPos = LayoutPoint(); |
336 m_offsetFromResizeCorner = LayoutSize(); | |
337 m_mouseDown = PlatformMouseEvent(); | 283 m_mouseDown = PlatformMouseEvent(); |
338 } | 284 } |
339 | 285 |
340 WebInputEventResult EventHandler::mergeEventResult( | 286 WebInputEventResult EventHandler::mergeEventResult( |
341 WebInputEventResult resultA, WebInputEventResult resultB) | 287 WebInputEventResult resultA, WebInputEventResult resultB) |
342 { | 288 { |
343 // The ordering of the enumeration is specific. There are times that | 289 // The ordering of the enumeration is specific. There are times that |
344 // multiple events fire and we need to combine them into a single | 290 // multiple events fire and we need to combine them into a single |
345 // result code. The enumeration is based on the level of consumption that | 291 // result code. The enumeration is based on the level of consumption that |
346 // is most significant. The enumeration is ordered with smaller specified | 292 // is most significant. The enumeration is ordered with smaller specified |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 if (!parent) | 422 if (!parent) |
477 return WebInputEventResult::NotHandled; | 423 return WebInputEventResult::NotHandled; |
478 | 424 |
479 layoutObject = parent->layoutObject(); | 425 layoutObject = parent->layoutObject(); |
480 if (!layoutObject || !layoutObject->isListBox()) | 426 if (!layoutObject || !layoutObject->isListBox()) |
481 return WebInputEventResult::NotHandled; | 427 return WebInputEventResult::NotHandled; |
482 } | 428 } |
483 | 429 |
484 m_mouseDownMayStartDrag = false; | 430 m_mouseDownMayStartDrag = false; |
485 | 431 |
486 if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) { | 432 if (m_mouseDownMayStartAutoscroll && !m_scrollManager.panScrollInProgress()) { |
487 if (AutoscrollController* controller = autoscrollController()) { | 433 if (AutoscrollController* controller = m_scrollManager.autoscrollControl ler()) { |
488 controller->startAutoscrollForSelection(layoutObject); | 434 controller->startAutoscrollForSelection(layoutObject); |
489 m_mouseDownMayStartAutoscroll = false; | 435 m_mouseDownMayStartAutoscroll = false; |
490 } | 436 } |
491 } | 437 } |
492 | 438 |
493 selectionController().handleMouseDraggedEvent(event, m_mouseDownPos, m_dragS tartPos, m_mousePressNode.get(), m_lastKnownMousePosition); | 439 selectionController().handleMouseDraggedEvent(event, m_mouseDownPos, m_dragS tartPos, m_mousePressNode.get(), m_lastKnownMousePosition); |
494 return WebInputEventResult::HandledSystem; | 440 return WebInputEventResult::HandledSystem; |
495 } | 441 } |
496 | 442 |
497 void EventHandler::updateSelectionForMouseDrag() | 443 void EventHandler::updateSelectionForMouseDrag() |
498 { | 444 { |
499 selectionController().updateSelectionForMouseDrag(m_mousePressNode.get(), m_ dragStartPos, m_lastKnownMousePosition); | 445 selectionController().updateSelectionForMouseDrag(m_mousePressNode.get(), m_ dragStartPos, m_lastKnownMousePosition); |
500 } | 446 } |
501 | 447 |
502 WebInputEventResult EventHandler::handleMouseReleaseEvent(const MouseEventWithHi tTestResults& event) | 448 WebInputEventResult EventHandler::handleMouseReleaseEvent(const MouseEventWithHi tTestResults& event) |
503 { | 449 { |
504 AutoscrollController* controller = autoscrollController(); | 450 AutoscrollController* controller = m_scrollManager.autoscrollController(); |
dtapuska
2016/05/27 14:12:23
Why can't this just be a call to m_scrollManager.s
Navid Zolghadr
2016/05/30 20:15:46
stopAutoScroll is used in other places without thi
| |
505 if (controller && controller->autoscrollInProgress()) | 451 if (controller && controller->autoscrollInProgress()) |
506 stopAutoscroll(); | 452 m_scrollManager.stopAutoscroll(); |
507 | 453 |
508 // Used to prevent mouseMoveEvent from initiating a drag before | 454 // Used to prevent mouseMoveEvent from initiating a drag before |
509 // the mouse is pressed again. | 455 // the mouse is pressed again. |
510 m_mousePressed = false; | 456 m_mousePressed = false; |
511 m_capturesDragging = false; | 457 m_capturesDragging = false; |
512 m_mouseDownMayStartDrag = false; | 458 m_mouseDownMayStartDrag = false; |
513 m_mouseDownMayStartAutoscroll = false; | 459 m_mouseDownMayStartAutoscroll = false; |
514 | 460 |
515 return selectionController().handleMouseReleaseEvent(event, m_dragStartPos) ? WebInputEventResult::HandledSystem : WebInputEventResult::NotHandled; | 461 return selectionController().handleMouseReleaseEvent(event, m_dragStartPos) ? WebInputEventResult::HandledSystem : WebInputEventResult::NotHandled; |
516 } | 462 } |
517 | 463 |
518 #if OS(WIN) | 464 #if OS(WIN) |
519 | 465 |
520 void EventHandler::startPanScrolling(LayoutObject* layoutObject) | 466 void EventHandler::startPanScrolling(LayoutObject* layoutObject) |
521 { | 467 { |
522 if (!layoutObject->isBox()) | 468 if (!layoutObject->isBox()) |
dtapuska
2016/05/27 14:12:23
This seems like something that should be delegated
Navid Zolghadr
2016/05/30 20:15:46
This seems a little tricky to remove autoScrollCon
bokan
2016/05/31 19:39:13
I'd prefer if we kept this patch as simple and mec
Navid Zolghadr
2016/06/01 17:36:43
Okay then. I'll leave this function as is.
| |
523 return; | 469 return; |
524 AutoscrollController* controller = autoscrollController(); | 470 AutoscrollController* controller = m_scrollManager.autoscrollController(); |
525 if (!controller) | 471 if (!controller) |
526 return; | 472 return; |
527 controller->startPanScrolling(toLayoutBox(layoutObject), lastKnownMousePosit ion()); | 473 controller->startPanScrolling(toLayoutBox(layoutObject), lastKnownMousePosit ion()); |
528 invalidateClick(); | 474 invalidateClick(); |
529 } | 475 } |
530 | 476 |
531 #endif // OS(WIN) | 477 #endif // OS(WIN) |
532 | 478 |
533 AutoscrollController* EventHandler::autoscrollController() const | |
534 { | |
535 if (Page* page = m_frame->page()) | |
536 return &page->autoscrollController(); | |
537 return nullptr; | |
538 } | |
539 | |
540 bool EventHandler::panScrollInProgress() const | |
541 { | |
542 return autoscrollController() && autoscrollController()->panScrollInProgress (); | |
543 } | |
544 | |
545 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding) | 479 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding) |
546 { | 480 { |
547 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); | 481 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); |
548 | 482 |
549 ASSERT((hitType & HitTestRequest::ListBased) || padding.isEmpty()); | 483 ASSERT((hitType & HitTestRequest::ListBased) || padding.isEmpty()); |
550 | 484 |
551 // We always send hitTestResultAtPoint to the main frame if we have one, | 485 // We always send hitTestResultAtPoint to the main frame if we have one, |
552 // otherwise we might hit areas that are obscured by higher frames. | 486 // otherwise we might hit areas that are obscured by higher frames. |
553 if (m_frame->page()) { | 487 if (m_frame->page()) { |
554 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 488 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
(...skipping 22 matching lines...) Expand all Loading... | |
577 | 511 |
578 m_frame->contentLayoutItem().hitTest(result); | 512 m_frame->contentLayoutItem().hitTest(result); |
579 if (!request.readOnly()) | 513 if (!request.readOnly()) |
580 m_frame->document()->updateHoverActiveState(request, result.innerElement ()); | 514 m_frame->document()->updateHoverActiveState(request, result.innerElement ()); |
581 | 515 |
582 return result; | 516 return result; |
583 } | 517 } |
584 | 518 |
585 void EventHandler::stopAutoscroll() | 519 void EventHandler::stopAutoscroll() |
586 { | 520 { |
587 if (AutoscrollController* controller = autoscrollController()) | 521 m_scrollManager.stopAutoscroll(); |
588 controller->stopAutoscroll(); | |
589 } | |
590 | |
591 ScrollResult EventHandler::scrollBox(LayoutBox* box, | |
592 ScrollGranularity granularity, const FloatSize& delta, | |
593 const FloatPoint& position, const FloatSize& velocity, | |
594 bool* wasRootScroller) | |
595 { | |
596 ASSERT(box); | |
597 Node* node = box->node(); | |
598 | |
599 // If there's no ApplyScroll callback on the element, scroll as usuall in | |
600 // the non-scroll-customization case. | |
601 if (!node || !node->isElementNode() || !toElement(node)->getApplyScroll()) { | |
602 *wasRootScroller = false; | |
603 return box->scroll(granularity, delta); | |
604 } | |
605 | |
606 // Viewport actions should only happen when scrolling an element in the | |
607 // main frame. | |
608 ASSERT(m_frame->isMainFrame()); | |
609 | |
610 // If there is an ApplyScroll callback, its because we placed one on the | |
611 // root scroller to control top controls and overscroll. Invoke a scroll | |
612 // using parts of the scroll customization framework on just this element. | |
613 computeScrollChainForSingleNode(*node, m_currentScrollChain); | |
614 | |
615 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateData()); | |
616 scrollStateData->delta_x = delta.width(); | |
617 scrollStateData->delta_y = delta.height(); | |
618 scrollStateData->position_x = position.x(); | |
619 scrollStateData->position_y = position.y(); | |
620 // TODO(bokan): delta_granularity is meant to be the number of pixels per | |
621 // unit of delta but we can't determine that until we get to the area we'll | |
622 // scroll. This is a hack, we stuff the enum into the double value for | |
623 // now. | |
624 scrollStateData->delta_granularity = static_cast<double>(granularity); | |
625 scrollStateData->velocity_x = velocity.width(); | |
626 scrollStateData->velocity_y = velocity.height(); | |
627 scrollStateData->should_propagate = false; | |
628 scrollStateData->is_in_inertial_phase = false; | |
629 scrollStateData->from_user_input = true; | |
630 scrollStateData->delta_consumed_for_scroll_sequence = false; | |
631 ScrollState* scrollState = | |
632 ScrollState::create(std::move(scrollStateData)); | |
633 | |
634 customizedScroll(*node, *scrollState); | |
635 | |
636 ScrollResult result( | |
637 scrollState->deltaX() != delta.width(), | |
638 scrollState->deltaY() != delta.height(), | |
639 scrollState->deltaX(), | |
640 scrollState->deltaY()); | |
641 | |
642 *wasRootScroller = true; | |
643 m_currentScrollChain.clear(); | |
644 | |
645 return result; | |
646 } | |
647 | |
648 ScrollResult EventHandler::physicalScroll(ScrollGranularity granularity, | |
649 const FloatSize& delta, const FloatPoint& position, | |
650 const FloatSize& velocity, Node* startNode, Node** stopNode, bool* consumed) | |
651 { | |
652 if (consumed) | |
653 *consumed = false; | |
654 if (delta.isZero()) | |
655 return ScrollResult(); | |
656 | |
657 Node* node = startNode; | |
658 ASSERT(node && node->layoutObject()); | |
659 | |
660 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
661 | |
662 ScrollResult result; | |
663 | |
664 LayoutBox* curBox = node->layoutObject()->enclosingBox(); | |
665 while (curBox) { | |
666 // If we're at the stopNode, we should try to scroll it but we shouldn't | |
667 // chain past it. | |
668 bool shouldStopChaining = | |
669 stopNode && *stopNode && curBox->node() == *stopNode; | |
670 bool wasRootScroller = false; | |
671 | |
672 result = scrollBox( | |
673 curBox, | |
674 granularity, | |
675 delta, | |
676 position, | |
677 velocity, | |
678 &wasRootScroller); | |
679 | |
680 if (result.didScroll() && stopNode) | |
681 *stopNode = curBox->node(); | |
682 | |
683 if (result.didScroll() || shouldStopChaining) { | |
684 setFrameWasScrolledByUser(); | |
685 if (consumed) | |
686 *consumed = true; | |
687 return result; | |
688 } else if (wasRootScroller) { | |
689 // Don't try to chain past the root scroller, even if there's | |
690 // eligible ancestors. | |
691 break; | |
692 } | |
693 | |
694 curBox = curBox->containingBlock(); | |
695 } | |
696 | |
697 return result; | |
698 } | |
699 | |
700 bool EventHandler::logicalScroll(ScrollDirection direction, ScrollGranularity gr anularity, Node* startNode) | |
701 { | |
702 Node* node = startNode; | |
703 | |
704 if (!node) | |
705 node = m_frame->document()->focusedElement(); | |
706 | |
707 if (!node) | |
708 node = m_mousePressNode.get(); | |
709 | |
710 if ((!node || !node->layoutObject()) && m_frame->view() && !m_frame->view()- >layoutViewItem().isNull()) | |
711 node = m_frame->view()->layoutViewItem().node(); | |
712 | |
713 if (!node) | |
714 return false; | |
715 | |
716 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
717 | |
718 LayoutBox* curBox = node->layoutObject()->enclosingBox(); | |
719 while (curBox) { | |
720 ScrollDirectionPhysical physicalDirection = toPhysicalDirection( | |
721 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode()); | |
722 | |
723 ScrollResult result = curBox->scroll(granularity, toScrollDelta(physical Direction, 1)); | |
724 | |
725 if (result.didScroll()) { | |
726 setFrameWasScrolledByUser(); | |
727 return true; | |
728 } | |
729 | |
730 curBox = curBox->containingBlock(); | |
731 } | |
732 | |
733 return false; | |
734 } | |
735 | |
736 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt ate) | |
737 { | |
738 if (scrollState.fullyConsumed()) | |
739 return; | |
740 | |
741 if (scrollState.deltaX() || scrollState.deltaY()) | |
742 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
743 | |
744 if (m_currentScrollChain.empty()) | |
745 recomputeScrollChain(*m_frame, startNode, m_currentScrollChain); | |
746 scrollState.setScrollChain(m_currentScrollChain); | |
747 | |
748 scrollState.distributeToScrollChainDescendant(); | |
749 } | 522 } |
750 | 523 |
751 // TODO(bokan): This should be merged with logicalScroll assuming | 524 // TODO(bokan): This should be merged with logicalScroll assuming |
752 // defaultSpaceEventHandler's chaining scroll can be done crossing frames. | 525 // defaultSpaceEventHandler's chaining scroll can be done crossing frames. |
753 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) | 526 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) |
754 { | 527 { |
755 // The layout needs to be up to date to determine if we can scroll. We may b e | 528 // The layout needs to be up to date to determine if we can scroll. We may b e |
756 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. | 529 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. |
dtapuska
2016/05/27 14:12:23
It would seem to me bubbling scroll would just get
Navid Zolghadr
2016/05/30 20:15:46
Done.
| |
757 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 530 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
758 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 531 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
759 if (logicalScroll(direction, granularity, startingNode)) | 532 if (m_scrollManager.logicalScroll(direction, granularity, startingNode, m_mo usePressNode)) |
760 return true; | 533 return true; |
761 | 534 |
762 Frame* parentFrame = m_frame->tree().parent(); | 535 Frame* parentFrame = m_frame->tree().parent(); |
763 if (!parentFrame || !parentFrame->isLocalFrame()) | 536 if (!parentFrame || !parentFrame->isLocalFrame()) |
764 return false; | 537 return false; |
765 // FIXME: Broken for OOPI. | 538 // FIXME: Broken for OOPI. |
766 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner()); | 539 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner()); |
767 } | 540 } |
768 | 541 |
769 IntPoint EventHandler::lastKnownMousePosition() const | 542 IntPoint EventHandler::lastKnownMousePosition() const |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 if (LocalFrame* frame = result.innerNodeFrame()) { | 624 if (LocalFrame* frame = result.innerNodeFrame()) { |
852 OptionalCursor optionalCursor = frame->eventHandler().selectCursor(resul t); | 625 OptionalCursor optionalCursor = frame->eventHandler().selectCursor(resul t); |
853 if (optionalCursor.isCursorChange()) { | 626 if (optionalCursor.isCursorChange()) { |
854 view->setCursor(optionalCursor.cursor()); | 627 view->setCursor(optionalCursor.cursor()); |
855 } | 628 } |
856 } | 629 } |
857 } | 630 } |
858 | 631 |
859 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) | 632 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) |
860 { | 633 { |
861 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) | 634 if (m_scrollManager.inResizeMode()) |
862 return NoCursorChange; | 635 return NoCursorChange; |
863 | 636 |
864 Page* page = m_frame->page(); | 637 Page* page = m_frame->page(); |
865 if (!page) | 638 if (!page) |
866 return NoCursorChange; | 639 return NoCursorChange; |
867 if (panScrollInProgress()) | 640 if (m_scrollManager.panScrollInProgress()) |
868 return NoCursorChange; | 641 return NoCursorChange; |
869 | 642 |
870 Node* node = result.innerPossiblyPseudoNode(); | 643 Node* node = result.innerPossiblyPseudoNode(); |
871 if (!node) | 644 if (!node) |
872 return selectAutoCursor(result, node, iBeamCursor()); | 645 return selectAutoCursor(result, node, iBeamCursor()); |
873 | 646 |
874 LayoutObject* layoutObject = node->layoutObject(); | 647 LayoutObject* layoutObject = node->layoutObject(); |
875 const ComputedStyle* style = layoutObject ? layoutObject->style() : nullptr; | 648 const ComputedStyle* style = layoutObject ? layoutObject->style() : nullptr; |
876 | 649 |
877 if (layoutObject) { | 650 if (layoutObject) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 m_capturingMouseEventsNode = mev.innerNode(); | 863 m_capturingMouseEventsNode = mev.innerNode(); |
1091 m_eventHandlerWillResetCapturingMouseEventsNode = true; | 864 m_eventHandlerWillResetCapturingMouseEventsNode = true; |
1092 } | 865 } |
1093 invalidateClick(); | 866 invalidateClick(); |
1094 return result; | 867 return result; |
1095 } | 868 } |
1096 | 869 |
1097 #if OS(WIN) | 870 #if OS(WIN) |
1098 // We store whether pan scrolling is in progress before calling stopAutoscro ll() | 871 // We store whether pan scrolling is in progress before calling stopAutoscro ll() |
1099 // because it will set m_autoscrollType to NoAutoscroll on return. | 872 // because it will set m_autoscrollType to NoAutoscroll on return. |
1100 bool isPanScrollInProgress = panScrollInProgress(); | 873 bool isPanScrollInProgress = m_scrollManager.panScrollInProgress(); |
1101 stopAutoscroll(); | 874 m_scrollManager.stopAutoscroll(); |
1102 if (isPanScrollInProgress) { | 875 if (isPanScrollInProgress) { |
1103 // We invalidate the click when exiting pan scrolling so that we don't i nadvertently navigate | 876 // We invalidate the click when exiting pan scrolling so that we don't i nadvertently navigate |
1104 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>. | 877 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>. |
1105 invalidateClick(); | 878 invalidateClick(); |
1106 return WebInputEventResult::HandledSuppressed; | 879 return WebInputEventResult::HandledSuppressed; |
1107 } | 880 } |
1108 #endif | 881 #endif |
1109 | 882 |
1110 m_clickCount = mouseEvent.clickCount(); | 883 m_clickCount = mouseEvent.clickCount(); |
1111 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me v.innerNode()) : mev.innerNode(); | 884 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me v.innerNode()) : mev.innerNode(); |
1112 | 885 |
1113 m_frame->selection().setCaretBlinkingSuspended(true); | 886 m_frame->selection().setCaretBlinkingSuspended(true); |
1114 | 887 |
1115 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event()); | 888 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event()); |
1116 | 889 |
1117 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) { | 890 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) { |
1118 FrameView* view = m_frame->view(); | 891 FrameView* view = m_frame->view(); |
1119 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr; | 892 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr; |
1120 IntPoint p = view->rootFrameToContents(mouseEvent.position()); | 893 IntPoint p = view->rootFrameToContents(mouseEvent.position()); |
1121 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i sPointInResizeControl(p, ResizerForPointer)) { | 894 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i sPointInResizeControl(p, ResizerForPointer)) { |
1122 m_resizeScrollableArea = layer->getScrollableArea(); | 895 m_scrollManager.setResizeScrollableArea(layer, p); |
1123 m_resizeScrollableArea->setInResizeMode(true); | |
1124 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); | |
1125 return WebInputEventResult::HandledSystem; | 896 return WebInputEventResult::HandledSystem; |
1126 } | 897 } |
1127 } | 898 } |
1128 | 899 |
1129 // m_selectionInitiationState is initialized after dispatching mousedown | 900 // m_selectionInitiationState is initialized after dispatching mousedown |
1130 // event in order not to keep the selection by DOM APIs Because we can't | 901 // event in order not to keep the selection by DOM APIs Because we can't |
1131 // give the user the chance to handle the selection by user action like | 902 // give the user the chance to handle the selection by user action like |
1132 // dragging if we keep the selection in case of mousedown. FireFox also has | 903 // dragging if we keep the selection in case of mousedown. FireFox also has |
1133 // the same behavior and it's more compatible with other browsers. | 904 // the same behavior and it's more compatible with other browsers. |
1134 selectionController().initializeSelectionState(); | 905 selectionController().initializeSelectionState(); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1285 if (forceLeave) | 1056 if (forceLeave) |
1286 m_frame->document()->updateHoverActiveState(request, 0); | 1057 m_frame->document()->updateHoverActiveState(request, 0); |
1287 else | 1058 else |
1288 mev = prepareMouseEvent(request, mouseEvent); | 1059 mev = prepareMouseEvent(request, mouseEvent); |
1289 | 1060 |
1290 if (hoveredNode) | 1061 if (hoveredNode) |
1291 *hoveredNode = mev.hitTestResult(); | 1062 *hoveredNode = mev.hitTestResult(); |
1292 | 1063 |
1293 Scrollbar* scrollbar = nullptr; | 1064 Scrollbar* scrollbar = nullptr; |
1294 | 1065 |
1295 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | 1066 if (m_scrollManager.inResizeMode()) { |
1296 m_resizeScrollableArea->resize(mev.event(), m_offsetFromResizeCorner); | 1067 m_scrollManager.resize(mev.event()); |
1297 } else { | 1068 } else { |
1298 if (!scrollbar) | 1069 if (!scrollbar) |
1299 scrollbar = mev.scrollbar(); | 1070 scrollbar = mev.scrollbar(); |
1300 | 1071 |
1301 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); | 1072 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); |
1302 if (onlyUpdateScrollbars) | 1073 if (onlyUpdateScrollbars) |
1303 return WebInputEventResult::HandledSuppressed; | 1074 return WebInputEventResult::HandledSuppressed; |
1304 } | 1075 } |
1305 | 1076 |
1306 WebInputEventResult eventResult = WebInputEventResult::NotHandled; | 1077 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1454 // This is to suppress sending click events for non-primary buttons. | 1225 // This is to suppress sending click events for non-primary buttons. |
1455 // But still doing default action like opening a new tab for middle | 1226 // But still doing default action like opening a new tab for middle |
1456 // click (crbug.com/255). | 1227 // click (crbug.com/255). |
1457 if (mev.event().button() != MouseButton::LeftButton) | 1228 if (mev.event().button() != MouseButton::LeftButton) |
1458 event->stopPropagation(); | 1229 event->stopPropagation(); |
1459 | 1230 |
1460 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchEv ent(event)); | 1231 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchEv ent(event)); |
1461 } | 1232 } |
1462 } | 1233 } |
1463 | 1234 |
1464 if (m_resizeScrollableArea) { | 1235 m_scrollManager.clearResizeScrollableArea(false); |
1465 m_resizeScrollableArea->setInResizeMode(false); | |
1466 m_resizeScrollableArea = nullptr; | |
1467 } | |
1468 | 1236 |
1469 if (eventResult == WebInputEventResult::NotHandled) | 1237 if (eventResult == WebInputEventResult::NotHandled) |
1470 eventResult = handleMouseReleaseEvent(mev); | 1238 eventResult = handleMouseReleaseEvent(mev); |
1471 | 1239 |
1472 invalidateClick(); | 1240 invalidateClick(); |
1473 | 1241 |
1474 return mergeEventResult(clickEventResult, eventResult); | 1242 return mergeEventResult(clickEventResult, eventResult); |
1475 } | 1243 } |
1476 | 1244 |
1477 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer ) | 1245 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer ) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 return eventResult; | 1320 return eventResult; |
1553 | 1321 |
1554 HitTestRequest request(HitTestRequest::ReadOnly); | 1322 HitTestRequest request(HitTestRequest::ReadOnly); |
1555 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); | 1323 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); |
1556 | 1324 |
1557 // Drag events should never go to text nodes (following IE, and proper mouse over/out dispatch) | 1325 // Drag events should never go to text nodes (following IE, and proper mouse over/out dispatch) |
1558 Node* newTarget = mev.innerNode(); | 1326 Node* newTarget = mev.innerNode(); |
1559 if (newTarget && newTarget->isTextNode()) | 1327 if (newTarget && newTarget->isTextNode()) |
1560 newTarget = FlatTreeTraversal::parent(*newTarget); | 1328 newTarget = FlatTreeTraversal::parent(*newTarget); |
1561 | 1329 |
1562 if (AutoscrollController* controller = autoscrollController()) | 1330 if (AutoscrollController* controller = m_scrollManager.autoscrollController( )) |
1563 controller->updateDragAndDrop(newTarget, event.position(), event.timesta mp()); | 1331 controller->updateDragAndDrop(newTarget, event.position(), event.timesta mp()); |
1564 | 1332 |
1565 if (m_dragTarget != newTarget) { | 1333 if (m_dragTarget != newTarget) { |
1566 // FIXME: this ordering was explicitly chosen to match WinIE. However, | 1334 // FIXME: this ordering was explicitly chosen to match WinIE. However, |
1567 // it is sometimes incorrect when dragging within subframes, as seen wit h | 1335 // it is sometimes incorrect when dragging within subframes, as seen wit h |
1568 // LayoutTests/fast/events/drag-in-frames.html. | 1336 // LayoutTests/fast/events/drag-in-frames.html. |
1569 // | 1337 // |
1570 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec. <http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. | 1338 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec. <http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. |
1571 LocalFrame* targetFrame; | 1339 LocalFrame* targetFrame; |
1572 if (targetIsFrame(newTarget, targetFrame)) { | 1340 if (targetIsFrame(newTarget, targetFrame)) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1640 result = targetFrame->eventHandler().performDragAndDrop(event, dataT ransfer); | 1408 result = targetFrame->eventHandler().performDragAndDrop(event, dataT ransfer); |
1641 } else if (m_dragTarget.get()) { | 1409 } else if (m_dragTarget.get()) { |
1642 result = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.get(), eve nt, dataTransfer); | 1410 result = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.get(), eve nt, dataTransfer); |
1643 } | 1411 } |
1644 clearDragState(); | 1412 clearDragState(); |
1645 return result; | 1413 return result; |
1646 } | 1414 } |
1647 | 1415 |
1648 void EventHandler::clearDragState() | 1416 void EventHandler::clearDragState() |
1649 { | 1417 { |
1650 stopAutoscroll(); | 1418 m_scrollManager.stopAutoscroll(); |
1651 m_dragTarget = nullptr; | 1419 m_dragTarget = nullptr; |
1652 m_capturingMouseEventsNode = nullptr; | 1420 m_capturingMouseEventsNode = nullptr; |
1653 m_shouldOnlyFireDragOverEvent = false; | 1421 m_shouldOnlyFireDragOverEvent = false; |
1654 } | 1422 } |
1655 | 1423 |
1656 void EventHandler::setCapturingMouseEventsNode(Node* n) | 1424 void EventHandler::setCapturingMouseEventsNode(Node* n) |
1657 { | 1425 { |
1658 m_capturingMouseEventsNode = n; | 1426 m_capturingMouseEventsNode = n; |
1659 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 1427 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
1660 } | 1428 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1887 | 1655 |
1888 // If we're over the frame scrollbar, scroll the document. | 1656 // If we're over the frame scrollbar, scroll the document. |
1889 if (!node && result.scrollbar()) | 1657 if (!node && result.scrollbar()) |
1890 node = doc->documentElement(); | 1658 node = doc->documentElement(); |
1891 | 1659 |
1892 bool sendDOMEvent = true; | 1660 bool sendDOMEvent = true; |
1893 LocalFrame* subframe = subframeForTargetNode(node); | 1661 LocalFrame* subframe = subframeForTargetNode(node); |
1894 if (subframe) { | 1662 if (subframe) { |
1895 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent); | 1663 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent); |
1896 if (result != WebInputEventResult::NotHandled) { | 1664 if (result != WebInputEventResult::NotHandled) { |
1897 setFrameWasScrolledByUser(); | 1665 m_scrollManager.setFrameWasScrolledByUser(); |
1898 return result; | 1666 return result; |
1899 } | 1667 } |
1900 // TODO(dtapuska): Remove this once wheel gesture scroll has | 1668 // TODO(dtapuska): Remove this once wheel gesture scroll has |
1901 // been enabled everywhere; as we can just return early. | 1669 // been enabled everywhere; as we can just return early. |
1902 // http://crbug.com/568183 | 1670 // http://crbug.com/568183 |
1903 // Don't propagate the DOM event into the parent iframe | 1671 // Don't propagate the DOM event into the parent iframe |
1904 // but do dispatch the scroll event. | 1672 // but do dispatch the scroll event. |
1905 sendDOMEvent = false; | 1673 sendDOMEvent = false; |
1906 } | 1674 } |
1907 | 1675 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1955 if (granularity == ScrollByPage) { | 1723 if (granularity == ScrollByPage) { |
1956 if (delta.width()) | 1724 if (delta.width()) |
1957 delta.setWidth(delta.width() > 0 ? 1 : -1); | 1725 delta.setWidth(delta.width() > 0 ? 1 : -1); |
1958 if (delta.height()) | 1726 if (delta.height()) |
1959 delta.setHeight(delta.height() > 0 ? 1 : -1); | 1727 delta.setHeight(delta.height() > 0 ? 1 : -1); |
1960 } | 1728 } |
1961 | 1729 |
1962 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 1730 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
1963 bool consumed = false; | 1731 bool consumed = false; |
1964 | 1732 |
1965 physicalScroll( | 1733 m_scrollManager.physicalScroll( |
1966 granularity, | 1734 granularity, |
1967 delta, | 1735 delta, |
1968 FloatPoint(), | 1736 FloatPoint(), |
1969 FloatSize(), | 1737 FloatSize(), |
1970 startNode, | 1738 startNode, |
1971 &node, | 1739 &node, |
1972 &consumed); | 1740 &consumed); |
1973 | 1741 |
1974 if (consumed) | 1742 if (consumed) |
1975 wheelEvent->setDefaultHandled(); | 1743 wheelEvent->setDefaultHandled(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2033 | 1801 |
2034 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? | 1802 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? |
2035 return handleGestureEventInFrame(targetedEvent); | 1803 return handleGestureEventInFrame(targetedEvent); |
2036 } | 1804 } |
2037 | 1805 |
2038 WebInputEventResult EventHandler::handleGestureEventInFrame(const GestureEventWi thHitTestResults& targetedEvent) | 1806 WebInputEventResult EventHandler::handleGestureEventInFrame(const GestureEventWi thHitTestResults& targetedEvent) |
2039 { | 1807 { |
2040 ASSERT(!targetedEvent.event().isScrollEvent()); | 1808 ASSERT(!targetedEvent.event().isScrollEvent()); |
2041 | 1809 |
2042 Node* eventTarget = targetedEvent.hitTestResult().innerNode(); | 1810 Node* eventTarget = targetedEvent.hitTestResult().innerNode(); |
2043 Scrollbar* scrollbar = targetedEvent.hitTestResult().scrollbar(); | |
2044 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 1811 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2045 | 1812 |
2046 if (scrollbar) { | 1813 if (m_scrollManager.canHandleGestureEvent(targetedEvent)) |
2047 bool shouldUpdateCapture = false; | 1814 return WebInputEventResult::HandledSuppressed; |
2048 if (scrollbar->gestureEvent(gestureEvent, &shouldUpdateCapture)) { | |
2049 if (shouldUpdateCapture) | |
2050 m_scrollbarHandlingScrollGesture = scrollbar; | |
2051 return WebInputEventResult::HandledSuppressed; | |
2052 } | |
2053 } | |
2054 | 1815 |
2055 if (eventTarget) { | 1816 if (eventTarget) { |
2056 GestureEvent* gestureDomEvent = GestureEvent::create(eventTarget->docume nt().domWindow(), gestureEvent); | 1817 GestureEvent* gestureDomEvent = GestureEvent::create(eventTarget->docume nt().domWindow(), gestureEvent); |
2057 if (gestureDomEvent) { | 1818 if (gestureDomEvent) { |
2058 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent); | 1819 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent); |
2059 if (gestureDomEventResult != DispatchEventResult::NotCanceled) { | 1820 if (gestureDomEventResult != DispatchEventResult::NotCanceled) { |
2060 ASSERT(gestureDomEventResult != DispatchEventResult::CanceledByE ventHandler); | 1821 ASSERT(gestureDomEventResult != DispatchEventResult::CanceledByE ventHandler); |
2061 return toWebInputEventResult(gestureDomEventResult); | 1822 return toWebInputEventResult(gestureDomEventResult); |
2062 } | 1823 } |
2063 } | 1824 } |
(...skipping 21 matching lines...) Expand all Loading... | |
2085 ASSERT_NOT_REACHED(); | 1846 ASSERT_NOT_REACHED(); |
2086 } | 1847 } |
2087 | 1848 |
2088 return WebInputEventResult::NotHandled; | 1849 return WebInputEventResult::NotHandled; |
2089 } | 1850 } |
2090 | 1851 |
2091 WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture Event& gestureEvent) | 1852 WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture Event& gestureEvent) |
2092 { | 1853 { |
2093 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); | 1854 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); |
2094 | 1855 |
2095 Node* eventTarget = nullptr; | 1856 return m_scrollManager.handleGestureScrollEvent(gestureEvent); |
2096 Scrollbar* scrollbar = nullptr; | |
2097 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { | |
2098 scrollbar = m_scrollbarHandlingScrollGesture.get(); | |
2099 eventTarget = m_scrollGestureHandlingNode.get(); | |
2100 } | |
2101 | |
2102 if (!eventTarget) { | |
2103 Document* document = m_frame->document(); | |
2104 if (document->layoutViewItem().isNull()) | |
2105 return WebInputEventResult::NotHandled; | |
2106 | |
2107 FrameView* view = m_frame->view(); | |
2108 LayoutPoint viewPoint = view->rootFrameToContents(gestureEvent.position( )); | |
2109 HitTestRequest request(HitTestRequest::ReadOnly); | |
2110 HitTestResult result(request, viewPoint); | |
2111 document->layoutViewItem().hitTest(result); | |
2112 | |
2113 eventTarget = result.innerNode(); | |
2114 | |
2115 m_lastGestureScrollOverWidget = result.isOverWidget(); | |
2116 m_scrollGestureHandlingNode = eventTarget; | |
2117 m_previousGestureScrolledNode = nullptr; | |
2118 | |
2119 if (!scrollbar) | |
2120 scrollbar = result.scrollbar(); | |
2121 } | |
2122 | |
2123 if (scrollbar) { | |
2124 bool shouldUpdateCapture = false; | |
2125 if (scrollbar->gestureEvent(gestureEvent, &shouldUpdateCapture)) { | |
2126 if (shouldUpdateCapture) | |
2127 m_scrollbarHandlingScrollGesture = scrollbar; | |
2128 return WebInputEventResult::HandledSuppressed; | |
2129 } | |
2130 m_scrollbarHandlingScrollGesture = nullptr; | |
2131 } | |
2132 | |
2133 if (eventTarget) { | |
2134 if (handleScrollGestureOnResizer(eventTarget, gestureEvent)) | |
2135 return WebInputEventResult::HandledSuppressed; | |
2136 | |
2137 GestureEvent* gestureDomEvent = GestureEvent::create(eventTarget->docume nt().domWindow(), gestureEvent); | |
2138 if (gestureDomEvent) { | |
2139 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent); | |
2140 if (gestureDomEventResult != DispatchEventResult::NotCanceled) { | |
2141 ASSERT(gestureDomEventResult != DispatchEventResult::CanceledByE ventHandler); | |
2142 return toWebInputEventResult(gestureDomEventResult); | |
2143 } | |
2144 } | |
2145 } | |
2146 | |
2147 switch (gestureEvent.type()) { | |
2148 case PlatformEvent::GestureScrollBegin: | |
2149 return handleGestureScrollBegin(gestureEvent); | |
2150 case PlatformEvent::GestureScrollUpdate: | |
2151 return handleGestureScrollUpdate(gestureEvent); | |
2152 case PlatformEvent::GestureScrollEnd: | |
2153 return handleGestureScrollEnd(gestureEvent); | |
2154 case PlatformEvent::GestureFlingStart: | |
2155 case PlatformEvent::GesturePinchBegin: | |
2156 case PlatformEvent::GesturePinchEnd: | |
2157 case PlatformEvent::GesturePinchUpdate: | |
2158 return WebInputEventResult::NotHandled; | |
2159 default: | |
2160 ASSERT_NOT_REACHED(); | |
2161 return WebInputEventResult::NotHandled; | |
2162 } | |
2163 } | 1857 } |
2164 | 1858 |
2165 WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest Results& targetedEvent) | 1859 WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest Results& targetedEvent) |
2166 { | 1860 { |
2167 FrameView* frameView(m_frame->view()); | 1861 FrameView* frameView(m_frame->view()); |
2168 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 1862 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2169 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); | 1863 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); |
2170 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); | 1864 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); |
2171 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); | 1865 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); |
2172 | 1866 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2315 { | 2009 { |
2316 #if !OS(ANDROID) | 2010 #if !OS(ANDROID) |
2317 if (m_longTapShouldInvokeContextMenu) { | 2011 if (m_longTapShouldInvokeContextMenu) { |
2318 m_longTapShouldInvokeContextMenu = false; | 2012 m_longTapShouldInvokeContextMenu = false; |
2319 return sendContextMenuEventForGesture(targetedEvent); | 2013 return sendContextMenuEventForGesture(targetedEvent); |
2320 } | 2014 } |
2321 #endif | 2015 #endif |
2322 return WebInputEventResult::NotHandled; | 2016 return WebInputEventResult::NotHandled; |
2323 } | 2017 } |
2324 | 2018 |
2325 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor mGestureEvent& gestureEvent) | |
2326 { | |
2327 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { | |
2328 PaintLayer* layer = eventTarget->layoutObject() ? eventTarget->layoutObj ect()->enclosingLayer() : nullptr; | |
2329 IntPoint p = m_frame->view()->rootFrameToContents(gestureEvent.position( )); | |
2330 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i sPointInResizeControl(p, ResizerForTouch)) { | |
2331 m_resizeScrollableArea = layer->getScrollableArea(); | |
2332 m_resizeScrollableArea->setInResizeMode(true); | |
2333 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); | |
2334 return true; | |
2335 } | |
2336 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { | |
2337 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | |
2338 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne r); | |
2339 return true; | |
2340 } | |
2341 } else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd) { | |
2342 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | |
2343 m_resizeScrollableArea->setInResizeMode(false); | |
2344 m_resizeScrollableArea = nullptr; | |
2345 return false; | |
2346 } | |
2347 } | |
2348 | |
2349 return false; | |
2350 } | |
2351 | |
2352 WebInputEventResult EventHandler::passScrollGestureEventToWidget(const PlatformG estureEvent& gestureEvent, LayoutObject* layoutObject) | |
2353 { | |
2354 ASSERT(gestureEvent.isScrollEvent()); | |
2355 | |
2356 if (!m_lastGestureScrollOverWidget || !layoutObject || !layoutObject->isLayo utPart()) | |
2357 return WebInputEventResult::NotHandled; | |
2358 | |
2359 Widget* widget = toLayoutPart(layoutObject)->widget(); | |
2360 | |
2361 if (!widget || !widget->isFrameView()) | |
2362 return WebInputEventResult::NotHandled; | |
2363 | |
2364 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent); | |
2365 } | |
2366 | |
2367 WebInputEventResult EventHandler::handleGestureScrollEnd(const PlatformGestureEv ent& gestureEvent) | 2019 WebInputEventResult EventHandler::handleGestureScrollEnd(const PlatformGestureEv ent& gestureEvent) |
2368 { | 2020 { |
2369 Node* node = m_scrollGestureHandlingNode; | 2021 return m_scrollManager.handleGestureScrollEnd(gestureEvent); |
2370 | |
2371 if (node) { | |
2372 passScrollGestureEventToWidget(gestureEvent, node->layoutObject()); | |
2373 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
2374 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta()); | |
2375 scrollStateData->is_ending = true; | |
2376 scrollStateData->is_in_inertial_phase = gestureEvent.inertialPhase() == ScrollInertialPhaseMomentum; | |
2377 scrollStateData->from_user_input = true; | |
2378 scrollStateData->is_direct_manipulation = true; | |
2379 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence; | |
2380 ScrollState* scrollState = ScrollState::create(std::move(scrollState Data)); | |
2381 customizedScroll(*node, *scrollState); | |
2382 } | |
2383 } | |
2384 | |
2385 clearGestureScrollState(); | |
2386 return WebInputEventResult::NotHandled; | |
2387 } | 2022 } |
2388 | 2023 |
2389 WebInputEventResult EventHandler::handleGestureScrollBegin(const PlatformGesture Event& gestureEvent) | 2024 WebInputEventResult EventHandler::handleGestureScrollBegin(const PlatformGesture Event& gestureEvent) |
2390 { | 2025 { |
2391 Document* document = m_frame->document(); | 2026 return m_scrollManager.handleGestureScrollBegin(gestureEvent); |
2392 if (document->layoutViewItem().isNull()) | |
2393 return WebInputEventResult::NotHandled; | |
2394 | |
2395 FrameView* view = m_frame->view(); | |
2396 if (!view) | |
2397 return WebInputEventResult::NotHandled; | |
2398 | |
2399 // If there's no layoutObject on the node, send the event to the nearest anc estor with a layoutObject. | |
2400 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s | |
2401 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->layoutOb ject()) | |
2402 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode(); | |
2403 | |
2404 if (!m_scrollGestureHandlingNode) { | |
2405 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | |
2406 m_scrollGestureHandlingNode = m_frame->document()->documentElement() ; | |
2407 else | |
2408 return WebInputEventResult::NotHandled; | |
2409 } | |
2410 ASSERT(m_scrollGestureHandlingNode); | |
2411 | |
2412 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->la youtObject()); | |
2413 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
2414 m_currentScrollChain.clear(); | |
2415 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateData() ); | |
2416 scrollStateData->position_x = gestureEvent.position().x(); | |
2417 scrollStateData->position_y = gestureEvent.position().y(); | |
2418 scrollStateData->is_beginning = true; | |
2419 scrollStateData->from_user_input = true; | |
2420 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsumedFor ScrollSequence; | |
2421 ScrollState* scrollState = ScrollState::create(std::move(scrollStateData )); | |
2422 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); | |
2423 } else { | |
2424 if (m_frame->isMainFrame()) | |
2425 m_frame->host()->topControls().scrollBegin(); | |
2426 } | |
2427 return WebInputEventResult::HandledSystem; | |
2428 } | |
2429 | |
2430 bool EventHandler::isRootScroller(const Node& node) const | |
2431 { | |
2432 // The root scroller is the one Element on the page designated to perform | |
2433 // "viewport actions" like top controls movement and overscroll glow. | |
2434 if (!frameHost() || !frameHost()->rootScroller()) | |
2435 return false; | |
2436 | |
2437 return frameHost()->rootScroller()->get() == &node; | |
2438 } | 2027 } |
2439 | 2028 |
2440 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) | 2029 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur eEvent& gestureEvent) |
2441 { | 2030 { |
2442 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | 2031 return m_scrollManager.handleGestureScrollUpdate(gestureEvent); |
2443 | |
2444 // Negate the deltas since the gesture event stores finger movement and | |
2445 // scrolling occurs in the direction opposite the finger's movement | |
2446 // direction. e.g. Finger moving up has negative event delta but causes the | |
2447 // page to scroll down causing positive scroll delta. | |
2448 FloatSize delta(-gestureEvent.deltaX(), -gestureEvent.deltaY()); | |
2449 FloatSize velocity(-gestureEvent.velocityX(), -gestureEvent.velocityY()); | |
2450 if (delta.isZero()) | |
2451 return WebInputEventResult::NotHandled; | |
2452 | |
2453 ScrollGranularity granularity = gestureEvent.deltaUnits(); | |
2454 Node* node = m_scrollGestureHandlingNode.get(); | |
2455 | |
2456 // Scroll customization is only available for touch. | |
2457 bool handleScrollCustomization = RuntimeEnabledFeatures::scrollCustomization Enabled() && gestureEvent.source() == PlatformGestureSourceTouchscreen; | |
2458 if (node) { | |
2459 LayoutObject* layoutObject = node->layoutObject(); | |
2460 if (!layoutObject) | |
2461 return WebInputEventResult::NotHandled; | |
2462 | |
2463 // Try to send the event to the correct view. | |
2464 WebInputEventResult result = passScrollGestureEventToWidget(gestureEvent , layoutObject); | |
2465 if (result != WebInputEventResult::NotHandled) { | |
2466 if (gestureEvent.preventPropagation() | |
2467 && !RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
2468 // This is an optimization which doesn't apply with | |
2469 // scroll customization enabled. | |
2470 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; | |
2471 } | |
2472 // FIXME: we should allow simultaneous scrolling of nested | |
2473 // iframes along perpendicular axes. See crbug.com/466991. | |
2474 m_deltaConsumedForScrollSequence = true; | |
2475 return result; | |
2476 } | |
2477 | |
2478 if (handleScrollCustomization) { | |
2479 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta()); | |
2480 scrollStateData->delta_x = delta.width(); | |
2481 scrollStateData->delta_y = delta.height(); | |
2482 scrollStateData->delta_granularity = ScrollByPrecisePixel; | |
2483 scrollStateData->velocity_x = velocity.width(); | |
2484 scrollStateData->velocity_y = velocity.height(); | |
2485 scrollStateData->should_propagate = !gestureEvent.preventPropagation (); | |
2486 scrollStateData->is_in_inertial_phase = gestureEvent.inertialPhase() == ScrollInertialPhaseMomentum; | |
2487 scrollStateData->from_user_input = true; | |
2488 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence; | |
2489 ScrollState* scrollState = ScrollState::create(std::move(scrollState Data)); | |
2490 if (m_previousGestureScrolledNode) { | |
2491 // The ScrollState needs to know what the current | |
2492 // native scrolling element is, so that for an | |
2493 // inertial scroll that shouldn't propagate, only the | |
2494 // currently scrolling element responds. | |
2495 ASSERT(m_previousGestureScrolledNode->isElementNode()); | |
2496 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get())); | |
2497 } | |
2498 customizedScroll(*node, *scrollState); | |
2499 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); | |
2500 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); | |
2501 if (scrollState->deltaX() != delta.width() | |
2502 || scrollState->deltaY() != delta.height()) { | |
2503 setFrameWasScrolledByUser(); | |
2504 return WebInputEventResult::HandledSystem; | |
2505 } | |
2506 } else { | |
2507 Node* stopNode = nullptr; | |
2508 if (gestureEvent.preventPropagation()) | |
2509 stopNode = m_previousGestureScrolledNode.get(); | |
2510 | |
2511 bool consumed = false; | |
2512 ScrollResult result = physicalScroll( | |
2513 granularity, | |
2514 delta, | |
2515 FloatPoint(gestureEvent.position()), | |
2516 velocity, | |
2517 node, | |
2518 &stopNode, | |
2519 &consumed); | |
2520 | |
2521 if (gestureEvent.preventPropagation()) | |
2522 m_previousGestureScrolledNode = stopNode; | |
2523 | |
2524 if ((!stopNode || !isRootScroller(*stopNode)) && frameHost()) { | |
2525 frameHost()->overscrollController().resetAccumulated( | |
2526 result.didScrollX, result.didScrollY); | |
2527 } | |
2528 | |
2529 if (consumed) | |
2530 return WebInputEventResult::HandledSystem; | |
2531 } | |
2532 } | |
2533 | |
2534 return WebInputEventResult::NotHandled; | |
2535 } | |
2536 | |
2537 void EventHandler::clearGestureScrollState() | |
2538 { | |
2539 m_scrollGestureHandlingNode = nullptr; | |
2540 m_previousGestureScrolledNode = nullptr; | |
2541 m_deltaConsumedForScrollSequence = false; | |
2542 m_currentScrollChain.clear(); | |
2543 | |
2544 if (FrameHost* host = frameHost()) { | |
2545 bool resetX = true; | |
2546 bool resetY = true; | |
2547 host->overscrollController().resetAccumulated(resetX, resetY); | |
2548 } | |
2549 } | 2032 } |
2550 | 2033 |
2551 bool EventHandler::isScrollbarHandlingGestures() const | 2034 bool EventHandler::isScrollbarHandlingGestures() const |
2552 { | 2035 { |
2553 return m_scrollbarHandlingScrollGesture.get(); | 2036 return m_scrollManager.isScrollbarHandlingGestures(); |
2554 } | 2037 } |
2555 | 2038 |
2556 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event) const | 2039 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event) const |
2557 { | 2040 { |
2558 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) | 2041 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) |
2559 return false; | 2042 return false; |
2560 return !event.area().isEmpty(); | 2043 return !event.area().isEmpty(); |
2561 } | 2044 } |
2562 | 2045 |
2563 bool EventHandler::bestClickableNodeForHitTestResult(const HitTestResult& result , IntPoint& targetPoint, Node*& targetNode) | 2046 bool EventHandler::bestClickableNodeForHitTestResult(const HitTestResult& result , IntPoint& targetPoint, Node*& targetNode) |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3082 return m_frame->page()->isCursorVisible(); | 2565 return m_frame->page()->isCursorVisible(); |
3083 } | 2566 } |
3084 | 2567 |
3085 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) | 2568 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) |
3086 { | 2569 { |
3087 m_frameSetBeingResized = frameSet; | 2570 m_frameSetBeingResized = frameSet; |
3088 } | 2571 } |
3089 | 2572 |
3090 void EventHandler::resizeScrollableAreaDestroyed() | 2573 void EventHandler::resizeScrollableAreaDestroyed() |
3091 { | 2574 { |
3092 ASSERT(m_resizeScrollableArea); | 2575 m_scrollManager.clearResizeScrollableArea(true); |
3093 m_resizeScrollableArea = nullptr; | |
3094 } | 2576 } |
3095 | 2577 |
3096 void EventHandler::hoverTimerFired(Timer<EventHandler>*) | 2578 void EventHandler::hoverTimerFired(Timer<EventHandler>*) |
3097 { | 2579 { |
3098 TRACE_EVENT0("input", "EventHandler::hoverTimerFired"); | 2580 TRACE_EVENT0("input", "EventHandler::hoverTimerFired"); |
3099 m_hoverTimer.stop(); | 2581 m_hoverTimer.stop(); |
3100 | 2582 |
3101 ASSERT(m_frame); | 2583 ASSERT(m_frame); |
3102 ASSERT(m_frame->document()); | 2584 ASSERT(m_frame->document()); |
3103 | 2585 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3153 } | 2635 } |
3154 | 2636 |
3155 WebInputEventResult EventHandler::keyEvent(const PlatformKeyboardEvent& initialK eyEvent) | 2637 WebInputEventResult EventHandler::keyEvent(const PlatformKeyboardEvent& initialK eyEvent) |
3156 { | 2638 { |
3157 m_frame->chromeClient().clearToolTip(); | 2639 m_frame->chromeClient().clearToolTip(); |
3158 | 2640 |
3159 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) | 2641 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) |
3160 capsLockStateMayHaveChanged(); | 2642 capsLockStateMayHaveChanged(); |
3161 | 2643 |
3162 #if OS(WIN) | 2644 #if OS(WIN) |
3163 if (panScrollInProgress()) { | 2645 if (m_scrollManager.panScrollInProgress()) { |
3164 // If a key is pressed while the panScroll is in progress then we want t o stop | 2646 // If a key is pressed while the panScroll is in progress then we want t o stop |
3165 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent. type() == PlatformEvent::RawKeyDown) | 2647 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent. type() == PlatformEvent::RawKeyDown) |
3166 stopAutoscroll(); | 2648 m_scrollManager.stopAutoscroll(); |
3167 | 2649 |
3168 // If we were in panscroll mode, we swallow the key event | 2650 // If we were in panscroll mode, we swallow the key event |
3169 return WebInputEventResult::HandledSuppressed; | 2651 return WebInputEventResult::HandledSuppressed; |
3170 } | 2652 } |
3171 #endif | 2653 #endif |
3172 | 2654 |
3173 // Check for cases where we are too early for events -- possible unmatched k ey up | 2655 // Check for cases where we are too early for events -- possible unmatched k ey up |
3174 // from pressing return in the location bar. | 2656 // from pressing return in the location bar. |
3175 Node* node = eventTargetNodeForDocument(m_frame->document()); | 2657 Node* node = eventTargetNodeForDocument(m_frame->document()); |
3176 if (!node) | 2658 if (!node) |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3480 event->setDefaultHandled(); | 2962 event->setDefaultHandled(); |
3481 } | 2963 } |
3482 | 2964 |
3483 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) | 2965 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) |
3484 { | 2966 { |
3485 ASSERT(event->type() == EventTypeNames::keypress); | 2967 ASSERT(event->type() == EventTypeNames::keypress); |
3486 | 2968 |
3487 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 2969 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
3488 return; | 2970 return; |
3489 | 2971 |
3490 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; | 2972 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; |
dtapuska
2016/05/27 14:12:23
I wonder if defaultSpaceEventHandler and defaultWh
Navid Zolghadr
2016/05/30 20:15:46
I wanted to move DefaultSpaceEventHandler to anoth
bokan
2016/05/31 19:39:13
This plan sgtm.
| |
3491 | 2973 |
3492 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 2974 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
3493 if (logicalScroll(direction, ScrollByPage)) { | 2975 if (m_scrollManager.logicalScroll(direction, ScrollByPage, nullptr, m_mouseP ressNode)) { |
3494 event->setDefaultHandled(); | 2976 event->setDefaultHandled(); |
3495 return; | 2977 return; |
3496 } | 2978 } |
3497 } | 2979 } |
3498 | 2980 |
3499 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) | 2981 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) |
3500 { | 2982 { |
3501 ASSERT(event->type() == EventTypeNames::keydown); | 2983 ASSERT(event->type() == EventTypeNames::keydown); |
3502 | 2984 |
3503 if (!RuntimeEnabledFeatures::backspaceDefaultHandlerEnabled()) | 2985 if (!RuntimeEnabledFeatures::backspaceDefaultHandlerEnabled()) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3579 void EventHandler::capsLockStateMayHaveChanged() | 3061 void EventHandler::capsLockStateMayHaveChanged() |
3580 { | 3062 { |
3581 if (Element* element = m_frame->document()->focusedElement()) { | 3063 if (Element* element = m_frame->document()->focusedElement()) { |
3582 if (LayoutObject* r = element->layoutObject()) { | 3064 if (LayoutObject* r = element->layoutObject()) { |
3583 if (r->isTextField()) | 3065 if (r->isTextField()) |
3584 toLayoutTextControlSingleLine(r)->capsLockStateMayHaveChanged(); | 3066 toLayoutTextControlSingleLine(r)->capsLockStateMayHaveChanged(); |
3585 } | 3067 } |
3586 } | 3068 } |
3587 } | 3069 } |
3588 | 3070 |
3589 void EventHandler::setFrameWasScrolledByUser() | |
3590 { | |
3591 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) | |
3592 documentLoader->initialScrollState().wasScrolledByUser = true; | |
3593 } | |
3594 | |
3595 bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults& mev) | 3071 bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults& mev) |
3596 { | 3072 { |
3597 Scrollbar* scrollbar = mev.scrollbar(); | 3073 Scrollbar* scrollbar = mev.scrollbar(); |
3598 updateLastScrollbarUnderMouse(scrollbar, true); | 3074 updateLastScrollbarUnderMouse(scrollbar, true); |
3599 | 3075 |
3600 if (!scrollbar || !scrollbar->enabled()) | 3076 if (!scrollbar || !scrollbar->enabled()) |
3601 return false; | 3077 return false; |
3602 setFrameWasScrolledByUser(); | 3078 m_scrollManager.setFrameWasScrolledByUser(); |
3603 scrollbar->mouseDown(mev.event()); | 3079 scrollbar->mouseDown(mev.event()); |
3604 return true; | 3080 return true; |
3605 } | 3081 } |
3606 | 3082 |
3607 // If scrollbar (under mouse) is different from last, send a mouse exited. Set | 3083 // If scrollbar (under mouse) is different from last, send a mouse exited. Set |
3608 // last to scrollbar if setLast is true; else set last to 0. | 3084 // last to scrollbar if setLast is true; else set last to 0. |
3609 void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL ast) | 3085 void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL ast) |
3610 { | 3086 { |
3611 if (m_lastScrollbarUnderMouse != scrollbar) { | 3087 if (m_lastScrollbarUnderMouse != scrollbar) { |
3612 // Send mouse exited to the old scrollbar. | 3088 // Send mouse exited to the old scrollbar. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3708 | 3184 |
3709 FrameHost* EventHandler::frameHost() const | 3185 FrameHost* EventHandler::frameHost() const |
3710 { | 3186 { |
3711 if (!m_frame->page()) | 3187 if (!m_frame->page()) |
3712 return nullptr; | 3188 return nullptr; |
3713 | 3189 |
3714 return &m_frame->page()->frameHost(); | 3190 return &m_frame->page()->frameHost(); |
3715 } | 3191 } |
3716 | 3192 |
3717 } // namespace blink | 3193 } // namespace blink |
OLD | NEW |