| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 uint32_t m_nodeFlags; | 106 uint32_t m_nodeFlags; |
| 107 Member<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 DCHECK(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 DCHECK(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 = HeapHashSet<WeakMember<Node>>; | 128 using WeakNodeSet = HeapHashSet<WeakMember<Node>>; |
| 129 static WeakNodeSet& liveNodeSet() | 129 static WeakNodeSet& liveNodeSet() |
| 130 { | 130 { |
| 131 DEFINE_STATIC_LOCAL(WeakNodeSet, set, (new WeakNodeSet)); | 131 DEFINE_STATIC_LOCAL(WeakNodeSet, set, (new WeakNodeSet)); |
| 132 return set; | 132 return set; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 #endif | 257 #endif |
| 258 } | 258 } |
| 259 | 259 |
| 260 Node::Node(TreeScope* treeScope, ConstructionType type) | 260 Node::Node(TreeScope* treeScope, ConstructionType type) |
| 261 : m_nodeFlags(type) | 261 : m_nodeFlags(type) |
| 262 , m_parentOrShadowHostNode(nullptr) | 262 , m_parentOrShadowHostNode(nullptr) |
| 263 , m_treeScope(treeScope) | 263 , m_treeScope(treeScope) |
| 264 , m_previous(nullptr) | 264 , m_previous(nullptr) |
| 265 , m_next(nullptr) | 265 , m_next(nullptr) |
| 266 { | 266 { |
| 267 ASSERT(m_treeScope || type == CreateDocument || type == CreateShadowRoot); | 267 DCHECK(m_treeScope || type == CreateDocument || type == CreateShadowRoot); |
| 268 #if !ENABLE(OILPAN) | 268 #if !ENABLE(OILPAN) |
| 269 if (m_treeScope) | 269 if (m_treeScope) |
| 270 m_treeScope->guardRef(); | 270 m_treeScope->guardRef(); |
| 271 #endif | 271 #endif |
| 272 | 272 |
| 273 #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS) | 273 #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS) |
| 274 trackForDebugging(); | 274 trackForDebugging(); |
| 275 #endif | 275 #endif |
| 276 InstanceCounters::incrementCounter(InstanceCounters::NodeCounter); | 276 InstanceCounters::incrementCounter(InstanceCounters::NodeCounter); |
| 277 } | 277 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 297 m_next->setPreviousSibling(nullptr); | 297 m_next->setPreviousSibling(nullptr); |
| 298 | 298 |
| 299 if (m_treeScope) | 299 if (m_treeScope) |
| 300 m_treeScope->guardDeref(); | 300 m_treeScope->guardDeref(); |
| 301 | 301 |
| 302 if (getFlag(HasWeakReferencesFlag)) | 302 if (getFlag(HasWeakReferencesFlag)) |
| 303 WeakIdentifierMap<Node>::notifyObjectDestroyed(this); | 303 WeakIdentifierMap<Node>::notifyObjectDestroyed(this); |
| 304 | 304 |
| 305 // clearEventTargetData() must be always done, | 305 // clearEventTargetData() must be always done, |
| 306 // or eventTargetDataMap() may keep a raw pointer to a deleted object. | 306 // or eventTargetDataMap() may keep a raw pointer to a deleted object. |
| 307 ASSERT(!hasEventTargetData()); | 307 DCHECK(!hasEventTargetData()); |
| 308 #else | 308 #else |
| 309 // With Oilpan, the rare data finalizer also asserts for | 309 // With Oilpan, the rare data finalizer also asserts for |
| 310 // this condition (we cannot directly access it here.) | 310 // this condition (we cannot directly access it here.) |
| 311 RELEASE_ASSERT(hasRareData() || !layoutObject()); | 311 RELEASE_ASSERT(hasRareData() || !layoutObject()); |
| 312 #endif | 312 #endif |
| 313 | 313 |
| 314 InstanceCounters::decrementCounter(InstanceCounters::NodeCounter); | 314 InstanceCounters::decrementCounter(InstanceCounters::NodeCounter); |
| 315 } | 315 } |
| 316 | 316 |
| 317 #if !ENABLE(OILPAN) | 317 #if !ENABLE(OILPAN) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 342 NodeRareData& Node::ensureRareData() | 342 NodeRareData& Node::ensureRareData() |
| 343 { | 343 { |
| 344 if (hasRareData()) | 344 if (hasRareData()) |
| 345 return *rareData(); | 345 return *rareData(); |
| 346 | 346 |
| 347 if (isElementNode()) | 347 if (isElementNode()) |
| 348 m_data.m_rareData = ElementRareData::create(m_data.m_layoutObject); | 348 m_data.m_rareData = ElementRareData::create(m_data.m_layoutObject); |
| 349 else | 349 else |
| 350 m_data.m_rareData = NodeRareData::create(m_data.m_layoutObject); | 350 m_data.m_rareData = NodeRareData::create(m_data.m_layoutObject); |
| 351 | 351 |
| 352 ASSERT(m_data.m_rareData); | 352 DCHECK(m_data.m_rareData); |
| 353 | 353 |
| 354 setFlag(HasRareDataFlag); | 354 setFlag(HasRareDataFlag); |
| 355 return *rareData(); | 355 return *rareData(); |
| 356 } | 356 } |
| 357 | 357 |
| 358 #if !ENABLE(OILPAN) | 358 #if !ENABLE(OILPAN) |
| 359 void Node::clearRareData() | 359 void Node::clearRareData() |
| 360 { | 360 { |
| 361 ASSERT(hasRareData()); | 361 DCHECK(hasRareData()); |
| 362 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi
stry()->isEmpty()); | 362 DCHECK(!transientMutationObserverRegistry() || transientMutationObserverRegi
stry()->isEmpty()); |
| 363 | 363 |
| 364 LayoutObject* layoutObject = m_data.m_rareData->layoutObject(); | 364 LayoutObject* layoutObject = m_data.m_rareData->layoutObject(); |
| 365 if (isElementNode()) | 365 if (isElementNode()) |
| 366 delete static_cast<ElementRareData*>(m_data.m_rareData); | 366 delete static_cast<ElementRareData*>(m_data.m_rareData); |
| 367 else | 367 else |
| 368 delete static_cast<NodeRareData*>(m_data.m_rareData); | 368 delete static_cast<NodeRareData*>(m_data.m_rareData); |
| 369 m_data.m_layoutObject = layoutObject; | 369 m_data.m_layoutObject = layoutObject; |
| 370 clearFlag(HasRareDataFlag); | 370 clearFlag(HasRareDataFlag); |
| 371 } | 371 } |
| 372 #endif | 372 #endif |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 { | 537 { |
| 538 document().updateLayoutTree(); | 538 document().updateLayoutTree(); |
| 539 return hasEditableStyle(RichlyEditable, UserSelectAllIsAlwaysNonEditable); | 539 return hasEditableStyle(RichlyEditable, UserSelectAllIsAlwaysNonEditable); |
| 540 } | 540 } |
| 541 | 541 |
| 542 bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment
treatment) const | 542 bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment
treatment) const |
| 543 { | 543 { |
| 544 if (isPseudoElement()) | 544 if (isPseudoElement()) |
| 545 return false; | 545 return false; |
| 546 | 546 |
| 547 // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but | 547 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but |
| 548 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion | 548 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion |
| 549 // would fire in the middle of Document::setFocusedNode(). | 549 // would fire in the middle of Document::setFocusedNode(). |
| 550 | 550 |
| 551 for (const Node* node = this; node; node = node->parentNode()) { | 551 for (const Node* node = this; node; node = node->parentNode()) { |
| 552 if ((node->isHTMLElement() || node->isDocumentNode()) && node->layoutObj
ect()) { | 552 if ((node->isHTMLElement() || node->isDocumentNode()) && node->layoutObj
ect()) { |
| 553 // Elements with user-select: all style are considered atomic | 553 // Elements with user-select: all style are considered atomic |
| 554 // therefore non editable. | 554 // therefore non editable. |
| 555 if (nodeIsUserSelectAll(node) && treatment == UserSelectAllIsAlwaysN
onEditable) | 555 if (nodeIsUserSelectAll(node) && treatment == UserSelectAllIsAlwaysN
onEditable) |
| 556 return false; | 556 return false; |
| 557 switch (node->layoutObject()->style()->userModify()) { | 557 switch (node->layoutObject()->style()->userModify()) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 618 |
| 619 Node& Node::shadowIncludingRoot() const | 619 Node& Node::shadowIncludingRoot() const |
| 620 { | 620 { |
| 621 if (inShadowIncludingDocument()) | 621 if (inShadowIncludingDocument()) |
| 622 return document(); | 622 return document(); |
| 623 Node* root = const_cast<Node*>(this); | 623 Node* root = const_cast<Node*>(this); |
| 624 while (Node* host = root->shadowHost()) | 624 while (Node* host = root->shadowHost()) |
| 625 root = host; | 625 root = host; |
| 626 while (Node* ancestor = root->parentNode()) | 626 while (Node* ancestor = root->parentNode()) |
| 627 root = ancestor; | 627 root = ancestor; |
| 628 ASSERT(!root->shadowHost()); | 628 DCHECK(!root->shadowHost()); |
| 629 return *root; | 629 return *root; |
| 630 } | 630 } |
| 631 | 631 |
| 632 #if ENABLE(ASSERT) | 632 #if DCHECK_IS_ON() |
| 633 bool Node::needsDistributionRecalc() const | 633 bool Node::needsDistributionRecalc() const |
| 634 { | 634 { |
| 635 return shadowIncludingRoot().childNeedsDistributionRecalc(); | 635 return shadowIncludingRoot().childNeedsDistributionRecalc(); |
| 636 } | 636 } |
| 637 #endif | 637 #endif |
| 638 | 638 |
| 639 void Node::updateDistribution() | 639 void Node::updateDistribution() |
| 640 { | 640 { |
| 641 // Extra early out to avoid spamming traces. | 641 // Extra early out to avoid spamming traces. |
| 642 if (inShadowIncludingDocument() && !document().childNeedsDistributionRecalc(
)) | 642 if (inShadowIncludingDocument() && !document().childNeedsDistributionRecalc(
)) |
| 643 return; | 643 return; |
| 644 TRACE_EVENT0("blink", "Node::updateDistribution"); | 644 TRACE_EVENT0("blink", "Node::updateDistribution"); |
| 645 ScriptForbiddenScope forbidScript; | 645 ScriptForbiddenScope forbidScript; |
| 646 Node& root = shadowIncludingRoot(); | 646 Node& root = shadowIncludingRoot(); |
| 647 if (root.childNeedsDistributionRecalc()) | 647 if (root.childNeedsDistributionRecalc()) |
| 648 root.recalcDistribution(); | 648 root.recalcDistribution(); |
| 649 } | 649 } |
| 650 | 650 |
| 651 void Node::recalcDistribution() | 651 void Node::recalcDistribution() |
| 652 { | 652 { |
| 653 ASSERT(childNeedsDistributionRecalc()); | 653 DCHECK(childNeedsDistributionRecalc()); |
| 654 | 654 |
| 655 if (isElementNode()) { | 655 if (isElementNode()) { |
| 656 if (ElementShadow* shadow = toElement(this)->shadow()) | 656 if (ElementShadow* shadow = toElement(this)->shadow()) |
| 657 shadow->distributeIfNeeded(); | 657 shadow->distributeIfNeeded(); |
| 658 } | 658 } |
| 659 | 659 |
| 660 ASSERT(ScriptForbiddenScope::isScriptForbidden()); | 660 DCHECK(ScriptForbiddenScope::isScriptForbidden()); |
| 661 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 661 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 662 if (child->childNeedsDistributionRecalc()) | 662 if (child->childNeedsDistributionRecalc()) |
| 663 child->recalcDistribution(); | 663 child->recalcDistribution(); |
| 664 } | 664 } |
| 665 | 665 |
| 666 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { | 666 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { |
| 667 if (root->childNeedsDistributionRecalc()) | 667 if (root->childNeedsDistributionRecalc()) |
| 668 root->recalcDistribution(); | 668 root->recalcDistribution(); |
| 669 } | 669 } |
| 670 | 670 |
| 671 clearChildNeedsDistributionRecalc(); | 671 clearChildNeedsDistributionRecalc(); |
| 672 } | 672 } |
| 673 | 673 |
| 674 void Node::setIsLink(bool isLink) | 674 void Node::setIsLink(bool isLink) |
| 675 { | 675 { |
| 676 setFlag(isLink && !SVGImage::isInSVGImage(toElement(this)), IsLinkFlag); | 676 setFlag(isLink && !SVGImage::isInSVGImage(toElement(this)), IsLinkFlag); |
| 677 } | 677 } |
| 678 | 678 |
| 679 void Node::setNeedsStyleInvalidation() | 679 void Node::setNeedsStyleInvalidation() |
| 680 { | 680 { |
| 681 ASSERT(isElementNode()); | 681 DCHECK(isElementNode()); |
| 682 setFlag(NeedsStyleInvalidationFlag); | 682 setFlag(NeedsStyleInvalidationFlag); |
| 683 markAncestorsWithChildNeedsStyleInvalidation(); | 683 markAncestorsWithChildNeedsStyleInvalidation(); |
| 684 } | 684 } |
| 685 | 685 |
| 686 void Node::markAncestorsWithChildNeedsStyleInvalidation() | 686 void Node::markAncestorsWithChildNeedsStyleInvalidation() |
| 687 { | 687 { |
| 688 ScriptForbiddenScope forbidScriptDuringRawIteration; | 688 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 689 for (Node* node = parentOrShadowHostNode(); node && !node->childNeedsStyleIn
validation(); node = node->parentOrShadowHostNode()) | 689 for (Node* node = parentOrShadowHostNode(); node && !node->childNeedsStyleIn
validation(); node = node->parentOrShadowHostNode()) |
| 690 node->setChildNeedsStyleInvalidation(); | 690 node->setChildNeedsStyleInvalidation(); |
| 691 document().scheduleLayoutTreeUpdateIfNeeded(); | 691 document().scheduleLayoutTreeUpdateIfNeeded(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 711 | 711 |
| 712 void Node::markAncestorsWithChildNeedsStyleRecalc() | 712 void Node::markAncestorsWithChildNeedsStyleRecalc() |
| 713 { | 713 { |
| 714 for (ContainerNode* p = parentOrShadowHostNode(); p && !p->childNeedsStyleRe
calc(); p = p->parentOrShadowHostNode()) | 714 for (ContainerNode* p = parentOrShadowHostNode(); p && !p->childNeedsStyleRe
calc(); p = p->parentOrShadowHostNode()) |
| 715 p->setChildNeedsStyleRecalc(); | 715 p->setChildNeedsStyleRecalc(); |
| 716 document().scheduleLayoutTreeUpdateIfNeeded(); | 716 document().scheduleLayoutTreeUpdateIfNeeded(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 void Node::setNeedsStyleRecalc(StyleChangeType changeType, const StyleChangeReas
onForTracing& reason) | 719 void Node::setNeedsStyleRecalc(StyleChangeType changeType, const StyleChangeReas
onForTracing& reason) |
| 720 { | 720 { |
| 721 ASSERT(changeType != NoStyleChange); | 721 DCHECK(changeType != NoStyleChange); |
| 722 if (!inActiveDocument()) | 722 if (!inActiveDocument()) |
| 723 return; | 723 return; |
| 724 | 724 |
| 725 TRACE_EVENT_INSTANT1( | 725 TRACE_EVENT_INSTANT1( |
| 726 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), | 726 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), |
| 727 "StyleRecalcInvalidationTracking", | 727 "StyleRecalcInvalidationTracking", |
| 728 TRACE_EVENT_SCOPE_THREAD, | 728 TRACE_EVENT_SCOPE_THREAD, |
| 729 "data", | 729 "data", |
| 730 InspectorStyleRecalcInvalidationTrackingEvent::data(this, reason)); | 730 InspectorStyleRecalcInvalidationTrackingEvent::data(this, reason)); |
| 731 | 731 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 755 return inShadowIncludingDocument() && document().isActive(); | 755 return inShadowIncludingDocument() && document().isActive(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 Node* Node::focusDelegate() | 758 Node* Node::focusDelegate() |
| 759 { | 759 { |
| 760 return this; | 760 return this; |
| 761 } | 761 } |
| 762 | 762 |
| 763 bool Node::shouldHaveFocusAppearance() const | 763 bool Node::shouldHaveFocusAppearance() const |
| 764 { | 764 { |
| 765 ASSERT(focused()); | 765 DCHECK(focused()); |
| 766 return true; | 766 return true; |
| 767 } | 767 } |
| 768 | 768 |
| 769 bool Node::isInert() const | 769 bool Node::isInert() const |
| 770 { | 770 { |
| 771 const HTMLDialogElement* dialog = document().activeModalDialog(); | 771 const HTMLDialogElement* dialog = document().activeModalDialog(); |
| 772 if (dialog && this != document() && (!canParticipateInFlatTree() || !FlatTre
eTraversal::containsIncludingPseudoElement(*dialog, *this))) | 772 if (dialog && this != document() && (!canParticipateInFlatTree() || !FlatTre
eTraversal::containsIncludingPseudoElement(*dialog, *this))) |
| 773 return true; | 773 return true; |
| 774 return document().ownerElement() && document().ownerElement()->isInert(); | 774 return document().ownerElement() && document().ownerElement()->isInert(); |
| 775 } | 775 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 } else if (otherDepth > thisDepth) { | 883 } else if (otherDepth > thisDepth) { |
| 884 for (int i = otherDepth; i > thisDepth; --i) | 884 for (int i = otherDepth; i > thisDepth; --i) |
| 885 otherIterator = parent(*otherIterator); | 885 otherIterator = parent(*otherIterator); |
| 886 } | 886 } |
| 887 while (thisIterator) { | 887 while (thisIterator) { |
| 888 if (thisIterator == otherIterator) | 888 if (thisIterator == otherIterator) |
| 889 return const_cast<Node*>(thisIterator); | 889 return const_cast<Node*>(thisIterator); |
| 890 thisIterator = parent(*thisIterator); | 890 thisIterator = parent(*thisIterator); |
| 891 otherIterator = parent(*otherIterator); | 891 otherIterator = parent(*otherIterator); |
| 892 } | 892 } |
| 893 ASSERT(!otherIterator); | 893 DCHECK(!otherIterator); |
| 894 return nullptr; | 894 return nullptr; |
| 895 } | 895 } |
| 896 | 896 |
| 897 void Node::reattach(const AttachContext& context) | 897 void Node::reattach(const AttachContext& context) |
| 898 { | 898 { |
| 899 AttachContext reattachContext(context); | 899 AttachContext reattachContext(context); |
| 900 reattachContext.performingReattach = true; | 900 reattachContext.performingReattach = true; |
| 901 | 901 |
| 902 // We only need to detach if the node has already been through attach(). | 902 // We only need to detach if the node has already been through attach(). |
| 903 if (getStyleChangeType() < NeedsReattachStyleChange) | 903 if (getStyleChangeType() < NeedsReattachStyleChange) |
| 904 detach(reattachContext); | 904 detach(reattachContext); |
| 905 attach(reattachContext); | 905 attach(reattachContext); |
| 906 } | 906 } |
| 907 | 907 |
| 908 void Node::attach(const AttachContext&) | 908 void Node::attach(const AttachContext&) |
| 909 { | 909 { |
| 910 ASSERT(document().inStyleRecalc() || isDocumentNode()); | 910 DCHECK(document().inStyleRecalc() || isDocumentNode()); |
| 911 ASSERT(!document().lifecycle().inDetach()); | 911 DCHECK(!document().lifecycle().inDetach()); |
| 912 ASSERT(needsAttach()); | 912 DCHECK(needsAttach()); |
| 913 ASSERT(!layoutObject() || (layoutObject()->style() && (layoutObject()->paren
t() || layoutObject()->isLayoutView()))); | 913 DCHECK(!layoutObject() || (layoutObject()->style() && (layoutObject()->paren
t() || layoutObject()->isLayoutView()))); |
| 914 | 914 |
| 915 clearNeedsStyleRecalc(); | 915 clearNeedsStyleRecalc(); |
| 916 | 916 |
| 917 if (AXObjectCache* cache = document().axObjectCache()) | 917 if (AXObjectCache* cache = document().axObjectCache()) |
| 918 cache->updateCacheAfterNodeIsAttached(this); | 918 cache->updateCacheAfterNodeIsAttached(this); |
| 919 } | 919 } |
| 920 | 920 |
| 921 void Node::detach(const AttachContext& context) | 921 void Node::detach(const AttachContext& context) |
| 922 { | 922 { |
| 923 ASSERT(document().lifecycle().stateAllowsDetach()); | 923 DCHECK(document().lifecycle().stateAllowsDetach()); |
| 924 DocumentLifecycle::DetachScope willDetach(document().lifecycle()); | 924 DocumentLifecycle::DetachScope willDetach(document().lifecycle()); |
| 925 | 925 |
| 926 if (layoutObject()) | 926 if (layoutObject()) |
| 927 layoutObject()->destroyAndCleanupAnonymousWrappers(); | 927 layoutObject()->destroyAndCleanupAnonymousWrappers(); |
| 928 setLayoutObject(nullptr); | 928 setLayoutObject(nullptr); |
| 929 setStyleChange(NeedsReattachStyleChange); | 929 setStyleChange(NeedsReattachStyleChange); |
| 930 clearChildNeedsStyleInvalidation(); | 930 clearChildNeedsStyleInvalidation(); |
| 931 } | 931 } |
| 932 | 932 |
| 933 void Node::reattachWhitespaceSiblingsIfNeeded(Text* start) | 933 void Node::reattachWhitespaceSiblingsIfNeeded(Text* start) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 ShadowRoot* Node::containingShadowRoot() const | 1026 ShadowRoot* Node::containingShadowRoot() const |
| 1027 { | 1027 { |
| 1028 Node& root = treeScope().rootNode(); | 1028 Node& root = treeScope().rootNode(); |
| 1029 return root.isShadowRoot() ? toShadowRoot(&root) : nullptr; | 1029 return root.isShadowRoot() ? toShadowRoot(&root) : nullptr; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 Node* Node::nonBoundaryShadowTreeRootNode() | 1032 Node* Node::nonBoundaryShadowTreeRootNode() |
| 1033 { | 1033 { |
| 1034 ASSERT(!isShadowRoot()); | 1034 DCHECK(!isShadowRoot()); |
| 1035 Node* root = this; | 1035 Node* root = this; |
| 1036 while (root) { | 1036 while (root) { |
| 1037 if (root->isShadowRoot()) | 1037 if (root->isShadowRoot()) |
| 1038 return root; | 1038 return root; |
| 1039 Node* parent = root->parentOrShadowHostNode(); | 1039 Node* parent = root->parentOrShadowHostNode(); |
| 1040 if (parent && parent->isShadowRoot()) | 1040 if (parent && parent->isShadowRoot()) |
| 1041 return root; | 1041 return root; |
| 1042 root = parent; | 1042 root = parent; |
| 1043 } | 1043 } |
| 1044 return nullptr; | 1044 return nullptr; |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 DCHECK(!eventTargetDataMap().contains(this)); |
| 1903 setHasEventTargetData(true); | 1903 setHasEventTargetData(true); |
| 1904 RawPtr<EventTargetData> data = new EventTargetData; | 1904 RawPtr<EventTargetData> data = 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 DCHECK_IS_ON() |
| 1915 setHasEventTargetData(false); | 1915 setHasEventTargetData(false); |
| 1916 #endif | 1916 #endif |
| 1917 } | 1917 } |
| 1918 #endif | 1918 #endif |
| 1919 | 1919 |
| 1920 HeapVector<Member<MutationObserverRegistration>>* Node::mutationObserverRegistry
() | 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(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1948 MutationRecordDeliveryOptions deliveryOptions = registration->delive
ryOptions(); | 1948 MutationRecordDeliveryOptions deliveryOptions = registration->delive
ryOptions(); |
| 1949 HeapHashMap<Member<MutationObserver>, MutationRecordDeliveryOptions>
::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(HeapHashMap<Member<MutationObser
ver>, MutationRecordDeliveryOptions>& observers, MutationObserver::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 DCHECK((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) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 HeapVector<Member<MutationObserverRegistration>>* registry = mutationObserve
rRegistry(); | 1989 HeapVector<Member<MutationObserverRegistration>>* registry = mutationObserve
rRegistry(); |
| 1990 ASSERT(registry); | 1990 DCHECK(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 DCHECK_NE(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 RawPtr<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 HeapHashSet<Member<MutationObserverRegistration>>* transientRegistry = trans
ientMutationObserverRegistry(); | 2018 HeapHashSet<Member<MutationObserverRegistration>>* transientRegistry = trans
ientMutationObserverRegistry(); |
| 2019 ASSERT(transientRegistry); | 2019 DCHECK(transientRegistry); |
| 2020 if (!transientRegistry) | 2020 if (!transientRegistry) |
| 2021 return; | 2021 return; |
| 2022 | 2022 |
| 2023 ASSERT(transientRegistry->contains(registration)); | 2023 DCHECK(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()) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2064 DispatchEventResult Node::dispatchEventInternal(Event* event) | 2064 DispatchEventResult Node::dispatchEventInternal(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 #if DCHECK_IS_ON() |
| 2075 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 2076 #endif |
| 2075 | 2077 |
| 2076 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) | 2078 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) |
| 2077 return; | 2079 return; |
| 2078 | 2080 |
| 2079 dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMSubtreeModified
, true)); | 2081 dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMSubtreeModified
, true)); |
| 2080 } | 2082 } |
| 2081 | 2083 |
| 2082 DispatchEventResult Node::dispatchDOMActivateEvent(int detail, RawPtr<Event> und
erlyingEvent) | 2084 DispatchEventResult Node::dispatchDOMActivateEvent(int detail, RawPtr<Event> und
erlyingEvent) |
| 2083 { | 2085 { |
| 2084 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 2086 #if DCHECK_IS_ON() |
| 2087 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 2088 #endif |
| 2085 RawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActivate, true, t
rue, document().domWindow(), detail); | 2089 RawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActivate, true, t
rue, document().domWindow(), detail); |
| 2086 event->setUnderlyingEvent(underlyingEvent); | 2090 event->setUnderlyingEvent(underlyingEvent); |
| 2087 dispatchScopedEvent(event); | 2091 dispatchScopedEvent(event); |
| 2088 | 2092 |
| 2089 // TODO(dtapuska): Dispatching scoped events shouldn't check the return | 2093 // TODO(dtapuska): Dispatching scoped events shouldn't check the return |
| 2090 // type because the scoped event could get put off in the delayed queue. | 2094 // type because the scoped event could get put off in the delayed queue. |
| 2091 return EventTarget::dispatchEventResult(*event); | 2095 return EventTarget::dispatchEventResult(*event); |
| 2092 } | 2096 } |
| 2093 | 2097 |
| 2094 DispatchEventResult Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEve
nt, const AtomicString& eventType, | 2098 DispatchEventResult Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEve
nt, const AtomicString& eventType, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 inline void TreeScope::removedLastRefToScope() | 2211 inline void TreeScope::removedLastRefToScope() |
| 2208 { | 2212 { |
| 2209 ASSERT_WITH_SECURITY_IMPLICATION(!deletionHasBegun()); | 2213 ASSERT_WITH_SECURITY_IMPLICATION(!deletionHasBegun()); |
| 2210 if (m_guardRefCount) { | 2214 if (m_guardRefCount) { |
| 2211 // If removing a child removes the last self-only ref, we don't | 2215 // If removing a child removes the last self-only ref, we don't |
| 2212 // want the scope to be destructed until after | 2216 // want the scope to be destructed until after |
| 2213 // removeDetachedChildren returns, so we guard ourselves with an | 2217 // removeDetachedChildren returns, so we guard ourselves with an |
| 2214 // extra self-only ref. | 2218 // extra self-only ref. |
| 2215 guardRef(); | 2219 guardRef(); |
| 2216 dispose(); | 2220 dispose(); |
| 2217 #if ENABLE(ASSERT) | 2221 #if DCHECK_IS_ON() |
| 2218 // We need to do this right now since guardDeref() can delete this. | 2222 // We need to do this right now since guardDeref() can delete this. |
| 2219 rootNode().m_inRemovedLastRefFunction = false; | 2223 rootNode().m_inRemovedLastRefFunction = false; |
| 2220 #endif | 2224 #endif |
| 2221 guardDeref(); | 2225 guardDeref(); |
| 2222 } else { | 2226 } else { |
| 2223 #if ENABLE(ASSERT) | 2227 #if DCHECK_IS_ON() |
| 2224 rootNode().m_inRemovedLastRefFunction = false; | 2228 rootNode().m_inRemovedLastRefFunction = false; |
| 2225 #endif | 2229 #endif |
| 2226 #if ENABLE(SECURITY_ASSERT) | 2230 #if ENABLE(SECURITY_ASSERT) |
| 2227 beginDeletion(); | 2231 beginDeletion(); |
| 2228 #endif | 2232 #endif |
| 2229 delete this; | 2233 delete this; |
| 2230 } | 2234 } |
| 2231 } | 2235 } |
| 2232 | 2236 |
| 2233 // It's important not to inline removedLastRef, because we don't want to inline
the code to | 2237 // It's important not to inline removedLastRef, because we don't want to inline
the code to |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2249 } | 2253 } |
| 2250 #endif | 2254 #endif |
| 2251 | 2255 |
| 2252 unsigned Node::connectedSubframeCount() const | 2256 unsigned Node::connectedSubframeCount() const |
| 2253 { | 2257 { |
| 2254 return hasRareData() ? rareData()->connectedSubframeCount() : 0; | 2258 return hasRareData() ? rareData()->connectedSubframeCount() : 0; |
| 2255 } | 2259 } |
| 2256 | 2260 |
| 2257 void Node::incrementConnectedSubframeCount() | 2261 void Node::incrementConnectedSubframeCount() |
| 2258 { | 2262 { |
| 2259 ASSERT(isContainerNode()); | 2263 DCHECK(isContainerNode()); |
| 2260 ensureRareData().incrementConnectedSubframeCount(); | 2264 ensureRareData().incrementConnectedSubframeCount(); |
| 2261 } | 2265 } |
| 2262 | 2266 |
| 2263 void Node::decrementConnectedSubframeCount() | 2267 void Node::decrementConnectedSubframeCount() |
| 2264 { | 2268 { |
| 2265 rareData()->decrementConnectedSubframeCount(); | 2269 rareData()->decrementConnectedSubframeCount(); |
| 2266 } | 2270 } |
| 2267 | 2271 |
| 2268 RawPtr<StaticNodeList> Node::getDestinationInsertionPoints() | 2272 RawPtr<StaticNodeList> Node::getDestinationInsertionPoints() |
| 2269 { | 2273 { |
| 2270 updateDistribution(); | 2274 updateDistribution(); |
| 2271 HeapVector<Member<InsertionPoint>, 8> insertionPoints; | 2275 HeapVector<Member<InsertionPoint>, 8> insertionPoints; |
| 2272 collectDestinationInsertionPoints(*this, insertionPoints); | 2276 collectDestinationInsertionPoints(*this, insertionPoints); |
| 2273 HeapVector<Member<Node>> filteredInsertionPoints; | 2277 HeapVector<Member<Node>> filteredInsertionPoints; |
| 2274 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 2278 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| 2275 InsertionPoint* insertionPoint = insertionPoints[i]; | 2279 InsertionPoint* insertionPoint = insertionPoints[i]; |
| 2276 ASSERT(insertionPoint->containingShadowRoot()); | 2280 DCHECK(insertionPoint->containingShadowRoot()); |
| 2277 if (!insertionPoint->containingShadowRoot()->isOpenOrV0()) | 2281 if (!insertionPoint->containingShadowRoot()->isOpenOrV0()) |
| 2278 break; | 2282 break; |
| 2279 filteredInsertionPoints.append(insertionPoint); | 2283 filteredInsertionPoints.append(insertionPoint); |
| 2280 } | 2284 } |
| 2281 return StaticNodeList::adopt(filteredInsertionPoints); | 2285 return StaticNodeList::adopt(filteredInsertionPoints); |
| 2282 } | 2286 } |
| 2283 | 2287 |
| 2284 HTMLSlotElement* Node::assignedSlot() const | 2288 HTMLSlotElement* Node::assignedSlot() const |
| 2285 { | 2289 { |
| 2286 ASSERT(!needsDistributionRecalc()); | 2290 #if DCHECK_IS_ON() |
| 2291 DCHECK(!needsDistributionRecalc()); |
| 2292 #endif |
| 2287 if (ElementShadow* shadow = parentElementShadow()) { | 2293 if (ElementShadow* shadow = parentElementShadow()) { |
| 2288 if (shadow->isV1()) | 2294 if (shadow->isV1()) |
| 2289 return shadow->assignedSlotFor(*this); | 2295 return shadow->assignedSlotFor(*this); |
| 2290 } | 2296 } |
| 2291 return nullptr; | 2297 return nullptr; |
| 2292 } | 2298 } |
| 2293 | 2299 |
| 2294 HTMLSlotElement* Node::assignedSlotForBinding() | 2300 HTMLSlotElement* Node::assignedSlotForBinding() |
| 2295 { | 2301 { |
| 2296 updateDistribution(); | 2302 updateDistribution(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2311 document().userActionElements().setActive(this, flag); | 2317 document().userActionElements().setActive(this, flag); |
| 2312 } | 2318 } |
| 2313 | 2319 |
| 2314 void Node::setHovered(bool flag) | 2320 void Node::setHovered(bool flag) |
| 2315 { | 2321 { |
| 2316 document().userActionElements().setHovered(this, flag); | 2322 document().userActionElements().setHovered(this, flag); |
| 2317 } | 2323 } |
| 2318 | 2324 |
| 2319 bool Node::isUserActionElementActive() const | 2325 bool Node::isUserActionElementActive() const |
| 2320 { | 2326 { |
| 2321 ASSERT(isUserActionElement()); | 2327 DCHECK(isUserActionElement()); |
| 2322 return document().userActionElements().isActive(this); | 2328 return document().userActionElements().isActive(this); |
| 2323 } | 2329 } |
| 2324 | 2330 |
| 2325 bool Node::isUserActionElementInActiveChain() const | 2331 bool Node::isUserActionElementInActiveChain() const |
| 2326 { | 2332 { |
| 2327 ASSERT(isUserActionElement()); | 2333 DCHECK(isUserActionElement()); |
| 2328 return document().userActionElements().isInActiveChain(this); | 2334 return document().userActionElements().isInActiveChain(this); |
| 2329 } | 2335 } |
| 2330 | 2336 |
| 2331 bool Node::isUserActionElementHovered() const | 2337 bool Node::isUserActionElementHovered() const |
| 2332 { | 2338 { |
| 2333 ASSERT(isUserActionElement()); | 2339 DCHECK(isUserActionElement()); |
| 2334 return document().userActionElements().isHovered(this); | 2340 return document().userActionElements().isHovered(this); |
| 2335 } | 2341 } |
| 2336 | 2342 |
| 2337 bool Node::isUserActionElementFocused() const | 2343 bool Node::isUserActionElementFocused() const |
| 2338 { | 2344 { |
| 2339 ASSERT(isUserActionElement()); | 2345 DCHECK(isUserActionElement()); |
| 2340 return document().userActionElements().isFocused(this); | 2346 return document().userActionElements().isFocused(this); |
| 2341 } | 2347 } |
| 2342 | 2348 |
| 2343 void Node::setCustomElementState(CustomElementState newState) | 2349 void Node::setCustomElementState(CustomElementState newState) |
| 2344 { | 2350 { |
| 2345 CustomElementState oldState = getCustomElementState(); | 2351 CustomElementState oldState = getCustomElementState(); |
| 2346 | 2352 |
| 2347 switch (newState) { | 2353 switch (newState) { |
| 2348 case NotCustomElement: | 2354 case NotCustomElement: |
| 2349 ASSERT_NOT_REACHED(); // Everything starts in this state | 2355 ASSERT_NOT_REACHED(); // Everything starts in this state |
| 2350 return; | 2356 return; |
| 2351 | 2357 |
| 2352 case WaitingForUpgrade: | 2358 case WaitingForUpgrade: |
| 2353 ASSERT(NotCustomElement == oldState); | 2359 DCHECK_EQ(NotCustomElement, oldState); |
| 2354 break; | 2360 break; |
| 2355 | 2361 |
| 2356 case Upgraded: | 2362 case Upgraded: |
| 2357 ASSERT(WaitingForUpgrade == oldState); | 2363 DCHECK_EQ(WaitingForUpgrade, oldState); |
| 2358 break; | 2364 break; |
| 2359 } | 2365 } |
| 2360 | 2366 |
| 2361 ASSERT(isHTMLElement() || isSVGElement()); | 2367 DCHECK(isHTMLElement() || isSVGElement()); |
| 2362 setFlag(CustomElementFlag); | 2368 setFlag(CustomElementFlag); |
| 2363 setFlag(newState == Upgraded, CustomElementUpgradedFlag); | 2369 setFlag(newState == Upgraded, CustomElementUpgradedFlag); |
| 2364 | 2370 |
| 2365 if (oldState == NotCustomElement || newState == Upgraded) | 2371 if (oldState == NotCustomElement || newState == Upgraded) |
| 2366 toElement(this)->pseudoStateChanged(CSSSelector::PseudoUnresolved); | 2372 toElement(this)->pseudoStateChanged(CSSSelector::PseudoUnresolved); |
| 2367 } | 2373 } |
| 2368 | 2374 |
| 2369 DEFINE_TRACE(Node) | 2375 DEFINE_TRACE(Node) |
| 2370 { | 2376 { |
| 2371 visitor->trace(m_parentOrShadowHostNode); | 2377 visitor->trace(m_parentOrShadowHostNode); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2401 return 0; | 2407 return 0; |
| 2402 } | 2408 } |
| 2403 | 2409 |
| 2404 v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre
ationContext) | 2410 v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre
ationContext) |
| 2405 { | 2411 { |
| 2406 // It's possible that no one except for the new wrapper owns this object at | 2412 // It's possible that no one except for the new wrapper owns this object at |
| 2407 // this moment, so we have to prevent GC to collect this object until the | 2413 // this moment, so we have to prevent GC to collect this object until the |
| 2408 // object gets associated with the wrapper. | 2414 // object gets associated with the wrapper. |
| 2409 RawPtr<Node> protect(this); | 2415 RawPtr<Node> protect(this); |
| 2410 | 2416 |
| 2411 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); | 2417 DCHECK(!DOMDataStore::containsWrapper(this, isolate)); |
| 2412 | 2418 |
| 2413 const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); | 2419 const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); |
| 2414 | 2420 |
| 2415 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio
nContext, wrapperType, this); | 2421 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio
nContext, wrapperType, this); |
| 2416 if (UNLIKELY(wrapper.IsEmpty())) | 2422 if (UNLIKELY(wrapper.IsEmpty())) |
| 2417 return wrapper; | 2423 return wrapper; |
| 2418 | 2424 |
| 2419 wrapperType->installConditionallyEnabledProperties(wrapper, isolate); | 2425 wrapperType->installConditionallyEnabledProperties(wrapper, isolate); |
| 2420 return associateWithWrapper(isolate, wrapperType, wrapper); | 2426 return associateWithWrapper(isolate, wrapperType, wrapper); |
| 2421 } | 2427 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2447 | 2453 |
| 2448 void showNodePath(const blink::Node* node) | 2454 void showNodePath(const blink::Node* node) |
| 2449 { | 2455 { |
| 2450 if (node) | 2456 if (node) |
| 2451 node->showNodePathForThis(); | 2457 node->showNodePathForThis(); |
| 2452 else | 2458 else |
| 2453 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2459 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
| 2454 } | 2460 } |
| 2455 | 2461 |
| 2456 #endif | 2462 #endif |
| OLD | NEW |