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

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: Rebased Created 6 years, 6 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> {
184 WTF_MAKE_FAST_ALLOCATED; 184 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
185 public: 185 public:
186 RevalidateStyleAttributeTask(InspectorDOMAgent*); 186 RevalidateStyleAttributeTask(InspectorDOMAgent*);
haraken 2014/06/19 05:49:53 Add explicit.
keishi 2014/07/24 02:15:02 Done.
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 for (unsigned i = 0; i < nodes->length(); ++i) 641 for (unsigned i = 0; i < nodes->length(); ++i)
635 result->addItem(pushNodePathToFrontend(nodes->item(i))); 642 result->addItem(pushNodePathToFrontend(nodes->item(i)));
636 } 643 }
637 644
638 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) 645 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush)
639 { 646 {
640 ASSERT(nodeToPush); // Invalid input 647 ASSERT(nodeToPush); // Invalid input
641 648
642 if (!m_document) 649 if (!m_document)
643 return 0; 650 return 0;
644 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. 651 if (!m_documentNodeToIdMap->contains(m_document))
645 if (!m_documentNodeToIdMap->contains(m_document.get()))
646 return 0; 652 return 0;
647 653
648 // Return id in case the node is known. 654 // Return id in case the node is known.
649 int result = m_documentNodeToIdMap->get(nodeToPush); 655 int result = m_documentNodeToIdMap->get(nodeToPush);
650 if (result) 656 if (result)
651 return result; 657 return result;
652 658
653 Node* node = nodeToPush; 659 Node* node = nodeToPush;
654 Vector<Node*> path; 660 Vector<Node*> path;
655 NodeToIdMap* danglingMap = 0; 661 NodeToIdMap* danglingMap = 0;
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 } 1915 }
1910 1916
1911 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node) 1917 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node)
1912 { 1918 {
1913 int id = m_documentNodeToIdMap->get(node); 1919 int id = m_documentNodeToIdMap->get(node);
1914 // If node is not mapped yet -> ignore the event. 1920 // If node is not mapped yet -> ignore the event.
1915 if (!id) 1921 if (!id)
1916 return; 1922 return;
1917 1923
1918 if (!m_revalidateStyleAttrTask) 1924 if (!m_revalidateStyleAttrTask)
1919 m_revalidateStyleAttrTask = adoptPtr(new RevalidateStyleAttributeTask(th is)); 1925 m_revalidateStyleAttrTask = adoptPtrWillBeNoop(new RevalidateStyleAttrib uteTask(this));
1920 m_revalidateStyleAttrTask->scheduleFor(toElement(node)); 1926 m_revalidateStyleAttrTask->scheduleFor(toElement(node));
1921 } 1927 }
1922 1928
1923 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root) 1929 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root)
1924 { 1930 {
1925 if (!host->ownerDocument()) 1931 if (!host->ownerDocument())
1926 return; 1932 return;
1927 1933
1928 int hostId = m_documentNodeToIdMap->get(host); 1934 int hostId = m_documentNodeToIdMap->get(host);
1929 if (!hostId) 1935 if (!hostId)
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 2095
2090 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(S criptState::forMainWorld(frame)); 2096 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(S criptState::forMainWorld(frame));
2091 if (injectedScript.isEmpty()) 2097 if (injectedScript.isEmpty())
2092 return nullptr; 2098 return nullptr;
2093 2099
2094 return injectedScript.wrapNode(node, objectGroup); 2100 return injectedScript.wrapNode(node, objectGroup);
2095 } 2101 }
2096 2102
2097 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt ring) 2103 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt ring)
2098 { 2104 {
2099 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. 2105 if (!m_documentNodeToIdMap->contains(m_document)) {
2100 if (!m_documentNodeToIdMap->contains(m_document.get())) {
2101 RefPtr<TypeBuilder::DOM::Node> root; 2106 RefPtr<TypeBuilder::DOM::Node> root;
2102 getDocument(errorString, root); 2107 getDocument(errorString, root);
2103 return errorString->isEmpty(); 2108 return errorString->isEmpty();
2104 } 2109 }
2105 return true; 2110 return true;
2106 } 2111 }
2107 2112
2108 void InspectorDOMAgent::trace(Visitor* visitor) 2113 void InspectorDOMAgent::trace(Visitor* visitor)
2109 { 2114 {
2110 visitor->trace(m_domListener); 2115 visitor->trace(m_domListener);
2111 visitor->trace(m_pageAgent); 2116 visitor->trace(m_pageAgent);
2117 visitor->trace(m_injectedScriptManager);
2112 #if ENABLE(OILPAN) 2118 #if ENABLE(OILPAN)
2113 visitor->trace(m_documentNodeToIdMap); 2119 visitor->trace(m_documentNodeToIdMap);
2114 visitor->trace(m_danglingNodeToIdMaps); 2120 visitor->trace(m_danglingNodeToIdMaps);
2115 visitor->trace(m_idToNode); 2121 visitor->trace(m_idToNode);
2116 #endif 2122 #endif
2117 visitor->trace(m_idToNodesMap); 2123 visitor->trace(m_idToNodesMap);
2118 visitor->trace(m_document); 2124 visitor->trace(m_document);
2125 visitor->trace(m_revalidateStyleAttrTask);
2119 visitor->trace(m_searchResults); 2126 visitor->trace(m_searchResults);
2120 visitor->trace(m_history); 2127 visitor->trace(m_history);
2121 visitor->trace(m_domEditor); 2128 visitor->trace(m_domEditor);
2122 visitor->trace(m_listener); 2129 visitor->trace(m_listener);
2123 InspectorBaseAgent::trace(visitor); 2130 InspectorBaseAgent::trace(visitor);
2124 } 2131 }
2125 2132
2126 } // namespace WebCore 2133 } // namespace WebCore
2127 2134
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698