| OLD | NEW |
| 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 Loading... |
| 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 FINAL : public NoBaseWillBeGarbageCollectedFi
nalized<RevalidateStyleAttributeTask> { |
| 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 #if ENABLE(OILPAN) |
| 226 visitor->trace(m_elements); |
| 227 #endif |
| 228 } |
| 229 |
| 221 String InspectorDOMAgent::toErrorString(ExceptionState& exceptionState) | 230 String InspectorDOMAgent::toErrorString(ExceptionState& exceptionState) |
| 222 { | 231 { |
| 223 if (exceptionState.hadException()) | 232 if (exceptionState.hadException()) |
| 224 return DOMException::getErrorName(exceptionState.code()) + " " + excepti
onState.message(); | 233 return DOMException::getErrorName(exceptionState.code()) + " " + excepti
onState.message(); |
| 225 return ""; | 234 return ""; |
| 226 } | 235 } |
| 227 | 236 |
| 228 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri
ptManager* injectedScriptManager, InspectorOverlay* overlay) | 237 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri
ptManager* injectedScriptManager, InspectorOverlay* overlay) |
| 229 : InspectorBaseAgent<InspectorDOMAgent>("DOM") | 238 : InspectorBaseAgent<InspectorDOMAgent>("DOM") |
| 230 , m_pageAgent(pageAgent) | 239 , m_pageAgent(pageAgent) |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 for (unsigned i = 0; i < nodes->length(); ++i) | 657 for (unsigned i = 0; i < nodes->length(); ++i) |
| 649 result->addItem(pushNodePathToFrontend(nodes->item(i))); | 658 result->addItem(pushNodePathToFrontend(nodes->item(i))); |
| 650 } | 659 } |
| 651 | 660 |
| 652 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) | 661 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) |
| 653 { | 662 { |
| 654 ASSERT(nodeToPush); // Invalid input | 663 ASSERT(nodeToPush); // Invalid input |
| 655 | 664 |
| 656 if (!m_document) | 665 if (!m_document) |
| 657 return 0; | 666 return 0; |
| 658 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. | 667 if (!m_documentNodeToIdMap->contains(m_document)) |
| 659 if (!m_documentNodeToIdMap->contains(m_document.get())) | |
| 660 return 0; | 668 return 0; |
| 661 | 669 |
| 662 // Return id in case the node is known. | 670 // Return id in case the node is known. |
| 663 int result = m_documentNodeToIdMap->get(nodeToPush); | 671 int result = m_documentNodeToIdMap->get(nodeToPush); |
| 664 if (result) | 672 if (result) |
| 665 return result; | 673 return result; |
| 666 | 674 |
| 667 Node* node = nodeToPush; | 675 Node* node = nodeToPush; |
| 668 WillBeHeapVector<RawPtrWillBeMember<Node> > path; | 676 WillBeHeapVector<RawPtrWillBeMember<Node> > path; |
| 669 NodeToIdMap* danglingMap = 0; | 677 NodeToIdMap* danglingMap = 0; |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 } | 1937 } |
| 1930 | 1938 |
| 1931 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node) | 1939 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node) |
| 1932 { | 1940 { |
| 1933 int id = m_documentNodeToIdMap->get(node); | 1941 int id = m_documentNodeToIdMap->get(node); |
| 1934 // If node is not mapped yet -> ignore the event. | 1942 // If node is not mapped yet -> ignore the event. |
| 1935 if (!id) | 1943 if (!id) |
| 1936 return; | 1944 return; |
| 1937 | 1945 |
| 1938 if (!m_revalidateStyleAttrTask) | 1946 if (!m_revalidateStyleAttrTask) |
| 1939 m_revalidateStyleAttrTask = adoptPtr(new RevalidateStyleAttributeTask(th
is)); | 1947 m_revalidateStyleAttrTask = adoptPtrWillBeNoop(new RevalidateStyleAttrib
uteTask(this)); |
| 1940 m_revalidateStyleAttrTask->scheduleFor(toElement(node)); | 1948 m_revalidateStyleAttrTask->scheduleFor(toElement(node)); |
| 1941 } | 1949 } |
| 1942 | 1950 |
| 1943 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root) | 1951 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root) |
| 1944 { | 1952 { |
| 1945 if (!host->ownerDocument()) | 1953 if (!host->ownerDocument()) |
| 1946 return; | 1954 return; |
| 1947 | 1955 |
| 1948 int hostId = m_documentNodeToIdMap->get(host); | 1956 int hostId = m_documentNodeToIdMap->get(host); |
| 1949 if (!hostId) | 1957 if (!hostId) |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 | 2117 |
| 2110 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(S
criptState::forMainWorld(frame)); | 2118 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(S
criptState::forMainWorld(frame)); |
| 2111 if (injectedScript.isEmpty()) | 2119 if (injectedScript.isEmpty()) |
| 2112 return nullptr; | 2120 return nullptr; |
| 2113 | 2121 |
| 2114 return injectedScript.wrapNode(node, objectGroup); | 2122 return injectedScript.wrapNode(node, objectGroup); |
| 2115 } | 2123 } |
| 2116 | 2124 |
| 2117 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt
ring) | 2125 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt
ring) |
| 2118 { | 2126 { |
| 2119 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. | 2127 if (!m_documentNodeToIdMap->contains(m_document)) { |
| 2120 if (!m_documentNodeToIdMap->contains(m_document.get())) { | |
| 2121 RefPtr<TypeBuilder::DOM::Node> root; | 2128 RefPtr<TypeBuilder::DOM::Node> root; |
| 2122 getDocument(errorString, root); | 2129 getDocument(errorString, root); |
| 2123 return errorString->isEmpty(); | 2130 return errorString->isEmpty(); |
| 2124 } | 2131 } |
| 2125 return true; | 2132 return true; |
| 2126 } | 2133 } |
| 2127 | 2134 |
| 2128 void InspectorDOMAgent::trace(Visitor* visitor) | 2135 void InspectorDOMAgent::trace(Visitor* visitor) |
| 2129 { | 2136 { |
| 2130 visitor->trace(m_domListener); | 2137 visitor->trace(m_domListener); |
| 2131 visitor->trace(m_pageAgent); | 2138 visitor->trace(m_pageAgent); |
| 2139 visitor->trace(m_injectedScriptManager); |
| 2132 #if ENABLE(OILPAN) | 2140 #if ENABLE(OILPAN) |
| 2133 visitor->trace(m_documentNodeToIdMap); | 2141 visitor->trace(m_documentNodeToIdMap); |
| 2134 visitor->trace(m_danglingNodeToIdMaps); | 2142 visitor->trace(m_danglingNodeToIdMaps); |
| 2135 visitor->trace(m_idToNode); | 2143 visitor->trace(m_idToNode); |
| 2136 visitor->trace(m_idToNodesMap); | 2144 visitor->trace(m_idToNodesMap); |
| 2137 visitor->trace(m_document); | 2145 visitor->trace(m_document); |
| 2146 visitor->trace(m_revalidateStyleAttrTask); |
| 2138 visitor->trace(m_searchResults); | 2147 visitor->trace(m_searchResults); |
| 2139 #endif | 2148 #endif |
| 2140 visitor->trace(m_history); | 2149 visitor->trace(m_history); |
| 2141 visitor->trace(m_domEditor); | 2150 visitor->trace(m_domEditor); |
| 2142 visitor->trace(m_listener); | 2151 visitor->trace(m_listener); |
| 2143 InspectorBaseAgent::trace(visitor); | 2152 InspectorBaseAgent::trace(visitor); |
| 2144 } | 2153 } |
| 2145 | 2154 |
| 2146 } // namespace blink | 2155 } // namespace blink |
| 2147 | 2156 |
| OLD | NEW |