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 shadowRoot->host()->ensureDistribution(); |
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 shadowRoot->host()->ensureDistribution(); |
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 shadowRoot->host()->ensureDistribution(); |
| 84 shadowRoot->owner()->distributor().setNeedsStyleRecalcIfDistributedTo(th
is); |
| 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 |
87 bool InsertionPoint::isActive() const | 98 bool InsertionPoint::isActive() const |
88 { | 99 { |
89 if (!containingShadowRoot()) | 100 if (!containingShadowRoot()) |
90 return false; | 101 return false; |
91 const Node* node = parentNode(); | 102 const Node* node = parentNode(); |
92 while (node) { | 103 while (node) { |
93 if (node->isInsertionPoint()) | 104 if (node->isInsertionPoint()) |
94 return false; | 105 return false; |
95 | 106 |
96 node = node->parentNode(); | 107 node = node->parentNode(); |
97 } | 108 } |
98 return true; | 109 return true; |
99 } | 110 } |
100 | 111 |
101 PassRefPtr<NodeList> InsertionPoint::getDistributedNodes() const | 112 PassRefPtr<NodeList> InsertionPoint::getDistributedNodes() const |
102 { | 113 { |
103 if (ShadowRoot* shadowRoot = containingShadowRoot()) | 114 if (ShadowRoot* shadowRoot = containingShadowRoot()) |
104 ContentDistributor::ensureDistribution(shadowRoot); | 115 shadowRoot->host()->ensureDistribution(); |
105 | 116 |
106 Vector<RefPtr<Node> > nodes; | 117 Vector<RefPtr<Node> > nodes; |
107 | 118 |
108 for (size_t i = 0; i < m_distribution.size(); ++i) | 119 for (size_t i = 0; i < m_distribution.size(); ++i) |
109 nodes.append(m_distribution.at(i)); | 120 nodes.append(m_distribution.at(i)); |
110 | 121 |
111 return StaticNodeList::adopt(nodes); | 122 return StaticNodeList::adopt(nodes); |
112 } | 123 } |
113 | 124 |
114 bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context) | 125 bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context) |
(...skipping 84 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 shadow->host()->ensureDistribution(); |
209 if (ShadowRoot* root = current->containingShadowRoot()) | 221 if (ShadowRoot* root = current->containingShadowRoot()) |
210 ContentDistributor::ensureDistribution(root); | 222 root->host()->ensureDistribution(); |
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)) { |
219 if (InsertionPoint* insertedTo = parent->isShadowRoot() ? ScopeConte
ntDistribution::assignedTo(toShadowRoot(parent)) : 0) { | 231 if (InsertionPoint* insertedTo = parent->isShadowRoot() ? ScopeConte
ntDistribution::assignedTo(toShadowRoot(parent)) : 0) { |
220 current = insertedTo; | 232 current = insertedTo; |
221 insertionPoint = insertedTo; | 233 insertionPoint = insertedTo; |
222 continue; | 234 continue; |
223 } | 235 } |
224 } | 236 } |
225 | 237 |
226 break; | 238 break; |
227 } | 239 } |
228 | 240 |
229 return insertionPoint; | 241 return insertionPoint; |
230 } | 242 } |
231 | 243 |
232 void collectInsertionPointsWhereNodeIsDistributed(const Node* node, Vector<Inser
tionPoint*, 8>& results) | 244 void collectInsertionPointsWhereNodeIsDistributed(const Node* node, Vector<Inser
tionPoint*, 8>& results) |
233 { | 245 { |
234 const Node* current = node; | 246 const Node* current = node; |
235 while (true) { | 247 while (true) { |
236 if (ElementShadow* shadow = shadowOfParentForDistribution(current)) { | 248 if (ElementShadow* shadow = shadowOfParentForDistribution(current)) { |
237 if (ShadowRoot* root = current->containingShadowRoot()) | 249 if (ShadowRoot* root = current->containingShadowRoot()) |
238 ContentDistributor::ensureDistribution(root); | 250 root->host()->ensureDistribution(); |
239 if (InsertionPoint* insertedTo = shadow->distributor().findInsertion
PointFor(node)) { | 251 if (InsertionPoint* insertedTo = shadow->distributor().findInsertion
PointFor(node)) { |
240 current = insertedTo; | 252 current = insertedTo; |
241 results.append(insertedTo); | 253 results.append(insertedTo); |
242 continue; | 254 continue; |
243 } | 255 } |
244 } | 256 } |
245 if (Node* parent = parentNodeForDistribution(current)) { | 257 if (Node* parent = parentNodeForDistribution(current)) { |
246 if (InsertionPoint* insertedTo = parent->isShadowRoot() ? ScopeConte
ntDistribution::assignedTo(toShadowRoot(parent)) : 0) { | 258 if (InsertionPoint* insertedTo = parent->isShadowRoot() ? ScopeConte
ntDistribution::assignedTo(toShadowRoot(parent)) : 0) { |
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 |