| 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 LayoutEditor* layoutEditor() { return nullptr; } |
| 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) |
| 138 , m_layoutEditor(LayoutEditor::create()) |
| 137 { | 139 { |
| 138 m_overlayHost->setListener(this); | 140 m_overlayHost->setListener(this); |
| 141 m_overlayHost->setLayoutEditorListener(m_layoutEditor.get()); |
| 139 } | 142 } |
| 140 | 143 |
| 141 InspectorOverlayImpl::~InspectorOverlayImpl() | 144 InspectorOverlayImpl::~InspectorOverlayImpl() |
| 142 { | 145 { |
| 143 ASSERT(!m_overlayPage); | 146 ASSERT(!m_overlayPage); |
| 144 } | 147 } |
| 145 | 148 |
| 146 DEFINE_TRACE(InspectorOverlayImpl) | 149 DEFINE_TRACE(InspectorOverlayImpl) |
| 147 { | 150 { |
| 148 visitor->trace(m_highlightNode); | 151 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 | 173 // 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. | 174 // being called within Document::updateLayoutTree which violates document li
fecycle expectations. |
| 172 if (m_updating) | 175 if (m_updating) |
| 173 return; | 176 return; |
| 174 | 177 |
| 175 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight); | 178 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight); |
| 176 } | 179 } |
| 177 | 180 |
| 178 bool InspectorOverlayImpl::handleInputEvent(const WebInputEvent& inputEvent) | 181 bool InspectorOverlayImpl::handleInputEvent(const WebInputEvent& inputEvent) |
| 179 { | 182 { |
| 183 bool handled = false; |
| 180 if (isEmpty()) | 184 if (isEmpty()) |
| 181 return false; | 185 return handled; |
| 182 | 186 |
| 183 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type ==
WebInputEvent::GestureTap) { | 187 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). | 188 // 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)); | 189 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webVie
wImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEv
ent)); |
| 186 overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent); | 190 overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent); |
| 187 } | 191 } |
| 188 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W
ebInputEvent::MouseEnter) { | 192 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. | 193 // 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)); | 194 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent)); |
| 191 if (mouseEvent.type() == PlatformEvent::MouseMoved) | 195 if (mouseEvent.type() == PlatformEvent::MouseMoved) |
| 192 overlayMainFrame()->eventHandler().handleMouseMoveEvent(mouseEvent); | 196 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent(mo
useEvent); |
| 193 if (mouseEvent.type() == PlatformEvent::MousePressed) | 197 if (mouseEvent.type() == PlatformEvent::MousePressed) |
| 194 overlayMainFrame()->eventHandler().handleMousePressEvent(mouseEvent)
; | 198 handled = overlayMainFrame()->eventHandler().handleMousePressEvent(m
ouseEvent); |
| 195 if (mouseEvent.type() == PlatformEvent::MouseReleased) | 199 if (mouseEvent.type() == PlatformEvent::MouseReleased) |
| 196 overlayMainFrame()->eventHandler().handleMouseReleaseEvent(mouseEven
t); | 200 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent
(mouseEvent); |
| 197 } | 201 } |
| 198 if (WebInputEvent::isTouchEventType(inputEvent.type)) { | 202 if (WebInputEvent::isTouchEventType(inputEvent.type)) { |
| 199 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent)); | 203 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent)); |
| 200 overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent); | 204 overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent); |
| 201 } | 205 } |
| 202 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { | 206 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { |
| 203 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(stati
c_cast<const WebKeyboardEvent&>(inputEvent)); | 207 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(stati
c_cast<const WebKeyboardEvent&>(inputEvent)); |
| 204 overlayMainFrame()->eventHandler().keyEvent(keyboardEvent); | 208 overlayMainFrame()->eventHandler().keyEvent(keyboardEvent); |
| 205 } | 209 } |
| 206 | 210 |
| 207 // Overlay should not consume events. | 211 return handled; |
| 208 return false; | |
| 209 } | 212 } |
| 210 | 213 |
| 211 void InspectorOverlayImpl::setPausedInDebuggerMessage(const String* message) | 214 void InspectorOverlayImpl::setPausedInDebuggerMessage(const String* message) |
| 212 { | 215 { |
| 213 m_pausedInDebuggerMessage = message ? *message : String(); | 216 m_pausedInDebuggerMessage = message ? *message : String(); |
| 214 update(); | 217 update(); |
| 215 } | 218 } |
| 216 | 219 |
| 217 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled) | 220 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled) |
| 218 { | 221 { |
| 219 m_inspectModeEnabled = enabled; | 222 m_inspectModeEnabled = enabled; |
| 220 update(); | 223 update(); |
| 221 } | 224 } |
| 222 | 225 |
| 223 void InspectorOverlayImpl::hideHighlight() | 226 void InspectorOverlayImpl::hideHighlight() |
| 224 { | 227 { |
| 228 m_layoutEditor->setNode(nullptr); |
| 225 m_highlightNode.clear(); | 229 m_highlightNode.clear(); |
| 226 m_eventTargetNode.clear(); | 230 m_eventTargetNode.clear(); |
| 227 m_highlightQuad.clear(); | 231 m_highlightQuad.clear(); |
| 228 m_layoutEditor.clear(); | |
| 229 update(); | 232 update(); |
| 230 } | 233 } |
| 231 | 234 |
| 232 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In
spectorHighlightConfig& highlightConfig, bool omitTooltip) | 235 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In
spectorHighlightConfig& highlightConfig, bool omitTooltip) |
| 233 { | 236 { |
| 234 m_nodeHighlightConfig = highlightConfig; | 237 m_nodeHighlightConfig = highlightConfig; |
| 235 m_highlightNode = node; | 238 m_highlightNode = node; |
| 236 if (highlightConfig.showLayoutEditor) | 239 if (highlightConfig.showLayoutEditor) |
| 237 m_layoutEditor = LayoutEditor::create(node); | 240 m_layoutEditor->setNode(node); |
| 238 m_eventTargetNode = eventTarget; | 241 m_eventTargetNode = eventTarget; |
| 239 m_omitTooltip = omitTooltip; | 242 m_omitTooltip = omitTooltip; |
| 240 update(); | 243 update(); |
| 241 } | 244 } |
| 242 | 245 |
| 243 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe
ctorHighlightConfig& highlightConfig) | 246 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe
ctorHighlightConfig& highlightConfig) |
| 244 { | 247 { |
| 245 m_quadHighlightConfig = highlightConfig; | 248 m_quadHighlightConfig = highlightConfig; |
| 246 m_highlightQuad = quad; | 249 m_highlightQuad = quad; |
| 247 m_omitTooltip = false; | 250 m_omitTooltip = false; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 if (!m_suspendCount++) | 481 if (!m_suspendCount++) |
| 479 clear(); | 482 clear(); |
| 480 } | 483 } |
| 481 | 484 |
| 482 void InspectorOverlayImpl::resumeUpdates() | 485 void InspectorOverlayImpl::resumeUpdates() |
| 483 { | 486 { |
| 484 --m_suspendCount; | 487 --m_suspendCount; |
| 485 } | 488 } |
| 486 | 489 |
| 487 } // namespace blink | 490 } // namespace blink |
| OLD | NEW |