Chromium Code Reviews| Index: Source/core/inspector/InspectorDOMAgent.cpp |
| diff --git a/Source/core/inspector/InspectorDOMAgent.cpp b/Source/core/inspector/InspectorDOMAgent.cpp |
| index fffd8b1e82eee1595d05c99e60526a625ab3a75f..5f4feea4716fe4383bb5dcddbca9202b22e837e0 100644 |
| --- a/Source/core/inspector/InspectorDOMAgent.cpp |
| +++ b/Source/core/inspector/InspectorDOMAgent.cpp |
| @@ -72,7 +72,6 @@ |
| #include "core/inspector/InspectorHistory.h" |
| #include "core/inspector/InspectorIdentifiers.h" |
| #include "core/inspector/InspectorOverlay.h" |
| -#include "core/inspector/InspectorPageAgent.h" |
| #include "core/inspector/InspectorState.h" |
| #include "core/inspector/InstrumentingAgents.h" |
| #include "core/layout/HitTestResult.h" |
| @@ -292,9 +291,9 @@ bool InspectorDOMAgent::getPseudoElementType(PseudoId pseudoId, TypeBuilder::DOM |
| } |
| } |
| -InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay) |
| +InspectorDOMAgent::InspectorDOMAgent(LocalFrame* inspectedFrame, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay) |
| : InspectorBaseAgent<InspectorDOMAgent, InspectorFrontend::DOM>("DOM") |
| - , m_pageAgent(pageAgent) |
| + , m_inspectedFrame(inspectedFrame) |
| , m_injectedScriptManager(injectedScriptManager) |
| , m_overlay(overlay) |
| , m_domListener(nullptr) |
| @@ -537,7 +536,7 @@ void InspectorDOMAgent::innerEnable() |
| m_state->setBoolean(DOMAgentState::domAgentEnabled, true); |
| m_history = adoptPtrWillBeNoop(new InspectorHistory()); |
| m_domEditor = adoptPtrWillBeNoop(new DOMEditor(m_history.get())); |
| - m_document = m_pageAgent->inspectedFrame()->document(); |
| + m_document = m_inspectedFrame->document(); |
| m_instrumentingAgents->setInspectorDOMAgent(this); |
| if (m_listener) |
| m_listener->domAgentWasEnabled(); |
| @@ -1332,20 +1331,25 @@ void InspectorDOMAgent::highlightNode(ErrorString* errorString, const RefPtr<JSO |
| } |
| void InspectorDOMAgent::highlightFrame( |
| - ErrorString*, |
| + ErrorString* errorString, |
| const String& frameId, |
| const RefPtr<JSONObject>* color, |
| const RefPtr<JSONObject>* outlineColor) |
| { |
| - LocalFrame* frame = m_pageAgent->frameForId(frameId); |
| - // FIXME: Inspector doesn't currently work cross process. |
|
yurys
2015/04/24 08:54:40
Please return this.
|
| - if (frame && frame->deprecatedLocalOwner()) { |
| - OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHighlightConfig()); |
| - highlightConfig->showInfo = true; // Always show tooltips for frames. |
| - highlightConfig->content = parseColor(color); |
| - highlightConfig->contentOutline = parseColor(outlineColor); |
| - m_overlay->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTarget */, *highlightConfig, false); |
| + LocalFrame* frame = InspectorIdentifiers<LocalFrame>::lookup(frameId); |
| + if (!frame || frame->instrumentingAgents() != m_inspectedFrame->instrumentingAgents()) { |
| + *errorString = "No frame for given id found"; |
| + return; |
| } |
| + FrameOwner* owner = frame->owner(); |
| + if (!owner || !owner->isLocal()) |
| + return; |
| + HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(owner); |
| + OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHighlightConfig()); |
| + highlightConfig->showInfo = true; // Always show tooltips for frames. |
| + highlightConfig->content = parseColor(color); |
| + highlightConfig->contentOutline = parseColor(outlineColor); |
| + m_overlay->highlightNode(ownerElement, 0 /* eventTarget */, *highlightConfig, false); |
| } |
| void InspectorDOMAgent::hideHighlight(ErrorString*) |
| @@ -1816,7 +1820,7 @@ bool InspectorDOMAgent::isWhitespace(Node* node) |
| void InspectorDOMAgent::domContentLoadedEventFired(LocalFrame* frame) |
| { |
| - if (frame != m_pageAgent->inspectedFrame()) |
| + if (frame != m_inspectedFrame) |
| return; |
| // Re-push document once it is loaded. |
| @@ -1848,13 +1852,12 @@ void InspectorDOMAgent::invalidateFrameOwnerElement(LocalFrame* frame) |
| void InspectorDOMAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader) |
| { |
| - LocalFrame* inspectedFrame = m_pageAgent->inspectedFrame(); |
| - if (loader->frame() != inspectedFrame) { |
| + if (loader->frame() != m_inspectedFrame) { |
| invalidateFrameOwnerElement(loader->frame()); |
| return; |
| } |
| - setDocument(inspectedFrame->document()); |
| + setDocument(m_inspectedFrame->document()); |
| } |
| void InspectorDOMAgent::didInsertDOMNode(Node* node) |
| @@ -2039,7 +2042,7 @@ void InspectorDOMAgent::frameDocumentUpdated(LocalFrame* frame) |
| if (!document) |
| return; |
| - if (frame != m_pageAgent->inspectedFrame()) |
| + if (frame != m_inspectedFrame) |
| return; |
| // Only update the main frame document, nested frame document updates are not required |
| @@ -2145,7 +2148,7 @@ void InspectorDOMAgent::pushNodesByBackendIdsToFrontend(ErrorString* errorString |
| } |
| Node* node = DOMNodeIds::nodeForId(backendNodeId); |
| - if (node && node->document().frame() && node->document().frame()->instrumentingAgents() == m_pageAgent->inspectedFrame()->instrumentingAgents()) |
| + if (node && node->document().frame() && node->document().frame()->instrumentingAgents() == m_inspectedFrame->instrumentingAgents()) |
| result->addItem(pushNodePathToFrontend(node)); |
| else |
| result->addItem(0); |
| @@ -2223,7 +2226,7 @@ bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt |
| DEFINE_TRACE(InspectorDOMAgent) |
| { |
| visitor->trace(m_domListener); |
| - visitor->trace(m_pageAgent); |
| + visitor->trace(m_inspectedFrame); |
| visitor->trace(m_injectedScriptManager); |
| visitor->trace(m_overlay); |
| #if ENABLE(OILPAN) |