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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 virtual int maxCharacterOffset() const; | 504 virtual int maxCharacterOffset() const; |
505 | 505 |
506 // Whether or not a selection can be started in this object | 506 // Whether or not a selection can be started in this object |
507 virtual bool canStartSelection() const; | 507 virtual bool canStartSelection() const; |
508 | 508 |
509 // ------------------------------------------------------------------------- ---- | 509 // ------------------------------------------------------------------------- ---- |
510 // Integration with layout tree | 510 // Integration with layout tree |
511 | 511 |
512 // As layoutObject() includes a branch you should avoid calling it repeatedl y in hot code paths. | 512 // As layoutObject() includes a branch you should avoid calling it repeatedl y in hot code paths. |
513 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well. | 513 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well. |
514 LayoutObject* layoutObject() const { return hasRareData() ? m_data.m_rareDat a->layoutObject() : m_data.m_layoutObject; } | 514 LayoutObject* layoutObject() const |
515 { | |
516 if (hasRareData()) | |
517 return m_data.m_rareData->layoutObject(); | |
518 return hasLayoutObject() ? m_data.m_layoutObject : nullptr; | |
519 } | |
515 void setLayoutObject(LayoutObject* layoutObject) | 520 void setLayoutObject(LayoutObject* layoutObject) |
516 { | 521 { |
517 if (hasRareData()) | 522 if (hasRareData()) |
518 m_data.m_rareData->setLayoutObject(layoutObject); | 523 m_data.m_rareData->setLayoutObject(layoutObject); |
519 else | 524 else |
520 m_data.m_layoutObject = layoutObject; | 525 m_data.m_layoutObject = layoutObject; |
526 if (layoutObject) | |
527 setFlag(HasLayoutObjectFlag); | |
esprehn
2016/08/05 21:26:26
setFlag(static_cast<bool>(layoutObject), HasLayout
Bugs Nash
2016/08/12 03:55:33
Done
| |
528 else | |
529 clearFlag(HasLayoutObjectFlag); | |
521 } | 530 } |
522 | 531 |
523 // Use these two methods with caution. | 532 // Use these two methods with caution. |
524 LayoutBox* layoutBox() const; | 533 LayoutBox* layoutBox() const; |
525 LayoutBoxModelObject* layoutBoxModelObject() const; | 534 LayoutBoxModelObject* layoutBoxModelObject() const; |
526 | 535 |
527 struct AttachContext { | 536 struct AttachContext { |
528 STACK_ALLOCATED(); | 537 STACK_ALLOCATED(); |
529 ComputedStyle* resolvedStyle = nullptr; | 538 ComputedStyle* resolvedStyle = nullptr; |
530 bool performingReattach = false; | 539 bool performingReattach = false; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 | 734 |
726 HasNameOrIsEditingTextFlag = 1 << 23, | 735 HasNameOrIsEditingTextFlag = 1 << 23, |
727 HasWeakReferencesFlag = 1 << 24, | 736 HasWeakReferencesFlag = 1 << 24, |
728 V8CollectableDuringMinorGCFlag = 1 << 25, | 737 V8CollectableDuringMinorGCFlag = 1 << 25, |
729 HasEventTargetDataFlag = 1 << 26, | 738 HasEventTargetDataFlag = 1 << 26, |
730 AlreadySpellCheckedFlag = 1 << 27, | 739 AlreadySpellCheckedFlag = 1 << 27, |
731 | 740 |
732 V0CustomElementFlag = 1 << 28, | 741 V0CustomElementFlag = 1 << 28, |
733 V0CustomElementUpgradedFlag = 1 << 29, | 742 V0CustomElementUpgradedFlag = 1 << 29, |
734 | 743 |
744 HasLayoutObjectFlag = 1 << 30, | |
745 | |
735 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge | 746 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge |
736 }; | 747 }; |
737 | 748 |
738 // 3 bits remaining. | 749 // 1 bit remaining. |
esprehn
2016/08/05 21:26:26
thanks for fixing this :)
| |
739 | 750 |
740 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } | 751 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } |
741 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); } | 752 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); } |
742 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } | 753 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } |
743 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } | 754 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } |
744 | 755 |
745 protected: | 756 protected: |
746 enum ConstructionType { | 757 enum ConstructionType { |
747 CreateOther = DefaultNodeFlags, | 758 CreateOther = DefaultNodeFlags, |
748 CreateText = DefaultNodeFlags | IsTextFlag, | 759 CreateText = DefaultNodeFlags | IsTextFlag, |
(...skipping 11 matching lines...) Expand all Loading... | |
760 Node(TreeScope*, ConstructionType); | 771 Node(TreeScope*, ConstructionType); |
761 | 772 |
762 virtual void didMoveToNewDocument(Document& oldDocument); | 773 virtual void didMoveToNewDocument(Document& oldDocument); |
763 | 774 |
764 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override; | 775 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override; |
765 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override; | 776 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override; |
766 DispatchEventResult dispatchEventInternal(Event*) override; | 777 DispatchEventResult dispatchEventInternal(Event*) override; |
767 | 778 |
768 static void reattachWhitespaceSiblingsIfNeeded(Text* start); | 779 static void reattachWhitespaceSiblingsIfNeeded(Text* start); |
769 | 780 |
781 bool hasLayoutObject() const { return getFlag(HasLayoutObjectFlag); } | |
770 bool hasRareData() const { return getFlag(HasRareDataFlag); } | 782 bool hasRareData() const { return getFlag(HasRareDataFlag); } |
771 | 783 |
772 NodeRareData* rareData() const; | 784 NodeRareData* rareData() const; |
773 NodeRareData& ensureRareData(); | 785 NodeRareData& ensureRareData(); |
774 | 786 |
775 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); } | 787 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); } |
776 | 788 |
777 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } | 789 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } |
778 | 790 |
779 // isTreeScopeInitialized() can be false | 791 // isTreeScopeInitialized() can be false |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
818 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry(); | 830 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry(); |
819 | 831 |
820 uint32_t m_nodeFlags; | 832 uint32_t m_nodeFlags; |
821 Member<ContainerNode> m_parentOrShadowHostNode; | 833 Member<ContainerNode> m_parentOrShadowHostNode; |
822 Member<TreeScope> m_treeScope; | 834 Member<TreeScope> m_treeScope; |
823 Member<Node> m_previous; | 835 Member<Node> m_previous; |
824 Member<Node> m_next; | 836 Member<Node> m_next; |
825 // When a node has rare data we move the layoutObject into the rare data. | 837 // When a node has rare data we move the layoutObject into the rare data. |
826 union DataUnion { | 838 union DataUnion { |
827 DataUnion() : m_layoutObject(nullptr) { } | 839 DataUnion() : m_layoutObject(nullptr) { } |
840 ComputedStyle* m_computedStyle; | |
828 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | 841 // LayoutObjects are fully owned by their DOM node. See LayoutObject's |
829 // LIFETIME documentation section. | 842 // LIFETIME documentation section. |
830 LayoutObject* m_layoutObject; | 843 LayoutObject* m_layoutObject; |
831 NodeRareDataBase* m_rareData; | 844 NodeRareDataBase* m_rareData; |
832 } m_data; | 845 } m_data; |
833 }; | 846 }; |
834 | 847 |
835 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) | 848 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) |
836 { | 849 { |
837 DCHECK(isMainThread()); | 850 DCHECK(isMainThread()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
917 } // namespace blink | 930 } // namespace blink |
918 | 931 |
919 #ifndef NDEBUG | 932 #ifndef NDEBUG |
920 // Outside the WebCore namespace for ease of invocation from gdb. | 933 // Outside the WebCore namespace for ease of invocation from gdb. |
921 void showNode(const blink::Node*); | 934 void showNode(const blink::Node*); |
922 void showTree(const blink::Node*); | 935 void showTree(const blink::Node*); |
923 void showNodePath(const blink::Node*); | 936 void showNodePath(const blink::Node*); |
924 #endif | 937 #endif |
925 | 938 |
926 #endif // Node_h | 939 #endif // Node_h |
OLD | NEW |