| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 , m_applyAuthorStyles(false) | 124 , m_applyAuthorStyles(false) |
| 125 , m_needsSelectFeatureSet(false) | 125 , m_needsSelectFeatureSet(false) |
| 126 { | 126 { |
| 127 } | 127 } |
| 128 | 128 |
| 129 ElementShadow::~ElementShadow() | 129 ElementShadow::~ElementShadow() |
| 130 { | 130 { |
| 131 removeAllShadowRoots(); | 131 removeAllShadowRoots(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 ShadowRoot* ElementShadow::addShadowRoot(Element* shadowHost, ShadowRoot::Shadow
RootType type) | 134 ShadowRoot* ElementShadow::addShadowRoot(Element& shadowHost, ShadowRoot::Shadow
RootType type) |
| 135 { | 135 { |
| 136 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(&shadowHost->document(),
type); | 136 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(&shadowHost.document(), t
ype); |
| 137 | 137 |
| 138 shadowRoot->setParentOrShadowHostNode(shadowHost); | 138 shadowRoot->setParentOrShadowHostNode(&shadowHost); |
| 139 shadowRoot->setParentTreeScope(&shadowHost->treeScope()); | 139 shadowRoot->setParentTreeScope(&shadowHost.treeScope()); |
| 140 m_shadowRoots.push(shadowRoot.get()); | 140 m_shadowRoots.push(shadowRoot.get()); |
| 141 ChildNodeInsertionNotifier(shadowHost).notify(shadowRoot.get()); | 141 ChildNodeInsertionNotifier(shadowHost).notify(*shadowRoot); |
| 142 setNeedsDistributionRecalc(); | 142 setNeedsDistributionRecalc(); |
| 143 shadowHost->lazyReattachIfAttached(); | 143 shadowHost.lazyReattachIfAttached(); |
| 144 | 144 |
| 145 // addShadowRoot() affects apply-author-styles. However, we know that the yo
ungest shadow root has not had any children yet. | 145 // addShadowRoot() affects apply-author-styles. However, we know that the yo
ungest shadow root has not had any children yet. |
| 146 // The youngest shadow root's apply-author-styles is default (false). So we
can just set m_applyAuthorStyles false. | 146 // The youngest shadow root's apply-author-styles is default (false). So we
can just set m_applyAuthorStyles false. |
| 147 m_applyAuthorStyles = false; | 147 m_applyAuthorStyles = false; |
| 148 | 148 |
| 149 shadowHost->didAddShadowRoot(*shadowRoot); | 149 shadowHost.didAddShadowRoot(*shadowRoot); |
| 150 InspectorInstrumentation::didPushShadowRoot(shadowHost, shadowRoot.get()); | 150 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); |
| 151 | 151 |
| 152 return shadowRoot.get(); | 152 return shadowRoot.get(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void ElementShadow::removeAllShadowRoots() | 155 void ElementShadow::removeAllShadowRoots() |
| 156 { | 156 { |
| 157 // Dont protect this ref count. | 157 // Dont protect this ref count. |
| 158 Element* shadowHost = host(); | 158 Element* shadowHost = host(); |
| 159 ASSERT(shadowHost); |
| 159 | 160 |
| 160 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { | 161 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { |
| 161 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); | 162 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); |
| 162 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); | 163 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); |
| 163 | 164 |
| 164 if (oldRoot->confusingAndOftenMisusedAttached()) | 165 if (oldRoot->confusingAndOftenMisusedAttached()) |
| 165 oldRoot->detach(); | 166 oldRoot->detach(); |
| 166 | 167 |
| 167 m_shadowRoots.removeHead(); | 168 m_shadowRoots.removeHead(); |
| 168 oldRoot->setParentOrShadowHostNode(0); | 169 oldRoot->setParentOrShadowHostNode(0); |
| 169 oldRoot->setParentTreeScope(&shadowHost->document()); | 170 oldRoot->setParentTreeScope(&shadowHost->document()); |
| 170 oldRoot->setPrev(0); | 171 oldRoot->setPrev(0); |
| 171 oldRoot->setNext(0); | 172 oldRoot->setNext(0); |
| 172 ChildNodeRemovalNotifier(shadowHost).notify(oldRoot.get()); | 173 ChildNodeRemovalNotifier(*shadowHost).notify(*oldRoot); |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 | 176 |
| 176 void ElementShadow::attach(const Node::AttachContext& context) | 177 void ElementShadow::attach(const Node::AttachContext& context) |
| 177 { | 178 { |
| 178 Node::AttachContext childrenContext(context); | 179 Node::AttachContext childrenContext(context); |
| 179 childrenContext.resolvedStyle = 0; | 180 childrenContext.resolvedStyle = 0; |
| 180 | 181 |
| 181 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { | 182 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { |
| 182 if (root->needsAttach()) | 183 if (root->needsAttach()) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 359 |
| 359 void ElementShadow::clearDistribution() | 360 void ElementShadow::clearDistribution() |
| 360 { | 361 { |
| 361 m_nodeToInsertionPoint.clear(); | 362 m_nodeToInsertionPoint.clear(); |
| 362 | 363 |
| 363 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) | 364 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) |
| 364 root->setInsertionPoint(0); | 365 root->setInsertionPoint(0); |
| 365 } | 366 } |
| 366 | 367 |
| 367 } // namespace | 368 } // namespace |
| OLD | NEW |