Chromium Code Reviews| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 WTF_MAKE_FAST_ALLOCATED; | 184 WTF_MAKE_FAST_ALLOCATED; |
| 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 | 190 |
| 191 private: | 191 private: |
| 192 InspectorDOMAgent* m_domAgent; | 192 InspectorDOMAgent* m_domAgent; |
| 193 Timer<RevalidateStyleAttributeTask> m_timer; | 193 Timer<RevalidateStyleAttributeTask> m_timer; |
| 194 HashSet<RefPtr<Element> > m_elements; | 194 WillBePersistentHeapHashSet<RefPtrWillBeMember<Element> > m_elements; |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 RevalidateStyleAttributeTask::RevalidateStyleAttributeTask(InspectorDOMAgent* do mAgent) | 197 RevalidateStyleAttributeTask::RevalidateStyleAttributeTask(InspectorDOMAgent* do mAgent) |
| 198 : m_domAgent(domAgent) | 198 : m_domAgent(domAgent) |
| 199 , m_timer(this, &RevalidateStyleAttributeTask::onTimer) | 199 , m_timer(this, &RevalidateStyleAttributeTask::onTimer) |
| 200 { | 200 { |
| 201 } | 201 } |
| 202 | 202 |
| 203 void RevalidateStyleAttributeTask::scheduleFor(Element* element) | 203 void RevalidateStyleAttributeTask::scheduleFor(Element* element) |
| 204 { | 204 { |
| 205 m_elements.add(element); | 205 m_elements.add(element); |
| 206 if (!m_timer.isActive()) | 206 if (!m_timer.isActive()) |
| 207 m_timer.startOneShot(0, FROM_HERE); | 207 m_timer.startOneShot(0, FROM_HERE); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*) | 210 void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*) |
| 211 { | 211 { |
| 212 // The timer is stopped on m_domAgent destruction, so this method will never be called after m_domAgent has been destroyed. | 212 // 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; | 213 WillBeHeapVector<RawPtrWillBeMember<Element> > elements; |
| 214 for (HashSet<RefPtr<Element> >::iterator it = m_elements.begin(), end = m_el ements.end(); it != end; ++it) | 214 for (WillBePersistentHeapHashSet<RefPtrWillBeMember<Element> >::iterator it = m_elements.begin(), end = m_elements.end(); it != end; ++it) |
| 215 elements.append(it->get()); | 215 elements.append(it->get()); |
| 216 m_domAgent->styleAttributeInvalidated(elements); | 216 m_domAgent->styleAttributeInvalidated(elements); |
| 217 | 217 |
| 218 m_elements.clear(); | 218 m_elements.clear(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 String InspectorDOMAgent::toErrorString(ExceptionState& exceptionState) | 221 String InspectorDOMAgent::toErrorString(ExceptionState& exceptionState) |
| 222 { | 222 { |
| 223 if (exceptionState.hadException()) | 223 if (exceptionState.hadException()) |
| 224 return DOMException::getErrorName(exceptionState.code()) + " " + excepti onState.message(); | 224 return DOMException::getErrorName(exceptionState.code()) + " " + excepti onState.message(); |
| 225 return ""; | 225 return ""; |
| 226 } | 226 } |
| 227 | 227 |
| 228 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay) | 228 InspectorDOMAgent::InspectorDOMAgent(InspectorPageAgent* pageAgent, InjectedScri ptManager* injectedScriptManager, InspectorOverlay* overlay) |
| 229 : InspectorBaseAgent<InspectorDOMAgent>("DOM") | 229 : InspectorBaseAgent<InspectorDOMAgent>("DOM") |
| 230 , m_pageAgent(pageAgent) | 230 , m_pageAgent(pageAgent) |
| 231 , m_injectedScriptManager(injectedScriptManager) | 231 , m_injectedScriptManager(injectedScriptManager) |
| 232 , m_overlay(overlay) | 232 , m_overlay(overlay) |
| 233 , m_frontend(0) | 233 , m_frontend(0) |
| 234 , m_domListener(0) | 234 , m_domListener(0) |
| 235 , m_documentNodeToIdMap(adoptPtrWillBeNoop(new NodeToIdMap())) | |
| 235 , m_lastNodeId(1) | 236 , m_lastNodeId(1) |
| 236 , m_searchingForNode(NotSearching) | 237 , m_searchingForNode(NotSearching) |
| 237 , m_suppressAttributeModifiedEvent(false) | 238 , m_suppressAttributeModifiedEvent(false) |
| 238 , m_listener(0) | 239 , m_listener(0) |
| 239 { | 240 { |
| 240 } | 241 } |
| 241 | 242 |
| 242 InspectorDOMAgent::~InspectorDOMAgent() | 243 InspectorDOMAgent::~InspectorDOMAgent() |
| 243 { | 244 { |
| 244 reset(); | 245 reset(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 bool childrenRequested = m_childrenRequested.contains(id); | 380 bool childrenRequested = m_childrenRequested.contains(id); |
| 380 if (childrenRequested) { | 381 if (childrenRequested) { |
| 381 // Unbind subtree known to client recursively. | 382 // Unbind subtree known to client recursively. |
| 382 m_childrenRequested.remove(id); | 383 m_childrenRequested.remove(id); |
| 383 Node* child = innerFirstChild(node); | 384 Node* child = innerFirstChild(node); |
| 384 while (child) { | 385 while (child) { |
| 385 unbind(child, nodesMap); | 386 unbind(child, nodesMap); |
| 386 child = innerNextSibling(child); | 387 child = innerNextSibling(child); |
| 387 } | 388 } |
| 388 } | 389 } |
| 389 if (nodesMap == &m_documentNodeToIdMap) | 390 if (nodesMap == m_documentNodeToIdMap.get()) |
| 390 m_cachedChildCount.remove(id); | 391 m_cachedChildCount.remove(id); |
| 391 } | 392 } |
| 392 | 393 |
| 393 Node* InspectorDOMAgent::assertNode(ErrorString* errorString, int nodeId) | 394 Node* InspectorDOMAgent::assertNode(ErrorString* errorString, int nodeId) |
| 394 { | 395 { |
| 395 Node* node = nodeForId(nodeId); | 396 Node* node = nodeForId(nodeId); |
| 396 if (!node) { | 397 if (!node) { |
| 397 *errorString = "Could not find node with given id"; | 398 *errorString = "Could not find node with given id"; |
| 398 return 0; | 399 return 0; |
| 399 } | 400 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 // Backward compatibility. Mark agent as enabled when it requests document. | 514 // Backward compatibility. Mark agent as enabled when it requests document. |
| 514 enable(errorString); | 515 enable(errorString); |
| 515 | 516 |
| 516 if (!m_document) { | 517 if (!m_document) { |
| 517 *errorString = "Document is not available"; | 518 *errorString = "Document is not available"; |
| 518 return; | 519 return; |
| 519 } | 520 } |
| 520 | 521 |
| 521 discardFrontendBindings(); | 522 discardFrontendBindings(); |
| 522 | 523 |
| 523 root = buildObjectForNode(m_document.get(), 2, &m_documentNodeToIdMap); | 524 root = buildObjectForNode(m_document.get(), 2, m_documentNodeToIdMap.get()); |
| 524 } | 525 } |
| 525 | 526 |
| 526 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth) | 527 void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth) |
| 527 { | 528 { |
| 528 Node* node = nodeForId(nodeId); | 529 Node* node = nodeForId(nodeId); |
| 529 if (!node || (!node->isElementNode() && !node->isDocumentNode() && !node->is DocumentFragment())) | 530 if (!node || (!node->isElementNode() && !node->isDocumentNode() && !node->is DocumentFragment())) |
| 530 return; | 531 return; |
| 531 | 532 |
| 532 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); | 533 NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId); |
| 533 | 534 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 548 | 549 |
| 549 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArrayFor ContainerChildren(node, depth, nodeMap); | 550 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArrayFor ContainerChildren(node, depth, nodeMap); |
| 550 m_frontend->setChildNodes(nodeId, children.release()); | 551 m_frontend->setChildNodes(nodeId, children.release()); |
| 551 } | 552 } |
| 552 | 553 |
| 553 void InspectorDOMAgent::discardFrontendBindings() | 554 void InspectorDOMAgent::discardFrontendBindings() |
| 554 { | 555 { |
| 555 if (m_history) | 556 if (m_history) |
| 556 m_history->reset(); | 557 m_history->reset(); |
| 557 m_searchResults.clear(); | 558 m_searchResults.clear(); |
| 558 m_documentNodeToIdMap.clear(); | 559 m_documentNodeToIdMap->clear(); |
| 559 m_idToNode.clear(); | 560 m_idToNode.clear(); |
| 560 releaseDanglingNodes(); | 561 releaseDanglingNodes(); |
| 561 m_childrenRequested.clear(); | 562 m_childrenRequested.clear(); |
| 562 m_cachedChildCount.clear(); | 563 m_cachedChildCount.clear(); |
| 563 if (m_revalidateStyleAttrTask) | 564 if (m_revalidateStyleAttrTask) |
| 564 m_revalidateStyleAttrTask->reset(); | 565 m_revalidateStyleAttrTask->reset(); |
| 565 } | 566 } |
| 566 | 567 |
| 567 Node* InspectorDOMAgent::nodeForId(int id) | 568 Node* InspectorDOMAgent::nodeForId(int id) |
| 568 { | 569 { |
| 569 if (!id) | 570 if (!id) |
| 570 return 0; | 571 return 0; |
| 571 | 572 |
| 572 HashMap<int, Node*>::iterator it = m_idToNode.find(id); | 573 WillBeHeapHashMap<int, RawPtrWillBeMember<Node> >::iterator it = m_idToNode. find(id); |
| 573 if (it != m_idToNode.end()) | 574 if (it != m_idToNode.end()) |
| 574 return it->value; | 575 return it->value; |
| 575 return 0; | 576 return 0; |
| 576 } | 577 } |
| 577 | 578 |
| 578 void InspectorDOMAgent::requestChildNodes(ErrorString* errorString, int nodeId, const int* depth) | 579 void InspectorDOMAgent::requestChildNodes(ErrorString* errorString, int nodeId, const int* depth) |
| 579 { | 580 { |
| 580 int sanitizedDepth; | 581 int sanitizedDepth; |
| 581 | 582 |
| 582 if (!depth) | 583 if (!depth) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 594 } | 595 } |
| 595 | 596 |
| 596 void InspectorDOMAgent::querySelector(ErrorString* errorString, int nodeId, cons t String& selectors, int* elementId) | 597 void InspectorDOMAgent::querySelector(ErrorString* errorString, int nodeId, cons t String& selectors, int* elementId) |
| 597 { | 598 { |
| 598 *elementId = 0; | 599 *elementId = 0; |
| 599 Node* node = assertNode(errorString, nodeId); | 600 Node* node = assertNode(errorString, nodeId); |
| 600 if (!node || !node->isContainerNode()) | 601 if (!node || !node->isContainerNode()) |
| 601 return; | 602 return; |
| 602 | 603 |
| 603 TrackExceptionState exceptionState; | 604 TrackExceptionState exceptionState; |
| 604 RefPtr<Element> element = toContainerNode(node)->querySelector(AtomicString( selectors), exceptionState); | 605 RefPtrWillBeRawPtr<Element> element = toContainerNode(node)->querySelector(A tomicString(selectors), exceptionState); |
| 605 if (exceptionState.hadException()) { | 606 if (exceptionState.hadException()) { |
| 606 *errorString = "DOM Error while querying"; | 607 *errorString = "DOM Error while querying"; |
| 607 return; | 608 return; |
| 608 } | 609 } |
| 609 | 610 |
| 610 if (element) | 611 if (element) |
| 611 *elementId = pushNodePathToFrontend(element.get()); | 612 *elementId = pushNodePathToFrontend(element.get()); |
| 612 } | 613 } |
| 613 | 614 |
| 614 void InspectorDOMAgent::querySelectorAll(ErrorString* errorString, int nodeId, c onst String& selectors, RefPtr<TypeBuilder::Array<int> >& result) | 615 void InspectorDOMAgent::querySelectorAll(ErrorString* errorString, int nodeId, c onst String& selectors, RefPtr<TypeBuilder::Array<int> >& result) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 629 for (unsigned i = 0; i < nodes->length(); ++i) | 630 for (unsigned i = 0; i < nodes->length(); ++i) |
| 630 result->addItem(pushNodePathToFrontend(nodes->item(i))); | 631 result->addItem(pushNodePathToFrontend(nodes->item(i))); |
| 631 } | 632 } |
| 632 | 633 |
| 633 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) | 634 int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush) |
| 634 { | 635 { |
| 635 ASSERT(nodeToPush); // Invalid input | 636 ASSERT(nodeToPush); // Invalid input |
| 636 | 637 |
| 637 if (!m_document) | 638 if (!m_document) |
| 638 return 0; | 639 return 0; |
| 639 if (!m_documentNodeToIdMap.contains(m_document)) | 640 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. |
| 641 if (!m_documentNodeToIdMap->contains(m_document.get())) | |
| 640 return 0; | 642 return 0; |
| 641 | 643 |
| 642 // Return id in case the node is known. | 644 // Return id in case the node is known. |
| 643 int result = m_documentNodeToIdMap.get(nodeToPush); | 645 int result = m_documentNodeToIdMap->get(nodeToPush); |
| 644 if (result) | 646 if (result) |
| 645 return result; | 647 return result; |
| 646 | 648 |
| 647 Node* node = nodeToPush; | 649 Node* node = nodeToPush; |
| 648 Vector<Node*> path; | 650 Vector<Node*> path; |
| 649 NodeToIdMap* danglingMap = 0; | 651 NodeToIdMap* danglingMap = 0; |
| 650 | 652 |
| 651 while (true) { | 653 while (true) { |
| 652 Node* parent = innerParentNode(node); | 654 Node* parent = innerParentNode(node); |
| 653 if (!parent) { | 655 if (!parent) { |
| 654 // Node being pushed is detached -> push subtree root. | 656 // Node being pushed is detached -> push subtree root. |
| 655 OwnPtr<NodeToIdMap> newMap = adoptPtr(new NodeToIdMap); | 657 OwnPtrWillBeRawPtr<NodeToIdMap> newMap = adoptPtrWillBeNoop(new Node ToIdMap); |
| 656 danglingMap = newMap.get(); | 658 danglingMap = newMap.get(); |
| 657 m_danglingNodeToIdMaps.append(newMap.release()); | 659 m_danglingNodeToIdMaps.append(newMap.release()); |
| 658 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeB uilder::Array<TypeBuilder::DOM::Node>::create(); | 660 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeB uilder::Array<TypeBuilder::DOM::Node>::create(); |
| 659 children->addItem(buildObjectForNode(node, 0, danglingMap)); | 661 children->addItem(buildObjectForNode(node, 0, danglingMap)); |
| 660 m_frontend->setChildNodes(0, children); | 662 m_frontend->setChildNodes(0, children); |
| 661 break; | 663 break; |
| 662 } else { | 664 } else { |
| 663 path.append(parent); | 665 path.append(parent); |
| 664 if (m_documentNodeToIdMap.get(parent)) | 666 if (m_documentNodeToIdMap->get(parent)) |
| 665 break; | 667 break; |
| 666 else | 668 node = parent; |
| 667 node = parent; | |
| 668 } | 669 } |
| 669 } | 670 } |
| 670 | 671 |
| 671 NodeToIdMap* map = danglingMap ? danglingMap : &m_documentNodeToIdMap; | 672 NodeToIdMap* map = danglingMap ? danglingMap : m_documentNodeToIdMap.get(); |
| 672 for (int i = path.size() - 1; i >= 0; --i) { | 673 for (int i = path.size() - 1; i >= 0; --i) { |
| 673 int nodeId = map->get(path.at(i)); | 674 int nodeId = map->get(path.at(i)); |
| 674 ASSERT(nodeId); | 675 ASSERT(nodeId); |
| 675 pushChildNodesToFrontend(nodeId); | 676 pushChildNodesToFrontend(nodeId); |
| 676 } | 677 } |
| 677 return map->get(nodeToPush); | 678 return map->get(nodeToPush); |
| 678 } | 679 } |
| 679 | 680 |
| 680 int InspectorDOMAgent::boundNodeId(Node* node) | 681 int InspectorDOMAgent::boundNodeId(Node* node) |
| 681 { | 682 { |
| 682 return m_documentNodeToIdMap.get(node); | 683 return m_documentNodeToIdMap->get(node); |
| 683 } | 684 } |
| 684 | 685 |
| 685 void InspectorDOMAgent::setAttributeValue(ErrorString* errorString, int elementI d, const String& name, const String& value) | 686 void InspectorDOMAgent::setAttributeValue(ErrorString* errorString, int elementI d, const String& name, const String& value) |
| 686 { | 687 { |
| 687 Element* element = assertEditableElement(errorString, elementId); | 688 Element* element = assertEditableElement(errorString, elementId); |
| 688 if (!element) | 689 if (!element) |
| 689 return; | 690 return; |
| 690 | 691 |
| 691 m_domEditor->setAttribute(element, name, value, errorString); | 692 m_domEditor->setAttribute(element, name, value, errorString); |
| 692 } | 693 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 if (exceptionState.hadException() || !nodeList) | 1034 if (exceptionState.hadException() || !nodeList) |
| 1034 continue; | 1035 continue; |
| 1035 | 1036 |
| 1036 unsigned size = nodeList->length(); | 1037 unsigned size = nodeList->length(); |
| 1037 for (unsigned i = 0; i < size; ++i) | 1038 for (unsigned i = 0; i < size; ++i) |
| 1038 resultCollector.add(nodeList->item(i)); | 1039 resultCollector.add(nodeList->item(i)); |
| 1039 } | 1040 } |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 *searchId = IdentifiersFactory::createIdentifier(); | 1043 *searchId = IdentifiersFactory::createIdentifier(); |
| 1043 Vector<RefPtr<Node> >* resultsIt = &m_searchResults.add(*searchId, Vector<Re fPtr<Node> >()).storedValue->value; | 1044 WillBeHeapVector<RefPtrWillBeMember<Node> >* resultsIt = &m_searchResults.ad d(*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.
| |
| 1044 | 1045 |
| 1045 for (ListHashSet<Node*>::iterator it = resultCollector.begin(); it != result Collector.end(); ++it) | 1046 for (ListHashSet<Node*>::iterator it = resultCollector.begin(); it != result Collector.end(); ++it) |
| 1046 resultsIt->append(*it); | 1047 resultsIt->append(*it); |
| 1047 | 1048 |
| 1048 *resultCount = resultsIt->size(); | 1049 *resultCount = resultsIt->size(); |
| 1049 } | 1050 } |
| 1050 | 1051 |
| 1051 void InspectorDOMAgent::getSearchResults(ErrorString* errorString, const String& searchId, int fromIndex, int toIndex, RefPtr<TypeBuilder::Array<int> >& nodeIds ) | 1052 void InspectorDOMAgent::getSearchResults(ErrorString* errorString, const String& searchId, int fromIndex, int toIndex, RefPtr<TypeBuilder::Array<int> >& nodeIds ) |
| 1052 { | 1053 { |
| 1053 SearchResults::iterator it = m_searchResults.find(searchId); | 1054 SearchResults::iterator it = m_searchResults.find(searchId); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1572 Attr* attribute = toAttr(node); | 1573 Attr* attribute = toAttr(node); |
| 1573 value->setName(attribute->name()); | 1574 value->setName(attribute->name()); |
| 1574 value->setValue(attribute->value()); | 1575 value->setValue(attribute->value()); |
| 1575 } else if (node->isShadowRoot()) { | 1576 } else if (node->isShadowRoot()) { |
| 1576 value->setShadowRootType(shadowRootType(toShadowRoot(node))); | 1577 value->setShadowRootType(shadowRootType(toShadowRoot(node))); |
| 1577 } | 1578 } |
| 1578 | 1579 |
| 1579 if (node->isContainerNode()) { | 1580 if (node->isContainerNode()) { |
| 1580 int nodeCount = innerChildNodeCount(node); | 1581 int nodeCount = innerChildNodeCount(node); |
| 1581 value->setChildNodeCount(nodeCount); | 1582 value->setChildNodeCount(nodeCount); |
| 1582 if (nodesMap == &m_documentNodeToIdMap) | 1583 if (nodesMap == m_documentNodeToIdMap) |
| 1583 m_cachedChildCount.set(id, nodeCount); | 1584 m_cachedChildCount.set(id, nodeCount); |
| 1584 if (forcePushChildren && !depth) | 1585 if (forcePushChildren && !depth) |
| 1585 depth = 1; | 1586 depth = 1; |
| 1586 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArra yForContainerChildren(node, depth, nodesMap); | 1587 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArra yForContainerChildren(node, depth, nodesMap); |
| 1587 if (children->length() > 0 || depth) // Push children along with shadow in any case. | 1588 if (children->length() > 0 || depth) // Push children along with shadow in any case. |
| 1588 value->setChildren(children.release()); | 1589 value->setChildren(children.release()); |
| 1589 } | 1590 } |
| 1590 | 1591 |
| 1591 return value.release(); | 1592 return value.release(); |
| 1592 } | 1593 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1747 if (enabled()) | 1748 if (enabled()) |
| 1748 m_frontend->documentUpdated(); | 1749 m_frontend->documentUpdated(); |
| 1749 } | 1750 } |
| 1750 | 1751 |
| 1751 void InspectorDOMAgent::invalidateFrameOwnerElement(LocalFrame* frame) | 1752 void InspectorDOMAgent::invalidateFrameOwnerElement(LocalFrame* frame) |
| 1752 { | 1753 { |
| 1753 Element* frameOwner = frame->document()->ownerElement(); | 1754 Element* frameOwner = frame->document()->ownerElement(); |
| 1754 if (!frameOwner) | 1755 if (!frameOwner) |
| 1755 return; | 1756 return; |
| 1756 | 1757 |
| 1757 int frameOwnerId = m_documentNodeToIdMap.get(frameOwner); | 1758 int frameOwnerId = m_documentNodeToIdMap->get(frameOwner); |
| 1758 if (!frameOwnerId) | 1759 if (!frameOwnerId) |
| 1759 return; | 1760 return; |
| 1760 | 1761 |
| 1761 // Re-add frame owner element together with its new children. | 1762 // Re-add frame owner element together with its new children. |
| 1762 int parentId = m_documentNodeToIdMap.get(innerParentNode(frameOwner)); | 1763 int parentId = m_documentNodeToIdMap->get(innerParentNode(frameOwner)); |
| 1763 m_frontend->childNodeRemoved(parentId, frameOwnerId); | 1764 m_frontend->childNodeRemoved(parentId, frameOwnerId); |
| 1764 unbind(frameOwner, &m_documentNodeToIdMap); | 1765 unbind(frameOwner, m_documentNodeToIdMap.get()); |
| 1765 | 1766 |
| 1766 RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(frameOwner, 0, &m_ documentNodeToIdMap); | 1767 RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(frameOwner, 0, m_d ocumentNodeToIdMap.get()); |
| 1767 Node* previousSibling = innerPreviousSibling(frameOwner); | 1768 Node* previousSibling = innerPreviousSibling(frameOwner); |
| 1768 int prevId = previousSibling ? m_documentNodeToIdMap.get(previousSibling) : 0; | 1769 int prevId = previousSibling ? m_documentNodeToIdMap->get(previousSibling) : 0; |
| 1769 m_frontend->childNodeInserted(parentId, prevId, value.release()); | 1770 m_frontend->childNodeInserted(parentId, prevId, value.release()); |
| 1770 } | 1771 } |
| 1771 | 1772 |
| 1772 void InspectorDOMAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* loader) | 1773 void InspectorDOMAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* loader) |
| 1773 { | 1774 { |
| 1774 // FIXME: If "frame" is always guarenteed to be in the same Page as loader-> frame() | 1775 // FIXME: If "frame" is always guarenteed to be in the same Page as loader-> frame() |
| 1775 // then all we need to check here is loader->frame()->isMainFrame() | 1776 // then all we need to check here is loader->frame()->isMainFrame() |
| 1776 // and we don't need "frame" at all. | 1777 // and we don't need "frame" at all. |
| 1777 LocalFrame* mainFrame = frame->page()->mainFrame(); | 1778 LocalFrame* mainFrame = frame->page()->mainFrame(); |
| 1778 if (loader->frame() != mainFrame) { | 1779 if (loader->frame() != mainFrame) { |
| 1779 invalidateFrameOwnerElement(loader->frame()); | 1780 invalidateFrameOwnerElement(loader->frame()); |
| 1780 return; | 1781 return; |
| 1781 } | 1782 } |
| 1782 | 1783 |
| 1783 setDocument(mainFrame->document()); | 1784 setDocument(mainFrame->document()); |
| 1784 } | 1785 } |
| 1785 | 1786 |
| 1786 void InspectorDOMAgent::didInsertDOMNode(Node* node) | 1787 void InspectorDOMAgent::didInsertDOMNode(Node* node) |
| 1787 { | 1788 { |
| 1788 if (isWhitespace(node)) | 1789 if (isWhitespace(node)) |
| 1789 return; | 1790 return; |
| 1790 | 1791 |
| 1791 // We could be attaching existing subtree. Forget the bindings. | 1792 // We could be attaching existing subtree. Forget the bindings. |
| 1792 unbind(node, &m_documentNodeToIdMap); | 1793 unbind(node, m_documentNodeToIdMap.get()); |
| 1793 | 1794 |
| 1794 ContainerNode* parent = node->parentNode(); | 1795 ContainerNode* parent = node->parentNode(); |
| 1795 if (!parent) | 1796 if (!parent) |
| 1796 return; | 1797 return; |
| 1797 int parentId = m_documentNodeToIdMap.get(parent); | 1798 int parentId = m_documentNodeToIdMap->get(parent); |
| 1798 // Return if parent is not mapped yet. | 1799 // Return if parent is not mapped yet. |
| 1799 if (!parentId) | 1800 if (!parentId) |
| 1800 return; | 1801 return; |
| 1801 | 1802 |
| 1802 if (!m_childrenRequested.contains(parentId)) { | 1803 if (!m_childrenRequested.contains(parentId)) { |
| 1803 // No children are mapped yet -> only notify on changes of child count. | 1804 // No children are mapped yet -> only notify on changes of child count. |
| 1804 int count = m_cachedChildCount.get(parentId) + 1; | 1805 int count = m_cachedChildCount.get(parentId) + 1; |
| 1805 m_cachedChildCount.set(parentId, count); | 1806 m_cachedChildCount.set(parentId, count); |
| 1806 m_frontend->childNodeCountUpdated(parentId, count); | 1807 m_frontend->childNodeCountUpdated(parentId, count); |
| 1807 } else { | 1808 } else { |
| 1808 // Children have been requested -> return value of a new child. | 1809 // Children have been requested -> return value of a new child. |
| 1809 Node* prevSibling = innerPreviousSibling(node); | 1810 Node* prevSibling = innerPreviousSibling(node); |
| 1810 int prevId = prevSibling ? m_documentNodeToIdMap.get(prevSibling) : 0; | 1811 int prevId = prevSibling ? m_documentNodeToIdMap->get(prevSibling) : 0; |
| 1811 RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(node, 0, &m_do cumentNodeToIdMap); | 1812 RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(node, 0, m_doc umentNodeToIdMap.get()); |
| 1812 m_frontend->childNodeInserted(parentId, prevId, value.release()); | 1813 m_frontend->childNodeInserted(parentId, prevId, value.release()); |
| 1813 } | 1814 } |
| 1814 } | 1815 } |
| 1815 | 1816 |
| 1816 void InspectorDOMAgent::willRemoveDOMNode(Node* node) | 1817 void InspectorDOMAgent::willRemoveDOMNode(Node* node) |
| 1817 { | 1818 { |
| 1818 if (isWhitespace(node)) | 1819 if (isWhitespace(node)) |
| 1819 return; | 1820 return; |
| 1820 | 1821 |
| 1821 ContainerNode* parent = node->parentNode(); | 1822 ContainerNode* parent = node->parentNode(); |
| 1822 | 1823 |
| 1823 // If parent is not mapped yet -> ignore the event. | 1824 // If parent is not mapped yet -> ignore the event. |
| 1824 if (!m_documentNodeToIdMap.contains(parent)) | 1825 if (!m_documentNodeToIdMap->contains(parent)) |
| 1825 return; | 1826 return; |
| 1826 | 1827 |
| 1827 int parentId = m_documentNodeToIdMap.get(parent); | 1828 int parentId = m_documentNodeToIdMap->get(parent); |
| 1828 | 1829 |
| 1829 if (!m_childrenRequested.contains(parentId)) { | 1830 if (!m_childrenRequested.contains(parentId)) { |
| 1830 // No children are mapped yet -> only notify on changes of child count. | 1831 // No children are mapped yet -> only notify on changes of child count. |
| 1831 int count = m_cachedChildCount.get(parentId) - 1; | 1832 int count = m_cachedChildCount.get(parentId) - 1; |
| 1832 m_cachedChildCount.set(parentId, count); | 1833 m_cachedChildCount.set(parentId, count); |
| 1833 m_frontend->childNodeCountUpdated(parentId, count); | 1834 m_frontend->childNodeCountUpdated(parentId, count); |
| 1834 } else { | 1835 } else { |
| 1835 m_frontend->childNodeRemoved(parentId, m_documentNodeToIdMap.get(node)); | 1836 m_frontend->childNodeRemoved(parentId, m_documentNodeToIdMap->get(node)) ; |
| 1836 } | 1837 } |
| 1837 unbind(node, &m_documentNodeToIdMap); | 1838 unbind(node, m_documentNodeToIdMap.get()); |
| 1838 } | 1839 } |
| 1839 | 1840 |
| 1840 void InspectorDOMAgent::willModifyDOMAttr(Element*, const AtomicString& oldValue , const AtomicString& newValue) | 1841 void InspectorDOMAgent::willModifyDOMAttr(Element*, const AtomicString& oldValue , const AtomicString& newValue) |
| 1841 { | 1842 { |
| 1842 m_suppressAttributeModifiedEvent = (oldValue == newValue); | 1843 m_suppressAttributeModifiedEvent = (oldValue == newValue); |
| 1843 } | 1844 } |
| 1844 | 1845 |
| 1845 void InspectorDOMAgent::didModifyDOMAttr(Element* element, const AtomicString& n ame, const AtomicString& value) | 1846 void InspectorDOMAgent::didModifyDOMAttr(Element* element, const AtomicString& n ame, const AtomicString& value) |
| 1846 { | 1847 { |
| 1847 bool shouldSuppressEvent = m_suppressAttributeModifiedEvent; | 1848 bool shouldSuppressEvent = m_suppressAttributeModifiedEvent; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1866 // If node is not mapped yet -> ignore the event. | 1867 // If node is not mapped yet -> ignore the event. |
| 1867 if (!id) | 1868 if (!id) |
| 1868 return; | 1869 return; |
| 1869 | 1870 |
| 1870 if (m_domListener) | 1871 if (m_domListener) |
| 1871 m_domListener->didModifyDOMAttr(element); | 1872 m_domListener->didModifyDOMAttr(element); |
| 1872 | 1873 |
| 1873 m_frontend->attributeRemoved(id, name); | 1874 m_frontend->attributeRemoved(id, name); |
| 1874 } | 1875 } |
| 1875 | 1876 |
| 1876 void InspectorDOMAgent::styleAttributeInvalidated(const Vector<Element*>& elemen ts) | 1877 void InspectorDOMAgent::styleAttributeInvalidated(const WillBeHeapVector<RawPtrW illBeMember<Element> >& elements) |
| 1877 { | 1878 { |
| 1878 RefPtr<TypeBuilder::Array<int> > nodeIds = TypeBuilder::Array<int>::create() ; | 1879 RefPtr<TypeBuilder::Array<int> > nodeIds = TypeBuilder::Array<int>::create() ; |
| 1879 for (unsigned i = 0, size = elements.size(); i < size; ++i) { | 1880 for (unsigned i = 0, size = elements.size(); i < size; ++i) { |
| 1880 Element* element = elements.at(i); | 1881 Element* element = elements.at(i); |
| 1881 int id = boundNodeId(element); | 1882 int id = boundNodeId(element); |
| 1882 // If node is not mapped yet -> ignore the event. | 1883 // If node is not mapped yet -> ignore the event. |
| 1883 if (!id) | 1884 if (!id) |
| 1884 continue; | 1885 continue; |
| 1885 | 1886 |
| 1886 if (m_domListener) | 1887 if (m_domListener) |
| 1887 m_domListener->didModifyDOMAttr(element); | 1888 m_domListener->didModifyDOMAttr(element); |
| 1888 nodeIds->addItem(id); | 1889 nodeIds->addItem(id); |
| 1889 } | 1890 } |
| 1890 m_frontend->inlineStyleInvalidated(nodeIds.release()); | 1891 m_frontend->inlineStyleInvalidated(nodeIds.release()); |
| 1891 } | 1892 } |
| 1892 | 1893 |
| 1893 void InspectorDOMAgent::characterDataModified(CharacterData* characterData) | 1894 void InspectorDOMAgent::characterDataModified(CharacterData* characterData) |
| 1894 { | 1895 { |
| 1895 int id = m_documentNodeToIdMap.get(characterData); | 1896 int id = m_documentNodeToIdMap->get(characterData); |
| 1896 if (!id) { | 1897 if (!id) { |
| 1897 // Push text node if it is being created. | 1898 // Push text node if it is being created. |
| 1898 didInsertDOMNode(characterData); | 1899 didInsertDOMNode(characterData); |
| 1899 return; | 1900 return; |
| 1900 } | 1901 } |
| 1901 m_frontend->characterDataModified(id, characterData->data()); | 1902 m_frontend->characterDataModified(id, characterData->data()); |
| 1902 } | 1903 } |
| 1903 | 1904 |
| 1904 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node) | 1905 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node) |
| 1905 { | 1906 { |
| 1906 int id = m_documentNodeToIdMap.get(node); | 1907 int id = m_documentNodeToIdMap->get(node); |
| 1907 // If node is not mapped yet -> ignore the event. | 1908 // If node is not mapped yet -> ignore the event. |
| 1908 if (!id) | 1909 if (!id) |
| 1909 return; | 1910 return; |
| 1910 | 1911 |
| 1911 if (!m_revalidateStyleAttrTask) | 1912 if (!m_revalidateStyleAttrTask) |
| 1912 m_revalidateStyleAttrTask = adoptPtr(new RevalidateStyleAttributeTask(th is)); | 1913 m_revalidateStyleAttrTask = adoptPtr(new RevalidateStyleAttributeTask(th is)); |
| 1913 m_revalidateStyleAttrTask->scheduleFor(toElement(node)); | 1914 m_revalidateStyleAttrTask->scheduleFor(toElement(node)); |
| 1914 } | 1915 } |
| 1915 | 1916 |
| 1916 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root) | 1917 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root) |
| 1917 { | 1918 { |
| 1918 if (!host->ownerDocument()) | 1919 if (!host->ownerDocument()) |
| 1919 return; | 1920 return; |
| 1920 | 1921 |
| 1921 int hostId = m_documentNodeToIdMap.get(host); | 1922 int hostId = m_documentNodeToIdMap->get(host); |
| 1922 if (!hostId) | 1923 if (!hostId) |
| 1923 return; | 1924 return; |
| 1924 | 1925 |
| 1925 pushChildNodesToFrontend(hostId, 1); | 1926 pushChildNodesToFrontend(hostId, 1); |
| 1926 m_frontend->shadowRootPushed(hostId, buildObjectForNode(root, 0, &m_document NodeToIdMap)); | 1927 m_frontend->shadowRootPushed(hostId, buildObjectForNode(root, 0, m_documentN odeToIdMap.get())); |
| 1927 } | 1928 } |
| 1928 | 1929 |
| 1929 void InspectorDOMAgent::willPopShadowRoot(Element* host, ShadowRoot* root) | 1930 void InspectorDOMAgent::willPopShadowRoot(Element* host, ShadowRoot* root) |
| 1930 { | 1931 { |
| 1931 if (!host->ownerDocument()) | 1932 if (!host->ownerDocument()) |
| 1932 return; | 1933 return; |
| 1933 | 1934 |
| 1934 int hostId = m_documentNodeToIdMap.get(host); | 1935 int hostId = m_documentNodeToIdMap->get(host); |
| 1935 int rootId = m_documentNodeToIdMap.get(root); | 1936 int rootId = m_documentNodeToIdMap->get(root); |
| 1936 if (hostId && rootId) | 1937 if (hostId && rootId) |
| 1937 m_frontend->shadowRootPopped(hostId, rootId); | 1938 m_frontend->shadowRootPopped(hostId, rootId); |
| 1938 } | 1939 } |
| 1939 | 1940 |
| 1940 void InspectorDOMAgent::frameDocumentUpdated(LocalFrame* frame) | 1941 void InspectorDOMAgent::frameDocumentUpdated(LocalFrame* frame) |
| 1941 { | 1942 { |
| 1942 Document* document = frame->document(); | 1943 Document* document = frame->document(); |
| 1943 if (!document) | 1944 if (!document) |
| 1944 return; | 1945 return; |
| 1945 | 1946 |
| 1946 Page* page = frame->page(); | 1947 Page* page = frame->page(); |
| 1947 ASSERT(page); | 1948 ASSERT(page); |
| 1948 if (frame != page->mainFrame()) | 1949 if (frame != page->mainFrame()) |
| 1949 return; | 1950 return; |
| 1950 | 1951 |
| 1951 // Only update the main frame document, nested frame document updates are no t required | 1952 // Only update the main frame document, nested frame document updates are no t required |
| 1952 // (will be handled by invalidateFrameOwnerElement()). | 1953 // (will be handled by invalidateFrameOwnerElement()). |
| 1953 setDocument(document); | 1954 setDocument(document); |
| 1954 } | 1955 } |
| 1955 | 1956 |
| 1956 void InspectorDOMAgent::pseudoElementCreated(PseudoElement* pseudoElement) | 1957 void InspectorDOMAgent::pseudoElementCreated(PseudoElement* pseudoElement) |
| 1957 { | 1958 { |
| 1958 Element* parent = pseudoElement->parentOrShadowHostElement(); | 1959 Element* parent = pseudoElement->parentOrShadowHostElement(); |
| 1959 if (!parent) | 1960 if (!parent) |
| 1960 return; | 1961 return; |
| 1961 int parentId = m_documentNodeToIdMap.get(parent); | 1962 int parentId = m_documentNodeToIdMap->get(parent); |
| 1962 if (!parentId) | 1963 if (!parentId) |
| 1963 return; | 1964 return; |
| 1964 | 1965 |
| 1965 pushChildNodesToFrontend(parentId, 1); | 1966 pushChildNodesToFrontend(parentId, 1); |
| 1966 m_frontend->pseudoElementAdded(parentId, buildObjectForNode(pseudoElement, 0 , &m_documentNodeToIdMap)); | 1967 m_frontend->pseudoElementAdded(parentId, buildObjectForNode(pseudoElement, 0 , m_documentNodeToIdMap.get())); |
| 1967 } | 1968 } |
| 1968 | 1969 |
| 1969 void InspectorDOMAgent::pseudoElementDestroyed(PseudoElement* pseudoElement) | 1970 void InspectorDOMAgent::pseudoElementDestroyed(PseudoElement* pseudoElement) |
| 1970 { | 1971 { |
| 1971 int pseudoElementId = m_documentNodeToIdMap.get(pseudoElement); | 1972 int pseudoElementId = m_documentNodeToIdMap->get(pseudoElement); |
| 1972 if (!pseudoElementId) | 1973 if (!pseudoElementId) |
| 1973 return; | 1974 return; |
| 1974 | 1975 |
| 1975 // If a PseudoElement is bound, its parent element must be bound, too. | 1976 // If a PseudoElement is bound, its parent element must be bound, too. |
| 1976 Element* parent = pseudoElement->parentOrShadowHostElement(); | 1977 Element* parent = pseudoElement->parentOrShadowHostElement(); |
| 1977 ASSERT(parent); | 1978 ASSERT(parent); |
| 1978 int parentId = m_documentNodeToIdMap.get(parent); | 1979 int parentId = m_documentNodeToIdMap->get(parent); |
| 1979 ASSERT(parentId); | 1980 ASSERT(parentId); |
| 1980 | 1981 |
| 1981 unbind(pseudoElement, &m_documentNodeToIdMap); | 1982 unbind(pseudoElement, m_documentNodeToIdMap.get()); |
| 1982 m_frontend->pseudoElementRemoved(parentId, pseudoElementId); | 1983 m_frontend->pseudoElementRemoved(parentId, pseudoElementId); |
| 1983 } | 1984 } |
| 1984 | 1985 |
| 1985 static ShadowRoot* shadowRootForNode(Node* node, const String& type) | 1986 static ShadowRoot* shadowRootForNode(Node* node, const String& type) |
| 1986 { | 1987 { |
| 1987 if (!node->isElementNode()) | 1988 if (!node->isElementNode()) |
| 1988 return 0; | 1989 return 0; |
| 1989 if (type == "a") | 1990 if (type == "a") |
| 1990 return toElement(node)->shadowRoot(); | 1991 return toElement(node)->shadowRoot(); |
| 1991 if (type == "u") | 1992 if (type == "u") |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2082 | 2083 |
| 2083 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(S criptState::forMainWorld(frame)); | 2084 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(S criptState::forMainWorld(frame)); |
| 2084 if (injectedScript.isEmpty()) | 2085 if (injectedScript.isEmpty()) |
| 2085 return nullptr; | 2086 return nullptr; |
| 2086 | 2087 |
| 2087 return injectedScript.wrapNode(node, objectGroup); | 2088 return injectedScript.wrapNode(node, objectGroup); |
| 2088 } | 2089 } |
| 2089 | 2090 |
| 2090 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt ring) | 2091 bool InspectorDOMAgent::pushDocumentUponHandlelessOperation(ErrorString* errorSt ring) |
| 2091 { | 2092 { |
| 2092 if (!m_documentNodeToIdMap.contains(m_document)) { | 2093 // FIXME: Oilpan: .get will be unnecessary if m_document is a Member<>. |
| 2094 if (!m_documentNodeToIdMap->contains(m_document.get())) { | |
| 2093 RefPtr<TypeBuilder::DOM::Node> root; | 2095 RefPtr<TypeBuilder::DOM::Node> root; |
| 2094 getDocument(errorString, root); | 2096 getDocument(errorString, root); |
| 2095 return errorString->isEmpty(); | 2097 return errorString->isEmpty(); |
| 2096 } | 2098 } |
| 2097 return true; | 2099 return true; |
| 2098 } | 2100 } |
| 2099 | 2101 |
| 2100 } // namespace WebCore | 2102 } // namespace WebCore |
| 2101 | 2103 |
| OLD | NEW |