| 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 12 matching lines...) Expand all Loading... |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 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 #include "sky/engine/core/dom/shadow/ElementShadow.h" | 27 #include "sky/engine/core/dom/shadow/ElementShadow.h" |
| 28 | 28 |
| 29 #include "sky/engine/core/dom/Document.h" | 29 #include "sky/engine/core/dom/Document.h" |
| 30 #include "sky/engine/core/dom/ElementTraversal.h" | 30 #include "sky/engine/core/dom/ElementTraversal.h" |
| 31 #include "sky/engine/core/dom/NodeTraversal.h" | 31 #include "sky/engine/core/dom/NodeTraversal.h" |
| 32 #include "sky/engine/core/dom/shadow/ContentDistribution.h" | 32 #include "sky/engine/core/dom/shadow/ContentDistribution.h" |
| 33 #include "sky/engine/core/html/HTMLContentElement.h" | |
| 34 #include "sky/engine/platform/EventDispatchForbiddenScope.h" | 33 #include "sky/engine/platform/EventDispatchForbiddenScope.h" |
| 35 #include "sky/engine/platform/ScriptForbiddenScope.h" | 34 #include "sky/engine/platform/ScriptForbiddenScope.h" |
| 36 | 35 |
| 37 namespace blink { | 36 namespace blink { |
| 38 | 37 |
| 39 class DistributionPool final { | 38 class DistributionPool final { |
| 40 STACK_ALLOCATED(); | 39 STACK_ALLOCATED(); |
| 41 public: | 40 public: |
| 42 explicit DistributionPool(const ContainerNode&); | 41 explicit DistributionPool(const ContainerNode&); |
| 43 void clear(); | 42 void clear(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 79 } |
| 81 | 80 |
| 82 void DistributionPool::distributeTo(InsertionPoint* insertionPoint, ElementShado
w* elementShadow) | 81 void DistributionPool::distributeTo(InsertionPoint* insertionPoint, ElementShado
w* elementShadow) |
| 83 { | 82 { |
| 84 ContentDistribution distribution; | 83 ContentDistribution distribution; |
| 85 | 84 |
| 86 for (size_t i = 0; i < m_nodes.size(); ++i) { | 85 for (size_t i = 0; i < m_nodes.size(); ++i) { |
| 87 if (m_distributed[i]) | 86 if (m_distributed[i]) |
| 88 continue; | 87 continue; |
| 89 | 88 |
| 90 if (isHTMLContentElement(*insertionPoint) && !toHTMLContentElement(inser
tionPoint)->canSelectNode(m_nodes, i)) | |
| 91 continue; | |
| 92 | |
| 93 Node* node = m_nodes[i]; | 89 Node* node = m_nodes[i]; |
| 94 distribution.append(node); | 90 distribution.append(node); |
| 95 elementShadow->didDistributeNode(node, insertionPoint); | 91 elementShadow->didDistributeNode(node, insertionPoint); |
| 96 m_distributed[i] = true; | 92 m_distributed[i] = true; |
| 97 } | 93 } |
| 98 | 94 |
| 99 // Distributes fallback elements | 95 // Distributes fallback elements |
| 100 if (insertionPoint->isContentInsertionPoint() && distribution.isEmpty()) { | 96 if (insertionPoint->isContentInsertionPoint() && distribution.isEmpty()) { |
| 101 for (Node* fallbackNode = insertionPoint->firstChild(); fallbackNode; fa
llbackNode = fallbackNode->nextSibling()) { | 97 for (Node* fallbackNode = insertionPoint->firstChild(); fallbackNode; fa
llbackNode = fallbackNode->nextSibling()) { |
| 102 distribution.append(fallbackNode); | 98 distribution.append(fallbackNode); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 260 } |
| 265 | 261 |
| 266 void ElementShadow::collectSelectFeatureSetFrom(ShadowRoot& root) | 262 void ElementShadow::collectSelectFeatureSetFrom(ShadowRoot& root) |
| 267 { | 263 { |
| 268 if (!root.containsShadowRoots() && !root.containsContentElements()) | 264 if (!root.containsShadowRoots() && !root.containsContentElements()) |
| 269 return; | 265 return; |
| 270 | 266 |
| 271 for (Element* element = ElementTraversal::firstWithin(root); element; elemen
t = ElementTraversal::next(*element, &root)) { | 267 for (Element* element = ElementTraversal::firstWithin(root); element; elemen
t = ElementTraversal::next(*element, &root)) { |
| 272 if (ElementShadow* shadow = element->shadow()) | 268 if (ElementShadow* shadow = element->shadow()) |
| 273 m_selectFeatures.add(shadow->ensureSelectFeatureSet()); | 269 m_selectFeatures.add(shadow->ensureSelectFeatureSet()); |
| 274 if (!isHTMLContentElement(*element)) | |
| 275 continue; | |
| 276 const CSSSelectorList& list = toHTMLContentElement(*element).selectorLis
t(); | |
| 277 for (const CSSSelector* selector = list.first(); selector; selector = CS
SSelectorList::next(*selector)) { | |
| 278 for (const CSSSelector* component = selector; component; component =
component->tagHistory()) | |
| 279 m_selectFeatures.collectFeaturesFromSelector(*component); | |
| 280 } | |
| 281 } | 270 } |
| 282 } | 271 } |
| 283 | 272 |
| 284 void ElementShadow::willAffectSelector() | 273 void ElementShadow::willAffectSelector() |
| 285 { | 274 { |
| 286 for (ElementShadow* shadow = this; shadow; shadow = shadow->containingShadow
()) { | 275 for (ElementShadow* shadow = this; shadow; shadow = shadow->containingShadow
()) { |
| 287 if (shadow->needsSelectFeatureSet()) | 276 if (shadow->needsSelectFeatureSet()) |
| 288 break; | 277 break; |
| 289 shadow->setNeedsSelectFeatureSet(); | 278 shadow->setNeedsSelectFeatureSet(); |
| 290 } | 279 } |
| 291 setNeedsDistributionRecalc(); | 280 setNeedsDistributionRecalc(); |
| 292 } | 281 } |
| 293 | 282 |
| 294 void ElementShadow::clearDistribution() | 283 void ElementShadow::clearDistribution() |
| 295 { | 284 { |
| 296 m_nodeToInsertionPoints.clear(); | 285 m_nodeToInsertionPoints.clear(); |
| 297 } | 286 } |
| 298 | 287 |
| 299 } // namespace | 288 } // namespace |
| OLD | NEW |