| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #ifndef ShadowRootRareData_h | 31 #ifndef ShadowRootRareData_h |
| 32 #define ShadowRootRareData_h | 32 #define ShadowRootRareData_h |
| 33 | 33 |
| 34 #include "core/dom/shadow/InsertionPoint.h" | 34 #include "core/dom/shadow/InsertionPoint.h" |
| 35 #include "core/html/HTMLSlotElement.h" | 35 #include "core/html/HTMLSlotElement.h" |
| 36 #include "wtf/RefPtr.h" | 36 #include "wtf/RefPtr.h" |
| 37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class ShadowRootRareData : public NoBaseWillBeGarbageCollected<ShadowRootRareDat
a> { | 41 class ShadowRootRareData : public GarbageCollected<ShadowRootRareData> { |
| 42 USING_FAST_MALLOC_WILL_BE_REMOVED(ShadowRootRareData); | |
| 43 public: | 42 public: |
| 44 ShadowRootRareData() | 43 ShadowRootRareData() |
| 45 : m_descendantShadowElementCount(0) | 44 : m_descendantShadowElementCount(0) |
| 46 , m_descendantContentElementCount(0) | 45 , m_descendantContentElementCount(0) |
| 47 , m_childShadowRootCount(0) | 46 , m_childShadowRootCount(0) |
| 48 , m_descendantSlotCount(0) | 47 , m_descendantSlotCount(0) |
| 49 { | 48 { |
| 50 } | 49 } |
| 51 | 50 |
| 52 HTMLShadowElement* shadowInsertionPointOfYoungerShadowRoot() const { return
m_shadowInsertionPointOfYoungerShadowRoot.get(); } | 51 HTMLShadowElement* shadowInsertionPointOfYoungerShadowRoot() const { return
m_shadowInsertionPointOfYoungerShadowRoot.get(); } |
| 53 void setShadowInsertionPointOfYoungerShadowRoot(PassRefPtrWillBeRawPtr<HTMLS
hadowElement> shadowInsertionPoint) { m_shadowInsertionPointOfYoungerShadowRoot
= shadowInsertionPoint; } | 52 void setShadowInsertionPointOfYoungerShadowRoot(RawPtr<HTMLShadowElement> sh
adowInsertionPoint) { m_shadowInsertionPointOfYoungerShadowRoot = shadowInsertio
nPoint; } |
| 54 | 53 |
| 55 void didAddInsertionPoint(InsertionPoint*); | 54 void didAddInsertionPoint(InsertionPoint*); |
| 56 void didRemoveInsertionPoint(InsertionPoint*); | 55 void didRemoveInsertionPoint(InsertionPoint*); |
| 57 | 56 |
| 58 bool containsShadowElements() const { return m_descendantShadowElementCount;
} | 57 bool containsShadowElements() const { return m_descendantShadowElementCount;
} |
| 59 bool containsContentElements() const { return m_descendantContentElementCoun
t; } | 58 bool containsContentElements() const { return m_descendantContentElementCoun
t; } |
| 60 bool containsShadowRoots() const { return m_childShadowRootCount; } | 59 bool containsShadowRoots() const { return m_childShadowRootCount; } |
| 61 | 60 |
| 62 unsigned descendantShadowElementCount() const { return m_descendantShadowEle
mentCount; } | 61 unsigned descendantShadowElementCount() const { return m_descendantShadowEle
mentCount; } |
| 63 | 62 |
| 64 void didAddChildShadowRoot() { ++m_childShadowRootCount; } | 63 void didAddChildShadowRoot() { ++m_childShadowRootCount; } |
| 65 void didRemoveChildShadowRoot() { ASSERT(m_childShadowRootCount > 0); --m_ch
ildShadowRootCount; } | 64 void didRemoveChildShadowRoot() { ASSERT(m_childShadowRootCount > 0); --m_ch
ildShadowRootCount; } |
| 66 | 65 |
| 67 unsigned childShadowRootCount() const { return m_childShadowRootCount; } | 66 unsigned childShadowRootCount() const { return m_childShadowRootCount; } |
| 68 | 67 |
| 69 const WillBeHeapVector<RefPtrWillBeMember<InsertionPoint>>& descendantInsert
ionPoints() { return m_descendantInsertionPoints; } | 68 const HeapVector<Member<InsertionPoint>>& descendantInsertionPoints() { retu
rn m_descendantInsertionPoints; } |
| 70 void setDescendantInsertionPoints(WillBeHeapVector<RefPtrWillBeMember<Insert
ionPoint>>& list) { m_descendantInsertionPoints.swap(list); } | 69 void setDescendantInsertionPoints(HeapVector<Member<InsertionPoint>>& list)
{ m_descendantInsertionPoints.swap(list); } |
| 71 void clearDescendantInsertionPoints() { m_descendantInsertionPoints.clear();
} | 70 void clearDescendantInsertionPoints() { m_descendantInsertionPoints.clear();
} |
| 72 | 71 |
| 73 StyleSheetList* styleSheets() { return m_styleSheetList.get(); } | 72 StyleSheetList* styleSheets() { return m_styleSheetList.get(); } |
| 74 void setStyleSheets(PassRefPtrWillBeRawPtr<StyleSheetList> styleSheetList) {
m_styleSheetList = styleSheetList; } | 73 void setStyleSheets(RawPtr<StyleSheetList> styleSheetList) { m_styleSheetLis
t = styleSheetList; } |
| 75 | 74 |
| 76 void didAddSlot() { ++m_descendantSlotCount; } | 75 void didAddSlot() { ++m_descendantSlotCount; } |
| 77 void didRemoveSlot() { ASSERT(m_descendantSlotCount >= 1); --m_descendantSlo
tCount; } | 76 void didRemoveSlot() { ASSERT(m_descendantSlotCount >= 1); --m_descendantSlo
tCount; } |
| 78 | 77 |
| 79 unsigned descendantSlotCount() const { return m_descendantSlotCount; } | 78 unsigned descendantSlotCount() const { return m_descendantSlotCount; } |
| 80 | 79 |
| 81 const WillBeHeapVector<RefPtrWillBeMember<HTMLSlotElement>>& descendantSlots
() const { return m_descendantSlots; } | 80 const HeapVector<Member<HTMLSlotElement>>& descendantSlots() const { return
m_descendantSlots; } |
| 82 | 81 |
| 83 void setDescendantSlots(WillBeHeapVector<RefPtrWillBeMember<HTMLSlotElement>
>& slots) { m_descendantSlots.swap(slots); } | 82 void setDescendantSlots(HeapVector<Member<HTMLSlotElement>>& slots) { m_desc
endantSlots.swap(slots); } |
| 84 void clearDescendantSlots() { m_descendantSlots.clear(); } | 83 void clearDescendantSlots() { m_descendantSlots.clear(); } |
| 85 | 84 |
| 86 DEFINE_INLINE_TRACE() | 85 DEFINE_INLINE_TRACE() |
| 87 { | 86 { |
| 88 visitor->trace(m_shadowInsertionPointOfYoungerShadowRoot); | 87 visitor->trace(m_shadowInsertionPointOfYoungerShadowRoot); |
| 89 visitor->trace(m_descendantInsertionPoints); | 88 visitor->trace(m_descendantInsertionPoints); |
| 90 visitor->trace(m_styleSheetList); | 89 visitor->trace(m_styleSheetList); |
| 91 visitor->trace(m_descendantSlots); | 90 visitor->trace(m_descendantSlots); |
| 92 } | 91 } |
| 93 | 92 |
| 94 private: | 93 private: |
| 95 RefPtrWillBeMember<HTMLShadowElement> m_shadowInsertionPointOfYoungerShadowR
oot; | 94 Member<HTMLShadowElement> m_shadowInsertionPointOfYoungerShadowRoot; |
| 96 unsigned m_descendantShadowElementCount; | 95 unsigned m_descendantShadowElementCount; |
| 97 unsigned m_descendantContentElementCount; | 96 unsigned m_descendantContentElementCount; |
| 98 unsigned m_childShadowRootCount; | 97 unsigned m_childShadowRootCount; |
| 99 WillBeHeapVector<RefPtrWillBeMember<InsertionPoint>> m_descendantInsertionPo
ints; | 98 HeapVector<Member<InsertionPoint>> m_descendantInsertionPoints; |
| 100 RefPtrWillBeMember<StyleSheetList> m_styleSheetList; | 99 Member<StyleSheetList> m_styleSheetList; |
| 101 unsigned m_descendantSlotCount; | 100 unsigned m_descendantSlotCount; |
| 102 WillBeHeapVector<RefPtrWillBeMember<HTMLSlotElement>> m_descendantSlots; | 101 HeapVector<Member<HTMLSlotElement>> m_descendantSlots; |
| 103 }; | 102 }; |
| 104 | 103 |
| 105 inline void ShadowRootRareData::didAddInsertionPoint(InsertionPoint* point) | 104 inline void ShadowRootRareData::didAddInsertionPoint(InsertionPoint* point) |
| 106 { | 105 { |
| 107 ASSERT(point); | 106 ASSERT(point); |
| 108 if (isHTMLShadowElement(*point)) | 107 if (isHTMLShadowElement(*point)) |
| 109 ++m_descendantShadowElementCount; | 108 ++m_descendantShadowElementCount; |
| 110 else if (isHTMLContentElement(*point)) | 109 else if (isHTMLContentElement(*point)) |
| 111 ++m_descendantContentElementCount; | 110 ++m_descendantContentElementCount; |
| 112 else | 111 else |
| (...skipping 10 matching lines...) Expand all Loading... |
| 123 else | 122 else |
| 124 ASSERT_NOT_REACHED(); | 123 ASSERT_NOT_REACHED(); |
| 125 | 124 |
| 126 ASSERT(m_descendantContentElementCount >= 0); | 125 ASSERT(m_descendantContentElementCount >= 0); |
| 127 ASSERT(m_descendantShadowElementCount >= 0); | 126 ASSERT(m_descendantShadowElementCount >= 0); |
| 128 } | 127 } |
| 129 | 128 |
| 130 } // namespace blink | 129 } // namespace blink |
| 131 | 130 |
| 132 #endif | 131 #endif |
| OLD | NEW |