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 27 matching lines...) Expand all Loading... | |
38 #include "core/dom/shadow/ShadowRoot.h" | 38 #include "core/dom/shadow/ShadowRoot.h" |
39 | 39 |
40 namespace WebCore { | 40 namespace WebCore { |
41 | 41 |
42 using namespace HTMLNames; | 42 using namespace HTMLNames; |
43 | 43 |
44 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document) | 44 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document) |
45 : HTMLElement(tagName, document, CreateInsertionPoint) | 45 : HTMLElement(tagName, document, CreateInsertionPoint) |
46 , m_registeredWithShadowRoot(false) | 46 , m_registeredWithShadowRoot(false) |
47 { | 47 { |
48 setHasCustomStyleCallbacks(); | |
48 } | 49 } |
49 | 50 |
50 InsertionPoint::~InsertionPoint() | 51 InsertionPoint::~InsertionPoint() |
51 { | 52 { |
52 } | 53 } |
53 | 54 |
54 void InsertionPoint::attach(const AttachContext& context) | 55 void InsertionPoint::attach(const AttachContext& context) |
55 { | 56 { |
56 if (ShadowRoot* shadowRoot = containingShadowRoot()) | 57 if (ShadowRoot* shadowRoot = containingShadowRoot()) |
57 ContentDistributor::ensureDistribution(shadowRoot); | 58 ContentDistributor::ensureDistribution(shadowRoot); |
58 for (size_t i = 0; i < m_distribution.size(); ++i) { | 59 for (size_t i = 0; i < m_distribution.size(); ++i) { |
59 if (!m_distribution.at(i)->attached()) | 60 if (!m_distribution.at(i)->attached()) |
60 m_distribution.at(i)->attach(context); | 61 m_distribution.at(i)->attach(context); |
61 } | 62 } |
62 | 63 |
63 HTMLElement::attach(context); | 64 HTMLElement::attach(context); |
64 } | 65 } |
65 | 66 |
66 void InsertionPoint::detach(const AttachContext& context) | 67 void InsertionPoint::detach(const AttachContext& context) |
67 { | 68 { |
68 if (ShadowRoot* shadowRoot = containingShadowRoot()) | 69 if (ShadowRoot* shadowRoot = containingShadowRoot()) |
69 ContentDistributor::ensureDistribution(shadowRoot); | 70 ContentDistributor::ensureDistribution(shadowRoot); |
70 | 71 |
71 for (size_t i = 0; i < m_distribution.size(); ++i) | 72 for (size_t i = 0; i < m_distribution.size(); ++i) |
72 m_distribution.at(i)->detach(context); | 73 m_distribution.at(i)->detach(context); |
73 | 74 |
74 HTMLElement::detach(context); | 75 HTMLElement::detach(context); |
75 } | 76 } |
76 | 77 |
78 void InsertionPoint::willRecalcStyle(StyleChange change) | |
79 { | |
80 if (change < Inherit) | |
81 return; | |
82 if (ShadowRoot* shadowRoot = containingShadowRoot()) { | |
83 ContentDistributor::ensureDistribution(shadowRoot); | |
esprehn
2013/06/14 08:32:29
Why not call shadowRoot->host() here and avoid the
| |
84 shadowRoot->owner()->distributor().setNeedsStyleRecalcIfDistributedTo(sh adowRoot->host(), this); | |
85 } | |
86 } | |
87 | |
77 bool InsertionPoint::shouldUseFallbackElements() const | 88 bool InsertionPoint::shouldUseFallbackElements() const |
78 { | 89 { |
79 return isActive() && !hasDistribution(); | 90 return isActive() && !hasDistribution(); |
80 } | 91 } |
81 | 92 |
82 bool InsertionPoint::isShadowBoundary() const | 93 bool InsertionPoint::isShadowBoundary() const |
83 { | 94 { |
84 return treeScope()->rootNode()->isShadowRoot() && isActive(); | 95 return treeScope()->rootNode()->isShadowRoot() && isActive(); |
85 } | 96 } |
86 | 97 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 return selectorList; | 210 return selectorList; |
200 } | 211 } |
201 | 212 |
202 InsertionPoint* resolveReprojection(const Node* projectedNode) | 213 InsertionPoint* resolveReprojection(const Node* projectedNode) |
203 { | 214 { |
204 InsertionPoint* insertionPoint = 0; | 215 InsertionPoint* insertionPoint = 0; |
205 const Node* current = projectedNode; | 216 const Node* current = projectedNode; |
206 | 217 |
207 while (current) { | 218 while (current) { |
208 if (ElementShadow* shadow = shadowOfParentForDistribution(current)) { | 219 if (ElementShadow* shadow = shadowOfParentForDistribution(current)) { |
220 ContentDistributor::ensureDistribution(shadow); | |
209 if (ShadowRoot* root = current->containingShadowRoot()) | 221 if (ShadowRoot* root = current->containingShadowRoot()) |
210 ContentDistributor::ensureDistribution(root); | 222 ContentDistributor::ensureDistribution(root); |
211 if (InsertionPoint* insertedTo = shadow->distributor().findInsertion PointFor(projectedNode)) { | 223 if (InsertionPoint* insertedTo = shadow->distributor().findInsertion PointFor(projectedNode)) { |
212 current = insertedTo; | 224 current = insertedTo; |
213 insertionPoint = insertedTo; | 225 insertionPoint = insertedTo; |
214 continue; | 226 continue; |
215 } | 227 } |
216 } | 228 } |
217 | 229 |
218 if (Node* parent = parentNodeForDistribution(current)) { | 230 if (Node* parent = parentNodeForDistribution(current)) { |
(...skipping 28 matching lines...) Expand all Loading... | |
247 current = insertedTo; | 259 current = insertedTo; |
248 results.append(insertedTo); | 260 results.append(insertedTo); |
249 continue; | 261 continue; |
250 } | 262 } |
251 } | 263 } |
252 return; | 264 return; |
253 } | 265 } |
254 } | 266 } |
255 | 267 |
256 } // namespace WebCore | 268 } // namespace WebCore |
OLD | NEW |