Changeset 163475 in webkit
- Timestamp:
- Feb 5, 2014 1:50:55 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r163469 r163475 1 2014-02-05 Antti Koivisto <antti@apple.com> 2 3 ElementRuleCollector should not use StyleResolver::State 4 https://bugs.webkit.org/show_bug.cgi?id=128247 5 6 Reviewed by Andreas Kling. 7 8 * platform/mac/fast/parser/xhtml-alternate-entities-expected.png: 9 * platform/mac/fast/parser/xhtml-alternate-entities-expected.txt: This is a progression. 10 1 11 2014-02-05 Yuki Sekiguchi <yuki.sekiguchi@access-company.com> 2 12 -
trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.txt
r161884 r163475 19 19 RenderText {#text} at (0,0) size 0x0 20 20 RenderText {#text} at (0,0) size 0x0 21 RenderInline {p} at (0,0) size 489x18 21 RenderInline {p} at (0,0) size 489x18 [color=#FF0000] 22 22 RenderInline {font} at (0,0) size 489x18 23 23 RenderText {#text} at (0,0) size 489x18 -
trunk/Source/WebCore/ChangeLog
r163472 r163475 1 2014-02-05 Antti Koivisto <antti@apple.com> 2 3 ElementRuleCollector should not use StyleResolver::State 4 https://bugs.webkit.org/show_bug.cgi?id=128247 5 6 Reviewed by Andreas Kling. 7 8 Make ElementRuleCollector more reusable. 9 10 * css/ElementRuleCollector.cpp: 11 (WebCore::ElementRuleCollector::collectMatchingRules): 12 (WebCore::ElementRuleCollector::sortAndTransferMatchedRules): 13 (WebCore::ElementRuleCollector::matchAuthorRules): 14 (WebCore::ElementRuleCollector::matchUARules): 15 (WebCore::ElementRuleCollector::ruleMatches): 16 (WebCore::ElementRuleCollector::collectMatchingRulesForList): 17 (WebCore::ElementRuleCollector::matchAllRules): 18 * css/ElementRuleCollector.h: 19 (WebCore::ElementRuleCollector::ElementRuleCollector): 20 21 Pass the objects that are actually needed rather than the entire State. 22 1 23 2014-02-05 Brent Fulgham <bfulgham@apple.com> 2 24 -
trunk/Source/WebCore/css/ElementRuleCollector.cpp
r163440 r163475 3 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 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, 2014 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> … … 146 146 { 147 147 ASSERT(matchRequest.ruleSet); 148 ASSERT(m_state.element()); 149 150 const StyleResolver::State& state = m_state; 151 Element* element = state.element(); 152 const StyledElement* styledElement = state.styledElement(); 153 const AtomicString& pseudoId = element->shadowPseudoId(); 154 if (!pseudoId.isEmpty()) { 155 ASSERT(styledElement); 148 149 const AtomicString& pseudoId = m_element.shadowPseudoId(); 150 if (!pseudoId.isEmpty()) 156 151 collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange); 157 }158 152 159 153 #if ENABLE(VIDEO_TRACK) 160 if ( element->isWebVTTElement())154 if (m_element.isWebVTTElement()) 161 155 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange); 162 156 #endif … … 166 160 // c) the rules comes from a scoped style sheet within the same tree scope 167 161 if (!MatchingUARulesScope::isMatchingUARules() 168 && ! element->treeScope().applyAuthorStyles())162 && !m_element.treeScope().applyAuthorStyles()) 169 163 return; 170 164 171 165 // We need to collect the rules for id, class, tag, and everything else into a buffer and 172 166 // then sort the buffer. 173 if ( element->hasID())174 collectMatchingRulesForList(matchRequest.ruleSet->idRules( element->idForStyleResolution().impl()), matchRequest, ruleRange);175 if ( styledElement && styledElement->hasClass()) {176 for (size_t i = 0; i < styledElement->classNames().size(); ++i)177 collectMatchingRulesForList(matchRequest.ruleSet->classRules( styledElement->classNames()[i].impl()), matchRequest, ruleRange);178 } 179 180 if ( element->isLink())167 if (m_element.hasID()) 168 collectMatchingRulesForList(matchRequest.ruleSet->idRules(m_element.idForStyleResolution().impl()), matchRequest, ruleRange); 169 if (m_element.hasClass()) { 170 for (size_t i = 0; i < m_element.classNames().size(); ++i) 171 collectMatchingRulesForList(matchRequest.ruleSet->classRules(m_element.classNames()[i].impl()), matchRequest, ruleRange); 172 } 173 174 if (m_element.isLink()) 181 175 collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, ruleRange); 182 if (SelectorChecker::matchesFocusPseudoClass( element))176 if (SelectorChecker::matchesFocusPseudoClass(&m_element)) 183 177 collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, ruleRange); 184 collectMatchingRulesForList(matchRequest.ruleSet->tagRules( element->localName().impl()), matchRequest, ruleRange);178 collectMatchingRulesForList(matchRequest.ruleSet->tagRules(m_element.localName().impl()), matchRequest, ruleRange); 185 179 collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest, ruleRange); 186 180 } … … 204 198 void ElementRuleCollector::sortAndTransferMatchedRules() 205 199 { 206 const StyleResolver::State& state = m_state;207 208 200 if (!m_matchedRules || m_matchedRules->isEmpty()) 209 201 return; … … 220 212 // Now transfer the set of matched rules over to our list of declarations. 221 213 for (unsigned i = 0; i < matchedRules.size(); i++) { 222 if ( state.style()&& matchedRules[i]->containsUncommonAttributeSelector())223 state.style()->setUnique();214 if (m_style && matchedRules[i]->containsUncommonAttributeSelector()) 215 m_style->setUnique(); 224 216 m_result.addMatchedProperties(matchedRules[i]->rule()->properties(), matchedRules[i]->rule(), matchedRules[i]->linkMatchType(), matchedRules[i]->propertyWhitelistType(MatchingUARulesScope::isMatchingUARules())); 225 217 } … … 230 222 clearMatchedRules(); 231 223 m_result.ranges.lastAuthorRule = m_result.matchedProperties.size() - 1; 232 233 if (!m_state.element())234 return;235 224 236 225 // Match global author rules. … … 271 260 272 261 // In quirks mode, we match rules from the quirks user agent sheet. 273 if ( document().inQuirksMode())262 if (m_element.document().inQuirksMode()) 274 263 matchUARules(CSSDefaultStyleSheets::defaultQuirksStyle); 275 264 276 265 // 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. 277 if ( document().isViewSource())266 if (m_element.document().isViewSource()) 278 267 matchUARules(CSSDefaultStyleSheets::viewSourceStyle()); 279 268 } … … 292 281 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, PseudoId& dynamicPseudo) 293 282 { 294 const StyleResolver::State& state = m_state;295 296 283 bool fastCheckableSelector = ruleData.hasFastCheckableSelector(); 297 284 if (fastCheckableSelector) { … … 301 288 // We know a sufficiently simple single part selector matches simply because we found it from the rule hash. 302 289 // This is limited to HTML only so we don't need to check the namespace. 303 if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && state.element()->isHTMLElement()) {290 if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && m_element.isHTMLElement()) { 304 291 if (!ruleData.hasMultipartSelector()) 305 292 return true; … … 310 297 void* compiledSelectorChecker = ruleData.compiledSelectorCodeRef().code().executableAddress(); 311 298 if (!compiledSelectorChecker && ruleData.compilationStatus() == SelectorCompilationStatus::NotCompiled) { 312 JSC::VM* vm = document().scriptExecutionContext()->vm();299 JSC::VM* vm = m_element.document().scriptExecutionContext()->vm(); 313 300 SelectorCompilationStatus compilationStatus; 314 301 JSC::MacroAssemblerCodeRef compiledSelectorCodeRef; … … 324 311 if (ruleData.compilationStatus() == SelectorCompilationStatus::SimpleSelectorChecker) { 325 312 SelectorCompiler::SimpleSelectorChecker selectorChecker = SelectorCompiler::simpleSelectorCheckerFunction(compiledSelectorChecker, ruleData.compilationStatus()); 326 return selectorChecker( state.element());313 return selectorChecker(&m_element); 327 314 } 328 315 ASSERT(ruleData.compilationStatus() == SelectorCompilationStatus::SelectorCheckerWithCheckingContext); … … 330 317 SelectorCompiler::SelectorCheckerWithCheckingContext selectorChecker = SelectorCompiler::selectorCheckerFunctionWithCheckingContext(compiledSelectorChecker, ruleData.compilationStatus()); 331 318 SelectorCompiler::CheckingContext context; 332 context.elementStyle = state.style();319 context.elementStyle = m_style; 333 320 context.resolvingMode = m_mode; 334 return selectorChecker( state.element(), &context);321 return selectorChecker(&m_element, &context); 335 322 } 336 323 #endif // ENABLE(CSS_SELECTOR_JIT) 337 324 338 325 if (fastCheckableSelector) { 339 if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches( state.element(), ruleData.selector()->tagQName()))326 if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(&m_element, ruleData.selector()->tagQName())) 340 327 return false; 341 SelectorCheckerFastPath selectorCheckerFastPath(ruleData.selector(), state.element());328 SelectorCheckerFastPath selectorCheckerFastPath(ruleData.selector(), &m_element); 342 329 if (!selectorCheckerFastPath.matchesRightmostAttributeSelector()) 343 330 return false; … … 347 334 348 335 // Slow path. 349 SelectorChecker selectorChecker( document(), m_mode);350 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.element(), SelectorChecker::VisitedMatchEnabled);351 context.elementStyle = state.style();336 SelectorChecker selectorChecker(m_element.document(), m_mode); 337 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), &m_element, SelectorChecker::VisitedMatchEnabled); 338 context.elementStyle = m_style; 352 339 context.pseudoId = m_pseudoStyleRequest.pseudoId; 353 340 context.scrollbar = m_pseudoStyleRequest.scrollbar; … … 364 351 if (!rules) 365 352 return; 366 367 const StyleResolver::State& state = m_state;368 353 369 354 for (unsigned i = 0, size = rules->size(); i < size; ++i) { … … 393 378 if (m_mode == SelectorChecker::CollectingRules) 394 379 continue; 395 if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID )396 state.style()->setHasPseudoStyle(dynamicPseudo);380 if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID && m_style) 381 m_style->setHasPseudoStyle(dynamicPseudo); 397 382 } else { 398 383 // Update our first/last rule indices in the matched rules array. … … 431 416 432 417 // Now check author rules, beginning first with presentational attributes mapped from HTML. 433 if (m_state.styledElement()) { 434 addElementStyleProperties(m_state.styledElement()->presentationAttributeStyle()); 418 if (m_element.isStyledElement()) { 419 StyledElement& styledElement = toStyledElement(m_element); 420 addElementStyleProperties(styledElement.presentationAttributeStyle()); 435 421 436 422 // Now we check additional mapped declarations. 437 423 // Tables and table cells share an additional mapped rule that must be applied 438 424 // after all attributes, since their mapped style depends on the values of multiple attributes. 439 addElementStyleProperties( m_state.styledElement()->additionalPresentationAttributeStyle());440 441 if ( m_state.styledElement()->isHTMLElement()) {425 addElementStyleProperties(styledElement.additionalPresentationAttributeStyle()); 426 427 if (styledElement.isHTMLElement()) { 442 428 bool isAuto; 443 TextDirection textDirection = toHTMLElement( m_state.styledElement())->directionalityIfhasDirAutoAttribute(isAuto);429 TextDirection textDirection = toHTMLElement(styledElement).directionalityIfhasDirAutoAttribute(isAuto); 444 430 if (isAuto) 445 431 m_result.addMatchedProperties(textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration()); … … 451 437 matchAuthorRules(false); 452 438 453 // Now check our inline style attribute. 454 if (matchAuthorAndUserStyles && m_state.styledElement() && m_state.styledElement()->inlineStyle()) { 455 // Inline style is immutable as long as there is no CSSOM wrapper. 456 // FIXME: Media control shadow trees seem to have problems with caching. 457 bool isInlineStyleCacheable = !m_state.styledElement()->inlineStyle()->isMutable() && !m_state.styledElement()->isInShadowTree(); 458 // FIXME: Constify. 459 addElementStyleProperties(m_state.styledElement()->inlineStyle(), isInlineStyleCacheable); 460 } 461 462 // Now check SMIL animation override style. 463 if (includeSMILProperties && matchAuthorAndUserStyles && m_state.styledElement() && m_state.styledElement()->isSVGElement()) 464 addElementStyleProperties(toSVGElement(m_state.styledElement())->animatedSMILStyleProperties(), false /* isCacheable */); 439 if (matchAuthorAndUserStyles && m_element.isStyledElement()) { 440 StyledElement& styledElement = toStyledElement(m_element); 441 // Now check our inline style attribute. 442 if (styledElement.inlineStyle()) { 443 // Inline style is immutable as long as there is no CSSOM wrapper. 444 // FIXME: Media control shadow trees seem to have problems with caching. 445 bool isInlineStyleCacheable = !styledElement.inlineStyle()->isMutable() && !styledElement.isInShadowTree(); 446 // FIXME: Constify. 447 addElementStyleProperties(styledElement.inlineStyle(), isInlineStyleCacheable); 448 } 449 450 // Now check SMIL animation override style. 451 if (includeSMILProperties && styledElement.isSVGElement()) 452 addElementStyleProperties(toSVGElement(styledElement).animatedSMILStyleProperties(), false /* isCacheable */); 453 } 465 454 } 466 455 -
trunk/Source/WebCore/css/ElementRuleCollector.h
r163263 r163475 1 1 /* 2 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Apple Inc. All rights reserved.3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 41 41 class ElementRuleCollector { 42 42 public: 43 ElementRuleCollector(StyleResolver* styleResolver, const StyleResolver::State& state) 44 : m_state(state) 45 , m_ruleSets(styleResolver->ruleSets()) 46 , m_selectorFilter(styleResolver->selectorFilter()) 43 ElementRuleCollector(Element& element, RenderStyle* style, const DocumentRuleSets& ruleSets, const SelectorFilter& selectorFilter) 44 : m_element(element) 45 , m_style(style) 46 , m_ruleSets(ruleSets) 47 , m_selectorFilter(selectorFilter) 47 48 , m_isPrintStyle(false) 48 49 , m_regionForStyling(0) … … 50 51 , m_sameOriginOnly(false) 51 52 , m_mode(SelectorChecker::ResolvingStyle) 52 , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent( state.parentNode()))53 , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(element.parentNode())) 53 54 { 54 55 } … … 71 72 72 73 private: 73 Document& document() { return m_state.document(); }74 74 void addElementStyleProperties(const StyleProperties*, bool isCacheable = true); 75 75 … … 87 87 void clearMatchedRules(); 88 88 89 const StyleResolver::State& m_state; 90 DocumentRuleSets& m_ruleSets; 91 SelectorFilter& m_selectorFilter; 89 Element& m_element; 90 RenderStyle* m_style; 91 const DocumentRuleSets& m_ruleSets; 92 const SelectorFilter& m_selectorFilter; 92 93 93 94 bool m_isPrintStyle; -
trunk/Source/WebCore/css/StyleResolver.cpp
r163440 r163475 487 487 return false; 488 488 489 ElementRuleCollector collector( this, m_state);489 ElementRuleCollector collector(*m_state.element(), m_state.style(), m_ruleSets, m_selectorFilter); 490 490 return collector.hasAnyMatchingRules(ruleSet); 491 491 } … … 797 797 m_ruleSets.collectFeatures(document().isViewSource()); 798 798 799 ElementRuleCollector collector( this, state);799 ElementRuleCollector collector(*element, state.style(), m_ruleSets, m_selectorFilter); 800 800 collector.setRegionForStyling(regionForStyling); 801 801 collector.setMedium(m_medium.get()); … … 940 940 } 941 941 942 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e , const PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle)942 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, const PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle) 943 943 { 944 944 ASSERT(parentStyle); 945 if (!e )945 if (!element) 946 946 return 0; 947 947 948 948 State& state = m_state; 949 949 950 initElement(e );951 952 state.initForStyleResolve(document(), e , parentStyle);950 initElement(element); 951 952 state.initForStyleResolve(document(), element, parentStyle); 953 953 954 954 if (m_state.parentStyle()) { … … 964 964 965 965 // Check UA, user and author rules. 966 ElementRuleCollector collector( this, state);966 ElementRuleCollector collector(*element, m_state.style(), m_ruleSets, m_selectorFilter); 967 967 collector.setPseudoStyleRequest(pseudoStyleRequest); 968 968 collector.setMedium(m_medium.get()); … … 979 979 state.style()->setStyleType(pseudoStyleRequest.pseudoId); 980 980 981 applyMatchedProperties(collector.matchedResult(), e );981 applyMatchedProperties(collector.matchedResult(), element); 982 982 983 983 // Clean up our style object's display and text decorations (among other fixups). … … 1453 1453 } 1454 1454 1455 Vector<RefPtr<StyleRuleBase>> StyleResolver::pseudoStyleRulesForElement(Element* e , PseudoId pseudoId, unsigned rulesToInclude)1456 { 1457 if (!e || !e->document().haveStylesheetsLoaded())1455 Vector<RefPtr<StyleRuleBase>> StyleResolver::pseudoStyleRulesForElement(Element* element, PseudoId pseudoId, unsigned rulesToInclude) 1456 { 1457 if (!element || !element->document().haveStylesheetsLoaded()) 1458 1458 return Vector<RefPtr<StyleRuleBase>>(); 1459 1459 1460 initElement(e );1461 m_state.initForStyleResolve(document(), e , 0);1462 1463 ElementRuleCollector collector( this, m_state);1460 initElement(element); 1461 m_state.initForStyleResolve(document(), element, 0); 1462 1463 ElementRuleCollector collector(*element, m_state.style(), m_ruleSets, m_selectorFilter); 1464 1464 collector.setMode(SelectorChecker::CollectingRules); 1465 1465 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId));
Note: See TracChangeset
for help on using the changeset viewer.