Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / dom / shadow / ShadowRootRareData.h
blobe7132cc3f0cf34f569032ee67842272ee509753d
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef ShadowRootRareData_h
32 #define ShadowRootRareData_h
34 #include "core/dom/shadow/InsertionPoint.h"
35 #include "wtf/RefPtr.h"
36 #include "wtf/Vector.h"
38 namespace blink {
40 class ShadowRootRareData : public NoBaseWillBeGarbageCollected<ShadowRootRareData> {
41 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(ShadowRootRareData);
42 public:
43 ShadowRootRareData()
44 : m_descendantShadowElementCount(0)
45 , m_descendantContentElementCount(0)
46 , m_childShadowRootCount(0)
50 HTMLShadowElement* shadowInsertionPointOfYoungerShadowRoot() const { return m_shadowInsertionPointOfYoungerShadowRoot.get(); }
51 void setShadowInsertionPointOfYoungerShadowRoot(PassRefPtrWillBeRawPtr<HTMLShadowElement> shadowInsertionPoint) { m_shadowInsertionPointOfYoungerShadowRoot = shadowInsertionPoint; }
53 void didAddInsertionPoint(InsertionPoint*);
54 void didRemoveInsertionPoint(InsertionPoint*);
56 bool containsShadowElements() const { return m_descendantShadowElementCount; }
57 bool containsContentElements() const { return m_descendantContentElementCount; }
58 bool containsShadowRoots() const { return m_childShadowRootCount; }
60 unsigned descendantShadowElementCount() const { return m_descendantShadowElementCount; }
62 void didAddChildShadowRoot() { ++m_childShadowRootCount; }
63 void didRemoveChildShadowRoot() { ASSERT(m_childShadowRootCount > 0); --m_childShadowRootCount; }
65 unsigned childShadowRootCount() const { return m_childShadowRootCount; }
67 const WillBeHeapVector<RefPtrWillBeMember<InsertionPoint>>& descendantInsertionPoints() { return m_descendantInsertionPoints; }
68 void setDescendantInsertionPoints(WillBeHeapVector<RefPtrWillBeMember<InsertionPoint>>& list) { m_descendantInsertionPoints.swap(list); }
69 void clearDescendantInsertionPoints() { m_descendantInsertionPoints.clear(); }
71 StyleSheetList* styleSheets() { return m_styleSheetList.get(); }
72 void setStyleSheets(PassRefPtrWillBeRawPtr<StyleSheetList> styleSheetList) { m_styleSheetList = styleSheetList; }
74 DEFINE_INLINE_TRACE()
76 visitor->trace(m_shadowInsertionPointOfYoungerShadowRoot);
77 visitor->trace(m_descendantInsertionPoints);
78 visitor->trace(m_styleSheetList);
81 private:
82 RefPtrWillBeMember<HTMLShadowElement> m_shadowInsertionPointOfYoungerShadowRoot;
83 unsigned m_descendantShadowElementCount;
84 unsigned m_descendantContentElementCount;
85 unsigned m_childShadowRootCount;
86 WillBeHeapVector<RefPtrWillBeMember<InsertionPoint>> m_descendantInsertionPoints;
87 RefPtrWillBeMember<StyleSheetList> m_styleSheetList;
90 inline void ShadowRootRareData::didAddInsertionPoint(InsertionPoint* point)
92 ASSERT(point);
93 if (isHTMLShadowElement(*point))
94 ++m_descendantShadowElementCount;
95 else if (isHTMLContentElement(*point))
96 ++m_descendantContentElementCount;
97 else
98 ASSERT_NOT_REACHED();
101 inline void ShadowRootRareData::didRemoveInsertionPoint(InsertionPoint* point)
103 ASSERT(point);
104 if (isHTMLShadowElement(*point))
105 --m_descendantShadowElementCount;
106 else if (isHTMLContentElement(*point))
107 --m_descendantContentElementCount;
108 else
109 ASSERT_NOT_REACHED();
111 ASSERT(m_descendantContentElementCount >= 0);
112 ASSERT(m_descendantShadowElementCount >= 0);
115 } // namespace blink
117 #endif