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

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

Issue 862183003: Merge ShadowRootRareData into ShadowRoot. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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) 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 20 matching lines...) Expand all
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 34
35 namespace blink { 35 namespace blink {
36 36
37 class Document; 37 class Document;
38 class ElementShadow; 38 class ElementShadow;
39 class ExceptionState; 39 class ExceptionState;
40 class InsertionPoint; 40 class InsertionPoint;
41 class ShadowRootRareData;
42 class StyleSheetList;
43 41
44 class ShadowRoot final : public DocumentFragment, public TreeScope { 42 class ShadowRoot final : public DocumentFragment, public TreeScope {
45 DEFINE_WRAPPERTYPEINFO(); 43 DEFINE_WRAPPERTYPEINFO();
46 public: 44 public:
47 45
48 static PassRefPtr<ShadowRoot> create(Document& document) 46 static PassRefPtr<ShadowRoot> create(Document& document)
49 { 47 {
50 return adoptRef(new ShadowRoot(document)); 48 return adoptRef(new ShadowRoot(document));
51 } 49 }
52 50
53 void recalcStyle(StyleRecalcChange); 51 void recalcStyle(StyleRecalcChange);
54 52
55 // Disambiguate between Node and TreeScope hierarchies; TreeScope's implemen tation is simpler. 53 // Disambiguate between Node and TreeScope hierarchies; TreeScope's implemen tation is simpler.
56 using TreeScope::document; 54 using TreeScope::document;
57 using TreeScope::getElementById; 55 using TreeScope::getElementById;
58 56
59 Element* host() const { return toElement(parentOrShadowHostNode()); } 57 Element* host() const { return toElement(parentOrShadowHostNode()); }
60 ElementShadow* owner() const { return host() ? host()->shadow() : 0; } 58 ElementShadow* owner() const { return host() ? host()->shadow() : 0; }
61 59
62 virtual void insertedInto(ContainerNode*) override; 60 virtual void insertedInto(ContainerNode*) override;
63 virtual void removedFrom(ContainerNode*) override; 61 virtual void removedFrom(ContainerNode*) override;
64 62
65 bool containsContentElements() const; 63 bool containsContentElements() const;
66 bool containsInsertionPoints() const { return containsContentElements(); }
67 bool containsShadowRoots() const; 64 bool containsShadowRoots() const;
68 65
69 // For Internals, don't use this. 66 void didAddInsertionPoint();
70 unsigned childShadowRootCount() const; 67 void didRemoveInsertionPoint();
71
72 void didAddInsertionPoint(InsertionPoint*);
73 void didRemoveInsertionPoint(InsertionPoint*);
74 const Vector<RefPtr<InsertionPoint> >& descendantInsertionPoints(); 68 const Vector<RefPtr<InsertionPoint> >& descendantInsertionPoints();
75 69
76 // Make protected methods from base class public here. 70 // Make protected methods from base class public here.
77 using TreeScope::setDocument; 71 using TreeScope::setDocument;
78 using TreeScope::setParentTreeScope; 72 using TreeScope::setParentTreeScope;
79 73
80 public:
81 Element* activeElement() const; 74 Element* activeElement() const;
82 75
83 PassRefPtr<Node> cloneNode(bool, ExceptionState&); 76 PassRefPtr<Node> cloneNode(bool, ExceptionState&);
84 PassRefPtr<Node> cloneNode(ExceptionState& exceptionState) { return cloneNod e(true, exceptionState); } 77 PassRefPtr<Node> cloneNode(ExceptionState& exceptionState);
85 78
86 private: 79 private:
87 ShadowRoot(Document&); 80 explicit ShadowRoot(Document&);
88 virtual ~ShadowRoot(); 81 virtual ~ShadowRoot();
89 82
90 #if !ENABLE(OILPAN)
91 virtual void dispose() override; 83 virtual void dispose() override;
92 #endif
93
94 ShadowRootRareData* ensureShadowRootRareData();
95 84
96 void addChildShadowRoot(); 85 void addChildShadowRoot();
97 void removeChildShadowRoot(); 86 void removeChildShadowRoot();
98 void invalidateDescendantInsertionPoints(); 87 void invalidateDescendantInsertionPoints();
99 88
100 // ShadowRoots should never be cloned. 89 virtual PassRefPtr<Node> cloneNode(bool) override;
101 virtual PassRefPtr<Node> cloneNode(bool) override { return nullptr; }
102 90
103 OwnPtr<ShadowRootRareData> m_shadowRootRareData; 91 Vector<RefPtr<InsertionPoint> > m_descendantInsertionPoints;
92 unsigned m_descendantContentElementCount;
93 unsigned m_childShadowRootCount;
104 unsigned m_descendantInsertionPointsIsValid : 1; 94 unsigned m_descendantInsertionPointsIsValid : 1;
105 }; 95 };
106 96
107 inline Element* ShadowRoot::activeElement() const 97 inline Element* ShadowRoot::activeElement() const
108 { 98 {
109 return adjustedFocusedElement(); 99 return adjustedFocusedElement();
110 } 100 }
111 101
112 DEFINE_NODE_TYPE_CASTS(ShadowRoot, isShadowRoot()); 102 DEFINE_NODE_TYPE_CASTS(ShadowRoot, isShadowRoot());
113 DEFINE_TYPE_CASTS(ShadowRoot, TreeScope, treeScope, treeScope->rootNode().isShad owRoot(), treeScope.rootNode().isShadowRoot()); 103 DEFINE_TYPE_CASTS(ShadowRoot, TreeScope, treeScope, treeScope->rootNode().isShad owRoot(), treeScope.rootNode().isShadowRoot());
114 104
115 } // namespace blink 105 } // namespace blink
116 106
117 #endif // SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ 107 #endif // SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_
OLDNEW
« no previous file with comments | « sky/engine/core/dom/shadow/InsertionPoint.cpp ('k') | sky/engine/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698