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

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

Issue 2093143002: Revert of Storage of ComputedStyle separate from LayoutObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = 20; 93 const int nodeStyleChangeShift = 19;
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
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 522 LayoutObject* layoutObject() const { return hasRareData() ? m_data.m_rareDat a->layoutObject() : m_data.m_layoutObject; }
523 {
524 if (hasRareData())
525 return m_data.m_rareData->layoutObject();
526 return hasLayoutObject() ? m_data.m_layoutObject : nullptr;
527 }
528 void setLayoutObject(LayoutObject* layoutObject) 523 void setLayoutObject(LayoutObject* layoutObject)
529 { 524 {
530 if (hasRareData()) 525 if (hasRareData())
531 m_data.m_rareData->setLayoutObject(layoutObject); 526 m_data.m_rareData->setLayoutObject(layoutObject);
532 else 527 else
533 m_data.m_layoutObject = layoutObject; 528 m_data.m_layoutObject = layoutObject;
534 if (layoutObject)
535 setFlag(HasLayoutObjectFlag);
536 else
537 clearFlag(HasLayoutObjectFlag);
538 } 529 }
539 530
540 // Use these two methods with caution. 531 // Use these two methods with caution.
541 LayoutBox* layoutBox() const; 532 LayoutBox* layoutBox() const;
542 LayoutBoxModelObject* layoutBoxModelObject() const; 533 LayoutBoxModelObject* layoutBoxModelObject() const;
543 534
544 struct AttachContext { 535 struct AttachContext {
545 STACK_ALLOCATED(); 536 STACK_ALLOCATED();
546 ComputedStyle* resolvedStyle = nullptr; 537 ComputedStyle* resolvedStyle = nullptr;
547 bool performingReattach = false; 538 bool performingReattach = false;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 686
696 DECLARE_VIRTUAL_TRACE_WRAPPERS(); 687 DECLARE_VIRTUAL_TRACE_WRAPPERS();
697 688
698 unsigned lengthOfContents() const; 689 unsigned lengthOfContents() const;
699 690
700 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override; 691 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) override;
701 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn fo*, v8::Local<v8::Object> wrapper) override WARN_UNUSED_RETURN; 692 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn fo*, v8::Local<v8::Object> wrapper) override WARN_UNUSED_RETURN;
702 693
703 private: 694 private:
704 enum NodeFlags { 695 enum NodeFlags {
705 HasLayoutObjectFlag = 1, 696 HasRareDataFlag = 1,
706 HasRareDataFlag = 1 << 1,
707 697
708 // Node type flags. These never change once created. 698 // Node type flags. These never change once created.
709 IsTextFlag = 1 << 2, 699 IsTextFlag = 1 << 1,
710 IsContainerFlag = 1 << 3, 700 IsContainerFlag = 1 << 2,
711 IsElementFlag = 1 << 4, 701 IsElementFlag = 1 << 3,
712 IsHTMLFlag = 1 << 5, 702 IsHTMLFlag = 1 << 4,
713 IsSVGFlag = 1 << 6, 703 IsSVGFlag = 1 << 5,
714 IsDocumentFragmentFlag = 1 << 7, 704 IsDocumentFragmentFlag = 1 << 6,
715 IsInsertionPointFlag = 1 << 8, 705 IsInsertionPointFlag = 1 << 7,
716 706
717 // Changes based on if the element should be treated like a link, 707 // Changes based on if the element should be treated like a link,
718 // ex. When setting the href attribute on an <a>. 708 // ex. When setting the href attribute on an <a>.
719 IsLinkFlag = 1 << 9, 709 IsLinkFlag = 1 << 8,
720 710
721 // Changes based on :hover, :active and :focus state. 711 // Changes based on :hover, :active and :focus state.
722 IsUserActionElementFlag = 1 << 10, 712 IsUserActionElementFlag = 1 << 9,
723 713
724 // Tree state flags. These change when the element is added/removed 714 // Tree state flags. These change when the element is added/removed
725 // from a DOM tree. 715 // from a DOM tree.
726 InDocumentFlag = 1 << 11, 716 InDocumentFlag = 1 << 10,
727 IsInShadowTreeFlag = 1 << 12, 717 IsInShadowTreeFlag = 1 << 11,
728 718
729 // Set by the parser when the children are done parsing. 719 // Set by the parser when the children are done parsing.
730 IsFinishedParsingChildrenFlag = 1 << 13, 720 IsFinishedParsingChildrenFlag = 1 << 12,
731 721
732 // Flags related to recalcStyle. 722 // Flags related to recalcStyle.
733 SVGFilterNeedsLayerUpdateFlag = 1 << 14, 723 SVGFilterNeedsLayerUpdateFlag = 1 << 13,
734 HasCustomStyleCallbacksFlag = 1 << 15, 724 HasCustomStyleCallbacksFlag = 1 << 14,
735 ChildNeedsStyleInvalidationFlag = 1 << 16, 725 ChildNeedsStyleInvalidationFlag = 1 << 15,
736 NeedsStyleInvalidationFlag = 1 << 17, 726 NeedsStyleInvalidationFlag = 1 << 16,
737 ChildNeedsDistributionRecalcFlag = 1 << 18, 727 ChildNeedsDistributionRecalcFlag = 1 << 17,
738 ChildNeedsStyleRecalcFlag = 1 << 19, 728 ChildNeedsStyleRecalcFlag = 1 << 18,
739 StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1), 729 StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1),
740 730
741 CustomElementFlag = 1 << 22, 731 CustomElementFlag = 1 << 21,
742 CustomElementCustomFlag = 1 << 23, 732 CustomElementCustomFlag = 1 << 22,
743 733
744 HasNameOrIsEditingTextFlag = 1 << 24, 734 HasNameOrIsEditingTextFlag = 1 << 23,
745 HasWeakReferencesFlag = 1 << 25, 735 HasWeakReferencesFlag = 1 << 24,
746 V8CollectableDuringMinorGCFlag = 1 << 26, 736 V8CollectableDuringMinorGCFlag = 1 << 25,
747 HasEventTargetDataFlag = 1 << 27, 737 HasEventTargetDataFlag = 1 << 26,
748 AlreadySpellCheckedFlag = 1 << 28, 738 AlreadySpellCheckedFlag = 1 << 27,
749 739
750 V0CustomElementFlag = 1 << 29, 740 V0CustomElementFlag = 1 << 28,
751 V0CustomElementUpgradedFlag = 1 << 30, 741 V0CustomElementUpgradedFlag = 1 << 29,
752 742
753 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge 743 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge
754 }; 744 };
755 745
756 // 1 bit remaining. 746 // 3 bits remaining.
757 747
758 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } 748 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
759 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); } 749 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); }
760 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } 750 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; }
761 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } 751 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; }
762 752
763 protected: 753 protected:
764 enum ConstructionType { 754 enum ConstructionType {
765 CreateOther = DefaultNodeFlags, 755 CreateOther = DefaultNodeFlags,
766 CreateText = DefaultNodeFlags | IsTextFlag, 756 CreateText = DefaultNodeFlags | IsTextFlag,
(...skipping 11 matching lines...) Expand all
778 Node(TreeScope*, ConstructionType); 768 Node(TreeScope*, ConstructionType);
779 769
780 virtual void didMoveToNewDocument(Document& oldDocument); 770 virtual void didMoveToNewDocument(Document& oldDocument);
781 771
782 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override; 772 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override;
783 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override; 773 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override;
784 DispatchEventResult dispatchEventInternal(Event*) override; 774 DispatchEventResult dispatchEventInternal(Event*) override;
785 775
786 static void reattachWhitespaceSiblingsIfNeeded(Text* start); 776 static void reattachWhitespaceSiblingsIfNeeded(Text* start);
787 777
788 bool hasLayoutObject() const { return getFlag(HasLayoutObjectFlag); }
789 bool hasRareData() const { return getFlag(HasRareDataFlag); } 778 bool hasRareData() const { return getFlag(HasRareDataFlag); }
790 779
791 NodeRareData* rareData() const; 780 NodeRareData* rareData() const;
792 NodeRareData& ensureRareData(); 781 NodeRareData& ensureRareData();
793 782
794 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); } 783 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); }
795 784
796 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } 785 void setTreeScope(TreeScope* scope) { m_treeScope = scope; }
797 786
798 // isTreeScopeInitialized() can be false 787 // isTreeScopeInitialized() can be false
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry(); 826 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry();
838 827
839 uint32_t m_nodeFlags; 828 uint32_t m_nodeFlags;
840 Member<ContainerNode> m_parentOrShadowHostNode; 829 Member<ContainerNode> m_parentOrShadowHostNode;
841 Member<TreeScope> m_treeScope; 830 Member<TreeScope> m_treeScope;
842 Member<Node> m_previous; 831 Member<Node> m_previous;
843 Member<Node> m_next; 832 Member<Node> m_next;
844 // When a node has rare data we move the layoutObject into the rare data. 833 // When a node has rare data we move the layoutObject into the rare data.
845 union DataUnion { 834 union DataUnion {
846 DataUnion() : m_layoutObject(nullptr) { } 835 DataUnion() : m_layoutObject(nullptr) { }
847 ComputedStyle* m_computedStyle;
848 // LayoutObjects are fully owned by their DOM node. See LayoutObject's 836 // LayoutObjects are fully owned by their DOM node. See LayoutObject's
849 // LIFETIME documentation section. 837 // LIFETIME documentation section.
850 LayoutObject* m_layoutObject; 838 LayoutObject* m_layoutObject;
851 NodeRareDataBase* m_rareData; 839 NodeRareDataBase* m_rareData;
852 } m_data; 840 } m_data;
853 }; 841 };
854 842
855 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) 843 inline void Node::setParentOrShadowHostNode(ContainerNode* parent)
856 { 844 {
857 DCHECK(isMainThread()); 845 DCHECK(isMainThread());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 } // namespace blink 920 } // namespace blink
933 921
934 #ifndef NDEBUG 922 #ifndef NDEBUG
935 // Outside the WebCore namespace for ease of invocation from gdb. 923 // Outside the WebCore namespace for ease of invocation from gdb.
936 void showNode(const blink::Node*); 924 void showNode(const blink::Node*);
937 void showTree(const blink::Node*); 925 void showTree(const blink::Node*);
938 void showNodePath(const blink::Node*); 926 void showNodePath(const blink::Node*);
939 #endif 927 #endif
940 928
941 #endif // Node_h 929 #endif // Node_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698