Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.h

Issue 2119263002: [DO NOT LAND: Dummy CL] Storage of ComputedStyle separate from LayoutObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 class ComputedStyle; 84 class ComputedStyle;
85 class SVGQualifiedName; 85 class SVGQualifiedName;
86 class ShadowRoot; 86 class ShadowRoot;
87 template <typename NodeType> class StaticNodeTypeList; 87 template <typename NodeType> class StaticNodeTypeList;
88 using StaticNodeList = StaticNodeTypeList<Node>; 88 using StaticNodeList = StaticNodeTypeList<Node>;
89 class StyleChangeReasonForTracing; 89 class StyleChangeReasonForTracing;
90 class TagCollection; 90 class TagCollection;
91 class Text; 91 class Text;
92 class TouchEvent; 92 class TouchEvent;
93 93
94 const int nodeStyleChangeShift = 19; 94 const int nodeStyleChangeShift = 20;
95 const int nodeCustomElementShift = 21; 95 const int nodeCustomElementShift = 22;
96 96
97 enum StyleChangeType { 97 enum StyleChangeType {
98 NoStyleChange = 0, 98 NoStyleChange = 0,
99 LocalStyleChange = 1 << nodeStyleChangeShift, 99 LocalStyleChange = 1 << nodeStyleChangeShift,
100 SubtreeStyleChange = 2 << nodeStyleChangeShift, 100 SubtreeStyleChange = 2 << nodeStyleChangeShift,
101 NeedsReattachStyleChange = 3 << nodeStyleChangeShift, 101 NeedsReattachStyleChange = 3 << nodeStyleChangeShift,
102 }; 102 };
103 103
104 enum class CustomElementState { 104 enum class CustomElementState {
105 // https://dom.spec.whatwg.org/#concept-element-custom-element-state 105 // https://dom.spec.whatwg.org/#concept-element-custom-element-state
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 virtual int maxCharacterOffset() const; 481 virtual int maxCharacterOffset() const;
482 482
483 // Whether or not a selection can be started in this object 483 // Whether or not a selection can be started in this object
484 virtual bool canStartSelection() const; 484 virtual bool canStartSelection() const;
485 485
486 // ------------------------------------------------------------------------- ---- 486 // ------------------------------------------------------------------------- ----
487 // Integration with layout tree 487 // Integration with layout tree
488 488
489 // As layoutObject() includes a branch you should avoid calling it repeatedl y in hot code paths. 489 // As layoutObject() includes a branch you should avoid calling it repeatedl y in hot code paths.
490 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well. 490 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well.
491 LayoutObject* layoutObject() const { return hasRareData() ? m_data.m_rareDat a->layoutObject() : m_data.m_layoutObject; } 491 LayoutObject* layoutObject() const
492 {
493 if (hasRareData())
494 return m_data.m_rareData->layoutObject();
495 return hasLayoutObject() ? m_data.m_layoutObject : nullptr;
496 }
492 void setLayoutObject(LayoutObject* layoutObject) 497 void setLayoutObject(LayoutObject* layoutObject)
493 { 498 {
494 if (hasRareData()) 499 if (hasRareData())
495 m_data.m_rareData->setLayoutObject(layoutObject); 500 m_data.m_rareData->setLayoutObject(layoutObject);
496 else 501 else
497 m_data.m_layoutObject = layoutObject; 502 m_data.m_layoutObject = layoutObject;
503 if (layoutObject)
504 setFlag(HasLayoutObjectFlag);
505 else
506 clearFlag(HasLayoutObjectFlag);
498 } 507 }
499 508
500 // Use these two methods with caution. 509 // Use these two methods with caution.
501 LayoutBox* layoutBox() const; 510 LayoutBox* layoutBox() const;
502 LayoutBoxModelObject* layoutBoxModelObject() const; 511 LayoutBoxModelObject* layoutBoxModelObject() const;
503 512
504 struct AttachContext { 513 struct AttachContext {
505 STACK_ALLOCATED(); 514 STACK_ALLOCATED();
506 ComputedStyle* resolvedStyle = nullptr; 515 ComputedStyle* resolvedStyle = nullptr;
507 bool performingReattach = false; 516 bool performingReattach = false;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 664
656 DECLARE_VIRTUAL_TRACE_WRAPPERS(); 665 DECLARE_VIRTUAL_TRACE_WRAPPERS();
657 666
658 unsigned lengthOfContents() const; 667 unsigned lengthOfContents() const;
659 668
660 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override; 669 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override;
661 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn fo*, v8::Local<v8::Object> wrapper) override WARN_UNUSED_RETURN; 670 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn fo*, v8::Local<v8::Object> wrapper) override WARN_UNUSED_RETURN;
662 671
663 private: 672 private:
664 enum NodeFlags { 673 enum NodeFlags {
665 HasRareDataFlag = 1, 674 HasLayoutObjectFlag = 1,
675 HasRareDataFlag = 1 << 1,
666 676
667 // Node type flags. These never change once created. 677 // Node type flags. These never change once created.
668 IsTextFlag = 1 << 1, 678 IsTextFlag = 1 << 2,
669 IsContainerFlag = 1 << 2, 679 IsContainerFlag = 1 << 3,
670 IsElementFlag = 1 << 3, 680 IsElementFlag = 1 << 4,
671 IsHTMLFlag = 1 << 4, 681 IsHTMLFlag = 1 << 5,
672 IsSVGFlag = 1 << 5, 682 IsSVGFlag = 1 << 6,
673 IsDocumentFragmentFlag = 1 << 6, 683 IsDocumentFragmentFlag = 1 << 7,
674 IsInsertionPointFlag = 1 << 7, 684 IsInsertionPointFlag = 1 << 8,
675 685
676 // Changes based on if the element should be treated like a link, 686 // Changes based on if the element should be treated like a link,
677 // ex. When setting the href attribute on an <a>. 687 // ex. When setting the href attribute on an <a>.
678 IsLinkFlag = 1 << 8, 688 IsLinkFlag = 1 << 9,
679 689
680 // Changes based on :hover, :active and :focus state. 690 // Changes based on :hover, :active and :focus state.
681 IsUserActionElementFlag = 1 << 9, 691 IsUserActionElementFlag = 1 << 10,
682 692
683 // Tree state flags. These change when the element is added/removed 693 // Tree state flags. These change when the element is added/removed
684 // from a DOM tree. 694 // from a DOM tree.
685 IsConnectedFlag = 1 << 10, 695 IsConnectedFlag = 1 << 11,
686 IsInShadowTreeFlag = 1 << 11, 696 IsInShadowTreeFlag = 1 << 12,
687 697
688 // Set by the parser when the children are done parsing. 698 // Set by the parser when the children are done parsing.
689 IsFinishedParsingChildrenFlag = 1 << 12, 699 IsFinishedParsingChildrenFlag = 1 << 13,
690 700
691 // Flags related to recalcStyle. 701 // Flags related to recalcStyle.
692 SVGFilterNeedsLayerUpdateFlag = 1 << 13, 702 SVGFilterNeedsLayerUpdateFlag = 1 << 14,
693 HasCustomStyleCallbacksFlag = 1 << 14, 703 HasCustomStyleCallbacksFlag = 1 << 15,
694 ChildNeedsStyleInvalidationFlag = 1 << 15, 704 ChildNeedsStyleInvalidationFlag = 1 << 16,
695 NeedsStyleInvalidationFlag = 1 << 16, 705 NeedsStyleInvalidationFlag = 1 << 17,
696 ChildNeedsDistributionRecalcFlag = 1 << 17, 706 ChildNeedsDistributionRecalcFlag = 1 << 18,
697 ChildNeedsStyleRecalcFlag = 1 << 18, 707 ChildNeedsStyleRecalcFlag = 1 << 19,
698 StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1), 708 StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1),
699 709
700 CustomElementStateMask = 0x3 << nodeCustomElementShift, 710 CustomElementStateMask = 0x3 << nodeCustomElementShift,
701 711
702 HasNameOrIsEditingTextFlag = 1 << 23, 712 HasNameOrIsEditingTextFlag = 1 << 24,
703 HasWeakReferencesFlag = 1 << 24, 713 HasWeakReferencesFlag = 1 << 25,
704 V8CollectableDuringMinorGCFlag = 1 << 25, 714 V8CollectableDuringMinorGCFlag = 1 << 26,
705 HasEventTargetDataFlag = 1 << 26, 715 HasEventTargetDataFlag = 1 << 27,
706 AlreadySpellCheckedFlag = 1 << 27, 716 AlreadySpellCheckedFlag = 1 << 28,
707 717
708 V0CustomElementFlag = 1 << 28, 718 V0CustomElementFlag = 1 << 29,
709 V0CustomElementUpgradedFlag = 1 << 29, 719 V0CustomElementUpgradedFlag = 1 << 30,
710 720
711 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge 721 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge
712 }; 722 };
713 723
714 // 3 bits remaining. 724 // 1 bit remaining.
715 725
716 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } 726 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
717 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); } 727 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); }
718 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } 728 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; }
719 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } 729 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; }
720 730
721 protected: 731 protected:
722 enum ConstructionType { 732 enum ConstructionType {
723 CreateOther = DefaultNodeFlags, 733 CreateOther = DefaultNodeFlags,
724 CreateText = DefaultNodeFlags | IsTextFlag, 734 CreateText = DefaultNodeFlags | IsTextFlag,
(...skipping 11 matching lines...) Expand all
736 Node(TreeScope*, ConstructionType); 746 Node(TreeScope*, ConstructionType);
737 747
738 virtual void didMoveToNewDocument(Document& oldDocument); 748 virtual void didMoveToNewDocument(Document& oldDocument);
739 749
740 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override; 750 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override;
741 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override; 751 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override;
742 DispatchEventResult dispatchEventInternal(Event*) override; 752 DispatchEventResult dispatchEventInternal(Event*) override;
743 753
744 static void reattachWhitespaceSiblingsIfNeeded(Text* start); 754 static void reattachWhitespaceSiblingsIfNeeded(Text* start);
745 755
756 bool hasLayoutObject() const { return getFlag(HasLayoutObjectFlag); }
746 bool hasRareData() const { return getFlag(HasRareDataFlag); } 757 bool hasRareData() const { return getFlag(HasRareDataFlag); }
747 758
748 NodeRareData* rareData() const; 759 NodeRareData* rareData() const;
749 NodeRareData& ensureRareData(); 760 NodeRareData& ensureRareData();
750 761
751 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); } 762 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); }
752 763
753 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } 764 void setTreeScope(TreeScope* scope) { m_treeScope = scope; }
754 765
755 // isTreeScopeInitialized() can be false 766 // isTreeScopeInitialized() can be false
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry(); 801 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry();
791 802
792 uint32_t m_nodeFlags; 803 uint32_t m_nodeFlags;
793 Member<ContainerNode> m_parentOrShadowHostNode; 804 Member<ContainerNode> m_parentOrShadowHostNode;
794 Member<TreeScope> m_treeScope; 805 Member<TreeScope> m_treeScope;
795 Member<Node> m_previous; 806 Member<Node> m_previous;
796 Member<Node> m_next; 807 Member<Node> m_next;
797 // When a node has rare data we move the layoutObject into the rare data. 808 // When a node has rare data we move the layoutObject into the rare data.
798 union DataUnion { 809 union DataUnion {
799 DataUnion() : m_layoutObject(nullptr) { } 810 DataUnion() : m_layoutObject(nullptr) { }
811 ComputedStyle* m_computedStyle;
800 // LayoutObjects are fully owned by their DOM node. See LayoutObject's 812 // LayoutObjects are fully owned by their DOM node. See LayoutObject's
801 // LIFETIME documentation section. 813 // LIFETIME documentation section.
802 LayoutObject* m_layoutObject; 814 LayoutObject* m_layoutObject;
803 NodeRareDataBase* m_rareData; 815 NodeRareDataBase* m_rareData;
804 } m_data; 816 } m_data;
805 }; 817 };
806 818
807 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) 819 inline void Node::setParentOrShadowHostNode(ContainerNode* parent)
808 { 820 {
809 DCHECK(isMainThread()); 821 DCHECK(isMainThread());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 } // namespace blink 894 } // namespace blink
883 895
884 #ifndef NDEBUG 896 #ifndef NDEBUG
885 // Outside the WebCore namespace for ease of invocation from gdb. 897 // Outside the WebCore namespace for ease of invocation from gdb.
886 void showNode(const blink::Node*); 898 void showNode(const blink::Node*);
887 void showTree(const blink::Node*); 899 void showTree(const blink::Node*);
888 void showNodePath(const blink::Node*); 900 void showNodePath(const blink::Node*);
889 #endif 901 #endif
890 902
891 #endif // Node_h 903 #endif // Node_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698