OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/input/GestureManager.h" | 5 #include "core/input/GestureManager.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/editing/SelectionController.h" | 8 #include "core/editing/SelectionController.h" |
9 #include "core/events/GestureEvent.h" | 9 #include "core/events/GestureEvent.h" |
10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), | 180 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), |
181 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse); | 181 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse); |
182 | 182 |
183 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that | 183 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that |
184 // mean for for TEs? What's the right balance here? crbug.com/617255 | 184 // mean for for TEs? What's the right balance here? crbug.com/617255 |
185 WebInputEventResult mouseDownEventResult = WebInputEventResult::HandledSuppr essed; | 185 WebInputEventResult mouseDownEventResult = WebInputEventResult::HandledSuppr essed; |
186 if (!m_suppressMouseEventsFromGestures) { | 186 if (!m_suppressMouseEventsFromGestures) { |
187 mouseDownEventResult = m_frame->eventHandler().dispatchMouseEvent(EventT ypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMo useDown); | 187 mouseDownEventResult = m_frame->eventHandler().dispatchMouseEvent(EventT ypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMo useDown); |
188 m_selectionController->initializeSelectionState(); | 188 m_selectionController->initializeSelectionState(); |
189 if (mouseDownEventResult == WebInputEventResult::NotHandled) | 189 if (mouseDownEventResult == WebInputEventResult::NotHandled) |
190 mouseDownEventResult = m_frame->eventHandler().handleMouseFocus(Mous eEventWithHitTestResults(fakeMouseDown, currentHitTest), InputDeviceCapabilities ::firesTouchEventsSourceCapabilities()); | 190 mouseDownEventResult = m_frame->eventHandler().handleMouseFocus(curr entHitTest, InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); |
191 if (mouseDownEventResult == WebInputEventResult::NotHandled) | 191 if (mouseDownEventResult == WebInputEventResult::NotHandled) |
192 mouseDownEventResult = m_frame->eventHandler().handleMousePressEvent (MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); | 192 mouseDownEventResult = m_frame->eventHandler().handleMousePressEvent (MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); |
193 } | 193 } |
194 | 194 |
195 if (currentHitTest.innerNode()) { | 195 if (currentHitTest.innerNode()) { |
196 DCHECK(gestureEvent.type() == PlatformEvent::GestureTap); | 196 DCHECK(gestureEvent.type() == PlatformEvent::GestureTap); |
197 HitTestResult result = currentHitTest; | 197 HitTestResult result = currentHitTest; |
198 result.setToShadowHostIfInUserAgentShadowRoot(); | 198 result.setToShadowHostIfInUserAgentShadowRoot(); |
199 m_frame->chromeClient().onMouseDown(result.innerNode()); | 199 m_frame->chromeClient().onMouseDown(result.innerNode()); |
200 } | 200 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, / * clickCount */ 0, | 296 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, / * clickCount */ 0, |
297 static_cast<PlatformEvent::Modifiers>(modifiers), | 297 static_cast<PlatformEvent::Modifiers>(modifiers), |
298 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerP roperties::PointerType::Mouse); | 298 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerP roperties::PointerType::Mouse); |
299 m_frame->eventHandler().dispatchMouseEvent( | 299 m_frame->eventHandler().dispatchMouseEvent( |
300 EventTypeNames::mousemove, targetedEvent.hitTestResult().innerNode() , 0, fakeMouseMove); | 300 EventTypeNames::mousemove, targetedEvent.hitTestResult().innerNode() , 0, fakeMouseMove); |
301 } | 301 } |
302 | 302 |
303 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; | 303 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; |
304 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) | 304 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) |
305 eventType = PlatformEvent::MouseReleased; | 305 eventType = PlatformEvent::MouseReleased; |
306 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven t.event().globalPosition(), WebPointerProperties::Button::NoButton, | |
307 eventType, /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(mod ifiers), PlatformMouseEvent::FromTouch, | |
308 WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::M ouse); | |
306 | 309 |
307 // To simulate right-click behavior, we send a right mouse down and then con text menu event. | 310 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { |
308 // TODO(crbug.com/579564): Maybe we should not send mouse down at all | 311 HitTestRequest request(HitTestRequest::Active); |
bokan
2016/08/26 16:55:14
We're doing another hit test here right? Can we no
mustaq
2016/08/26 17:19:03
This is because the mousemove dispatched above can
bokan
2016/08/26 17:31:54
Ah, got it.
| |
309 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven t.event().globalPosition(), WebPointerProperties::Button::Right, eventType, 1, | 312 LayoutPoint documentPoint = m_frame->view()->rootFrameToContents(targete dEvent.event().position()); |
310 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::RightBu ttonDown), | 313 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEven t(request, documentPoint, mouseEvent); |
311 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), WebPo interProperties::PointerType::Mouse); | 314 |
312 if (!m_suppressMouseEventsFromGestures) { | 315 WebInputEventResult eventResult = m_frame->eventHandler().dispatchMouseE vent( |
313 // FIXME: Send HitTestResults to avoid redundant hit tests. | 316 EventTypeNames::mousedown, mev.innerNode(), /* clickCount */ 0, mous eEvent); |
314 m_frame->eventHandler().handleMousePressEvent(mouseEvent); | 317 |
318 if (eventResult == WebInputEventResult::NotHandled) | |
319 eventResult = m_frame->eventHandler().handleMouseFocus(mev.hitTestRe sult(), InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); | |
320 | |
321 if (eventResult == WebInputEventResult::NotHandled) | |
322 m_frame->eventHandler().handleMousePressEvent(mev); | |
Navid Zolghadr
2016/08/29 15:19:50
It seems we have changed the flow quite a bit here
| |
315 } | 323 } |
316 | 324 |
317 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); | 325 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); |
318 // We do not need to send a corresponding mouse release because in case of | |
319 // right-click, the context menu takes capture and consumes all events. | |
320 } | 326 } |
321 | 327 |
322 WebInputEventResult GestureManager::handleGestureShowPress() | 328 WebInputEventResult GestureManager::handleGestureShowPress() |
323 { | 329 { |
324 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); | 330 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); |
325 | 331 |
326 FrameView* view = m_frame->view(); | 332 FrameView* view = m_frame->view(); |
327 if (!view) | 333 if (!view) |
328 return WebInputEventResult::NotHandled; | 334 return WebInputEventResult::NotHandled; |
329 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) | 335 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) |
(...skipping 16 matching lines...) Expand all Loading... | |
346 | 352 |
347 return &m_frame->page()->frameHost(); | 353 return &m_frame->page()->frameHost(); |
348 } | 354 } |
349 | 355 |
350 double GestureManager::getLastShowPressTimestamp() const | 356 double GestureManager::getLastShowPressTimestamp() const |
351 { | 357 { |
352 return m_lastShowPressTimestamp; | 358 return m_lastShowPressTimestamp; |
353 } | 359 } |
354 | 360 |
355 } // namespace blink | 361 } // namespace blink |
OLD | NEW |