OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 Loading... |
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_SHADOWROOT_H_ | 27 #ifndef SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ |
28 #define SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ | 28 #define SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ |
29 | 29 |
30 #include "sky/engine/core/dom/ContainerNode.h" | 30 #include "sky/engine/core/dom/ContainerNode.h" |
31 #include "sky/engine/core/dom/DocumentFragment.h" | 31 #include "sky/engine/core/dom/DocumentFragment.h" |
32 #include "sky/engine/core/dom/Element.h" | 32 #include "sky/engine/core/dom/Element.h" |
33 #include "sky/engine/core/dom/TreeScope.h" | 33 #include "sky/engine/core/dom/TreeScope.h" |
34 #include "sky/engine/wtf/DoublyLinkedList.h" | |
35 | 34 |
36 namespace blink { | 35 namespace blink { |
37 | 36 |
38 class Document; | 37 class Document; |
39 class ElementShadow; | 38 class ElementShadow; |
40 class ExceptionState; | 39 class ExceptionState; |
41 class InsertionPoint; | 40 class InsertionPoint; |
42 class ShadowRootRareData; | 41 class ShadowRootRareData; |
43 class StyleSheetList; | 42 class StyleSheetList; |
44 | 43 |
45 class ShadowRoot final : public DocumentFragment, public TreeScope, public Doubl
yLinkedListNode<ShadowRoot> { | 44 class ShadowRoot final : public DocumentFragment, public TreeScope { |
46 DEFINE_WRAPPERTYPEINFO(); | 45 DEFINE_WRAPPERTYPEINFO(); |
47 friend class WTF::DoublyLinkedListNode<ShadowRoot>; | |
48 public: | 46 public: |
49 | 47 |
50 static PassRefPtr<ShadowRoot> create(Document& document) | 48 static PassRefPtr<ShadowRoot> create(Document& document) |
51 { | 49 { |
52 return adoptRef(new ShadowRoot(document)); | 50 return adoptRef(new ShadowRoot(document)); |
53 } | 51 } |
54 | 52 |
55 void recalcStyle(StyleRecalcChange); | 53 void recalcStyle(StyleRecalcChange); |
56 | 54 |
57 // Disambiguate between Node and TreeScope hierarchies; TreeScope's implemen
tation is simpler. | 55 // Disambiguate between Node and TreeScope hierarchies; TreeScope's implemen
tation is simpler. |
58 using TreeScope::document; | 56 using TreeScope::document; |
59 using TreeScope::getElementById; | 57 using TreeScope::getElementById; |
60 | 58 |
61 Element* host() const { return toElement(parentOrShadowHostNode()); } | 59 Element* host() const { return toElement(parentOrShadowHostNode()); } |
62 ElementShadow* owner() const { return host() ? host()->shadow() : 0; } | 60 ElementShadow* owner() const { return host() ? host()->shadow() : 0; } |
63 | 61 |
64 ShadowRoot* youngerShadowRoot() const { return prev(); } | |
65 | |
66 bool isYoungest() const { return !youngerShadowRoot(); } | |
67 bool isOldest() const { return !olderShadowRoot(); } | |
68 bool isOldestAuthorShadowRoot() const; | |
69 | |
70 virtual void insertedInto(ContainerNode*) override; | 62 virtual void insertedInto(ContainerNode*) override; |
71 virtual void removedFrom(ContainerNode*) override; | 63 virtual void removedFrom(ContainerNode*) override; |
72 | 64 |
73 void registerScopedHTMLStyleChild(); | 65 void registerScopedHTMLStyleChild(); |
74 void unregisterScopedHTMLStyleChild(); | 66 void unregisterScopedHTMLStyleChild(); |
75 | 67 |
76 bool containsContentElements() const; | 68 bool containsContentElements() const; |
77 bool containsInsertionPoints() const { return containsContentElements(); } | 69 bool containsInsertionPoints() const { return containsContentElements(); } |
78 bool containsShadowRoots() const; | 70 bool containsShadowRoots() const; |
79 | 71 |
80 // For Internals, don't use this. | 72 // For Internals, don't use this. |
81 unsigned childShadowRootCount() const; | 73 unsigned childShadowRootCount() const; |
82 unsigned numberOfStyles() const { return m_numberOfStyles; } | 74 unsigned numberOfStyles() const { return m_numberOfStyles; } |
83 | 75 |
84 void didAddInsertionPoint(InsertionPoint*); | 76 void didAddInsertionPoint(InsertionPoint*); |
85 void didRemoveInsertionPoint(InsertionPoint*); | 77 void didRemoveInsertionPoint(InsertionPoint*); |
86 const Vector<RefPtr<InsertionPoint> >& descendantInsertionPoints(); | 78 const Vector<RefPtr<InsertionPoint> >& descendantInsertionPoints(); |
87 | 79 |
88 // Make protected methods from base class public here. | 80 // Make protected methods from base class public here. |
89 using TreeScope::setDocument; | 81 using TreeScope::setDocument; |
90 using TreeScope::setParentTreeScope; | 82 using TreeScope::setParentTreeScope; |
91 | 83 |
92 public: | 84 public: |
93 Element* activeElement() const; | 85 Element* activeElement() const; |
94 | 86 |
95 ShadowRoot* olderShadowRoot() const { return next(); } | |
96 | |
97 PassRefPtr<Node> cloneNode(bool, ExceptionState&); | 87 PassRefPtr<Node> cloneNode(bool, ExceptionState&); |
98 PassRefPtr<Node> cloneNode(ExceptionState& exceptionState) { return cloneNod
e(true, exceptionState); } | 88 PassRefPtr<Node> cloneNode(ExceptionState& exceptionState) { return cloneNod
e(true, exceptionState); } |
99 | 89 |
100 StyleSheetList* styleSheets(); | 90 StyleSheetList* styleSheets(); |
101 | 91 |
102 private: | 92 private: |
103 ShadowRoot(Document&); | 93 ShadowRoot(Document&); |
104 virtual ~ShadowRoot(); | 94 virtual ~ShadowRoot(); |
105 | 95 |
106 #if !ENABLE(OILPAN) | 96 #if !ENABLE(OILPAN) |
107 virtual void dispose() override; | 97 virtual void dispose() override; |
108 #endif | 98 #endif |
109 | 99 |
110 ShadowRootRareData* ensureShadowRootRareData(); | 100 ShadowRootRareData* ensureShadowRootRareData(); |
111 | 101 |
112 void addChildShadowRoot(); | 102 void addChildShadowRoot(); |
113 void removeChildShadowRoot(); | 103 void removeChildShadowRoot(); |
114 void invalidateDescendantInsertionPoints(); | 104 void invalidateDescendantInsertionPoints(); |
115 | 105 |
116 // ShadowRoots should never be cloned. | 106 // ShadowRoots should never be cloned. |
117 virtual PassRefPtr<Node> cloneNode(bool) override { return nullptr; } | 107 virtual PassRefPtr<Node> cloneNode(bool) override { return nullptr; } |
118 | 108 |
119 // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=888
34 | |
120 bool isOrphan() const { return !host(); } | |
121 | |
122 RawPtr<ShadowRoot> m_prev; | |
123 RawPtr<ShadowRoot> m_next; | |
124 OwnPtr<ShadowRootRareData> m_shadowRootRareData; | 109 OwnPtr<ShadowRootRareData> m_shadowRootRareData; |
125 unsigned m_numberOfStyles : 27; | 110 unsigned m_numberOfStyles : 27; |
126 unsigned m_registeredWithParentShadowRoot : 1; | 111 unsigned m_registeredWithParentShadowRoot : 1; |
127 unsigned m_descendantInsertionPointsIsValid : 1; | 112 unsigned m_descendantInsertionPointsIsValid : 1; |
128 }; | 113 }; |
129 | 114 |
130 inline Element* ShadowRoot::activeElement() const | 115 inline Element* ShadowRoot::activeElement() const |
131 { | 116 { |
132 return adjustedFocusedElement(); | 117 return adjustedFocusedElement(); |
133 } | 118 } |
134 | 119 |
135 DEFINE_NODE_TYPE_CASTS(ShadowRoot, isShadowRoot()); | 120 DEFINE_NODE_TYPE_CASTS(ShadowRoot, isShadowRoot()); |
136 DEFINE_TYPE_CASTS(ShadowRoot, TreeScope, treeScope, treeScope->rootNode().isShad
owRoot(), treeScope.rootNode().isShadowRoot()); | 121 DEFINE_TYPE_CASTS(ShadowRoot, TreeScope, treeScope, treeScope->rootNode().isShad
owRoot(), treeScope.rootNode().isShadowRoot()); |
137 | 122 |
138 } // namespace blink | 123 } // namespace blink |
139 | 124 |
140 #endif // SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ | 125 #endif // SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ |
OLD | NEW |