Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Side by Side Diff: Source/core/inspector/InspectorDOMAgent.cpp

Issue 898593002: DevTools: use per-LocalFrame instrumenting agents instead of per-Page ones. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed assertion Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 276 }
277 277
278 void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend) 278 void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend)
279 { 279 {
280 ASSERT(!m_frontend); 280 ASSERT(!m_frontend);
281 m_history = adoptPtrWillBeNoop(new InspectorHistory()); 281 m_history = adoptPtrWillBeNoop(new InspectorHistory());
282 m_domEditor = adoptPtrWillBeNoop(new DOMEditor(m_history.get())); 282 m_domEditor = adoptPtrWillBeNoop(new DOMEditor(m_history.get()));
283 283
284 m_frontend = frontend->dom(); 284 m_frontend = frontend->dom();
285 m_instrumentingAgents->setInspectorDOMAgent(this); 285 m_instrumentingAgents->setInspectorDOMAgent(this);
286 m_document = m_pageAgent->mainFrame()->document(); 286 m_document = m_pageAgent->inspectedFrame()->document();
287 } 287 }
288 288
289 void InspectorDOMAgent::clearFrontend() 289 void InspectorDOMAgent::clearFrontend()
290 { 290 {
291 ASSERT(m_frontend); 291 ASSERT(m_frontend);
292 292
293 m_history.clear(); 293 m_history.clear();
294 m_domEditor.clear(); 294 m_domEditor.clear();
295 295
296 ErrorString error; 296 ErrorString error;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 return nullptr; 525 return nullptr;
526 } 526 }
527 527
528 return element; 528 return element;
529 } 529 }
530 530
531 void InspectorDOMAgent::innerEnable() 531 void InspectorDOMAgent::innerEnable()
532 { 532 {
533 m_state->setBoolean(DOMAgentState::domAgentEnabled, true); 533 m_state->setBoolean(DOMAgentState::domAgentEnabled, true);
534 m_document = nullptr; 534 m_document = nullptr;
535 setDocument(m_pageAgent->mainFrame()->document()); 535 setDocument(m_pageAgent->inspectedFrame()->document());
536 if (m_listener) 536 if (m_listener)
537 m_listener->domAgentWasEnabled(); 537 m_listener->domAgentWasEnabled();
538 } 538 }
539 539
540 void InspectorDOMAgent::enable(ErrorString*) 540 void InspectorDOMAgent::enable(ErrorString*)
541 { 541 {
542 if (enabled()) 542 if (enabled())
543 return; 543 return;
544 innerEnable(); 544 innerEnable();
545 } 545 }
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 } 1893 }
1894 1894
1895 bool InspectorDOMAgent::isWhitespace(Node* node) 1895 bool InspectorDOMAgent::isWhitespace(Node* node)
1896 { 1896 {
1897 //TODO: pull ignoreWhitespace setting from the frontend and use here. 1897 //TODO: pull ignoreWhitespace setting from the frontend and use here.
1898 return node && node->nodeType() == Node::TEXT_NODE && node->nodeValue().stri pWhiteSpace().length() == 0; 1898 return node && node->nodeType() == Node::TEXT_NODE && node->nodeValue().stri pWhiteSpace().length() == 0;
1899 } 1899 }
1900 1900
1901 void InspectorDOMAgent::domContentLoadedEventFired(LocalFrame* frame) 1901 void InspectorDOMAgent::domContentLoadedEventFired(LocalFrame* frame)
1902 { 1902 {
1903 if (!frame->isMainFrame()) 1903 if (frame != m_pageAgent->inspectedFrame())
1904 return; 1904 return;
1905 1905
1906 // Re-push document once it is loaded. 1906 // Re-push document once it is loaded.
1907 discardFrontendBindings(); 1907 discardFrontendBindings();
1908 if (enabled()) 1908 if (enabled())
1909 m_frontend->documentUpdated(); 1909 m_frontend->documentUpdated();
1910 } 1910 }
1911 1911
1912 void InspectorDOMAgent::invalidateFrameOwnerElement(LocalFrame* frame) 1912 void InspectorDOMAgent::invalidateFrameOwnerElement(LocalFrame* frame)
1913 { 1913 {
1914 HTMLFrameOwnerElement* frameOwner = frame->document()->ownerElement(); 1914 HTMLFrameOwnerElement* frameOwner = frame->document()->ownerElement();
1915 if (!frameOwner) 1915 if (!frameOwner)
1916 return; 1916 return;
1917 1917
1918 int frameOwnerId = m_documentNodeToIdMap->get(frameOwner); 1918 int frameOwnerId = m_documentNodeToIdMap->get(frameOwner);
1919 if (!frameOwnerId) 1919 if (!frameOwnerId)
1920 return; 1920 return;
1921 1921
1922 // Re-add frame owner element together with its new children. 1922 // Re-add frame owner element together with its new children.
1923 int parentId = m_documentNodeToIdMap->get(innerParentNode(frameOwner)); 1923 int parentId = m_documentNodeToIdMap->get(innerParentNode(frameOwner));
1924 m_frontend->childNodeRemoved(parentId, frameOwnerId); 1924 m_frontend->childNodeRemoved(parentId, frameOwnerId);
1925 unbind(frameOwner, m_documentNodeToIdMap.get()); 1925 unbind(frameOwner, m_documentNodeToIdMap.get());
1926 1926
1927 RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(frameOwner, 0, m_d ocumentNodeToIdMap.get()); 1927 RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(frameOwner, 0, m_d ocumentNodeToIdMap.get());
1928 Node* previousSibling = innerPreviousSibling(frameOwner); 1928 Node* previousSibling = innerPreviousSibling(frameOwner);
1929 int prevId = previousSibling ? m_documentNodeToIdMap->get(previousSibling) : 0; 1929 int prevId = previousSibling ? m_documentNodeToIdMap->get(previousSibling) : 0;
1930 m_frontend->childNodeInserted(parentId, prevId, value.release()); 1930 m_frontend->childNodeInserted(parentId, prevId, value.release());
1931 } 1931 }
1932 1932
1933 void InspectorDOMAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* loader) 1933 void InspectorDOMAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader)
1934 { 1934 {
1935 // FIXME: If "frame" is always guarenteed to be in the same Page as loader-> frame() 1935 LocalFrame* inspectedFrame = m_pageAgent->inspectedFrame();
1936 // then all we need to check here is loader->frame()->isMainFrame() 1936 if (loader->frame() != inspectedFrame) {
1937 // and we don't need "frame" at all.
1938 if (!frame->page()->mainFrame()->isLocalFrame())
1939 return;
1940 LocalFrame* mainFrame = frame->page()->deprecatedLocalMainFrame();
1941 if (loader->frame() != mainFrame) {
1942 invalidateFrameOwnerElement(loader->frame()); 1937 invalidateFrameOwnerElement(loader->frame());
1943 return; 1938 return;
1944 } 1939 }
1945 1940
1946 setDocument(mainFrame->document()); 1941 setDocument(inspectedFrame->document());
1947 } 1942 }
1948 1943
1949 void InspectorDOMAgent::didInsertDOMNode(Node* node) 1944 void InspectorDOMAgent::didInsertDOMNode(Node* node)
1950 { 1945 {
1951 if (isWhitespace(node)) 1946 if (isWhitespace(node))
1952 return; 1947 return;
1953 1948
1954 // We could be attaching existing subtree. Forget the bindings. 1949 // We could be attaching existing subtree. Forget the bindings.
1955 unbind(node, m_documentNodeToIdMap.get()); 1950 unbind(node, m_documentNodeToIdMap.get());
1956 1951
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 return; 2122 return;
2128 revalidateTask()->scheduleContentDistributionRevalidationFor(shadowHost); 2123 revalidateTask()->scheduleContentDistributionRevalidationFor(shadowHost);
2129 } 2124 }
2130 2125
2131 void InspectorDOMAgent::frameDocumentUpdated(LocalFrame* frame) 2126 void InspectorDOMAgent::frameDocumentUpdated(LocalFrame* frame)
2132 { 2127 {
2133 Document* document = frame->document(); 2128 Document* document = frame->document();
2134 if (!document) 2129 if (!document)
2135 return; 2130 return;
2136 2131
2137 Page* page = frame->page(); 2132 if (frame != m_pageAgent->inspectedFrame())
2138 ASSERT(page);
2139 if (frame != page->mainFrame())
2140 return; 2133 return;
2141 2134
2142 // Only update the main frame document, nested frame document updates are no t required 2135 // Only update the main frame document, nested frame document updates are no t required
2143 // (will be handled by invalidateFrameOwnerElement()). 2136 // (will be handled by invalidateFrameOwnerElement()).
2144 setDocument(document); 2137 setDocument(document);
2145 } 2138 }
2146 2139
2147 void InspectorDOMAgent::pseudoElementCreated(PseudoElement* pseudoElement) 2140 void InspectorDOMAgent::pseudoElementCreated(PseudoElement* pseudoElement)
2148 { 2141 {
2149 Element* parent = pseudoElement->parentOrShadowHostElement(); 2142 Element* parent = pseudoElement->parentOrShadowHostElement();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 result = TypeBuilder::Array<int>::create(); 2228 result = TypeBuilder::Array<int>::create();
2236 for (const auto& backendNode : *backendNodeIds) { 2229 for (const auto& backendNode : *backendNodeIds) {
2237 int backendNodeId; 2230 int backendNodeId;
2238 2231
2239 if (!(backendNode)->asNumber(&backendNodeId)) { 2232 if (!(backendNode)->asNumber(&backendNodeId)) {
2240 *errorString = "Invalid argument type"; 2233 *errorString = "Invalid argument type";
2241 return; 2234 return;
2242 } 2235 }
2243 2236
2244 Node* node = InspectorNodeIds::nodeForId(backendNodeId); 2237 Node* node = InspectorNodeIds::nodeForId(backendNodeId);
2245 if (node && node->document().page() == m_pageAgent->page()) 2238 if (node && node->document().frame()->instrumentingAgents() == m_pageAge nt->inspectedFrame()->instrumentingAgents())
2246 result->addItem(pushNodePathToFrontend(node)); 2239 result->addItem(pushNodePathToFrontend(node));
2247 else 2240 else
2248 result->addItem(0); 2241 result->addItem(0);
2249 } 2242 }
2250 } 2243 }
2251 2244
2252 void InspectorDOMAgent::getRelayoutBoundary(ErrorString* errorString, int nodeId , int* relayoutBoundaryNodeId) 2245 void InspectorDOMAgent::getRelayoutBoundary(ErrorString* errorString, int nodeId , int* relayoutBoundaryNodeId)
2253 { 2246 {
2254 Node* node = assertNode(errorString, nodeId); 2247 Node* node = assertNode(errorString, nodeId);
2255 if (!node) 2248 if (!node)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 visitor->trace(m_revalidateTask); 2296 visitor->trace(m_revalidateTask);
2304 visitor->trace(m_searchResults); 2297 visitor->trace(m_searchResults);
2305 #endif 2298 #endif
2306 visitor->trace(m_history); 2299 visitor->trace(m_history);
2307 visitor->trace(m_domEditor); 2300 visitor->trace(m_domEditor);
2308 visitor->trace(m_listener); 2301 visitor->trace(m_listener);
2309 InspectorBaseAgent::trace(visitor); 2302 InspectorBaseAgent::trace(visitor);
2310 } 2303 }
2311 2304
2312 } // namespace blink 2305 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorController.cpp ('k') | Source/core/inspector/InspectorDOMStorageAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698