Chromium Code Reviews| Index: Source/core/inspector/InspectorDOMAgent.cpp |
| diff --git a/Source/core/inspector/InspectorDOMAgent.cpp b/Source/core/inspector/InspectorDOMAgent.cpp |
| index 136cf96170847cf404c490ba54c0e54788488dc8..2213aa566274a109d37650a14f5c24fd56fe9383 100644 |
| --- a/Source/core/inspector/InspectorDOMAgent.cpp |
| +++ b/Source/core/inspector/InspectorDOMAgent.cpp |
| @@ -316,6 +316,7 @@ InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri |
| , m_searchingForNode(NotSearching) |
| , m_suppressAttributeModifiedEvent(false) |
| , m_backendNodeIdToInspect(0) |
| + , m_layoutEditorEnabled(false) |
| { |
| } |
| @@ -1126,7 +1127,7 @@ void InspectorDOMAgent::discardSearchResults(ErrorString*, const String& searchI |
| bool InspectorDOMAgent::handleMousePress() |
| { |
| - if (m_searchingForNode == NotSearching) |
| + if (!shouldHandleInputEvents()) |
| return false; |
| if (m_hoveredNodeForInspectMode) { |
| @@ -1139,7 +1140,7 @@ bool InspectorDOMAgent::handleMousePress() |
| bool InspectorDOMAgent::handleGestureEvent(LocalFrame* frame, const PlatformGestureEvent& event) |
| { |
| - if (m_searchingForNode == NotSearching || event.type() != PlatformEvent::GestureTap) |
|
dgozman
2015/08/28 23:44:10
Bring back GestureTap!
sergeyv
2015/09/02 00:40:57
Done.
|
| + if (!shouldHandleInputEvents()) |
| return false; |
| Node* node = hoveredNodeForEvent(frame, event, false); |
| if (node && m_inspectModeHighlightConfig) { |
| @@ -1153,7 +1154,7 @@ bool InspectorDOMAgent::handleGestureEvent(LocalFrame* frame, const PlatformGest |
| bool InspectorDOMAgent::handleTouchEvent(LocalFrame* frame, const PlatformTouchEvent& event) |
| { |
| - if (m_searchingForNode == NotSearching) |
| + if (!shouldHandleInputEvents()) |
| return false; |
| Node* node = hoveredNodeForEvent(frame, event, false); |
| if (node && m_inspectModeHighlightConfig) { |
| @@ -1183,11 +1184,19 @@ void InspectorDOMAgent::inspect(Node* inspectedNode) |
| } |
| frontend()->inspectNodeRequested(backendNodeId); |
| + |
| + if (m_searchingForNode == SearchingInLayoutEditor) { |
| + m_layoutEditorEnabled = true; |
| + if (m_client) { |
| + m_client->setInspectModeEnabled(false); |
| + m_client->showLayoutEditorForNode(node, *m_inspectModeHighlightConfig.get()); |
| + } |
| + } |
| } |
| bool InspectorDOMAgent::handleMouseMove(LocalFrame* frame, const PlatformMouseEvent& event) |
| { |
| - if (m_searchingForNode == NotSearching) |
| + if (!shouldHandleInputEvents()) |
| return false; |
| if (!frame->view() || !frame->contentLayoutObject()) |
| @@ -1231,6 +1240,8 @@ void InspectorDOMAgent::setSearchingForNode(ErrorString* errorString, SearchMode |
| } else { |
| m_hoveredNodeForInspectMode.clear(); |
| hideHighlight(errorString); |
| + if (m_client) |
| + m_client->showLayoutEditorForNode(nullptr, m_inspectModeHighlightConfig ? *m_inspectModeHighlightConfig : InspectorHighlightConfig()); |
| } |
| } |
| @@ -1251,9 +1262,6 @@ PassOwnPtr<InspectorHighlightConfig> InspectorDOMAgent::highlightConfigFromInspe |
| bool showExtensionLines = false; // Default: false (do not show extension lines). |
| highlightInspectorObject->getBoolean("showExtensionLines", &showExtensionLines); |
| highlightConfig->showExtensionLines = showExtensionLines; |
| - bool showLayoutEditor = false; |
| - highlightInspectorObject->getBoolean("showLayoutEditor", &showLayoutEditor); |
| - highlightConfig->showLayoutEditor = showLayoutEditor; |
| bool displayAsMaterial = false; |
| highlightInspectorObject->getBoolean("displayAsMaterial", &displayAsMaterial); |
| highlightConfig->displayAsMaterial = displayAsMaterial; |
| @@ -1269,11 +1277,22 @@ PassOwnPtr<InspectorHighlightConfig> InspectorDOMAgent::highlightConfigFromInspe |
| return highlightConfig.release(); |
| } |
| -void InspectorDOMAgent::setInspectModeEnabled(ErrorString* errorString, bool enabled, const bool* inspectUAShadowDOM, const RefPtr<JSONObject>* highlightConfig) |
| +void InspectorDOMAgent::setInspectModeEnabled(ErrorString* errorString, bool enabled, const String* mode, const RefPtr<JSONObject>* highlightConfig) |
| { |
| if (enabled && !pushDocumentUponHandlelessOperation(errorString)) |
| return; |
| - SearchMode searchMode = enabled ? (asBool(inspectUAShadowDOM) ? SearchingForUAShadow : SearchingForNormal) : NotSearching; |
| + SearchMode searchMode = SearchingForNormal; |
| + if (!enabled) { |
| + searchMode = NotSearching; |
| + } else if (!mode) { |
| + searchMode = SearchingForNormal; |
| + } else if (*mode == "showUAShadowDOM") { |
|
dgozman
2015/08/28 23:44:10
There should be TypeBuilder constants for these.
sergeyv
2015/09/02 00:40:58
Done.
|
| + searchMode = SearchingForUAShadow; |
| + } else if (*mode == "showLayoutEditor") { |
| + searchMode = SearchingInLayoutEditor; |
| + m_layoutEditorEnabled = false; |
| + } |
| + |
| setSearchingForNode(errorString, searchMode, highlightConfig ? highlightConfig->get() : nullptr); |
| } |
| @@ -2230,6 +2249,27 @@ bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt |
| return true; |
| } |
| +void InspectorDOMAgent::resumeSearchingForNode(Node* startNode) |
| +{ |
| + if (m_searchingForNode != SearchingInLayoutEditor) |
| + return; |
| + |
| + m_layoutEditorEnabled = false; |
| + if (m_client) |
| + m_client->setInspectModeEnabled(true); |
| + if (startNode && m_inspectModeHighlightConfig) { |
| + m_hoveredNodeForInspectMode = startNode; |
| + if (m_client) |
| + m_client->highlightNode(startNode, 0, *m_inspectModeHighlightConfig, false); |
| + } |
| + |
| +} |
| + |
| +bool InspectorDOMAgent::shouldHandleInputEvents() |
|
dgozman
2015/08/28 23:44:10
shouldSearchForNode
sergeyv
2015/09/02 00:40:57
Done.
|
| +{ |
| + return m_searchingForNode != NotSearching && (m_searchingForNode != SearchingInLayoutEditor || !m_layoutEditorEnabled); |
|
dgozman
2015/08/28 23:44:10
return !(m_searchingForNode == NotSearching || (m_
sergeyv
2015/09/02 00:40:58
Done.
|
| +} |
| + |
| DEFINE_TRACE(InspectorDOMAgent) |
| { |
| visitor->trace(m_domListener); |