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

Side by Side Diff: sky/engine/core/dom/shadow/ElementShadow.h

Issue 759663003: Only allow one shadowRoot. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 6 years 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) 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 13 matching lines...) Expand all
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ 27 #ifndef SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_
28 #define SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ 28 #define SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_
29 29
30 #include "sky/engine/core/dom/shadow/InsertionPoint.h" 30 #include "sky/engine/core/dom/shadow/InsertionPoint.h"
31 #include "sky/engine/core/dom/shadow/SelectRuleFeatureSet.h" 31 #include "sky/engine/core/dom/shadow/SelectRuleFeatureSet.h"
32 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 32 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
33 #include "sky/engine/platform/heap/Handle.h" 33 #include "sky/engine/platform/heap/Handle.h"
34 #include "sky/engine/wtf/DoublyLinkedList.h"
35 #include "sky/engine/wtf/HashMap.h" 34 #include "sky/engine/wtf/HashMap.h"
36 #include "sky/engine/wtf/Noncopyable.h" 35 #include "sky/engine/wtf/Noncopyable.h"
37 #include "sky/engine/wtf/PassOwnPtr.h" 36 #include "sky/engine/wtf/PassOwnPtr.h"
38 37
39 namespace blink { 38 namespace blink {
40 39
41 class ElementShadow final { 40 class ElementShadow final {
42 WTF_MAKE_NONCOPYABLE(ElementShadow); 41 WTF_MAKE_NONCOPYABLE(ElementShadow);
43 WTF_MAKE_FAST_ALLOCATED; 42 WTF_MAKE_FAST_ALLOCATED;
44 public: 43 public:
45 static PassOwnPtr<ElementShadow> create(); 44 static PassOwnPtr<ElementShadow> create();
46 ~ElementShadow(); 45 ~ElementShadow();
47 46
48 Element* host() const; 47 Element* host() const;
49 ShadowRoot* youngestShadowRoot() const { return m_shadowRoots.head(); } 48 ShadowRoot* shadowRoot() const { return m_shadowRoot; }
50 ShadowRoot* oldestShadowRoot() const { return m_shadowRoots.tail(); }
51 ElementShadow* containingShadow() const; 49 ElementShadow* containingShadow() const;
52 50
53 ShadowRoot& addShadowRoot(Element& shadowHost); 51 ShadowRoot& addShadowRoot(Element& shadowHost);
54 52
55 bool hasSameStyles(const ElementShadow*) const; 53 bool hasSameStyles(const ElementShadow*) const;
56 54
57 void attach(const Node::AttachContext&); 55 void attach(const Node::AttachContext&);
58 void detach(const Node::AttachContext&); 56 void detach(const Node::AttachContext&);
59 57
60 void willAffectSelector(); 58 void willAffectSelector();
(...skipping 20 matching lines...) Expand all
81 void collectSelectFeatureSetFrom(ShadowRoot&); 79 void collectSelectFeatureSetFrom(ShadowRoot&);
82 void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*); 80 void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*);
83 81
84 bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; } 82 bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; }
85 void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; } 83 void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; }
86 84
87 typedef HashMap<RawPtr<const Node>, DestinationInsertionPoints> NodeToDestin ationInsertionPoints; 85 typedef HashMap<RawPtr<const Node>, DestinationInsertionPoints> NodeToDestin ationInsertionPoints;
88 NodeToDestinationInsertionPoints m_nodeToInsertionPoints; 86 NodeToDestinationInsertionPoints m_nodeToInsertionPoints;
89 87
90 SelectRuleFeatureSet m_selectFeatures; 88 SelectRuleFeatureSet m_selectFeatures;
91 // FIXME: Oilpan: add a heap-based version of DoublyLinkedList<>. 89 ShadowRoot* m_shadowRoot;
92 DoublyLinkedList<ShadowRoot> m_shadowRoots;
93 bool m_needsDistributionRecalc; 90 bool m_needsDistributionRecalc;
94 bool m_needsSelectFeatureSet; 91 bool m_needsSelectFeatureSet;
95 }; 92 };
96 93
97 inline Element* ElementShadow::host() const 94 inline Element* ElementShadow::host() const
98 { 95 {
99 ASSERT(!m_shadowRoots.isEmpty()); 96 ASSERT(m_shadowRoot);
100 return youngestShadowRoot()->host(); 97 return m_shadowRoot->host();
101 }
102
103 inline ShadowRoot* Node::youngestShadowRoot() const
104 {
105 if (!isElementNode())
106 return 0;
107 return toElement(this)->youngestShadowRoot();
108 }
109
110 inline ShadowRoot* Element::youngestShadowRoot() const
111 {
112 if (ElementShadow* shadow = this->shadow())
113 return shadow->youngestShadowRoot();
114 return 0;
115 } 98 }
116 99
117 inline ElementShadow* ElementShadow::containingShadow() const 100 inline ElementShadow* ElementShadow::containingShadow() const
118 { 101 {
119 if (ShadowRoot* parentRoot = host()->containingShadowRoot()) 102 if (ShadowRoot* parentRoot = host()->containingShadowRoot())
120 return parentRoot->owner(); 103 return parentRoot->owner();
121 return 0; 104 return 0;
122 } 105 }
123 106
124 inline void ElementShadow::distributeIfNeeded() 107 inline void ElementShadow::distributeIfNeeded()
125 { 108 {
126 if (m_needsDistributionRecalc) 109 if (m_needsDistributionRecalc)
127 distribute(); 110 distribute();
128 m_needsDistributionRecalc = false; 111 m_needsDistributionRecalc = false;
129 } 112 }
130 113
131 } // namespace 114 } // namespace
132 115
133 #endif // SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ 116 #endif // SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698