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

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

Issue 1904923002: Reduce a shadow root object's size by not inheriting DoublyLinkedList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@raredatav0
Patch Set: fix typo Created 4 years, 8 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/shadow/ElementShadow.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #ifndef ElementShadow_h 27 #ifndef ElementShadow_h
28 #define ElementShadow_h 28 #define ElementShadow_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/dom/shadow/InsertionPoint.h" 31 #include "core/dom/shadow/InsertionPoint.h"
32 #include "core/dom/shadow/SelectRuleFeatureSet.h" 32 #include "core/dom/shadow/SelectRuleFeatureSet.h"
33 #include "core/dom/shadow/ShadowRoot.h" 33 #include "core/dom/shadow/ShadowRoot.h"
34 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 #include "wtf/DoublyLinkedList.h"
36 #include "wtf/HashMap.h" 35 #include "wtf/HashMap.h"
37 #include "wtf/Noncopyable.h" 36 #include "wtf/Noncopyable.h"
38 37
39 namespace blink { 38 namespace blink {
40 39
41 class CORE_EXPORT ElementShadow final : public GarbageCollectedFinalized<Element Shadow> { 40 class CORE_EXPORT ElementShadow final : public GarbageCollectedFinalized<Element Shadow> {
42 WTF_MAKE_NONCOPYABLE(ElementShadow); 41 WTF_MAKE_NONCOPYABLE(ElementShadow);
43 public: 42 public:
44 static ElementShadow* create(); 43 static ElementShadow* create();
45 ~ElementShadow(); 44 ~ElementShadow();
46 45
47 Element* host() const; 46 Element* host() const;
48 ShadowRoot& youngestShadowRoot() const { DCHECK(m_shadowRoots.head()); retur n *m_shadowRoots.head(); } 47 ShadowRoot& youngestShadowRoot() const;
49 ShadowRoot* oldestShadowRoot() const { return m_shadowRoots.tail(); } 48 ShadowRoot* oldestShadowRoot() const { return m_shadowRoot; }
50 ElementShadow* containingShadow() const; 49 ElementShadow* containingShadow() const;
51 50
52 ShadowRoot& addShadowRoot(Element& shadowHost, ShadowRootType); 51 ShadowRoot& addShadowRoot(Element& shadowHost, ShadowRootType);
53 52
54 bool hasSameStyles(const ElementShadow*) const; 53 bool hasSameStyles(const ElementShadow*) const;
55 54
56 void attach(const Node::AttachContext&); 55 void attach(const Node::AttachContext&);
57 void detach(const Node::AttachContext&); 56 void detach(const Node::AttachContext&);
58 57
59 void willAffectSelector(); 58 void willAffectSelector();
60 const SelectRuleFeatureSet& ensureSelectFeatureSet(); 59 const SelectRuleFeatureSet& ensureSelectFeatureSet();
61 60
62 void distributeIfNeeded(); 61 void distributeIfNeeded();
63 void setNeedsDistributionRecalc(); 62 void setNeedsDistributionRecalc();
64 bool needsDistributionRecalc() const { return m_needsDistributionRecalc; } 63 bool needsDistributionRecalc() const { return m_needsDistributionRecalc; }
65 64
66 const InsertionPoint* finalDestinationInsertionPointFor(const Node*) const; 65 const InsertionPoint* finalDestinationInsertionPointFor(const Node*) const;
67 const DestinationInsertionPoints* destinationInsertionPointsFor(const Node*) const; 66 const DestinationInsertionPoints* destinationInsertionPointsFor(const Node*) const;
68 67
69 void didDistributeNode(const Node*, InsertionPoint*); 68 void didDistributeNode(const Node*, InsertionPoint*);
70 69
71 bool isV1() const { return youngestShadowRoot().isV1(); }; 70 bool isV1() const { return youngestShadowRoot().isV1(); };
72 bool isOpenOrV0() const { return youngestShadowRoot().isOpenOrV0(); }; 71 bool isOpenOrV0() const { return youngestShadowRoot().isOpenOrV0(); };
73 72
74 DECLARE_TRACE(); 73 DECLARE_TRACE();
75 74
76 private: 75 private:
77 ElementShadow(); 76 ElementShadow();
78 77
78 void appendShadowRoot(ShadowRoot&);
79
79 void distribute(); 80 void distribute();
80 void clearDistribution(); 81 void clearDistribution();
81 82
82 void distributeV0(); 83 void distributeV0();
83 void distributeV1(); 84 void distributeV1();
84 85
85 void collectSelectFeatureSetFrom(ShadowRoot&); 86 void collectSelectFeatureSetFrom(ShadowRoot&);
86 void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*); 87 void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*);
87 88
88 bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; } 89 bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; }
89 void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; } 90 void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; }
90 91
91 using NodeToDestinationInsertionPoints = HeapHashMap<Member<const Node>, Mem ber<DestinationInsertionPoints>>; 92 using NodeToDestinationInsertionPoints = HeapHashMap<Member<const Node>, Mem ber<DestinationInsertionPoints>>;
92 NodeToDestinationInsertionPoints m_nodeToInsertionPoints; 93 NodeToDestinationInsertionPoints m_nodeToInsertionPoints;
93 94
94 SelectRuleFeatureSet m_selectFeatures; 95 SelectRuleFeatureSet m_selectFeatures;
95 // TODO(Oilpan): add a heap-based version of DoublyLinkedList<>. 96 Member<ShadowRoot> m_shadowRoot;
96 DoublyLinkedList<ShadowRoot> m_shadowRoots;
97 bool m_needsDistributionRecalc; 97 bool m_needsDistributionRecalc;
98 bool m_needsSelectFeatureSet; 98 bool m_needsSelectFeatureSet;
99 }; 99 };
100 100
101 inline Element* ElementShadow::host() const 101 inline Element* ElementShadow::host() const
102 { 102 {
103 DCHECK(!m_shadowRoots.isEmpty()); 103 DCHECK(m_shadowRoot);
104 return youngestShadowRoot().host(); 104 return m_shadowRoot->host();
105 } 105 }
106 106
107 inline ShadowRoot* Node::youngestShadowRoot() const 107 inline ShadowRoot* Node::youngestShadowRoot() const
108 { 108 {
109 if (!isElementNode()) 109 if (!isElementNode())
110 return 0; 110 return 0;
111 return toElement(this)->youngestShadowRoot(); 111 return toElement(this)->youngestShadowRoot();
112 } 112 }
113 113
114 inline ShadowRoot* Element::youngestShadowRoot() const 114 inline ShadowRoot* Element::youngestShadowRoot() const
(...skipping 13 matching lines...) Expand all
128 inline void ElementShadow::distributeIfNeeded() 128 inline void ElementShadow::distributeIfNeeded()
129 { 129 {
130 if (m_needsDistributionRecalc) 130 if (m_needsDistributionRecalc)
131 distribute(); 131 distribute();
132 m_needsDistributionRecalc = false; 132 m_needsDistributionRecalc = false;
133 } 133 }
134 134
135 } // namespace blink 135 } // namespace blink
136 136
137 #endif 137 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698