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

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

Issue 323043002: Oilpan: Prepare moving InspectorAgent related classes to oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed Created 6 years, 5 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 static Node* hoveredNodeForEvent(LocalFrame* frame, const PlatformTouchEvent& ev ent, bool ignorePointerEventsNone) 175 static Node* hoveredNodeForEvent(LocalFrame* frame, const PlatformTouchEvent& ev ent, bool ignorePointerEventsNone)
176 { 176 {
177 const Vector<PlatformTouchPoint>& points = event.touchPoints(); 177 const Vector<PlatformTouchPoint>& points = event.touchPoints();
178 if (!points.size()) 178 if (!points.size())
179 return 0; 179 return 0;
180 return hoveredNodeForPoint(frame, roundedIntPoint(points[0].pos()), ignorePo interEventsNone); 180 return hoveredNodeForPoint(frame, roundedIntPoint(points[0].pos()), ignorePo interEventsNone);
181 } 181 }
182 182
183 class RevalidateStyleAttributeTask { 183 class RevalidateStyleAttributeTask : public NoBaseWillBeGarbageCollectedFinalize d<RevalidateStyleAttributeTask> {
haraken 2014/07/25 01:38:44 Add FINAL.
keishi 2014/07/25 03:56:28 Done.
184 WTF_MAKE_FAST_ALLOCATED; 184 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
185 public: 185 public:
186 RevalidateStyleAttributeTask(InspectorDOMAgent*); 186 explicit RevalidateStyleAttributeTask(InspectorDOMAgent*);
187 void scheduleFor(Element*); 187 void scheduleFor(Element*);
188 void reset() { m_timer.stop(); } 188 void reset() { m_timer.stop(); }
189 void onTimer(Timer<RevalidateStyleAttributeTask>*); 189 void onTimer(Timer<RevalidateStyleAttributeTask>*);
190 void trace(Visitor*);
190 191
191 private: 192 private:
192 InspectorDOMAgent* m_domAgent; 193 RawPtrWillBeMember<InspectorDOMAgent> m_domAgent;
193 Timer<RevalidateStyleAttributeTask> m_timer; 194 Timer<RevalidateStyleAttributeTask> m_timer;
194 WillBePersistentHeapHashSet<RefPtrWillBeMember<Element> > m_elements; 195 WillBeHeapHashSet<RefPtrWillBeMember<Element> > m_elements;
195 }; 196 };
196 197
197 RevalidateStyleAttributeTask::RevalidateStyleAttributeTask(InspectorDOMAgent* do mAgent) 198 RevalidateStyleAttributeTask::RevalidateStyleAttributeTask(InspectorDOMAgent* do mAgent)
198 : m_domAgent(domAgent) 199 : m_domAgent(domAgent)
199 , m_timer(this, &RevalidateStyleAttributeTask::onTimer) 200 , m_timer(this, &RevalidateStyleAttributeTask::onTimer)
200 { 201 {
201 } 202 }
202 203
203 void RevalidateStyleAttributeTask::scheduleFor(Element* element) 204 void RevalidateStyleAttributeTask::scheduleFor(Element* element)
204 { 205 {
205 m_elements.add(element); 206 m_elements.add(element);
206 if (!m_timer.isActive()) 207 if (!m_timer.isActive())
207 m_timer.startOneShot(0, FROM_HERE); 208 m_timer.startOneShot(0, FROM_HERE);
208 } 209 }
209 210
210 void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*) 211 void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*)
211 { 212 {
212 // The timer is stopped on m_domAgent destruction, so this method will never be called after m_domAgent has been destroyed. 213 // The timer is stopped on m_domAgent destruction, so this method will never be called after m_domAgent has been destroyed.
213 WillBeHeapVector<RawPtrWillBeMember<Element> > elements; 214 WillBeHeapVector<RawPtrWillBeMember<Element> > elements;
214 for (WillBePersistentHeapHashSet<RefPtrWillBeMember<Element> >::iterator it = m_elements.begin(), end = m_elements.end(); it != end; ++it) 215 for (WillBePersistentHeapHashSet<RefPtrWillBeMember<Element> >::iterator it = m_elements.begin(), end = m_elements.end(); it != end; ++it)
215 elements.append(it->get()); 216 elements.append(it->get());
216 m_domAgent->styleAttributeInvalidated(elements); 217 m_domAgent->styleAttributeInvalidated(elements);
217 218
218 m_elements.clear(); 219 m_elements.clear();
219 } 220 }
220 221
222 void RevalidateStyleAttributeTask::trace(Visitor* visitor)
223 {
224 visitor->trace(m_domAgent);
225 visitor->trace(m_elements);
226 }
227
221 String InspectorDOMAgent::toErrorString(ExceptionState& exceptionState) 228 String InspectorDOMAgent::toErrorString(ExceptionState& exceptionState)
222 { 229 {
223 if (exceptionState.hadException()) 230 if (exceptionState.hadException())
224 return DOMException::getErrorName(exceptionState.code()) + " " + excepti onState.message(); 231 return DOMException::getErrorName(exceptionState.code()) + " " + excepti onState.message();
225 return ""; 232 return "";
226 } 233 }
227 234
228 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay) 235 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay)
229 : InspectorBaseAgent<InspectorDOMAgent>("DOM") 236 : InspectorBaseAgent<InspectorDOMAgent>("DOM")
230 , m_pageAgent(pageAgent) 237 , m_pageAgent(pageAgent)
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 if (m_history) 580 if (m_history)
574 m_history->reset(); 581 m_history->reset();
575 m_searchResults.clear(); 582 m_searchResults.clear();
576 m_documentNodeToIdMap->clear(); 583 m_documentNodeToIdMap->clear();
577 m_idToNode.clear(); 584 m_idToNode.clear();
578 m_idToNodesMap.clear(); 585 m_idToNodesMap.clear();
579 releaseDanglingNodes(); 586 releaseDanglingNodes();
580 m_childrenRequested.clear(); 587 m_childrenRequested.clear();
581 m_cachedChildCount.clear(); 588 m_cachedChildCount.clear();
582 if (m_revalidateStyleAttrTask) 589 if (m_revalidateStyleAttrTask)
583 m_revalidateStyleAttrTask->reset(); 590 m_revalidateStyleAttrTask->reset();
haraken 2014/07/25 01:38:44 discardFrontendBindings() is called in a destructo
keishi 2014/07/25 03:56:28 reset() was wrapped in #!ENABLE(OILPAN) in r178895
584 } 591 }
585 592
586 Node* InspectorDOMAgent::nodeForId(int id) 593 Node* InspectorDOMAgent::nodeForId(int id)
587 { 594 {
588 if (!id) 595 if (!id)
589 return 0; 596 return 0;
590 597
591 WillBeHeapHashMap<int, RawPtrWillBeMember<Node> >::iterator it = m_idToNode. find(id); 598 WillBeHeapHashMap<int, RawPtrWillBeMember<Node> >::iterator it = m_idToNode. find(id);
592 if (it != m_idToNode.end()) 599 if (it != m_idToNode.end())
593 return it->value; 600 return it->value;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 for (unsigned i = 0; i < nodes->length(); ++i) 655 for (unsigned i = 0; i < nodes->length(); ++i)
649 result->addItem(pushNodePathToFrontend(nodes->item(i))); 656 result->addItem(pushNodePathToFrontend(nodes->item(i)));
650 } 657 }
651 658
652 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) 659 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush)
653 { 660 {
654 ASSERT(nodeToPush); // Invalid input 661 ASSERT(nodeToPush); // Invalid input
655 662
656 if (!m_document) 663 if (!m_document)
657 return 0; 664 return 0;
658 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. 665 if (!m_documentNodeToIdMap->contains(m_document))
659 if (!m_documentNodeToIdMap->contains(m_document.get()))
660 return 0; 666 return 0;
661 667
662 // Return id in case the node is known. 668 // Return id in case the node is known.
663 int result = m_documentNodeToIdMap->get(nodeToPush); 669 int result = m_documentNodeToIdMap->get(nodeToPush);
664 if (result) 670 if (result)
665 return result; 671 return result;
666 672
667 Node* node = nodeToPush; 673 Node* node = nodeToPush;
668 WillBeHeapVector<RawPtrWillBeMember<Node> > path; 674 WillBeHeapVector<RawPtrWillBeMember<Node> > path;
669 NodeToIdMap* danglingMap = 0; 675 NodeToIdMap* danglingMap = 0;
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 } 1935 }
1930 1936
1931 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node) 1937 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node)
1932 { 1938 {
1933 int id = m_documentNodeToIdMap->get(node); 1939 int id = m_documentNodeToIdMap->get(node);
1934 // If node is not mapped yet -> ignore the event. 1940 // If node is not mapped yet -> ignore the event.
1935 if (!id) 1941 if (!id)
1936 return; 1942 return;
1937 1943
1938 if (!m_revalidateStyleAttrTask) 1944 if (!m_revalidateStyleAttrTask)
1939 m_revalidateStyleAttrTask = adoptPtr(new RevalidateStyleAttributeTask(th is)); 1945 m_revalidateStyleAttrTask = adoptPtrWillBeNoop(new RevalidateStyleAttrib uteTask(this));
1940 m_revalidateStyleAttrTask->scheduleFor(toElement(node)); 1946 m_revalidateStyleAttrTask->scheduleFor(toElement(node));
1941 } 1947 }
1942 1948
1943 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root) 1949 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root)
1944 { 1950 {
1945 if (!host->ownerDocument()) 1951 if (!host->ownerDocument())
1946 return; 1952 return;
1947 1953
1948 int hostId = m_documentNodeToIdMap->get(host); 1954 int hostId = m_documentNodeToIdMap->get(host);
1949 if (!hostId) 1955 if (!hostId)
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 2115
2110 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(S criptState::forMainWorld(frame)); 2116 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(S criptState::forMainWorld(frame));
2111 if (injectedScript.isEmpty()) 2117 if (injectedScript.isEmpty())
2112 return nullptr; 2118 return nullptr;
2113 2119
2114 return injectedScript.wrapNode(node, objectGroup); 2120 return injectedScript.wrapNode(node, objectGroup);
2115 } 2121 }
2116 2122
2117 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt ring) 2123 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt ring)
2118 { 2124 {
2119 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. 2125 if (!m_documentNodeToIdMap->contains(m_document)) {
2120 if (!m_documentNodeToIdMap->contains(m_document.get())) {
2121 RefPtr<TypeBuilder::DOM::Node> root; 2126 RefPtr<TypeBuilder::DOM::Node> root;
2122 getDocument(errorString, root); 2127 getDocument(errorString, root);
2123 return errorString->isEmpty(); 2128 return errorString->isEmpty();
2124 } 2129 }
2125 return true; 2130 return true;
2126 } 2131 }
2127 2132
2128 void InspectorDOMAgent::trace(Visitor* visitor) 2133 void InspectorDOMAgent::trace(Visitor* visitor)
2129 { 2134 {
2130 visitor->trace(m_domListener); 2135 visitor->trace(m_domListener);
2131 visitor->trace(m_pageAgent); 2136 visitor->trace(m_pageAgent);
2137 visitor->trace(m_injectedScriptManager);
2132 #if ENABLE(OILPAN) 2138 #if ENABLE(OILPAN)
2133 visitor->trace(m_documentNodeToIdMap); 2139 visitor->trace(m_documentNodeToIdMap);
2134 visitor->trace(m_danglingNodeToIdMaps); 2140 visitor->trace(m_danglingNodeToIdMaps);
2135 visitor->trace(m_idToNode); 2141 visitor->trace(m_idToNode);
2136 #endif 2142 #endif
2137 visitor->trace(m_idToNodesMap); 2143 visitor->trace(m_idToNodesMap);
2138 visitor->trace(m_document); 2144 visitor->trace(m_document);
2145 visitor->trace(m_revalidateStyleAttrTask);
2139 visitor->trace(m_searchResults); 2146 visitor->trace(m_searchResults);
2140 visitor->trace(m_history); 2147 visitor->trace(m_history);
2141 visitor->trace(m_domEditor); 2148 visitor->trace(m_domEditor);
2142 visitor->trace(m_listener); 2149 visitor->trace(m_listener);
2143 InspectorBaseAgent::trace(visitor); 2150 InspectorBaseAgent::trace(visitor);
2144 } 2151 }
2145 2152
2146 } // namespace blink 2153 } // namespace blink
2147 2154
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698