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(); |
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()) |
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 return m_scrollManager.bubblingScroll(direction, granularity, startingNode,
m_mousePressNode); |
756 // here because of an onLoad event, in which case the final layout hasn't be
en performed yet. | |
757 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
758 // FIXME: enable scroll customization in this case. See crbug.com/410974. | |
759 if (logicalScroll(direction, granularity, startingNode)) | |
760 return true; | |
761 | |
762 Frame* parentFrame = m_frame->tree().parent(); | |
763 if (!parentFrame || !parentFrame->isLocalFrame()) | |
764 return false; | |
765 // FIXME: Broken for OOPI. | |
766 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g
ranularity, m_frame->deprecatedLocalOwner()); | |
767 } | 529 } |
768 | 530 |
769 IntPoint EventHandler::lastKnownMousePosition() const | 531 IntPoint EventHandler::lastKnownMousePosition() const |
770 { | 532 { |
771 return m_lastKnownMousePosition; | 533 return m_lastKnownMousePosition; |
772 } | 534 } |
773 | 535 |
774 IntPoint EventHandler::dragDataTransferLocationForTesting() | 536 IntPoint EventHandler::dragDataTransferLocationForTesting() |
775 { | 537 { |
776 if (dragState().m_dragDataTransfer) | 538 if (dragState().m_dragDataTransfer) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 if (LocalFrame* frame = result.innerNodeFrame()) { | 613 if (LocalFrame* frame = result.innerNodeFrame()) { |
852 OptionalCursor optionalCursor = frame->eventHandler().selectCursor(resul
t); | 614 OptionalCursor optionalCursor = frame->eventHandler().selectCursor(resul
t); |
853 if (optionalCursor.isCursorChange()) { | 615 if (optionalCursor.isCursorChange()) { |
854 view->setCursor(optionalCursor.cursor()); | 616 view->setCursor(optionalCursor.cursor()); |
855 } | 617 } |
856 } | 618 } |
857 } | 619 } |
858 | 620 |
859 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) | 621 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) |
860 { | 622 { |
861 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) | 623 if (m_scrollManager.inResizeMode()) |
862 return NoCursorChange; | 624 return NoCursorChange; |
863 | 625 |
864 Page* page = m_frame->page(); | 626 Page* page = m_frame->page(); |
865 if (!page) | 627 if (!page) |
866 return NoCursorChange; | 628 return NoCursorChange; |
867 if (panScrollInProgress()) | 629 if (m_scrollManager.panScrollInProgress()) |
868 return NoCursorChange; | 630 return NoCursorChange; |
869 | 631 |
870 Node* node = result.innerPossiblyPseudoNode(); | 632 Node* node = result.innerPossiblyPseudoNode(); |
871 if (!node) | 633 if (!node) |
872 return selectAutoCursor(result, node, iBeamCursor()); | 634 return selectAutoCursor(result, node, iBeamCursor()); |
873 | 635 |
874 LayoutObject* layoutObject = node->layoutObject(); | 636 LayoutObject* layoutObject = node->layoutObject(); |
875 const ComputedStyle* style = layoutObject ? layoutObject->style() : nullptr; | 637 const ComputedStyle* style = layoutObject ? layoutObject->style() : nullptr; |
876 | 638 |
877 if (layoutObject) { | 639 if (layoutObject) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 m_capturingMouseEventsNode = mev.innerNode(); | 852 m_capturingMouseEventsNode = mev.innerNode(); |
1091 m_eventHandlerWillResetCapturingMouseEventsNode = true; | 853 m_eventHandlerWillResetCapturingMouseEventsNode = true; |
1092 } | 854 } |
1093 invalidateClick(); | 855 invalidateClick(); |
1094 return result; | 856 return result; |
1095 } | 857 } |
1096 | 858 |
1097 #if OS(WIN) | 859 #if OS(WIN) |
1098 // We store whether pan scrolling is in progress before calling stopAutoscro
ll() | 860 // We store whether pan scrolling is in progress before calling stopAutoscro
ll() |
1099 // because it will set m_autoscrollType to NoAutoscroll on return. | 861 // because it will set m_autoscrollType to NoAutoscroll on return. |
1100 bool isPanScrollInProgress = panScrollInProgress(); | 862 bool isPanScrollInProgress = m_scrollManager.panScrollInProgress(); |
1101 stopAutoscroll(); | 863 m_scrollManager.stopAutoscroll(); |
1102 if (isPanScrollInProgress) { | 864 if (isPanScrollInProgress) { |
1103 // We invalidate the click when exiting pan scrolling so that we don't i
nadvertently navigate | 865 // 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>. | 866 // away from the current page (e.g. the click was on a hyperlink). See <
rdar://problem/6095023>. |
1105 invalidateClick(); | 867 invalidateClick(); |
1106 return WebInputEventResult::HandledSuppressed; | 868 return WebInputEventResult::HandledSuppressed; |
1107 } | 869 } |
1108 #endif | 870 #endif |
1109 | 871 |
1110 m_clickCount = mouseEvent.clickCount(); | 872 m_clickCount = mouseEvent.clickCount(); |
1111 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me
v.innerNode()) : mev.innerNode(); | 873 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me
v.innerNode()) : mev.innerNode(); |
1112 | 874 |
1113 m_frame->selection().setCaretBlinkingSuspended(true); | 875 m_frame->selection().setCaretBlinkingSuspended(true); |
1114 | 876 |
1115 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event
TypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event()); | 877 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event
TypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event()); |
1116 | 878 |
1117 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) { | 879 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) { |
1118 FrameView* view = m_frame->view(); | 880 FrameView* view = m_frame->view(); |
1119 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l
ayoutObject()->enclosingLayer() : nullptr; | 881 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l
ayoutObject()->enclosingLayer() : nullptr; |
1120 IntPoint p = view->rootFrameToContents(mouseEvent.position()); | 882 IntPoint p = view->rootFrameToContents(mouseEvent.position()); |
1121 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i
sPointInResizeControl(p, ResizerForPointer)) { | 883 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i
sPointInResizeControl(p, ResizerForPointer)) { |
1122 m_resizeScrollableArea = layer->getScrollableArea(); | 884 m_scrollManager.setResizeScrollableArea(layer, p); |
1123 m_resizeScrollableArea->setInResizeMode(true); | |
1124 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); | |
1125 return WebInputEventResult::HandledSystem; | 885 return WebInputEventResult::HandledSystem; |
1126 } | 886 } |
1127 } | 887 } |
1128 | 888 |
1129 // m_selectionInitiationState is initialized after dispatching mousedown | 889 // m_selectionInitiationState is initialized after dispatching mousedown |
1130 // event in order not to keep the selection by DOM APIs Because we can't | 890 // 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 | 891 // 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 | 892 // 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. | 893 // the same behavior and it's more compatible with other browsers. |
1134 selectionController().initializeSelectionState(); | 894 selectionController().initializeSelectionState(); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 if (forceLeave) | 1045 if (forceLeave) |
1286 m_frame->document()->updateHoverActiveState(request, 0); | 1046 m_frame->document()->updateHoverActiveState(request, 0); |
1287 else | 1047 else |
1288 mev = prepareMouseEvent(request, mouseEvent); | 1048 mev = prepareMouseEvent(request, mouseEvent); |
1289 | 1049 |
1290 if (hoveredNode) | 1050 if (hoveredNode) |
1291 *hoveredNode = mev.hitTestResult(); | 1051 *hoveredNode = mev.hitTestResult(); |
1292 | 1052 |
1293 Scrollbar* scrollbar = nullptr; | 1053 Scrollbar* scrollbar = nullptr; |
1294 | 1054 |
1295 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | 1055 if (m_scrollManager.inResizeMode()) { |
1296 m_resizeScrollableArea->resize(mev.event(), m_offsetFromResizeCorner); | 1056 m_scrollManager.resize(mev.event()); |
1297 } else { | 1057 } else { |
1298 if (!scrollbar) | 1058 if (!scrollbar) |
1299 scrollbar = mev.scrollbar(); | 1059 scrollbar = mev.scrollbar(); |
1300 | 1060 |
1301 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); | 1061 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); |
1302 if (onlyUpdateScrollbars) | 1062 if (onlyUpdateScrollbars) |
1303 return WebInputEventResult::HandledSuppressed; | 1063 return WebInputEventResult::HandledSuppressed; |
1304 } | 1064 } |
1305 | 1065 |
1306 WebInputEventResult eventResult = WebInputEventResult::NotHandled; | 1066 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. | 1214 // This is to suppress sending click events for non-primary buttons. |
1455 // But still doing default action like opening a new tab for middle | 1215 // But still doing default action like opening a new tab for middle |
1456 // click (crbug.com/255). | 1216 // click (crbug.com/255). |
1457 if (mev.event().button() != MouseButton::LeftButton) | 1217 if (mev.event().button() != MouseButton::LeftButton) |
1458 event->stopPropagation(); | 1218 event->stopPropagation(); |
1459 | 1219 |
1460 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchEv
ent(event)); | 1220 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchEv
ent(event)); |
1461 } | 1221 } |
1462 } | 1222 } |
1463 | 1223 |
1464 if (m_resizeScrollableArea) { | 1224 m_scrollManager.clearResizeScrollableArea(false); |
1465 m_resizeScrollableArea->setInResizeMode(false); | |
1466 m_resizeScrollableArea = nullptr; | |
1467 } | |
1468 | 1225 |
1469 if (eventResult == WebInputEventResult::NotHandled) | 1226 if (eventResult == WebInputEventResult::NotHandled) |
1470 eventResult = handleMouseReleaseEvent(mev); | 1227 eventResult = handleMouseReleaseEvent(mev); |
1471 | 1228 |
1472 invalidateClick(); | 1229 invalidateClick(); |
1473 | 1230 |
1474 return mergeEventResult(clickEventResult, eventResult); | 1231 return mergeEventResult(clickEventResult, eventResult); |
1475 } | 1232 } |
1476 | 1233 |
1477 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp
e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer
) | 1234 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; | 1309 return eventResult; |
1553 | 1310 |
1554 HitTestRequest request(HitTestRequest::ReadOnly); | 1311 HitTestRequest request(HitTestRequest::ReadOnly); |
1555 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); | 1312 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); |
1556 | 1313 |
1557 // Drag events should never go to text nodes (following IE, and proper mouse
over/out dispatch) | 1314 // Drag events should never go to text nodes (following IE, and proper mouse
over/out dispatch) |
1558 Node* newTarget = mev.innerNode(); | 1315 Node* newTarget = mev.innerNode(); |
1559 if (newTarget && newTarget->isTextNode()) | 1316 if (newTarget && newTarget->isTextNode()) |
1560 newTarget = FlatTreeTraversal::parent(*newTarget); | 1317 newTarget = FlatTreeTraversal::parent(*newTarget); |
1561 | 1318 |
1562 if (AutoscrollController* controller = autoscrollController()) | 1319 if (AutoscrollController* controller = m_scrollManager.autoscrollController(
)) |
1563 controller->updateDragAndDrop(newTarget, event.position(), event.timesta
mp()); | 1320 controller->updateDragAndDrop(newTarget, event.position(), event.timesta
mp()); |
1564 | 1321 |
1565 if (m_dragTarget != newTarget) { | 1322 if (m_dragTarget != newTarget) { |
1566 // FIXME: this ordering was explicitly chosen to match WinIE. However, | 1323 // FIXME: this ordering was explicitly chosen to match WinIE. However, |
1567 // it is sometimes incorrect when dragging within subframes, as seen wit
h | 1324 // it is sometimes incorrect when dragging within subframes, as seen wit
h |
1568 // LayoutTests/fast/events/drag-in-frames.html. | 1325 // LayoutTests/fast/events/drag-in-frames.html. |
1569 // | 1326 // |
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>. | 1327 // 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; | 1328 LocalFrame* targetFrame; |
1572 if (targetIsFrame(newTarget, targetFrame)) { | 1329 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); | 1397 result = targetFrame->eventHandler().performDragAndDrop(event, dataT
ransfer); |
1641 } else if (m_dragTarget.get()) { | 1398 } else if (m_dragTarget.get()) { |
1642 result = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.get(), eve
nt, dataTransfer); | 1399 result = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.get(), eve
nt, dataTransfer); |
1643 } | 1400 } |
1644 clearDragState(); | 1401 clearDragState(); |
1645 return result; | 1402 return result; |
1646 } | 1403 } |
1647 | 1404 |
1648 void EventHandler::clearDragState() | 1405 void EventHandler::clearDragState() |
1649 { | 1406 { |
1650 stopAutoscroll(); | 1407 m_scrollManager.stopAutoscroll(); |
1651 m_dragTarget = nullptr; | 1408 m_dragTarget = nullptr; |
1652 m_capturingMouseEventsNode = nullptr; | 1409 m_capturingMouseEventsNode = nullptr; |
1653 m_shouldOnlyFireDragOverEvent = false; | 1410 m_shouldOnlyFireDragOverEvent = false; |
1654 } | 1411 } |
1655 | 1412 |
1656 void EventHandler::setCapturingMouseEventsNode(Node* n) | 1413 void EventHandler::setCapturingMouseEventsNode(Node* n) |
1657 { | 1414 { |
1658 m_capturingMouseEventsNode = n; | 1415 m_capturingMouseEventsNode = n; |
1659 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 1416 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
1660 } | 1417 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 | 1639 |
1883 // If we're over the frame scrollbar, scroll the document. | 1640 // If we're over the frame scrollbar, scroll the document. |
1884 if (!node && result.scrollbar()) | 1641 if (!node && result.scrollbar()) |
1885 node = doc->documentElement(); | 1642 node = doc->documentElement(); |
1886 | 1643 |
1887 bool sendDOMEvent = true; | 1644 bool sendDOMEvent = true; |
1888 LocalFrame* subframe = subframeForTargetNode(node); | 1645 LocalFrame* subframe = subframeForTargetNode(node); |
1889 if (subframe) { | 1646 if (subframe) { |
1890 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e
vent); | 1647 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e
vent); |
1891 if (result != WebInputEventResult::NotHandled) { | 1648 if (result != WebInputEventResult::NotHandled) { |
1892 setFrameWasScrolledByUser(); | 1649 m_scrollManager.setFrameWasScrolledByUser(); |
1893 return result; | 1650 return result; |
1894 } | 1651 } |
1895 // TODO(dtapuska): Remove this once wheel gesture scroll has | 1652 // TODO(dtapuska): Remove this once wheel gesture scroll has |
1896 // been enabled everywhere; as we can just return early. | 1653 // been enabled everywhere; as we can just return early. |
1897 // http://crbug.com/568183 | 1654 // http://crbug.com/568183 |
1898 // Don't propagate the DOM event into the parent iframe | 1655 // Don't propagate the DOM event into the parent iframe |
1899 // but do dispatch the scroll event. | 1656 // but do dispatch the scroll event. |
1900 sendDOMEvent = false; | 1657 sendDOMEvent = false; |
1901 } | 1658 } |
1902 | 1659 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 if (granularity == ScrollByPage) { | 1707 if (granularity == ScrollByPage) { |
1951 if (delta.width()) | 1708 if (delta.width()) |
1952 delta.setWidth(delta.width() > 0 ? 1 : -1); | 1709 delta.setWidth(delta.width() > 0 ? 1 : -1); |
1953 if (delta.height()) | 1710 if (delta.height()) |
1954 delta.setHeight(delta.height() > 0 ? 1 : -1); | 1711 delta.setHeight(delta.height() > 0 ? 1 : -1); |
1955 } | 1712 } |
1956 | 1713 |
1957 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 1714 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
1958 bool consumed = false; | 1715 bool consumed = false; |
1959 | 1716 |
1960 physicalScroll( | 1717 m_scrollManager.physicalScroll( |
1961 granularity, | 1718 granularity, |
1962 delta, | 1719 delta, |
1963 FloatPoint(), | 1720 FloatPoint(), |
1964 FloatSize(), | 1721 FloatSize(), |
1965 startNode, | 1722 startNode, |
1966 &node, | 1723 &node, |
1967 &consumed); | 1724 &consumed); |
1968 | 1725 |
1969 if (consumed) | 1726 if (consumed) |
1970 wheelEvent->setDefaultHandled(); | 1727 wheelEvent->setDefaultHandled(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 | 1785 |
2029 // No hit test result, handle in root instance. Perhaps we should just retur
n false instead? | 1786 // No hit test result, handle in root instance. Perhaps we should just retur
n false instead? |
2030 return handleGestureEventInFrame(targetedEvent); | 1787 return handleGestureEventInFrame(targetedEvent); |
2031 } | 1788 } |
2032 | 1789 |
2033 WebInputEventResult EventHandler::handleGestureEventInFrame(const GestureEventWi
thHitTestResults& targetedEvent) | 1790 WebInputEventResult EventHandler::handleGestureEventInFrame(const GestureEventWi
thHitTestResults& targetedEvent) |
2034 { | 1791 { |
2035 ASSERT(!targetedEvent.event().isScrollEvent()); | 1792 ASSERT(!targetedEvent.event().isScrollEvent()); |
2036 | 1793 |
2037 Node* eventTarget = targetedEvent.hitTestResult().innerNode(); | 1794 Node* eventTarget = targetedEvent.hitTestResult().innerNode(); |
2038 Scrollbar* scrollbar = targetedEvent.hitTestResult().scrollbar(); | |
2039 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 1795 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2040 | 1796 |
2041 if (scrollbar) { | 1797 if (m_scrollManager.canHandleGestureEvent(targetedEvent)) |
2042 bool shouldUpdateCapture = false; | 1798 return WebInputEventResult::HandledSuppressed; |
2043 if (scrollbar->gestureEvent(gestureEvent, &shouldUpdateCapture)) { | |
2044 if (shouldUpdateCapture) | |
2045 m_scrollbarHandlingScrollGesture = scrollbar; | |
2046 return WebInputEventResult::HandledSuppressed; | |
2047 } | |
2048 } | |
2049 | 1799 |
2050 if (eventTarget) { | 1800 if (eventTarget) { |
2051 GestureEvent* gestureDomEvent = GestureEvent::create(eventTarget->docume
nt().domWindow(), gestureEvent); | 1801 GestureEvent* gestureDomEvent = GestureEvent::create(eventTarget->docume
nt().domWindow(), gestureEvent); |
2052 if (gestureDomEvent) { | 1802 if (gestureDomEvent) { |
2053 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve
nt(gestureDomEvent); | 1803 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve
nt(gestureDomEvent); |
2054 if (gestureDomEventResult != DispatchEventResult::NotCanceled) { | 1804 if (gestureDomEventResult != DispatchEventResult::NotCanceled) { |
2055 ASSERT(gestureDomEventResult != DispatchEventResult::CanceledByE
ventHandler); | 1805 ASSERT(gestureDomEventResult != DispatchEventResult::CanceledByE
ventHandler); |
2056 return toWebInputEventResult(gestureDomEventResult); | 1806 return toWebInputEventResult(gestureDomEventResult); |
2057 } | 1807 } |
2058 } | 1808 } |
(...skipping 21 matching lines...) Expand all Loading... |
2080 ASSERT_NOT_REACHED(); | 1830 ASSERT_NOT_REACHED(); |
2081 } | 1831 } |
2082 | 1832 |
2083 return WebInputEventResult::NotHandled; | 1833 return WebInputEventResult::NotHandled; |
2084 } | 1834 } |
2085 | 1835 |
2086 WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture
Event& gestureEvent) | 1836 WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture
Event& gestureEvent) |
2087 { | 1837 { |
2088 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); | 1838 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); |
2089 | 1839 |
2090 Node* eventTarget = nullptr; | 1840 return m_scrollManager.handleGestureScrollEvent(gestureEvent); |
2091 Scrollbar* scrollbar = nullptr; | |
2092 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { | |
2093 scrollbar = m_scrollbarHandlingScrollGesture.get(); | |
2094 eventTarget = m_scrollGestureHandlingNode.get(); | |
2095 } | |
2096 | |
2097 if (!eventTarget) { | |
2098 Document* document = m_frame->document(); | |
2099 if (document->layoutViewItem().isNull()) | |
2100 return WebInputEventResult::NotHandled; | |
2101 | |
2102 FrameView* view = m_frame->view(); | |
2103 LayoutPoint viewPoint = view->rootFrameToContents(gestureEvent.position(
)); | |
2104 HitTestRequest request(HitTestRequest::ReadOnly); | |
2105 HitTestResult result(request, viewPoint); | |
2106 document->layoutViewItem().hitTest(result); | |
2107 | |
2108 eventTarget = result.innerNode(); | |
2109 | |
2110 m_lastGestureScrollOverWidget = result.isOverWidget(); | |
2111 m_scrollGestureHandlingNode = eventTarget; | |
2112 m_previousGestureScrolledNode = nullptr; | |
2113 | |
2114 if (!scrollbar) | |
2115 scrollbar = result.scrollbar(); | |
2116 } | |
2117 | |
2118 if (scrollbar) { | |
2119 bool shouldUpdateCapture = false; | |
2120 if (scrollbar->gestureEvent(gestureEvent, &shouldUpdateCapture)) { | |
2121 if (shouldUpdateCapture) | |
2122 m_scrollbarHandlingScrollGesture = scrollbar; | |
2123 return WebInputEventResult::HandledSuppressed; | |
2124 } | |
2125 m_scrollbarHandlingScrollGesture = nullptr; | |
2126 } | |
2127 | |
2128 if (eventTarget) { | |
2129 if (handleScrollGestureOnResizer(eventTarget, gestureEvent)) | |
2130 return WebInputEventResult::HandledSuppressed; | |
2131 | |
2132 GestureEvent* gestureDomEvent = GestureEvent::create(eventTarget->docume
nt().domWindow(), gestureEvent); | |
2133 if (gestureDomEvent) { | |
2134 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve
nt(gestureDomEvent); | |
2135 if (gestureDomEventResult != DispatchEventResult::NotCanceled) { | |
2136 ASSERT(gestureDomEventResult != DispatchEventResult::CanceledByE
ventHandler); | |
2137 return toWebInputEventResult(gestureDomEventResult); | |
2138 } | |
2139 } | |
2140 } | |
2141 | |
2142 switch (gestureEvent.type()) { | |
2143 case PlatformEvent::GestureScrollBegin: | |
2144 return handleGestureScrollBegin(gestureEvent); | |
2145 case PlatformEvent::GestureScrollUpdate: | |
2146 return handleGestureScrollUpdate(gestureEvent); | |
2147 case PlatformEvent::GestureScrollEnd: | |
2148 return handleGestureScrollEnd(gestureEvent); | |
2149 case PlatformEvent::GestureFlingStart: | |
2150 case PlatformEvent::GesturePinchBegin: | |
2151 case PlatformEvent::GesturePinchEnd: | |
2152 case PlatformEvent::GesturePinchUpdate: | |
2153 return WebInputEventResult::NotHandled; | |
2154 default: | |
2155 ASSERT_NOT_REACHED(); | |
2156 return WebInputEventResult::NotHandled; | |
2157 } | |
2158 } | 1841 } |
2159 | 1842 |
2160 WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest
Results& targetedEvent) | 1843 WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest
Results& targetedEvent) |
2161 { | 1844 { |
2162 FrameView* frameView(m_frame->view()); | 1845 FrameView* frameView(m_frame->view()); |
2163 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 1846 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
2164 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur
eEvent.type()); | 1847 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur
eEvent.type()); |
2165 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); | 1848 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); |
2166 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); | 1849 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); |
2167 | 1850 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 { | 1993 { |
2311 #if !OS(ANDROID) | 1994 #if !OS(ANDROID) |
2312 if (m_longTapShouldInvokeContextMenu) { | 1995 if (m_longTapShouldInvokeContextMenu) { |
2313 m_longTapShouldInvokeContextMenu = false; | 1996 m_longTapShouldInvokeContextMenu = false; |
2314 return sendContextMenuEventForGesture(targetedEvent); | 1997 return sendContextMenuEventForGesture(targetedEvent); |
2315 } | 1998 } |
2316 #endif | 1999 #endif |
2317 return WebInputEventResult::NotHandled; | 2000 return WebInputEventResult::NotHandled; |
2318 } | 2001 } |
2319 | 2002 |
2320 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor
mGestureEvent& gestureEvent) | |
2321 { | |
2322 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { | |
2323 PaintLayer* layer = eventTarget->layoutObject() ? eventTarget->layoutObj
ect()->enclosingLayer() : nullptr; | |
2324 IntPoint p = m_frame->view()->rootFrameToContents(gestureEvent.position(
)); | |
2325 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i
sPointInResizeControl(p, ResizerForTouch)) { | |
2326 m_resizeScrollableArea = layer->getScrollableArea(); | |
2327 m_resizeScrollableArea->setInResizeMode(true); | |
2328 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); | |
2329 return true; | |
2330 } | |
2331 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { | |
2332 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | |
2333 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne
r); | |
2334 return true; | |
2335 } | |
2336 } else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd) { | |
2337 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { | |
2338 m_resizeScrollableArea->setInResizeMode(false); | |
2339 m_resizeScrollableArea = nullptr; | |
2340 return false; | |
2341 } | |
2342 } | |
2343 | |
2344 return false; | |
2345 } | |
2346 | |
2347 WebInputEventResult EventHandler::passScrollGestureEventToWidget(const PlatformG
estureEvent& gestureEvent, LayoutObject* layoutObject) | |
2348 { | |
2349 ASSERT(gestureEvent.isScrollEvent()); | |
2350 | |
2351 if (!m_lastGestureScrollOverWidget || !layoutObject || !layoutObject->isLayo
utPart()) | |
2352 return WebInputEventResult::NotHandled; | |
2353 | |
2354 Widget* widget = toLayoutPart(layoutObject)->widget(); | |
2355 | |
2356 if (!widget || !widget->isFrameView()) | |
2357 return WebInputEventResult::NotHandled; | |
2358 | |
2359 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent(
gestureEvent); | |
2360 } | |
2361 | |
2362 WebInputEventResult EventHandler::handleGestureScrollEnd(const PlatformGestureEv
ent& gestureEvent) | 2003 WebInputEventResult EventHandler::handleGestureScrollEnd(const PlatformGestureEv
ent& gestureEvent) |
2363 { | 2004 { |
2364 Node* node = m_scrollGestureHandlingNode; | 2005 return m_scrollManager.handleGestureScrollEnd(gestureEvent); |
2365 | |
2366 if (node) { | |
2367 passScrollGestureEventToWidget(gestureEvent, node->layoutObject()); | |
2368 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
2369 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa
ta()); | |
2370 scrollStateData->is_ending = true; | |
2371 scrollStateData->is_in_inertial_phase = gestureEvent.inertialPhase()
== ScrollInertialPhaseMomentum; | |
2372 scrollStateData->from_user_input = true; | |
2373 scrollStateData->is_direct_manipulation = true; | |
2374 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume
dForScrollSequence; | |
2375 ScrollState* scrollState = ScrollState::create(std::move(scrollState
Data)); | |
2376 customizedScroll(*node, *scrollState); | |
2377 } | |
2378 } | |
2379 | |
2380 clearGestureScrollState(); | |
2381 return WebInputEventResult::NotHandled; | |
2382 } | |
2383 | |
2384 WebInputEventResult EventHandler::handleGestureScrollBegin(const PlatformGesture
Event& gestureEvent) | |
2385 { | |
2386 Document* document = m_frame->document(); | |
2387 if (document->layoutViewItem().isNull()) | |
2388 return WebInputEventResult::NotHandled; | |
2389 | |
2390 FrameView* view = m_frame->view(); | |
2391 if (!view) | |
2392 return WebInputEventResult::NotHandled; | |
2393 | |
2394 // If there's no layoutObject on the node, send the event to the nearest anc
estor with a layoutObject. | |
2395 // Needed for <option> and <optgroup> elements so we can touch scroll <selec
t>s | |
2396 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->layoutOb
ject()) | |
2397 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado
wHostNode(); | |
2398 | |
2399 if (!m_scrollGestureHandlingNode) { | |
2400 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | |
2401 m_scrollGestureHandlingNode = m_frame->document()->documentElement()
; | |
2402 else | |
2403 return WebInputEventResult::NotHandled; | |
2404 } | |
2405 ASSERT(m_scrollGestureHandlingNode); | |
2406 | |
2407 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->la
youtObject()); | |
2408 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
2409 m_currentScrollChain.clear(); | |
2410 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateData()
); | |
2411 scrollStateData->position_x = gestureEvent.position().x(); | |
2412 scrollStateData->position_y = gestureEvent.position().y(); | |
2413 scrollStateData->is_beginning = true; | |
2414 scrollStateData->from_user_input = true; | |
2415 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsumedFor
ScrollSequence; | |
2416 ScrollState* scrollState = ScrollState::create(std::move(scrollStateData
)); | |
2417 customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); | |
2418 } else { | |
2419 if (m_frame->isMainFrame()) | |
2420 m_frame->host()->topControls().scrollBegin(); | |
2421 } | |
2422 return WebInputEventResult::HandledSystem; | |
2423 } | |
2424 | |
2425 bool EventHandler::isRootScroller(const Node& node) const | |
2426 { | |
2427 // The root scroller is the one Element on the page designated to perform | |
2428 // "viewport actions" like top controls movement and overscroll glow. | |
2429 if (!frameHost() || !frameHost()->rootScroller()) | |
2430 return false; | |
2431 | |
2432 return frameHost()->rootScroller()->get() == &node; | |
2433 } | |
2434 | |
2435 WebInputEventResult EventHandler::handleGestureScrollUpdate(const PlatformGestur
eEvent& gestureEvent) | |
2436 { | |
2437 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | |
2438 | |
2439 // Negate the deltas since the gesture event stores finger movement and | |
2440 // scrolling occurs in the direction opposite the finger's movement | |
2441 // direction. e.g. Finger moving up has negative event delta but causes the | |
2442 // page to scroll down causing positive scroll delta. | |
2443 FloatSize delta(-gestureEvent.deltaX(), -gestureEvent.deltaY()); | |
2444 FloatSize velocity(-gestureEvent.velocityX(), -gestureEvent.velocityY()); | |
2445 if (delta.isZero()) | |
2446 return WebInputEventResult::NotHandled; | |
2447 | |
2448 ScrollGranularity granularity = gestureEvent.deltaUnits(); | |
2449 Node* node = m_scrollGestureHandlingNode.get(); | |
2450 | |
2451 // Scroll customization is only available for touch. | |
2452 bool handleScrollCustomization = RuntimeEnabledFeatures::scrollCustomization
Enabled() && gestureEvent.source() == PlatformGestureSourceTouchscreen; | |
2453 if (node) { | |
2454 LayoutObject* layoutObject = node->layoutObject(); | |
2455 if (!layoutObject) | |
2456 return WebInputEventResult::NotHandled; | |
2457 | |
2458 // Try to send the event to the correct view. | |
2459 WebInputEventResult result = passScrollGestureEventToWidget(gestureEvent
, layoutObject); | |
2460 if (result != WebInputEventResult::NotHandled) { | |
2461 if (gestureEvent.preventPropagation() | |
2462 && !RuntimeEnabledFeatures::scrollCustomizationEnabled()) { | |
2463 // This is an optimization which doesn't apply with | |
2464 // scroll customization enabled. | |
2465 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; | |
2466 } | |
2467 // FIXME: we should allow simultaneous scrolling of nested | |
2468 // iframes along perpendicular axes. See crbug.com/466991. | |
2469 m_deltaConsumedForScrollSequence = true; | |
2470 return result; | |
2471 } | |
2472 | |
2473 if (handleScrollCustomization) { | |
2474 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa
ta()); | |
2475 scrollStateData->delta_x = delta.width(); | |
2476 scrollStateData->delta_y = delta.height(); | |
2477 scrollStateData->delta_granularity = ScrollByPrecisePixel; | |
2478 scrollStateData->velocity_x = velocity.width(); | |
2479 scrollStateData->velocity_y = velocity.height(); | |
2480 scrollStateData->should_propagate = !gestureEvent.preventPropagation
(); | |
2481 scrollStateData->is_in_inertial_phase = gestureEvent.inertialPhase()
== ScrollInertialPhaseMomentum; | |
2482 scrollStateData->from_user_input = true; | |
2483 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume
dForScrollSequence; | |
2484 ScrollState* scrollState = ScrollState::create(std::move(scrollState
Data)); | |
2485 if (m_previousGestureScrolledNode) { | |
2486 // The ScrollState needs to know what the current | |
2487 // native scrolling element is, so that for an | |
2488 // inertial scroll that shouldn't propagate, only the | |
2489 // currently scrolling element responds. | |
2490 ASSERT(m_previousGestureScrolledNode->isElementNode()); | |
2491 scrollState->setCurrentNativeScrollingElement(toElement(m_previo
usGestureScrolledNode.get())); | |
2492 } | |
2493 customizedScroll(*node, *scrollState); | |
2494 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE
lement(); | |
2495 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro
llSequence(); | |
2496 if (scrollState->deltaX() != delta.width() | |
2497 || scrollState->deltaY() != delta.height()) { | |
2498 setFrameWasScrolledByUser(); | |
2499 return WebInputEventResult::HandledSystem; | |
2500 } | |
2501 } else { | |
2502 Node* stopNode = nullptr; | |
2503 if (gestureEvent.preventPropagation()) | |
2504 stopNode = m_previousGestureScrolledNode.get(); | |
2505 | |
2506 bool consumed = false; | |
2507 ScrollResult result = physicalScroll( | |
2508 granularity, | |
2509 delta, | |
2510 FloatPoint(gestureEvent.position()), | |
2511 velocity, | |
2512 node, | |
2513 &stopNode, | |
2514 &consumed); | |
2515 | |
2516 if (gestureEvent.preventPropagation()) | |
2517 m_previousGestureScrolledNode = stopNode; | |
2518 | |
2519 if ((!stopNode || !isRootScroller(*stopNode)) && frameHost()) { | |
2520 frameHost()->overscrollController().resetAccumulated( | |
2521 result.didScrollX, result.didScrollY); | |
2522 } | |
2523 | |
2524 if (consumed) | |
2525 return WebInputEventResult::HandledSystem; | |
2526 } | |
2527 } | |
2528 | |
2529 return WebInputEventResult::NotHandled; | |
2530 } | |
2531 | |
2532 void EventHandler::clearGestureScrollState() | |
2533 { | |
2534 m_scrollGestureHandlingNode = nullptr; | |
2535 m_previousGestureScrolledNode = nullptr; | |
2536 m_deltaConsumedForScrollSequence = false; | |
2537 m_currentScrollChain.clear(); | |
2538 | |
2539 if (FrameHost* host = frameHost()) { | |
2540 bool resetX = true; | |
2541 bool resetY = true; | |
2542 host->overscrollController().resetAccumulated(resetX, resetY); | |
2543 } | |
2544 } | 2006 } |
2545 | 2007 |
2546 bool EventHandler::isScrollbarHandlingGestures() const | 2008 bool EventHandler::isScrollbarHandlingGestures() const |
2547 { | 2009 { |
2548 return m_scrollbarHandlingScrollGesture.get(); | 2010 return m_scrollManager.isScrollbarHandlingGestures(); |
2549 } | 2011 } |
2550 | 2012 |
2551 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const | 2013 bool EventHandler::shouldApplyTouchAdjustment(const PlatformGestureEvent& event)
const |
2552 { | 2014 { |
2553 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) | 2015 if (m_frame->settings() && !m_frame->settings()->touchAdjustmentEnabled()) |
2554 return false; | 2016 return false; |
2555 return !event.area().isEmpty(); | 2017 return !event.area().isEmpty(); |
2556 } | 2018 } |
2557 | 2019 |
2558 bool EventHandler::bestClickableNodeForHitTestResult(const HitTestResult& result
, IntPoint& targetPoint, Node*& targetNode) | 2020 bool EventHandler::bestClickableNodeForHitTestResult(const HitTestResult& result
, IntPoint& targetPoint, Node*& targetNode) |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3077 return m_frame->page()->isCursorVisible(); | 2539 return m_frame->page()->isCursorVisible(); |
3078 } | 2540 } |
3079 | 2541 |
3080 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) | 2542 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) |
3081 { | 2543 { |
3082 m_frameSetBeingResized = frameSet; | 2544 m_frameSetBeingResized = frameSet; |
3083 } | 2545 } |
3084 | 2546 |
3085 void EventHandler::resizeScrollableAreaDestroyed() | 2547 void EventHandler::resizeScrollableAreaDestroyed() |
3086 { | 2548 { |
3087 ASSERT(m_resizeScrollableArea); | 2549 m_scrollManager.clearResizeScrollableArea(true); |
3088 m_resizeScrollableArea = nullptr; | |
3089 } | 2550 } |
3090 | 2551 |
3091 void EventHandler::hoverTimerFired(Timer<EventHandler>*) | 2552 void EventHandler::hoverTimerFired(Timer<EventHandler>*) |
3092 { | 2553 { |
3093 TRACE_EVENT0("input", "EventHandler::hoverTimerFired"); | 2554 TRACE_EVENT0("input", "EventHandler::hoverTimerFired"); |
3094 m_hoverTimer.stop(); | 2555 m_hoverTimer.stop(); |
3095 | 2556 |
3096 ASSERT(m_frame); | 2557 ASSERT(m_frame); |
3097 ASSERT(m_frame->document()); | 2558 ASSERT(m_frame->document()); |
3098 | 2559 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3148 } | 2609 } |
3149 | 2610 |
3150 WebInputEventResult EventHandler::keyEvent(const PlatformKeyboardEvent& initialK
eyEvent) | 2611 WebInputEventResult EventHandler::keyEvent(const PlatformKeyboardEvent& initialK
eyEvent) |
3151 { | 2612 { |
3152 m_frame->chromeClient().clearToolTip(); | 2613 m_frame->chromeClient().clearToolTip(); |
3153 | 2614 |
3154 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) | 2615 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) |
3155 capsLockStateMayHaveChanged(); | 2616 capsLockStateMayHaveChanged(); |
3156 | 2617 |
3157 #if OS(WIN) | 2618 #if OS(WIN) |
3158 if (panScrollInProgress()) { | 2619 if (m_scrollManager.panScrollInProgress()) { |
3159 // If a key is pressed while the panScroll is in progress then we want t
o stop | 2620 // If a key is pressed while the panScroll is in progress then we want t
o stop |
3160 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent.
type() == PlatformEvent::RawKeyDown) | 2621 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent.
type() == PlatformEvent::RawKeyDown) |
3161 stopAutoscroll(); | 2622 m_scrollManager.stopAutoscroll(); |
3162 | 2623 |
3163 // If we were in panscroll mode, we swallow the key event | 2624 // If we were in panscroll mode, we swallow the key event |
3164 return WebInputEventResult::HandledSuppressed; | 2625 return WebInputEventResult::HandledSuppressed; |
3165 } | 2626 } |
3166 #endif | 2627 #endif |
3167 | 2628 |
3168 // Check for cases where we are too early for events -- possible unmatched k
ey up | 2629 // Check for cases where we are too early for events -- possible unmatched k
ey up |
3169 // from pressing return in the location bar. | 2630 // from pressing return in the location bar. |
3170 Node* node = eventTargetNodeForDocument(m_frame->document()); | 2631 Node* node = eventTargetNodeForDocument(m_frame->document()); |
3171 if (!node) | 2632 if (!node) |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3478 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) | 2939 void EventHandler::defaultSpaceEventHandler(KeyboardEvent* event) |
3479 { | 2940 { |
3480 ASSERT(event->type() == EventTypeNames::keypress); | 2941 ASSERT(event->type() == EventTypeNames::keypress); |
3481 | 2942 |
3482 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 2943 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
3483 return; | 2944 return; |
3484 | 2945 |
3485 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward
: ScrollBlockDirectionForward; | 2946 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward
: ScrollBlockDirectionForward; |
3486 | 2947 |
3487 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 2948 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
3488 if (logicalScroll(direction, ScrollByPage)) { | 2949 if (m_scrollManager.logicalScroll(direction, ScrollByPage, nullptr, m_mouseP
ressNode)) { |
3489 event->setDefaultHandled(); | 2950 event->setDefaultHandled(); |
3490 return; | 2951 return; |
3491 } | 2952 } |
3492 } | 2953 } |
3493 | 2954 |
3494 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) | 2955 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) |
3495 { | 2956 { |
3496 ASSERT(event->type() == EventTypeNames::keydown); | 2957 ASSERT(event->type() == EventTypeNames::keydown); |
3497 | 2958 |
3498 if (!RuntimeEnabledFeatures::backspaceDefaultHandlerEnabled()) | 2959 if (!RuntimeEnabledFeatures::backspaceDefaultHandlerEnabled()) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3574 void EventHandler::capsLockStateMayHaveChanged() | 3035 void EventHandler::capsLockStateMayHaveChanged() |
3575 { | 3036 { |
3576 if (Element* element = m_frame->document()->focusedElement()) { | 3037 if (Element* element = m_frame->document()->focusedElement()) { |
3577 if (LayoutObject* r = element->layoutObject()) { | 3038 if (LayoutObject* r = element->layoutObject()) { |
3578 if (r->isTextField()) | 3039 if (r->isTextField()) |
3579 toLayoutTextControlSingleLine(r)->capsLockStateMayHaveChanged(); | 3040 toLayoutTextControlSingleLine(r)->capsLockStateMayHaveChanged(); |
3580 } | 3041 } |
3581 } | 3042 } |
3582 } | 3043 } |
3583 | 3044 |
3584 void EventHandler::setFrameWasScrolledByUser() | |
3585 { | |
3586 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) | |
3587 documentLoader->initialScrollState().wasScrolledByUser = true; | |
3588 } | |
3589 | |
3590 bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults&
mev) | 3045 bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults&
mev) |
3591 { | 3046 { |
3592 Scrollbar* scrollbar = mev.scrollbar(); | 3047 Scrollbar* scrollbar = mev.scrollbar(); |
3593 updateLastScrollbarUnderMouse(scrollbar, true); | 3048 updateLastScrollbarUnderMouse(scrollbar, true); |
3594 | 3049 |
3595 if (!scrollbar || !scrollbar->enabled()) | 3050 if (!scrollbar || !scrollbar->enabled()) |
3596 return false; | 3051 return false; |
3597 setFrameWasScrolledByUser(); | 3052 m_scrollManager.setFrameWasScrolledByUser(); |
3598 scrollbar->mouseDown(mev.event()); | 3053 scrollbar->mouseDown(mev.event()); |
3599 return true; | 3054 return true; |
3600 } | 3055 } |
3601 | 3056 |
3602 // If scrollbar (under mouse) is different from last, send a mouse exited. Set | 3057 // If scrollbar (under mouse) is different from last, send a mouse exited. Set |
3603 // last to scrollbar if setLast is true; else set last to 0. | 3058 // last to scrollbar if setLast is true; else set last to 0. |
3604 void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL
ast) | 3059 void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL
ast) |
3605 { | 3060 { |
3606 if (m_lastScrollbarUnderMouse != scrollbar) { | 3061 if (m_lastScrollbarUnderMouse != scrollbar) { |
3607 // Send mouse exited to the old scrollbar. | 3062 // Send mouse exited to the old scrollbar. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3696 | 3151 |
3697 FrameHost* EventHandler::frameHost() const | 3152 FrameHost* EventHandler::frameHost() const |
3698 { | 3153 { |
3699 if (!m_frame->page()) | 3154 if (!m_frame->page()) |
3700 return nullptr; | 3155 return nullptr; |
3701 | 3156 |
3702 return &m_frame->page()->frameHost(); | 3157 return &m_frame->page()->frameHost(); |
3703 } | 3158 } |
3704 | 3159 |
3705 } // namespace blink | 3160 } // namespace blink |
OLD | NEW |