Chromium Code Reviews| 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/dom/shadow/InsertionPoint.h" | 31 #include "core/dom/shadow/InsertionPoint.h" |
| 32 | 32 |
| 33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
| 34 #include "core/dom/Document.h" | 34 |
|
tkent
2016/09/13 07:09:45
nit: The blank line is unnecessary.
hayato
2016/09/13 07:14:56
Done
| |
| 35 #include "core/dom/ElementTraversal.h" | 35 #include "core/dom/ElementTraversal.h" |
| 36 #include "core/dom/QualifiedName.h" | 36 #include "core/dom/QualifiedName.h" |
| 37 #include "core/dom/StaticNodeList.h" | 37 #include "core/dom/StaticNodeList.h" |
| 38 #include "core/dom/StyleChangeReason.h" | 38 #include "core/dom/StyleChangeReason.h" |
| 39 #include "core/dom/shadow/ElementShadow.h" | 39 #include "core/dom/shadow/ElementShadow.h" |
| 40 #include "core/dom/shadow/ElementShadowV0.h" | |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 using namespace HTMLNames; | 44 using namespace HTMLNames; |
| 44 | 45 |
| 45 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document& document) | 46 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document& document) |
| 46 : HTMLElement(tagName, document, CreateInsertionPoint) | 47 : HTMLElement(tagName, document, CreateInsertionPoint) |
| 47 , m_registeredWithShadowRoot(false) | 48 , m_registeredWithShadowRoot(false) |
| 48 { | 49 { |
| 49 setHasCustomStyleCallbacks(); | 50 setHasCustomStyleCallbacks(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 if (ShadowRoot* root = containingShadowRoot()) { | 198 if (ShadowRoot* root = containingShadowRoot()) { |
| 198 if (ElementShadow* rootOwner = root->owner()) | 199 if (ElementShadow* rootOwner = root->owner()) |
| 199 rootOwner->setNeedsDistributionRecalc(); | 200 rootOwner->setNeedsDistributionRecalc(); |
| 200 } | 201 } |
| 201 } | 202 } |
| 202 | 203 |
| 203 Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode* i nsertionPoint) | 204 Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode* i nsertionPoint) |
| 204 { | 205 { |
| 205 HTMLElement::insertedInto(insertionPoint); | 206 HTMLElement::insertedInto(insertionPoint); |
| 206 if (ShadowRoot* root = containingShadowRoot()) { | 207 if (ShadowRoot* root = containingShadowRoot()) { |
| 207 if (ElementShadow* rootOwner = root->owner()) { | 208 if (!root->isV1()) { |
| 208 rootOwner->setNeedsDistributionRecalc(); | 209 if (ElementShadow* rootOwner = root->owner()) { |
| 209 if (canBeActive() && !m_registeredWithShadowRoot && insertionPoint-> treeScope().rootNode() == root) { | 210 rootOwner->setNeedsDistributionRecalc(); |
| 210 m_registeredWithShadowRoot = true; | 211 if (canBeActive() && !m_registeredWithShadowRoot && insertionPoi nt->treeScope().rootNode() == root) { |
| 211 root->didAddInsertionPoint(this); | 212 m_registeredWithShadowRoot = true; |
| 212 if (canAffectSelector()) | 213 root->didAddInsertionPoint(this); |
| 213 rootOwner->willAffectSelector(); | 214 if (canAffectSelector()) |
| 215 rootOwner->v0().willAffectSelector(); | |
| 216 } | |
| 214 } | 217 } |
| 215 } | 218 } |
| 216 } | 219 } |
| 217 | 220 |
| 218 // We could have been distributed into in a detached subtree, make sure to | 221 // We could have been distributed into in a detached subtree, make sure to |
| 219 // clear the distribution when inserted again to avoid cycles. | 222 // clear the distribution when inserted again to avoid cycles. |
| 220 clearDistribution(); | 223 clearDistribution(); |
| 221 | 224 |
| 222 return InsertionDone; | 225 return InsertionDone; |
| 223 } | 226 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 236 // host can be null when removedFrom() is called from ElementShadow destruct or. | 239 // host can be null when removedFrom() is called from ElementShadow destruct or. |
| 237 ElementShadow* rootOwner = root ? root->owner() : 0; | 240 ElementShadow* rootOwner = root ? root->owner() : 0; |
| 238 | 241 |
| 239 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. | 242 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. |
| 240 clearDistribution(); | 243 clearDistribution(); |
| 241 | 244 |
| 242 if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) { | 245 if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) { |
| 243 DCHECK(root); | 246 DCHECK(root); |
| 244 m_registeredWithShadowRoot = false; | 247 m_registeredWithShadowRoot = false; |
| 245 root->didRemoveInsertionPoint(this); | 248 root->didRemoveInsertionPoint(this); |
| 246 if (rootOwner) { | 249 if (!root->isV1() && rootOwner) { |
| 247 if (canAffectSelector()) | 250 if (canAffectSelector()) |
| 248 rootOwner->willAffectSelector(); | 251 rootOwner->v0().willAffectSelector(); |
| 249 } | 252 } |
| 250 } | 253 } |
| 251 | 254 |
| 252 HTMLElement::removedFrom(insertionPoint); | 255 HTMLElement::removedFrom(insertionPoint); |
| 253 } | 256 } |
| 254 | 257 |
| 255 DEFINE_TRACE(InsertionPoint) | 258 DEFINE_TRACE(InsertionPoint) |
| 256 { | 259 { |
| 257 visitor->trace(m_distributedNodes); | 260 visitor->trace(m_distributedNodes); |
| 258 HTMLElement::trace(visitor); | 261 HTMLElement::trace(visitor); |
| 259 } | 262 } |
| 260 | 263 |
| 261 const InsertionPoint* resolveReprojection(const Node* projectedNode) | 264 const InsertionPoint* resolveReprojection(const Node* projectedNode) |
| 262 { | 265 { |
| 263 DCHECK(projectedNode); | 266 DCHECK(projectedNode); |
| 264 const InsertionPoint* insertionPoint = 0; | 267 const InsertionPoint* insertionPoint = 0; |
| 265 const Node* current = projectedNode; | 268 const Node* current = projectedNode; |
| 266 ElementShadow* lastElementShadow = 0; | 269 ElementShadow* lastElementShadow = 0; |
| 267 while (true) { | 270 while (true) { |
| 268 ElementShadow* shadow = shadowWhereNodeCanBeDistributedForV0(*current); | 271 ElementShadow* shadow = shadowWhereNodeCanBeDistributedForV0(*current); |
| 269 if (!shadow || shadow->isV1() || shadow == lastElementShadow) | 272 if (!shadow || shadow->isV1() || shadow == lastElementShadow) |
| 270 break; | 273 break; |
| 271 lastElementShadow = shadow; | 274 lastElementShadow = shadow; |
| 272 const InsertionPoint* insertedTo = shadow->finalDestinationInsertionPoin tFor(projectedNode); | 275 const InsertionPoint* insertedTo = shadow->v0().finalDestinationInsertio nPointFor(projectedNode); |
| 273 if (!insertedTo) | 276 if (!insertedTo) |
| 274 break; | 277 break; |
| 275 DCHECK_NE(current, insertedTo); | 278 DCHECK_NE(current, insertedTo); |
| 276 current = insertedTo; | 279 current = insertedTo; |
| 277 insertionPoint = insertedTo; | 280 insertionPoint = insertedTo; |
| 278 } | 281 } |
| 279 return insertionPoint; | 282 return insertionPoint; |
| 280 } | 283 } |
| 281 | 284 |
| 282 void collectDestinationInsertionPoints(const Node& node, HeapVector<Member<Inser tionPoint>, 8>& results) | 285 void collectDestinationInsertionPoints(const Node& node, HeapVector<Member<Inser tionPoint>, 8>& results) |
| 283 { | 286 { |
| 284 const Node* current = &node; | 287 const Node* current = &node; |
| 285 ElementShadow* lastElementShadow = 0; | 288 ElementShadow* lastElementShadow = 0; |
| 286 while (true) { | 289 while (true) { |
| 287 ElementShadow* shadow = shadowWhereNodeCanBeDistributedForV0(*current); | 290 ElementShadow* shadow = shadowWhereNodeCanBeDistributedForV0(*current); |
| 288 if (!shadow || shadow->isV1() || shadow == lastElementShadow) | 291 if (!shadow || shadow->isV1() || shadow == lastElementShadow) |
| 289 return; | 292 return; |
| 290 lastElementShadow = shadow; | 293 lastElementShadow = shadow; |
| 291 const DestinationInsertionPoints* insertionPoints = shadow->destinationI nsertionPointsFor(&node); | 294 const DestinationInsertionPoints* insertionPoints = shadow->v0().destina tionInsertionPointsFor(&node); |
| 292 if (!insertionPoints) | 295 if (!insertionPoints) |
| 293 return; | 296 return; |
| 294 for (size_t i = 0; i < insertionPoints->size(); ++i) | 297 for (size_t i = 0; i < insertionPoints->size(); ++i) |
| 295 results.append(insertionPoints->at(i).get()); | 298 results.append(insertionPoints->at(i).get()); |
| 296 DCHECK_NE(current, insertionPoints->last().get()); | 299 DCHECK_NE(current, insertionPoints->last().get()); |
| 297 current = insertionPoints->last().get(); | 300 current = insertionPoints->last().get(); |
| 298 } | 301 } |
| 299 } | 302 } |
| 300 | 303 |
| 301 } // namespace blink | 304 } // namespace blink |
| OLD | NEW |