OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 if (document().renderer() && document().renderer()->style()) | 178 if (document().renderer() && document().renderer()->style()) |
179 document().renderer()->style()->font().update(fontSelector()); | 179 document().renderer()->style()->font().update(fontSelector()); |
180 | 180 |
181 if (RuntimeEnabledFeatures::cssViewportEnabled()) | 181 if (RuntimeEnabledFeatures::cssViewportEnabled()) |
182 collectViewportRules(); | 182 collectViewportRules(); |
183 } | 183 } |
184 | 184 |
185 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) | 185 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) |
186 { | 186 { |
187 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.scopedStyleResolve
rFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); | 187 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.scopedStyleResolve
rFor(*scopingNode) : m_styleTree.scopedStyleResolverForDocument(); |
188 if (!resolver) | 188 if (!resolver) |
189 return; | 189 return; |
190 | 190 |
191 m_ruleSets.shadowDistributedRules().reset(scopingNode); | 191 m_ruleSets.shadowDistributedRules().reset(scopingNode); |
192 | 192 |
193 resolver->resetAuthorStyle(); | 193 resolver->resetAuthorStyle(); |
194 if (!scopingNode) | 194 if (!scopingNode) |
195 return; | 195 return; |
196 | 196 |
197 if (scopingNode->isShadowRoot()) | 197 if (scopingNode->isShadowRoot()) |
198 resetAtHostRules(scopingNode); | 198 resetAtHostRules(scopingNode); |
199 | 199 |
200 if (!resolver->hasOnlyEmptyRuleSets()) | 200 if (!resolver->hasOnlyEmptyRuleSets()) |
201 return; | 201 return; |
202 | 202 |
203 m_styleTree.remove(scopingNode); | 203 m_styleTree.remove(scopingNode); |
204 } | 204 } |
205 | 205 |
206 void StyleResolver::resetAtHostRules(const ContainerNode* scopingNode) | 206 void StyleResolver::resetAtHostRules(const ContainerNode* scopingNode) |
207 { | 207 { |
208 ASSERT(scopingNode); | 208 ASSERT(scopingNode); |
209 ASSERT(scopingNode->isShadowRoot()); | 209 ASSERT(scopingNode->isShadowRoot()); |
210 | 210 |
211 const ShadowRoot* shadowRoot = toShadowRoot(scopingNode); | 211 const ShadowRoot* shadowRoot = toShadowRoot(scopingNode); |
212 const ContainerNode* shadowHost = shadowRoot->shadowHost(); | 212 const ContainerNode* shadowHost = shadowRoot->shadowHost(); |
213 ScopedStyleResolver* resolver = m_styleTree.scopedStyleResolverFor(shadowHos
t); | 213 ASSERT(shadowHost); |
| 214 ScopedStyleResolver* resolver = m_styleTree.scopedStyleResolverFor(*shadowHo
st); |
214 if (!resolver) | 215 if (!resolver) |
215 return; | 216 return; |
216 | 217 |
217 resolver->resetAtHostRules(shadowRoot); | 218 resolver->resetAtHostRules(shadowRoot); |
218 if (!resolver->hasOnlyEmptyRuleSets()) | 219 if (!resolver->hasOnlyEmptyRuleSets()) |
219 return; | 220 return; |
220 | 221 |
221 m_styleTree.remove(shadowHost); | 222 m_styleTree.remove(shadowHost); |
222 } | 223 } |
223 | 224 |
(...skipping 13 matching lines...) Expand all Loading... |
237 m_features.clear(); | 238 m_features.clear(); |
238 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource()); | 239 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource()); |
239 m_styleTree.collectFeaturesTo(m_features); | 240 m_styleTree.collectFeaturesTo(m_features); |
240 | 241 |
241 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); | 242 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |
242 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); | 243 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |
243 } | 244 } |
244 | 245 |
245 void StyleResolver::pushParentElement(Element* parent) | 246 void StyleResolver::pushParentElement(Element* parent) |
246 { | 247 { |
| 248 ASSERT(parent); |
247 const ContainerNode* parentsParent = parent->parentOrShadowHostElement(); | 249 const ContainerNode* parentsParent = parent->parentOrShadowHostElement(); |
248 | 250 |
249 // We are not always invoked consistently. For example, script execution can
cause us to enter | 251 // We are not always invoked consistently. For example, script execution can
cause us to enter |
250 // style recalc in the middle of tree building. We may also be invoked from
somewhere within the tree. | 252 // style recalc in the middle of tree building. We may also be invoked from
somewhere within the tree. |
251 // Reset the stack in this case, or if we see a new root element. | 253 // Reset the stack in this case, or if we see a new root element. |
252 // Otherwise just push the new parent. | 254 // Otherwise just push the new parent. |
253 if (!parentsParent || m_selectorFilter.parentStackIsEmpty()) | 255 if (!parentsParent || m_selectorFilter.parentStackIsEmpty()) |
254 m_selectorFilter.setupParentStack(parent); | 256 m_selectorFilter.setupParentStack(parent); |
255 else | 257 else |
256 m_selectorFilter.pushParent(parent); | 258 m_selectorFilter.pushParent(parent); |
257 | 259 |
258 // Note: We mustn't skip ShadowRoot nodes for the scope stack. | 260 // Note: We mustn't skip ShadowRoot nodes for the scope stack. |
259 m_styleTree.pushStyleCache(parent, parent->parentOrShadowHostNode()); | 261 m_styleTree.pushStyleCache(*parent, parent->parentOrShadowHostNode()); |
260 } | 262 } |
261 | 263 |
262 void StyleResolver::popParentElement(Element* parent) | 264 void StyleResolver::popParentElement(Element* parent) |
263 { | 265 { |
| 266 ASSERT(parent); |
264 // Note that we may get invoked for some random elements in some wacky cases
during style resolve. | 267 // Note that we may get invoked for some random elements in some wacky cases
during style resolve. |
265 // Pause maintaining the stack in this case. | 268 // Pause maintaining the stack in this case. |
266 if (m_selectorFilter.parentStackIsConsistent(parent)) | 269 if (m_selectorFilter.parentStackIsConsistent(parent)) |
267 m_selectorFilter.popParent(); | 270 m_selectorFilter.popParent(); |
268 | 271 |
269 m_styleTree.popStyleCache(parent); | 272 m_styleTree.popStyleCache(*parent); |
270 } | 273 } |
271 | 274 |
272 void StyleResolver::pushParentShadowRoot(const ShadowRoot* shadowRoot) | 275 void StyleResolver::pushParentShadowRoot(const ShadowRoot& shadowRoot) |
273 { | 276 { |
274 ASSERT(shadowRoot->host()); | 277 ASSERT(shadowRoot.host()); |
275 m_styleTree.pushStyleCache(shadowRoot, shadowRoot->host()); | 278 m_styleTree.pushStyleCache(shadowRoot, shadowRoot.host()); |
276 } | 279 } |
277 | 280 |
278 void StyleResolver::popParentShadowRoot(const ShadowRoot* shadowRoot) | 281 void StyleResolver::popParentShadowRoot(const ShadowRoot& shadowRoot) |
279 { | 282 { |
280 ASSERT(shadowRoot->host()); | 283 ASSERT(shadowRoot.host()); |
281 m_styleTree.popStyleCache(shadowRoot); | 284 m_styleTree.popStyleCache(shadowRoot); |
282 } | 285 } |
283 | 286 |
284 StyleResolver::~StyleResolver() | 287 StyleResolver::~StyleResolver() |
285 { | 288 { |
286 m_fontSelector->clearDocument(); | 289 m_fontSelector->clearDocument(); |
287 m_viewportStyleResolver->clearDocument(); | 290 m_viewportStyleResolver->clearDocument(); |
288 } | 291 } |
289 | 292 |
290 inline void StyleResolver::matchShadowDistributedRules(ElementRuleCollector& col
lector, bool includeEmptyRules) | 293 inline void StyleResolver::matchShadowDistributedRules(ElementRuleCollector& col
lector, bool includeEmptyRules) |
(...skipping 18 matching lines...) Expand all Loading... |
309 for (size_t i = 0; i < matchRequests.size(); ++i) | 312 for (size_t i = 0; i < matchRequests.size(); ++i) |
310 collector.collectMatchingRules(matchRequests[i], ruleRange, cascadeScope
); | 313 collector.collectMatchingRules(matchRequests[i], ruleRange, cascadeScope
); |
311 collector.sortAndTransferMatchedRules(); | 314 collector.sortAndTransferMatchedRules(); |
312 | 315 |
313 collector.setBehaviorAtBoundary(previousBoundary); | 316 collector.setBehaviorAtBoundary(previousBoundary); |
314 collector.setCanUseFastReject(previousCanUseFastReject); | 317 collector.setCanUseFastReject(previousCanUseFastReject); |
315 } | 318 } |
316 | 319 |
317 void StyleResolver::matchHostRules(Element* element, ScopedStyleResolver* resolv
er, ElementRuleCollector& collector, bool includeEmptyRules) | 320 void StyleResolver::matchHostRules(Element* element, ScopedStyleResolver* resolv
er, ElementRuleCollector& collector, bool includeEmptyRules) |
318 { | 321 { |
319 if (element != resolver->scopingNode()) | 322 if (element != &resolver->scopingNode()) |
320 return; | 323 return; |
321 resolver->matchHostRules(collector, includeEmptyRules); | 324 resolver->matchHostRules(collector, includeEmptyRules); |
322 } | 325 } |
323 | 326 |
324 static inline bool applyAuthorStylesOf(const Element* element) | 327 static inline bool applyAuthorStylesOf(const Element* element) |
325 { | 328 { |
326 return element->treeScope()->applyAuthorStyles() || (element->shadow() && el
ement->shadow()->applyAuthorStyles()); | 329 return element->treeScope()->applyAuthorStyles() || (element->shadow() && el
ement->shadow()->applyAuthorStyles()); |
327 } | 330 } |
328 | 331 |
329 void StyleResolver::matchScopedAuthorRulesForShadowHost(Element* element, Elemen
tRuleCollector& collector, bool includeEmptyRules, Vector<ScopedStyleResolver*,
8>& resolvers, Vector<ScopedStyleResolver*, 8>& resolversInShadowTree) | 332 void StyleResolver::matchScopedAuthorRulesForShadowHost(Element* element, Elemen
tRuleCollector& collector, bool includeEmptyRules, Vector<ScopedStyleResolver*,
8>& resolvers, Vector<ScopedStyleResolver*, 8>& resolversInShadowTree) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 375 |
373 bool applyAuthorStyles = applyAuthorStylesOf(element); | 376 bool applyAuthorStyles = applyAuthorStylesOf(element); |
374 CascadeScope cascadeScope = 0; | 377 CascadeScope cascadeScope = 0; |
375 CascadeOrder cascadeOrder = resolvers.size(); | 378 CascadeOrder cascadeOrder = resolvers.size(); |
376 collector.clearMatchedRules(); | 379 collector.clearMatchedRules(); |
377 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; | 380 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; |
378 | 381 |
379 for (unsigned i = 0; i < resolvers.size(); ++i, --cascadeOrder) { | 382 for (unsigned i = 0; i < resolvers.size(); ++i, --cascadeOrder) { |
380 ScopedStyleResolver* resolver = resolvers.at(i); | 383 ScopedStyleResolver* resolver = resolvers.at(i); |
381 // FIXME: Need to clarify how to treat style scoped. | 384 // FIXME: Need to clarify how to treat style scoped. |
382 resolver->collectMatchingAuthorRules(collector, includeEmptyRules, apply
AuthorStyles, cascadeScope++, resolver->treeScope() == element->treeScope() && r
esolver->scopingNode()->isShadowRoot() ? 0 : cascadeOrder); | 385 resolver->collectMatchingAuthorRules(collector, includeEmptyRules, apply
AuthorStyles, cascadeScope++, resolver->treeScope() == element->treeScope() && r
esolver->scopingNode().isShadowRoot() ? 0 : cascadeOrder); |
383 } | 386 } |
384 | 387 |
385 collector.sortAndTransferMatchedRules(); | 388 collector.sortAndTransferMatchedRules(); |
386 | 389 |
387 matchHostRules(element, resolvers.first(), collector, includeEmptyRules); | 390 matchHostRules(element, resolvers.first(), collector, includeEmptyRules); |
388 } | 391 } |
389 | 392 |
390 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector, bool includeEmptyRules) | 393 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector, bool includeEmptyRules) |
391 { | 394 { |
392 matchScopedAuthorRules(element, collector, includeEmptyRules); | 395 matchScopedAuthorRules(element, collector, includeEmptyRules); |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties
SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa
che); | 1553 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties
SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa
che); |
1551 | 1554 |
1552 fprintf(stderr, "Total:\n"); | 1555 fprintf(stderr, "Total:\n"); |
1553 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS
tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, | 1556 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS
tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, |
1554 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa
tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch
edPropertiesEnteredIntoCache); | 1557 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa
tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch
edPropertiesEnteredIntoCache); |
1555 fprintf(stderr, "-----------------------------------------------------------
---------------------\n"); | 1558 fprintf(stderr, "-----------------------------------------------------------
---------------------\n"); |
1556 } | 1559 } |
1557 #endif | 1560 #endif |
1558 | 1561 |
1559 } // namespace WebCore | 1562 } // namespace WebCore |
OLD | NEW |