| 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 "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
| 36 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class ShadowRootRareData { | 40 class ShadowRootRareData { |
| 41 public: | 41 public: |
| 42 ShadowRootRareData() | 42 ShadowRootRareData() |
| 43 : m_descendantShadowElementCount(0) | 43 : m_descendantContentElementCount(0) |
| 44 , m_descendantContentElementCount(0) | |
| 45 , m_childShadowRootCount(0) | 44 , m_childShadowRootCount(0) |
| 46 { | 45 { |
| 47 } | 46 } |
| 48 | 47 |
| 49 HTMLShadowElement* shadowInsertionPointOfYoungerShadowRoot() const { return
m_shadowInsertionPointOfYoungerShadowRoot.get(); } | |
| 50 void setShadowInsertionPointOfYoungerShadowRoot(PassRefPtr<HTMLShadowElement
> shadowInsertionPoint) { m_shadowInsertionPointOfYoungerShadowRoot = shadowInse
rtionPoint; } | |
| 51 | |
| 52 void didAddInsertionPoint(InsertionPoint*); | 48 void didAddInsertionPoint(InsertionPoint*); |
| 53 void didRemoveInsertionPoint(InsertionPoint*); | 49 void didRemoveInsertionPoint(InsertionPoint*); |
| 54 | 50 |
| 55 bool containsShadowElements() const { return m_descendantShadowElementCount;
} | |
| 56 bool containsContentElements() const { return m_descendantContentElementCoun
t; } | 51 bool containsContentElements() const { return m_descendantContentElementCoun
t; } |
| 57 bool containsShadowRoots() const { return m_childShadowRootCount; } | 52 bool containsShadowRoots() const { return m_childShadowRootCount; } |
| 58 | 53 |
| 59 unsigned descendantShadowElementCount() const { return m_descendantShadowEle
mentCount; } | |
| 60 | |
| 61 void didAddChildShadowRoot() { ++m_childShadowRootCount; } | 54 void didAddChildShadowRoot() { ++m_childShadowRootCount; } |
| 62 void didRemoveChildShadowRoot() { ASSERT(m_childShadowRootCount > 0); --m_ch
ildShadowRootCount; } | 55 void didRemoveChildShadowRoot() { ASSERT(m_childShadowRootCount > 0); --m_ch
ildShadowRootCount; } |
| 63 | 56 |
| 64 unsigned childShadowRootCount() const { return m_childShadowRootCount; } | 57 unsigned childShadowRootCount() const { return m_childShadowRootCount; } |
| 65 | 58 |
| 66 const Vector<RefPtr<InsertionPoint> >& descendantInsertionPoints() { return
m_descendantInsertionPoints; } | 59 const Vector<RefPtr<InsertionPoint> >& descendantInsertionPoints() { return
m_descendantInsertionPoints; } |
| 67 void setDescendantInsertionPoints(Vector<RefPtr<InsertionPoint> >& list) { m
_descendantInsertionPoints.swap(list); } | 60 void setDescendantInsertionPoints(Vector<RefPtr<InsertionPoint> >& list) { m
_descendantInsertionPoints.swap(list); } |
| 68 void clearDescendantInsertionPoints() { m_descendantInsertionPoints.clear();
} | 61 void clearDescendantInsertionPoints() { m_descendantInsertionPoints.clear();
} |
| 69 | 62 |
| 70 StyleSheetList* styleSheets() { return m_styleSheetList.get(); } | 63 StyleSheetList* styleSheets() { return m_styleSheetList.get(); } |
| 71 void setStyleSheets(PassRefPtr<StyleSheetList> styleSheetList) { m_styleShee
tList = styleSheetList; } | 64 void setStyleSheets(PassRefPtr<StyleSheetList> styleSheetList) { m_styleShee
tList = styleSheetList; } |
| 72 | 65 |
| 73 void trace(Visitor* visitor) | |
| 74 { | |
| 75 visitor->trace(m_shadowInsertionPointOfYoungerShadowRoot); | |
| 76 visitor->trace(m_descendantInsertionPoints); | |
| 77 visitor->trace(m_styleSheetList); | |
| 78 } | |
| 79 | 66 |
| 80 private: | 67 private: |
| 81 RefPtr<HTMLShadowElement> m_shadowInsertionPointOfYoungerShadowRoot; | |
| 82 unsigned m_descendantShadowElementCount; | |
| 83 unsigned m_descendantContentElementCount; | 68 unsigned m_descendantContentElementCount; |
| 84 unsigned m_childShadowRootCount; | 69 unsigned m_childShadowRootCount; |
| 85 Vector<RefPtr<InsertionPoint> > m_descendantInsertionPoints; | 70 Vector<RefPtr<InsertionPoint> > m_descendantInsertionPoints; |
| 86 RefPtr<StyleSheetList> m_styleSheetList; | 71 RefPtr<StyleSheetList> m_styleSheetList; |
| 87 }; | 72 }; |
| 88 | 73 |
| 89 inline void ShadowRootRareData::didAddInsertionPoint(InsertionPoint* point) | 74 inline void ShadowRootRareData::didAddInsertionPoint(InsertionPoint* point) |
| 90 { | 75 { |
| 91 ASSERT(point); | 76 ASSERT(point); |
| 92 if (isHTMLShadowElement(*point)) | 77 if (isHTMLContentElement(*point)) |
| 93 ++m_descendantShadowElementCount; | |
| 94 else if (isHTMLContentElement(*point)) | |
| 95 ++m_descendantContentElementCount; | 78 ++m_descendantContentElementCount; |
| 96 else | 79 else |
| 97 ASSERT_NOT_REACHED(); | 80 ASSERT_NOT_REACHED(); |
| 98 } | 81 } |
| 99 | 82 |
| 100 inline void ShadowRootRareData::didRemoveInsertionPoint(InsertionPoint* point) | 83 inline void ShadowRootRareData::didRemoveInsertionPoint(InsertionPoint* point) |
| 101 { | 84 { |
| 102 ASSERT(point); | 85 ASSERT(point); |
| 103 if (isHTMLShadowElement(*point)) | 86 if (isHTMLContentElement(*point)) |
| 104 --m_descendantShadowElementCount; | |
| 105 else if (isHTMLContentElement(*point)) | |
| 106 --m_descendantContentElementCount; | 87 --m_descendantContentElementCount; |
| 107 else | 88 else |
| 108 ASSERT_NOT_REACHED(); | 89 ASSERT_NOT_REACHED(); |
| 109 | 90 |
| 110 ASSERT(m_descendantContentElementCount >= 0); | 91 ASSERT(m_descendantContentElementCount >= 0); |
| 111 ASSERT(m_descendantShadowElementCount >= 0); | |
| 112 } | 92 } |
| 113 | 93 |
| 114 } // namespace blink | 94 } // namespace blink |
| 115 | 95 |
| 116 #endif | 96 #endif |
| OLD | NEW |