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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 397 |
398 StyleResolver::~StyleResolver() | 398 StyleResolver::~StyleResolver() |
399 { | 399 { |
400 } | 400 } |
401 | 401 |
402 inline void StyleResolver::collectTreeBoundaryCrossingRules(Element* element, El
ementRuleCollector& collector, bool includeEmptyRules) | 402 inline void StyleResolver::collectTreeBoundaryCrossingRules(Element* element, El
ementRuleCollector& collector, bool includeEmptyRules) |
403 { | 403 { |
404 if (m_treeBoundaryCrossingRules.isEmpty()) | 404 if (m_treeBoundaryCrossingRules.isEmpty()) |
405 return; | 405 return; |
406 | 406 |
407 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); | |
408 | |
409 // When comparing rules declared in outer treescopes, outer's rules win. | 407 // When comparing rules declared in outer treescopes, outer's rules win. |
410 CascadeOrder outerCascadeOrder = m_treeBoundaryCrossingRules.size() + m_tree
BoundaryCrossingRules.size(); | 408 CascadeOrder outerCascadeOrder = m_treeBoundaryCrossingRules.size() + m_tree
BoundaryCrossingRules.size(); |
411 // When comparing rules declared in inner treescopes, inner's rules win. | 409 // When comparing rules declared in inner treescopes, inner's rules win. |
412 CascadeOrder innerCascadeOrder = m_treeBoundaryCrossingRules.size(); | 410 CascadeOrder innerCascadeOrder = m_treeBoundaryCrossingRules.size(); |
413 | 411 |
414 for (DocumentOrderedList::iterator it = m_treeBoundaryCrossingRules.begin();
it != m_treeBoundaryCrossingRules.end(); ++it) { | 412 for (DocumentOrderedList::iterator it = m_treeBoundaryCrossingRules.begin();
it != m_treeBoundaryCrossingRules.end(); ++it) { |
415 const ContainerNode* scopingNode = toContainerNode(*it); | 413 const ContainerNode* scopingNode = toContainerNode(*it); |
416 RuleSet* ruleSet = m_treeBoundaryCrossingRules.ruleSetScopedBy(scopingNo
de); | 414 RuleSet* ruleSet = m_treeBoundaryCrossingRules.ruleSetScopedBy(scopingNo
de); |
417 unsigned boundaryBehavior = SelectorChecker::ScopeContainsLastMatchedEle
ment; | 415 unsigned boundaryBehavior = SelectorChecker::ScopeContainsLastMatchedEle
ment; |
418 bool isInnerTreeScope = element->treeScope().isInclusiveAncestorOf(scopi
ngNode->treeScope()); | 416 bool isInnerTreeScope = element->treeScope().isInclusiveAncestorOf(scopi
ngNode->treeScope()); |
419 | 417 |
420 // If a given scoping node is a shadow root and a given element is in a
descendant tree of tree hosted by | 418 // If a given scoping node is a shadow root and a given element is in a
descendant tree of tree hosted by |
421 // the scoping node's shadow host, we should use ScopeIsShadowHost. | 419 // the scoping node's shadow host, we should use ScopeIsShadowHost. |
422 if (scopingNode && scopingNode->isShadowRoot()) { | 420 if (scopingNode && scopingNode->isShadowRoot()) { |
423 if (element->isInDescendantTreeOf(toShadowRoot(scopingNode)->host())
) | 421 if (element->isInDescendantTreeOf(toShadowRoot(scopingNode)->host())
) |
424 boundaryBehavior |= SelectorChecker::ScopeIsShadowHost; | 422 boundaryBehavior |= SelectorChecker::ScopeIsShadowHost; |
425 scopingNode = toShadowRoot(scopingNode)->host(); | 423 scopingNode = toShadowRoot(scopingNode)->host(); |
426 } | 424 } |
427 | 425 |
428 CascadeOrder cascadeOrder = isInnerTreeScope ? innerCascadeOrder : outer
CascadeOrder; | 426 CascadeOrder cascadeOrder = isInnerTreeScope ? innerCascadeOrder : outer
CascadeOrder; |
429 | 427 collector.collectMatchingRules(MatchRequest(ruleSet, includeEmptyRules,
scopingNode), collector.matchedResult().ranges.authorRuleRange(), static_cast<Se
lectorChecker::BehaviorAtBoundary>(boundaryBehavior), ignoreCascadeScope, cascad
eOrder); |
430 collector.collectMatchingRules(MatchRequest(ruleSet, includeEmptyRules,
scopingNode), ruleRange, static_cast<SelectorChecker::BehaviorAtBoundary>(bounda
ryBehavior), ignoreCascadeScope, cascadeOrder); | |
431 ++innerCascadeOrder; | 428 ++innerCascadeOrder; |
432 --outerCascadeOrder; | 429 --outerCascadeOrder; |
433 } | 430 } |
434 } | 431 } |
435 | 432 |
436 static inline bool applyAuthorStylesOf(const Element* element) | 433 static inline bool applyAuthorStylesOf(const Element* element) |
437 { | 434 { |
438 return element->treeScope().applyAuthorStyles() || (element->shadow() && ele
ment->shadow()->applyAuthorStyles()); | 435 return element->treeScope().applyAuthorStyles() || (element->shadow() && ele
ment->shadow()->applyAuthorStyles()); |
439 } | 436 } |
440 | 437 |
441 void StyleResolver::matchAuthorRulesForShadowHost(Element* element, ElementRuleC
ollector& collector, bool includeEmptyRules, Vector<ScopedStyleResolver*, 8>& re
solvers, Vector<ScopedStyleResolver*, 8>& resolversInShadowTree) | 438 void StyleResolver::matchAuthorRulesForShadowHost(Element* element, ElementRuleC
ollector& collector, bool includeEmptyRules, Vector<ScopedStyleResolver*, 8>& re
solvers, Vector<ScopedStyleResolver*, 8>& resolversInShadowTree) |
442 { | 439 { |
443 collector.clearMatchedRules(); | 440 collector.clearMatchedRules(); |
444 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; | 441 collector.matchedResult().ranges.authorRuleRange().setLast(collector.matched
Result().matchedProperties.size() - 1); |
445 | 442 |
446 CascadeScope cascadeScope = 0; | 443 CascadeScope cascadeScope = 0; |
447 CascadeOrder cascadeOrder = 0; | 444 CascadeOrder cascadeOrder = 0; |
448 bool applyAuthorStyles = applyAuthorStylesOf(element); | 445 bool applyAuthorStyles = applyAuthorStylesOf(element); |
449 | 446 |
450 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) | 447 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) |
451 resolversInShadowTree.at(j)->collectMatchingAuthorRules(collector, inclu
deEmptyRules, applyAuthorStyles, cascadeScope, cascadeOrder++); | 448 resolversInShadowTree.at(j)->collectMatchingAuthorRules(collector, inclu
deEmptyRules, applyAuthorStyles, cascadeScope, cascadeOrder++); |
452 | 449 |
453 if (resolvers.isEmpty() || resolvers.first()->treeScope() != element->treeSc
ope()) | 450 if (resolvers.isEmpty() || resolvers.first()->treeScope() != element->treeSc
ope()) |
454 ++cascadeScope; | 451 ++cascadeScope; |
455 cascadeOrder += resolvers.size(); | 452 cascadeOrder += resolvers.size(); |
456 for (unsigned i = 0; i < resolvers.size(); ++i) | 453 for (unsigned i = 0; i < resolvers.size(); ++i) |
457 resolvers.at(i)->collectMatchingAuthorRules(collector, includeEmptyRules
, applyAuthorStyles, cascadeScope++, --cascadeOrder); | 454 resolvers.at(i)->collectMatchingAuthorRules(collector, includeEmptyRules
, applyAuthorStyles, cascadeScope++, --cascadeOrder); |
458 | 455 |
459 collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); | 456 collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); |
460 collector.sortAndTransferMatchedRules(); | 457 collector.sortAndTransferMatchedRules(); |
461 } | 458 } |
462 | 459 |
463 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector, bool includeEmptyRules) | 460 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector, bool includeEmptyRules) |
464 { | 461 { |
465 collector.clearMatchedRules(); | 462 collector.clearMatchedRules(); |
466 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; | 463 collector.matchedResult().ranges.authorRuleRange().setLast(collector.matched
Result().matchedProperties.size() - 1); |
467 | 464 |
468 bool applyAuthorStyles = applyAuthorStylesOf(element); | 465 bool applyAuthorStyles = applyAuthorStylesOf(element); |
469 if (m_styleTree.hasOnlyScopedResolverForDocument()) { | 466 if (m_styleTree.hasOnlyScopedResolverForDocument()) { |
470 m_styleTree.scopedStyleResolverForDocument()->collectMatchingAuthorRules
(collector, includeEmptyRules, applyAuthorStyles, ignoreCascadeScope); | 467 m_styleTree.scopedStyleResolverForDocument()->collectMatchingAuthorRules
(collector, includeEmptyRules, applyAuthorStyles, ignoreCascadeScope); |
471 collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); | 468 collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); |
472 collector.sortAndTransferMatchedRules(); | 469 collector.sortAndTransferMatchedRules(); |
473 return; | 470 return; |
474 } | 471 } |
475 | 472 |
476 Vector<ScopedStyleResolver*, 8> resolvers; | 473 Vector<ScopedStyleResolver*, 8> resolvers; |
(...skipping 20 matching lines...) Expand all Loading... |
497 collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); | 494 collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); |
498 collector.sortAndTransferMatchedRules(); | 495 collector.sortAndTransferMatchedRules(); |
499 } | 496 } |
500 | 497 |
501 void StyleResolver::matchWatchSelectorRules(ElementRuleCollector& collector) | 498 void StyleResolver::matchWatchSelectorRules(ElementRuleCollector& collector) |
502 { | 499 { |
503 if (!m_watchedSelectorsRules) | 500 if (!m_watchedSelectorsRules) |
504 return; | 501 return; |
505 | 502 |
506 collector.clearMatchedRules(); | 503 collector.clearMatchedRules(); |
507 collector.matchedResult().ranges.lastUserRule = collector.matchedResult().ma
tchedProperties.size() - 1; | 504 collector.matchedResult().ranges.userRuleRange().setLast(collector.matchedRe
sult().matchedProperties.size() - 1); |
508 | 505 |
509 MatchRequest matchRequest(m_watchedSelectorsRules.get()); | 506 MatchRequest matchRequest(m_watchedSelectorsRules.get()); |
510 RuleRange ruleRange = collector.matchedResult().ranges.userRuleRange(); | 507 collector.collectMatchingRules(matchRequest, collector.matchedResult().range
s.userRuleRange()); |
511 collector.collectMatchingRules(matchRequest, ruleRange); | |
512 | |
513 collector.sortAndTransferMatchedRules(); | 508 collector.sortAndTransferMatchedRules(); |
514 } | 509 } |
515 | 510 |
516 void StyleResolver::matchUARules(ElementRuleCollector& collector) | 511 void StyleResolver::matchUARules(ElementRuleCollector& collector) |
517 { | 512 { |
518 collector.setMatchingUARules(true); | 513 collector.setMatchingUARules(true); |
519 | 514 |
520 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance(
); | 515 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance(
); |
521 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") | 516 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") |
522 ? defaultStyleSheets.defaultPrintStyle() : defaultStyleSheets.defaultSty
le(); | 517 ? defaultStyleSheets.defaultPrintStyle() : defaultStyleSheets.defaultSty
le(); |
523 matchUARules(collector, userAgentStyleSheet); | 518 matchUARules(collector, userAgentStyleSheet); |
524 | 519 |
525 // In quirks mode, we match rules from the quirks user agent sheet. | 520 // In quirks mode, we match rules from the quirks user agent sheet. |
526 if (document().inQuirksMode()) | 521 if (document().inQuirksMode()) |
527 matchUARules(collector, defaultStyleSheets.defaultQuirksStyle()); | 522 matchUARules(collector, defaultStyleSheets.defaultQuirksStyle()); |
528 | 523 |
529 // If document uses view source styles (in view source mode or in xml viewer
mode), then we match rules from the view source style sheet. | 524 // If document uses view source styles (in view source mode or in xml viewer
mode), then we match rules from the view source style sheet. |
530 if (document().isViewSource()) | 525 if (document().isViewSource()) |
531 matchUARules(collector, defaultStyleSheets.defaultViewSourceStyle()); | 526 matchUARules(collector, defaultStyleSheets.defaultViewSourceStyle()); |
532 | 527 |
533 collector.setMatchingUARules(false); | 528 collector.setMatchingUARules(false); |
534 | 529 |
535 matchWatchSelectorRules(collector); | 530 matchWatchSelectorRules(collector); |
536 } | 531 } |
537 | 532 |
538 void StyleResolver::matchUARules(ElementRuleCollector& collector, RuleSet* rules
) | 533 void StyleResolver::matchUARules(ElementRuleCollector& collector, RuleSet* rules
) |
539 { | 534 { |
540 collector.clearMatchedRules(); | 535 collector.clearMatchedRules(); |
541 collector.matchedResult().ranges.lastUARule = collector.matchedResult().matc
hedProperties.size() - 1; | 536 collector.matchedResult().ranges.UARuleRange().setLast(collector.matchedResu
lt().matchedProperties.size() - 1); |
542 | 537 collector.collectMatchingRules(MatchRequest(rules), collector.matchedResult(
).ranges.UARuleRange()); |
543 RuleRange ruleRange = collector.matchedResult().ranges.UARuleRange(); | |
544 collector.collectMatchingRules(MatchRequest(rules), ruleRange); | |
545 | |
546 collector.sortAndTransferMatchedRules(); | 538 collector.sortAndTransferMatchedRules(); |
547 } | 539 } |
548 | 540 |
549 void StyleResolver::matchAllRules(StyleResolverState& state, ElementRuleCollecto
r& collector, bool includeSMILProperties) | 541 void StyleResolver::matchAllRules(StyleResolverState& state, ElementRuleCollecto
r& collector, bool includeSMILProperties) |
550 { | 542 { |
551 matchUARules(collector); | 543 matchUARules(collector); |
552 | 544 |
553 // Now check author rules, beginning first with presentational attributes ma
pped from HTML. | 545 // Now check author rules, beginning first with presentational attributes ma
pped from HTML. |
554 if (state.element()->isStyledElement()) { | 546 if (state.element()->isStyledElement()) { |
555 collector.addElementStyleProperties(state.element()->presentationAttribu
teStyle()); | 547 collector.addElementStyleProperties(state.element()->presentationAttribu
teStyle()); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 ASSERT(animations && !animations->isEmpty()); | 751 ASSERT(animations && !animations->isEmpty()); |
760 while (animations->animation(0)->name() != animationName) | 752 while (animations->animation(0)->name() != animationName) |
761 animations->remove(0); | 753 animations->remove(0); |
762 ASSERT(!animations->isEmpty() && animations->animation(0)->name() == animati
onName); | 754 ASSERT(!animations->isEmpty() && animations->animation(0)->name() == animati
onName); |
763 | 755 |
764 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); | 756 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); |
765 | 757 |
766 // We don't need to bother with !important. Since there is only ever one | 758 // We don't need to bother with !important. Since there is only ever one |
767 // decl, there's nothing to override. So just add the first properties. | 759 // decl, there's nothing to override. So just add the first properties. |
768 bool inheritedOnly = false; | 760 bool inheritedOnly = false; |
769 applyMatchedProperties<AnimationProperties>(state, result, false, 0, result.
matchedProperties.size() - 1, inheritedOnly); | 761 applyMatchedProperties<AnimationProperties>(state, result, false, RuleRange(
0, result.matchedProperties.size() - 1), inheritedOnly); |
770 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); | 762 applyMatchedProperties<HighPriorityProperties>(state, result, false, RuleRan
ge(0, result.matchedProperties.size() - 1), inheritedOnly); |
771 | 763 |
772 // If our font got dirtied, go ahead and update it now. | 764 // If our font got dirtied, go ahead and update it now. |
773 updateFont(state); | 765 updateFont(state); |
774 | 766 |
775 // Line-height is set when we are sure we decided on the font-size | 767 // Line-height is set when we are sure we decided on the font-size |
776 if (state.lineHeightValue()) | 768 if (state.lineHeightValue()) |
777 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | 769 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); |
778 | 770 |
779 // Now do rest of the properties. | 771 // Now do rest of the properties. |
780 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); | 772 applyMatchedProperties<LowPriorityProperties>(state, result, false, RuleRang
e(0, result.matchedProperties.size() - 1), inheritedOnly); |
781 | 773 |
782 // If our font got dirtied by one of the non-essential font props, | 774 // If our font got dirtied by one of the non-essential font props, |
783 // go ahead and update it a second time. | 775 // go ahead and update it a second time. |
784 updateFont(state); | 776 updateFont(state); |
785 | 777 |
786 loadPendingResources(state); | 778 loadPendingResources(state); |
787 | 779 |
788 didAccess(); | 780 didAccess(); |
789 | 781 |
790 return state.takeStyle(); | 782 return state.takeStyle(); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 | 933 |
942 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); | 934 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); |
943 | 935 |
944 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) | 936 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) |
945 scopedResolver->matchPageRules(collector); | 937 scopedResolver->matchPageRules(collector); |
946 | 938 |
947 state.setLineHeightValue(0); | 939 state.setLineHeightValue(0); |
948 bool inheritedOnly = false; | 940 bool inheritedOnly = false; |
949 | 941 |
950 MatchResult& result = collector.matchedResult(); | 942 MatchResult& result = collector.matchedResult(); |
951 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, resu
lt.matchedProperties.size() - 1, inheritedOnly); | 943 applyMatchedProperties<HighPriorityProperties>(state, result, false, RuleRan
ge(0, result.matchedProperties.size() - 1), inheritedOnly); |
952 | 944 |
953 // If our font got dirtied, go ahead and update it now. | 945 // If our font got dirtied, go ahead and update it now. |
954 updateFont(state); | 946 updateFont(state); |
955 | 947 |
956 // Line-height is set when we are sure we decided on the font-size. | 948 // Line-height is set when we are sure we decided on the font-size. |
957 if (state.lineHeightValue()) | 949 if (state.lineHeightValue()) |
958 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | 950 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); |
959 | 951 |
960 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); | 952 applyMatchedProperties<LowPriorityProperties>(state, result, false, RuleRang
e(0, result.matchedProperties.size() - 1), inheritedOnly); |
961 | 953 |
962 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 954 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
963 | 955 |
964 loadPendingResources(state); | 956 loadPendingResources(state); |
965 | 957 |
966 didAccess(); | 958 didAccess(); |
967 | 959 |
968 // Now return the style. | 960 // Now return the style. |
969 return state.takeStyle(); | 961 return state.takeStyle(); |
970 } | 962 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 if (!isPropertyForPass<pass>(property)) | 1195 if (!isPropertyForPass<pass>(property)) |
1204 continue; | 1196 continue; |
1205 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) | 1197 if (pass == HighPriorityProperties && property == CSSPropertyLineHeight) |
1206 state.setLineHeightValue(current.value()); | 1198 state.setLineHeightValue(current.value()); |
1207 else | 1199 else |
1208 StyleBuilder::applyProperty(current.id(), state, current.value()); | 1200 StyleBuilder::applyProperty(current.id(), state, current.value()); |
1209 } | 1201 } |
1210 } | 1202 } |
1211 | 1203 |
1212 template <StyleResolver::StyleApplicationPass pass> | 1204 template <StyleResolver::StyleApplicationPass pass> |
1213 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
hResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inher
itedOnly) | 1205 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
hResult& matchResult, bool isImportant, const RuleRange& range, bool inheritedOn
ly) |
1214 { | 1206 { |
1215 if (startIndex == -1) | 1207 if (range.collapsed()) |
1216 return; | 1208 return; |
1217 | 1209 |
1218 if (state.style()->insideLink() != NotInsideLink) { | 1210 if (state.style()->insideLink() != NotInsideLink) { |
1219 for (int i = startIndex; i <= endIndex; ++i) { | 1211 for (int i = range.first(); i <= range.last(); ++i) { |
1220 const MatchedProperties& matchedProperties = matchResult.matchedProp
erties[i]; | 1212 const MatchedProperties& matchedProperties = matchResult.matchedProp
erties[i]; |
1221 unsigned linkMatchType = matchedProperties.linkMatchType; | 1213 unsigned linkMatchType = matchedProperties.linkMatchType; |
1222 // FIXME: It would be nicer to pass these as arguments but that requ
ires changes in many places. | 1214 // FIXME: It would be nicer to pass these as arguments but that requ
ires changes in many places. |
1223 state.setApplyPropertyToRegularStyle(linkMatchType & SelectorChecker
::MatchLink); | 1215 state.setApplyPropertyToRegularStyle(linkMatchType & SelectorChecker
::MatchLink); |
1224 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChe
cker::MatchVisited); | 1216 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChe
cker::MatchVisited); |
1225 | 1217 |
1226 applyProperties<pass>(state, matchedProperties.properties.get(), mat
chResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitel
istType>(matchedProperties.whitelistType)); | 1218 applyProperties<pass>(state, matchedProperties.properties.get(), mat
chResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitel
istType>(matchedProperties.whitelistType)); |
1227 } | 1219 } |
1228 state.setApplyPropertyToRegularStyle(true); | 1220 state.setApplyPropertyToRegularStyle(true); |
1229 state.setApplyPropertyToVisitedLinkStyle(false); | 1221 state.setApplyPropertyToVisitedLinkStyle(false); |
1230 return; | 1222 return; |
1231 } | 1223 } |
1232 for (int i = startIndex; i <= endIndex; ++i) { | 1224 for (int i = range.first(); i <= range.last(); ++i) { |
1233 const MatchedProperties& matchedProperties = matchResult.matchedProperti
es[i]; | 1225 const MatchedProperties& matchedProperties = matchResult.matchedProperti
es[i]; |
1234 applyProperties<pass>(state, matchedProperties.properties.get(), matchRe
sult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistT
ype>(matchedProperties.whitelistType)); | 1226 applyProperties<pass>(state, matchedProperties.properties.get(), matchRe
sult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistT
ype>(matchedProperties.whitelistType)); |
1235 } | 1227 } |
1236 } | 1228 } |
1237 | 1229 |
1238 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties
, unsigned size) | 1230 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties
, unsigned size) |
1239 { | 1231 { |
1240 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size
); | 1232 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size
); |
1241 } | 1233 } |
1242 | 1234 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get(
)); | 1271 state.style()->inheritFrom(cachedMatchedProperties->renderStyle.get(
)); |
1280 | 1272 |
1281 // Unfortunately the link status is treated like an inherited proper
ty. We need to explicitly restore it. | 1273 // Unfortunately the link status is treated like an inherited proper
ty. We need to explicitly restore it. |
1282 state.style()->setInsideLink(linkStatus); | 1274 state.style()->setInsideLink(linkStatus); |
1283 return; | 1275 return; |
1284 } | 1276 } |
1285 applyInheritedOnly = true; | 1277 applyInheritedOnly = true; |
1286 } | 1278 } |
1287 | 1279 |
1288 // Apply animation properties in order to apply animation results and trigge
r transitions below. | 1280 // Apply animation properties in order to apply animation results and trigge
r transitions below. |
1289 applyMatchedProperties<AnimationProperties>(state, matchResult, false, 0, ma
tchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1281 applyMatchedProperties<AnimationProperties>(state, matchResult, false, RuleR
ange(0, matchResult.matchedProperties.size() - 1), applyInheritedOnly); |
1290 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR
esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO
nly); | 1282 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR
esult.ranges.authorRuleRange(), applyInheritedOnly); |
1291 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR
esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly)
; | 1283 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR
esult.ranges.userRuleRange(), applyInheritedOnly); |
1292 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR
esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1284 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR
esult.ranges.UARuleRange(), applyInheritedOnly); |
1293 | 1285 |
1294 // Match transition-property / animation-name length by trimming and | 1286 // Match transition-property / animation-name length by trimming and |
1295 // lengthening other transition / animation property lists | 1287 // lengthening other transition / animation property lists |
1296 // FIXME: This is wrong because we shouldn't affect the computed values | 1288 // FIXME: This is wrong because we shouldn't affect the computed values |
1297 state.style()->adjustAnimations(); | 1289 state.style()->adjustAnimations(); |
1298 state.style()->adjustTransitions(); | 1290 state.style()->adjustTransitions(); |
1299 | 1291 |
1300 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply | 1292 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply |
1301 // high-priority properties first, i.e., those properties that other propert
ies depend on. | 1293 // high-priority properties first, i.e., those properties that other propert
ies depend on. |
1302 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important | 1294 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important |
1303 // and (4) normal important. | 1295 // and (4) normal important. |
1304 state.setLineHeightValue(0); | 1296 state.setLineHeightValue(0); |
1305 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0,
matchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1297 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, Ru
leRange(0, matchResult.matchedProperties.size() - 1), applyInheritedOnly); |
1306 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit
edOnly); | 1298 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.authorRuleRange(), applyInheritedOnly); |
1307 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn
ly); | 1299 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.userRuleRange(), applyInheritedOnly); |
1308 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1300 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat
chResult.ranges.UARuleRange(), applyInheritedOnly); |
1309 | 1301 |
1310 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti
veZoom() != state.style()->effectiveZoom()) { | 1302 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti
veZoom() != state.style()->effectiveZoom()) { |
1311 state.fontBuilder().setFontDirty(true); | 1303 state.fontBuilder().setFontDirty(true); |
1312 applyInheritedOnly = false; | 1304 applyInheritedOnly = false; |
1313 } | 1305 } |
1314 | 1306 |
1315 // If our font got dirtied, go ahead and update it now. | 1307 // If our font got dirtied, go ahead and update it now. |
1316 updateFont(state); | 1308 updateFont(state); |
1317 | 1309 |
1318 // Line-height is set when we are sure we decided on the font-size. | 1310 // Line-height is set when we are sure we decided on the font-size. |
1319 if (state.lineHeightValue()) | 1311 if (state.lineHeightValue()) |
1320 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | 1312 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); |
1321 | 1313 |
1322 // Many properties depend on the font. If it changes we just apply all prope
rties. | 1314 // Many properties depend on the font. If it changes we just apply all prope
rties. |
1323 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes
cription() != state.style()->fontDescription()) | 1315 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes
cription() != state.style()->fontDescription()) |
1324 applyInheritedOnly = false; | 1316 applyInheritedOnly = false; |
1325 | 1317 |
1326 // Now do the normal priority UA properties. | 1318 // Now do the normal priority UA properties. |
1327 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1319 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.UARuleRange(), applyInheritedOnly); |
1328 | 1320 |
1329 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. | 1321 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. |
1330 state.cacheUserAgentBorderAndBackground(); | 1322 state.cacheUserAgentBorderAndBackground(); |
1331 | 1323 |
1332 // Now do the author and user normal priority properties and all the !import
ant properties. | 1324 // Now do the author and user normal priority properties and all the !import
ant properties. |
1333 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
nheritedOnly); | 1325 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, Rul
eRange(matchResult.ranges.UARuleRange().last() + 1, matchResult.matchedPropertie
s.size() - 1), applyInheritedOnly); |
1334 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
dOnly); | 1326 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.authorRuleRange(), applyInheritedOnly); |
1335 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
y); | 1327 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.userRuleRange(), applyInheritedOnly); |
1336 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1328 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.UARuleRange(), applyInheritedOnly); |
1337 | 1329 |
1338 loadPendingResources(state); | 1330 loadPendingResources(state); |
1339 | 1331 |
1340 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, state.style(), state.parentStyle())) { | 1332 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, state.style(), state.parentStyle())) { |
1341 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); | 1333 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); |
1342 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa
sh, matchResult); | 1334 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa
sh, matchResult); |
1343 } | 1335 } |
1344 | 1336 |
1345 ASSERT(!state.fontBuilder().fontDirty()); | 1337 ASSERT(!state.fontBuilder().fontDirty()); |
1346 } | 1338 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 visitor->trace(m_keyframesRuleMap); | 1415 visitor->trace(m_keyframesRuleMap); |
1424 visitor->trace(m_viewportDependentMediaQueryResults); | 1416 visitor->trace(m_viewportDependentMediaQueryResults); |
1425 visitor->trace(m_viewportStyleResolver); | 1417 visitor->trace(m_viewportStyleResolver); |
1426 visitor->trace(m_siblingRuleSet); | 1418 visitor->trace(m_siblingRuleSet); |
1427 visitor->trace(m_uncommonAttributeRuleSet); | 1419 visitor->trace(m_uncommonAttributeRuleSet); |
1428 visitor->trace(m_watchedSelectorsRules); | 1420 visitor->trace(m_watchedSelectorsRules); |
1429 visitor->trace(m_treeBoundaryCrossingRules); | 1421 visitor->trace(m_treeBoundaryCrossingRules); |
1430 } | 1422 } |
1431 | 1423 |
1432 } // namespace WebCore | 1424 } // namespace WebCore |
OLD | NEW |