| 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 22 matching lines...) Expand all Loading... |
| 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/Vector.h" | 36 #include "wtf/Vector.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class ShadowRootRareData : public GarbageCollected<ShadowRootRareData> { | 40 class ShadowRootRareData : public GarbageCollected<ShadowRootRareData> { |
| 41 public: | 41 public: |
| 42 ShadowRootRareData() | 42 ShadowRootRareData() |
| 43 : m_descendantShadowElementCount(0) | 43 : m_childShadowRootCount(0) |
| 44 , m_descendantContentElementCount(0) | |
| 45 , m_childShadowRootCount(0) | |
| 46 , m_descendantSlotCount(0) | 44 , m_descendantSlotCount(0) |
| 47 { | 45 { |
| 48 } | 46 } |
| 49 | 47 |
| 50 HTMLShadowElement* shadowInsertionPointOfYoungerShadowRoot() const { return
m_shadowInsertionPointOfYoungerShadowRoot.get(); } | |
| 51 void setShadowInsertionPointOfYoungerShadowRoot(HTMLShadowElement* shadowIns
ertionPoint) { m_shadowInsertionPointOfYoungerShadowRoot = shadowInsertionPoint;
} | |
| 52 | |
| 53 void didAddInsertionPoint(InsertionPoint*); | |
| 54 void didRemoveInsertionPoint(InsertionPoint*); | |
| 55 | |
| 56 bool containsShadowElements() const { return m_descendantShadowElementCount;
} | |
| 57 bool containsContentElements() const { return m_descendantContentElementCoun
t; } | |
| 58 bool containsShadowRoots() const { return m_childShadowRootCount; } | 48 bool containsShadowRoots() const { return m_childShadowRootCount; } |
| 59 | 49 |
| 60 unsigned descendantShadowElementCount() const { return m_descendantShadowEle
mentCount; } | |
| 61 | |
| 62 void didAddChildShadowRoot() { ++m_childShadowRootCount; } | 50 void didAddChildShadowRoot() { ++m_childShadowRootCount; } |
| 63 void didRemoveChildShadowRoot() { DCHECK_GT(m_childShadowRootCount, 0u); --m
_childShadowRootCount; } | 51 void didRemoveChildShadowRoot() { DCHECK_GT(m_childShadowRootCount, 0u); --m
_childShadowRootCount; } |
| 64 | 52 |
| 65 unsigned childShadowRootCount() const { return m_childShadowRootCount; } | 53 unsigned childShadowRootCount() const { return m_childShadowRootCount; } |
| 66 | 54 |
| 67 const HeapVector<Member<InsertionPoint>>& descendantInsertionPoints() { retu
rn m_descendantInsertionPoints; } | |
| 68 void setDescendantInsertionPoints(HeapVector<Member<InsertionPoint>>& list)
{ m_descendantInsertionPoints.swap(list); } | |
| 69 void clearDescendantInsertionPoints() { m_descendantInsertionPoints.clear();
} | |
| 70 | |
| 71 StyleSheetList* styleSheets() { return m_styleSheetList.get(); } | 55 StyleSheetList* styleSheets() { return m_styleSheetList.get(); } |
| 72 void setStyleSheets(StyleSheetList* styleSheetList) { m_styleSheetList = sty
leSheetList; } | 56 void setStyleSheets(StyleSheetList* styleSheetList) { m_styleSheetList = sty
leSheetList; } |
| 73 | 57 |
| 74 void didAddSlot() { ++m_descendantSlotCount; } | 58 void didAddSlot() { ++m_descendantSlotCount; } |
| 75 void didRemoveSlot() { DCHECK_GT(m_descendantSlotCount, 0u); --m_descendantS
lotCount; } | 59 void didRemoveSlot() { DCHECK_GT(m_descendantSlotCount, 0u); --m_descendantS
lotCount; } |
| 76 | 60 |
| 77 unsigned descendantSlotCount() const { return m_descendantSlotCount; } | 61 unsigned descendantSlotCount() const { return m_descendantSlotCount; } |
| 78 | 62 |
| 79 const HeapVector<Member<HTMLSlotElement>>& descendantSlots() const { return
m_descendantSlots; } | 63 const HeapVector<Member<HTMLSlotElement>>& descendantSlots() const { return
m_descendantSlots; } |
| 80 | 64 |
| 81 void setDescendantSlots(HeapVector<Member<HTMLSlotElement>>& slots) { m_desc
endantSlots.swap(slots); } | 65 void setDescendantSlots(HeapVector<Member<HTMLSlotElement>>& slots) { m_desc
endantSlots.swap(slots); } |
| 82 void clearDescendantSlots() { m_descendantSlots.clear(); } | 66 void clearDescendantSlots() { m_descendantSlots.clear(); } |
| 83 | 67 |
| 84 DEFINE_INLINE_TRACE() | 68 DEFINE_INLINE_TRACE() |
| 85 { | 69 { |
| 86 visitor->trace(m_shadowInsertionPointOfYoungerShadowRoot); | |
| 87 visitor->trace(m_descendantInsertionPoints); | |
| 88 visitor->trace(m_styleSheetList); | 70 visitor->trace(m_styleSheetList); |
| 89 visitor->trace(m_descendantSlots); | 71 visitor->trace(m_descendantSlots); |
| 90 } | 72 } |
| 91 | 73 |
| 92 private: | 74 private: |
| 93 Member<HTMLShadowElement> m_shadowInsertionPointOfYoungerShadowRoot; | |
| 94 unsigned m_descendantShadowElementCount; | |
| 95 unsigned m_descendantContentElementCount; | |
| 96 unsigned m_childShadowRootCount; | 75 unsigned m_childShadowRootCount; |
| 97 HeapVector<Member<InsertionPoint>> m_descendantInsertionPoints; | |
| 98 Member<StyleSheetList> m_styleSheetList; | 76 Member<StyleSheetList> m_styleSheetList; |
| 99 unsigned m_descendantSlotCount; | 77 unsigned m_descendantSlotCount; |
| 100 HeapVector<Member<HTMLSlotElement>> m_descendantSlots; | 78 HeapVector<Member<HTMLSlotElement>> m_descendantSlots; |
| 101 }; | 79 }; |
| 102 | 80 |
| 103 inline void ShadowRootRareData::didAddInsertionPoint(InsertionPoint* point) | |
| 104 { | |
| 105 DCHECK(point); | |
| 106 if (isHTMLShadowElement(*point)) | |
| 107 ++m_descendantShadowElementCount; | |
| 108 else if (isHTMLContentElement(*point)) | |
| 109 ++m_descendantContentElementCount; | |
| 110 else | |
| 111 ASSERT_NOT_REACHED(); | |
| 112 } | |
| 113 | |
| 114 inline void ShadowRootRareData::didRemoveInsertionPoint(InsertionPoint* point) | |
| 115 { | |
| 116 DCHECK(point); | |
| 117 if (isHTMLShadowElement(*point)) { | |
| 118 DCHECK_GT(m_descendantShadowElementCount, 0u); | |
| 119 --m_descendantShadowElementCount; | |
| 120 } else if (isHTMLContentElement(*point)) { | |
| 121 DCHECK_GT(m_descendantContentElementCount, 0u); | |
| 122 --m_descendantContentElementCount; | |
| 123 } else { | |
| 124 ASSERT_NOT_REACHED(); | |
| 125 } | |
| 126 } | |
| 127 | |
| 128 } // namespace blink | 81 } // namespace blink |
| 129 | 82 |
| 130 #endif | 83 #endif |
| OLD | NEW |