Chromium Code Reviews| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/PageConsoleAgent.h" | 32 #include "core/inspector/PageConsoleAgent.h" |
| 33 | 33 |
| 34 #include "core/dom/Node.h" | 34 #include "core/dom/Node.h" |
| 35 #include "core/dom/NodeTraversal.h" | 35 #include "core/dom/NodeTraversal.h" |
| 36 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
| 37 #include "core/frame/FrameConsole.h" | |
| 37 #include "core/inspector/InjectedScriptHost.h" | 38 #include "core/inspector/InjectedScriptHost.h" |
| 38 #include "core/inspector/InjectedScriptManager.h" | 39 #include "core/inspector/InjectedScriptManager.h" |
| 39 #include "core/inspector/InspectorDOMAgent.h" | 40 #include "core/inspector/InspectorDOMAgent.h" |
| 41 #include "core/page/Page.h" | |
| 40 | 42 |
| 41 namespace blink { | 43 namespace blink { |
| 42 | 44 |
| 43 PageConsoleAgent::PageConsoleAgent(InjectedScriptManager* injectedScriptManager, InspectorDOMAgent* domAgent, InspectorTimelineAgent* timelineAgent, InspectorTr acingAgent* tracingAgent) | 45 PageConsoleAgent::PageConsoleAgent(InjectedScriptManager* injectedScriptManager, InspectorDOMAgent* domAgent, InspectorTimelineAgent* timelineAgent, InspectorTr acingAgent* tracingAgent, Page* page) |
| 44 : InspectorConsoleAgent(timelineAgent, tracingAgent, injectedScriptManager) | 46 : InspectorConsoleAgent(timelineAgent, tracingAgent, injectedScriptManager) |
| 45 , m_inspectorDOMAgent(domAgent) | 47 , m_inspectorDOMAgent(domAgent) |
| 48 , m_page(page) | |
| 46 { | 49 { |
| 47 } | 50 } |
| 48 | 51 |
| 49 PageConsoleAgent::~PageConsoleAgent() | 52 PageConsoleAgent::~PageConsoleAgent() |
| 50 { | 53 { |
| 51 #if !ENABLE(OILPAN) | 54 #if !ENABLE(OILPAN) |
| 52 m_inspectorDOMAgent = nullptr; | 55 m_inspectorDOMAgent = nullptr; |
| 53 #endif | 56 #endif |
| 54 } | 57 } |
| 55 | 58 |
| 56 void PageConsoleAgent::trace(Visitor* visitor) | 59 void PageConsoleAgent::trace(Visitor* visitor) |
| 57 { | 60 { |
| 58 visitor->trace(m_inspectorDOMAgent); | 61 visitor->trace(m_inspectorDOMAgent); |
| 59 InspectorConsoleAgent::trace(visitor); | 62 InspectorConsoleAgent::trace(visitor); |
| 60 } | 63 } |
| 61 | 64 |
| 62 void PageConsoleAgent::clearMessages(ErrorString* errorString) | 65 void PageConsoleAgent::clearMessages(ErrorString* errorString) |
| 63 { | 66 { |
| 64 m_inspectorDOMAgent->releaseDanglingNodes(); | 67 m_inspectorDOMAgent->releaseDanglingNodes(); |
| 65 InspectorConsoleAgent::clearMessages(errorString); | 68 InspectorConsoleAgent::clearMessages(errorString); |
| 66 } | 69 } |
| 67 | 70 |
| 71 ConsoleMessageStorage* PageConsoleAgent::messageStorage() | |
| 72 { | |
| 73 Frame* frame = m_page->mainFrame(); | |
|
aandrey
2014/08/26 08:56:42
m_page->deprecatedLocalMainFrame() ?
kozyatinskiy1
2014/08/26 09:39:29
Done.
| |
| 74 ASSERT(frame->isLocalFrame()); | |
| 75 return toLocalFrame(frame)->console().messageStorage(); | |
| 76 } | |
| 77 | |
| 68 class InspectableNode FINAL : public InjectedScriptHost::InspectableObject { | 78 class InspectableNode FINAL : public InjectedScriptHost::InspectableObject { |
| 69 public: | 79 public: |
| 70 explicit InspectableNode(Node* node) : m_node(node) { } | 80 explicit InspectableNode(Node* node) : m_node(node) { } |
| 71 virtual ScriptValue get(ScriptState* state) OVERRIDE | 81 virtual ScriptValue get(ScriptState* state) OVERRIDE |
| 72 { | 82 { |
| 73 return InjectedScriptHost::nodeAsScriptValue(state, m_node); | 83 return InjectedScriptHost::nodeAsScriptValue(state, m_node); |
| 74 } | 84 } |
| 75 private: | 85 private: |
| 76 Node* m_node; | 86 Node* m_node; |
| 77 }; | 87 }; |
| 78 | 88 |
| 79 void PageConsoleAgent::addInspectedNode(ErrorString* errorString, int nodeId) | 89 void PageConsoleAgent::addInspectedNode(ErrorString* errorString, int nodeId) |
| 80 { | 90 { |
| 81 Node* node = m_inspectorDOMAgent->nodeForId(nodeId); | 91 Node* node = m_inspectorDOMAgent->nodeForId(nodeId); |
| 82 if (!node) { | 92 if (!node) { |
| 83 *errorString = "nodeId is not valid"; | 93 *errorString = "nodeId is not valid"; |
| 84 return; | 94 return; |
| 85 } | 95 } |
| 86 while (node->isInShadowTree()) { | 96 while (node->isInShadowTree()) { |
| 87 Node& ancestor = NodeTraversal::highestAncestorOrSelf(*node); | 97 Node& ancestor = NodeTraversal::highestAncestorOrSelf(*node); |
| 88 if (!ancestor.isShadowRoot() || toShadowRoot(ancestor).type() == ShadowR oot::AuthorShadowRoot) | 98 if (!ancestor.isShadowRoot() || toShadowRoot(ancestor).type() == ShadowR oot::AuthorShadowRoot) |
| 89 break; | 99 break; |
| 90 // User agent shadow root, keep climbing up. | 100 // User agent shadow root, keep climbing up. |
| 91 node = toShadowRoot(ancestor).host(); | 101 node = toShadowRoot(ancestor).host(); |
| 92 } | 102 } |
| 93 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(n ew InspectableNode(node))); | 103 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(n ew InspectableNode(node))); |
| 94 } | 104 } |
| 95 | 105 |
| 96 } // namespace blink | 106 } // namespace blink |
| OLD | NEW |