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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 // Note that we may get invoked for some random elements in some wacky cases
during style resolve. | 367 // Note that we may get invoked for some random elements in some wacky cases
during style resolve. |
368 // Pause maintaining the stack in this case. | 368 // Pause maintaining the stack in this case. |
369 if (m_selectorFilter.parentStackIsConsistent(&parent)) | 369 if (m_selectorFilter.parentStackIsConsistent(&parent)) |
370 m_selectorFilter.popParent(); | 370 m_selectorFilter.popParent(); |
371 } | 371 } |
372 | 372 |
373 StyleResolver::~StyleResolver() | 373 StyleResolver::~StyleResolver() |
374 { | 374 { |
375 } | 375 } |
376 | 376 |
377 static inline bool applyAuthorStylesOf(const Element* element) | |
378 { | |
379 return element->treeScope().applyAuthorStyles(); | |
380 } | |
381 | |
382 void StyleResolver::matchAuthorRulesForShadowHost(Element* element, ElementRuleC
ollector& collector, bool includeEmptyRules, WillBeHeapVector<RawPtrWillBeMember
<ScopedStyleResolver>, 8>& resolvers, WillBeHeapVector<RawPtrWillBeMember<Scoped
StyleResolver>, 8>& resolversInShadowTree) | 377 void StyleResolver::matchAuthorRulesForShadowHost(Element* element, ElementRuleC
ollector& collector, bool includeEmptyRules, WillBeHeapVector<RawPtrWillBeMember
<ScopedStyleResolver>, 8>& resolvers, WillBeHeapVector<RawPtrWillBeMember<Scoped
StyleResolver>, 8>& resolversInShadowTree) |
383 { | 378 { |
384 collector.clearMatchedRules(); | 379 collector.clearMatchedRules(); |
385 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; | 380 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; |
386 | 381 |
387 CascadeScope cascadeScope = 0; | 382 CascadeScope cascadeScope = 0; |
388 CascadeOrder cascadeOrder = 0; | 383 CascadeOrder cascadeOrder = 0; |
389 bool applyAuthorStyles = applyAuthorStylesOf(element); | 384 bool isInShadowTree = element->isInShadowTree(); |
390 | 385 |
391 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) | 386 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) |
392 resolversInShadowTree.at(j)->collectMatchingAuthorRules(collector, inclu
deEmptyRules, applyAuthorStyles, cascadeScope, cascadeOrder++); | 387 resolversInShadowTree.at(j)->collectMatchingAuthorRules(collector, inclu
deEmptyRules, isInShadowTree, cascadeScope, cascadeOrder++); |
393 | 388 |
394 if (resolvers.isEmpty() || resolvers.first()->treeScope() != element->treeSc
ope()) | 389 if (resolvers.isEmpty() || resolvers.first()->treeScope() != element->treeSc
ope()) |
395 ++cascadeScope; | 390 ++cascadeScope; |
396 cascadeOrder += resolvers.size(); | 391 cascadeOrder += resolvers.size(); |
397 for (unsigned i = 0; i < resolvers.size(); ++i) | 392 for (unsigned i = 0; i < resolvers.size(); ++i) |
398 resolvers.at(i)->collectMatchingAuthorRules(collector, includeEmptyRules
, applyAuthorStyles, cascadeScope++, --cascadeOrder); | 393 resolvers.at(i)->collectMatchingAuthorRules(collector, includeEmptyRules
, isInShadowTree, cascadeScope++, --cascadeOrder); |
399 | 394 |
400 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collec
tor, includeEmptyRules); | 395 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collec
tor, includeEmptyRules); |
401 collector.sortAndTransferMatchedRules(); | 396 collector.sortAndTransferMatchedRules(); |
402 } | 397 } |
403 | 398 |
404 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector, bool includeEmptyRules) | 399 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector, bool includeEmptyRules) |
405 { | 400 { |
406 collector.clearMatchedRules(); | 401 collector.clearMatchedRules(); |
407 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; | 402 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; |
408 | 403 |
409 bool applyAuthorStyles = applyAuthorStylesOf(element); | 404 bool isInShadowTree = element->isInShadowTree(); |
410 if (document().styleEngine()->hasOnlyScopedResolverForDocument()) { | 405 if (document().styleEngine()->hasOnlyScopedResolverForDocument()) { |
411 document().scopedStyleResolver()->collectMatchingAuthorRules(collector,
includeEmptyRules, applyAuthorStyles, ignoreCascadeScope); | 406 document().scopedStyleResolver()->collectMatchingAuthorRules(collector,
includeEmptyRules, isInShadowTree, ignoreCascadeScope); |
412 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, co
llector, includeEmptyRules); | 407 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, co
llector, includeEmptyRules); |
413 collector.sortAndTransferMatchedRules(); | 408 collector.sortAndTransferMatchedRules(); |
414 return; | 409 return; |
415 } | 410 } |
416 | 411 |
417 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers; | 412 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers; |
418 resolveScopedStyles(element, resolvers); | 413 resolveScopedStyles(element, resolvers); |
419 | 414 |
420 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolversInShad
owTree; | 415 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolversInShad
owTree; |
421 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); | 416 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); |
422 if (!resolversInShadowTree.isEmpty()) { | 417 if (!resolversInShadowTree.isEmpty()) { |
423 matchAuthorRulesForShadowHost(element, collector, includeEmptyRules, res
olvers, resolversInShadowTree); | 418 matchAuthorRulesForShadowHost(element, collector, includeEmptyRules, res
olvers, resolversInShadowTree); |
424 return; | 419 return; |
425 } | 420 } |
426 | 421 |
427 if (resolvers.isEmpty()) | 422 if (resolvers.isEmpty()) |
428 return; | 423 return; |
429 | 424 |
430 CascadeScope cascadeScope = 0; | 425 CascadeScope cascadeScope = 0; |
431 CascadeOrder cascadeOrder = resolvers.size(); | 426 CascadeOrder cascadeOrder = resolvers.size(); |
432 for (unsigned i = 0; i < resolvers.size(); ++i, --cascadeOrder) { | 427 for (unsigned i = 0; i < resolvers.size(); ++i, --cascadeOrder) { |
433 ScopedStyleResolver* resolver = resolvers.at(i); | 428 ScopedStyleResolver* resolver = resolvers.at(i); |
434 // FIXME: Need to clarify how to treat style scoped. | 429 // FIXME: Need to clarify how to treat style scoped. |
435 resolver->collectMatchingAuthorRules(collector, includeEmptyRules, apply
AuthorStyles, cascadeScope++, resolver->treeScope() == element->treeScope() && r
esolver->treeScope().rootNode().isShadowRoot() ? 0 : cascadeOrder); | 430 resolver->collectMatchingAuthorRules(collector, includeEmptyRules, isInS
hadowTree, cascadeScope++, resolver->treeScope() == element->treeScope() && reso
lver->treeScope().rootNode().isShadowRoot() ? 0 : cascadeOrder); |
436 } | 431 } |
437 | 432 |
438 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collec
tor, includeEmptyRules); | 433 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collec
tor, includeEmptyRules); |
439 collector.sortAndTransferMatchedRules(); | 434 collector.sortAndTransferMatchedRules(); |
440 } | 435 } |
441 | 436 |
442 void StyleResolver::matchUARules(ElementRuleCollector& collector) | 437 void StyleResolver::matchUARules(ElementRuleCollector& collector) |
443 { | 438 { |
444 collector.setMatchingUARules(true); | 439 collector.setMatchingUARules(true); |
445 | 440 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shad
owRoot = shadowRoot->olderShadowRoot()) { | 1026 for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shad
owRoot = shadowRoot->olderShadowRoot()) { |
1032 if (shadowRoot->numberOfStyles() > 0) { | 1027 if (shadowRoot->numberOfStyles() > 0) { |
1033 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) | 1028 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) |
1034 resolvers.append(resolver); | 1029 resolvers.append(resolver); |
1035 } | 1030 } |
1036 } | 1031 } |
1037 } | 1032 } |
1038 | 1033 |
1039 void StyleResolver::styleTreeResolveScopedKeyframesRules(const Element* element,
WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) | 1034 void StyleResolver::styleTreeResolveScopedKeyframesRules(const Element* element,
WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) |
1040 { | 1035 { |
1041 Document& document = element->document(); | |
1042 TreeScope& treeScope = element->treeScope(); | 1036 TreeScope& treeScope = element->treeScope(); |
1043 bool applyAuthorStyles = treeScope.applyAuthorStyles(); | |
1044 | 1037 |
1045 // Add resolvers for shadow roots hosted by the given element. | 1038 // Add resolvers for shadow roots hosted by the given element. |
1046 collectScopedResolversForHostedShadowTrees(element, resolvers); | 1039 collectScopedResolversForHostedShadowTrees(element, resolvers); |
1047 | 1040 |
1048 // Add resolvers while walking up DOM tree from the given element. | 1041 // Add resolvers while walking up DOM tree from the given element. |
1049 for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scope
dResolver; scopedResolver = scopedResolver->parent()) { | 1042 for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scope
dResolver; scopedResolver = scopedResolver->parent()) { |
1050 if (scopedResolver->treeScope() == treeScope || (applyAuthorStyles && sc
opedResolver->treeScope() == document)) | 1043 if (scopedResolver->treeScope() == treeScope) |
1051 resolvers.append(scopedResolver); | 1044 resolvers.append(scopedResolver); |
1052 } | 1045 } |
1053 } | 1046 } |
1054 | 1047 |
1055 template <StyleResolver::StyleApplicationPass pass> | 1048 template <StyleResolver::StyleApplicationPass pass> |
1056 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil
lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo
lations) | 1049 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil
lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo
lations) |
1057 { | 1050 { |
1058 for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >::c
onst_iterator iter = activeInterpolations.begin(); iter != activeInterpolations.
end(); ++iter) { | 1051 for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >::c
onst_iterator iter = activeInterpolations.begin(); iter != activeInterpolations.
end(); ++iter) { |
1059 CSSPropertyID property = iter->key; | 1052 CSSPropertyID property = iter->key; |
1060 if (!isPropertyForPass<pass>(property)) | 1053 if (!isPropertyForPass<pass>(property)) |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 visitor->trace(m_uncommonAttributeRuleSet); | 1585 visitor->trace(m_uncommonAttributeRuleSet); |
1593 visitor->trace(m_watchedSelectorsRules); | 1586 visitor->trace(m_watchedSelectorsRules); |
1594 visitor->trace(m_treeBoundaryCrossingRules); | 1587 visitor->trace(m_treeBoundaryCrossingRules); |
1595 visitor->trace(m_styleSharingLists); | 1588 visitor->trace(m_styleSharingLists); |
1596 visitor->trace(m_pendingStyleSheets); | 1589 visitor->trace(m_pendingStyleSheets); |
1597 visitor->trace(m_document); | 1590 visitor->trace(m_document); |
1598 #endif | 1591 #endif |
1599 } | 1592 } |
1600 | 1593 |
1601 } // namespace blink | 1594 } // namespace blink |
OLD | NEW |