Chromium Code Reviews| Index: Source/core/inspector/InspectorDOMAgent.cpp |
| diff --git a/Source/core/inspector/InspectorDOMAgent.cpp b/Source/core/inspector/InspectorDOMAgent.cpp |
| index 376ad6b3f13ac57ca389cad4c81741adce9a799f..e38727b53e329397da0c76338f4db1b003f15dfb 100644 |
| --- a/Source/core/inspector/InspectorDOMAgent.cpp |
| +++ b/Source/core/inspector/InspectorDOMAgent.cpp |
| @@ -191,7 +191,7 @@ public: |
| private: |
| InspectorDOMAgent* m_domAgent; |
| Timer<RevalidateStyleAttributeTask> m_timer; |
| - HashSet<RefPtr<Element> > m_elements; |
| + WillBePersistentHeapHashSet<RefPtrWillBeMember<Element> > m_elements; |
| }; |
| RevalidateStyleAttributeTask::RevalidateStyleAttributeTask(InspectorDOMAgent* domAgent) |
| @@ -210,8 +210,8 @@ void RevalidateStyleAttributeTask::scheduleFor(Element* element) |
| void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*) |
| { |
| // The timer is stopped on m_domAgent destruction, so this method will never be called after m_domAgent has been destroyed. |
| - Vector<Element*> elements; |
| - for (HashSet<RefPtr<Element> >::iterator it = m_elements.begin(), end = m_elements.end(); it != end; ++it) |
| + WillBeHeapVector<RawPtrWillBeMember<Element> > elements; |
| + for (WillBePersistentHeapHashSet<RefPtrWillBeMember<Element> >::iterator it = m_elements.begin(), end = m_elements.end(); it != end; ++it) |
| elements.append(it->get()); |
| m_domAgent->styleAttributeInvalidated(elements); |
| @@ -232,6 +232,7 @@ InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri |
| , m_overlay(overlay) |
| , m_frontend(0) |
| , m_domListener(0) |
| + , m_documentNodeToIdMap(adoptPtrWillBeNoop(new NodeToIdMap())) |
| , m_lastNodeId(1) |
| , m_searchingForNode(NotSearching) |
| , m_suppressAttributeModifiedEvent(false) |
| @@ -386,7 +387,7 @@ void InspectorDOMAgent::unbind(Node* node, NodeToIdMap* nodesMap) |
| child = innerNextSibling(child); |
| } |
| } |
| - if (nodesMap == &m_documentNodeToIdMap) |
| + if (nodesMap == m_documentNodeToIdMap.get()) |
| m_cachedChildCount.remove(id); |
| } |
| @@ -520,7 +521,7 @@ void InspectorDOMAgent::getDocument(ErrorString* errorString, RefPtr<TypeBuilder |
| discardFrontendBindings(); |
| - root = buildObjectForNode(m_document.get(), 2, &m_documentNodeToIdMap); |
| + root = buildObjectForNode(m_document.get(), 2, m_documentNodeToIdMap.get()); |
| } |
| void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth) |
| @@ -555,7 +556,7 @@ void InspectorDOMAgent::discardFrontendBindings() |
| if (m_history) |
| m_history->reset(); |
| m_searchResults.clear(); |
| - m_documentNodeToIdMap.clear(); |
| + m_documentNodeToIdMap->clear(); |
| m_idToNode.clear(); |
| releaseDanglingNodes(); |
| m_childrenRequested.clear(); |
| @@ -569,7 +570,7 @@ Node* InspectorDOMAgent::nodeForId(int id) |
| if (!id) |
| return 0; |
| - HashMap<int, Node*>::iterator it = m_idToNode.find(id); |
| + WillBeHeapHashMap<int, RawPtrWillBeMember<Node> >::iterator it = m_idToNode.find(id); |
| if (it != m_idToNode.end()) |
| return it->value; |
| return 0; |
| @@ -601,7 +602,7 @@ void InspectorDOMAgent::querySelector(ErrorString* errorString, int nodeId, cons |
| return; |
| TrackExceptionState exceptionState; |
| - RefPtr<Element> element = toContainerNode(node)->querySelector(AtomicString(selectors), exceptionState); |
| + RefPtrWillBeRawPtr<Element> element = toContainerNode(node)->querySelector(AtomicString(selectors), exceptionState); |
| if (exceptionState.hadException()) { |
| *errorString = "DOM Error while querying"; |
| return; |
| @@ -636,11 +637,12 @@ int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) |
| if (!m_document) |
| return 0; |
| - if (!m_documentNodeToIdMap.contains(m_document)) |
| + // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. |
| + if (!m_documentNodeToIdMap->contains(m_document.get())) |
| return 0; |
| // Return id in case the node is known. |
| - int result = m_documentNodeToIdMap.get(nodeToPush); |
| + int result = m_documentNodeToIdMap->get(nodeToPush); |
| if (result) |
| return result; |
| @@ -652,7 +654,7 @@ int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) |
| Node* parent = innerParentNode(node); |
| if (!parent) { |
| // Node being pushed is detached -> push subtree root. |
| - OwnPtr<NodeToIdMap> newMap = adoptPtr(new NodeToIdMap); |
| + OwnPtrWillBeRawPtr<NodeToIdMap> newMap = adoptPtrWillBeNoop(new NodeToIdMap); |
| danglingMap = newMap.get(); |
| m_danglingNodeToIdMaps.append(newMap.release()); |
| RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeBuilder::Array<TypeBuilder::DOM::Node>::create(); |
| @@ -661,14 +663,13 @@ int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) |
| break; |
| } else { |
| path.append(parent); |
| - if (m_documentNodeToIdMap.get(parent)) |
| + if (m_documentNodeToIdMap->get(parent)) |
| break; |
| - else |
| - node = parent; |
| + node = parent; |
| } |
| } |
| - NodeToIdMap* map = danglingMap ? danglingMap : &m_documentNodeToIdMap; |
| + NodeToIdMap* map = danglingMap ? danglingMap : m_documentNodeToIdMap.get(); |
| for (int i = path.size() - 1; i >= 0; --i) { |
| int nodeId = map->get(path.at(i)); |
| ASSERT(nodeId); |
| @@ -679,7 +680,7 @@ int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) |
| int InspectorDOMAgent::boundNodeId(Node* node) |
| { |
| - return m_documentNodeToIdMap.get(node); |
| + return m_documentNodeToIdMap->get(node); |
| } |
| void InspectorDOMAgent::setAttributeValue(ErrorString* errorString, int elementId, const String& name, const String& value) |
| @@ -1040,7 +1041,7 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim |
| } |
| *searchId = IdentifiersFactory::createIdentifier(); |
| - Vector<RefPtr<Node> >* resultsIt = &m_searchResults.add(*searchId, Vector<RefPtr<Node> >()).storedValue->value; |
| + WillBeHeapVector<RefPtrWillBeMember<Node> >* resultsIt = &m_searchResults.add(*searchId, WillBeHeapVector<RefPtrWillBeMember<Node> >()).storedValue->value; |
|
haraken
2014/06/06 07:17:04
Doesn't nullptr work?
tkent
2014/06/06 07:59:45
It's not a pointer.
|
| for (ListHashSet<Node*>::iterator it = resultCollector.begin(); it != resultCollector.end(); ++it) |
| resultsIt->append(*it); |
| @@ -1579,7 +1580,7 @@ PassRefPtr<TypeBuilder::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node* n |
| if (node->isContainerNode()) { |
| int nodeCount = innerChildNodeCount(node); |
| value->setChildNodeCount(nodeCount); |
| - if (nodesMap == &m_documentNodeToIdMap) |
| + if (nodesMap == m_documentNodeToIdMap) |
| m_cachedChildCount.set(id, nodeCount); |
| if (forcePushChildren && !depth) |
| depth = 1; |
| @@ -1754,18 +1755,18 @@ void InspectorDOMAgent::invalidateFrameOwnerElement(LocalFrame* frame) |
| if (!frameOwner) |
| return; |
| - int frameOwnerId = m_documentNodeToIdMap.get(frameOwner); |
| + int frameOwnerId = m_documentNodeToIdMap->get(frameOwner); |
| if (!frameOwnerId) |
| return; |
| // Re-add frame owner element together with its new children. |
| - int parentId = m_documentNodeToIdMap.get(innerParentNode(frameOwner)); |
| + int parentId = m_documentNodeToIdMap->get(innerParentNode(frameOwner)); |
| m_frontend->childNodeRemoved(parentId, frameOwnerId); |
| - unbind(frameOwner, &m_documentNodeToIdMap); |
| + unbind(frameOwner, m_documentNodeToIdMap.get()); |
| - RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(frameOwner, 0, &m_documentNodeToIdMap); |
| + RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(frameOwner, 0, m_documentNodeToIdMap.get()); |
| Node* previousSibling = innerPreviousSibling(frameOwner); |
| - int prevId = previousSibling ? m_documentNodeToIdMap.get(previousSibling) : 0; |
| + int prevId = previousSibling ? m_documentNodeToIdMap->get(previousSibling) : 0; |
| m_frontend->childNodeInserted(parentId, prevId, value.release()); |
| } |
| @@ -1789,12 +1790,12 @@ void InspectorDOMAgent::didInsertDOMNode(Node* node) |
| return; |
| // We could be attaching existing subtree. Forget the bindings. |
| - unbind(node, &m_documentNodeToIdMap); |
| + unbind(node, m_documentNodeToIdMap.get()); |
| ContainerNode* parent = node->parentNode(); |
| if (!parent) |
| return; |
| - int parentId = m_documentNodeToIdMap.get(parent); |
| + int parentId = m_documentNodeToIdMap->get(parent); |
| // Return if parent is not mapped yet. |
| if (!parentId) |
| return; |
| @@ -1807,8 +1808,8 @@ void InspectorDOMAgent::didInsertDOMNode(Node* node) |
| } else { |
| // Children have been requested -> return value of a new child. |
| Node* prevSibling = innerPreviousSibling(node); |
| - int prevId = prevSibling ? m_documentNodeToIdMap.get(prevSibling) : 0; |
| - RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(node, 0, &m_documentNodeToIdMap); |
| + int prevId = prevSibling ? m_documentNodeToIdMap->get(prevSibling) : 0; |
| + RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(node, 0, m_documentNodeToIdMap.get()); |
| m_frontend->childNodeInserted(parentId, prevId, value.release()); |
| } |
| } |
| @@ -1821,10 +1822,10 @@ void InspectorDOMAgent::willRemoveDOMNode(Node* node) |
| ContainerNode* parent = node->parentNode(); |
| // If parent is not mapped yet -> ignore the event. |
| - if (!m_documentNodeToIdMap.contains(parent)) |
| + if (!m_documentNodeToIdMap->contains(parent)) |
| return; |
| - int parentId = m_documentNodeToIdMap.get(parent); |
| + int parentId = m_documentNodeToIdMap->get(parent); |
| if (!m_childrenRequested.contains(parentId)) { |
| // No children are mapped yet -> only notify on changes of child count. |
| @@ -1832,9 +1833,9 @@ void InspectorDOMAgent::willRemoveDOMNode(Node* node) |
| m_cachedChildCount.set(parentId, count); |
| m_frontend->childNodeCountUpdated(parentId, count); |
| } else { |
| - m_frontend->childNodeRemoved(parentId, m_documentNodeToIdMap.get(node)); |
| + m_frontend->childNodeRemoved(parentId, m_documentNodeToIdMap->get(node)); |
| } |
| - unbind(node, &m_documentNodeToIdMap); |
| + unbind(node, m_documentNodeToIdMap.get()); |
| } |
| void InspectorDOMAgent::willModifyDOMAttr(Element*, const AtomicString& oldValue, const AtomicString& newValue) |
| @@ -1873,7 +1874,7 @@ void InspectorDOMAgent::didRemoveDOMAttr(Element* element, const AtomicString& n |
| m_frontend->attributeRemoved(id, name); |
| } |
| -void InspectorDOMAgent::styleAttributeInvalidated(const Vector<Element*>& elements) |
| +void InspectorDOMAgent::styleAttributeInvalidated(const WillBeHeapVector<RawPtrWillBeMember<Element> >& elements) |
| { |
| RefPtr<TypeBuilder::Array<int> > nodeIds = TypeBuilder::Array<int>::create(); |
| for (unsigned i = 0, size = elements.size(); i < size; ++i) { |
| @@ -1892,7 +1893,7 @@ void InspectorDOMAgent::styleAttributeInvalidated(const Vector<Element*>& elemen |
| void InspectorDOMAgent::characterDataModified(CharacterData* characterData) |
| { |
| - int id = m_documentNodeToIdMap.get(characterData); |
| + int id = m_documentNodeToIdMap->get(characterData); |
| if (!id) { |
| // Push text node if it is being created. |
| didInsertDOMNode(characterData); |
| @@ -1903,7 +1904,7 @@ void InspectorDOMAgent::characterDataModified(CharacterData* characterData) |
| void InspectorDOMAgent::didInvalidateStyleAttr(Node* node) |
| { |
| - int id = m_documentNodeToIdMap.get(node); |
| + int id = m_documentNodeToIdMap->get(node); |
| // If node is not mapped yet -> ignore the event. |
| if (!id) |
| return; |
| @@ -1918,12 +1919,12 @@ void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root) |
| if (!host->ownerDocument()) |
| return; |
| - int hostId = m_documentNodeToIdMap.get(host); |
| + int hostId = m_documentNodeToIdMap->get(host); |
| if (!hostId) |
| return; |
| pushChildNodesToFrontend(hostId, 1); |
| - m_frontend->shadowRootPushed(hostId, buildObjectForNode(root, 0, &m_documentNodeToIdMap)); |
| + m_frontend->shadowRootPushed(hostId, buildObjectForNode(root, 0, m_documentNodeToIdMap.get())); |
| } |
| void InspectorDOMAgent::willPopShadowRoot(Element* host, ShadowRoot* root) |
| @@ -1931,8 +1932,8 @@ void InspectorDOMAgent::willPopShadowRoot(Element* host, ShadowRoot* root) |
| if (!host->ownerDocument()) |
| return; |
| - int hostId = m_documentNodeToIdMap.get(host); |
| - int rootId = m_documentNodeToIdMap.get(root); |
| + int hostId = m_documentNodeToIdMap->get(host); |
| + int rootId = m_documentNodeToIdMap->get(root); |
| if (hostId && rootId) |
| m_frontend->shadowRootPopped(hostId, rootId); |
| } |
| @@ -1958,27 +1959,27 @@ void InspectorDOMAgent::pseudoElementCreated(PseudoElement* pseudoElement) |
| Element* parent = pseudoElement->parentOrShadowHostElement(); |
| if (!parent) |
| return; |
| - int parentId = m_documentNodeToIdMap.get(parent); |
| + int parentId = m_documentNodeToIdMap->get(parent); |
| if (!parentId) |
| return; |
| pushChildNodesToFrontend(parentId, 1); |
| - m_frontend->pseudoElementAdded(parentId, buildObjectForNode(pseudoElement, 0, &m_documentNodeToIdMap)); |
| + m_frontend->pseudoElementAdded(parentId, buildObjectForNode(pseudoElement, 0, m_documentNodeToIdMap.get())); |
| } |
| void InspectorDOMAgent::pseudoElementDestroyed(PseudoElement* pseudoElement) |
| { |
| - int pseudoElementId = m_documentNodeToIdMap.get(pseudoElement); |
| + int pseudoElementId = m_documentNodeToIdMap->get(pseudoElement); |
| if (!pseudoElementId) |
| return; |
| // If a PseudoElement is bound, its parent element must be bound, too. |
| Element* parent = pseudoElement->parentOrShadowHostElement(); |
| ASSERT(parent); |
| - int parentId = m_documentNodeToIdMap.get(parent); |
| + int parentId = m_documentNodeToIdMap->get(parent); |
| ASSERT(parentId); |
| - unbind(pseudoElement, &m_documentNodeToIdMap); |
| + unbind(pseudoElement, m_documentNodeToIdMap.get()); |
| m_frontend->pseudoElementRemoved(parentId, pseudoElementId); |
| } |
| @@ -2089,7 +2090,8 @@ PassRefPtr<TypeBuilder::Runtime::RemoteObject> InspectorDOMAgent::resolveNode(No |
| bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorString) |
| { |
| - if (!m_documentNodeToIdMap.contains(m_document)) { |
| + // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. |
| + if (!m_documentNodeToIdMap->contains(m_document.get())) { |
| RefPtr<TypeBuilder::DOM::Node> root; |
| getDocument(errorString, root); |
| return errorString->isEmpty(); |