| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 #include "wtf/Vector.h" | 97 #include "wtf/Vector.h" |
| 98 #include "wtf/text/CString.h" | 98 #include "wtf/text/CString.h" |
| 99 #include "wtf/text/StringBuilder.h" | 99 #include "wtf/text/StringBuilder.h" |
| 100 | 100 |
| 101 namespace blink { | 101 namespace blink { |
| 102 | 102 |
| 103 using namespace HTMLNames; | 103 using namespace HTMLNames; |
| 104 | 104 |
| 105 struct SameSizeAsNode : NODE_BASE_CLASSES { | 105 struct SameSizeAsNode : NODE_BASE_CLASSES { |
| 106 uint32_t m_nodeFlags; | 106 uint32_t m_nodeFlags; |
| 107 RawPtrWillBeMember<void*> m_willbeMember[4]; | 107 Member<void*> m_willbeMember[4]; |
| 108 void* m_pointer; | 108 void* m_pointer; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 static_assert(sizeof(Node) <= sizeof(SameSizeAsNode), "Node should stay small"); | 111 static_assert(sizeof(Node) <= sizeof(SameSizeAsNode), "Node should stay small"); |
| 112 | 112 |
| 113 #if !ENABLE(OILPAN) | 113 #if !ENABLE(OILPAN) |
| 114 void* Node::operator new(size_t size) | 114 void* Node::operator new(size_t size) |
| 115 { | 115 { |
| 116 ASSERT(isMainThread()); | 116 ASSERT(isMainThread()); |
| 117 return partitionAlloc(WTF::Partitions::nodePartition(), size, "blink::Node")
; | 117 return partitionAlloc(WTF::Partitions::nodePartition(), size, "blink::Node")
; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void Node::operator delete(void* ptr) | 120 void Node::operator delete(void* ptr) |
| 121 { | 121 { |
| 122 ASSERT(isMainThread()); | 122 ASSERT(isMainThread()); |
| 123 partitionFree(ptr); | 123 partitionFree(ptr); |
| 124 } | 124 } |
| 125 #endif | 125 #endif |
| 126 | 126 |
| 127 #if DUMP_NODE_STATISTICS | 127 #if DUMP_NODE_STATISTICS |
| 128 using WeakNodeSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<Node>>; | 128 using WeakNodeSet = HeapHashSet<WeakMember<Node>>; |
| 129 static WeakNodeSet& liveNodeSet() | 129 static WeakNodeSet& liveNodeSet() |
| 130 { | 130 { |
| 131 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakNodeSet>, set, (adoptPtrWillB
eNoop(new WeakNodeSet()))); | 131 DEFINE_STATIC_LOCAL(Persistent<WeakNodeSet>, set, (new WeakNodeSet())); |
| 132 return *set; | 132 return *set; |
| 133 } | 133 } |
| 134 #endif | 134 #endif |
| 135 | 135 |
| 136 void Node::dumpStatistics() | 136 void Node::dumpStatistics() |
| 137 { | 137 { |
| 138 #if DUMP_NODE_STATISTICS | 138 #if DUMP_NODE_STATISTICS |
| 139 size_t nodesWithRareData = 0; | 139 size_t nodesWithRareData = 0; |
| 140 | 140 |
| 141 size_t elementNodes = 0; | 141 size_t elementNodes = 0; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 String Node::nodeValue() const | 384 String Node::nodeValue() const |
| 385 { | 385 { |
| 386 return String(); | 386 return String(); |
| 387 } | 387 } |
| 388 | 388 |
| 389 void Node::setNodeValue(const String&) | 389 void Node::setNodeValue(const String&) |
| 390 { | 390 { |
| 391 // By default, setting nodeValue has no effect. | 391 // By default, setting nodeValue has no effect. |
| 392 } | 392 } |
| 393 | 393 |
| 394 PassRefPtrWillBeRawPtr<NodeList> Node::childNodes() | 394 RawPtr<NodeList> Node::childNodes() |
| 395 { | 395 { |
| 396 if (isContainerNode()) | 396 if (isContainerNode()) |
| 397 return ensureRareData().ensureNodeLists().ensureChildNodeList(toContaine
rNode(*this)); | 397 return ensureRareData().ensureNodeLists().ensureChildNodeList(toContaine
rNode(*this)); |
| 398 return ensureRareData().ensureNodeLists().ensureEmptyChildNodeList(*this); | 398 return ensureRareData().ensureNodeLists().ensureEmptyChildNodeList(*this); |
| 399 } | 399 } |
| 400 | 400 |
| 401 Node* Node::pseudoAwarePreviousSibling() const | 401 Node* Node::pseudoAwarePreviousSibling() const |
| 402 { | 402 { |
| 403 if (parentElement() && !previousSibling()) { | 403 if (parentElement() && !previousSibling()) { |
| 404 Element* parent = parentElement(); | 404 Element* parent = parentElement(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 Node& Node::treeRoot() const | 457 Node& Node::treeRoot() const |
| 458 { | 458 { |
| 459 if (isInTreeScope()) | 459 if (isInTreeScope()) |
| 460 return treeScope().rootNode(); | 460 return treeScope().rootNode(); |
| 461 const Node* node = this; | 461 const Node* node = this; |
| 462 while (node->parentNode()) | 462 while (node->parentNode()) |
| 463 node = node->parentNode(); | 463 node = node->parentNode(); |
| 464 return const_cast<Node&>(*node); | 464 return const_cast<Node&>(*node); |
| 465 } | 465 } |
| 466 | 466 |
| 467 PassRefPtrWillBeRawPtr<Node> Node::insertBefore(PassRefPtrWillBeRawPtr<Node> new
Child, Node* refChild, ExceptionState& exceptionState) | 467 RawPtr<Node> Node::insertBefore(RawPtr<Node> newChild, Node* refChild, Exception
State& exceptionState) |
| 468 { | 468 { |
| 469 if (isContainerNode()) | 469 if (isContainerNode()) |
| 470 return toContainerNode(this)->insertBefore(newChild, refChild, exception
State); | 470 return toContainerNode(this)->insertBefore(newChild, refChild, exception
State); |
| 471 | 471 |
| 472 exceptionState.throwDOMException(HierarchyRequestError, "This node type does
not support this method."); | 472 exceptionState.throwDOMException(HierarchyRequestError, "This node type does
not support this method."); |
| 473 return nullptr; | 473 return nullptr; |
| 474 } | 474 } |
| 475 | 475 |
| 476 PassRefPtrWillBeRawPtr<Node> Node::replaceChild(PassRefPtrWillBeRawPtr<Node> new
Child, PassRefPtrWillBeRawPtr<Node> oldChild, ExceptionState& exceptionState) | 476 RawPtr<Node> Node::replaceChild(RawPtr<Node> newChild, RawPtr<Node> oldChild, Ex
ceptionState& exceptionState) |
| 477 { | 477 { |
| 478 if (isContainerNode()) | 478 if (isContainerNode()) |
| 479 return toContainerNode(this)->replaceChild(newChild, oldChild, exception
State); | 479 return toContainerNode(this)->replaceChild(newChild, oldChild, exception
State); |
| 480 | 480 |
| 481 exceptionState.throwDOMException(HierarchyRequestError, "This node type doe
s not support this method."); | 481 exceptionState.throwDOMException(HierarchyRequestError, "This node type doe
s not support this method."); |
| 482 return nullptr; | 482 return nullptr; |
| 483 } | 483 } |
| 484 | 484 |
| 485 PassRefPtrWillBeRawPtr<Node> Node::removeChild(PassRefPtrWillBeRawPtr<Node> oldC
hild, ExceptionState& exceptionState) | 485 RawPtr<Node> Node::removeChild(RawPtr<Node> oldChild, ExceptionState& exceptionS
tate) |
| 486 { | 486 { |
| 487 if (isContainerNode()) | 487 if (isContainerNode()) |
| 488 return toContainerNode(this)->removeChild(oldChild, exceptionState); | 488 return toContainerNode(this)->removeChild(oldChild, exceptionState); |
| 489 | 489 |
| 490 exceptionState.throwDOMException(NotFoundError, "This node type does not sup
port this method."); | 490 exceptionState.throwDOMException(NotFoundError, "This node type does not sup
port this method."); |
| 491 return nullptr; | 491 return nullptr; |
| 492 } | 492 } |
| 493 | 493 |
| 494 PassRefPtrWillBeRawPtr<Node> Node::appendChild(PassRefPtrWillBeRawPtr<Node> newC
hild, ExceptionState& exceptionState) | 494 RawPtr<Node> Node::appendChild(RawPtr<Node> newChild, ExceptionState& exceptionS
tate) |
| 495 { | 495 { |
| 496 if (isContainerNode()) | 496 if (isContainerNode()) |
| 497 return toContainerNode(this)->appendChild(newChild, exceptionState); | 497 return toContainerNode(this)->appendChild(newChild, exceptionState); |
| 498 | 498 |
| 499 exceptionState.throwDOMException(HierarchyRequestError, "This node type does
not support this method."); | 499 exceptionState.throwDOMException(HierarchyRequestError, "This node type does
not support this method."); |
| 500 return nullptr; | 500 return nullptr; |
| 501 } | 501 } |
| 502 | 502 |
| 503 void Node::remove(ExceptionState& exceptionState) | 503 void Node::remove(ExceptionState& exceptionState) |
| 504 { | 504 { |
| 505 if (ContainerNode* parent = parentNode()) | 505 if (ContainerNode* parent = parentNode()) |
| 506 parent->removeChild(this, exceptionState); | 506 parent->removeChild(this, exceptionState); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void Node::normalize() | 509 void Node::normalize() |
| 510 { | 510 { |
| 511 updateDistribution(); | 511 updateDistribution(); |
| 512 | 512 |
| 513 // Go through the subtree beneath us, normalizing all nodes. This means that | 513 // Go through the subtree beneath us, normalizing all nodes. This means that |
| 514 // any two adjacent text nodes are merged and any empty text nodes are remov
ed. | 514 // any two adjacent text nodes are merged and any empty text nodes are remov
ed. |
| 515 | 515 |
| 516 RefPtrWillBeRawPtr<Node> node = this; | 516 RawPtr<Node> node = this; |
| 517 while (Node* firstChild = node->firstChild()) | 517 while (Node* firstChild = node->firstChild()) |
| 518 node = firstChild; | 518 node = firstChild; |
| 519 while (node) { | 519 while (node) { |
| 520 if (node == this) | 520 if (node == this) |
| 521 break; | 521 break; |
| 522 | 522 |
| 523 if (node->getNodeType() == TEXT_NODE) | 523 if (node->getNodeType() == TEXT_NODE) |
| 524 node = toText(node)->mergeNextSiblingNodesIfPossible(); | 524 node = toText(node)->mergeNextSiblingNodesIfPossible(); |
| 525 else | 525 else |
| 526 node = NodeTraversal::nextPostOrder(*node); | 526 node = NodeTraversal::nextPostOrder(*node); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 node->setChildNeedsStyleInvalidation(); | 690 node->setChildNeedsStyleInvalidation(); |
| 691 document().scheduleLayoutTreeUpdateIfNeeded(); | 691 document().scheduleLayoutTreeUpdateIfNeeded(); |
| 692 } | 692 } |
| 693 | 693 |
| 694 void Node::markAncestorsWithChildNeedsDistributionRecalc() | 694 void Node::markAncestorsWithChildNeedsDistributionRecalc() |
| 695 { | 695 { |
| 696 ScriptForbiddenScope forbidScriptDuringRawIteration; | 696 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 697 if (RuntimeEnabledFeatures::shadowDOMV1Enabled() && inDocument() && !documen
t().childNeedsDistributionRecalc()) { | 697 if (RuntimeEnabledFeatures::shadowDOMV1Enabled() && inDocument() && !documen
t().childNeedsDistributionRecalc()) { |
| 698 // TODO(hayato): Support a non-document composed tree. | 698 // TODO(hayato): Support a non-document composed tree. |
| 699 // TODO(hayato): Enqueue a task only if a 'slotchange' event listner is
registered in the document composed tree. | 699 // TODO(hayato): Enqueue a task only if a 'slotchange' event listner is
registered in the document composed tree. |
| 700 Microtask::enqueueMicrotask(WTF::bind(&Document::updateDistribution, Pas
sRefPtrWillBeRawPtr<Document>(&document()))); | 700 Microtask::enqueueMicrotask(WTF::bind(&Document::updateDistribution, Raw
Ptr<Document>(&document()))); |
| 701 } | 701 } |
| 702 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) | 702 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) |
| 703 node->setChildNeedsDistributionRecalc(); | 703 node->setChildNeedsDistributionRecalc(); |
| 704 document().scheduleLayoutTreeUpdateIfNeeded(); | 704 document().scheduleLayoutTreeUpdateIfNeeded(); |
| 705 } | 705 } |
| 706 | 706 |
| 707 inline void Node::setStyleChange(StyleChangeType changeType) | 707 inline void Node::setStyleChange(StyleChangeType changeType) |
| 708 { | 708 { |
| 709 m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType; | 709 m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType; |
| 710 } | 710 } |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 switch (getNodeType()) { | 1329 switch (getNodeType()) { |
| 1330 case TEXT_NODE: | 1330 case TEXT_NODE: |
| 1331 case CDATA_SECTION_NODE: | 1331 case CDATA_SECTION_NODE: |
| 1332 case COMMENT_NODE: | 1332 case COMMENT_NODE: |
| 1333 case PROCESSING_INSTRUCTION_NODE: | 1333 case PROCESSING_INSTRUCTION_NODE: |
| 1334 setNodeValue(text); | 1334 setNodeValue(text); |
| 1335 return; | 1335 return; |
| 1336 case ELEMENT_NODE: | 1336 case ELEMENT_NODE: |
| 1337 case DOCUMENT_FRAGMENT_NODE: { | 1337 case DOCUMENT_FRAGMENT_NODE: { |
| 1338 // FIXME: Merge this logic into replaceChildrenWithText. | 1338 // FIXME: Merge this logic into replaceChildrenWithText. |
| 1339 RefPtrWillBeRawPtr<ContainerNode> container = toContainerNode(this); | 1339 RawPtr<ContainerNode> container = toContainerNode(this); |
| 1340 | 1340 |
| 1341 // Note: This is an intentional optimization. | 1341 // Note: This is an intentional optimization. |
| 1342 // See crbug.com/352836 also. | 1342 // See crbug.com/352836 also. |
| 1343 // No need to do anything if the text is identical. | 1343 // No need to do anything if the text is identical. |
| 1344 if (container->hasOneTextChild() && toText(container->firstChild())->dat
a() == text) | 1344 if (container->hasOneTextChild() && toText(container->firstChild())->dat
a() == text) |
| 1345 return; | 1345 return; |
| 1346 | 1346 |
| 1347 ChildListMutationScope mutation(*this); | 1347 ChildListMutationScope mutation(*this); |
| 1348 // Note: This API will not insert empty text nodes: | 1348 // Note: This API will not insert empty text nodes: |
| 1349 // https://dom.spec.whatwg.org/#dom-node-textcontent | 1349 // https://dom.spec.whatwg.org/#dom-node-textcontent |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1380 const Node* start1 = attr1 ? attr1->ownerElement() : this; | 1380 const Node* start1 = attr1 ? attr1->ownerElement() : this; |
| 1381 const Node* start2 = attr2 ? attr2->ownerElement() : otherNode; | 1381 const Node* start2 = attr2 ? attr2->ownerElement() : otherNode; |
| 1382 | 1382 |
| 1383 // If either of start1 or start2 is null, then we are disconnected, since on
e of the nodes is | 1383 // If either of start1 or start2 is null, then we are disconnected, since on
e of the nodes is |
| 1384 // an orphaned attribute node. | 1384 // an orphaned attribute node. |
| 1385 if (!start1 || !start2) { | 1385 if (!start1 || !start2) { |
| 1386 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED
ING : DOCUMENT_POSITION_FOLLOWING; | 1386 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED
ING : DOCUMENT_POSITION_FOLLOWING; |
| 1387 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION
_SPECIFIC | direction; | 1387 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION
_SPECIFIC | direction; |
| 1388 } | 1388 } |
| 1389 | 1389 |
| 1390 WillBeHeapVector<RawPtrWillBeMember<const Node>, 16> chain1; | 1390 HeapVector<Member<const Node>, 16> chain1; |
| 1391 WillBeHeapVector<RawPtrWillBeMember<const Node>, 16> chain2; | 1391 HeapVector<Member<const Node>, 16> chain2; |
| 1392 if (attr1) | 1392 if (attr1) |
| 1393 chain1.append(attr1); | 1393 chain1.append(attr1); |
| 1394 if (attr2) | 1394 if (attr2) |
| 1395 chain2.append(attr2); | 1395 chain2.append(attr2); |
| 1396 | 1396 |
| 1397 if (attr1 && attr2 && start1 == start2 && start1) { | 1397 if (attr1 && attr2 && start1 == start2 && start1) { |
| 1398 // We are comparing two attributes on the same node. Crawl our attribute
map and see which one we hit first. | 1398 // We are comparing two attributes on the same node. Crawl our attribute
map and see which one we hit first. |
| 1399 const Element* owner1 = attr1->ownerElement(); | 1399 const Element* owner1 = attr1->ownerElement(); |
| 1400 AttributeCollection attributes = owner1->attributes(); | 1400 AttributeCollection attributes = owner1->attributes(); |
| 1401 for (const Attribute& attr : attributes) { | 1401 for (const Attribute& attr : attributes) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 showTreeAndMark(this, "*"); | 1590 showTreeAndMark(this, "*"); |
| 1591 } | 1591 } |
| 1592 | 1592 |
| 1593 void Node::showTreeForThisInFlatTree() const | 1593 void Node::showTreeForThisInFlatTree() const |
| 1594 { | 1594 { |
| 1595 showTreeAndMarkInFlatTree(this, "*"); | 1595 showTreeAndMarkInFlatTree(this, "*"); |
| 1596 } | 1596 } |
| 1597 | 1597 |
| 1598 void Node::showNodePathForThis() const | 1598 void Node::showNodePathForThis() const |
| 1599 { | 1599 { |
| 1600 WillBeHeapVector<RawPtrWillBeMember<const Node>, 16> chain; | 1600 HeapVector<Member<const Node>, 16> chain; |
| 1601 const Node* node = this; | 1601 const Node* node = this; |
| 1602 while (node->parentOrShadowHostNode()) { | 1602 while (node->parentOrShadowHostNode()) { |
| 1603 chain.append(node); | 1603 chain.append(node); |
| 1604 node = node->parentOrShadowHostNode(); | 1604 node = node->parentOrShadowHostNode(); |
| 1605 } | 1605 } |
| 1606 for (unsigned index = chain.size(); index > 0; --index) { | 1606 for (unsigned index = chain.size(); index > 0; --index) { |
| 1607 const Node* node = chain[index - 1]; | 1607 const Node* node = chain[index - 1]; |
| 1608 if (node->isShadowRoot()) { | 1608 if (node->isShadowRoot()) { |
| 1609 int count = 0; | 1609 int count = 0; |
| 1610 for (const ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowR
oot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) | 1610 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... |
| 1822 | 1822 |
| 1823 oldDocument.markers().removeMarkers(this); | 1823 oldDocument.markers().removeMarkers(this); |
| 1824 oldDocument.updateRangesAfterNodeMovedToAnotherDocument(*this); | 1824 oldDocument.updateRangesAfterNodeMovedToAnotherDocument(*this); |
| 1825 if (oldDocument.frameHost() && !document().frameHost()) | 1825 if (oldDocument.frameHost() && !document().frameHost()) |
| 1826 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(*t
his); | 1826 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(*t
his); |
| 1827 else if (document().frameHost() && !oldDocument.frameHost()) | 1827 else if (document().frameHost() && !oldDocument.frameHost()) |
| 1828 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*thi
s); | 1828 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*thi
s); |
| 1829 else if (oldDocument.frameHost() != document().frameHost()) | 1829 else if (oldDocument.frameHost() != document().frameHost()) |
| 1830 EventHandlerRegistry::didMoveBetweenFrameHosts(*this, oldDocument.frameH
ost(), document().frameHost()); | 1830 EventHandlerRegistry::didMoveBetweenFrameHosts(*this, oldDocument.frameH
ost(), document().frameHost()); |
| 1831 | 1831 |
| 1832 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>* regi
stry = mutationObserverRegistry()) { | 1832 if (HeapVector<Member<MutationObserverRegistration>>* registry = mutationObs
erverRegistry()) { |
| 1833 for (size_t i = 0; i < registry->size(); ++i) { | 1833 for (size_t i = 0; i < registry->size(); ++i) { |
| 1834 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); | 1834 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); |
| 1835 } | 1835 } |
| 1836 } | 1836 } |
| 1837 | 1837 |
| 1838 if (transientMutationObserverRegistry()) { | 1838 if (transientMutationObserverRegistry()) { |
| 1839 for (MutationObserverRegistration* registration : *transientMutationObse
rverRegistry()) | 1839 for (MutationObserverRegistration* registration : *transientMutationObse
rverRegistry()) |
| 1840 document().addMutationObserverTypes(registration->mutationTypes()); | 1840 document().addMutationObserverTypes(registration->mutationTypes()); |
| 1841 } | 1841 } |
| 1842 } | 1842 } |
| 1843 | 1843 |
| 1844 bool Node::addEventListenerInternal(const AtomicString& eventType, PassRefPtrWil
lBeRawPtr<EventListener> listener, const EventListenerOptions& options) | 1844 bool Node::addEventListenerInternal(const AtomicString& eventType, RawPtr<EventL
istener> listener, const EventListenerOptions& options) |
| 1845 { | 1845 { |
| 1846 if (!EventTarget::addEventListenerInternal(eventType, listener, options)) | 1846 if (!EventTarget::addEventListenerInternal(eventType, listener, options)) |
| 1847 return false; | 1847 return false; |
| 1848 | 1848 |
| 1849 document().addListenerTypeIfNeeded(eventType); | 1849 document().addListenerTypeIfNeeded(eventType); |
| 1850 if (FrameHost* frameHost = document().frameHost()) | 1850 if (FrameHost* frameHost = document().frameHost()) |
| 1851 frameHost->eventHandlerRegistry().didAddEventHandler(*this, eventType, o
ptions); | 1851 frameHost->eventHandlerRegistry().didAddEventHandler(*this, eventType, o
ptions); |
| 1852 | 1852 |
| 1853 return true; | 1853 return true; |
| 1854 } | 1854 } |
| 1855 | 1855 |
| 1856 bool Node::removeEventListenerInternal(const AtomicString& eventType, PassRefPtr
WillBeRawPtr<EventListener> listener, const EventListenerOptions& options) | 1856 bool Node::removeEventListenerInternal(const AtomicString& eventType, RawPtr<Eve
ntListener> listener, const EventListenerOptions& options) |
| 1857 { | 1857 { |
| 1858 if (!EventTarget::removeEventListenerInternal(eventType, listener, options)) | 1858 if (!EventTarget::removeEventListenerInternal(eventType, listener, options)) |
| 1859 return false; | 1859 return false; |
| 1860 | 1860 |
| 1861 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of | 1861 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of |
| 1862 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 | 1862 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 |
| 1863 if (FrameHost* frameHost = document().frameHost()) | 1863 if (FrameHost* frameHost = document().frameHost()) |
| 1864 frameHost->eventHandlerRegistry().didRemoveEventHandler(*this, eventType
, options); | 1864 frameHost->eventHandlerRegistry().didRemoveEventHandler(*this, eventType
, options); |
| 1865 | 1865 |
| 1866 return true; | 1866 return true; |
| 1867 } | 1867 } |
| 1868 | 1868 |
| 1869 void Node::removeAllEventListeners() | 1869 void Node::removeAllEventListeners() |
| 1870 { | 1870 { |
| 1871 if (hasEventListeners() && document().frameHost()) | 1871 if (hasEventListeners() && document().frameHost()) |
| 1872 document().frameHost()->eventHandlerRegistry().didRemoveAllEventHandlers
(*this); | 1872 document().frameHost()->eventHandlerRegistry().didRemoveAllEventHandlers
(*this); |
| 1873 EventTarget::removeAllEventListeners(); | 1873 EventTarget::removeAllEventListeners(); |
| 1874 } | 1874 } |
| 1875 | 1875 |
| 1876 void Node::removeAllEventListenersRecursively() | 1876 void Node::removeAllEventListenersRecursively() |
| 1877 { | 1877 { |
| 1878 ScriptForbiddenScope forbidScriptDuringRawIteration; | 1878 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 1879 for (Node& node : NodeTraversal::startsAt(this)) { | 1879 for (Node& node : NodeTraversal::startsAt(this)) { |
| 1880 node.removeAllEventListeners(); | 1880 node.removeAllEventListeners(); |
| 1881 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root->ol
derShadowRoot()) | 1881 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root->ol
derShadowRoot()) |
| 1882 root->removeAllEventListenersRecursively(); | 1882 root->removeAllEventListenersRecursively(); |
| 1883 } | 1883 } |
| 1884 } | 1884 } |
| 1885 | 1885 |
| 1886 using EventTargetDataMap = WillBeHeapHashMap<RawPtrWillBeWeakMember<Node>, OwnPt
rWillBeMember<EventTargetData>>; | 1886 using EventTargetDataMap = HeapHashMap<WeakMember<Node>, Member<EventTargetData>
>; |
| 1887 static EventTargetDataMap& eventTargetDataMap() | 1887 static EventTargetDataMap& eventTargetDataMap() |
| 1888 { | 1888 { |
| 1889 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<EventTargetDataMap>, map, (adoptP
trWillBeNoop(new EventTargetDataMap()))); | 1889 DEFINE_STATIC_LOCAL(Persistent<EventTargetDataMap>, map, (new EventTargetDat
aMap())); |
| 1890 return *map; | 1890 return *map; |
| 1891 } | 1891 } |
| 1892 | 1892 |
| 1893 EventTargetData* Node::eventTargetData() | 1893 EventTargetData* Node::eventTargetData() |
| 1894 { | 1894 { |
| 1895 return hasEventTargetData() ? eventTargetDataMap().get(this) : nullptr; | 1895 return hasEventTargetData() ? eventTargetDataMap().get(this) : nullptr; |
| 1896 } | 1896 } |
| 1897 | 1897 |
| 1898 EventTargetData& Node::ensureEventTargetData() | 1898 EventTargetData& Node::ensureEventTargetData() |
| 1899 { | 1899 { |
| 1900 if (hasEventTargetData()) | 1900 if (hasEventTargetData()) |
| 1901 return *eventTargetDataMap().get(this); | 1901 return *eventTargetDataMap().get(this); |
| 1902 ASSERT(!eventTargetDataMap().contains(this)); | 1902 ASSERT(!eventTargetDataMap().contains(this)); |
| 1903 setHasEventTargetData(true); | 1903 setHasEventTargetData(true); |
| 1904 OwnPtrWillBeRawPtr<EventTargetData> data = adoptPtrWillBeNoop(new EventTarge
tData); | 1904 RawPtr<EventTargetData> data = adoptPtrWillBeNoop(new EventTargetData); |
| 1905 EventTargetData* dataPtr = data.get(); | 1905 EventTargetData* dataPtr = data.get(); |
| 1906 eventTargetDataMap().set(this, data.release()); | 1906 eventTargetDataMap().set(this, data.release()); |
| 1907 return *dataPtr; | 1907 return *dataPtr; |
| 1908 } | 1908 } |
| 1909 | 1909 |
| 1910 #if !ENABLE(OILPAN) | 1910 #if !ENABLE(OILPAN) |
| 1911 void Node::clearEventTargetData() | 1911 void Node::clearEventTargetData() |
| 1912 { | 1912 { |
| 1913 eventTargetDataMap().remove(this); | 1913 eventTargetDataMap().remove(this); |
| 1914 #if ENABLE(ASSERT) | 1914 #if ENABLE(ASSERT) |
| 1915 setHasEventTargetData(false); | 1915 setHasEventTargetData(false); |
| 1916 #endif | 1916 #endif |
| 1917 } | 1917 } |
| 1918 #endif | 1918 #endif |
| 1919 | 1919 |
| 1920 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>* Node::mutati
onObserverRegistry() | 1920 HeapVector<Member<MutationObserverRegistration>>* Node::mutationObserverRegistry
() |
| 1921 { | 1921 { |
| 1922 if (!hasRareData()) | 1922 if (!hasRareData()) |
| 1923 return nullptr; | 1923 return nullptr; |
| 1924 NodeMutationObserverData* data = rareData()->mutationObserverData(); | 1924 NodeMutationObserverData* data = rareData()->mutationObserverData(); |
| 1925 if (!data) | 1925 if (!data) |
| 1926 return nullptr; | 1926 return nullptr; |
| 1927 return &data->registry; | 1927 return &data->registry; |
| 1928 } | 1928 } |
| 1929 | 1929 |
| 1930 WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>>* Node::trans
ientMutationObserverRegistry() | 1930 HeapHashSet<Member<MutationObserverRegistration>>* Node::transientMutationObserv
erRegistry() |
| 1931 { | 1931 { |
| 1932 if (!hasRareData()) | 1932 if (!hasRareData()) |
| 1933 return nullptr; | 1933 return nullptr; |
| 1934 NodeMutationObserverData* data = rareData()->mutationObserverData(); | 1934 NodeMutationObserverData* data = rareData()->mutationObserverData(); |
| 1935 if (!data) | 1935 if (!data) |
| 1936 return nullptr; | 1936 return nullptr; |
| 1937 return &data->transientRegistry; | 1937 return &data->transientRegistry; |
| 1938 } | 1938 } |
| 1939 | 1939 |
| 1940 template<typename Registry> | 1940 template<typename Registry> |
| 1941 static inline void collectMatchingObserversForMutation(WillBeHeapHashMap<RefPtrW
illBeMember<MutationObserver>, MutationRecordDeliveryOptions>& observers, Regist
ry* registry, Node& target, MutationObserver::MutationType type, const Qualified
Name* attributeName) | 1941 static inline void collectMatchingObserversForMutation(HeapHashMap<Member<Mutati
onObserver>, MutationRecordDeliveryOptions>& observers, Registry* registry, Node
& target, MutationObserver::MutationType type, const QualifiedName* attributeNam
e) |
| 1942 { | 1942 { |
| 1943 if (!registry) | 1943 if (!registry) |
| 1944 return; | 1944 return; |
| 1945 | 1945 |
| 1946 for (const auto& registration : *registry) { | 1946 for (const auto& registration : *registry) { |
| 1947 if (registration->shouldReceiveMutationFrom(target, type, attributeName)
) { | 1947 if (registration->shouldReceiveMutationFrom(target, type, attributeName)
) { |
| 1948 MutationRecordDeliveryOptions deliveryOptions = registration->delive
ryOptions(); | 1948 MutationRecordDeliveryOptions deliveryOptions = registration->delive
ryOptions(); |
| 1949 WillBeHeapHashMap<RefPtrWillBeMember<MutationObserver>, MutationReco
rdDeliveryOptions>::AddResult result = observers.add(®istration->observer(),
deliveryOptions); | 1949 HeapHashMap<Member<MutationObserver>, MutationRecordDeliveryOptions>
::AddResult result = observers.add(®istration->observer(), deliveryOptions); |
| 1950 if (!result.isNewEntry) | 1950 if (!result.isNewEntry) |
| 1951 result.storedValue->value |= deliveryOptions; | 1951 result.storedValue->value |= deliveryOptions; |
| 1952 } | 1952 } |
| 1953 } | 1953 } |
| 1954 } | 1954 } |
| 1955 | 1955 |
| 1956 void Node::getRegisteredMutationObserversOfType(WillBeHeapHashMap<RefPtrWillBeMe
mber<MutationObserver>, MutationRecordDeliveryOptions>& observers, MutationObser
ver::MutationType type, const QualifiedName* attributeName) | 1956 void Node::getRegisteredMutationObserversOfType(HeapHashMap<Member<MutationObser
ver>, MutationRecordDeliveryOptions>& observers, MutationObserver::MutationType
type, const QualifiedName* attributeName) |
| 1957 { | 1957 { |
| 1958 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute
Name); | 1958 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute
Name); |
| 1959 collectMatchingObserversForMutation(observers, mutationObserverRegistry(), *
this, type, attributeName); | 1959 collectMatchingObserversForMutation(observers, mutationObserverRegistry(), *
this, type, attributeName); |
| 1960 collectMatchingObserversForMutation(observers, transientMutationObserverRegi
stry(), *this, type, attributeName); | 1960 collectMatchingObserversForMutation(observers, transientMutationObserverRegi
stry(), *this, type, attributeName); |
| 1961 ScriptForbiddenScope forbidScriptDuringRawIteration; | 1961 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 1962 for (Node* node = parentNode(); node; node = node->parentNode()) { | 1962 for (Node* node = parentNode(); node; node = node->parentNode()) { |
| 1963 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), *this, type, attributeName); | 1963 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), *this, type, attributeName); |
| 1964 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), *this, type, attributeName); | 1964 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), *this, type, attributeName); |
| 1965 } | 1965 } |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 void Node::registerMutationObserver(MutationObserver& observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) | 1968 void Node::registerMutationObserver(MutationObserver& observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) |
| 1969 { | 1969 { |
| 1970 MutationObserverRegistration* registration = nullptr; | 1970 MutationObserverRegistration* registration = nullptr; |
| 1971 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>& registry
= ensureRareData().ensureMutationObserverData().registry; | 1971 HeapVector<Member<MutationObserverRegistration>>& registry = ensureRareData(
).ensureMutationObserverData().registry; |
| 1972 for (size_t i = 0; i < registry.size(); ++i) { | 1972 for (size_t i = 0; i < registry.size(); ++i) { |
| 1973 if (®istry[i]->observer() == &observer) { | 1973 if (®istry[i]->observer() == &observer) { |
| 1974 registration = registry[i].get(); | 1974 registration = registry[i].get(); |
| 1975 registration->resetObservation(options, attributeFilter); | 1975 registration->resetObservation(options, attributeFilter); |
| 1976 } | 1976 } |
| 1977 } | 1977 } |
| 1978 | 1978 |
| 1979 if (!registration) { | 1979 if (!registration) { |
| 1980 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); | 1980 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); |
| 1981 registration = registry.last().get(); | 1981 registration = registry.last().get(); |
| 1982 } | 1982 } |
| 1983 | 1983 |
| 1984 document().addMutationObserverTypes(registration->mutationTypes()); | 1984 document().addMutationObserverTypes(registration->mutationTypes()); |
| 1985 } | 1985 } |
| 1986 | 1986 |
| 1987 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) | 1987 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) |
| 1988 { | 1988 { |
| 1989 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>* registry
= mutationObserverRegistry(); | 1989 HeapVector<Member<MutationObserverRegistration>>* registry = mutationObserve
rRegistry(); |
| 1990 ASSERT(registry); | 1990 ASSERT(registry); |
| 1991 if (!registry) | 1991 if (!registry) |
| 1992 return; | 1992 return; |
| 1993 | 1993 |
| 1994 size_t index = registry->find(registration); | 1994 size_t index = registry->find(registration); |
| 1995 ASSERT(index != kNotFound); | 1995 ASSERT(index != kNotFound); |
| 1996 if (index == kNotFound) | 1996 if (index == kNotFound) |
| 1997 return; | 1997 return; |
| 1998 | 1998 |
| 1999 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes | 1999 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes |
| 2000 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). | 2000 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). |
| 2001 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. | 2001 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. |
| 2002 RefPtrWillBeRawPtr<Node> protect(this); | 2002 RawPtr<Node> protect(this); |
| 2003 #if ENABLE(OILPAN) | 2003 #if ENABLE(OILPAN) |
| 2004 // The explicit dispose() is needed to have the registration | 2004 // The explicit dispose() is needed to have the registration |
| 2005 // object unregister itself promptly. | 2005 // object unregister itself promptly. |
| 2006 registration->dispose(); | 2006 registration->dispose(); |
| 2007 #endif | 2007 #endif |
| 2008 registry->remove(index); | 2008 registry->remove(index); |
| 2009 } | 2009 } |
| 2010 | 2010 |
| 2011 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis
tration) | 2011 void Node::registerTransientMutationObserver(MutationObserverRegistration* regis
tration) |
| 2012 { | 2012 { |
| 2013 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra
tion); | 2013 ensureRareData().ensureMutationObserverData().transientRegistry.add(registra
tion); |
| 2014 } | 2014 } |
| 2015 | 2015 |
| 2016 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg
istration) | 2016 void Node::unregisterTransientMutationObserver(MutationObserverRegistration* reg
istration) |
| 2017 { | 2017 { |
| 2018 WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>>* transie
ntRegistry = transientMutationObserverRegistry(); | 2018 HeapHashSet<Member<MutationObserverRegistration>>* transientRegistry = trans
ientMutationObserverRegistry(); |
| 2019 ASSERT(transientRegistry); | 2019 ASSERT(transientRegistry); |
| 2020 if (!transientRegistry) | 2020 if (!transientRegistry) |
| 2021 return; | 2021 return; |
| 2022 | 2022 |
| 2023 ASSERT(transientRegistry->contains(registration)); | 2023 ASSERT(transientRegistry->contains(registration)); |
| 2024 transientRegistry->remove(registration); | 2024 transientRegistry->remove(registration); |
| 2025 } | 2025 } |
| 2026 | 2026 |
| 2027 void Node::notifyMutationObserversNodeWillDetach() | 2027 void Node::notifyMutationObserversNodeWillDetach() |
| 2028 { | 2028 { |
| 2029 if (!document().hasMutationObservers()) | 2029 if (!document().hasMutationObservers()) |
| 2030 return; | 2030 return; |
| 2031 | 2031 |
| 2032 ScriptForbiddenScope forbidScriptDuringRawIteration; | 2032 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 2033 for (Node* node = parentNode(); node; node = node->parentNode()) { | 2033 for (Node* node = parentNode(); node; node = node->parentNode()) { |
| 2034 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration>>*
registry = node->mutationObserverRegistry()) { | 2034 if (HeapVector<Member<MutationObserverRegistration>>* registry = node->m
utationObserverRegistry()) { |
| 2035 const size_t size = registry->size(); | 2035 const size_t size = registry->size(); |
| 2036 for (size_t i = 0; i < size; ++i) | 2036 for (size_t i = 0; i < size; ++i) |
| 2037 registry->at(i)->observedSubtreeNodeWillDetach(*this); | 2037 registry->at(i)->observedSubtreeNodeWillDetach(*this); |
| 2038 } | 2038 } |
| 2039 | 2039 |
| 2040 if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>>*
transientRegistry = node->transientMutationObserverRegistry()) { | 2040 if (HeapHashSet<Member<MutationObserverRegistration>>* transientRegistry
= node->transientMutationObserverRegistry()) { |
| 2041 for (auto& registration : *transientRegistry) | 2041 for (auto& registration : *transientRegistry) |
| 2042 registration->observedSubtreeNodeWillDetach(*this); | 2042 registration->observedSubtreeNodeWillDetach(*this); |
| 2043 } | 2043 } |
| 2044 } | 2044 } |
| 2045 } | 2045 } |
| 2046 | 2046 |
| 2047 void Node::handleLocalEvents(Event& event) | 2047 void Node::handleLocalEvents(Event& event) |
| 2048 { | 2048 { |
| 2049 if (!hasEventTargetData()) | 2049 if (!hasEventTargetData()) |
| 2050 return; | 2050 return; |
| 2051 | 2051 |
| 2052 if (isDisabledFormControl(this) && event.isMouseEvent()) | 2052 if (isDisabledFormControl(this) && event.isMouseEvent()) |
| 2053 return; | 2053 return; |
| 2054 | 2054 |
| 2055 fireEventListeners(&event); | 2055 fireEventListeners(&event); |
| 2056 } | 2056 } |
| 2057 | 2057 |
| 2058 void Node::dispatchScopedEvent(PassRefPtrWillBeRawPtr<Event> event) | 2058 void Node::dispatchScopedEvent(RawPtr<Event> event) |
| 2059 { | 2059 { |
| 2060 event->setTrusted(true); | 2060 event->setTrusted(true); |
| 2061 EventDispatcher::dispatchScopedEvent(*this, event->createMediator()); | 2061 EventDispatcher::dispatchScopedEvent(*this, event->createMediator()); |
| 2062 } | 2062 } |
| 2063 | 2063 |
| 2064 DispatchEventResult Node::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> ev
ent) | 2064 DispatchEventResult Node::dispatchEventInternal(RawPtr<Event> event) |
| 2065 { | 2065 { |
| 2066 return EventDispatcher::dispatchEvent(*this, event->createMediator()); | 2066 return EventDispatcher::dispatchEvent(*this, event->createMediator()); |
| 2067 } | 2067 } |
| 2068 | 2068 |
| 2069 void Node::dispatchSubtreeModifiedEvent() | 2069 void Node::dispatchSubtreeModifiedEvent() |
| 2070 { | 2070 { |
| 2071 if (isInShadowTree()) | 2071 if (isInShadowTree()) |
| 2072 return; | 2072 return; |
| 2073 | 2073 |
| 2074 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 2074 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 2075 | 2075 |
| 2076 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) | 2076 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) |
| 2077 return; | 2077 return; |
| 2078 | 2078 |
| 2079 dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMSubtreeModified
, true)); | 2079 dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMSubtreeModified
, true)); |
| 2080 } | 2080 } |
| 2081 | 2081 |
| 2082 DispatchEventResult Node::dispatchDOMActivateEvent(int detail, PassRefPtrWillBeR
awPtr<Event> underlyingEvent) | 2082 DispatchEventResult Node::dispatchDOMActivateEvent(int detail, RawPtr<Event> und
erlyingEvent) |
| 2083 { | 2083 { |
| 2084 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 2084 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 2085 RefPtrWillBeRawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActiv
ate, true, true, document().domWindow(), detail); | 2085 RawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActivate, true, t
rue, document().domWindow(), detail); |
| 2086 event->setUnderlyingEvent(underlyingEvent); | 2086 event->setUnderlyingEvent(underlyingEvent); |
| 2087 dispatchScopedEvent(event); | 2087 dispatchScopedEvent(event); |
| 2088 | 2088 |
| 2089 // TODO(dtapuska): Dispatching scoped events shouldn't check the return | 2089 // TODO(dtapuska): Dispatching scoped events shouldn't check the return |
| 2090 // type because the scoped event could get put off in the delayed queue. | 2090 // type because the scoped event could get put off in the delayed queue. |
| 2091 return EventTarget::dispatchEventResult(*event); | 2091 return EventTarget::dispatchEventResult(*event); |
| 2092 } | 2092 } |
| 2093 | 2093 |
| 2094 DispatchEventResult Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEve
nt, const AtomicString& eventType, | 2094 DispatchEventResult Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEve
nt, const AtomicString& eventType, |
| 2095 int detail, Node* relatedTarget) | 2095 int detail, Node* relatedTarget) |
| 2096 { | 2096 { |
| 2097 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, documen
t().domWindow(), nativeEvent, detail, relatedTarget); | 2097 RawPtr<MouseEvent> event = MouseEvent::create(eventType, document().domWindo
w(), nativeEvent, detail, relatedTarget); |
| 2098 return dispatchEvent(event); | 2098 return dispatchEvent(event); |
| 2099 } | 2099 } |
| 2100 | 2100 |
| 2101 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve
ntOptions eventOptions, SimulatedClickCreationScope scope) | 2101 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve
ntOptions eventOptions, SimulatedClickCreationScope scope) |
| 2102 { | 2102 { |
| 2103 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions
, scope); | 2103 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions
, scope); |
| 2104 } | 2104 } |
| 2105 | 2105 |
| 2106 void Node::dispatchInputEvent() | 2106 void Node::dispatchInputEvent() |
| 2107 { | 2107 { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2258 { | 2258 { |
| 2259 ASSERT(isContainerNode()); | 2259 ASSERT(isContainerNode()); |
| 2260 ensureRareData().incrementConnectedSubframeCount(); | 2260 ensureRareData().incrementConnectedSubframeCount(); |
| 2261 } | 2261 } |
| 2262 | 2262 |
| 2263 void Node::decrementConnectedSubframeCount() | 2263 void Node::decrementConnectedSubframeCount() |
| 2264 { | 2264 { |
| 2265 rareData()->decrementConnectedSubframeCount(); | 2265 rareData()->decrementConnectedSubframeCount(); |
| 2266 } | 2266 } |
| 2267 | 2267 |
| 2268 PassRefPtrWillBeRawPtr<StaticNodeList> Node::getDestinationInsertionPoints() | 2268 RawPtr<StaticNodeList> Node::getDestinationInsertionPoints() |
| 2269 { | 2269 { |
| 2270 updateDistribution(); | 2270 updateDistribution(); |
| 2271 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; | 2271 HeapVector<Member<InsertionPoint>, 8> insertionPoints; |
| 2272 collectDestinationInsertionPoints(*this, insertionPoints); | 2272 collectDestinationInsertionPoints(*this, insertionPoints); |
| 2273 WillBeHeapVector<RefPtrWillBeMember<Node>> filteredInsertionPoints; | 2273 HeapVector<Member<Node>> filteredInsertionPoints; |
| 2274 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 2274 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| 2275 InsertionPoint* insertionPoint = insertionPoints[i]; | 2275 InsertionPoint* insertionPoint = insertionPoints[i]; |
| 2276 ASSERT(insertionPoint->containingShadowRoot()); | 2276 ASSERT(insertionPoint->containingShadowRoot()); |
| 2277 if (!insertionPoint->containingShadowRoot()->isOpenOrV0()) | 2277 if (!insertionPoint->containingShadowRoot()->isOpenOrV0()) |
| 2278 break; | 2278 break; |
| 2279 filteredInsertionPoints.append(insertionPoint); | 2279 filteredInsertionPoints.append(insertionPoint); |
| 2280 } | 2280 } |
| 2281 return StaticNodeList::adopt(filteredInsertionPoints); | 2281 return StaticNodeList::adopt(filteredInsertionPoints); |
| 2282 } | 2282 } |
| 2283 | 2283 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 } | 2401 } |
| 2402 ASSERT_NOT_REACHED(); | 2402 ASSERT_NOT_REACHED(); |
| 2403 return 0; | 2403 return 0; |
| 2404 } | 2404 } |
| 2405 | 2405 |
| 2406 v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre
ationContext) | 2406 v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre
ationContext) |
| 2407 { | 2407 { |
| 2408 // It's possible that no one except for the new wrapper owns this object at | 2408 // It's possible that no one except for the new wrapper owns this object at |
| 2409 // this moment, so we have to prevent GC to collect this object until the | 2409 // this moment, so we have to prevent GC to collect this object until the |
| 2410 // object gets associated with the wrapper. | 2410 // object gets associated with the wrapper. |
| 2411 RefPtrWillBeRawPtr<Node> protect(this); | 2411 RawPtr<Node> protect(this); |
| 2412 | 2412 |
| 2413 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); | 2413 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); |
| 2414 | 2414 |
| 2415 const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); | 2415 const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); |
| 2416 | 2416 |
| 2417 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio
nContext, wrapperType, this); | 2417 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio
nContext, wrapperType, this); |
| 2418 if (UNLIKELY(wrapper.IsEmpty())) | 2418 if (UNLIKELY(wrapper.IsEmpty())) |
| 2419 return wrapper; | 2419 return wrapper; |
| 2420 | 2420 |
| 2421 wrapperType->installConditionallyEnabledProperties(wrapper, isolate); | 2421 wrapperType->installConditionallyEnabledProperties(wrapper, isolate); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2449 | 2449 |
| 2450 void showNodePath(const blink::Node* node) | 2450 void showNodePath(const blink::Node* node) |
| 2451 { | 2451 { |
| 2452 if (node) | 2452 if (node) |
| 2453 node->showNodePathForThis(); | 2453 node->showNodePathForThis(); |
| 2454 else | 2454 else |
| 2455 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2455 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
| 2456 } | 2456 } |
| 2457 | 2457 |
| 2458 #endif | 2458 #endif |
| OLD | NEW |