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 22 matching lines...) Expand all Loading... | |
33 #include "bindings/core/v8/V8InspectorOverlayHost.h" | 33 #include "bindings/core/v8/V8InspectorOverlayHost.h" |
34 #include "core/dom/Node.h" | 34 #include "core/dom/Node.h" |
35 #include "core/frame/FrameHost.h" | 35 #include "core/frame/FrameHost.h" |
36 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
37 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
38 #include "core/frame/Settings.h" | 38 #include "core/frame/Settings.h" |
39 #include "core/input/EventHandler.h" | 39 #include "core/input/EventHandler.h" |
40 #include "core/inspector/InspectorDebuggerAgent.h" | 40 #include "core/inspector/InspectorDebuggerAgent.h" |
41 #include "core/inspector/InspectorOverlayHost.h" | 41 #include "core/inspector/InspectorOverlayHost.h" |
42 #include "core/inspector/LayoutEditor.h" | 42 #include "core/inspector/LayoutEditor.h" |
43 #include "core/layout/LayoutView.h" | |
43 #include "core/loader/EmptyClients.h" | 44 #include "core/loader/EmptyClients.h" |
44 #include "core/loader/FrameLoadRequest.h" | 45 #include "core/loader/FrameLoadRequest.h" |
45 #include "core/page/ChromeClient.h" | 46 #include "core/page/ChromeClient.h" |
46 #include "core/page/Page.h" | 47 #include "core/page/Page.h" |
47 #include "platform/JSONValues.h" | 48 #include "platform/JSONValues.h" |
48 #include "platform/ScriptForbiddenScope.h" | 49 #include "platform/ScriptForbiddenScope.h" |
49 #include "platform/graphics/GraphicsContext.h" | 50 #include "platform/graphics/GraphicsContext.h" |
50 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
51 #include "public/platform/WebData.h" | 52 #include "public/platform/WebData.h" |
52 #include "web/PageOverlay.h" | 53 #include "web/PageOverlay.h" |
53 #include "web/WebGraphicsContextImpl.h" | 54 #include "web/WebGraphicsContextImpl.h" |
54 #include "web/WebInputEventConversion.h" | 55 #include "web/WebInputEventConversion.h" |
55 #include "web/WebLocalFrameImpl.h" | 56 #include "web/WebLocalFrameImpl.h" |
56 #include "web/WebViewImpl.h" | 57 #include "web/WebViewImpl.h" |
57 #include <v8.h> | 58 #include <v8.h> |
58 | 59 |
59 namespace blink { | 60 namespace blink { |
60 | 61 |
62 namespace { | |
63 | |
64 Node* hoveredNodeForPoint(LocalFrame* frame, const IntPoint& pointInRootFrame, b ool ignorePointerEventsNone) | |
65 { | |
66 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move | HitTestR equest::ReadOnly | HitTestRequest::AllowChildFrameContent; | |
67 if (ignorePointerEventsNone) | |
68 hitType |= HitTestRequest::IgnorePointerEventsNone; | |
69 HitTestRequest request(hitType); | |
70 HitTestResult result(request, frame->view()->rootFrameToContents(pointInRoot Frame)); | |
71 frame->contentLayoutObject()->hitTest(result); | |
72 Node* node = result.innerPossiblyPseudoNode(); | |
73 while (node && node->nodeType() == Node::TEXT_NODE) | |
74 node = node->parentNode(); | |
75 return node; | |
76 } | |
77 | |
78 Node* hoveredNodeForEvent(LocalFrame* frame, const PlatformGestureEvent& event, bool ignorePointerEventsNone) | |
79 { | |
80 return hoveredNodeForPoint(frame, event.position(), ignorePointerEventsNone) ; | |
81 } | |
82 | |
83 Node* hoveredNodeForEvent(LocalFrame* frame, const PlatformMouseEvent& event, bo ol ignorePointerEventsNone) | |
84 { | |
85 return hoveredNodeForPoint(frame, event.position(), ignorePointerEventsNone) ; | |
86 } | |
87 | |
88 Node* hoveredNodeForEvent(LocalFrame* frame, const PlatformTouchEvent& event, bo ol ignorePointerEventsNone) | |
89 { | |
90 const Vector<PlatformTouchPoint>& points = event.touchPoints(); | |
91 if (!points.size()) | |
92 return nullptr; | |
93 return hoveredNodeForPoint(frame, roundedIntPoint(points[0].pos()), ignorePo interEventsNone); | |
94 } | |
95 } // namespace | |
96 | |
61 class InspectorOverlayImpl::InspectorPageOverlayDelegate final : public PageOver lay::Delegate { | 97 class InspectorOverlayImpl::InspectorPageOverlayDelegate final : public PageOver lay::Delegate { |
62 public: | 98 public: |
63 explicit InspectorPageOverlayDelegate(InspectorOverlayImpl& overlay) | 99 explicit InspectorPageOverlayDelegate(InspectorOverlayImpl& overlay) |
64 : m_overlay(&overlay) | 100 : m_overlay(&overlay) |
65 { } | 101 { } |
66 | 102 |
67 DEFINE_INLINE_VIRTUAL_TRACE() | 103 DEFINE_INLINE_VIRTUAL_TRACE() |
68 { | 104 { |
69 visitor->trace(m_overlay); | 105 visitor->trace(m_overlay); |
70 PageOverlay::Delegate::trace(visitor); | 106 PageOverlay::Delegate::trace(visitor); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 , m_overlay(&overlay) | 165 , m_overlay(&overlay) |
130 { } | 166 { } |
131 | 167 |
132 RawPtrWillBeMember<ChromeClient> m_client; | 168 RawPtrWillBeMember<ChromeClient> m_client; |
133 RawPtrWillBeMember<InspectorOverlayImpl> m_overlay; | 169 RawPtrWillBeMember<InspectorOverlayImpl> m_overlay; |
134 }; | 170 }; |
135 | 171 |
136 | 172 |
137 InspectorOverlayImpl::InspectorOverlayImpl(WebViewImpl* webViewImpl) | 173 InspectorOverlayImpl::InspectorOverlayImpl(WebViewImpl* webViewImpl) |
138 : m_webViewImpl(webViewImpl) | 174 : m_webViewImpl(webViewImpl) |
139 , m_inspectModeEnabled(false) | |
140 , m_overlayHost(InspectorOverlayHost::create()) | 175 , m_overlayHost(InspectorOverlayHost::create()) |
141 , m_drawViewSize(false) | 176 , m_drawViewSize(false) |
142 , m_drawViewSizeWithGrid(false) | 177 , m_drawViewSizeWithGrid(false) |
143 , m_resizeTimerActive(false) | 178 , m_resizeTimerActive(false) |
144 , m_omitTooltip(false) | 179 , m_omitTooltip(false) |
145 , m_timer(this, &InspectorOverlayImpl::onTimer) | 180 , m_timer(this, &InspectorOverlayImpl::onTimer) |
146 , m_suspendCount(0) | 181 , m_suspendCount(0) |
147 , m_inLayout(false) | 182 , m_inLayout(false) |
148 , m_needsUpdate(false) | 183 , m_needsUpdate(false) |
184 , m_inspectMode(InspectorDOMAgent::NotSearching) | |
149 { | 185 { |
150 } | 186 } |
151 | 187 |
152 InspectorOverlayImpl::~InspectorOverlayImpl() | 188 InspectorOverlayImpl::~InspectorOverlayImpl() |
153 { | 189 { |
154 ASSERT(!m_overlayPage); | 190 ASSERT(!m_overlayPage); |
155 } | 191 } |
156 | 192 |
157 DEFINE_TRACE(InspectorOverlayImpl) | 193 DEFINE_TRACE(InspectorOverlayImpl) |
158 { | 194 { |
159 visitor->trace(m_highlightNode); | 195 visitor->trace(m_highlightNode); |
160 visitor->trace(m_eventTargetNode); | 196 visitor->trace(m_eventTargetNode); |
161 visitor->trace(m_overlayPage); | 197 visitor->trace(m_overlayPage); |
162 visitor->trace(m_overlayChromeClient); | 198 visitor->trace(m_overlayChromeClient); |
163 visitor->trace(m_overlayHost); | 199 visitor->trace(m_overlayHost); |
164 visitor->trace(m_debuggerAgent); | 200 visitor->trace(m_debuggerAgent); |
201 visitor->trace(m_domAgent); | |
165 visitor->trace(m_layoutEditor); | 202 visitor->trace(m_layoutEditor); |
203 visitor->trace(m_hoveredNodeForInspectMode); | |
166 } | 204 } |
167 | 205 |
168 void InspectorOverlayImpl::init(InspectorCSSAgent* cssAgent, InspectorDebuggerAg ent* debuggerAgent) | 206 void InspectorOverlayImpl::init(InspectorCSSAgent* cssAgent, InspectorDebuggerAg ent* debuggerAgent, InspectorDOMAgent* domAgent) |
169 { | 207 { |
170 m_layoutEditor = LayoutEditor::create(cssAgent); | 208 m_layoutEditor = LayoutEditor::create(cssAgent); |
171 m_debuggerAgent = debuggerAgent; | 209 m_debuggerAgent = debuggerAgent; |
210 m_domAgent = domAgent; | |
172 m_overlayHost->setListener(this); | 211 m_overlayHost->setListener(this); |
173 } | 212 } |
174 | 213 |
175 void InspectorOverlayImpl::invalidate() | 214 void InspectorOverlayImpl::invalidate() |
176 { | 215 { |
177 if (!m_pageOverlay) | 216 if (!m_pageOverlay) |
178 m_pageOverlay = PageOverlay::create(m_webViewImpl, new InspectorPageOver layDelegate(*this)); | 217 m_pageOverlay = PageOverlay::create(m_webViewImpl, new InspectorPageOver layDelegate(*this)); |
179 | 218 |
180 m_pageOverlay->update(); | 219 m_pageOverlay->update(); |
181 } | 220 } |
182 | 221 |
183 void InspectorOverlayImpl::layout() | 222 void InspectorOverlayImpl::layout() |
184 { | 223 { |
185 if (isEmpty()) | 224 if (isEmpty()) |
186 return; | 225 return; |
187 | 226 |
188 TemporaryChange<bool> scoped(m_inLayout, true); | 227 TemporaryChange<bool> scoped(m_inLayout, true); |
189 if (m_needsUpdate) { | 228 if (m_needsUpdate) { |
190 m_needsUpdate = false; | 229 m_needsUpdate = false; |
191 rebuildOverlayPage(); | 230 rebuildOverlayPage(); |
192 } | 231 } |
193 overlayMainFrame()->view()->updateAllLifecyclePhases(); | 232 overlayMainFrame()->view()->updateAllLifecyclePhases(); |
194 } | 233 } |
195 | 234 |
196 bool InspectorOverlayImpl::handleInputEvent(const WebInputEvent& inputEvent) | 235 bool InspectorOverlayImpl::handleInputEvent(const WebInputEvent& inputEvent) |
197 { | 236 { |
198 bool handled = false; | 237 bool handled = false; |
238 | |
199 if (isEmpty()) | 239 if (isEmpty()) |
200 return handled; | 240 return false; |
201 | 241 |
202 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) { | 242 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) { |
203 // Only let GestureTab in (we only need it and we know PlatformGestureEv entBuilder supports it). | 243 // Only let GestureTab in (we only need it and we know PlatformGestureEv entBuilder supports it). |
204 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webVie wImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEv ent)); | 244 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webVie wImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEv ent)); |
245 handled = handleGestureEvent(gestureEvent); | |
246 if (handled) | |
247 return true; | |
248 | |
205 overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent); | 249 overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent); |
206 } | 250 } |
207 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W ebInputEvent::MouseEnter) { | 251 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W ebInputEvent::MouseEnter) { |
208 // PlatformMouseEventBuilder does not work with MouseEnter type, so we f ilter it out manually. | 252 // PlatformMouseEventBuilder does not work with MouseEnter type, so we f ilter it out manually. |
209 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl- >mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent)); | 253 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl- >mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent)); |
254 | |
255 if (mouseEvent.type() == PlatformEvent::MouseMoved) | |
256 handled = handleMouseMove(mouseEvent); | |
257 else if (mouseEvent.type() == PlatformEvent::MousePressed) | |
258 handled = handleMousePress(); | |
259 | |
260 if (handled) | |
261 return true; | |
262 | |
210 if (mouseEvent.type() == PlatformEvent::MouseMoved) | 263 if (mouseEvent.type() == PlatformEvent::MouseMoved) |
211 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent(mo useEvent); | 264 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent(mo useEvent); |
212 if (mouseEvent.type() == PlatformEvent::MousePressed) | 265 if (mouseEvent.type() == PlatformEvent::MousePressed) |
213 handled = overlayMainFrame()->eventHandler().handleMousePressEvent(m ouseEvent); | 266 handled = overlayMainFrame()->eventHandler().handleMousePressEvent(m ouseEvent); |
214 if (mouseEvent.type() == PlatformEvent::MouseReleased) | 267 if (mouseEvent.type() == PlatformEvent::MouseReleased) |
215 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent (mouseEvent); | 268 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent (mouseEvent); |
216 } | 269 } |
270 | |
217 if (WebInputEvent::isTouchEventType(inputEvent.type)) { | 271 if (WebInputEvent::isTouchEventType(inputEvent.type)) { |
218 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl- >mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent)); | 272 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl- >mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent)); |
273 handled = handleTouchEvent(touchEvent); | |
274 if (handled) | |
275 return true; | |
219 overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent); | 276 overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent); |
220 } | 277 } |
221 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { | 278 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { |
222 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(stati c_cast<const WebKeyboardEvent&>(inputEvent)); | 279 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(stati c_cast<const WebKeyboardEvent&>(inputEvent)); |
223 overlayMainFrame()->eventHandler().keyEvent(keyboardEvent); | 280 overlayMainFrame()->eventHandler().keyEvent(keyboardEvent); |
224 } | 281 } |
225 | 282 |
226 return handled; | 283 return handled; |
227 } | 284 } |
228 | 285 |
229 void InspectorOverlayImpl::setPausedInDebuggerMessage(const String* message) | 286 void InspectorOverlayImpl::setPausedInDebuggerMessage(const String* message) |
230 { | 287 { |
231 m_pausedInDebuggerMessage = message ? *message : String(); | 288 m_pausedInDebuggerMessage = message ? *message : String(); |
232 update(); | 289 update(); |
233 } | 290 } |
234 | 291 |
235 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled) | |
236 { | |
237 m_inspectModeEnabled = enabled; | |
238 update(); | |
239 } | |
240 | |
241 void InspectorOverlayImpl::hideHighlight() | 292 void InspectorOverlayImpl::hideHighlight() |
242 { | 293 { |
243 if (m_layoutEditor) | 294 if (m_layoutEditor) |
244 m_layoutEditor->setNode(nullptr); | 295 m_layoutEditor->setNode(nullptr); |
245 m_highlightNode.clear(); | 296 m_highlightNode.clear(); |
246 m_eventTargetNode.clear(); | 297 m_eventTargetNode.clear(); |
247 m_highlightQuad.clear(); | 298 m_highlightQuad.clear(); |
248 update(); | 299 update(); |
249 } | 300 } |
250 | 301 |
302 void InspectorOverlayImpl::highlightNode(Node* node, const InspectorHighlightCon fig& highlightConfig, bool omitTooltip) | |
303 { | |
304 highlightNode(node, nullptr, highlightConfig, omitTooltip); | |
305 } | |
306 | |
251 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In spectorHighlightConfig& highlightConfig, bool omitTooltip) | 307 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In spectorHighlightConfig& highlightConfig, bool omitTooltip) |
252 { | 308 { |
253 m_nodeHighlightConfig = highlightConfig; | 309 m_nodeHighlightConfig = highlightConfig; |
254 m_highlightNode = node; | 310 m_highlightNode = node; |
255 if (m_layoutEditor && highlightConfig.showLayoutEditor) | 311 if (m_layoutEditor && highlightConfig.showLayoutEditor) |
256 m_layoutEditor->setNode(node); | 312 m_layoutEditor->setNode(node); |
257 m_eventTargetNode = eventTarget; | 313 m_eventTargetNode = eventTarget; |
258 m_omitTooltip = omitTooltip; | 314 m_omitTooltip = omitTooltip; |
259 update(); | 315 update(); |
260 } | 316 } |
261 | 317 |
318 void InspectorOverlayImpl::setInspectMode(InspectorDOMAgent::SearchMode searchMo de, PassOwnPtr<InspectorHighlightConfig> highlightConfig) | |
319 { | |
320 m_inspectMode = searchMode; | |
321 update(); | |
322 | |
323 if (searchMode != InspectorDOMAgent::NotSearching) { | |
324 m_inspectModeHighlightConfig = highlightConfig; | |
325 } else { | |
326 m_hoveredNodeForInspectMode.clear(); | |
327 hideHighlight(); | |
328 } | |
329 } | |
330 | |
262 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe ctorHighlightConfig& highlightConfig) | 331 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe ctorHighlightConfig& highlightConfig) |
263 { | 332 { |
264 m_quadHighlightConfig = highlightConfig; | 333 m_quadHighlightConfig = highlightConfig; |
265 m_highlightQuad = quad; | 334 m_highlightQuad = quad; |
266 m_omitTooltip = false; | 335 m_omitTooltip = false; |
267 update(); | 336 update(); |
268 } | 337 } |
269 | 338 |
270 bool InspectorOverlayImpl::isEmpty() | 339 bool InspectorOverlayImpl::isEmpty() |
271 { | 340 { |
272 if (m_suspendCount) | 341 if (m_suspendCount) |
273 return true; | 342 return true; |
274 bool hasAlwaysVisibleElements = m_highlightNode || m_eventTargetNode || m_hi ghlightQuad || (m_resizeTimerActive && m_drawViewSize); | 343 bool hasAlwaysVisibleElements = m_highlightNode || m_eventTargetNode || m_hi ghlightQuad || (m_resizeTimerActive && m_drawViewSize); |
275 bool hasInvisibleInInspectModeElements = !m_pausedInDebuggerMessage.isNull() ; | 344 bool hasInvisibleInInspectModeElements = !m_pausedInDebuggerMessage.isNull() ; |
276 return !(hasAlwaysVisibleElements || (hasInvisibleInInspectModeElements && ! m_inspectModeEnabled)); | 345 return !(hasAlwaysVisibleElements || m_inspectMode != InspectorDOMAgent::Not Searching || hasInvisibleInInspectModeElements); |
dgozman
2015/09/01 17:51:46
This looks wrong. Let's discuss offline.
sergeyv
2015/09/01 19:08:09
As we discussed it offline: it is correct, but I h
| |
277 } | 346 } |
278 | 347 |
279 void InspectorOverlayImpl::update() | 348 void InspectorOverlayImpl::update() |
280 { | 349 { |
281 if (isEmpty()) { | 350 if (isEmpty()) { |
282 if (m_pageOverlay) | 351 if (m_pageOverlay) |
283 m_pageOverlay.clear(); | 352 m_pageOverlay.clear(); |
284 return; | 353 return; |
285 } | 354 } |
286 m_needsUpdate = true; | 355 m_needsUpdate = true; |
287 m_webViewImpl->page()->chromeClient().scheduleAnimation(); | 356 m_webViewImpl->page()->chromeClient().scheduleAnimation(); |
288 } | 357 } |
289 | 358 |
290 void InspectorOverlayImpl::rebuildOverlayPage() | 359 void InspectorOverlayImpl::rebuildOverlayPage() |
291 { | 360 { |
292 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView(); | 361 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView(); |
293 if (!view) | 362 if (!view) |
294 return; | 363 return; |
295 | 364 |
296 IntRect visibleRectInDocument = view->scrollableArea()->visibleContentRect() ; | 365 IntRect visibleRectInDocument = view->scrollableArea()->visibleContentRect() ; |
297 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s ize(); | 366 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s ize(); |
298 toLocalFrame(overlayPage()->mainFrame())->view()->resize(viewportSize); | 367 toLocalFrame(overlayPage()->mainFrame())->view()->resize(viewportSize); |
299 reset(viewportSize, visibleRectInDocument.location()); | 368 reset(viewportSize, visibleRectInDocument.location()); |
300 | 369 |
301 drawNodeHighlight(); | 370 drawNodeHighlight(); |
302 drawQuadHighlight(); | 371 drawQuadHighlight(); |
303 if (!m_inspectModeEnabled) | 372 if (m_inspectMode == InspectorDOMAgent::NotSearching) |
304 drawPausedInDebuggerMessage(); | 373 drawPausedInDebuggerMessage(); |
305 drawViewSize(); | 374 drawViewSize(); |
306 } | 375 } |
307 | 376 |
308 static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size) | 377 static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size) |
309 { | 378 { |
310 RefPtr<JSONObject> result = JSONObject::create(); | 379 RefPtr<JSONObject> result = JSONObject::create(); |
311 result->setNumber("width", size.width()); | 380 result->setNumber("width", size.width()); |
312 result->setNumber("height", size.height()); | 381 result->setNumber("height", size.height()); |
313 return result.release(); | 382 return result.release(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 | 529 |
461 void InspectorOverlayImpl::clear() | 530 void InspectorOverlayImpl::clear() |
462 { | 531 { |
463 if (m_overlayPage) { | 532 if (m_overlayPage) { |
464 m_overlayPage->willBeDestroyed(); | 533 m_overlayPage->willBeDestroyed(); |
465 m_overlayPage.clear(); | 534 m_overlayPage.clear(); |
466 m_overlayChromeClient.clear(); | 535 m_overlayChromeClient.clear(); |
467 } | 536 } |
468 m_resizeTimerActive = false; | 537 m_resizeTimerActive = false; |
469 m_pausedInDebuggerMessage = String(); | 538 m_pausedInDebuggerMessage = String(); |
470 m_inspectModeEnabled = false; | 539 m_inspectMode = InspectorDOMAgent::NotSearching; |
471 m_timer.stop(); | 540 m_timer.stop(); |
472 hideHighlight(); | 541 hideHighlight(); |
473 } | 542 } |
474 | 543 |
475 void InspectorOverlayImpl::overlayResumed() | 544 void InspectorOverlayImpl::overlayResumed() |
476 { | 545 { |
477 if (m_debuggerAgent) { | 546 if (m_debuggerAgent) { |
478 ErrorString error; | 547 ErrorString error; |
479 m_debuggerAgent->resume(&error); | 548 m_debuggerAgent->resume(&error); |
480 } | 549 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 } | 591 } |
523 update(); | 592 update(); |
524 } | 593 } |
525 | 594 |
526 void InspectorOverlayImpl::setShowViewportSizeOnResize(bool show, bool showGrid) | 595 void InspectorOverlayImpl::setShowViewportSizeOnResize(bool show, bool showGrid) |
527 { | 596 { |
528 m_drawViewSize = show; | 597 m_drawViewSize = show; |
529 m_drawViewSizeWithGrid = showGrid; | 598 m_drawViewSizeWithGrid = showGrid; |
530 } | 599 } |
531 | 600 |
601 bool InspectorOverlayImpl::handleMouseMove(const PlatformMouseEvent& event) | |
602 { | |
603 if (m_inspectMode == InspectorDOMAgent::NotSearching) | |
604 return false; | |
605 | |
606 LocalFrame* frame = m_webViewImpl->mainFrameImpl()->frame(); | |
607 if (!frame->view() || !frame->contentLayoutObject()) | |
608 return false; | |
609 Node* node = hoveredNodeForEvent(frame, event, event.shiftKey()); | |
610 | |
611 // Do not highlight within user agent shadow root unless requested. | |
612 if (m_inspectMode != InspectorDOMAgent::SearchingForUAShadow) { | |
613 ShadowRoot* shadowRoot = InspectorDOMAgent::userAgentShadowRoot(node); | |
614 if (shadowRoot) | |
615 node = shadowRoot->host(); | |
616 } | |
617 | |
618 // Shadow roots don't have boxes - use host element instead. | |
619 if (node && node->isShadowRoot()) | |
620 node = node->parentOrShadowHostNode(); | |
621 | |
622 if (!node) | |
623 return true; | |
624 | |
625 Node* eventTarget = event.shiftKey() ? hoveredNodeForEvent(m_webViewImpl->ma inFrameImpl()->frame(), event, false) : nullptr; | |
626 if (eventTarget == node) | |
627 eventTarget = nullptr; | |
628 | |
629 if (node && m_inspectModeHighlightConfig) { | |
630 m_hoveredNodeForInspectMode = node; | |
631 highlightNode(node, eventTarget, *m_inspectModeHighlightConfig, event.ct rlKey() || event.metaKey()); | |
632 } | |
633 return true; | |
634 } | |
635 | |
636 bool InspectorOverlayImpl::handleMousePress() | |
637 { | |
638 if (m_inspectMode == InspectorDOMAgent::NotSearching) | |
639 return false; | |
640 | |
641 if (m_hoveredNodeForInspectMode) { | |
642 if (m_domAgent) | |
643 m_domAgent->inspect(m_hoveredNodeForInspectMode.get()); | |
644 m_hoveredNodeForInspectMode.clear(); | |
645 return true; | |
646 } | |
647 return false; | |
648 } | |
649 | |
650 bool InspectorOverlayImpl::handleGestureEvent(const PlatformGestureEvent& event) | |
651 { | |
652 if (m_inspectMode == InspectorDOMAgent::NotSearching || event.type() != Plat formEvent::GestureTap) | |
653 return false; | |
654 Node* node = hoveredNodeForEvent(m_webViewImpl->mainFrameImpl()->frame(), ev ent, false); | |
655 if (node && m_inspectModeHighlightConfig) { | |
656 highlightNode(node, *m_inspectModeHighlightConfig, false); | |
657 if (m_domAgent) | |
658 m_domAgent->inspect(node); | |
659 return true; | |
660 } | |
661 return false; | |
662 } | |
663 | |
664 bool InspectorOverlayImpl::handleTouchEvent(const PlatformTouchEvent& event) | |
665 { | |
666 if (m_inspectMode == InspectorDOMAgent::NotSearching) | |
667 return false; | |
668 Node* node = hoveredNodeForEvent(m_webViewImpl->mainFrameImpl()->frame(), ev ent, false); | |
669 if (node && m_inspectModeHighlightConfig) { | |
670 highlightNode(node, *m_inspectModeHighlightConfig, false); | |
671 if (m_domAgent) | |
672 m_domAgent->inspect(node); | |
673 return true; | |
674 } | |
675 return false; | |
676 } | |
677 | |
532 } // namespace blink | 678 } // namespace blink |
OLD | NEW |