OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 Node* hoveredNodeForEvent(LocalFrame* frame, | 83 Node* hoveredNodeForEvent(LocalFrame* frame, |
84 const WebGestureEvent& event, | 84 const WebGestureEvent& event, |
85 bool ignorePointerEventsNone) { | 85 bool ignorePointerEventsNone) { |
86 return hoveredNodeForPoint(frame, | 86 return hoveredNodeForPoint(frame, |
87 roundedIntPoint(event.positionInRootFrame()), | 87 roundedIntPoint(event.positionInRootFrame()), |
88 ignorePointerEventsNone); | 88 ignorePointerEventsNone); |
89 } | 89 } |
90 | 90 |
91 Node* hoveredNodeForEvent(LocalFrame* frame, | 91 Node* hoveredNodeForEvent(LocalFrame* frame, |
92 const PlatformMouseEvent& event, | 92 const WebMouseEvent& event, |
93 bool ignorePointerEventsNone) { | 93 bool ignorePointerEventsNone) { |
94 return hoveredNodeForPoint(frame, event.position(), ignorePointerEventsNone); | 94 return hoveredNodeForPoint(frame, |
| 95 roundedIntPoint(event.positionInRootFrame()), |
| 96 ignorePointerEventsNone); |
95 } | 97 } |
96 | 98 |
97 Node* hoveredNodeForEvent(LocalFrame* frame, | 99 Node* hoveredNodeForEvent(LocalFrame* frame, |
98 const WebTouchEvent& event, | 100 const WebTouchEvent& event, |
99 bool ignorePointerEventsNone) { | 101 bool ignorePointerEventsNone) { |
100 if (!event.touchesLength) | 102 if (!event.touchesLength) |
101 return nullptr; | 103 return nullptr; |
102 WebTouchPoint transformedPoint = event.touchPointInRootFrame(0); | 104 WebTouchPoint transformedPoint = event.touchPointInRootFrame(0); |
103 return hoveredNodeForPoint(frame, roundedIntPoint(transformedPoint.position), | 105 return hoveredNodeForPoint(frame, roundedIntPoint(transformedPoint.position), |
104 ignorePointerEventsNone); | 106 ignorePointerEventsNone); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // We only have a use for gesture tap. | 240 // We only have a use for gesture tap. |
239 WebGestureEvent transformedEvent = TransformWebGestureEvent( | 241 WebGestureEvent transformedEvent = TransformWebGestureEvent( |
240 m_frameImpl->frameView(), | 242 m_frameImpl->frameView(), |
241 static_cast<const WebGestureEvent&>(inputEvent)); | 243 static_cast<const WebGestureEvent&>(inputEvent)); |
242 handled = handleGestureEvent(transformedEvent); | 244 handled = handleGestureEvent(transformedEvent); |
243 if (handled) | 245 if (handled) |
244 return true; | 246 return true; |
245 | 247 |
246 overlayMainFrame()->eventHandler().handleGestureEvent(transformedEvent); | 248 overlayMainFrame()->eventHandler().handleGestureEvent(transformedEvent); |
247 } | 249 } |
248 if (WebInputEvent::isMouseEventType(inputEvent.type()) && | 250 if (WebInputEvent::isMouseEventType(inputEvent.type())) { |
249 inputEvent.type() != WebInputEvent::MouseEnter) { | 251 WebMouseEvent mouseEvent = |
250 // PlatformMouseEventBuilder does not work with MouseEnter type, so we | 252 TransformWebMouseEvent(m_frameImpl->frameView(), |
251 // filter it out manually. | 253 static_cast<const WebMouseEvent&>(inputEvent)); |
252 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder( | |
253 m_frameImpl->frameView(), | |
254 static_cast<const WebMouseEvent&>(inputEvent)); | |
255 | 254 |
256 if (mouseEvent.type() == PlatformEvent::MouseMoved) | 255 if (mouseEvent.type() == WebInputEvent::MouseMove) |
257 handled = handleMouseMove(mouseEvent); | 256 handled = handleMouseMove(mouseEvent); |
258 else if (mouseEvent.type() == PlatformEvent::MousePressed) | 257 else if (mouseEvent.type() == WebInputEvent::MouseDown) |
259 handled = handleMousePress(); | 258 handled = handleMousePress(); |
260 | 259 |
261 if (handled) | 260 if (handled) |
262 return true; | 261 return true; |
263 | 262 |
264 if (mouseEvent.type() == PlatformEvent::MouseMoved) { | 263 if (mouseEvent.type() == WebInputEvent::MouseMove) { |
265 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent( | 264 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent( |
266 mouseEvent, createPlatformMouseEventVector( | 265 mouseEvent, TransformWebMouseEventVector( |
267 m_frameImpl->frameView(), | 266 m_frameImpl->frameView(), |
268 std::vector<const WebInputEvent*>())) != | 267 std::vector<const WebInputEvent*>())) != |
269 WebInputEventResult::NotHandled; | 268 WebInputEventResult::NotHandled; |
270 } | 269 } |
271 if (mouseEvent.type() == PlatformEvent::MousePressed) | 270 if (mouseEvent.type() == WebInputEvent::MouseDown) |
272 handled = overlayMainFrame()->eventHandler().handleMousePressEvent( | 271 handled = overlayMainFrame()->eventHandler().handleMousePressEvent( |
273 mouseEvent) != WebInputEventResult::NotHandled; | 272 mouseEvent) != WebInputEventResult::NotHandled; |
274 if (mouseEvent.type() == PlatformEvent::MouseReleased) | 273 if (mouseEvent.type() == WebInputEvent::MouseUp) |
275 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent( | 274 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent( |
276 mouseEvent) != WebInputEventResult::NotHandled; | 275 mouseEvent) != WebInputEventResult::NotHandled; |
277 } | 276 } |
278 | 277 |
279 if (WebInputEvent::isTouchEventType(inputEvent.type())) { | 278 if (WebInputEvent::isTouchEventType(inputEvent.type())) { |
280 WebTouchEvent transformedEvent = | 279 WebTouchEvent transformedEvent = |
281 TransformWebTouchEvent(m_frameImpl->frameView(), | 280 TransformWebTouchEvent(m_frameImpl->frameView(), |
282 static_cast<const WebTouchEvent&>(inputEvent)); | 281 static_cast<const WebTouchEvent&>(inputEvent)); |
283 handled = handleTouchEvent(transformedEvent); | 282 handled = handleTouchEvent(transformedEvent); |
284 if (handled) | 283 if (handled) |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 m_resizeTimerActive = true; | 698 m_resizeTimerActive = true; |
700 m_timer.startOneShot(1, BLINK_FROM_HERE); | 699 m_timer.startOneShot(1, BLINK_FROM_HERE); |
701 } | 700 } |
702 scheduleUpdate(); | 701 scheduleUpdate(); |
703 } | 702 } |
704 | 703 |
705 void InspectorOverlay::setShowViewportSizeOnResize(bool show) { | 704 void InspectorOverlay::setShowViewportSizeOnResize(bool show) { |
706 m_drawViewSize = show; | 705 m_drawViewSize = show; |
707 } | 706 } |
708 | 707 |
709 bool InspectorOverlay::handleMouseMove(const PlatformMouseEvent& event) { | 708 bool InspectorOverlay::handleMouseMove(const WebMouseEvent& event) { |
710 if (!shouldSearchForNode()) | 709 if (!shouldSearchForNode()) |
711 return false; | 710 return false; |
712 | 711 |
713 LocalFrame* frame = m_frameImpl->frame(); | 712 LocalFrame* frame = m_frameImpl->frame(); |
714 if (!frame || !frame->view() || frame->contentLayoutItem().isNull()) | 713 if (!frame || !frame->view() || frame->contentLayoutItem().isNull()) |
715 return false; | 714 return false; |
716 Node* node = hoveredNodeForEvent(frame, event, event.shiftKey()); | 715 Node* node = hoveredNodeForEvent(frame, event, |
| 716 event.modifiers() & WebInputEvent::ShiftKey); |
717 | 717 |
718 // Do not highlight within user agent shadow root unless requested. | 718 // Do not highlight within user agent shadow root unless requested. |
719 if (m_inspectMode != InspectorDOMAgent::SearchingForUAShadow) { | 719 if (m_inspectMode != InspectorDOMAgent::SearchingForUAShadow) { |
720 ShadowRoot* shadowRoot = InspectorDOMAgent::userAgentShadowRoot(node); | 720 ShadowRoot* shadowRoot = InspectorDOMAgent::userAgentShadowRoot(node); |
721 if (shadowRoot) | 721 if (shadowRoot) |
722 node = &shadowRoot->host(); | 722 node = &shadowRoot->host(); |
723 } | 723 } |
724 | 724 |
725 // Shadow roots don't have boxes - use host element instead. | 725 // Shadow roots don't have boxes - use host element instead. |
726 if (node && node->isShadowRoot()) | 726 if (node && node->isShadowRoot()) |
727 node = node->parentOrShadowHostNode(); | 727 node = node->parentOrShadowHostNode(); |
728 | 728 |
729 if (!node) | 729 if (!node) |
730 return true; | 730 return true; |
731 | 731 |
732 Node* eventTarget = | 732 Node* eventTarget = (event.modifiers() & WebInputEvent::ShiftKey) |
733 event.shiftKey() ? hoveredNodeForEvent(frame, event, false) : nullptr; | 733 ? hoveredNodeForEvent(frame, event, false) |
| 734 : nullptr; |
734 if (eventTarget == node) | 735 if (eventTarget == node) |
735 eventTarget = nullptr; | 736 eventTarget = nullptr; |
736 | 737 |
737 if (node && m_inspectModeHighlightConfig) { | 738 if (node && m_inspectModeHighlightConfig) { |
738 m_hoveredNodeForInspectMode = node; | 739 m_hoveredNodeForInspectMode = node; |
739 if (m_domAgent) | 740 if (m_domAgent) |
740 m_domAgent->nodeHighlightedInOverlay(node); | 741 m_domAgent->nodeHighlightedInOverlay(node); |
741 highlightNode(node, eventTarget, *m_inspectModeHighlightConfig, | 742 highlightNode(node, eventTarget, *m_inspectModeHighlightConfig, |
742 event.ctrlKey() || event.metaKey()); | 743 (event.modifiers() & |
| 744 (WebInputEvent::ControlKey | WebInputEvent::MetaKey))); |
743 } | 745 } |
744 return true; | 746 return true; |
745 } | 747 } |
746 | 748 |
747 bool InspectorOverlay::handleMousePress() { | 749 bool InspectorOverlay::handleMousePress() { |
748 if (!shouldSearchForNode()) | 750 if (!shouldSearchForNode()) |
749 return false; | 751 return false; |
750 | 752 |
751 if (m_hoveredNodeForInspectMode) { | 753 if (m_hoveredNodeForInspectMode) { |
752 inspect(m_hoveredNodeForInspectMode.get()); | 754 inspect(m_hoveredNodeForInspectMode.get()); |
(...skipping 30 matching lines...) Expand all Loading... |
783 bool InspectorOverlay::shouldSearchForNode() { | 785 bool InspectorOverlay::shouldSearchForNode() { |
784 return m_inspectMode != InspectorDOMAgent::NotSearching; | 786 return m_inspectMode != InspectorDOMAgent::NotSearching; |
785 } | 787 } |
786 | 788 |
787 void InspectorOverlay::inspect(Node* node) { | 789 void InspectorOverlay::inspect(Node* node) { |
788 if (m_domAgent) | 790 if (m_domAgent) |
789 m_domAgent->inspect(node); | 791 m_domAgent->inspect(node); |
790 } | 792 } |
791 | 793 |
792 } // namespace blink | 794 } // namespace blink |
OLD | NEW |