Changeset 252313 in webkit
- Timestamp:
- Nov 10, 2019 12:01:51 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252308 r252313 1 2019-11-10 Antti Koivisto <antti@apple.com> 2 3 Stack allocate StyleResolver state 4 https://bugs.webkit.org/show_bug.cgi?id=204053 5 6 Reviewed by Zalan Bujtas. 7 8 State is currently awkwardly a member that gets cleared. It should be stack allocated and 9 passed around where needed. 10 11 * animation/KeyframeEffect.cpp: 12 (WebCore::KeyframeEffect::updateBlendingKeyframes): 13 * css/DOMCSSRegisterCustomProperty.cpp: 14 (WebCore::DOMCSSRegisterCustomProperty::registerProperty): 15 * css/StyleResolver.cpp: 16 (WebCore::StyleResolver::builderContext): 17 18 Helper for initializing Style::Builder from resolver state. 19 20 (WebCore::StyleResolver::styleForElement): 21 (WebCore::StyleResolver::styleForKeyframe): 22 (WebCore::StyleResolver::keyframeStylesForAnimation): 23 (WebCore::StyleResolver::pseudoStyleForElement): 24 (WebCore::StyleResolver::styleForPage): 25 (WebCore::StyleResolver::defaultStyleForElement): 26 (WebCore::StyleResolver::pseudoStyleRulesForElement): 27 (WebCore::StyleResolver::applyMatchedProperties): 28 (WebCore::StyleResolver::State::clear): Deleted. 29 30 Nothing to clear, state is transient. 31 32 (WebCore::StyleResolver::setNewStateWithElement): Deleted. 33 (WebCore::StyleResolver::applyPropertyToStyle): Deleted. 34 (WebCore::StyleResolver::applyPropertyToCurrentStyle): Deleted. 35 36 Style::Builder can be used directly to apply properties instead of via these functions that require state setup. 37 38 (WebCore::StyleResolver::initializeFontStyle): Deleted. 39 * css/StyleResolver.h: 40 (WebCore::StyleResolver::inspectorCSSOMWrappers): 41 (WebCore::StyleResolver::style const): Deleted. 42 (WebCore::StyleResolver::parentStyle const): Deleted. 43 (WebCore::StyleResolver::rootElementStyle const): Deleted. 44 (WebCore::StyleResolver::element const): Deleted. 45 (WebCore::StyleResolver::state): Deleted. 46 (WebCore::StyleResolver::state const): Deleted. 47 * html/canvas/CanvasRenderingContext2D.cpp: 48 (WebCore::CanvasRenderingContext2D::setFont): 49 50 Use Style::Builder directly to apply properties. 51 52 * style/StyleBuilder.cpp: 53 (WebCore::Style::Builder::Builder): 54 55 Encapsulte immutable arguments into BuilderContext type. 56 57 (WebCore::Style::Builder::applyPropertyValue): 58 * style/StyleBuilder.h: 59 * style/StyleBuilderState.cpp: 60 (WebCore::Style::BuilderState::BuilderState): 61 (WebCore::Style::BuilderState::updateFontForZoomChange): 62 (WebCore::Style::BuilderState::updateFontForGenericFamilyChange): 63 * style/StyleBuilderState.h: 64 (WebCore::Style::BuilderState::parentStyle const): 65 (WebCore::Style::BuilderState::rootElementStyle const): 66 (WebCore::Style::BuilderState::document const): 67 (WebCore::Style::BuilderState::element const): 68 (WebCore::Style::BuilderState::parentFontDescription): 69 1 70 2019-11-09 Antti Koivisto <antti@apple.com> 2 71 -
trunk/Source/WebCore/animation/KeyframeEffect.cpp
r252253 r252313 745 745 746 746 for (auto& keyframe : m_parsedKeyframes) { 747 styleResolver.setNewStateWithElement(*m_target);748 747 KeyframeValue keyframeValue(keyframe.computedOffset, nullptr); 749 748 … … 753 752 754 753 auto keyframeRule = StyleRuleKeyframe::create(WTFMove(styleProperties)); 755 keyframeValue.setStyle(styleResolver.styleForKeyframe( &elementStyle, keyframeRule.ptr(), keyframeValue));754 keyframeValue.setStyle(styleResolver.styleForKeyframe(*m_target, &elementStyle, keyframeRule.ptr(), keyframeValue)); 756 755 keyframeList.insert(WTFMove(keyframeValue)); 757 756 } -
trunk/Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp
r252030 r252313 53 53 // We need to initialize this so that we can successfully parse computationally dependent values (like em units). 54 54 // We don't actually need the values to be accurate, since they will be rejected later anyway 55 styleResolver.applyPropertyToStyle(CSSPropertyInvalid, nullptr, styleResolver.defaultStyleForElement());55 auto style = styleResolver.defaultStyleForElement(nullptr); 56 56 57 57 HashSet<CSSPropertyID> dependencies; … … 61 61 return Exception { SyntaxError, "The given initial value must be computationally independent." }; 62 62 63 63 64 MatchResult matchResult; 64 Style::Builder dummyBuilder(styleResolver, matchResult, { }); 65 66 auto parentStyle = RenderStyle::clone(*style); 67 Style::Builder dummyBuilder(*style, { document, parentStyle }, matchResult, { }); 68 65 69 initialValue = CSSPropertyParser::parseTypedCustomPropertyValue(descriptor.name, descriptor.syntax, tokenizer.tokenRange(), dummyBuilder.state(), strictCSSParserContext()); 66 70 -
trunk/Source/WebCore/css/StyleResolver.cpp
r252308 r252313 85 85 using namespace HTMLNames; 86 86 87 inline void StyleResolver::State::clear()88 {89 m_element = nullptr;90 m_parentStyle = nullptr;91 m_ownedParentStyle = nullptr;92 m_userAgentAppearanceStyle = nullptr;93 }94 95 87 StyleResolver::StyleResolver(Document& document) 96 88 : m_ruleSets(*this) … … 174 166 } 175 167 176 StyleResolver::State::State(const Element& element, const RenderStyle* parentStyle, const RenderStyle* documentElementStyle , const SelectorFilter* selectorFilter)168 StyleResolver::State::State(const Element& element, const RenderStyle* parentStyle, const RenderStyle* documentElementStyle) 177 169 : m_element(&element) 178 170 , m_parentStyle(parentStyle) 179 , m_selectorFilter(selectorFilter)180 171 { 181 172 bool resetStyleInheritance = hasShadowRootParent(element) && downcast<ShadowRoot>(element.parentNode())->resetStyleInheritance(); … … 208 199 } 209 200 210 void StyleResolver::setNewStateWithElement(const Element& element) 211 { 212 // Apply the declaration to the style. This is a simplified version of the logic in styleForElement. 213 m_state = State(element, nullptr); 201 Style::BuilderContext StyleResolver::builderContext(const State& state) 202 { 203 return { 204 m_document, 205 *state.parentStyle(), 206 state.rootElementStyle(), 207 state.element() 208 }; 214 209 } 215 210 … … 218 213 RELEASE_ASSERT(!m_isDeleted); 219 214 220 m_state = State(element, parentStyle, m_overrideDocumentElementStyle, selectorFilter); 221 State& state = m_state; 215 auto state = State(element, parentStyle, m_overrideDocumentElementStyle); 222 216 223 217 if (state.parentStyle()) { … … 225 219 state.style()->inheritFrom(*state.parentStyle()); 226 220 } else { 227 state.setStyle(defaultStyleForElement( ));221 state.setStyle(defaultStyleForElement(&element)); 228 222 state.setParentStyle(RenderStyle::clonePtr(*state.style())); 229 223 } … … 244 238 CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(element); 245 239 246 ElementRuleCollector collector(element, m_ruleSets, m_state.selectorFilter());240 ElementRuleCollector collector(element, m_ruleSets, selectorFilter); 247 241 collector.setMedium(&m_mediaQueryEvaluator); 248 242 … … 261 255 auto elementStyleRelations = Style::commitRelationsToRenderStyle(style, element, collector.styleRelations()); 262 256 263 applyMatchedProperties( collector.matchResult(), element);257 applyMatchedProperties(state, collector.matchResult()); 264 258 265 259 Style::Adjuster adjuster(document(), *state.parentStyle(), parentBoxStyle, &element); … … 269 263 document().setHasStyleWithViewportUnits(); 270 264 271 state.clear(); // Clear out for the next resolve.272 273 265 return { state.takeStyle(), WTFMove(elementStyleRelations) }; 274 266 } 275 267 276 std::unique_ptr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* elementStyle, const StyleRuleKeyframe* keyframe, KeyframeValue& keyframeValue)268 std::unique_ptr<RenderStyle> StyleResolver::styleForKeyframe(const Element& element, const RenderStyle* elementStyle, const StyleRuleKeyframe* keyframe, KeyframeValue& keyframeValue) 277 269 { 278 270 RELEASE_ASSERT(!m_isDeleted); … … 281 273 result.authorDeclarations.append({ &keyframe->properties() }); 282 274 283 ASSERT(!m_state.style()); 284 285 State& state = m_state; 286 287 // Create the style 275 auto state = State(element, nullptr); 276 288 277 state.setStyle(RenderStyle::clonePtr(*elementStyle)); 289 278 state.setParentStyle(RenderStyle::clonePtr(*elementStyle)); 290 279 291 Style::Builder builder(* this, result, { Style::CascadeLevel::Author });280 Style::Builder builder(*state.style(), builderContext(state), result, { Style::CascadeLevel::Author }); 292 281 builder.applyAllProperties(); 293 282 … … 372 361 // Construct and populate the style for each keyframe. 373 362 for (auto& keyframe : *keyframes) { 374 setNewStateWithElement(element);375 376 363 // Add this keyframe style to all the indicated key times 377 364 for (auto key : keyframe->keys()) { 378 365 KeyframeValue keyframeValue(0, nullptr); 379 keyframeValue.setStyle(styleForKeyframe(element Style, keyframe.ptr(), keyframeValue));366 keyframeValue.setStyle(styleForKeyframe(element, elementStyle, keyframe.ptr(), keyframeValue)); 380 367 keyframeValue.setKey(key); 381 368 if (auto timingFunctionCSSValue = keyframe->properties().getPropertyCSSValue(CSSPropertyAnimationTimingFunction)) … … 394 381 } 395 382 KeyframeValue keyframeValue(0, nullptr); 396 keyframeValue.setStyle(styleForKeyframe(element Style, zeroPercentKeyframe, keyframeValue));383 keyframeValue.setStyle(styleForKeyframe(element, elementStyle, zeroPercentKeyframe, keyframeValue)); 397 384 list.insert(WTFMove(keyframeValue)); 398 385 } … … 406 393 } 407 394 KeyframeValue keyframeValue(1, nullptr); 408 keyframeValue.setStyle(styleForKeyframe(element Style, hundredPercentKeyframe, keyframeValue));395 keyframeValue.setStyle(styleForKeyframe(element, elementStyle, hundredPercentKeyframe, keyframeValue)); 409 396 list.insert(WTFMove(keyframeValue)); 410 397 } … … 413 400 std::unique_ptr<RenderStyle> StyleResolver::pseudoStyleForElement(const Element& element, const PseudoStyleRequest& pseudoStyleRequest, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const SelectorFilter* selectorFilter) 414 401 { 415 m_state = State(element, &parentStyle, m_overrideDocumentElementStyle, selectorFilter); 416 417 State& state = m_state; 418 419 if (m_state.parentStyle()) { 402 auto state = State(element, &parentStyle, m_overrideDocumentElementStyle); 403 404 if (state.parentStyle()) { 420 405 state.setStyle(RenderStyle::createPtr()); 421 state.style()->inheritFrom(* m_state.parentStyle());406 state.style()->inheritFrom(*state.parentStyle()); 422 407 } else { 423 state.setStyle(defaultStyleForElement( ));408 state.setStyle(defaultStyleForElement(&element)); 424 409 state.setParentStyle(RenderStyle::clonePtr(*state.style())); 425 410 } 426 411 427 // Since we don't use pseudo-elements in any of our quirk/print user agent rules, don't waste time walking 428 // those rules. 429 430 // Check UA, user and author rules. 431 ElementRuleCollector collector(element, m_ruleSets, m_state.selectorFilter()); 412 ElementRuleCollector collector(element, m_ruleSets, selectorFilter); 432 413 collector.setPseudoStyleRequest(pseudoStyleRequest); 433 414 collector.setMedium(&m_mediaQueryEvaluator); … … 446 427 state.style()->setStyleType(pseudoStyleRequest.pseudoId); 447 428 448 applyMatchedProperties( collector.matchResult(), element);429 applyMatchedProperties(state, collector.matchResult()); 449 430 450 431 Style::Adjuster adjuster(document(), *state.parentStyle(), parentBoxStyle, nullptr); … … 454 435 document().setHasStyleWithViewportUnits(); 455 436 456 // Now return the style.457 437 return state.takeStyle(); 458 438 } … … 466 446 return RenderStyle::createPtr(); 467 447 468 m_state = State(*documentElement, m_document.renderStyle());469 470 m_state.setStyle(RenderStyle::createPtr());471 m_state.style()->inheritFrom(*m_state.rootElementStyle());472 473 PageRuleCollector collector( m_state, m_ruleSets);448 auto state = State(*documentElement, m_document.renderStyle()); 449 450 state.setStyle(RenderStyle::createPtr()); 451 state.style()->inheritFrom(*state.rootElementStyle()); 452 453 PageRuleCollector collector(state, m_ruleSets); 474 454 collector.matchAllPageRules(pageIndex); 475 455 476 456 auto& result = collector.matchResult(); 477 457 478 Style::Builder builder(* this, result, { Style::CascadeLevel::Author });458 Style::Builder builder(*state.style(), builderContext(state), result, { Style::CascadeLevel::Author }); 479 459 builder.applyAllProperties(); 480 460 481 461 // Now return the style. 482 return m_state.takeStyle(); 483 } 484 485 std::unique_ptr<RenderStyle> StyleResolver::defaultStyleForElement() 486 { 487 m_state.setStyle(RenderStyle::createPtr()); 488 // Make sure our fonts are initialized if we don't inherit them from our parent style. 489 initializeFontStyle(); 490 m_state.style()->fontCascade().update(&document().fontSelector()); 491 return m_state.takeStyle(); 462 return state.takeStyle(); 463 } 464 465 std::unique_ptr<RenderStyle> StyleResolver::defaultStyleForElement(const Element* element) 466 { 467 auto style = RenderStyle::createPtr(); 468 469 FontCascadeDescription fontDescription; 470 fontDescription.setRenderingMode(settings().fontRenderingMode()); 471 fontDescription.setOneFamily(standardFamily); 472 fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium); 473 474 auto size = Style::fontSizeForKeyword(CSSValueMedium, false, document()); 475 fontDescription.setSpecifiedSize(size); 476 fontDescription.setComputedSize(Style::computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), is<SVGElement>(element), style.get(), document())); 477 478 fontDescription.setShouldAllowUserInstalledFonts(settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No); 479 style->setFontDescription(WTFMove(fontDescription)); 480 481 style->fontCascade().update(&document().fontSelector()); 482 483 return style; 492 484 } 493 485 … … 502 494 return { }; 503 495 504 m_state = State(*element, nullptr);505 506 ElementRuleCollector collector(*element, m_ruleSets, m_state.selectorFilter());496 auto state = State(*element, nullptr); 497 498 ElementRuleCollector collector(*element, m_ruleSets, nullptr); 507 499 collector.setMode(SelectorChecker::Mode::CollectingRules); 508 500 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); … … 547 539 } 548 540 549 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element& element, UseMatchedDeclarationsCache useMatchedDeclarationsCache) 550 { 551 State& state = m_state; 541 void StyleResolver::applyMatchedProperties(State& state, const MatchResult& matchResult, UseMatchedDeclarationsCache useMatchedDeclarationsCache) 542 { 552 543 unsigned cacheHash = useMatchedDeclarationsCache == UseMatchedDeclarationsCache::Yes ? Style::MatchedDeclarationsCache::computeHash(matchResult) : 0; 553 544 auto includedProperties = Style::PropertyCascade::IncludedProperties::All; … … 555 546 auto& style = *state.style(); 556 547 auto& parentStyle = *state.parentStyle(); 548 auto& element = *state.element(); 557 549 558 550 auto* cacheEntry = m_matchedDeclarationsCache.find(cacheHash, matchResult); … … 580 572 // can look at them later to figure out if this is a styled form control or not. 581 573 auto userAgentStyle = RenderStyle::clonePtr(style); 582 Style::Builder builder(*userAgentStyle, *this, matchResult, { Style::CascadeLevel::UserAgent });574 Style::Builder builder(*userAgentStyle, builderContext(state), matchResult, { Style::CascadeLevel::UserAgent }); 583 575 builder.applyAllProperties(); 584 576 … … 586 578 } 587 579 588 Style::Builder builder(* this, matchResult, Style::allCascadeLevels(), includedProperties);580 Style::Builder builder(*state.style(), builderContext(state), matchResult, Style::allCascadeLevels(), includedProperties); 589 581 590 582 // High priority properties may affect resolution of other properties (they are mostly font related). … … 593 585 // If the effective zoom value changes, we can't use the matched properties cache. Start over. 594 586 if (cacheEntry && cacheEntry->renderStyle->effectiveZoom() != style.effectiveZoom()) 595 return applyMatchedProperties( matchResult, element, UseMatchedDeclarationsCache::No);587 return applyMatchedProperties(state, matchResult, UseMatchedDeclarationsCache::No); 596 588 597 589 // If the font changed, we can't use the matched properties cache. Start over. 598 590 if (cacheEntry && cacheEntry->renderStyle->fontDescription() != style.fontDescription()) 599 return applyMatchedProperties( matchResult, element, UseMatchedDeclarationsCache::No);591 return applyMatchedProperties(state, matchResult, UseMatchedDeclarationsCache::No); 600 592 601 593 builder.applyLowPriorityProperties(); … … 609 601 if (Style::MatchedDeclarationsCache::isCacheable(element, style, parentStyle)) 610 602 m_matchedDeclarationsCache.add(style, parentStyle, cacheHash, matchResult); 611 }612 613 void StyleResolver::applyPropertyToStyle(CSSPropertyID id, CSSValue* value, std::unique_ptr<RenderStyle> style)614 {615 m_state = State();616 m_state.setParentStyle(RenderStyle::clonePtr(*style));617 m_state.setStyle(WTFMove(style));618 applyPropertyToCurrentStyle(id, value);619 }620 621 void StyleResolver::applyPropertyToCurrentStyle(CSSPropertyID id, CSSValue* value)622 {623 if (!value)624 return;625 626 MatchResult matchResult;627 Style::Builder builder(*this, matchResult, { });628 builder.applyPropertyValue(id, *value);629 }630 631 void StyleResolver::initializeFontStyle()632 {633 FontCascadeDescription fontDescription;634 fontDescription.setRenderingMode(settings().fontRenderingMode());635 fontDescription.setOneFamily(standardFamily);636 fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);637 638 auto size = Style::fontSizeForKeyword(CSSValueMedium, false, document());639 fontDescription.setSpecifiedSize(size);640 fontDescription.setComputedSize(Style::computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), is<SVGElement>(m_state.element()), m_state.style(), document()));641 642 fontDescription.setShouldAllowUserInstalledFonts(settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No);643 style()->setFontDescription(WTFMove(fontDescription));644 603 } 645 604 -
trunk/Source/WebCore/css/StyleResolver.h
r252308 r252313 30 30 #include "RenderStyle.h" 31 31 #include "RuleSet.h" 32 #include "StyleBuilderState.h" 32 33 #include <memory> 33 34 #include <wtf/HashMap.h> … … 113 114 114 115 std::unique_ptr<RenderStyle> styleForPage(int pageIndex); 115 std::unique_ptr<RenderStyle> defaultStyleForElement(); 116 117 RenderStyle* style() const { return m_state.style(); } 118 const RenderStyle* parentStyle() const { return m_state.parentStyle(); } 119 const RenderStyle* rootElementStyle() const { return m_state.rootElementStyle(); } 120 const Element* element() const { return m_state.element(); } 116 std::unique_ptr<RenderStyle> defaultStyleForElement(const Element*); 117 121 118 Document& document() { return m_document; } 122 119 const Document& document() const { return m_document; } … … 135 132 void addCurrentSVGFontFaceRules(); 136 133 137 void setNewStateWithElement(const Element&); 138 std::unique_ptr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleRuleKeyframe*, KeyframeValue&); 134 std::unique_ptr<RenderStyle> styleForKeyframe(const Element&, const RenderStyle*, const StyleRuleKeyframe*, KeyframeValue&); 139 135 bool isAnimationNameValid(const String&); 140 136 … … 150 146 Vector<RefPtr<StyleRule>> pseudoStyleRulesForElement(const Element*, PseudoId, unsigned rulesToInclude = AllButEmptyCSSRules); 151 147 152 void applyPropertyToStyle(CSSPropertyID, CSSValue*, std::unique_ptr<RenderStyle>);153 void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*);154 155 void initializeFontStyle();156 157 148 bool hasSelectorForId(const AtomString&) const; 158 149 bool hasSelectorForAttribute(const Element&, const AtomString&) const; … … 182 173 void clearCachedDeclarationsAffectedByViewportUnits(); 183 174 175 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; } 176 184 177 private: 185 enum class UseMatchedDeclarationsCache { Yes, No }; 186 void applyMatchedProperties(const MatchResult&, const Element&, UseMatchedDeclarationsCache = UseMatchedDeclarationsCache::Yes); 187 188 DocumentRuleSets m_ruleSets; 189 190 typedef HashMap<AtomStringImpl*, RefPtr<StyleRuleKeyframes>> KeyframesRuleMap; 191 KeyframesRuleMap m_keyframesRuleMap; 192 193 public: 178 friend class PageRuleCollector; 179 194 180 class State { 195 181 public: 196 182 State() { } 197 State(const Element&, const RenderStyle* parentStyle, const RenderStyle* documentElementStyle = nullptr , const SelectorFilter* = nullptr);183 State(const Element&, const RenderStyle* parentStyle, const RenderStyle* documentElementStyle = nullptr); 198 184 199 185 public: 200 void clear();201 202 186 const Element* element() const { return m_element; } 203 187 … … 213 197 void setUserAgentAppearanceStyle(std::unique_ptr<RenderStyle> style) { m_userAgentAppearanceStyle = WTFMove(style); } 214 198 215 const SelectorFilter* selectorFilter() const { return m_selectorFilter; }216 217 199 private: 218 200 const Element* m_element { nullptr }; 219 201 std::unique_ptr<RenderStyle> m_style; 220 202 const RenderStyle* m_parentStyle { nullptr }; 221 std::unique_ptr< RenderStyle> m_ownedParentStyle;203 std::unique_ptr<const RenderStyle> m_ownedParentStyle; 222 204 const RenderStyle* m_rootElementStyle { nullptr }; 223 224 const SelectorFilter* m_selectorFilter { nullptr };225 205 226 206 std::unique_ptr<RenderStyle> m_userAgentAppearanceStyle; 227 207 }; 228 208 229 State& state() { return m_state; } 230 const State& state() const { return m_state; } 231 232 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; } 233 234 private: 235 void cacheBorderAndBackground(); 209 Style::BuilderContext builderContext(const State&); 210 211 enum class UseMatchedDeclarationsCache { Yes, No }; 212 void applyMatchedProperties(State&, const MatchResult&, UseMatchedDeclarationsCache = UseMatchedDeclarationsCache::Yes); 213 214 DocumentRuleSets m_ruleSets; 215 216 typedef HashMap<AtomStringImpl*, RefPtr<StyleRuleKeyframes>> KeyframesRuleMap; 217 KeyframesRuleMap m_keyframesRuleMap; 236 218 237 219 MediaQueryEvaluator m_mediaQueryEvaluator; … … 251 233 252 234 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; 253 254 State m_state;255 235 256 236 Style::MatchedDeclarationsCache m_matchedDeclarationsCache; -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r251796 r252313 44 44 #include "ResourceLoadObserver.h" 45 45 #include "RuntimeEnabledFeatures.h" 46 #include "StyleBuilder.h" 46 47 #include "StyleProperties.h" 47 #include "StyleResolver.h"48 48 #include "TextMetrics.h" 49 49 #include "TextRun.h" … … 172 172 173 173 // Now map the font property longhands into the style. 174 StyleResolver& styleResolver = canvas().styleResolver(); 175 styleResolver.applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get(), WTFMove(newStyle)); 176 styleResolver.applyPropertyToCurrentStyle(CSSPropertyFontStyle, parsedStyle->getPropertyCSSValue(CSSPropertyFontStyle).get()); 177 styleResolver.applyPropertyToCurrentStyle(CSSPropertyFontVariantCaps, parsedStyle->getPropertyCSSValue(CSSPropertyFontVariantCaps).get()); 178 styleResolver.applyPropertyToCurrentStyle(CSSPropertyFontWeight, parsedStyle->getPropertyCSSValue(CSSPropertyFontWeight).get()); 179 styleResolver.applyPropertyToCurrentStyle(CSSPropertyFontSize, parsedStyle->getPropertyCSSValue(CSSPropertyFontSize).get()); 180 styleResolver.applyPropertyToCurrentStyle(CSSPropertyLineHeight, parsedStyle->getPropertyCSSValue(CSSPropertyLineHeight).get()); 181 182 modifiableState().font.initialize(document.fontSelector(), *styleResolver.style()); 174 175 MatchResult matchResult; 176 auto parentStyle = RenderStyle::clone(*newStyle); 177 WebCore::Style::Builder styleBuilder(*newStyle, { document, parentStyle }, matchResult, { }); 178 179 styleBuilder.applyPropertyValue(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get()); 180 styleBuilder.applyPropertyValue(CSSPropertyFontStyle, parsedStyle->getPropertyCSSValue(CSSPropertyFontStyle).get()); 181 styleBuilder.applyPropertyValue(CSSPropertyFontVariantCaps, parsedStyle->getPropertyCSSValue(CSSPropertyFontVariantCaps).get()); 182 styleBuilder.applyPropertyValue(CSSPropertyFontWeight, parsedStyle->getPropertyCSSValue(CSSPropertyFontWeight).get()); 183 styleBuilder.applyPropertyValue(CSSPropertyFontSize, parsedStyle->getPropertyCSSValue(CSSPropertyFontSize).get()); 184 styleBuilder.applyPropertyValue(CSSPropertyLineHeight, parsedStyle->getPropertyCSSValue(CSSPropertyLineHeight).get()); 185 186 modifiableState().font.initialize(document.fontSelector(), *newStyle); 183 187 } 184 188 -
trunk/Source/WebCore/style/PropertyCascade.h
r252030 r252313 36 36 37 37 namespace Style { 38 39 inline bool isValidVisitedLinkProperty(CSSPropertyID id)40 {41 switch (id) {42 case CSSPropertyBackgroundColor:43 case CSSPropertyBorderLeftColor:44 case CSSPropertyBorderRightColor:45 case CSSPropertyBorderTopColor:46 case CSSPropertyBorderBottomColor:47 case CSSPropertyCaretColor:48 case CSSPropertyColor:49 case CSSPropertyOutlineColor:50 case CSSPropertyColumnRuleColor:51 case CSSPropertyTextDecorationColor:52 case CSSPropertyWebkitTextEmphasisColor:53 case CSSPropertyWebkitTextFillColor:54 case CSSPropertyWebkitTextStrokeColor:55 case CSSPropertyFill:56 case CSSPropertyStroke:57 case CSSPropertyStrokeColor:58 return true;59 default:60 break;61 }62 63 return false;64 }65 38 66 39 class PropertyCascade { -
trunk/Source/WebCore/style/StyleBuilder.cpp
r252255 r252313 38 38 #include "StyleBuilderGenerated.h" 39 39 #include "StyleFontSizeFunctions.h" 40 #include "StyleResolver.h"41 40 42 41 namespace WebCore { … … 45 44 static const CSSPropertyID firstLowPriorityProperty = static_cast<CSSPropertyID>(lastHighPriorityProperty + 1); 46 45 47 staticPropertyCascade::Direction directionFromStyle(const RenderStyle& style)46 inline PropertyCascade::Direction directionFromStyle(const RenderStyle& style) 48 47 { 49 48 return { style.direction(), style.writingMode() }; 50 49 } 51 50 52 Builder::Builder(RenderStyle& style, const StyleResolver& resolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, PropertyCascade::IncludedProperties includedProperties) 51 inline bool isValidVisitedLinkProperty(CSSPropertyID id) 52 { 53 switch (id) { 54 case CSSPropertyBackgroundColor: 55 case CSSPropertyBorderLeftColor: 56 case CSSPropertyBorderRightColor: 57 case CSSPropertyBorderTopColor: 58 case CSSPropertyBorderBottomColor: 59 case CSSPropertyCaretColor: 60 case CSSPropertyColor: 61 case CSSPropertyOutlineColor: 62 case CSSPropertyColumnRuleColor: 63 case CSSPropertyTextDecorationColor: 64 case CSSPropertyWebkitTextEmphasisColor: 65 case CSSPropertyWebkitTextFillColor: 66 case CSSPropertyWebkitTextStrokeColor: 67 case CSSPropertyFill: 68 case CSSPropertyStroke: 69 case CSSPropertyStrokeColor: 70 return true; 71 default: 72 break; 73 } 74 75 return false; 76 } 77 78 Builder::Builder(RenderStyle& style, BuilderContext&& context, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, PropertyCascade::IncludedProperties includedProperties) 53 79 : m_cascade(matchResult, cascadeLevels, includedProperties, directionFromStyle(style)) 54 , m_state(*this, style, *resolver.parentStyle(), resolver.rootElementStyle(), resolver.document(), resolver.element()) 55 { 56 ASSERT(resolver.parentStyle()); 57 } 58 59 Builder::Builder(StyleResolver& resolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, PropertyCascade::IncludedProperties includedProperties) 60 : Builder(*resolver.style(), resolver, matchResult, cascadeLevels, includedProperties) 61 { 62 ASSERT(resolver.style()); 80 , m_state(*this, style, WTFMove(context)) 81 { 63 82 } 64 83 … … 98 117 } 99 118 100 void Builder::applyPropertyValue(CSSPropertyID propertyID, CSSValue& value) 101 { 102 applyProperty(propertyID, value, SelectorChecker::MatchDefault); 119 void Builder::applyPropertyValue(CSSPropertyID propertyID, CSSValue* value) 120 { 121 if (!value) 122 return; 123 124 applyProperty(propertyID, *value, SelectorChecker::MatchDefault); 103 125 104 126 m_state.updateFont(); -
trunk/Source/WebCore/style/StyleBuilder.h
r252255 r252313 36 36 WTF_MAKE_FAST_ALLOCATED; 37 37 public: 38 Builder(RenderStyle&, const StyleResolver&, const MatchResult&, OptionSet<CascadeLevel>, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All); 39 Builder(StyleResolver&, const MatchResult&, OptionSet<CascadeLevel>, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All); 38 Builder(RenderStyle&, BuilderContext&&, const MatchResult&, OptionSet<CascadeLevel>, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All); 40 39 ~Builder(); 41 40 … … 47 46 void applyCustomProperty(const String& name); 48 47 49 void applyPropertyValue(CSSPropertyID, CSSValue &);48 void applyPropertyValue(CSSPropertyID, CSSValue*); 50 49 51 50 BuilderState& state() { return m_state; } -
trunk/Source/WebCore/style/StyleBuilderState.cpp
r252030 r252313 52 52 namespace Style { 53 53 54 BuilderState::BuilderState(Builder& builder, RenderStyle& style, const RenderStyle& parentStyle, const RenderStyle* rootElementStyle, const Document& document, const Element* element)54 BuilderState::BuilderState(Builder& builder, RenderStyle& style, BuilderContext&& context) 55 55 : m_builder(builder) 56 56 , m_styleMap(*this) 57 57 , m_style(style) 58 , m_parentStyle(parentStyle) 59 , m_rootElementStyle(rootElementStyle) 60 , m_cssToLengthConversionData(&style, rootElementStyle, document.renderView()) 61 , m_document(document) 62 , m_element(element) 58 , m_context(WTFMove(context)) 59 , m_cssToLengthConversionData(&style, rootElementStyle(), document().renderView()) 63 60 { 64 61 } … … 360 357 void BuilderState::updateFontForZoomChange() 361 358 { 362 if (m_style.effectiveZoom() == m_parentStyle.effectiveZoom() && m_style.textZoom() == m_parentStyle.textZoom())359 if (m_style.effectiveZoom() == parentStyle().effectiveZoom() && m_style.textZoom() == parentStyle().textZoom()) 363 360 return; 364 361 … … 377 374 return; 378 375 379 const auto& parentFont = m_parentStyle.fontDescription();376 const auto& parentFont = parentStyle().fontDescription(); 380 377 if (childFont.useFixedDefaultSize() == parentFont.useFixedDefaultSize()) 381 378 return; -
trunk/Source/WebCore/style/StyleBuilderState.h
r251916 r252313 42 42 class Builder; 43 43 44 struct BuilderContext { 45 Ref<const Document> document; 46 const RenderStyle& parentStyle; 47 const RenderStyle* rootElementStyle = nullptr; 48 RefPtr<const Element> element = nullptr; 49 }; 50 44 51 class BuilderState { 45 52 public: 46 BuilderState(Builder&, RenderStyle&, const RenderStyle& parentStyle, const RenderStyle* rootElementStyle, const Document&, const Element*);53 BuilderState(Builder&, RenderStyle&, BuilderContext&&); 47 54 48 55 Builder& builder() { return m_builder; } 49 56 50 57 RenderStyle& style() { return m_style; } 51 const RenderStyle& parentStyle() const { return m_ parentStyle; }52 const RenderStyle* rootElementStyle() const { return m_ rootElementStyle; }58 const RenderStyle& parentStyle() const { return m_context.parentStyle; } 59 const RenderStyle* rootElementStyle() const { return m_context.rootElementStyle; } 53 60 54 const Document& document() const { return m_ document.get(); }55 const Element* element() const { return m_ element.get(); }61 const Document& document() const { return m_context.document.get(); } 62 const Element* element() const { return m_context.element.get(); } 56 63 57 64 void setFontDescription(FontCascadeDescription&& fontDescription) { m_fontDirty |= m_style.setFontDescription(WTFMove(fontDescription)); } … … 66 73 67 74 const FontCascadeDescription& fontDescription() { return m_style.fontDescription(); } 68 const FontCascadeDescription& parentFontDescription() { return m_parentStyle.fontDescription(); }75 const FontCascadeDescription& parentFontDescription() { return parentStyle().fontDescription(); } 69 76 70 77 // FIXME: These are mutually exclusive, clean up the code to take that into account. … … 106 113 107 114 RenderStyle& m_style; 108 const RenderStyle& m_parentStyle; 109 const RenderStyle* m_rootElementStyle; 115 const BuilderContext m_context; 110 116 111 117 const CSSToLengthConversionData m_cssToLengthConversionData; 112 113 Ref<const Document> m_document;114 RefPtr<const Element> m_element;115 118 116 119 Bitmap<numCSSProperties> m_appliedProperties;
Note: See TracChangeset
for help on using the changeset viewer.