| 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-2011, 2014 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 virtual int maxCharacterOffset() const; | 470 virtual int maxCharacterOffset() const; |
| 471 | 471 |
| 472 // Whether or not a selection can be started in this object | 472 // Whether or not a selection can be started in this object |
| 473 virtual bool canStartSelection() const; | 473 virtual bool canStartSelection() const; |
| 474 | 474 |
| 475 // -------------------------------------------------------------------------
---- | 475 // -------------------------------------------------------------------------
---- |
| 476 // Integration with layout tree | 476 // Integration with layout tree |
| 477 | 477 |
| 478 // As layoutObject() includes a branch you should avoid calling it repeatedl
y in hot code paths. | 478 // As layoutObject() includes a branch you should avoid calling it repeatedl
y in hot code paths. |
| 479 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to
have one as well. | 479 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to
have one as well. |
| 480 LayoutObject* layoutObject() const { return hasRareData() ? m_data.m_rareDat
a->layoutObject() : m_data.m_layoutObject; } | 480 LayoutObject* layoutObject() const |
| 481 { |
| 482 if (hasRareData()) |
| 483 return m_data.m_rareData->layoutObject(); |
| 484 return hasLayoutObject() ? m_data.m_layoutObject : nullptr; |
| 485 } |
| 481 void setLayoutObject(LayoutObject* layoutObject) | 486 void setLayoutObject(LayoutObject* layoutObject) |
| 482 { | 487 { |
| 483 if (hasRareData()) | 488 if (hasRareData()) |
| 484 m_data.m_rareData->setLayoutObject(layoutObject); | 489 m_data.m_rareData->setLayoutObject(layoutObject); |
| 485 else | 490 else |
| 486 m_data.m_layoutObject = layoutObject; | 491 m_data.m_layoutObject = layoutObject; |
| 492 setFlag(static_cast<bool>(layoutObject), HasLayoutObjectFlag); |
| 487 } | 493 } |
| 488 | 494 |
| 489 // Use these two methods with caution. | 495 // Use these two methods with caution. |
| 490 LayoutBox* layoutBox() const; | 496 LayoutBox* layoutBox() const; |
| 491 LayoutBoxModelObject* layoutBoxModelObject() const; | 497 LayoutBoxModelObject* layoutBoxModelObject() const; |
| 492 | 498 |
| 493 struct AttachContext { | 499 struct AttachContext { |
| 494 STACK_ALLOCATED(); | 500 STACK_ALLOCATED(); |
| 495 ComputedStyle* resolvedStyle = nullptr; | 501 ComputedStyle* resolvedStyle = nullptr; |
| 496 bool performingReattach = false; | 502 bool performingReattach = false; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 696 |
| 691 HasNameOrIsEditingTextFlag = 1 << 23, | 697 HasNameOrIsEditingTextFlag = 1 << 23, |
| 692 HasWeakReferencesFlag = 1 << 24, | 698 HasWeakReferencesFlag = 1 << 24, |
| 693 V8CollectableDuringMinorGCFlag = 1 << 25, | 699 V8CollectableDuringMinorGCFlag = 1 << 25, |
| 694 HasEventTargetDataFlag = 1 << 26, | 700 HasEventTargetDataFlag = 1 << 26, |
| 695 AlreadySpellCheckedFlag = 1 << 27, | 701 AlreadySpellCheckedFlag = 1 << 27, |
| 696 | 702 |
| 697 V0CustomElementFlag = 1 << 28, | 703 V0CustomElementFlag = 1 << 28, |
| 698 V0CustomElementUpgradedFlag = 1 << 29, | 704 V0CustomElementUpgradedFlag = 1 << 29, |
| 699 | 705 |
| 706 HasLayoutObjectFlag = 1 << 30, |
| 707 |
| 700 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha
nge | 708 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha
nge |
| 701 }; | 709 }; |
| 702 | 710 |
| 703 // 3 bits remaining. | 711 // 1 bit remaining. |
| 704 | 712 |
| 705 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } | 713 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } |
| 706 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) |
(-(int32_t)f & mask); } | 714 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) |
(-(int32_t)f & mask); } |
| 707 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } | 715 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } |
| 708 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } | 716 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } |
| 709 | 717 |
| 710 protected: | 718 protected: |
| 711 enum ConstructionType { | 719 enum ConstructionType { |
| 712 CreateOther = DefaultNodeFlags, | 720 CreateOther = DefaultNodeFlags, |
| 713 CreateText = DefaultNodeFlags | IsTextFlag, | 721 CreateText = DefaultNodeFlags | IsTextFlag, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 725 Node(TreeScope*, ConstructionType); | 733 Node(TreeScope*, ConstructionType); |
| 726 | 734 |
| 727 virtual void didMoveToNewDocument(Document& oldDocument); | 735 virtual void didMoveToNewDocument(Document& oldDocument); |
| 728 | 736 |
| 729 void addedEventListener(const AtomicString& eventType, RegisteredEventListen
er&) override; | 737 void addedEventListener(const AtomicString& eventType, RegisteredEventListen
er&) override; |
| 730 void removedEventListener(const AtomicString& eventType, const RegisteredEve
ntListener&) override; | 738 void removedEventListener(const AtomicString& eventType, const RegisteredEve
ntListener&) override; |
| 731 DispatchEventResult dispatchEventInternal(Event*) override; | 739 DispatchEventResult dispatchEventInternal(Event*) override; |
| 732 | 740 |
| 733 static void reattachWhitespaceSiblingsIfNeeded(Text* start); | 741 static void reattachWhitespaceSiblingsIfNeeded(Text* start); |
| 734 | 742 |
| 743 bool hasLayoutObject() const { return getFlag(HasLayoutObjectFlag); } |
| 735 bool hasRareData() const { return getFlag(HasRareDataFlag); } | 744 bool hasRareData() const { return getFlag(HasRareDataFlag); } |
| 736 | 745 |
| 737 NodeRareData* rareData() const; | 746 NodeRareData* rareData() const; |
| 738 NodeRareData& ensureRareData(); | 747 NodeRareData& ensureRareData(); |
| 739 | 748 |
| 740 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla
g); } | 749 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla
g); } |
| 741 | 750 |
| 742 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } | 751 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } |
| 743 | 752 |
| 744 // isTreeScopeInitialized() can be false | 753 // isTreeScopeInitialized() can be false |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver
Registry(); | 788 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver
Registry(); |
| 780 | 789 |
| 781 uint32_t m_nodeFlags; | 790 uint32_t m_nodeFlags; |
| 782 Member<ContainerNode> m_parentOrShadowHostNode; | 791 Member<ContainerNode> m_parentOrShadowHostNode; |
| 783 Member<TreeScope> m_treeScope; | 792 Member<TreeScope> m_treeScope; |
| 784 Member<Node> m_previous; | 793 Member<Node> m_previous; |
| 785 Member<Node> m_next; | 794 Member<Node> m_next; |
| 786 // When a node has rare data we move the layoutObject into the rare data. | 795 // When a node has rare data we move the layoutObject into the rare data. |
| 787 union DataUnion { | 796 union DataUnion { |
| 788 DataUnion() : m_layoutObject(nullptr) { } | 797 DataUnion() : m_layoutObject(nullptr) { } |
| 798 ComputedStyle* m_computedStyle; |
| 789 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | 799 // LayoutObjects are fully owned by their DOM node. See LayoutObject's |
| 790 // LIFETIME documentation section. | 800 // LIFETIME documentation section. |
| 791 LayoutObject* m_layoutObject; | 801 LayoutObject* m_layoutObject; |
| 792 NodeRareDataBase* m_rareData; | 802 NodeRareDataBase* m_rareData; |
| 793 } m_data; | 803 } m_data; |
| 794 }; | 804 }; |
| 795 | 805 |
| 796 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) | 806 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) |
| 797 { | 807 { |
| 798 DCHECK(isMainThread()); | 808 DCHECK(isMainThread()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } // namespace blink | 881 } // namespace blink |
| 872 | 882 |
| 873 #ifndef NDEBUG | 883 #ifndef NDEBUG |
| 874 // Outside the WebCore namespace for ease of invocation from gdb. | 884 // Outside the WebCore namespace for ease of invocation from gdb. |
| 875 void showNode(const blink::Node*); | 885 void showNode(const blink::Node*); |
| 876 void showTree(const blink::Node*); | 886 void showTree(const blink::Node*); |
| 877 void showNodePath(const blink::Node*); | 887 void showNodePath(const blink::Node*); |
| 878 #endif | 888 #endif |
| 879 | 889 |
| 880 #endif // Node_h | 890 #endif // Node_h |
| OLD | NEW |