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

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: 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 1882 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->mainFrame())
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* mainFrame = m_pageAgent->mainFrame();
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) { 1936 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(mainFrame->document());
1947 } 1942 }
1948 1943
1949 void InspectorDOMAgent::didInsertDOMNode(Node* node) 1944 void InspectorDOMAgent::didInsertDOMNode(Node* node)
1950 { 1945 {
(...skipping 176 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->mainFrame())
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->mainFrame()->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

Powered by Google App Engine
This is Rietveld 408576698