| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 13 matching lines...) Expand all Loading... |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ | 27 #ifndef SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ |
| 28 #define SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ | 28 #define SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ |
| 29 | 29 |
| 30 #include "sky/engine/core/dom/shadow/InsertionPoint.h" | 30 #include "sky/engine/core/dom/shadow/InsertionPoint.h" |
| 31 #include "sky/engine/core/dom/shadow/SelectRuleFeatureSet.h" | 31 #include "sky/engine/core/dom/shadow/SelectRuleFeatureSet.h" |
| 32 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 32 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 33 #include "sky/engine/platform/heap/Handle.h" | 33 #include "sky/engine/platform/heap/Handle.h" |
| 34 #include "sky/engine/wtf/DoublyLinkedList.h" | |
| 35 #include "sky/engine/wtf/HashMap.h" | 34 #include "sky/engine/wtf/HashMap.h" |
| 36 #include "sky/engine/wtf/Noncopyable.h" | 35 #include "sky/engine/wtf/Noncopyable.h" |
| 37 #include "sky/engine/wtf/PassOwnPtr.h" | 36 #include "sky/engine/wtf/PassOwnPtr.h" |
| 38 | 37 |
| 39 namespace blink { | 38 namespace blink { |
| 40 | 39 |
| 41 class ElementShadow final { | 40 class ElementShadow final { |
| 42 WTF_MAKE_NONCOPYABLE(ElementShadow); | 41 WTF_MAKE_NONCOPYABLE(ElementShadow); |
| 43 WTF_MAKE_FAST_ALLOCATED; | 42 WTF_MAKE_FAST_ALLOCATED; |
| 44 public: | 43 public: |
| 45 static PassOwnPtr<ElementShadow> create(); | 44 static PassOwnPtr<ElementShadow> create(); |
| 46 ~ElementShadow(); | 45 ~ElementShadow(); |
| 47 | 46 |
| 48 Element* host() const; | 47 Element* host() const; |
| 49 ShadowRoot* youngestShadowRoot() const { return m_shadowRoots.head(); } | 48 ShadowRoot* shadowRoot() const { return m_shadowRoot; } |
| 50 ShadowRoot* oldestShadowRoot() const { return m_shadowRoots.tail(); } | |
| 51 ElementShadow* containingShadow() const; | 49 ElementShadow* containingShadow() const; |
| 52 | 50 |
| 53 ShadowRoot& addShadowRoot(Element& shadowHost); | 51 ShadowRoot& addShadowRoot(Element& shadowHost); |
| 54 | 52 |
| 55 bool hasSameStyles(const ElementShadow*) const; | 53 bool hasSameStyles(const ElementShadow*) const; |
| 56 | 54 |
| 57 void attach(const Node::AttachContext&); | 55 void attach(const Node::AttachContext&); |
| 58 void detach(const Node::AttachContext&); | 56 void detach(const Node::AttachContext&); |
| 59 | 57 |
| 60 void willAffectSelector(); | 58 void willAffectSelector(); |
| 61 const SelectRuleFeatureSet& ensureSelectFeatureSet(); | 59 const SelectRuleFeatureSet& ensureSelectFeatureSet(); |
| 62 | 60 |
| 63 void distributeIfNeeded(); | 61 void distributeIfNeeded(); |
| 64 void setNeedsDistributionRecalc(); | 62 void setNeedsDistributionRecalc(); |
| 65 | 63 |
| 66 const InsertionPoint* finalDestinationInsertionPointFor(const Node*) const; | 64 const InsertionPoint* finalDestinationInsertionPointFor(const Node*) const; |
| 67 const DestinationInsertionPoints* destinationInsertionPointsFor(const Node*)
const; | 65 const DestinationInsertionPoints* destinationInsertionPointsFor(const Node*)
const; |
| 68 | 66 |
| 69 void didDistributeNode(const Node*, InsertionPoint*); | 67 void didDistributeNode(const Node*, InsertionPoint*); |
| 70 | 68 |
| 71 private: | 69 private: |
| 72 ElementShadow(); | 70 ElementShadow(); |
| 73 | 71 |
| 74 #if !ENABLE(OILPAN) | 72 void removeDetachedShadowRoot(); |
| 75 void removeDetachedShadowRoots(); | |
| 76 #endif | |
| 77 | 73 |
| 78 void distribute(); | 74 void distribute(); |
| 79 void clearDistribution(); | 75 void clearDistribution(); |
| 80 | 76 |
| 81 void collectSelectFeatureSetFrom(ShadowRoot&); | 77 void collectSelectFeatureSetFrom(ShadowRoot&); |
| 82 void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*); | 78 void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*); |
| 83 | 79 |
| 84 bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; } | 80 bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; } |
| 85 void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; } | 81 void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; } |
| 86 | 82 |
| 87 typedef HashMap<RawPtr<const Node>, DestinationInsertionPoints> NodeToDestin
ationInsertionPoints; | 83 typedef HashMap<RawPtr<const Node>, DestinationInsertionPoints> NodeToDestin
ationInsertionPoints; |
| 88 NodeToDestinationInsertionPoints m_nodeToInsertionPoints; | 84 NodeToDestinationInsertionPoints m_nodeToInsertionPoints; |
| 89 | 85 |
| 90 SelectRuleFeatureSet m_selectFeatures; | 86 SelectRuleFeatureSet m_selectFeatures; |
| 91 // FIXME: Oilpan: add a heap-based version of DoublyLinkedList<>. | 87 ShadowRoot* m_shadowRoot; |
| 92 DoublyLinkedList<ShadowRoot> m_shadowRoots; | |
| 93 bool m_needsDistributionRecalc; | 88 bool m_needsDistributionRecalc; |
| 94 bool m_needsSelectFeatureSet; | 89 bool m_needsSelectFeatureSet; |
| 95 }; | 90 }; |
| 96 | 91 |
| 97 inline Element* ElementShadow::host() const | 92 inline Element* ElementShadow::host() const |
| 98 { | 93 { |
| 99 ASSERT(!m_shadowRoots.isEmpty()); | 94 ASSERT(m_shadowRoot); |
| 100 return youngestShadowRoot()->host(); | 95 return m_shadowRoot->host(); |
| 101 } | |
| 102 | |
| 103 inline ShadowRoot* Node::youngestShadowRoot() const | |
| 104 { | |
| 105 if (!isElementNode()) | |
| 106 return 0; | |
| 107 return toElement(this)->youngestShadowRoot(); | |
| 108 } | |
| 109 | |
| 110 inline ShadowRoot* Element::youngestShadowRoot() const | |
| 111 { | |
| 112 if (ElementShadow* shadow = this->shadow()) | |
| 113 return shadow->youngestShadowRoot(); | |
| 114 return 0; | |
| 115 } | 96 } |
| 116 | 97 |
| 117 inline ElementShadow* ElementShadow::containingShadow() const | 98 inline ElementShadow* ElementShadow::containingShadow() const |
| 118 { | 99 { |
| 119 if (ShadowRoot* parentRoot = host()->containingShadowRoot()) | 100 if (ShadowRoot* parentRoot = host()->containingShadowRoot()) |
| 120 return parentRoot->owner(); | 101 return parentRoot->owner(); |
| 121 return 0; | 102 return 0; |
| 122 } | 103 } |
| 123 | 104 |
| 124 inline void ElementShadow::distributeIfNeeded() | 105 inline void ElementShadow::distributeIfNeeded() |
| 125 { | 106 { |
| 126 if (m_needsDistributionRecalc) | 107 if (m_needsDistributionRecalc) |
| 127 distribute(); | 108 distribute(); |
| 128 m_needsDistributionRecalc = false; | 109 m_needsDistributionRecalc = false; |
| 129 } | 110 } |
| 130 | 111 |
| 131 } // namespace | 112 } // namespace |
| 132 | 113 |
| 133 #endif // SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ | 114 #endif // SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ |
| OLD | NEW |