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

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

Issue 892693006: Revert of DevTools: use per-LocalFrame instrumenting agents instead of per-Page ones. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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->inspectedFrame()->document(); 286 m_document = m_pageAgent->mainFrame()->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->inspectedFrame()->document()); 535 setDocument(m_pageAgent->mainFrame()->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 != m_pageAgent->inspectedFrame()) 1903 if (!frame->isMainFrame())
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*, DocumentLoader* loader) 1933 void InspectorDOMAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* loader)
1934 { 1934 {
1935 LocalFrame* inspectedFrame = m_pageAgent->inspectedFrame(); 1935 // FIXME: If "frame" is always guarenteed to be in the same Page as loader-> frame()
1936 if (loader->frame() != inspectedFrame) { 1936 // then all we need to check here is loader->frame()->isMainFrame()
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) {
1937 invalidateFrameOwnerElement(loader->frame()); 1942 invalidateFrameOwnerElement(loader->frame());
1938 return; 1943 return;
1939 } 1944 }
1940 1945
1941 setDocument(inspectedFrame->document()); 1946 setDocument(mainFrame->document());
1942 } 1947 }
1943 1948
1944 void InspectorDOMAgent::didInsertDOMNode(Node* node) 1949 void InspectorDOMAgent::didInsertDOMNode(Node* node)
1945 { 1950 {
1946 if (isWhitespace(node)) 1951 if (isWhitespace(node))
1947 return; 1952 return;
1948 1953
1949 // We could be attaching existing subtree. Forget the bindings. 1954 // We could be attaching existing subtree. Forget the bindings.
1950 unbind(node, m_documentNodeToIdMap.get()); 1955 unbind(node, m_documentNodeToIdMap.get());
1951 1956
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 return; 2127 return;
2123 revalidateTask()->scheduleContentDistributionRevalidationFor(shadowHost); 2128 revalidateTask()->scheduleContentDistributionRevalidationFor(shadowHost);
2124 } 2129 }
2125 2130
2126 void InspectorDOMAgent::frameDocumentUpdated(LocalFrame* frame) 2131 void InspectorDOMAgent::frameDocumentUpdated(LocalFrame* frame)
2127 { 2132 {
2128 Document* document = frame->document(); 2133 Document* document = frame->document();
2129 if (!document) 2134 if (!document)
2130 return; 2135 return;
2131 2136
2132 if (frame != m_pageAgent->inspectedFrame()) 2137 Page* page = frame->page();
2138 ASSERT(page);
2139 if (frame != page->mainFrame())
2133 return; 2140 return;
2134 2141
2135 // Only update the main frame document, nested frame document updates are no t required 2142 // Only update the main frame document, nested frame document updates are no t required
2136 // (will be handled by invalidateFrameOwnerElement()). 2143 // (will be handled by invalidateFrameOwnerElement()).
2137 setDocument(document); 2144 setDocument(document);
2138 } 2145 }
2139 2146
2140 void InspectorDOMAgent::pseudoElementCreated(PseudoElement* pseudoElement) 2147 void InspectorDOMAgent::pseudoElementCreated(PseudoElement* pseudoElement)
2141 { 2148 {
2142 Element* parent = pseudoElement->parentOrShadowHostElement(); 2149 Element* parent = pseudoElement->parentOrShadowHostElement();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 result = TypeBuilder::Array<int>::create(); 2235 result = TypeBuilder::Array<int>::create();
2229 for (const auto& backendNode : *backendNodeIds) { 2236 for (const auto& backendNode : *backendNodeIds) {
2230 int backendNodeId; 2237 int backendNodeId;
2231 2238
2232 if (!(backendNode)->asNumber(&backendNodeId)) { 2239 if (!(backendNode)->asNumber(&backendNodeId)) {
2233 *errorString = "Invalid argument type"; 2240 *errorString = "Invalid argument type";
2234 return; 2241 return;
2235 } 2242 }
2236 2243
2237 Node* node = InspectorNodeIds::nodeForId(backendNodeId); 2244 Node* node = InspectorNodeIds::nodeForId(backendNodeId);
2238 if (node && node->document().frame()->instrumentingAgents() == m_pageAge nt->inspectedFrame()->instrumentingAgents()) 2245 if (node && node->document().page() == m_pageAgent->page())
2239 result->addItem(pushNodePathToFrontend(node)); 2246 result->addItem(pushNodePathToFrontend(node));
2240 else 2247 else
2241 result->addItem(0); 2248 result->addItem(0);
2242 } 2249 }
2243 } 2250 }
2244 2251
2245 void InspectorDOMAgent::getRelayoutBoundary(ErrorString* errorString, int nodeId , int* relayoutBoundaryNodeId) 2252 void InspectorDOMAgent::getRelayoutBoundary(ErrorString* errorString, int nodeId , int* relayoutBoundaryNodeId)
2246 { 2253 {
2247 Node* node = assertNode(errorString, nodeId); 2254 Node* node = assertNode(errorString, nodeId);
2248 if (!node) 2255 if (!node)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 visitor->trace(m_revalidateTask); 2303 visitor->trace(m_revalidateTask);
2297 visitor->trace(m_searchResults); 2304 visitor->trace(m_searchResults);
2298 #endif 2305 #endif
2299 visitor->trace(m_history); 2306 visitor->trace(m_history);
2300 visitor->trace(m_domEditor); 2307 visitor->trace(m_domEditor);
2301 visitor->trace(m_listener); 2308 visitor->trace(m_listener);
2302 InspectorBaseAgent::trace(visitor); 2309 InspectorBaseAgent::trace(visitor);
2303 } 2310 }
2304 2311
2305 } // namespace blink 2312 } // 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