| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 void setPausedInDebuggerMessage(const String*) override { } | 102 void setPausedInDebuggerMessage(const String*) override { } |
| 103 void setInspectModeEnabled(bool) override { } | 103 void setInspectModeEnabled(bool) override { } |
| 104 void hideHighlight() override { } | 104 void hideHighlight() override { } |
| 105 void highlightNode(Node*, Node* eventTarget, const InspectorHighlightConfig&
, bool omitTooltip) override { } | 105 void highlightNode(Node*, Node* eventTarget, const InspectorHighlightConfig&
, bool omitTooltip) override { } |
| 106 void highlightQuad(PassOwnPtr<FloatQuad>, const InspectorHighlightConfig&) o
verride { } | 106 void highlightQuad(PassOwnPtr<FloatQuad>, const InspectorHighlightConfig&) o
verride { } |
| 107 void showAndHideViewSize(bool showGrid) override { } | 107 void showAndHideViewSize(bool showGrid) override { } |
| 108 void setListener(InspectorOverlay::Listener* listener) override { } | 108 void setListener(InspectorOverlay::Listener* listener) override { } |
| 109 void suspendUpdates() override { } | 109 void suspendUpdates() override { } |
| 110 void resumeUpdates() override { } | 110 void resumeUpdates() override { } |
| 111 void clear() override { } | 111 void clear() override { } |
| 112 void setLayoutEditor(PassOwnPtrWillBeRawPtr<LayoutEditor>) override { } |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 DEFINE_TRACE(InspectorOverlayStub) | 115 DEFINE_TRACE(InspectorOverlayStub) |
| 115 { | 116 { |
| 116 InspectorOverlay::trace(visitor); | 117 InspectorOverlay::trace(visitor); |
| 117 } | 118 } |
| 118 | 119 |
| 119 } // anonymous namespace | 120 } // anonymous namespace |
| 120 | 121 |
| 121 // static | 122 // static |
| 122 PassOwnPtrWillBeRawPtr<InspectorOverlay> InspectorOverlayImpl::createEmpty() | 123 PassOwnPtrWillBeRawPtr<InspectorOverlay> InspectorOverlayImpl::createEmpty() |
| 123 { | 124 { |
| 124 return adoptPtrWillBeNoop(new InspectorOverlayStub()); | 125 return adoptPtrWillBeNoop(new InspectorOverlayStub()); |
| 125 } | 126 } |
| 126 | 127 |
| 127 InspectorOverlayImpl::InspectorOverlayImpl(WebViewImpl* webViewImpl) | 128 InspectorOverlayImpl::InspectorOverlayImpl(WebViewImpl* webViewImpl) |
| 128 : m_webViewImpl(webViewImpl) | 129 : m_webViewImpl(webViewImpl) |
| 129 , m_inspectModeEnabled(false) | 130 , m_inspectModeEnabled(false) |
| 130 , m_overlayHost(InspectorOverlayHost::create()) | 131 , m_overlayHost(InspectorOverlayHost::create()) |
| 131 , m_drawViewSize(false) | 132 , m_drawViewSize(false) |
| 132 , m_drawViewSizeWithGrid(false) | 133 , m_drawViewSizeWithGrid(false) |
| 133 , m_omitTooltip(false) | 134 , m_omitTooltip(false) |
| 134 , m_timer(this, &InspectorOverlayImpl::onTimer) | 135 , m_timer(this, &InspectorOverlayImpl::onTimer) |
| 135 , m_suspendCount(0) | 136 , m_suspendCount(0) |
| 136 , m_updating(false) | 137 , m_updating(false) |
| 137 { | 138 { |
| 138 m_overlayHost->setListener(this); | 139 m_overlayHost->setDebuggerListener(this); |
| 139 } | 140 } |
| 140 | 141 |
| 141 InspectorOverlayImpl::~InspectorOverlayImpl() | 142 InspectorOverlayImpl::~InspectorOverlayImpl() |
| 142 { | 143 { |
| 143 ASSERT(!m_overlayPage); | 144 ASSERT(!m_overlayPage); |
| 144 } | 145 } |
| 145 | 146 |
| 146 DEFINE_TRACE(InspectorOverlayImpl) | 147 DEFINE_TRACE(InspectorOverlayImpl) |
| 147 { | 148 { |
| 148 visitor->trace(m_highlightNode); | 149 visitor->trace(m_highlightNode); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 170 // Don't invalidate during an update, because that will lead to Document::sc
heduleLayoutTreeUpdate | 171 // Don't invalidate during an update, because that will lead to Document::sc
heduleLayoutTreeUpdate |
| 171 // being called within Document::updateLayoutTree which violates document li
fecycle expectations. | 172 // being called within Document::updateLayoutTree which violates document li
fecycle expectations. |
| 172 if (m_updating) | 173 if (m_updating) |
| 173 return; | 174 return; |
| 174 | 175 |
| 175 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight); | 176 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight); |
| 176 } | 177 } |
| 177 | 178 |
| 178 bool InspectorOverlayImpl::handleInputEvent(const WebInputEvent& inputEvent) | 179 bool InspectorOverlayImpl::handleInputEvent(const WebInputEvent& inputEvent) |
| 179 { | 180 { |
| 181 bool handled = false; |
| 180 if (isEmpty()) | 182 if (isEmpty()) |
| 181 return false; | 183 return handled; |
| 182 | 184 |
| 183 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type ==
WebInputEvent::GestureTap) { | 185 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type ==
WebInputEvent::GestureTap) { |
| 184 // Only let GestureTab in (we only need it and we know PlatformGestureEv
entBuilder supports it). | 186 // Only let GestureTab in (we only need it and we know PlatformGestureEv
entBuilder supports it). |
| 185 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webVie
wImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEv
ent)); | 187 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webVie
wImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEv
ent)); |
| 186 overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent); | 188 overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent); |
| 187 } | 189 } |
| 188 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W
ebInputEvent::MouseEnter) { | 190 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W
ebInputEvent::MouseEnter) { |
| 189 // PlatformMouseEventBuilder does not work with MouseEnter type, so we f
ilter it out manually. | 191 // PlatformMouseEventBuilder does not work with MouseEnter type, so we f
ilter it out manually. |
| 190 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent)); | 192 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent)); |
| 191 if (mouseEvent.type() == PlatformEvent::MouseMoved) | 193 if (mouseEvent.type() == PlatformEvent::MouseMoved) |
| 192 overlayMainFrame()->eventHandler().handleMouseMoveEvent(mouseEvent); | 194 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent(mo
useEvent); |
| 193 if (mouseEvent.type() == PlatformEvent::MousePressed) | 195 if (mouseEvent.type() == PlatformEvent::MousePressed) |
| 194 overlayMainFrame()->eventHandler().handleMousePressEvent(mouseEvent)
; | 196 handled = overlayMainFrame()->eventHandler().handleMousePressEvent(m
ouseEvent); |
| 195 if (mouseEvent.type() == PlatformEvent::MouseReleased) | 197 if (mouseEvent.type() == PlatformEvent::MouseReleased) |
| 196 overlayMainFrame()->eventHandler().handleMouseReleaseEvent(mouseEven
t); | 198 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent
(mouseEvent); |
| 197 } | 199 } |
| 198 if (WebInputEvent::isTouchEventType(inputEvent.type)) { | 200 if (WebInputEvent::isTouchEventType(inputEvent.type)) { |
| 199 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent)); | 201 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent)); |
| 200 overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent); | 202 overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent); |
| 201 } | 203 } |
| 202 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { | 204 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { |
| 203 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(stati
c_cast<const WebKeyboardEvent&>(inputEvent)); | 205 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(stati
c_cast<const WebKeyboardEvent&>(inputEvent)); |
| 204 overlayMainFrame()->eventHandler().keyEvent(keyboardEvent); | 206 overlayMainFrame()->eventHandler().keyEvent(keyboardEvent); |
| 205 } | 207 } |
| 206 | 208 |
| 207 // Overlay should not consume events. | 209 return handled; |
| 208 return false; | |
| 209 } | 210 } |
| 210 | 211 |
| 211 void InspectorOverlayImpl::setPausedInDebuggerMessage(const String* message) | 212 void InspectorOverlayImpl::setPausedInDebuggerMessage(const String* message) |
| 212 { | 213 { |
| 213 m_pausedInDebuggerMessage = message ? *message : String(); | 214 m_pausedInDebuggerMessage = message ? *message : String(); |
| 214 update(); | 215 update(); |
| 215 } | 216 } |
| 216 | 217 |
| 217 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled) | 218 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled) |
| 218 { | 219 { |
| 219 m_inspectModeEnabled = enabled; | 220 m_inspectModeEnabled = enabled; |
| 220 update(); | 221 update(); |
| 221 } | 222 } |
| 222 | 223 |
| 223 void InspectorOverlayImpl::hideHighlight() | 224 void InspectorOverlayImpl::hideHighlight() |
| 224 { | 225 { |
| 226 if (m_layoutEditor) |
| 227 m_layoutEditor->setNode(nullptr); |
| 225 m_highlightNode.clear(); | 228 m_highlightNode.clear(); |
| 226 m_eventTargetNode.clear(); | 229 m_eventTargetNode.clear(); |
| 227 m_highlightQuad.clear(); | 230 m_highlightQuad.clear(); |
| 228 m_layoutEditor.clear(); | |
| 229 update(); | 231 update(); |
| 230 } | 232 } |
| 231 | 233 |
| 232 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In
spectorHighlightConfig& highlightConfig, bool omitTooltip) | 234 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In
spectorHighlightConfig& highlightConfig, bool omitTooltip) |
| 233 { | 235 { |
| 234 m_nodeHighlightConfig = highlightConfig; | 236 m_nodeHighlightConfig = highlightConfig; |
| 235 m_highlightNode = node; | 237 m_highlightNode = node; |
| 236 if (highlightConfig.showLayoutEditor) | 238 if (m_layoutEditor && highlightConfig.showLayoutEditor) |
| 237 m_layoutEditor = LayoutEditor::create(node); | 239 m_layoutEditor->setNode(node); |
| 238 m_eventTargetNode = eventTarget; | 240 m_eventTargetNode = eventTarget; |
| 239 m_omitTooltip = omitTooltip; | 241 m_omitTooltip = omitTooltip; |
| 240 update(); | 242 update(); |
| 241 } | 243 } |
| 242 | 244 |
| 243 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe
ctorHighlightConfig& highlightConfig) | 245 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe
ctorHighlightConfig& highlightConfig) |
| 244 { | 246 { |
| 245 m_quadHighlightConfig = highlightConfig; | 247 m_quadHighlightConfig = highlightConfig; |
| 246 m_highlightQuad = quad; | 248 m_highlightQuad = quad; |
| 247 m_omitTooltip = false; | 249 m_omitTooltip = false; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 { | 479 { |
| 478 if (!m_suspendCount++) | 480 if (!m_suspendCount++) |
| 479 clear(); | 481 clear(); |
| 480 } | 482 } |
| 481 | 483 |
| 482 void InspectorOverlayImpl::resumeUpdates() | 484 void InspectorOverlayImpl::resumeUpdates() |
| 483 { | 485 { |
| 484 --m_suspendCount; | 486 --m_suspendCount; |
| 485 } | 487 } |
| 486 | 488 |
| 489 void InspectorOverlayImpl::setLayoutEditor(PassOwnPtrWillBeRawPtr<LayoutEditor>
layoutEditor) |
| 490 { |
| 491 m_layoutEditor = layoutEditor; |
| 492 m_overlayHost->setLayoutEditorListener(m_layoutEditor.get()); |
| 493 } |
| 494 |
| 495 |
| 487 } // namespace blink | 496 } // namespace blink |
| OLD | NEW |