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

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

Issue 306053010: Tried using CrossThreadPersistent for workerDebuggerAgents (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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, points[0].pos(), ignorePointerEventsNone); 180 return hoveredNodeForPoint(frame, points[0].pos(), ignorePointerEventsNone);
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*);
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 HashSet<RefPtr<Element> > m_elements; 195 HashSet<RefPtr<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 Vector<Element*> elements; 214 Vector<Element*> elements;
214 for (HashSet<RefPtr<Element> >::iterator it = m_elements.begin(), end = m_el ements.end(); it != end; ++it) 215 for (HashSet<RefPtr<Element> >::iterator it = m_elements.begin(), end = m_el ements.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 }
226
221 String InspectorDOMAgent::toErrorString(ExceptionState& exceptionState) 227 String InspectorDOMAgent::toErrorString(ExceptionState& exceptionState)
222 { 228 {
223 if (exceptionState.hadException()) 229 if (exceptionState.hadException())
224 return DOMException::getErrorName(exceptionState.code()) + " " + excepti onState.message(); 230 return DOMException::getErrorName(exceptionState.code()) + " " + excepti onState.message();
225 return ""; 231 return "";
226 } 232 }
227 233
228 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay) 234 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay)
229 : InspectorBaseAgent<InspectorDOMAgent>("DOM") 235 : InspectorBaseAgent<InspectorDOMAgent>("DOM")
230 , m_pageAgent(pageAgent) 236 , m_pageAgent(pageAgent)
(...skipping 10 matching lines...) Expand all
241 247
242 InspectorDOMAgent::~InspectorDOMAgent() 248 InspectorDOMAgent::~InspectorDOMAgent()
243 { 249 {
244 reset(); 250 reset();
245 ASSERT(m_searchingForNode == NotSearching); 251 ASSERT(m_searchingForNode == NotSearching);
246 } 252 }
247 253
248 void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend) 254 void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend)
249 { 255 {
250 ASSERT(!m_frontend); 256 ASSERT(!m_frontend);
251 m_history = adoptPtr(new InspectorHistory()); 257 m_history = adoptPtrWillBeNoop(new InspectorHistory());
252 m_domEditor = adoptPtr(new DOMEditor(m_history.get())); 258 m_domEditor = adoptPtrWillBeNoop(new DOMEditor(m_history.get()));
253 259
254 m_frontend = frontend->dom(); 260 m_frontend = frontend->dom();
255 m_instrumentingAgents->setInspectorDOMAgent(this); 261 m_instrumentingAgents->setInspectorDOMAgent(this);
256 m_document = m_pageAgent->mainFrame()->document(); 262 m_document = m_pageAgent->mainFrame()->document();
257 } 263 }
258 264
259 void InspectorDOMAgent::clearFrontend() 265 void InspectorDOMAgent::clearFrontend()
260 { 266 {
261 ASSERT(m_frontend); 267 ASSERT(m_frontend);
262 268
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 } 1905 }
1900 1906
1901 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node) 1907 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node)
1902 { 1908 {
1903 int id = m_documentNodeToIdMap.get(node); 1909 int id = m_documentNodeToIdMap.get(node);
1904 // If node is not mapped yet -> ignore the event. 1910 // If node is not mapped yet -> ignore the event.
1905 if (!id) 1911 if (!id)
1906 return; 1912 return;
1907 1913
1908 if (!m_revalidateStyleAttrTask) 1914 if (!m_revalidateStyleAttrTask)
1909 m_revalidateStyleAttrTask = adoptPtr(new RevalidateStyleAttributeTask(th is)); 1915 m_revalidateStyleAttrTask = adoptPtrWillBeNoop(new RevalidateStyleAttrib uteTask(this));
1910 m_revalidateStyleAttrTask->scheduleFor(toElement(node)); 1916 m_revalidateStyleAttrTask->scheduleFor(toElement(node));
1911 } 1917 }
1912 1918
1913 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root) 1919 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root)
1914 { 1920 {
1915 if (!host->ownerDocument()) 1921 if (!host->ownerDocument())
1916 return; 1922 return;
1917 1923
1918 int hostId = m_documentNodeToIdMap.get(host); 1924 int hostId = m_documentNodeToIdMap.get(host);
1919 if (!hostId) 1925 if (!hostId)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt ring) 2093 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt ring)
2088 { 2094 {
2089 if (!m_documentNodeToIdMap.contains(m_document)) { 2095 if (!m_documentNodeToIdMap.contains(m_document)) {
2090 RefPtr<TypeBuilder::DOM::Node> root; 2096 RefPtr<TypeBuilder::DOM::Node> root;
2091 getDocument(errorString, root); 2097 getDocument(errorString, root);
2092 return errorString->isEmpty(); 2098 return errorString->isEmpty();
2093 } 2099 }
2094 return true; 2100 return true;
2095 } 2101 }
2096 2102
2103 void InspectorDOMAgent::trace(Visitor* visitor)
2104 {
2105 visitor->trace(m_pageAgent);
2106 visitor->trace(m_revalidateStyleAttrTask);
2107 visitor->trace(m_history);
2108 visitor->trace(m_domEditor);
2109 InspectorBaseAgent::trace(visitor);
2110 }
2111
2097 } // namespace WebCore 2112 } // namespace WebCore
2098 2113
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.h ('k') | Source/core/inspector/InspectorDOMDebuggerAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698