| 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. | 5  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. | 
| 6  * All rights reserved. | 6  * All rights reserved. | 
| 7  * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7  * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 
| 8  * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8  * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 
| 9  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 
| 10  * (http://www.torchmobile.com/) | 10  * (http://www.torchmobile.com/) | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 80 #include "core/dom/shadow/ElementShadow.h" | 80 #include "core/dom/shadow/ElementShadow.h" | 
| 81 #include "core/dom/shadow/ShadowRoot.h" | 81 #include "core/dom/shadow/ShadowRoot.h" | 
| 82 #include "core/frame/FrameView.h" | 82 #include "core/frame/FrameView.h" | 
| 83 #include "core/frame/LocalFrame.h" | 83 #include "core/frame/LocalFrame.h" | 
| 84 #include "core/frame/Settings.h" | 84 #include "core/frame/Settings.h" | 
| 85 #include "core/frame/UseCounter.h" | 85 #include "core/frame/UseCounter.h" | 
| 86 #include "core/html/HTMLIFrameElement.h" | 86 #include "core/html/HTMLIFrameElement.h" | 
| 87 #include "core/html/HTMLSlotElement.h" | 87 #include "core/html/HTMLSlotElement.h" | 
| 88 #include "core/inspector/InspectorInstrumentation.h" | 88 #include "core/inspector/InspectorInstrumentation.h" | 
| 89 #include "core/layout/GeneratedChildren.h" | 89 #include "core/layout/GeneratedChildren.h" | 
| 90 #include "core/layout/api/LayoutViewItem.h" |  | 
| 91 #include "core/style/StyleInheritedVariables.h" | 90 #include "core/style/StyleInheritedVariables.h" | 
| 92 #include "core/svg/SVGDocumentExtensions.h" | 91 #include "core/svg/SVGDocumentExtensions.h" | 
| 93 #include "core/svg/SVGElement.h" | 92 #include "core/svg/SVGElement.h" | 
| 94 #include "platform/RuntimeEnabledFeatures.h" | 93 #include "platform/RuntimeEnabledFeatures.h" | 
| 95 #include "wtf/StdLibExtras.h" | 94 #include "wtf/StdLibExtras.h" | 
| 96 | 95 | 
| 97 namespace { | 96 namespace { | 
| 98 | 97 | 
| 99 using namespace blink; | 98 using namespace blink; | 
| 100 | 99 | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 174        shadowRoot = shadowRoot->olderShadowRoot()) { | 173        shadowRoot = shadowRoot->olderShadowRoot()) { | 
| 175     if (shadowRoot->numberOfStyles() > 0) { | 174     if (shadowRoot->numberOfStyles() > 0) { | 
| 176       if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver()) | 175       if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver()) | 
| 177         resolvers.append(resolver); | 176         resolvers.append(resolver); | 
| 178     } | 177     } | 
| 179   } | 178   } | 
| 180 } | 179 } | 
| 181 | 180 | 
| 182 StyleResolver::StyleResolver(Document& document) | 181 StyleResolver::StyleResolver(Document& document) | 
| 183     : m_document(document), | 182     : m_document(document), | 
| 184       m_needCollectFeatures(false), |  | 
| 185       m_printMediaType(false), | 183       m_printMediaType(false), | 
| 186       m_styleSharingDepth(0) { | 184       m_styleSharingDepth(0) { | 
| 187   FrameView* view = document.view(); | 185   FrameView* view = document.view(); | 
| 188   DCHECK(view); | 186   DCHECK(view); | 
| 189   m_medium = new MediaQueryEvaluator(&view->frame()); | 187   m_medium = new MediaQueryEvaluator(&view->frame()); | 
| 190   m_printMediaType = | 188   m_printMediaType = | 
| 191       equalIgnoringCase(view->mediaType(), MediaTypeNames::print); | 189       equalIgnoringCase(view->mediaType(), MediaTypeNames::print); | 
| 192 |  | 
| 193   initWatchedSelectorRules(); |  | 
| 194 } | 190 } | 
| 195 | 191 | 
| 196 StyleResolver::~StyleResolver() {} | 192 StyleResolver::~StyleResolver() {} | 
| 197 | 193 | 
| 198 void StyleResolver::dispose() { | 194 void StyleResolver::dispose() { | 
| 199   m_matchedPropertiesCache.clear(); | 195   m_matchedPropertiesCache.clear(); | 
| 200 } | 196 } | 
| 201 | 197 | 
| 202 void StyleResolver::initWatchedSelectorRules() { |  | 
| 203   m_watchedSelectorsRules = nullptr; |  | 
| 204   CSSSelectorWatch* watch = CSSSelectorWatch::fromIfExists(*m_document); |  | 
| 205   if (!watch) |  | 
| 206     return; |  | 
| 207   const HeapVector<Member<StyleRule>>& watchedSelectors = |  | 
| 208       watch->watchedCallbackSelectors(); |  | 
| 209   if (!watchedSelectors.size()) |  | 
| 210     return; |  | 
| 211   m_watchedSelectorsRules = RuleSet::create(); |  | 
| 212   for (unsigned i = 0; i < watchedSelectors.size(); ++i) |  | 
| 213     m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), |  | 
| 214                                           RuleHasNoSpecialState); |  | 
| 215 } |  | 
| 216 |  | 
| 217 void StyleResolver::lazyAppendAuthorStyleSheets( | 198 void StyleResolver::lazyAppendAuthorStyleSheets( | 
| 218     unsigned firstNew, | 199     unsigned firstNew, | 
| 219     const HeapVector<Member<CSSStyleSheet>>& styleSheets) { | 200     const HeapVector<Member<CSSStyleSheet>>& styleSheets) { | 
| 220   unsigned size = styleSheets.size(); | 201   unsigned size = styleSheets.size(); | 
| 221   for (unsigned i = firstNew; i < size; ++i) | 202   for (unsigned i = firstNew; i < size; ++i) | 
| 222     m_pendingStyleSheets.add(styleSheets[i].get()); | 203     m_pendingStyleSheets.add(styleSheets[i].get()); | 
| 223 } | 204 } | 
| 224 | 205 | 
| 225 void StyleResolver::removePendingAuthorStyleSheets( | 206 void StyleResolver::removePendingAuthorStyleSheets( | 
| 226     const HeapVector<Member<CSSStyleSheet>>& styleSheets) { | 207     const HeapVector<Member<CSSStyleSheet>>& styleSheets) { | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 259     treeScope = m_document; | 240     treeScope = m_document; | 
| 260   treeScope->ensureScopedStyleResolver().appendCSSStyleSheet(cssSheet, | 241   treeScope->ensureScopedStyleResolver().appendCSSStyleSheet(cssSheet, | 
| 261                                                              *m_medium); | 242                                                              *m_medium); | 
| 262 } | 243 } | 
| 263 | 244 | 
| 264 void StyleResolver::appendPendingAuthorStyleSheets() { | 245 void StyleResolver::appendPendingAuthorStyleSheets() { | 
| 265   for (const auto& styleSheet : m_pendingStyleSheets) | 246   for (const auto& styleSheet : m_pendingStyleSheets) | 
| 266     appendCSSStyleSheet(*styleSheet); | 247     appendCSSStyleSheet(*styleSheet); | 
| 267 | 248 | 
| 268   m_pendingStyleSheets.clear(); | 249   m_pendingStyleSheets.clear(); | 
| 269   finishAppendAuthorStyleSheets(); |  | 
| 270 } | 250 } | 
| 271 | 251 | 
| 272 void StyleResolver::appendAuthorStyleSheets( | 252 void StyleResolver::appendAuthorStyleSheets( | 
| 273     const HeapVector<Member<CSSStyleSheet>>& styleSheets) { | 253     const HeapVector<Member<CSSStyleSheet>>& styleSheets) { | 
| 274   // This handles sheets added to the end of the stylesheet list only. In other | 254   // This handles sheets added to the end of the stylesheet list only. In other | 
| 275   // cases the style resolver needs to be reconstructed. To handle insertions | 255   // cases the style resolver needs to be reconstructed. To handle insertions | 
| 276   // too the rule order numbers would need to be updated. | 256   // too the rule order numbers would need to be updated. | 
| 277   for (const auto& styleSheet : styleSheets) | 257   for (const auto& styleSheet : styleSheets) | 
| 278     appendCSSStyleSheet(*styleSheet); | 258     appendCSSStyleSheet(*styleSheet); | 
| 279 } | 259 } | 
| 280 | 260 | 
| 281 void StyleResolver::finishAppendAuthorStyleSheets() { |  | 
| 282   collectFeatures(); |  | 
| 283 |  | 
| 284   if (!document().layoutViewItem().isNull() && |  | 
| 285       document().layoutViewItem().style()) |  | 
| 286     document().layoutViewItem().style()->font().update( |  | 
| 287         document().styleEngine().fontSelector()); |  | 
| 288 |  | 
| 289   document().styleEngine().resetCSSFeatureFlags(m_features); |  | 
| 290 } |  | 
| 291 |  | 
| 292 void StyleResolver::resetRuleFeatures() { |  | 
| 293   // Need to recreate RuleFeatureSet. |  | 
| 294   m_features.clear(); |  | 
| 295   m_siblingRuleSet.clear(); |  | 
| 296   m_uncommonAttributeRuleSet.clear(); |  | 
| 297   m_needCollectFeatures = true; |  | 
| 298 } |  | 
| 299 |  | 
| 300 static RuleSet* makeRuleSet(const HeapVector<RuleFeature>& rules) { |  | 
| 301   size_t size = rules.size(); |  | 
| 302   if (!size) |  | 
| 303     return nullptr; |  | 
| 304   RuleSet* ruleSet = RuleSet::create(); |  | 
| 305   for (size_t i = 0; i < size; ++i) |  | 
| 306     ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, |  | 
| 307                      rules[i].hasDocumentSecurityOrigin |  | 
| 308                          ? RuleHasDocumentSecurityOrigin |  | 
| 309                          : RuleHasNoSpecialState); |  | 
| 310   return ruleSet; |  | 
| 311 } |  | 
| 312 |  | 
| 313 void StyleResolver::collectFeatures() { |  | 
| 314   m_features.clear(); |  | 
| 315   // Collect all ids and rules using sibling selectors (:first-child and |  | 
| 316   // similar) in the current set of stylesheets. Style sharing code uses this |  | 
| 317   // information to reject sharing candidates. |  | 
| 318   CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance(); |  | 
| 319   if (defaultStyleSheets.defaultStyle()) { |  | 
| 320     m_features.add(defaultStyleSheets.defaultStyle()->features()); |  | 
| 321     m_hasFullscreenUAStyle = defaultStyleSheets.fullscreenStyleSheet(); |  | 
| 322   } |  | 
| 323 |  | 
| 324   if (document().isViewSource()) |  | 
| 325     m_features.add(defaultStyleSheets.defaultViewSourceStyle()->features()); |  | 
| 326 |  | 
| 327   if (m_watchedSelectorsRules) |  | 
| 328     m_features.add(m_watchedSelectorsRules->features()); |  | 
| 329 |  | 
| 330   document().styleEngine().collectScopedStyleFeaturesTo(m_features); |  | 
| 331 |  | 
| 332   m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |  | 
| 333   m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |  | 
| 334   m_needCollectFeatures = false; |  | 
| 335 } |  | 
| 336 |  | 
| 337 bool StyleResolver::hasRulesForId(const AtomicString& id) const { |  | 
| 338   return m_features.hasSelectorForId(id); |  | 
| 339 } |  | 
| 340 |  | 
| 341 void StyleResolver::addToStyleSharingList(Element& element) { | 261 void StyleResolver::addToStyleSharingList(Element& element) { | 
| 342   ASSERT(RuntimeEnabledFeatures::styleSharingEnabled()); | 262   DCHECK(RuntimeEnabledFeatures::styleSharingEnabled()); | 
| 343   // Never add elements to the style sharing list if we're not in a recalcStyle, | 263   // Never add elements to the style sharing list if we're not in a recalcStyle, | 
| 344   // otherwise we could leave stale pointers in there. | 264   // otherwise we could leave stale pointers in there. | 
| 345   if (!document().inStyleRecalc()) | 265   if (!document().inStyleRecalc()) | 
| 346     return; | 266     return; | 
| 347   INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), sharedStyleCandidates, | 267   INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), sharedStyleCandidates, | 
| 348                                 1); | 268                                 1); | 
| 349   StyleSharingList& list = styleSharingList(); | 269   StyleSharingList& list = styleSharingList(); | 
| 350   if (list.size() >= styleSharingListSize) | 270   if (list.size() >= styleSharingListSize) | 
| 351     list.removeLast(); | 271     list.removeLast(); | 
| 352   list.prepend(&element); | 272   list.prepend(&element); | 
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 498   } | 418   } | 
| 499 | 419 | 
| 500   bool matchElementScopeDone = !elementScopeResolver && !element.inlineStyle(); | 420   bool matchElementScopeDone = !elementScopeResolver && !element.inlineStyle(); | 
| 501 | 421 | 
| 502   const auto& treeBoundaryCrossingScopes = | 422   const auto& treeBoundaryCrossingScopes = | 
| 503       document().styleEngine().treeBoundaryCrossingScopes(); | 423       document().styleEngine().treeBoundaryCrossingScopes(); | 
| 504   for (auto it = treeBoundaryCrossingScopes.rbegin(); | 424   for (auto it = treeBoundaryCrossingScopes.rbegin(); | 
| 505        it != treeBoundaryCrossingScopes.rend(); ++it) { | 425        it != treeBoundaryCrossingScopes.rend(); ++it) { | 
| 506     const TreeScope& scope = (*it)->containingTreeScope(); | 426     const TreeScope& scope = (*it)->containingTreeScope(); | 
| 507     ScopedStyleResolver* resolver = scope.scopedStyleResolver(); | 427     ScopedStyleResolver* resolver = scope.scopedStyleResolver(); | 
| 508     ASSERT(resolver); | 428     DCHECK(resolver); | 
| 509 | 429 | 
| 510     bool isInnerTreeScope = | 430     bool isInnerTreeScope = | 
| 511         element.containingTreeScope().isInclusiveAncestorOf(scope); | 431         element.containingTreeScope().isInclusiveAncestorOf(scope); | 
| 512     if (!shouldCheckScope(element, **it, isInnerTreeScope)) | 432     if (!shouldCheckScope(element, **it, isInnerTreeScope)) | 
| 513       continue; | 433       continue; | 
| 514 | 434 | 
| 515     if (!matchElementScopeDone && | 435     if (!matchElementScopeDone && | 
| 516         scope.isInclusiveAncestorOf(element.containingTreeScope())) { | 436         scope.isInclusiveAncestorOf(element.containingTreeScope())) { | 
| 517       matchElementScopeDone = true; | 437       matchElementScopeDone = true; | 
| 518 | 438 | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 539     matchElementScopeRules(element, elementScopeResolver, collector); | 459     matchElementScopeRules(element, elementScopeResolver, collector); | 
| 540 } | 460 } | 
| 541 | 461 | 
| 542 void StyleResolver::matchAuthorRules(const Element& element, | 462 void StyleResolver::matchAuthorRules(const Element& element, | 
| 543                                      ElementRuleCollector& collector) { | 463                                      ElementRuleCollector& collector) { | 
| 544   if (document().shadowCascadeOrder() != ShadowCascadeOrder::ShadowCascadeV1) { | 464   if (document().shadowCascadeOrder() != ShadowCascadeOrder::ShadowCascadeV1) { | 
| 545     matchAuthorRulesV0(element, collector); | 465     matchAuthorRulesV0(element, collector); | 
| 546     return; | 466     return; | 
| 547   } | 467   } | 
| 548 | 468 | 
| 549   ASSERT(RuntimeEnabledFeatures::shadowDOMV1Enabled()); | 469   DCHECK(RuntimeEnabledFeatures::shadowDOMV1Enabled()); | 
| 550   matchHostRules(element, collector); | 470   matchHostRules(element, collector); | 
| 551   matchScopedRules(element, collector); | 471   matchScopedRules(element, collector); | 
| 552 } | 472 } | 
| 553 | 473 | 
| 554 void StyleResolver::matchAuthorRulesV0(const Element& element, | 474 void StyleResolver::matchAuthorRulesV0(const Element& element, | 
| 555                                        ElementRuleCollector& collector) { | 475                                        ElementRuleCollector& collector) { | 
| 556   collector.clearMatchedRules(); | 476   collector.clearMatchedRules(); | 
| 557 | 477 | 
| 558   CascadeOrder cascadeOrder = 0; | 478   CascadeOrder cascadeOrder = 0; | 
| 559   HeapVector<Member<ScopedStyleResolver>, 8> resolversInShadowTree; | 479   HeapVector<Member<ScopedStyleResolver>, 8> resolversInShadowTree; | 
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 729 void StyleResolver::loadPendingResources(StyleResolverState& state) { | 649 void StyleResolver::loadPendingResources(StyleResolverState& state) { | 
| 730   state.elementStyleResources().loadPendingResources(state.style()); | 650   state.elementStyleResources().loadPendingResources(state.style()); | 
| 731 } | 651 } | 
| 732 | 652 | 
| 733 PassRefPtr<ComputedStyle> StyleResolver::styleForElement( | 653 PassRefPtr<ComputedStyle> StyleResolver::styleForElement( | 
| 734     Element* element, | 654     Element* element, | 
| 735     const ComputedStyle* defaultParent, | 655     const ComputedStyle* defaultParent, | 
| 736     StyleSharingBehavior sharingBehavior, | 656     StyleSharingBehavior sharingBehavior, | 
| 737     RuleMatchingBehavior matchingBehavior) { | 657     RuleMatchingBehavior matchingBehavior) { | 
| 738   DCHECK(document().frame()); | 658   DCHECK(document().frame()); | 
| 739   ASSERT(document().settings()); | 659   DCHECK(document().settings()); | 
| 740   ASSERT(!hasPendingAuthorStyleSheets()); | 660   DCHECK(!hasPendingAuthorStyleSheets()); | 
| 741   ASSERT(!m_needCollectFeatures); |  | 
| 742 | 661 | 
| 743   // Once an element has a layoutObject, we don't try to destroy it, since | 662   // Once an element has a layoutObject, we don't try to destroy it, since | 
| 744   // otherwise the layoutObject will vanish if a style recalc happens during | 663   // otherwise the layoutObject will vanish if a style recalc happens during | 
| 745   // loading. | 664   // loading. | 
| 746   if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() && | 665   if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() && | 
| 747       !element->layoutObject()) { | 666       !element->layoutObject()) { | 
| 748     if (!s_styleNotYetAvailable) { | 667     if (!s_styleNotYetAvailable) { | 
| 749       s_styleNotYetAvailable = ComputedStyle::create().leakRef(); | 668       s_styleNotYetAvailable = ComputedStyle::create().leakRef(); | 
| 750       s_styleNotYetAvailable->setDisplay(EDisplay::None); | 669       s_styleNotYetAvailable->setDisplay(EDisplay::None); | 
| 751       s_styleNotYetAvailable->font().update( | 670       s_styleNotYetAvailable->font().update( | 
| 752           document().styleEngine().fontSelector()); | 671           document().styleEngine().fontSelector()); | 
| 753     } | 672     } | 
| 754 | 673 | 
| 755     document().setHasNodesWithPlaceholderStyle(); | 674     document().setHasNodesWithPlaceholderStyle(); | 
| 756     return s_styleNotYetAvailable; | 675     return s_styleNotYetAvailable; | 
| 757   } | 676   } | 
| 758 | 677 | 
| 759   document().styleEngine().incStyleForElementCount(); | 678   document().styleEngine().incStyleForElementCount(); | 
| 760   INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), elementsStyled, 1); | 679   INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), elementsStyled, 1); | 
| 761 | 680 | 
| 762   SelectorFilterParentScope::ensureParentStackIsPushed(); | 681   SelectorFilterParentScope::ensureParentStackIsPushed(); | 
| 763 | 682 | 
| 764   ElementResolveContext elementContext(*element); | 683   ElementResolveContext elementContext(*element); | 
| 765 | 684 | 
| 766   if (RuntimeEnabledFeatures::styleSharingEnabled() && | 685   if (RuntimeEnabledFeatures::styleSharingEnabled() && | 
| 767       sharingBehavior == AllowStyleSharing && | 686       sharingBehavior == AllowStyleSharing && | 
| 768       (defaultParent || elementContext.parentStyle())) { | 687       (defaultParent || elementContext.parentStyle())) { | 
| 769     SharedStyleFinder styleFinder(elementContext, m_features, | 688     if (RefPtr<ComputedStyle> sharedStyle = | 
| 770                                   m_siblingRuleSet.get(), | 689             document().styleEngine().findSharedStyle(elementContext)) | 
| 771                                   m_uncommonAttributeRuleSet.get(), *this); |  | 
| 772     if (RefPtr<ComputedStyle> sharedStyle = styleFinder.findSharedStyle()) |  | 
| 773       return sharedStyle.release(); | 690       return sharedStyle.release(); | 
| 774   } | 691   } | 
| 775 | 692 | 
| 776   StyleResolverState state(document(), elementContext, defaultParent); | 693   StyleResolverState state(document(), elementContext, defaultParent); | 
| 777 | 694 | 
| 778   ElementAnimations* elementAnimations = element->elementAnimations(); | 695   ElementAnimations* elementAnimations = element->elementAnimations(); | 
| 779   const ComputedStyle* baseComputedStyle = | 696   const ComputedStyle* baseComputedStyle = | 
| 780       elementAnimations ? elementAnimations->baseComputedStyle() : nullptr; | 697       elementAnimations ? elementAnimations->baseComputedStyle() : nullptr; | 
| 781 | 698 | 
| 782   if (baseComputedStyle) { | 699   if (baseComputedStyle) { | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 812     if (linkState != NotInsideLink) { | 729     if (linkState != NotInsideLink) { | 
| 813       bool forceVisited = InspectorInstrumentation::forcePseudoState( | 730       bool forceVisited = InspectorInstrumentation::forcePseudoState( | 
| 814           element, CSSSelector::PseudoVisited); | 731           element, CSSSelector::PseudoVisited); | 
| 815       if (forceVisited) | 732       if (forceVisited) | 
| 816         linkState = InsideVisitedLink; | 733         linkState = InsideVisitedLink; | 
| 817     } | 734     } | 
| 818     state.style()->setInsideLink(linkState); | 735     state.style()->setInsideLink(linkState); | 
| 819   } | 736   } | 
| 820 | 737 | 
| 821   if (!baseComputedStyle) { | 738   if (!baseComputedStyle) { | 
| 822     bool needsCollection = false; | 739     document().styleEngine().ensureUAStyleForElement(*element); | 
| 823     CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement( |  | 
| 824         *element, needsCollection); |  | 
| 825     if (needsCollection) |  | 
| 826       collectFeatures(); |  | 
| 827 | 740 | 
| 828     ElementRuleCollector collector(state.elementContext(), m_selectorFilter, | 741     ElementRuleCollector collector(state.elementContext(), m_selectorFilter, | 
| 829                                    state.style()); | 742                                    state.style()); | 
| 830 | 743 | 
| 831     matchAllRules(state, collector, | 744     matchAllRules(state, collector, | 
| 832                   matchingBehavior != MatchAllRulesExcludingSMIL); | 745                   matchingBehavior != MatchAllRulesExcludingSMIL); | 
| 833 | 746 | 
| 834     // TODO(dominicc): Remove this counter when Issue 590014 is fixed. | 747     // TODO(dominicc): Remove this counter when Issue 590014 is fixed. | 
| 835     if (element->hasTagName(HTMLNames::summaryTag)) { | 748     if (element->hasTagName(HTMLNames::summaryTag)) { | 
| 836       MatchedPropertiesRange properties = | 749       MatchedPropertiesRange properties = | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 954           parentStyle->getCachedPseudoStyle(pseudoId)) { | 867           parentStyle->getCachedPseudoStyle(pseudoId)) { | 
| 955     if (!pseudoElementLayoutObjectIsNeeded(cachedStyle)) | 868     if (!pseudoElementLayoutObjectIsNeeded(cachedStyle)) | 
| 956       return nullptr; | 869       return nullptr; | 
| 957     return createPseudoElement(&parent, pseudoId); | 870     return createPseudoElement(&parent, pseudoId); | 
| 958   } | 871   } | 
| 959 | 872 | 
| 960   StyleResolverState state(document(), &parent, parentStyle); | 873   StyleResolverState state(document(), &parent, parentStyle); | 
| 961   if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 874   if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 
| 962     return nullptr; | 875     return nullptr; | 
| 963   RefPtr<ComputedStyle> style = state.takeStyle(); | 876   RefPtr<ComputedStyle> style = state.takeStyle(); | 
| 964   ASSERT(style); | 877   DCHECK(style); | 
| 965   parentStyle->addCachedPseudoStyle(style); | 878   parentStyle->addCachedPseudoStyle(style); | 
| 966 | 879 | 
| 967   if (!pseudoElementLayoutObjectIsNeeded(style.get())) | 880   if (!pseudoElementLayoutObjectIsNeeded(style.get())) | 
| 968     return nullptr; | 881     return nullptr; | 
| 969 | 882 | 
| 970   PseudoElement* pseudo = createPseudoElement(&parent, pseudoId); | 883   PseudoElement* pseudo = createPseudoElement(&parent, pseudoId); | 
| 971 | 884 | 
| 972   setAnimationUpdateIfNeeded(state, *pseudo); | 885   setAnimationUpdateIfNeeded(state, *pseudo); | 
| 973   if (ElementAnimations* elementAnimations = pseudo->elementAnimations()) | 886   if (ElementAnimations* elementAnimations = pseudo->elementAnimations()) | 
| 974     elementAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo); | 887     elementAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo); | 
| 975   return pseudo; | 888   return pseudo; | 
| 976 } | 889 } | 
| 977 | 890 | 
| 978 bool StyleResolver::pseudoStyleForElementInternal( | 891 bool StyleResolver::pseudoStyleForElementInternal( | 
| 979     Element& element, | 892     Element& element, | 
| 980     const PseudoStyleRequest& pseudoStyleRequest, | 893     const PseudoStyleRequest& pseudoStyleRequest, | 
| 981     const ComputedStyle* parentStyle, | 894     const ComputedStyle* parentStyle, | 
| 982     StyleResolverState& state) { | 895     StyleResolverState& state) { | 
| 983   ASSERT(document().frame()); | 896   DCHECK(document().frame()); | 
| 984   ASSERT(document().settings()); | 897   DCHECK(document().settings()); | 
| 985   ASSERT(pseudoStyleRequest.pseudoId != PseudoIdFirstLineInherited); | 898   DCHECK(pseudoStyleRequest.pseudoId != PseudoIdFirstLineInherited); | 
| 986   ASSERT(state.parentStyle()); | 899   DCHECK(state.parentStyle()); | 
| 987 | 900 | 
| 988   SelectorFilterParentScope::ensureParentStackIsPushed(); | 901   SelectorFilterParentScope::ensureParentStackIsPushed(); | 
| 989 | 902 | 
| 990   Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); | 903   Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); | 
| 991 | 904 | 
| 992   ElementAnimations* elementAnimations = | 905   ElementAnimations* elementAnimations = | 
| 993       pseudoElement ? pseudoElement->elementAnimations() : nullptr; | 906       pseudoElement ? pseudoElement->elementAnimations() : nullptr; | 
| 994   const ComputedStyle* baseComputedStyle = | 907   const ComputedStyle* baseComputedStyle = | 
| 995       elementAnimations ? elementAnimations->baseComputedStyle() : nullptr; | 908       elementAnimations ? elementAnimations->baseComputedStyle() : nullptr; | 
| 996 | 909 | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1051   if (state.style()->hasViewportUnits()) | 964   if (state.style()->hasViewportUnits()) | 
| 1052     document().setHasViewportUnits(); | 965     document().setHasViewportUnits(); | 
| 1053 | 966 | 
| 1054   return true; | 967   return true; | 
| 1055 } | 968 } | 
| 1056 | 969 | 
| 1057 PassRefPtr<ComputedStyle> StyleResolver::pseudoStyleForElement( | 970 PassRefPtr<ComputedStyle> StyleResolver::pseudoStyleForElement( | 
| 1058     Element* element, | 971     Element* element, | 
| 1059     const PseudoStyleRequest& pseudoStyleRequest, | 972     const PseudoStyleRequest& pseudoStyleRequest, | 
| 1060     const ComputedStyle* parentStyle) { | 973     const ComputedStyle* parentStyle) { | 
| 1061   ASSERT(parentStyle); | 974   DCHECK(parentStyle); | 
| 1062   if (!element) | 975   if (!element) | 
| 1063     return nullptr; | 976     return nullptr; | 
| 1064 | 977 | 
| 1065   StyleResolverState state(document(), element, parentStyle); | 978   StyleResolverState state(document(), element, parentStyle); | 
| 1066   if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle, | 979   if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle, | 
| 1067                                      state)) { | 980                                      state)) { | 
| 1068     if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) | 981     if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) | 
| 1069       return nullptr; | 982       return nullptr; | 
| 1070     return state.takeStyle(); | 983     return state.takeStyle(); | 
| 1071   } | 984   } | 
| 1072 | 985 | 
| 1073   if (PseudoElement* pseudoElement = | 986   if (PseudoElement* pseudoElement = | 
| 1074           element->pseudoElement(pseudoStyleRequest.pseudoId)) | 987           element->pseudoElement(pseudoStyleRequest.pseudoId)) | 
| 1075     setAnimationUpdateIfNeeded(state, *pseudoElement); | 988     setAnimationUpdateIfNeeded(state, *pseudoElement); | 
| 1076 | 989 | 
| 1077   // Now return the style. | 990   // Now return the style. | 
| 1078   return state.takeStyle(); | 991   return state.takeStyle(); | 
| 1079 } | 992 } | 
| 1080 | 993 | 
| 1081 PassRefPtr<ComputedStyle> StyleResolver::styleForPage(int pageIndex) { | 994 PassRefPtr<ComputedStyle> StyleResolver::styleForPage(int pageIndex) { | 
| 1082   ASSERT(!hasPendingAuthorStyleSheets()); | 995   DCHECK(!hasPendingAuthorStyleSheets()); | 
| 1083   // m_rootElementStyle will be set to the document style. | 996   // m_rootElementStyle will be set to the document style. | 
| 1084   StyleResolverState state(document(), document().documentElement()); | 997   StyleResolverState state(document(), document().documentElement()); | 
| 1085 | 998 | 
| 1086   RefPtr<ComputedStyle> style = ComputedStyle::create(); | 999   RefPtr<ComputedStyle> style = ComputedStyle::create(); | 
| 1087   const ComputedStyle* rootElementStyle = state.rootElementStyle() | 1000   const ComputedStyle* rootElementStyle = state.rootElementStyle() | 
| 1088                                               ? state.rootElementStyle() | 1001                                               ? state.rootElementStyle() | 
| 1089                                               : document().computedStyle(); | 1002                                               : document().computedStyle(); | 
| 1090   ASSERT(rootElementStyle); | 1003   DCHECK(rootElementStyle); | 
| 1091   style->inheritFrom(*rootElementStyle); | 1004   style->inheritFrom(*rootElementStyle); | 
| 1092   state.setStyle(style.release()); | 1005   state.setStyle(style.release()); | 
| 1093 | 1006 | 
| 1094   PageRuleCollector collector(rootElementStyle, pageIndex); | 1007   PageRuleCollector collector(rootElementStyle, pageIndex); | 
| 1095 | 1008 | 
| 1096   collector.matchPageRules( | 1009   collector.matchPageRules( | 
| 1097       CSSDefaultStyleSheets::instance().defaultPrintStyle()); | 1010       CSSDefaultStyleSheets::instance().defaultPrintStyle()); | 
| 1098 | 1011 | 
| 1099   if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 1012   if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 
| 1100     scopedResolver->matchPageRules(collector); | 1013     scopedResolver->matchPageRules(collector); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 1119 | 1032 | 
| 1120 PassRefPtr<ComputedStyle> StyleResolver::initialStyleForElement() { | 1033 PassRefPtr<ComputedStyle> StyleResolver::initialStyleForElement() { | 
| 1121   RefPtr<ComputedStyle> style = ComputedStyle::create(); | 1034   RefPtr<ComputedStyle> style = ComputedStyle::create(); | 
| 1122   FontBuilder fontBuilder(document()); | 1035   FontBuilder fontBuilder(document()); | 
| 1123   fontBuilder.setInitial(style->effectiveZoom()); | 1036   fontBuilder.setInitial(style->effectiveZoom()); | 
| 1124   fontBuilder.createFont(document().styleEngine().fontSelector(), *style); | 1037   fontBuilder.createFont(document().styleEngine().fontSelector(), *style); | 
| 1125   return style.release(); | 1038   return style.release(); | 
| 1126 } | 1039 } | 
| 1127 | 1040 | 
| 1128 PassRefPtr<ComputedStyle> StyleResolver::styleForText(Text* textNode) { | 1041 PassRefPtr<ComputedStyle> StyleResolver::styleForText(Text* textNode) { | 
| 1129   ASSERT(textNode); | 1042   DCHECK(textNode); | 
| 1130 | 1043 | 
| 1131   Node* parentNode = LayoutTreeBuilderTraversal::parent(*textNode); | 1044   Node* parentNode = LayoutTreeBuilderTraversal::parent(*textNode); | 
| 1132   if (!parentNode || !parentNode->computedStyle()) | 1045   if (!parentNode || !parentNode->computedStyle()) | 
| 1133     return initialStyleForElement(); | 1046     return initialStyleForElement(); | 
| 1134   return parentNode->mutableComputedStyle(); | 1047   return parentNode->mutableComputedStyle(); | 
| 1135 } | 1048 } | 
| 1136 | 1049 | 
| 1137 void StyleResolver::updateFont(StyleResolverState& state) { | 1050 void StyleResolver::updateFont(StyleResolverState& state) { | 
| 1138   state.fontBuilder().createFont(document().styleEngine().fontSelector(), | 1051   state.fontBuilder().createFont(document().styleEngine().fontSelector(), | 
| 1139                                  state.mutableStyleRef()); | 1052                                  state.mutableStyleRef()); | 
| 1140   state.setConversionFontSizes(CSSToLengthConversionData::FontSizes( | 1053   state.setConversionFontSizes(CSSToLengthConversionData::FontSizes( | 
| 1141       state.style(), state.rootElementStyle())); | 1054       state.style(), state.rootElementStyle())); | 
| 1142   state.setConversionZoom(state.style()->effectiveZoom()); | 1055   state.setConversionZoom(state.style()->effectiveZoom()); | 
| 1143 } | 1056 } | 
| 1144 | 1057 | 
| 1145 StyleRuleList* StyleResolver::styleRulesForElement(Element* element, | 1058 StyleRuleList* StyleResolver::styleRulesForElement(Element* element, | 
| 1146                                                    unsigned rulesToInclude) { | 1059                                                    unsigned rulesToInclude) { | 
| 1147   ASSERT(element); | 1060   DCHECK(element); | 
| 1148   StyleResolverState state(document(), element); | 1061   StyleResolverState state(document(), element); | 
| 1149   ElementRuleCollector collector(state.elementContext(), m_selectorFilter, | 1062   ElementRuleCollector collector(state.elementContext(), m_selectorFilter, | 
| 1150                                  state.style()); | 1063                                  state.style()); | 
| 1151   collector.setMode(SelectorChecker::CollectingStyleRules); | 1064   collector.setMode(SelectorChecker::CollectingStyleRules); | 
| 1152   collectPseudoRulesForElement(*element, collector, PseudoIdNone, | 1065   collectPseudoRulesForElement(*element, collector, PseudoIdNone, | 
| 1153                                rulesToInclude); | 1066                                rulesToInclude); | 
| 1154   return collector.matchedStyleRuleList(); | 1067   return collector.matchedStyleRuleList(); | 
| 1155 } | 1068 } | 
| 1156 | 1069 | 
| 1157 CSSRuleList* StyleResolver::pseudoCSSRulesForElement(Element* element, | 1070 CSSRuleList* StyleResolver::pseudoCSSRulesForElement(Element* element, | 
| 1158                                                      PseudoId pseudoId, | 1071                                                      PseudoId pseudoId, | 
| 1159                                                      unsigned rulesToInclude) { | 1072                                                      unsigned rulesToInclude) { | 
| 1160   ASSERT(element); | 1073   DCHECK(element); | 
| 1161   StyleResolverState state(document(), element); | 1074   StyleResolverState state(document(), element); | 
| 1162   ElementRuleCollector collector(state.elementContext(), m_selectorFilter, | 1075   ElementRuleCollector collector(state.elementContext(), m_selectorFilter, | 
| 1163                                  state.style()); | 1076                                  state.style()); | 
| 1164   collector.setMode(SelectorChecker::CollectingCSSRules); | 1077   collector.setMode(SelectorChecker::CollectingCSSRules); | 
| 1165   collectPseudoRulesForElement(*element, collector, pseudoId, rulesToInclude); | 1078   collectPseudoRulesForElement(*element, collector, pseudoId, rulesToInclude); | 
| 1166   return collector.matchedCSSRuleList(); | 1079   return collector.matchedCSSRuleList(); | 
| 1167 } | 1080 } | 
| 1168 | 1081 | 
| 1169 CSSRuleList* StyleResolver::cssRulesForElement(Element* element, | 1082 CSSRuleList* StyleResolver::cssRulesForElement(Element* element, | 
| 1170                                                unsigned rulesToInclude) { | 1083                                                unsigned rulesToInclude) { | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 1184   if (rulesToInclude & AuthorCSSRules) { | 1097   if (rulesToInclude & AuthorCSSRules) { | 
| 1185     collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); | 1098     collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); | 
| 1186     collector.setIncludeEmptyRules(rulesToInclude & EmptyCSSRules); | 1099     collector.setIncludeEmptyRules(rulesToInclude & EmptyCSSRules); | 
| 1187     matchAuthorRules(element, collector); | 1100     matchAuthorRules(element, collector); | 
| 1188   } | 1101   } | 
| 1189 } | 1102 } | 
| 1190 | 1103 | 
| 1191 bool StyleResolver::applyAnimatedProperties(StyleResolverState& state, | 1104 bool StyleResolver::applyAnimatedProperties(StyleResolverState& state, | 
| 1192                                             const Element* animatingElement) { | 1105                                             const Element* animatingElement) { | 
| 1193   Element* element = state.element(); | 1106   Element* element = state.element(); | 
| 1194   ASSERT(element); | 1107   DCHECK(element); | 
| 1195 | 1108 | 
| 1196   // The animating element may be this element, or its pseudo element. It is | 1109   // The animating element may be this element, or its pseudo element. It is | 
| 1197   // null when calculating the style for a potential pseudo element that has | 1110   // null when calculating the style for a potential pseudo element that has | 
| 1198   // yet to be created. | 1111   // yet to be created. | 
| 1199   ASSERT(animatingElement == element || !animatingElement || | 1112   DCHECK(animatingElement == element || !animatingElement || | 
| 1200          animatingElement->parentOrShadowHostElement() == element); | 1113          animatingElement->parentOrShadowHostElement() == element); | 
| 1201 | 1114 | 
| 1202   if (!(animatingElement && animatingElement->hasAnimations()) && | 1115   if (!(animatingElement && animatingElement->hasAnimations()) && | 
| 1203       !state.style()->transitions() && !state.style()->animations()) | 1116       !state.style()->transitions() && !state.style()->animations()) | 
| 1204     return false; | 1117     return false; | 
| 1205 | 1118 | 
| 1206   CSSAnimations::calculateUpdate(animatingElement, *element, *state.style(), | 1119   CSSAnimations::calculateUpdate(animatingElement, *element, *state.style(), | 
| 1207                                  state.parentStyle(), state.animationUpdate(), | 1120                                  state.parentStyle(), state.animationUpdate(), | 
| 1208                                  this); | 1121                                  this); | 
| 1209 | 1122 | 
| 1210   CSSAnimations::snapshotCompositorKeyframes( | 1123   CSSAnimations::snapshotCompositorKeyframes( | 
| 1211       *element, state.animationUpdate(), *state.style(), state.parentStyle()); | 1124       *element, state.animationUpdate(), *state.style(), state.parentStyle()); | 
| 1212 | 1125 | 
| 1213   if (state.animationUpdate().isEmpty()) | 1126   if (state.animationUpdate().isEmpty()) | 
| 1214     return false; | 1127     return false; | 
| 1215 | 1128 | 
| 1216   if (state.style()->insideLink() != NotInsideLink) { | 1129   if (state.style()->insideLink() != NotInsideLink) { | 
| 1217     ASSERT(state.applyPropertyToRegularStyle()); | 1130     DCHECK(state.applyPropertyToRegularStyle()); | 
| 1218     state.setApplyPropertyToVisitedLinkStyle(true); | 1131     state.setApplyPropertyToVisitedLinkStyle(true); | 
| 1219   } | 1132   } | 
| 1220 | 1133 | 
| 1221   const ActiveInterpolationsMap& activeInterpolationsMapForAnimations = | 1134   const ActiveInterpolationsMap& activeInterpolationsMapForAnimations = | 
| 1222       state.animationUpdate().activeInterpolationsForAnimations(); | 1135       state.animationUpdate().activeInterpolationsForAnimations(); | 
| 1223   const ActiveInterpolationsMap& activeInterpolationsMapForTransitions = | 1136   const ActiveInterpolationsMap& activeInterpolationsMapForTransitions = | 
| 1224       state.animationUpdate().activeInterpolationsForTransitions(); | 1137       state.animationUpdate().activeInterpolationsForTransitions(); | 
| 1225   // TODO(crbug.com/644148): Apply animations on custom properties. | 1138   // TODO(crbug.com/644148): Apply animations on custom properties. | 
| 1226   applyAnimatedProperties<HighPropertyPriority>( | 1139   applyAnimatedProperties<HighPropertyPriority>( | 
| 1227       state, activeInterpolationsMapForAnimations); | 1140       state, activeInterpolationsMapForAnimations); | 
| 1228   applyAnimatedProperties<HighPropertyPriority>( | 1141   applyAnimatedProperties<HighPropertyPriority>( | 
| 1229       state, activeInterpolationsMapForTransitions); | 1142       state, activeInterpolationsMapForTransitions); | 
| 1230 | 1143 | 
| 1231   updateFont(state); | 1144   updateFont(state); | 
| 1232 | 1145 | 
| 1233   applyAnimatedProperties<LowPropertyPriority>( | 1146   applyAnimatedProperties<LowPropertyPriority>( | 
| 1234       state, activeInterpolationsMapForAnimations); | 1147       state, activeInterpolationsMapForAnimations); | 
| 1235   applyAnimatedProperties<LowPropertyPriority>( | 1148   applyAnimatedProperties<LowPropertyPriority>( | 
| 1236       state, activeInterpolationsMapForTransitions); | 1149       state, activeInterpolationsMapForTransitions); | 
| 1237 | 1150 | 
| 1238   // Start loading resources used by animations. | 1151   // Start loading resources used by animations. | 
| 1239   loadPendingResources(state); | 1152   loadPendingResources(state); | 
| 1240 | 1153 | 
| 1241   ASSERT(!state.fontBuilder().fontDirty()); | 1154   DCHECK(!state.fontBuilder().fontDirty()); | 
| 1242 | 1155 | 
| 1243   state.setApplyPropertyToVisitedLinkStyle(false); | 1156   state.setApplyPropertyToVisitedLinkStyle(false); | 
| 1244 | 1157 | 
| 1245   return true; | 1158   return true; | 
| 1246 } | 1159 } | 
| 1247 | 1160 | 
| 1248 StyleRuleKeyframes* StyleResolver::findKeyframesRule( | 1161 StyleRuleKeyframes* StyleResolver::findKeyframesRule( | 
| 1249     const Element* element, | 1162     const Element* element, | 
| 1250     const AtomicString& animationName) { | 1163     const AtomicString& animationName) { | 
| 1251   HeapVector<Member<ScopedStyleResolver>, 8> resolvers; | 1164   HeapVector<Member<ScopedStyleResolver>, 8> resolvers; | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1429     case CSSPropertyWebkitMarginBefore: | 1342     case CSSPropertyWebkitMarginBefore: | 
| 1430     case CSSPropertyWebkitMarginBeforeCollapse: | 1343     case CSSPropertyWebkitMarginBeforeCollapse: | 
| 1431     case CSSPropertyWebkitMarginBottomCollapse: | 1344     case CSSPropertyWebkitMarginBottomCollapse: | 
| 1432     case CSSPropertyWebkitMarginCollapse: | 1345     case CSSPropertyWebkitMarginCollapse: | 
| 1433     case CSSPropertyWebkitMarginEnd: | 1346     case CSSPropertyWebkitMarginEnd: | 
| 1434     case CSSPropertyWebkitMarginStart: | 1347     case CSSPropertyWebkitMarginStart: | 
| 1435     case CSSPropertyWebkitMarginTopCollapse: | 1348     case CSSPropertyWebkitMarginTopCollapse: | 
| 1436     case CSSPropertyWordSpacing: | 1349     case CSSPropertyWordSpacing: | 
| 1437       return true; | 1350       return true; | 
| 1438     case CSSPropertyTextDecoration: | 1351     case CSSPropertyTextDecoration: | 
| 1439       ASSERT(!RuntimeEnabledFeatures::css3TextDecorationsEnabled()); | 1352       DCHECK(!RuntimeEnabledFeatures::css3TextDecorationsEnabled()); | 
| 1440       return true; | 1353       return true; | 
| 1441     case CSSPropertyTextDecorationColor: | 1354     case CSSPropertyTextDecorationColor: | 
| 1442     case CSSPropertyTextDecorationLine: | 1355     case CSSPropertyTextDecorationLine: | 
| 1443     case CSSPropertyTextDecorationStyle: | 1356     case CSSPropertyTextDecorationStyle: | 
| 1444     case CSSPropertyTextDecorationSkip: | 1357     case CSSPropertyTextDecorationSkip: | 
| 1445       ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); | 1358       DCHECK(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); | 
| 1446       return true; | 1359       return true; | 
| 1447 | 1360 | 
| 1448     // text-shadow added in text decoration spec: | 1361     // text-shadow added in text decoration spec: | 
| 1449     // http://www.w3.org/TR/css-text-decor-3/#text-shadow-property | 1362     // http://www.w3.org/TR/css-text-decor-3/#text-shadow-property | 
| 1450     case CSSPropertyTextShadow: | 1363     case CSSPropertyTextShadow: | 
| 1451     // box-shadox added in CSS3 backgrounds spec: | 1364     // box-shadox added in CSS3 backgrounds spec: | 
| 1452     // http://www.w3.org/TR/css3-background/#placement | 1365     // http://www.w3.org/TR/css3-background/#placement | 
| 1453     case CSSPropertyBoxShadow: | 1366     case CSSPropertyBoxShadow: | 
| 1454     // Properties that we currently support outside of spec. | 1367     // Properties that we currently support outside of spec. | 
| 1455     case CSSPropertyVisibility: | 1368     case CSSPropertyVisibility: | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 1484   if (propertyWhitelistType == PropertyWhitelistNone) | 1397   if (propertyWhitelistType == PropertyWhitelistNone) | 
| 1485     return true;  // Early bail for the by far most common case. | 1398     return true;  // Early bail for the by far most common case. | 
| 1486 | 1399 | 
| 1487   if (propertyWhitelistType == PropertyWhitelistFirstLetter) | 1400   if (propertyWhitelistType == PropertyWhitelistFirstLetter) | 
| 1488     return isValidFirstLetterStyleProperty(property); | 1401     return isValidFirstLetterStyleProperty(property); | 
| 1489 | 1402 | 
| 1490   if (propertyWhitelistType == PropertyWhitelistCue) | 1403   if (propertyWhitelistType == PropertyWhitelistCue) | 
| 1491     return isValidCueStyleProperty(property) && | 1404     return isValidCueStyleProperty(property) && | 
| 1492            !shouldIgnoreTextTrackAuthorStyle(document); | 1405            !shouldIgnoreTextTrackAuthorStyle(document); | 
| 1493 | 1406 | 
| 1494   ASSERT_NOT_REACHED(); | 1407   NOTREACHED(); | 
| 1495   return true; | 1408   return true; | 
| 1496 } | 1409 } | 
| 1497 | 1410 | 
| 1498 // This method expands the 'all' shorthand property to longhand properties | 1411 // This method expands the 'all' shorthand property to longhand properties | 
| 1499 // and applies the expanded longhand properties. | 1412 // and applies the expanded longhand properties. | 
| 1500 template <CSSPropertyPriority priority> | 1413 template <CSSPropertyPriority priority> | 
| 1501 void StyleResolver::applyAllProperty( | 1414 void StyleResolver::applyAllProperty( | 
| 1502     StyleResolverState& state, | 1415     StyleResolverState& state, | 
| 1503     const CSSValue& allValue, | 1416     const CSSValue& allValue, | 
| 1504     bool inheritedOnly, | 1417     bool inheritedOnly, | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1648   m_matchedPropertiesCache.clear(); | 1561   m_matchedPropertiesCache.clear(); | 
| 1649 } | 1562 } | 
| 1650 | 1563 | 
| 1651 void StyleResolver::notifyResizeForViewportUnits() { | 1564 void StyleResolver::notifyResizeForViewportUnits() { | 
| 1652   m_matchedPropertiesCache.clearViewportDependent(); | 1565   m_matchedPropertiesCache.clearViewportDependent(); | 
| 1653 } | 1566 } | 
| 1654 | 1567 | 
| 1655 void StyleResolver::applyMatchedProperties(StyleResolverState& state, | 1568 void StyleResolver::applyMatchedProperties(StyleResolverState& state, | 
| 1656                                            const MatchResult& matchResult) { | 1569                                            const MatchResult& matchResult) { | 
| 1657   const Element* element = state.element(); | 1570   const Element* element = state.element(); | 
| 1658   ASSERT(element); | 1571   DCHECK(element); | 
| 1659 | 1572 | 
| 1660   INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), matchedPropertyApply, | 1573   INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), matchedPropertyApply, | 
| 1661                                 1); | 1574                                 1); | 
| 1662 | 1575 | 
| 1663   unsigned cacheHash = | 1576   unsigned cacheHash = | 
| 1664       RuntimeEnabledFeatures::styleMatchedPropertiesCacheEnabled() && | 1577       RuntimeEnabledFeatures::styleMatchedPropertiesCacheEnabled() && | 
| 1665               matchResult.isCacheable() | 1578               matchResult.isCacheable() | 
| 1666           ? computeMatchedPropertiesHash(matchResult.matchedProperties().data(), | 1579           ? computeMatchedPropertiesHash(matchResult.matchedProperties().data(), | 
| 1667                                          matchResult.matchedProperties().size()) | 1580                                          matchResult.matchedProperties().size()) | 
| 1668           : 0; | 1581           : 0; | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1799     // cacheUserAgentBorderAndBackground is incorrect, so doing this check again | 1712     // cacheUserAgentBorderAndBackground is incorrect, so doing this check again | 
| 1800     // would give the wrong answer. | 1713     // would give the wrong answer. | 
| 1801     state.style()->setHasAuthorBackground(hasAuthorBackground(state)); | 1714     state.style()->setHasAuthorBackground(hasAuthorBackground(state)); | 
| 1802     state.style()->setHasAuthorBorder(hasAuthorBorder(state)); | 1715     state.style()->setHasAuthorBorder(hasAuthorBorder(state)); | 
| 1803   } | 1716   } | 
| 1804 | 1717 | 
| 1805   loadPendingResources(state); | 1718   loadPendingResources(state); | 
| 1806 | 1719 | 
| 1807   if (!cachedMatchedProperties && cacheHash && | 1720   if (!cachedMatchedProperties && cacheHash && | 
| 1808       MatchedPropertiesCache::isCacheable(state)) { | 1721       MatchedPropertiesCache::isCacheable(state)) { | 
| 1809     ASSERT(RuntimeEnabledFeatures::styleMatchedPropertiesCacheEnabled()); | 1722     DCHECK(RuntimeEnabledFeatures::styleMatchedPropertiesCacheEnabled()); | 
| 1810     INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), | 1723     INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), | 
| 1811                                   matchedPropertyCacheAdded, 1); | 1724                                   matchedPropertyCacheAdded, 1); | 
| 1812     m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), | 1725     m_matchedPropertiesCache.add(*state.style(), *state.parentStyle(), | 
| 1813                                  cacheHash, matchResult.matchedProperties()); | 1726                                  cacheHash, matchResult.matchedProperties()); | 
| 1814   } | 1727   } | 
| 1815 | 1728 | 
| 1816   ASSERT(!state.fontBuilder().fontDirty()); | 1729   DCHECK(!state.fontBuilder().fontDirty()); | 
| 1817 } | 1730 } | 
| 1818 | 1731 | 
| 1819 bool StyleResolver::hasAuthorBackground(const StyleResolverState& state) { | 1732 bool StyleResolver::hasAuthorBackground(const StyleResolverState& state) { | 
| 1820   const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | 1733   const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | 
| 1821   if (!cachedUAStyle) | 1734   if (!cachedUAStyle) | 
| 1822     return false; | 1735     return false; | 
| 1823 | 1736 | 
| 1824   FillLayer oldFill = cachedUAStyle->backgroundLayers; | 1737   FillLayer oldFill = cachedUAStyle->backgroundLayers; | 
| 1825   FillLayer newFill = state.style()->backgroundLayers(); | 1738   FillLayer newFill = state.style()->backgroundLayers(); | 
| 1826   // Exclude background-repeat from comparison by resetting it. | 1739   // Exclude background-repeat from comparison by resetting it. | 
| 1827   oldFill.setRepeatX(NoRepeatFill); | 1740   oldFill.setRepeatX(NoRepeatFill); | 
| 1828   oldFill.setRepeatY(NoRepeatFill); | 1741   oldFill.setRepeatY(NoRepeatFill); | 
| 1829   newFill.setRepeatX(NoRepeatFill); | 1742   newFill.setRepeatX(NoRepeatFill); | 
| 1830   newFill.setRepeatY(NoRepeatFill); | 1743   newFill.setRepeatY(NoRepeatFill); | 
| 1831 | 1744 | 
| 1832   return (oldFill != newFill || | 1745   return (oldFill != newFill || | 
| 1833           cachedUAStyle->backgroundColor != state.style()->backgroundColor()); | 1746           cachedUAStyle->backgroundColor != state.style()->backgroundColor()); | 
| 1834 } | 1747 } | 
| 1835 | 1748 | 
| 1836 bool StyleResolver::hasAuthorBorder(const StyleResolverState& state) { | 1749 bool StyleResolver::hasAuthorBorder(const StyleResolverState& state) { | 
| 1837   const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | 1750   const CachedUAStyle* cachedUAStyle = state.cachedUAStyle(); | 
| 1838   return cachedUAStyle && (cachedUAStyle->border != state.style()->border()); | 1751   return cachedUAStyle && (cachedUAStyle->border != state.style()->border()); | 
| 1839 } | 1752 } | 
| 1840 | 1753 | 
| 1841 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) { | 1754 void StyleResolver::applyCallbackSelectors(StyleResolverState& state) { | 
| 1842   if (!m_watchedSelectorsRules) | 1755   RuleSet* watchedSelectorsRuleSet = | 
|  | 1756       document().styleEngine().watchedSelectorsRuleSet(); | 
|  | 1757   if (!watchedSelectorsRuleSet) | 
| 1843     return; | 1758     return; | 
| 1844 | 1759 | 
| 1845   ElementRuleCollector collector(state.elementContext(), m_selectorFilter, | 1760   ElementRuleCollector collector(state.elementContext(), m_selectorFilter, | 
| 1846                                  state.style()); | 1761                                  state.style()); | 
| 1847   collector.setMode(SelectorChecker::CollectingStyleRules); | 1762   collector.setMode(SelectorChecker::CollectingStyleRules); | 
| 1848   collector.setIncludeEmptyRules(true); | 1763   collector.setIncludeEmptyRules(true); | 
| 1849 | 1764 | 
| 1850   MatchRequest matchRequest(m_watchedSelectorsRules.get()); | 1765   MatchRequest matchRequest(watchedSelectorsRuleSet); | 
| 1851   collector.collectMatchingRules(matchRequest); | 1766   collector.collectMatchingRules(matchRequest); | 
| 1852   collector.sortAndTransferMatchedRules(); | 1767   collector.sortAndTransferMatchedRules(); | 
| 1853 | 1768 | 
| 1854   StyleRuleList* rules = collector.matchedStyleRuleList(); | 1769   StyleRuleList* rules = collector.matchedStyleRuleList(); | 
| 1855   if (!rules) | 1770   if (!rules) | 
| 1856     return; | 1771     return; | 
| 1857   for (size_t i = 0; i < rules->size(); i++) | 1772   for (size_t i = 0; i < rules->size(); i++) | 
| 1858     state.style()->addCallbackSelector( | 1773     state.style()->addCallbackSelector( | 
| 1859         rules->at(i)->selectorList().selectorsText()); | 1774         rules->at(i)->selectorList().selectorsText()); | 
| 1860 } | 1775 } | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1908   } | 1823   } | 
| 1909   return false; | 1824   return false; | 
| 1910 } | 1825 } | 
| 1911 | 1826 | 
| 1912 DEFINE_TRACE(StyleResolver) { | 1827 DEFINE_TRACE(StyleResolver) { | 
| 1913   visitor->trace(m_matchedPropertiesCache); | 1828   visitor->trace(m_matchedPropertiesCache); | 
| 1914   visitor->trace(m_medium); | 1829   visitor->trace(m_medium); | 
| 1915   visitor->trace(m_viewportDependentMediaQueryResults); | 1830   visitor->trace(m_viewportDependentMediaQueryResults); | 
| 1916   visitor->trace(m_deviceDependentMediaQueryResults); | 1831   visitor->trace(m_deviceDependentMediaQueryResults); | 
| 1917   visitor->trace(m_selectorFilter); | 1832   visitor->trace(m_selectorFilter); | 
| 1918   visitor->trace(m_features); |  | 
| 1919   visitor->trace(m_siblingRuleSet); |  | 
| 1920   visitor->trace(m_uncommonAttributeRuleSet); |  | 
| 1921   visitor->trace(m_watchedSelectorsRules); |  | 
| 1922   visitor->trace(m_styleSharingLists); | 1833   visitor->trace(m_styleSharingLists); | 
| 1923   visitor->trace(m_pendingStyleSheets); | 1834   visitor->trace(m_pendingStyleSheets); | 
| 1924   visitor->trace(m_document); | 1835   visitor->trace(m_document); | 
| 1925 } | 1836 } | 
| 1926 | 1837 | 
| 1927 }  // namespace blink | 1838 }  // namespace blink | 
| OLD | NEW | 
|---|