| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 #include "wtf/Vector.h" | 93 #include "wtf/Vector.h" |
| 94 #include "wtf/text/CString.h" | 94 #include "wtf/text/CString.h" |
| 95 #include "wtf/text/StringBuilder.h" | 95 #include "wtf/text/StringBuilder.h" |
| 96 | 96 |
| 97 namespace blink { | 97 namespace blink { |
| 98 | 98 |
| 99 using namespace HTMLNames; | 99 using namespace HTMLNames; |
| 100 | 100 |
| 101 struct SameSizeAsNode : NODE_BASE_CLASSES { | 101 struct SameSizeAsNode : NODE_BASE_CLASSES { |
| 102 uint32_t m_nodeFlags; | 102 uint32_t m_nodeFlags; |
| 103 RawPtrWillBeMember<void*> m_willbeMember[4]; | 103 Member<void*> m_willbeMember[4]; |
| 104 void* m_pointer; | 104 void* m_pointer; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 static_assert(sizeof(Node) <= sizeof(SameSizeAsNode), "Node should stay small"); | 107 static_assert(sizeof(Node) <= sizeof(SameSizeAsNode), "Node should stay small"); |
| 108 | 108 |
| 109 #if !ENABLE(OILPAN) | 109 #if !ENABLE(OILPAN) |
| 110 void* Node::operator new(size_t size) | 110 void* Node::operator new(size_t size) |
| 111 { | 111 { |
| 112 ASSERT(isMainThread()); | 112 ASSERT(isMainThread()); |
| 113 return partitionAlloc(WTF::Partitions::nodePartition(), size, "blink::Node")
; | 113 return partitionAlloc(WTF::Partitions::nodePartition(), size, "blink::Node")
; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void Node::operator delete(void* ptr) | 116 void Node::operator delete(void* ptr) |
| 117 { | 117 { |
| 118 ASSERT(isMainThread()); | 118 ASSERT(isMainThread()); |
| 119 partitionFree(ptr); | 119 partitionFree(ptr); |
| 120 } | 120 } |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 #if DUMP_NODE_STATISTICS | 123 #if DUMP_NODE_STATISTICS |
| 124 using WeakNodeSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<Node>>; | 124 using WeakNodeSet = HeapHashSet<WeakMember<Node>>; |
| 125 static WeakNodeSet& liveNodeSet() | 125 static WeakNodeSet& liveNodeSet() |
| 126 { | 126 { |
| 127 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakNodeSet>, set, (adoptPtrWillB
eNoop(new WeakNodeSet()))); | 127 DEFINE_STATIC_LOCAL(Persistent<WeakNodeSet>, set, ((new WeakNodeSet()))); |
| 128 return *set; | 128 return *set; |
| 129 } | 129 } |
| 130 #endif | 130 #endif |
| 131 | 131 |
| 132 void Node::dumpStatistics() | 132 void Node::dumpStatistics() |
| 133 { | 133 { |
| 134 #if DUMP_NODE_STATISTICS | 134 #if DUMP_NODE_STATISTICS |
| 135 size_t nodesWithRareData = 0; | 135 size_t nodesWithRareData = 0; |
| 136 | 136 |
| 137 size_t elementNodes = 0; | 137 size_t elementNodes = 0; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 String Node::nodeValue() const | 380 String Node::nodeValue() const |
| 381 { | 381 { |
| 382 return String(); | 382 return String(); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void Node::setNodeValue(const String&) | 385 void Node::setNodeValue(const String&) |
| 386 { | 386 { |
| 387 // By default, setting nodeValue has no effect. | 387 // By default, setting nodeValue has no effect. |
| 388 } | 388 } |
| 389 | 389 |
| 390 PassRefPtrWillBeRawPtr<NodeList> Node::childNodes() | 390 RawPtr<NodeList> Node::childNodes() |
| 391 { | 391 { |
| 392 if (isContainerNode()) | 392 if (isContainerNode()) |
| 393 return ensureRareData().ensureNodeLists().ensureChildNodeList(toContaine
rNode(*this)); | 393 return ensureRareData().ensureNodeLists().ensureChildNodeList(toContaine
rNode(*this)); |
| 394 return ensureRareData().ensureNodeLists().ensureEmptyChildNodeList(*this); | 394 return ensureRareData().ensureNodeLists().ensureEmptyChildNodeList(*this); |
| 395 } | 395 } |
| 396 | 396 |
| 397 Node* Node::pseudoAwarePreviousSibling() const | 397 Node* Node::pseudoAwarePreviousSibling() const |
| 398 { | 398 { |
| 399 if (parentElement() && !previousSibling()) { | 399 if (parentElement() && !previousSibling()) { |
| 400 Element* parent = parentElement(); | 400 Element* parent = parentElement(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 Node& Node::treeRoot() const | 453 Node& Node::treeRoot() const |
| 454 { | 454 { |
| 455 if (isInTreeScope()) | 455 if (isInTreeScope()) |
| 456 return treeScope().rootNode(); | 456 return treeScope().rootNode(); |
| 457 const Node* node = this; | 457 const Node* node = this; |
| 458 while (node->parentNode()) | 458 while (node->parentNode()) |
| 459 node = node->parentNode(); | 459 node = node->parentNode(); |
| 460 return const_cast<Node&>(*node); | 460 return const_cast<Node&>(*node); |
| 461 } | 461 } |
| 462 | 462 |
| 463 PassRefPtrWillBeRawPtr<Node> Node::insertBefore(PassRefPtrWillBeRawPtr<Node> new
Child, Node* refChild, ExceptionState& exceptionState) | 463 RawPtr<Node> Node::insertBefore(RawPtr<Node> newChild, Node* refChild, Exception
State& exceptionState) |
| 464 { | 464 { |
| 465 if (isContainerNode()) | 465 if (isContainerNode()) |
| 466 return toContainerNode(this)->insertBefore(newChild, refChild, exception
State); | 466 return toContainerNode(this)->insertBefore(newChild, refChild, exception
State); |
| 467 | 467 |
| 468 exceptionState.throwDOMException(HierarchyRequestError, "This node type does
not support this method."); | 468 exceptionState.throwDOMException(HierarchyRequestError, "This node type does
not support this method."); |
| 469 return nullptr; | 469 return nullptr; |
| 470 } | 470 } |
| 471 | 471 |
| 472 PassRefPtrWillBeRawPtr<Node> Node::replaceChild(PassRefPtrWillBeRawPtr<Node> new
Child, PassRefPtrWillBeRawPtr<Node> oldChild, ExceptionState& exceptionState) | 472 RawPtr<Node> Node::replaceChild(RawPtr<Node> newChild, RawPtr<Node> oldChild, Ex
ceptionState& exceptionState) |
| 473 { | 473 { |
| 474 if (isContainerNode()) | 474 if (isContainerNode()) |
| 475 return toContainerNode(this)->replaceChild(newChild, oldChild, exception
State); | 475 return toContainerNode(this)->replaceChild(newChild, oldChild, exception
State); |
| 476 | 476 |
| 477 exceptionState.throwDOMException(HierarchyRequestError, "This node type doe
s not support this method."); | 477 exceptionState.throwDOMException(HierarchyRequestError, "This node type doe
s not support this method."); |
| 478 return nullptr; | 478 return nullptr; |
| 479 } | 479 } |
| 480 | 480 |
| 481 PassRefPtrWillBeRawPtr<Node> Node::removeChild(PassRefPtrWillBeRawPtr<Node> oldC
hild, ExceptionState& exceptionState) | 481 RawPtr<Node> Node::removeChild(RawPtr<Node> oldChild, ExceptionState& exceptionS
tate) |
| 482 { | 482 { |
| 483 if (isContainerNode()) | 483 if (isContainerNode()) |
| 484 return toContainerNode(this)->removeChild(oldChild, exceptionState); | 484 return toContainerNode(this)->removeChild(oldChild, exceptionState); |
| 485 | 485 |
| 486 exceptionState.throwDOMException(NotFoundError, "This node type does not sup
port this method."); | 486 exceptionState.throwDOMException(NotFoundError, "This node type does not sup
port this method."); |
| 487 return nullptr; | 487 return nullptr; |
| 488 } | 488 } |
| 489 | 489 |
| 490 PassRefPtrWillBeRawPtr<Node> Node::appendChild(PassRefPtrWillBeRawPtr<Node> newC
hild, ExceptionState& exceptionState) | 490 RawPtr<Node> Node::appendChild(RawPtr<Node> newChild, ExceptionState& exceptionS
tate) |
| 491 { | 491 { |
| 492 if (isContainerNode()) | 492 if (isContainerNode()) |
| 493 return toContainerNode(this)->appendChild(newChild, exceptionState); | 493 return toContainerNode(this)->appendChild(newChild, exceptionState); |
| 494 | 494 |
| 495 exceptionState.throwDOMException(HierarchyRequestError, "This node type does
not support this method."); | 495 exceptionState.throwDOMException(HierarchyRequestError, "This node type does
not support this method."); |
| 496 return nullptr; | 496 return nullptr; |
| 497 } | 497 } |
| 498 | 498 |
| 499 void Node::remove(ExceptionState& exceptionState) | 499 void Node::remove(ExceptionState& exceptionState) |
| 500 { | 500 { |
| 501 if (ContainerNode* parent = parentNode()) | 501 if (ContainerNode* parent = parentNode()) |
| 502 parent->removeChild(this, exceptionState); | 502 parent->removeChild(this, exceptionState); |
| 503 } | 503 } |
| 504 | 504 |
| 505 void Node::normalize() | 505 void Node::normalize() |
| 506 { | 506 { |
| 507 updateDistribution(); | 507 updateDistribution(); |
| 508 | 508 |
| 509 // Go through the subtree beneath us, normalizing all nodes. This means that | 509 // Go through the subtree beneath us, normalizing all nodes. This means that |
| 510 // any two adjacent text nodes are merged and any empty text nodes are remov
ed. | 510 // any two adjacent text nodes are merged and any empty text nodes are remov
ed. |
| 511 | 511 |
| 512 RefPtrWillBeRawPtr<Node> node = this; | 512 RawPtr<Node> node = this; |
| 513 while (Node* firstChild = node->firstChild()) | 513 while (Node* firstChild = node->firstChild()) |
| 514 node = firstChild; | 514 node = firstChild; |
| 515 while (node) { | 515 while (node) { |
| 516 if (node == this) | 516 if (node == this) |
| 517 break; | 517 break; |
| 518 | 518 |
| 519 if (node->nodeType() == TEXT_NODE) | 519 if (node->nodeType() == TEXT_NODE) |
| 520 node = toText(node)->mergeNextSiblingNodesIfPossible(); | 520 node = toText(node)->mergeNextSiblingNodesIfPossible(); |
| 521 else | 521 else |
| 522 node = NodeTraversal::nextPostOrder(*node); | 522 node = NodeTraversal::nextPostOrder(*node); |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 switch (nodeType()) { | 1324 switch (nodeType()) { |
| 1325 case TEXT_NODE: | 1325 case TEXT_NODE: |
| 1326 case CDATA_SECTION_NODE: | 1326 case CDATA_SECTION_NODE: |
| 1327 case COMMENT_NODE: | 1327 case COMMENT_NODE: |
| 1328 case PROCESSING_INSTRUCTION_NODE: | 1328 case PROCESSING_INSTRUCTION_NODE: |
| 1329 setNodeValue(text); | 1329 setNodeValue(text); |
| 1330 return; | 1330 return; |
| 1331 case ELEMENT_NODE: | 1331 case ELEMENT_NODE: |
| 1332 case DOCUMENT_FRAGMENT_NODE: { | 1332 case DOCUMENT_FRAGMENT_NODE: { |
| 1333 // FIXME: Merge this logic into replaceChildrenWithText. | 1333 // FIXME: Merge this logic into replaceChildrenWithText. |
| 1334 RefPtrWillBeRawPtr<ContainerNode> container = toContainerNode(this); | 1334 RawPtr<ContainerNode> container = toContainerNode(this); |
| 1335 | 1335 |
| 1336 // Note: This is an intentional optimization. | 1336 // Note: This is an intentional optimization. |
| 1337 // See crbug.com/352836 also. | 1337 // See crbug.com/352836 also. |
| 1338 // No need to do anything if the text is identical. | 1338 // No need to do anything if the text is identical. |
| 1339 if (container->hasOneTextChild() && toText(container->firstChild())->dat
a() == text) | 1339 if (container->hasOneTextChild() && toText(container->firstChild())->dat
a() == text) |
| 1340 return; | 1340 return; |
| 1341 | 1341 |
| 1342 ChildListMutationScope mutation(*this); | 1342 ChildListMutationScope mutation(*this); |
| 1343 // Note: This API will not insert empty text nodes: | 1343 // Note: This API will not insert empty text nodes: |
| 1344 // https://dom.spec.whatwg.org/#dom-node-textcontent | 1344 // https://dom.spec.whatwg.org/#dom-node-textcontent |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1375 const Node* start1 = attr1 ? attr1->ownerElement() : this; | 1375 const Node* start1 = attr1 ? attr1->ownerElement() : this; |
| 1376 const Node* start2 = attr2 ? attr2->ownerElement() : otherNode; | 1376 const Node* start2 = attr2 ? attr2->ownerElement() : otherNode; |
| 1377 | 1377 |
| 1378 // If either of start1 or start2 is null, then we are disconnected, since on
e of the nodes is | 1378 // If either of start1 or start2 is null, then we are disconnected, since on
e of the nodes is |
| 1379 // an orphaned attribute node. | 1379 // an orphaned attribute node. |
| 1380 if (!start1 || !start2) { | 1380 if (!start1 || !start2) { |
| 1381 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED
ING : DOCUMENT_POSITION_FOLLOWING; | 1381 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED
ING : DOCUMENT_POSITION_FOLLOWING; |
| 1382 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION
_SPECIFIC | direction; | 1382 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION
_SPECIFIC | direction; |
| 1383 } | 1383 } |
| 1384 | 1384 |
| 1385 WillBeHeapVector<RawPtrWillBeMember<const Node>, 16> chain1; | 1385 HeapVector<Member<const Node>, 16> chain1; |
| 1386 WillBeHeapVector<RawPtrWillBeMember<const Node>, 16> chain2; | 1386 HeapVector<Member<const Node>, 16> chain2; |
| 1387 if (attr1) | 1387 if (attr1) |
| 1388 chain1.append(attr1); | 1388 chain1.append(attr1); |
| 1389 if (attr2) | 1389 if (attr2) |
| 1390 chain2.append(attr2); | 1390 chain2.append(attr2); |
| 1391 | 1391 |
| 1392 if (attr1 && attr2 && start1 == start2 && start1) { | 1392 if (attr1 && attr2 && start1 == start2 && start1) { |
| 1393 // We are comparing two attributes on the same node. Crawl our attribute
map and see which one we hit first. | 1393 // We are comparing two attributes on the same node. Crawl our attribute
map and see which one we hit first. |
| 1394 const Element* owner1 = attr1->ownerElement(); | 1394 const Element* owner1 = attr1->ownerElement(); |
| 1395 AttributeCollection attributes = owner1->attributes(); | 1395 AttributeCollection attributes = owner1->attributes(); |
| 1396 for (const Attribute& attr : attributes) { | 1396 for (const Attribute& attr : attributes) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 showTreeAndMark(this, "*"); | 1565 showTreeAndMark(this, "*"); |
| 1566 } | 1566 } |
| 1567 | 1567 |
| 1568 void Node::showTreeForThisInFlatTree() const | 1568 void Node::showTreeForThisInFlatTree() const |
| 1569 { | 1569 { |
| 1570 showTreeAndMarkInFlatTree(this, "*"); | 1570 showTreeAndMarkInFlatTree(this, "*"); |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 void Node::showNodePathForThis() const | 1573 void Node::showNodePathForThis() const |
| 1574 { | 1574 { |
| 1575 WillBeHeapVector<RawPtrWillBeMember<const Node>, 16> chain; | 1575 HeapVector<Member<const Node>, 16> chain; |
| 1576 const Node* node = this; | 1576 const Node* node = this; |
| 1577 while (node->parentOrShadowHostNode()) { | 1577 while (node->parentOrShadowHostNode()) { |
| 1578 chain.append(node); | 1578 chain.append(node); |
| 1579 node = node->parentOrShadowHostNode(); | 1579 node = node->parentOrShadowHostNode(); |
| 1580 } | 1580 } |
| 1581 for (unsigned index = chain.size(); index > 0; --index) { | 1581 for (unsigned index = chain.size(); index > 0; --index) { |
| 1582 const Node* node = chain[index - 1]; | 1582 const Node* node = chain[index - 1]; |
| 1583 if (node->isShadowRoot()) { | 1583 if (node->isShadowRoot()) { |
| 1584 int count = 0; | 1584 int count = 0; |
| 1585 for (const ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowR
oot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) | 1585 for (const ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowR
oot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 | 1797 |
| 1798 oldDocument.markers().removeMarkers(this); | 1798 oldDocument.markers().removeMarkers(this); |
| 1799 oldDocument.updateRangesAfterNodeMovedToAnotherDocument(*this); | 1799 oldDocument.updateRangesAfterNodeMovedToAnotherDocument(*this); |
| 1800 if (oldDocument.frameHost() && !document().frameHost()) | 1800 if (oldDocument.frameHost() && !document().frameHost()) |
| 1801 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(*t
his); | 1801 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(*t
his); |
| 1802 else if (document().frameHost() && !oldDocument.frameHost()) | 1802 else if (document().frameHost() && !oldDocument.frameHost()) |
| 1803 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*thi
s); | 1803 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*thi
s); |
| 1804 else if (oldDocument.frameHost() != document().frameHost()) | 1804 else if (oldDocument.frameHost() != document().frameHost()) |
| 1805 EventHandlerRegistry::didMoveBetweenFrameHosts(*this, oldDocument.frameH
ost(), document().frameHost()); | 1805 EventHandlerRegistry::didMoveBetweenFrameHosts(*this, oldDocument.frameH
ost(), document().frameHost()); |
| 1806 | 1806 |
| 1807 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>* regi
stry = mutationObserverRegistry()) { | 1807 if (HeapVector<Member<MutationObserverRegistration>>* registry = mutationObs
erverRegistry()) { |
| 1808 for (size_t i = 0; i < registry->size(); ++i) { | 1808 for (size_t i = 0; i < registry->size(); ++i) { |
| 1809 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); | 1809 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); |
| 1810 } | 1810 } |
| 1811 } | 1811 } |
| 1812 | 1812 |
| 1813 if (transientMutationObserverRegistry()) { | 1813 if (transientMutationObserverRegistry()) { |
| 1814 for (MutationObserverRegistration* registration : *transientMutationObse
rverRegistry()) | 1814 for (MutationObserverRegistration* registration : *transientMutationObse
rverRegistry()) |
| 1815 document().addMutationObserverTypes(registration->mutationTypes()); | 1815 document().addMutationObserverTypes(registration->mutationTypes()); |
| 1816 } | 1816 } |
| 1817 } | 1817 } |
| 1818 | 1818 |
| 1819 bool Node::addEventListenerInternal(const AtomicString& eventType, PassRefPtrWil
lBeRawPtr<EventListener> listener, const EventListenerOptions& options) | 1819 bool Node::addEventListenerInternal(const AtomicString& eventType, RawPtr<EventL
istener> listener, const EventListenerOptions& options) |
| 1820 { | 1820 { |
| 1821 if (!EventTarget::addEventListenerInternal(eventType, listener, options)) | 1821 if (!EventTarget::addEventListenerInternal(eventType, listener, options)) |
| 1822 return false; | 1822 return false; |
| 1823 | 1823 |
| 1824 document().addListenerTypeIfNeeded(eventType); | 1824 document().addListenerTypeIfNeeded(eventType); |
| 1825 if (FrameHost* frameHost = document().frameHost()) | 1825 if (FrameHost* frameHost = document().frameHost()) |
| 1826 frameHost->eventHandlerRegistry().didAddEventHandler(*this, eventType, o
ptions); | 1826 frameHost->eventHandlerRegistry().didAddEventHandler(*this, eventType, o
ptions); |
| 1827 | 1827 |
| 1828 return true; | 1828 return true; |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 bool Node::removeEventListenerInternal(const AtomicString& eventType, PassRefPtr
WillBeRawPtr<EventListener> listener, const EventListenerOptions& options) | 1831 bool Node::removeEventListenerInternal(const AtomicString& eventType, RawPtr<Eve
ntListener> listener, const EventListenerOptions& options) |
| 1832 { | 1832 { |
| 1833 if (!EventTarget::removeEventListenerInternal(eventType, listener, options)) | 1833 if (!EventTarget::removeEventListenerInternal(eventType, listener, options)) |
| 1834 return false; | 1834 return false; |
| 1835 | 1835 |
| 1836 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of | 1836 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of |
| 1837 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 | 1837 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 |
| 1838 if (FrameHost* frameHost = document().frameHost()) | 1838 if (FrameHost* frameHost = document().frameHost()) |
| 1839 frameHost->eventHandlerRegistry().didRemoveEventHandler(*this, eventType
, options); | 1839 frameHost->eventHandlerRegistry().didRemoveEventHandler(*this, eventType
, options); |
| 1840 | 1840 |
| 1841 return true; | 1841 return true; |
| 1842 } | 1842 } |
| 1843 | 1843 |
| 1844 void Node::removeAllEventListeners() | 1844 void Node::removeAllEventListeners() |
| 1845 { | 1845 { |
| 1846 if (hasEventListeners() && document().frameHost()) | 1846 if (hasEventListeners() && document().frameHost()) |
| 1847 document().frameHost()->eventHandlerRegistry().didRemoveAllEventHandlers
(*this); | 1847 document().frameHost()->eventHandlerRegistry().didRemoveAllEventHandlers
(*this); |
| 1848 EventTarget::removeAllEventListeners(); | 1848 EventTarget::removeAllEventListeners(); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 void Node::removeAllEventListenersRecursively() | 1851 void Node::removeAllEventListenersRecursively() |
| 1852 { | 1852 { |
| 1853 ScriptForbiddenScope forbidScriptDuringRawIteration; | 1853 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 1854 for (Node& node : NodeTraversal::startsAt(this)) { | 1854 for (Node& node : NodeTraversal::startsAt(this)) { |
| 1855 node.removeAllEventListeners(); | 1855 node.removeAllEventListeners(); |
| 1856 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root->ol
derShadowRoot()) | 1856 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root->ol
derShadowRoot()) |
| 1857 root->removeAllEventListenersRecursively(); | 1857 root->removeAllEventListenersRecursively(); |
| 1858 } | 1858 } |
| 1859 } | 1859 } |
| 1860 | 1860 |
| 1861 using EventTargetDataMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<Node>, OwnPt
rWillBeMember<EventTargetData>>; | 1861 using EventTargetDataMap = HeapHashMap<WeakMember<Node>, Member<EventTargetData>
>; |
| 1862 static EventTargetDataMap& eventTargetDataMap() | 1862 static EventTargetDataMap& eventTargetDataMap() |
| 1863 { | 1863 { |
| 1864 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<EventTargetDataMap>, map, (adoptP
trWillBeNoop(new EventTargetDataMap()))); | 1864 DEFINE_STATIC_LOCAL(Persistent<EventTargetDataMap>, map, ((new EventTargetDa
taMap()))); |
| 1865 return *map; | 1865 return *map; |
| 1866 } | 1866 } |
| 1867 | 1867 |
| 1868 EventTargetData* Node::eventTargetData() | 1868 EventTargetData* Node::eventTargetData() |
| 1869 { | 1869 { |
| 1870 return hasEventTargetData() ? eventTargetDataMap().get(this) : nullptr; | 1870 return hasEventTargetData() ? eventTargetDataMap().get(this) : nullptr; |
| 1871 } | 1871 } |
| 1872 | 1872 |
| 1873 EventTargetData& Node::ensureEventTargetData() | 1873 EventTargetData& Node::ensureEventTargetData() |
| 1874 { | 1874 { |
| 1875 if (hasEventTargetData()) | 1875 if (hasEventTargetData()) |
| 1876 return *eventTargetDataMap().get(this); | 1876 return *eventTargetDataMap().get(this); |
| 1877 ASSERT(!eventTargetDataMap().contains(this)); | 1877 ASSERT(!eventTargetDataMap().contains(this)); |
| 1878 setHasEventTargetData(true); | 1878 setHasEventTargetData(true); |
| 1879 OwnPtrWillBeRawPtr<EventTargetData> data = adoptPtrWillBeNoop(new EventTarge
tData); | 1879 RawPtr<EventTargetData> data = (new EventTargetData); |
| 1880 EventTargetData* dataPtr = data.get(); | 1880 EventTargetData* dataPtr = data.get(); |
| 1881 eventTargetDataMap().set(this, data.release()); | 1881 eventTargetDataMap().set(this, data.release()); |
| 1882 return *dataPtr; | 1882 return *dataPtr; |
| 1883 } | 1883 } |
| 1884 | 1884 |
| 1885 #if !ENABLE(OILPAN) | 1885 #if !ENABLE(OILPAN) |
| 1886 void Node::clearEventTargetData() | 1886 void Node::clearEventTargetData() |
| 1887 { | 1887 { |
| 1888 eventTargetDataMap().remove(this); | 1888 eventTargetDataMap().remove(this); |
| 1889 #if ENABLE(ASSERT) | 1889 #if ENABLE(ASSERT) |
| 1890 setHasEventTargetData(false); | 1890 setHasEventTargetData(false); |
| 1891 #endif | 1891 #endif |
| 1892 } | 1892 } |
| 1893 #endif | 1893 #endif |
| 1894 | 1894 |
| 1895 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>* Node::mutati
onObserverRegistry() | 1895 HeapVector<Member<MutationObserverRegistration>>* Node::mutationObserverRegistry
() |
| 1896 { | 1896 { |
| 1897 if (!hasRareData()) | 1897 if (!hasRareData()) |
| 1898 return nullptr; | 1898 return nullptr; |
| 1899 NodeMutationObserverData* data = rareData()->mutationObserverData(); | 1899 NodeMutationObserverData* data = rareData()->mutationObserverData(); |
| 1900 if (!data) | 1900 if (!data) |
| 1901 return nullptr; | 1901 return nullptr; |
| 1902 return &data->registry; | 1902 return &data->registry; |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>>* Node::trans
ientMutationObserverRegistry() | 1905 HeapHashSet<Member<MutationObserverRegistration>>* Node::transientMutationObserv
erRegistry() |
| 1906 { | 1906 { |
| 1907 if (!hasRareData()) | 1907 if (!hasRareData()) |
| 1908 return nullptr; | 1908 return nullptr; |
| 1909 NodeMutationObserverData* data = rareData()->mutationObserverData(); | 1909 NodeMutationObserverData* data = rareData()->mutationObserverData(); |
| 1910 if (!data) | 1910 if (!data) |
| 1911 return nullptr; | 1911 return nullptr; |
| 1912 return &data->transientRegistry; | 1912 return &data->transientRegistry; |
| 1913 } | 1913 } |
| 1914 | 1914 |
| 1915 template<typename Registry> | 1915 template<typename Registry> |
| 1916 static inline void collectMatchingObserversForMutation(WillBeHeapHashMap<RefPtrW
illBeMember<MutationObserver>, MutationRecordDeliveryOptions>& observers, Regist
ry* registry, Node& target, MutationObserver::MutationType type, const Qualified
Name* attributeName) | 1916 static inline void collectMatchingObserversForMutation(HeapHashMap<Member<Mutati
onObserver>, MutationRecordDeliveryOptions>& observers, Registry* registry, Node
& target, MutationObserver::MutationType type, const QualifiedName* attributeNam
e) |
| 1917 { | 1917 { |
| 1918 if (!registry) | 1918 if (!registry) |
| 1919 return; | 1919 return; |
| 1920 | 1920 |
| 1921 for (const auto& registration : *registry) { | 1921 for (const auto& registration : *registry) { |
| 1922 if (registration->shouldReceiveMutationFrom(target, type, attributeName)
) { | 1922 if (registration->shouldReceiveMutationFrom(target, type, attributeName)
) { |
| 1923 MutationRecordDeliveryOptions deliveryOptions = registration->delive
ryOptions(); | 1923 MutationRecordDeliveryOptions deliveryOptions = registration->delive
ryOptions(); |
| 1924 WillBeHeapHashMap<RefPtrWillBeMember<MutationObserver>, MutationReco
rdDeliveryOptions>::AddResult result = observers.add(®istration->observer(),
deliveryOptions); | 1924 HeapHashMap<Member<MutationObserver>, MutationRecordDeliveryOptions>
::AddResult result = observers.add(®istration->observer(), deliveryOptions); |
| 1925 if (!result.isNewEntry) | 1925 if (!result.isNewEntry) |
| 1926 result.storedValue->value |= deliveryOptions; | 1926 result.storedValue->value |= deliveryOptions; |
| 1927 } | 1927 } |
| 1928 } | 1928 } |
| 1929 } | 1929 } |
| 1930 | 1930 |
| 1931 void Node::getRegisteredMutationObserversOfType(WillBeHeapHashMap<RefPtrWillBeMe
mber<MutationObserver>, MutationRecordDeliveryOptions>& observers, MutationObser
ver::MutationType type, const QualifiedName* attributeName) | 1931 void Node::getRegisteredMutationObserversOfType(HeapHashMap<Member<MutationObser
ver>, MutationRecordDeliveryOptions>& observers, MutationObserver::MutationType
type, const QualifiedName* attributeName) |
| 1932 { | 1932 { |
| 1933 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute
Name); | 1933 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute
Name); |
| 1934 collectMatchingObserversForMutation(observers, mutationObserverRegistry(), *
this, type, attributeName); | 1934 collectMatchingObserversForMutation(observers, mutationObserverRegistry(), *
this, type, attributeName); |
| 1935 collectMatchingObserversForMutation(observers, transientMutationObserverRegi
stry(), *this, type, attributeName); | 1935 collectMatchingObserversForMutation(observers, transientMutationObserverRegi
stry(), *this, type, attributeName); |
| 1936 ScriptForbiddenScope forbidScriptDuringRawIteration; | 1936 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 1937 for (Node* node = parentNode(); node; node = node->parentNode()) { | 1937 for (Node* node = parentNode(); node; node = node->parentNode()) { |
| 1938 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), *this, type, attributeName); | 1938 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), *this, type, attributeName); |
| 1939 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), *this, type, attributeName); | 1939 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), *this, type, attributeName); |
| 1940 } | 1940 } |
| 1941 } | 1941 } |
| 1942 | 1942 |
| 1943 void Node::registerMutationObserver(MutationObserver& observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) | 1943 void Node::registerMutationObserver(MutationObserver& observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) |
| 1944 { | 1944 { |
| 1945 MutationObserverRegistration* registration = nullptr; | 1945 MutationObserverRegistration* registration = nullptr; |
| 1946 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>& registry
= ensureRareData().ensureMutationObserverData().registry; | 1946 HeapVector<Member<MutationObserverRegistration>>& registry = ensureRareData(
).ensureMutationObserverData().registry; |
| 1947 for (size_t i = 0; i < registry.size(); ++i) { | 1947 for (size_t i = 0; i < registry.size(); ++i) { |
| 1948 if (®istry[i]->observer() == &observer) { | 1948 if (®istry[i]->observer() == &observer) { |
| 1949 registration = registry[i].get(); | 1949 registration = registry[i].get(); |
| 1950 registration->resetObservation(options, attributeFilter); | 1950 registration->resetObservation(options, attributeFilter); |
| 1951 } | 1951 } |
| 1952 } | 1952 } |
| 1953 | 1953 |
| 1954 if (!registration) { | 1954 if (!registration) { |
| 1955 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); | 1955 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); |
| 1956 registration = registry.last().get(); | 1956 registration = registry.last().get(); |
| 1957 } | 1957 } |
| 1958 | 1958 |
| 1959 document().addMutationObserverTypes(registration->mutationTypes()); | 1959 document().addMutationObserverTypes(registration->mutationTypes()); |
| 1960 } | 1960 } |
| 1961 | 1961 |
| 1962 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) | 1962 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) |
| 1963 { | 1963 { |
| 1964 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>* registry
= mutationObserverRegistry(); | 1964 HeapVector<Member<MutationObserverRegistration>>* registry = mutationObserve
rRegistry(); |
| 1965 ASSERT(registry); | 1965 ASSERT(registry); |
| 1966 if (!registry) | 1966 if (!registry) |
| 1967 return; | 1967 return; |
| 1968 | 1968 |
| 1969 size_t index = registry->find(registration); | 1969 size_t index = registry->find(registration); |
| 1970 ASSERT(index != kNotFound); | 1970 ASSERT(index != kNotFound); |
| 1971 if (index == kNotFound) | 1971 if (index == kNotFound) |
| 1972 return; | 1972 return; |
| 1973 | 1973 |
| 1974 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes | 1974 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes |
| 1975 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). | 1975 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). |
| 1976 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. | 1976 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. |
| 1977 RefPtrWillBeRawPtr<Node> protect(this); | 1977 RawPtr<Node> protect(this); |
| 1978 #if ENABLE(OILPAN) | 1978 #if ENABLE(OILPAN) |
| 1979 // The explicit dispose() is needed to have the registration | 1979 // The explicit dispose() is needed to have the registration |
| 1980 // object unregister itself promptly. | 1980 // object unregister itself promptly. |
| 1981 registration->dispose(); | 1981 registration->dispose(); |
| 1982 #endif | 1982 #endif |
| 1983 registry->remove(index); | 1983 registry->remove(index); |
| 1984 } | 1984 } |
| 1985 | 1985 |
| 1986 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis
tration) | 1986 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis
tration) |
| 1987 { | 1987 { |
| 1988 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra
tion); | 1988 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra
tion); |
| 1989 } | 1989 } |
| 1990 | 1990 |
| 1991 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg
istration) | 1991 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg
istration) |
| 1992 { | 1992 { |
| 1993 WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>>* transie
ntRegistry = transientMutationObserverRegistry(); | 1993 HeapHashSet<Member<MutationObserverRegistration>>* transientRegistry = trans
ientMutationObserverRegistry(); |
| 1994 ASSERT(transientRegistry); | 1994 ASSERT(transientRegistry); |
| 1995 if (!transientRegistry) | 1995 if (!transientRegistry) |
| 1996 return; | 1996 return; |
| 1997 | 1997 |
| 1998 ASSERT(transientRegistry->contains(registration)); | 1998 ASSERT(transientRegistry->contains(registration)); |
| 1999 transientRegistry->remove(registration); | 1999 transientRegistry->remove(registration); |
| 2000 } | 2000 } |
| 2001 | 2001 |
| 2002 void Node::notifyMutationObserversNodeWillDetach() | 2002 void Node::notifyMutationObserversNodeWillDetach() |
| 2003 { | 2003 { |
| 2004 if (!document().hasMutationObservers()) | 2004 if (!document().hasMutationObservers()) |
| 2005 return; | 2005 return; |
| 2006 | 2006 |
| 2007 ScriptForbiddenScope forbidScriptDuringRawIteration; | 2007 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 2008 for (Node* node = parentNode(); node; node = node->parentNode()) { | 2008 for (Node* node = parentNode(); node; node = node->parentNode()) { |
| 2009 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>*
registry = node->mutationObserverRegistry()) { | 2009 if (HeapVector<Member<MutationObserverRegistration>>* registry = node->m
utationObserverRegistry()) { |
| 2010 const size_t size = registry->size(); | 2010 const size_t size = registry->size(); |
| 2011 for (size_t i = 0; i < size; ++i) | 2011 for (size_t i = 0; i < size; ++i) |
| 2012 registry->at(i)->observedSubtreeNodeWillDetach(*this); | 2012 registry->at(i)->observedSubtreeNodeWillDetach(*this); |
| 2013 } | 2013 } |
| 2014 | 2014 |
| 2015 if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>>*
transientRegistry = node->transientMutationObserverRegistry()) { | 2015 if (HeapHashSet<Member<MutationObserverRegistration>>* transientRegistry
= node->transientMutationObserverRegistry()) { |
| 2016 for (auto& registration : *transientRegistry) | 2016 for (auto& registration : *transientRegistry) |
| 2017 registration->observedSubtreeNodeWillDetach(*this); | 2017 registration->observedSubtreeNodeWillDetach(*this); |
| 2018 } | 2018 } |
| 2019 } | 2019 } |
| 2020 } | 2020 } |
| 2021 | 2021 |
| 2022 void Node::handleLocalEvents(Event& event) | 2022 void Node::handleLocalEvents(Event& event) |
| 2023 { | 2023 { |
| 2024 if (!hasEventTargetData()) | 2024 if (!hasEventTargetData()) |
| 2025 return; | 2025 return; |
| 2026 | 2026 |
| 2027 if (isDisabledFormControl(this) && event.isMouseEvent()) | 2027 if (isDisabledFormControl(this) && event.isMouseEvent()) |
| 2028 return; | 2028 return; |
| 2029 | 2029 |
| 2030 fireEventListeners(&event); | 2030 fireEventListeners(&event); |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 void Node::dispatchScopedEvent(PassRefPtrWillBeRawPtr<Event> event) | 2033 void Node::dispatchScopedEvent(RawPtr<Event> event) |
| 2034 { | 2034 { |
| 2035 event->setTrusted(true); | 2035 event->setTrusted(true); |
| 2036 EventDispatcher::dispatchScopedEvent(*this, event->createMediator()); | 2036 EventDispatcher::dispatchScopedEvent(*this, event->createMediator()); |
| 2037 } | 2037 } |
| 2038 | 2038 |
| 2039 bool Node::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event) | 2039 bool Node::dispatchEventInternal(RawPtr<Event> event) |
| 2040 { | 2040 { |
| 2041 return EventDispatcher::dispatchEvent(*this, event->createMediator()); | 2041 return EventDispatcher::dispatchEvent(*this, event->createMediator()); |
| 2042 } | 2042 } |
| 2043 | 2043 |
| 2044 void Node::dispatchSubtreeModifiedEvent() | 2044 void Node::dispatchSubtreeModifiedEvent() |
| 2045 { | 2045 { |
| 2046 if (isInShadowTree()) | 2046 if (isInShadowTree()) |
| 2047 return; | 2047 return; |
| 2048 | 2048 |
| 2049 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 2049 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 2050 | 2050 |
| 2051 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) | 2051 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) |
| 2052 return; | 2052 return; |
| 2053 | 2053 |
| 2054 dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMSubtreeModified
, true)); | 2054 dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMSubtreeModified
, true)); |
| 2055 } | 2055 } |
| 2056 | 2056 |
| 2057 bool Node::dispatchDOMActivateEvent(int detail, PassRefPtrWillBeRawPtr<Event> un
derlyingEvent) | 2057 bool Node::dispatchDOMActivateEvent(int detail, RawPtr<Event> underlyingEvent) |
| 2058 { | 2058 { |
| 2059 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 2059 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 2060 RefPtrWillBeRawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActiv
ate, true, true, document().domWindow(), detail); | 2060 RawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActivate, true, t
rue, document().domWindow(), detail); |
| 2061 event->setUnderlyingEvent(underlyingEvent); | 2061 event->setUnderlyingEvent(underlyingEvent); |
| 2062 dispatchScopedEvent(event); | 2062 dispatchScopedEvent(event); |
| 2063 return event->defaultHandled(); | 2063 return event->defaultHandled(); |
| 2064 } | 2064 } |
| 2065 | 2065 |
| 2066 bool Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEvent, const Atomi
cString& eventType, | 2066 bool Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEvent, const Atomi
cString& eventType, |
| 2067 int detail, Node* relatedTarget) | 2067 int detail, Node* relatedTarget) |
| 2068 { | 2068 { |
| 2069 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, documen
t().domWindow(), nativeEvent, detail, relatedTarget); | 2069 RawPtr<MouseEvent> event = MouseEvent::create(eventType, document().domWindo
w(), nativeEvent, detail, relatedTarget); |
| 2070 return dispatchEvent(event); | 2070 return dispatchEvent(event); |
| 2071 } | 2071 } |
| 2072 | 2072 |
| 2073 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve
ntOptions eventOptions, SimulatedClickCreationScope scope) | 2073 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve
ntOptions eventOptions, SimulatedClickCreationScope scope) |
| 2074 { | 2074 { |
| 2075 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions
, scope); | 2075 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions
, scope); |
| 2076 } | 2076 } |
| 2077 | 2077 |
| 2078 void Node::dispatchInputEvent() | 2078 void Node::dispatchInputEvent() |
| 2079 { | 2079 { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2236 unsigned count = connectedSubframeCount(); | 2236 unsigned count = connectedSubframeCount(); |
| 2237 | 2237 |
| 2238 if (!count) | 2238 if (!count) |
| 2239 return; | 2239 return; |
| 2240 | 2240 |
| 2241 ScriptForbiddenScope forbidScriptDuringRawIteration; | 2241 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 2242 for (Node* node = parentOrShadowHostNode(); node; node = node->parentOrShado
wHostNode()) | 2242 for (Node* node = parentOrShadowHostNode(); node; node = node->parentOrShado
wHostNode()) |
| 2243 node->incrementConnectedSubframeCount(count); | 2243 node->incrementConnectedSubframeCount(count); |
| 2244 } | 2244 } |
| 2245 | 2245 |
| 2246 PassRefPtrWillBeRawPtr<StaticNodeList> Node::getDestinationInsertionPoints() | 2246 RawPtr<StaticNodeList> Node::getDestinationInsertionPoints() |
| 2247 { | 2247 { |
| 2248 updateDistribution(); | 2248 updateDistribution(); |
| 2249 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; | 2249 HeapVector<Member<InsertionPoint>, 8> insertionPoints; |
| 2250 collectDestinationInsertionPoints(*this, insertionPoints); | 2250 collectDestinationInsertionPoints(*this, insertionPoints); |
| 2251 WillBeHeapVector<RefPtrWillBeMember<Node>> filteredInsertionPoints; | 2251 HeapVector<Member<Node>> filteredInsertionPoints; |
| 2252 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 2252 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| 2253 InsertionPoint* insertionPoint = insertionPoints[i]; | 2253 InsertionPoint* insertionPoint = insertionPoints[i]; |
| 2254 ASSERT(insertionPoint->containingShadowRoot()); | 2254 ASSERT(insertionPoint->containingShadowRoot()); |
| 2255 if (!insertionPoint->containingShadowRoot()->isOpenOrV0()) | 2255 if (!insertionPoint->containingShadowRoot()->isOpenOrV0()) |
| 2256 break; | 2256 break; |
| 2257 filteredInsertionPoints.append(insertionPoint); | 2257 filteredInsertionPoints.append(insertionPoint); |
| 2258 } | 2258 } |
| 2259 return StaticNodeList::adopt(filteredInsertionPoints); | 2259 return StaticNodeList::adopt(filteredInsertionPoints); |
| 2260 } | 2260 } |
| 2261 | 2261 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2377 } | 2377 } |
| 2378 ASSERT_NOT_REACHED(); | 2378 ASSERT_NOT_REACHED(); |
| 2379 return 0; | 2379 return 0; |
| 2380 } | 2380 } |
| 2381 | 2381 |
| 2382 v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre
ationContext) | 2382 v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre
ationContext) |
| 2383 { | 2383 { |
| 2384 // It's possible that no one except for the new wrapper owns this object at | 2384 // It's possible that no one except for the new wrapper owns this object at |
| 2385 // this moment, so we have to prevent GC to collect this object until the | 2385 // this moment, so we have to prevent GC to collect this object until the |
| 2386 // object gets associated with the wrapper. | 2386 // object gets associated with the wrapper. |
| 2387 RefPtrWillBeRawPtr<Node> protect(this); | 2387 RawPtr<Node> protect(this); |
| 2388 | 2388 |
| 2389 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); | 2389 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); |
| 2390 | 2390 |
| 2391 const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); | 2391 const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); |
| 2392 | 2392 |
| 2393 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio
nContext, wrapperType, this); | 2393 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio
nContext, wrapperType, this); |
| 2394 if (UNLIKELY(wrapper.IsEmpty())) | 2394 if (UNLIKELY(wrapper.IsEmpty())) |
| 2395 return wrapper; | 2395 return wrapper; |
| 2396 | 2396 |
| 2397 wrapperType->installConditionallyEnabledProperties(wrapper, isolate); | 2397 wrapperType->installConditionallyEnabledProperties(wrapper, isolate); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2425 | 2425 |
| 2426 void showNodePath(const blink::Node* node) | 2426 void showNodePath(const blink::Node* node) |
| 2427 { | 2427 { |
| 2428 if (node) | 2428 if (node) |
| 2429 node->showNodePathForThis(); | 2429 node->showNodePathForThis(); |
| 2430 else | 2430 else |
| 2431 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2431 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
| 2432 } | 2432 } |
| 2433 | 2433 |
| 2434 #endif | 2434 #endif |
| OLD | NEW |