Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 class ComputedStyle; | 83 class ComputedStyle; |
| 84 class SVGQualifiedName; | 84 class SVGQualifiedName; |
| 85 class ShadowRoot; | 85 class ShadowRoot; |
| 86 template <typename NodeType> class StaticNodeTypeList; | 86 template <typename NodeType> class StaticNodeTypeList; |
| 87 using StaticNodeList = StaticNodeTypeList<Node>; | 87 using StaticNodeList = StaticNodeTypeList<Node>; |
| 88 class StyleChangeReasonForTracing; | 88 class StyleChangeReasonForTracing; |
| 89 class TagCollection; | 89 class TagCollection; |
| 90 class Text; | 90 class Text; |
| 91 class TouchEvent; | 91 class TouchEvent; |
| 92 | 92 |
| 93 const int nodeStyleChangeShift = 19; | 93 const int nodeStyleChangeShift = 20; |
| 94 | 94 |
| 95 enum StyleChangeType { | 95 enum StyleChangeType { |
| 96 NoStyleChange = 0, | 96 NoStyleChange = 0, |
| 97 LocalStyleChange = 1 << nodeStyleChangeShift, | 97 LocalStyleChange = 1 << nodeStyleChangeShift, |
| 98 SubtreeStyleChange = 2 << nodeStyleChangeShift, | 98 SubtreeStyleChange = 2 << nodeStyleChangeShift, |
| 99 NeedsReattachStyleChange = 3 << nodeStyleChangeShift, | 99 NeedsReattachStyleChange = 3 << nodeStyleChangeShift, |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 enum class CustomElementState { | 102 enum class CustomElementState { |
| 103 Uncustomized = 0, | 103 Uncustomized = 0, |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 virtual int maxCharacterOffset() const; | 512 virtual int maxCharacterOffset() const; |
| 513 | 513 |
| 514 // Whether or not a selection can be started in this object | 514 // Whether or not a selection can be started in this object |
| 515 virtual bool canStartSelection() const; | 515 virtual bool canStartSelection() const; |
| 516 | 516 |
| 517 // ------------------------------------------------------------------------- ---- | 517 // ------------------------------------------------------------------------- ---- |
| 518 // Integration with layout tree | 518 // Integration with layout tree |
| 519 | 519 |
| 520 // As layoutObject() includes a branch you should avoid calling it repeatedl y in hot code paths. | 520 // As layoutObject() includes a branch you should avoid calling it repeatedl y in hot code paths. |
| 521 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well. | 521 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well. |
| 522 LayoutObject* layoutObject() const { return hasRareData() ? m_data.m_rareDat a->layoutObject() : m_data.m_layoutObject; } | 522 LayoutObject* layoutObject() const |
| 523 { | |
| 524 if (hasRareData()) | |
| 525 return m_data.m_rareData->layoutObject(); | |
| 526 return hasLayoutObject() ? m_data.m_layoutObject : nullptr; | |
| 527 } | |
| 523 void setLayoutObject(LayoutObject* layoutObject) | 528 void setLayoutObject(LayoutObject* layoutObject) |
| 524 { | 529 { |
| 525 if (hasRareData()) | 530 if (hasRareData()) |
| 526 m_data.m_rareData->setLayoutObject(layoutObject); | 531 m_data.m_rareData->setLayoutObject(layoutObject); |
| 527 else | 532 else |
| 528 m_data.m_layoutObject = layoutObject; | 533 m_data.m_layoutObject = layoutObject; |
| 534 if (layoutObject) | |
| 535 setFlag(HasLayoutObjectFlag); | |
| 536 else | |
| 537 clearFlag(HasLayoutObjectFlag); | |
| 529 } | 538 } |
| 530 | 539 |
| 531 // Use these two methods with caution. | 540 // Use these two methods with caution. |
| 532 LayoutBox* layoutBox() const; | 541 LayoutBox* layoutBox() const; |
| 533 LayoutBoxModelObject* layoutBoxModelObject() const; | 542 LayoutBoxModelObject* layoutBoxModelObject() const; |
| 534 | 543 |
| 535 struct AttachContext { | 544 struct AttachContext { |
| 536 STACK_ALLOCATED(); | 545 STACK_ALLOCATED(); |
| 537 ComputedStyle* resolvedStyle = nullptr; | 546 ComputedStyle* resolvedStyle = nullptr; |
| 538 bool performingReattach = false; | 547 bool performingReattach = false; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 | 695 |
| 687 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | 696 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
| 688 | 697 |
| 689 unsigned lengthOfContents() const; | 698 unsigned lengthOfContents() const; |
| 690 | 699 |
| 691 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override; | 700 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override; |
| 692 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn fo*, v8::Local<v8::Object> wrapper) override WARN_UNUSED_RETURN; | 701 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn fo*, v8::Local<v8::Object> wrapper) override WARN_UNUSED_RETURN; |
| 693 | 702 |
| 694 private: | 703 private: |
| 695 enum NodeFlags { | 704 enum NodeFlags { |
| 696 HasRareDataFlag = 1, | 705 HasLayoutObjectFlag = 1, |
| 706 HasRareDataFlag = 1 << 1, | |
| 697 | 707 |
| 698 // Node type flags. These never change once created. | 708 // Node type flags. These never change once created. |
| 699 IsTextFlag = 1 << 1, | 709 IsTextFlag = 1 << 2, |
| 700 IsContainerFlag = 1 << 2, | 710 IsContainerFlag = 1 << 3, |
| 701 IsElementFlag = 1 << 3, | 711 IsElementFlag = 1 << 4, |
| 702 IsHTMLFlag = 1 << 4, | 712 IsHTMLFlag = 1 << 5, |
| 703 IsSVGFlag = 1 << 5, | 713 IsSVGFlag = 1 << 6, |
| 704 IsDocumentFragmentFlag = 1 << 6, | 714 IsDocumentFragmentFlag = 1 << 7, |
| 705 IsInsertionPointFlag = 1 << 7, | 715 IsInsertionPointFlag = 1 << 8, |
| 706 | 716 |
| 707 // Changes based on if the element should be treated like a link, | 717 // Changes based on if the element should be treated like a link, |
| 708 // ex. When setting the href attribute on an <a>. | 718 // ex. When setting the href attribute on an <a>. |
| 709 IsLinkFlag = 1 << 8, | 719 IsLinkFlag = 1 << 9, |
| 710 | 720 |
| 711 // Changes based on :hover, :active and :focus state. | 721 // Changes based on :hover, :active and :focus state. |
| 712 IsUserActionElementFlag = 1 << 9, | 722 IsUserActionElementFlag = 1 << 10, |
| 713 | 723 |
| 714 // Tree state flags. These change when the element is added/removed | 724 // Tree state flags. These change when the element is added/removed |
| 715 // from a DOM tree. | 725 // from a DOM tree. |
| 716 InDocumentFlag = 1 << 10, | 726 InDocumentFlag = 1 << 11, |
| 717 IsInShadowTreeFlag = 1 << 11, | 727 IsInShadowTreeFlag = 1 << 12, |
| 718 | 728 |
| 719 // Set by the parser when the children are done parsing. | 729 // Set by the parser when the children are done parsing. |
| 720 IsFinishedParsingChildrenFlag = 1 << 12, | 730 IsFinishedParsingChildrenFlag = 1 << 13, |
| 721 | 731 |
| 722 // Flags related to recalcStyle. | 732 // Flags related to recalcStyle. |
| 723 SVGFilterNeedsLayerUpdateFlag = 1 << 13, | 733 SVGFilterNeedsLayerUpdateFlag = 1 << 14, |
| 724 HasCustomStyleCallbacksFlag = 1 << 14, | 734 HasCustomStyleCallbacksFlag = 1 << 15, |
| 725 ChildNeedsStyleInvalidationFlag = 1 << 15, | 735 ChildNeedsStyleInvalidationFlag = 1 << 16, |
| 726 NeedsStyleInvalidationFlag = 1 << 16, | 736 NeedsStyleInvalidationFlag = 1 << 17, |
| 727 ChildNeedsDistributionRecalcFlag = 1 << 17, | 737 ChildNeedsDistributionRecalcFlag = 1 << 18, |
| 728 ChildNeedsStyleRecalcFlag = 1 << 18, | 738 ChildNeedsStyleRecalcFlag = 1 << 19, |
| 729 StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1), | 739 StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1), |
| 730 | 740 |
| 731 CustomElementFlag = 1 << 21, | 741 CustomElementFlag = 1 << 22, |
| 732 CustomElementCustomFlag = 1 << 22, | 742 CustomElementCustomFlag = 1 << 23, |
| 733 | 743 |
| 734 HasNameOrIsEditingTextFlag = 1 << 23, | 744 HasNameOrIsEditingTextFlag = 1 << 24, |
| 735 HasWeakReferencesFlag = 1 << 24, | 745 HasWeakReferencesFlag = 1 << 25, |
| 736 V8CollectableDuringMinorGCFlag = 1 << 25, | 746 V8CollectableDuringMinorGCFlag = 1 << 26, |
| 737 HasEventTargetDataFlag = 1 << 26, | 747 HasEventTargetDataFlag = 1 << 27, |
| 738 AlreadySpellCheckedFlag = 1 << 27, | 748 AlreadySpellCheckedFlag = 1 << 28, |
| 739 | 749 |
| 740 V0CustomElementFlag = 1 << 28, | 750 V0CustomElementFlag = 1 << 29, |
| 741 V0CustomElementUpgradedFlag = 1 << 29, | 751 V0CustomElementUpgradedFlag = 1 << 30, |
| 742 | 752 |
| 743 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge | 753 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge |
| 744 }; | 754 }; |
| 745 | 755 |
| 746 // 3 bits remaining. | 756 // 1 bit remaining. |
| 747 | 757 |
| 748 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } | 758 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } |
| 749 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); } | 759 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); } |
| 750 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } | 760 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } |
| 751 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } | 761 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } |
| 752 | 762 |
| 753 protected: | 763 protected: |
| 754 enum ConstructionType { | 764 enum ConstructionType { |
| 755 CreateOther = DefaultNodeFlags, | 765 CreateOther = DefaultNodeFlags, |
| 756 CreateText = DefaultNodeFlags | IsTextFlag, | 766 CreateText = DefaultNodeFlags | IsTextFlag, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 768 Node(TreeScope*, ConstructionType); | 778 Node(TreeScope*, ConstructionType); |
| 769 | 779 |
| 770 virtual void didMoveToNewDocument(Document& oldDocument); | 780 virtual void didMoveToNewDocument(Document& oldDocument); |
| 771 | 781 |
| 772 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override; | 782 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override; |
| 773 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override; | 783 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override; |
| 774 DispatchEventResult dispatchEventInternal(Event*) override; | 784 DispatchEventResult dispatchEventInternal(Event*) override; |
| 775 | 785 |
| 776 static void reattachWhitespaceSiblingsIfNeeded(Text* start); | 786 static void reattachWhitespaceSiblingsIfNeeded(Text* start); |
| 777 | 787 |
| 788 bool hasLayoutObject() const { return getFlag(HasLayoutObjectFlag); } | |
| 778 bool hasRareData() const { return getFlag(HasRareDataFlag); } | 789 bool hasRareData() const { return getFlag(HasRareDataFlag); } |
| 779 | 790 |
| 780 NodeRareData* rareData() const; | 791 NodeRareData* rareData() const; |
| 781 NodeRareData& ensureRareData(); | 792 NodeRareData& ensureRareData(); |
| 782 | 793 |
| 783 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); } | 794 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); } |
| 784 | 795 |
| 785 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } | 796 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } |
| 786 | 797 |
| 787 // isTreeScopeInitialized() can be false | 798 // isTreeScopeInitialized() can be false |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry(); | 837 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry(); |
| 827 | 838 |
| 828 uint32_t m_nodeFlags; | 839 uint32_t m_nodeFlags; |
| 829 Member<ContainerNode> m_parentOrShadowHostNode; | 840 Member<ContainerNode> m_parentOrShadowHostNode; |
| 830 Member<TreeScope> m_treeScope; | 841 Member<TreeScope> m_treeScope; |
| 831 Member<Node> m_previous; | 842 Member<Node> m_previous; |
| 832 Member<Node> m_next; | 843 Member<Node> m_next; |
| 833 // When a node has rare data we move the layoutObject into the rare data. | 844 // When a node has rare data we move the layoutObject into the rare data. |
| 834 union DataUnion { | 845 union DataUnion { |
| 835 DataUnion() : m_layoutObject(nullptr) { } | 846 DataUnion() : m_layoutObject(nullptr) { } |
| 847 ComputedStyle* m_computedStyle; | |
|
esprehn
2016/06/24 17:51:14
You'll want to replace ElementRareDatas member wit
| |
| 836 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | 848 // LayoutObjects are fully owned by their DOM node. See LayoutObject's |
| 837 // LIFETIME documentation section. | 849 // LIFETIME documentation section. |
| 838 LayoutObject* m_layoutObject; | 850 LayoutObject* m_layoutObject; |
| 839 NodeRareDataBase* m_rareData; | 851 NodeRareDataBase* m_rareData; |
| 840 } m_data; | 852 } m_data; |
| 841 }; | 853 }; |
| 842 | 854 |
| 843 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) | 855 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) |
| 844 { | 856 { |
| 845 DCHECK(isMainThread()); | 857 DCHECK(isMainThread()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 920 } // namespace blink | 932 } // namespace blink |
| 921 | 933 |
| 922 #ifndef NDEBUG | 934 #ifndef NDEBUG |
| 923 // Outside the WebCore namespace for ease of invocation from gdb. | 935 // Outside the WebCore namespace for ease of invocation from gdb. |
| 924 void showNode(const blink::Node*); | 936 void showNode(const blink::Node*); |
| 925 void showTree(const blink::Node*); | 937 void showTree(const blink::Node*); |
| 926 void showNodePath(const blink::Node*); | 938 void showNodePath(const blink::Node*); |
| 927 #endif | 939 #endif |
| 928 | 940 |
| 929 #endif // Node_h | 941 #endif // Node_h |
| OLD | NEW |