Changeset 284693 in webkit
- Timestamp:
- Oct 22, 2021, 9:56:35 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 38 edited
-
ChangeLog (modified) (1 diff)
-
animation/AnimationEffect.h (modified) (2 diffs)
-
animation/CSSAnimation.cpp (modified) (1 diff)
-
animation/CSSAnimation.h (modified) (1 diff)
-
animation/CSSTransition.cpp (modified) (2 diffs)
-
animation/CSSTransition.h (modified) (1 diff)
-
animation/DeclarativeAnimation.cpp (modified) (2 diffs)
-
animation/DeclarativeAnimation.h (modified) (1 diff)
-
animation/KeyframeEffect.cpp (modified) (6 diffs)
-
animation/KeyframeEffect.h (modified) (3 diffs)
-
animation/KeyframeEffectStack.cpp (modified) (2 diffs)
-
animation/KeyframeEffectStack.h (modified) (2 diffs)
-
animation/WebAnimation.cpp (modified) (3 diffs)
-
animation/WebAnimation.h (modified) (2 diffs)
-
css/MediaQueryMatcher.cpp (modified) (1 diff)
-
css/StyleMedia.cpp (modified) (1 diff)
-
dom/Document.cpp (modified) (1 diff)
-
dom/Element.cpp (modified) (2 diffs)
-
dom/Element.h (modified) (3 diffs)
-
html/HTMLTitleElement.cpp (modified) (1 diff)
-
html/shadow/DateTimeFieldElement.cpp (modified) (1 diff)
-
html/shadow/DateTimeFieldElement.h (modified) (1 diff)
-
html/shadow/SliderThumbElement.cpp (modified) (2 diffs)
-
html/shadow/SliderThumbElement.h (modified) (2 diffs)
-
html/shadow/TextControlInnerElements.cpp (modified) (7 diffs)
-
html/shadow/TextControlInnerElements.h (modified) (6 diffs)
-
rendering/RenderElement.cpp (modified) (3 diffs)
-
rendering/style/KeyframeList.cpp (modified) (2 diffs)
-
style/StyleResolver.cpp (modified) (10 diffs)
-
style/StyleResolver.h (modified) (4 diffs)
-
style/StyleTreeResolver.cpp (modified) (13 diffs)
-
style/StyleTreeResolver.h (modified) (4 diffs)
-
style/Styleable.cpp (modified) (4 diffs)
-
style/Styleable.h (modified) (2 diffs)
-
svg/SVGElement.cpp (modified) (1 diff)
-
svg/SVGElement.h (modified) (1 diff)
-
svg/SVGElementRareData.h (modified) (1 diff)
-
testing/Internals.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r284692 r284693 1 2021-10-22 Antti Koivisto <antti@apple.com> 2 3 Factor style resolver context arguments into a struct 4 https://bugs.webkit.org/show_bug.cgi?id=232137 5 6 Reviewed by Antoine Quint. 7 8 Add Style::ResolutionContext struct and use it to consistently pass around all context argument needed 9 for resolving style instead of just passing around individual arguments as separate function parameter. 10 11 An immediately benefit is that we can remove the stateful setOverrideDocumentElementStyle hack. 12 This also makes the style system more flexible and extensible for future work. 13 14 Most of the patch is mechanically replacing a parent style argument in various places with a context 15 struct argument. 16 17 * animation/AnimationEffect.h: 18 * animation/CSSAnimation.cpp: 19 (WebCore::CSSAnimation::create): 20 * animation/CSSAnimation.h: 21 * animation/CSSTransition.cpp: 22 (WebCore::CSSTransition::create): 23 (WebCore::CSSTransition::resolve): 24 * animation/CSSTransition.h: 25 * animation/DeclarativeAnimation.cpp: 26 (WebCore::DeclarativeAnimation::initialize): 27 * animation/DeclarativeAnimation.h: 28 * animation/KeyframeEffect.cpp: 29 (WebCore::KeyframeEffect::updateBlendingKeyframes): 30 (WebCore::KeyframeEffect::computeDeclarativeAnimationBlendingKeyframes): 31 (WebCore::KeyframeEffect::computeCSSAnimationBlendingKeyframes): 32 (WebCore::KeyframeEffect::apply): 33 (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle): 34 * animation/KeyframeEffect.h: 35 * animation/KeyframeEffectStack.cpp: 36 (WebCore::KeyframeEffectStack::applyKeyframeEffects): 37 * animation/KeyframeEffectStack.h: 38 * animation/WebAnimation.cpp: 39 (WebCore::WebAnimation::resolve): 40 (WebCore::WebAnimation::commitStyles): 41 * animation/WebAnimation.h: 42 * css/MediaQueryMatcher.cpp: 43 (WebCore::MediaQueryMatcher::documentElementUserAgentStyle const): 44 * css/StyleMedia.cpp: 45 (WebCore::StyleMedia::matchMedium const): 46 * dom/Document.cpp: 47 (WebCore::Document::styleForElementIgnoringPendingStylesheets): 48 * dom/Element.cpp: 49 (WebCore::Element::resolveStyle): 50 (WebCore::Element::resolveCustomStyle): 51 * dom/Element.h: 52 * html/HTMLTitleElement.cpp: 53 (WebCore::HTMLTitleElement::computedTextWithDirection): 54 * html/shadow/DateTimeFieldElement.cpp: 55 (WebCore::DateTimeFieldElement::resolveCustomStyle): 56 * html/shadow/DateTimeFieldElement.h: 57 * html/shadow/SliderThumbElement.cpp: 58 (WebCore::SliderThumbElement::resolveCustomStyle): 59 (WebCore::SliderContainerElement::resolveCustomStyle): 60 * html/shadow/SliderThumbElement.h: 61 * html/shadow/TextControlInnerElements.cpp: 62 (WebCore::TextControlInnerContainer::resolveCustomStyle): 63 (WebCore::TextControlInnerElement::resolveCustomStyle): 64 (WebCore::TextControlInnerTextElement::resolveCustomStyle): 65 (WebCore::TextControlPlaceholderElement::resolveCustomStyle): 66 (WebCore::SearchFieldResultsButtonElement::resolveCustomStyle): 67 (WebCore::SearchFieldCancelButtonElement::resolveCustomStyle): 68 * html/shadow/TextControlInnerElements.h: 69 * rendering/RenderElement.cpp: 70 (WebCore::RenderElement::computeFirstLineStyle const): 71 (WebCore::RenderElement::getUncachedPseudoStyle const): 72 * rendering/style/KeyframeList.cpp: 73 (WebCore::KeyframeList::fillImplicitKeyframes): 74 * style/StyleResolver.cpp: 75 (WebCore::Style::Resolver::Resolver): 76 (WebCore::Style::Resolver::styleForElement): 77 (WebCore::Style::Resolver::styleForKeyframe): 78 (WebCore::Style::Resolver::keyframeStylesForAnimation): 79 (WebCore::Style::Resolver::pseudoStyleForElement): 80 * style/StyleResolver.h: 81 (WebCore::Style::Resolver::overrideDocumentElementStyle const): Deleted. 82 (WebCore::Style::Resolver::setOverrideDocumentElementStyle): Deleted. 83 * style/StyleTreeResolver.cpp: 84 (WebCore::Style::TreeResolver::Scope::Scope): 85 (WebCore::Style::TreeResolver::Scope::~Scope): 86 (WebCore::Style::TreeResolver::styleForStyleable): 87 (WebCore::Style::TreeResolver::resolveElement): 88 (WebCore::Style::TreeResolver::resolvePseudoStyle): 89 (WebCore::Style::TreeResolver::makeResolveContext): 90 (WebCore::Style::TreeResolver::makeResolveContextForPseudoElement): 91 (WebCore::Style::TreeResolver::parentBoxStyleForPseudoElement const): 92 (WebCore::Style::TreeResolver::createAnimatedElementUpdate): 93 (WebCore::Style::TreeResolver::parentBoxStyleForPseudo const): Deleted. 94 * style/StyleTreeResolver.h: 95 * style/Styleable.cpp: 96 (WebCore::Styleable::updateCSSAnimations const): 97 (WebCore::updateCSSTransitionsForStyleableAndProperty): 98 * style/Styleable.h: 99 (WebCore::Styleable::applyKeyframeEffects const): 100 * svg/SVGElement.cpp: 101 (WebCore::SVGElement::resolveCustomStyle): 102 * svg/SVGElement.h: 103 * svg/SVGElementRareData.h: 104 (WebCore::SVGElementRareData::overrideComputedStyle): 105 * testing/Internals.cpp: 106 (WebCore::Internals::highlightPseudoElementColor): 107 1 108 2021-10-22 Sihui Liu <sihui_liu@apple.com> 2 109 -
trunk/Source/WebCore/animation/AnimationEffect.h
r284213 r284693 48 48 namespace WebCore { 49 49 50 namespace Style { 51 struct ResolutionContext; 52 } 53 50 54 class AnimationEffect : public RefCounted<AnimationEffect>, public CanMakeWeakPtr<AnimationEffect> { 51 55 public: … … 62 66 ExceptionOr<void> updateTiming(std::optional<OptionalEffectTiming>); 63 67 64 virtual void apply(RenderStyle& targetStyle, const RenderStyle* parentElementStyle, std::optional<Seconds> = std::nullopt) = 0;68 virtual void apply(RenderStyle& targetStyle, const Style::ResolutionContext&, std::optional<Seconds> = std::nullopt) = 0; 65 69 virtual void invalidate() = 0; 66 70 virtual void animationDidTick() = 0; -
trunk/Source/WebCore/animation/CSSAnimation.cpp
r278540 r284693 37 37 WTF_MAKE_ISO_ALLOCATED_IMPL(CSSAnimation); 38 38 39 Ref<CSSAnimation> CSSAnimation::create(const Styleable& owningElement, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle)39 Ref<CSSAnimation> CSSAnimation::create(const Styleable& owningElement, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext& resolutionContext) 40 40 { 41 41 auto result = adoptRef(*new CSSAnimation(owningElement, backingAnimation)); 42 result->initialize(oldStyle, newStyle, parentElementStyle);42 result->initialize(oldStyle, newStyle, resolutionContext); 43 43 44 44 InspectorInstrumentation::didCreateWebAnimation(result.get()); -
trunk/Source/WebCore/animation/CSSAnimation.h
r278253 r284693 39 39 WTF_MAKE_ISO_ALLOCATED(CSSAnimation); 40 40 public: 41 static Ref<CSSAnimation> create(const Styleable&, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle);41 static Ref<CSSAnimation> create(const Styleable&, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext&); 42 42 ~CSSAnimation() = default; 43 43 -
trunk/Source/WebCore/animation/CSSTransition.cpp
r278253 r284693 42 42 ASSERT(oldStyle); 43 43 auto result = adoptRef(*new CSSTransition(owningElement, property, generationTime, backingAnimation, *oldStyle, newStyle, reversingAdjustedStartStyle, reversingShorteningFactor)); 44 result->initialize(oldStyle, newStyle, nullptr);44 result->initialize(oldStyle, newStyle, { nullptr }); 45 45 result->setTimingProperties(delay, duration); 46 46 … … 62 62 } 63 63 64 void CSSTransition::resolve(RenderStyle& targetStyle, const RenderStyle* parentElementStyle, std::optional<Seconds> startTime)64 void CSSTransition::resolve(RenderStyle& targetStyle, const Style::ResolutionContext& resolutionContext, std::optional<Seconds> startTime) 65 65 { 66 DeclarativeAnimation::resolve(targetStyle, parentElementStyle, startTime);66 DeclarativeAnimation::resolve(targetStyle, resolutionContext, startTime); 67 67 m_currentStyle = RenderStyle::clonePtr(targetStyle); 68 68 } -
trunk/Source/WebCore/animation/CSSTransition.h
r278340 r284693 59 59 void setTimingProperties(Seconds delay, Seconds duration); 60 60 Ref<AnimationEventBase> createEvent(const AtomString& eventType, double elapsedTime, const String& pseudoId, std::optional<Seconds> timelineTime) final; 61 void resolve(RenderStyle& targetStyle, const RenderStyle* parentElementStyle, std::optional<Seconds>) final;61 void resolve(RenderStyle& targetStyle, const Style::ResolutionContext&, std::optional<Seconds>) final; 62 62 63 63 CSSPropertyID m_property; -
trunk/Source/WebCore/animation/DeclarativeAnimation.cpp
r284057 r284693 106 106 } 107 107 108 void DeclarativeAnimation::initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle)108 void DeclarativeAnimation::initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext& resolutionContext) 109 109 { 110 110 // We need to suspend invalidation of the animation's keyframe effect during its creation … … 117 117 setEffect(KeyframeEffect::create(*m_owningElement, m_owningPseudoId)); 118 118 setTimeline(&m_owningElement->document().timeline()); 119 downcast<KeyframeEffect>(effect())->computeDeclarativeAnimationBlendingKeyframes(oldStyle, newStyle, parentElementStyle);119 downcast<KeyframeEffect>(effect())->computeDeclarativeAnimationBlendingKeyframes(oldStyle, newStyle, resolutionContext); 120 120 syncPropertiesWithBackingAnimation(); 121 121 if (backingAnimation().playState() == AnimationPlayState::Playing) -
trunk/Source/WebCore/animation/DeclarativeAnimation.h
r278253 r284693 76 76 DeclarativeAnimation(const Styleable&, const Animation&); 77 77 78 virtual void initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle);78 virtual void initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext&); 79 79 virtual void syncPropertiesWithBackingAnimation(); 80 80 // elapsedTime is the animation's current time at the time the event is added and is exposed through the DOM API, timelineTime is the animations' -
trunk/Source/WebCore/animation/KeyframeEffect.cpp
r284600 r284693 813 813 } 814 814 815 void KeyframeEffect::updateBlendingKeyframes(RenderStyle& elementStyle, const RenderStyle* parentElementStyle)815 void KeyframeEffect::updateBlendingKeyframes(RenderStyle& elementStyle, const Style::ResolutionContext& resolutionContext) 816 816 { 817 817 if (!m_blendingKeyframes.isEmpty() || !m_target) … … 830 830 831 831 auto keyframeRule = StyleRuleKeyframe::create(WTFMove(styleProperties)); 832 keyframeValue.setStyle(styleResolver.styleForKeyframe(*m_target, &elementStyle, parentElementStyle, keyframeRule.ptr(), keyframeValue));832 keyframeValue.setStyle(styleResolver.styleForKeyframe(*m_target, &elementStyle, resolutionContext, keyframeRule.ptr(), keyframeValue)); 833 833 keyframeList.insert(WTFMove(keyframeValue)); 834 834 } … … 1004 1004 } 1005 1005 1006 void KeyframeEffect::computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle)1006 void KeyframeEffect::computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext& resolutionContext) 1007 1007 { 1008 1008 ASSERT(is<DeclarativeAnimation>(animation())); 1009 1009 if (is<CSSAnimation>(animation())) 1010 computeCSSAnimationBlendingKeyframes(newStyle, parentElementStyle);1010 computeCSSAnimationBlendingKeyframes(newStyle, resolutionContext); 1011 1011 else if (is<CSSTransition>(animation())) 1012 1012 computeCSSTransitionBlendingKeyframes(oldStyle, newStyle); 1013 1013 } 1014 1014 1015 void KeyframeEffect::computeCSSAnimationBlendingKeyframes(const RenderStyle& unanimatedStyle, const RenderStyle* parentElementStyle)1015 void KeyframeEffect::computeCSSAnimationBlendingKeyframes(const RenderStyle& unanimatedStyle, const Style::ResolutionContext& resolutionContext) 1016 1016 { 1017 1017 ASSERT(is<CSSAnimation>(animation())); … … 1023 1023 KeyframeList keyframeList(backingAnimation.name().string); 1024 1024 if (auto* styleScope = Style::Scope::forOrdinal(*m_target, backingAnimation.nameStyleScopeOrdinal())) 1025 styleScope->resolver().keyframeStylesForAnimation(*m_target, &unanimatedStyle, parentElementStyle, keyframeList);1025 styleScope->resolver().keyframeStylesForAnimation(*m_target, &unanimatedStyle, resolutionContext, keyframeList); 1026 1026 1027 1027 // Ensure resource loads for all the frames. … … 1267 1267 } 1268 1268 1269 void KeyframeEffect::apply(RenderStyle& targetStyle, const RenderStyle* parentElementStyle, std::optional<Seconds> startTime)1269 void KeyframeEffect::apply(RenderStyle& targetStyle, const Style::ResolutionContext& resolutionContext, std::optional<Seconds> startTime) 1270 1270 { 1271 1271 if (!m_target) 1272 1272 return; 1273 1273 1274 updateBlendingKeyframes(targetStyle, parentElementStyle);1274 updateBlendingKeyframes(targetStyle, resolutionContext); 1275 1275 1276 1276 auto computedTiming = getComputedTiming(startTime); … … 1434 1434 // for a given iteration progress, current iteration and underlying value is calculated as follows. 1435 1435 1436 updateBlendingKeyframes(targetStyle, nullptr);1436 updateBlendingKeyframes(targetStyle, { nullptr }); 1437 1437 if (m_blendingKeyframes.isEmpty()) 1438 1438 return; -
trunk/Source/WebCore/animation/KeyframeEffect.h
r284075 r284693 124 124 125 125 void getAnimatedStyle(std::unique_ptr<RenderStyle>& animatedStyle); 126 void apply(RenderStyle& targetStyle, const RenderStyle* parentElementStyle, std::optional<Seconds> = std::nullopt) override;126 void apply(RenderStyle& targetStyle, const Style::ResolutionContext&, std::optional<Seconds> = std::nullopt) override; 127 127 void invalidate() override; 128 128 void animationDidTick() final; … … 155 155 bool colorFilterFunctionListsMatch() const override { return m_colorFilterFunctionListsMatch; } 156 156 157 void computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle);157 void computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext&); 158 158 const KeyframeList& blendingKeyframes() const { return m_blendingKeyframes; } 159 159 const HashSet<CSSPropertyID>& animatedProperties(); … … 199 199 void computeSomeKeyframesUseStepsTimingFunction(); 200 200 void clearBlendingKeyframes(); 201 void updateBlendingKeyframes(RenderStyle& elementStyle, const RenderStyle* parentElementStyle);202 void computeCSSAnimationBlendingKeyframes(const RenderStyle& unanimatedStyle, const RenderStyle* parentElementStyle);201 void updateBlendingKeyframes(RenderStyle& elementStyle, const Style::ResolutionContext&); 202 void computeCSSAnimationBlendingKeyframes(const RenderStyle& unanimatedStyle, const Style::ResolutionContext&); 203 203 void computeCSSTransitionBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle); 204 204 void computeAcceleratedPropertiesState(); -
trunk/Source/WebCore/animation/KeyframeEffectStack.cpp
r284516 r284693 122 122 } 123 123 124 OptionSet<AnimationImpact> KeyframeEffectStack::applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const RenderStyle* parentElementStyle)124 OptionSet<AnimationImpact> KeyframeEffectStack::applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const Style::ResolutionContext& resolutionContext) 125 125 { 126 126 OptionSet<AnimationImpact> impact; … … 135 135 for (const auto& effect : sortedEffects()) { 136 136 ASSERT(effect->animation()); 137 effect->animation()->resolve(targetStyle, parentElementStyle);137 effect->animation()->resolve(targetStyle, resolutionContext); 138 138 139 139 if (effect->isRunningAccelerated() || effect->isAboutToRunAccelerated()) -
trunk/Source/WebCore/animation/KeyframeEffectStack.h
r272904 r284693 37 37 class RenderStyle; 38 38 39 namespace Style { 40 struct ResolutionContext; 41 } 42 39 43 class KeyframeEffectStack { 40 44 WTF_MAKE_FAST_ALLOCATED; … … 51 55 bool isCurrentlyAffectingProperty(CSSPropertyID) const; 52 56 bool requiresPseudoElement() const; 53 OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const RenderStyle* parentElementStyle);57 OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const Style::ResolutionContext&); 54 58 bool hasEffectWithImplicitKeyframes() const; 55 59 -
trunk/Source/WebCore/animation/WebAnimation.cpp
r282784 r284693 1228 1228 } 1229 1229 1230 void WebAnimation::resolve(RenderStyle& targetStyle, const RenderStyle* parentElementStyle, std::optional<Seconds> startTime)1230 void WebAnimation::resolve(RenderStyle& targetStyle, const Style::ResolutionContext& resolutionContext, std::optional<Seconds> startTime) 1231 1231 { 1232 1232 if (!m_shouldSkipUpdatingFinishedStateWhenResolving) … … 1235 1235 1236 1236 if (m_effect) 1237 m_effect->apply(targetStyle, parentElementStyle, startTime);1237 m_effect->apply(targetStyle, resolutionContext, startTime); 1238 1238 } 1239 1239 … … 1427 1427 break; 1428 1428 if (effectInStack->animatedProperties().contains(property)) 1429 effectInStack->animation()->resolve(*animatedStyle, nullptr);1429 effectInStack->animation()->resolve(*animatedStyle, { nullptr }); 1430 1430 if (effectInStack->animation() == this) 1431 1431 break; 1432 1432 } 1433 1433 if (m_replaceState == ReplaceState::Removed) 1434 effect->animation()->resolve(*animatedStyle, nullptr);1434 effect->animation()->resolve(*animatedStyle, { nullptr }); 1435 1435 if (auto cssValue = computedStyleExtractor.valueForPropertyInStyle(*animatedStyle, property, renderer)) 1436 1436 inlineStyle->setPropertyInternal(property, cssValue->cssText(), false); -
trunk/Source/WebCore/animation/WebAnimation.h
r278340 r284693 49 49 template<typename IDLType> class DOMPromiseProxyWithResolveCallback; 50 50 51 namespace Style { 52 struct ResolutionContext; 53 } 54 51 55 class WebAnimation : public RefCounted<WebAnimation>, public EventTargetWithInlineData, public ActiveDOMObject { 52 56 WTF_MAKE_ISO_ALLOCATED(WebAnimation); … … 120 124 virtual void tick(); 121 125 WEBCORE_EXPORT Seconds timeToNextTick() const; 122 virtual void resolve(RenderStyle& targetStyle, const RenderStyle* parentElementStyle, std::optional<Seconds> = std::nullopt);126 virtual void resolve(RenderStyle& targetStyle, const Style::ResolutionContext&, std::optional<Seconds> = std::nullopt); 123 127 void effectTargetDidChange(const std::optional<const Styleable>& previousTarget, const std::optional<const Styleable>& newTarget); 124 128 void acceleratedStateDidChange(); -
trunk/Source/WebCore/css/MediaQueryMatcher.cpp
r284057 r284693 73 73 return nullptr; 74 74 75 return m_document->styleScope().resolver().styleForElement(*documentElement, m_document->renderStyle(), nullptr, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle;75 return m_document->styleScope().resolver().styleForElement(*documentElement, { m_document->renderStyle() }, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle; 76 76 } 77 77 -
trunk/Source/WebCore/css/StyleMedia.cpp
r236917 r284693 67 67 return false; 68 68 69 auto rootStyle = document->styleScope().resolver().styleForElement(*documentElement, document->renderStyle(), nullptr, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle;69 auto rootStyle = document->styleScope().resolver().styleForElement(*documentElement, { document->renderStyle() }, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle; 70 70 71 71 auto media = MediaQuerySet::create(query, MediaQueryParserContext(*document)); -
trunk/Source/WebCore/dom/Document.cpp
r284528 r284693 2263 2263 2264 2264 if (pseudoElementSpecifier != PseudoId::None) 2265 return resolver.pseudoStyleForElement(element, { pseudoElementSpecifier }, *parentStyle);2266 2267 auto elementStyle = resolver.styleForElement(element, parentStyle);2265 return resolver.pseudoStyleForElement(element, { pseudoElementSpecifier }, { parentStyle }); 2266 2267 auto elementStyle = resolver.styleForElement(element, { parentStyle }); 2268 2268 if (elementStyle.relations) { 2269 2269 Style::Update emptyUpdate(*this); -
trunk/Source/WebCore/dom/Element.cpp
r284142 r284693 1975 1975 } 1976 1976 1977 Style::ElementStyle Element::resolveStyle(const RenderStyle* parentStyle)1978 { 1979 return styleResolver().styleForElement(*this, parentStyle);1977 Style::ElementStyle Element::resolveStyle(const Style::ResolutionContext& resolutionContext) 1978 { 1979 return styleResolver().styleForElement(*this, resolutionContext); 1980 1980 } 1981 1981 … … 4410 4410 } 4411 4411 4412 std::optional<Style::ElementStyle> Element::resolveCustomStyle(const RenderStyle&, const RenderStyle*)4412 std::optional<Style::ElementStyle> Element::resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle*) 4413 4413 { 4414 4414 ASSERT(hasCustomStyleResolveCallbacks()); -
trunk/Source/WebCore/dom/Element.h
r284075 r284693 95 95 enum class Change : uint8_t; 96 96 struct ElementStyle; 97 struct ResolutionContext; 97 98 } 98 99 … … 572 573 virtual void willDetachRenderers(); 573 574 virtual void didDetachRenderers(); 574 virtual std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle);575 virtual std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle); 575 576 576 577 LayoutRect absoluteEventHandlerBounds(bool& includesFixedPositionElements) override; … … 594 595 595 596 Style::Resolver& styleResolver(); 596 Style::ElementStyle resolveStyle(const RenderStyle* parentStyle);597 Style::ElementStyle resolveStyle(const Style::ResolutionContext&); 597 598 598 599 // Invalidates the style of a single element. Style is resolved lazily. -
trunk/Source/WebCore/html/HTMLTitleElement.cpp
r234808 r284693 85 85 direction = computedStyle->direction(); 86 86 else 87 direction = styleResolver().styleForElement(*this, parentElement() ? parentElement()->renderStyle() : nullptr).renderStyle->direction();87 direction = styleResolver().styleForElement(*this, { parentElement() ? parentElement()->renderStyle() : nullptr }).renderStyle->direction(); 88 88 return { text(), direction }; 89 89 } -
trunk/Source/WebCore/html/shadow/DateTimeFieldElement.cpp
r284093 r284693 64 64 } 65 65 66 std::optional<Style::ElementStyle> DateTimeFieldElement::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle)67 { 68 auto elementStyle = resolveStyle( &parentStyle);66 std::optional<Style::ElementStyle> DateTimeFieldElement::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle* shadowHostStyle) 67 { 68 auto elementStyle = resolveStyle(resolutionContext); 69 69 if (!elementStyle.renderStyle) 70 70 return std::nullopt; -
trunk/Source/WebCore/html/shadow/DateTimeFieldElement.h
r278253 r284693 86 86 87 87 private: 88 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle&, const RenderStyle*) final;88 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle*) final; 89 89 90 90 bool supportsFocus() const override; -
trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp
r283757 r284693 587 587 } 588 588 589 std::optional<Style::ElementStyle> SliderThumbElement::resolveCustomStyle(const RenderStyle&, const RenderStyle* hostStyle)589 std::optional<Style::ElementStyle> SliderThumbElement::resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* hostStyle) 590 590 { 591 591 // This doesn't actually compute style. This is just a hack to pick shadow pseudo id when host style is known. … … 638 638 } 639 639 640 std::optional<Style::ElementStyle> SliderContainerElement::resolveCustomStyle(const RenderStyle&, const RenderStyle* hostStyle)640 std::optional<Style::ElementStyle> SliderContainerElement::resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* hostStyle) 641 641 { 642 642 // This doesn't actually compute style. This is just a hack to pick shadow pseudo id when host style is known. -
trunk/Source/WebCore/html/shadow/SliderThumbElement.h
r278253 r284693 76 76 void willDetachRenderers() final; 77 77 78 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle&, const RenderStyle*) final;78 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle*) final; 79 79 const AtomString& shadowPseudoId() const final; 80 80 … … 135 135 SliderContainerElement(Document&); 136 136 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final; 137 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle&, const RenderStyle*) final;137 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle*) final; 138 138 const AtomString& shadowPseudoId() const final; 139 139 bool isSliderContainerElement() const final { return true; } -
trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp
r283757 r284693 83 83 } 84 84 85 std::optional<Style::ElementStyle> TextControlInnerContainer::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle*)86 { 87 auto elementStyle = resolveStyle( &parentStyle);85 std::optional<Style::ElementStyle> TextControlInnerContainer::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle*) 86 { 87 auto elementStyle = resolveStyle(resolutionContext); 88 88 if (isStrongPasswordTextField(shadowHost())) { 89 89 elementStyle.renderStyle->setFlexWrap(FlexWrap::Wrap); … … 105 105 } 106 106 107 std::optional<Style::ElementStyle> TextControlInnerElement::resolveCustomStyle(const RenderStyle&, const RenderStyle* shadowHostStyle)107 std::optional<Style::ElementStyle> TextControlInnerElement::resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) 108 108 { 109 109 auto newStyle = RenderStyle::createPtr(); … … 189 189 } 190 190 191 std::optional<Style::ElementStyle> TextControlInnerTextElement::resolveCustomStyle(const RenderStyle&, const RenderStyle* shadowHostStyle)191 std::optional<Style::ElementStyle> TextControlInnerTextElement::resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) 192 192 { 193 193 auto style = downcast<HTMLTextFormControlElement>(*shadowHost()).createInnerTextStyle(*shadowHostStyle); … … 210 210 } 211 211 212 std::optional<Style::ElementStyle> TextControlPlaceholderElement::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle)213 { 214 auto style = resolveStyle( &parentStyle);212 std::optional<Style::ElementStyle> TextControlPlaceholderElement::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle* shadowHostStyle) 213 { 214 auto style = resolveStyle(resolutionContext); 215 215 216 216 auto& controlElement = downcast<HTMLTextFormControlElement>(*containingShadowRoot()->host()); … … 240 240 } 241 241 242 std::optional<Style::ElementStyle> SearchFieldResultsButtonElement::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle)242 std::optional<Style::ElementStyle> SearchFieldResultsButtonElement::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle* shadowHostStyle) 243 243 { 244 244 RefPtr input = downcast<HTMLInputElement>(shadowHost()); … … 248 248 if (shadowHostStyle && shadowHostStyle->effectiveAppearance() != SearchFieldPart) { 249 249 SetForScope<bool> canAdjustStyleForAppearance(m_canAdjustStyleForAppearance, false); 250 return resolveStyle( &parentStyle);250 return resolveStyle(resolutionContext); 251 251 } 252 252 … … 307 307 } 308 308 309 std::optional<Style::ElementStyle> SearchFieldCancelButtonElement::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle*)310 { 311 auto elementStyle = resolveStyle( &parentStyle);309 std::optional<Style::ElementStyle> SearchFieldCancelButtonElement::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle*) 310 { 311 auto elementStyle = resolveStyle(resolutionContext); 312 312 auto& inputElement = downcast<HTMLInputElement>(*shadowHost()); 313 313 elementStyle.renderStyle->setVisibility(elementStyle.renderStyle->visibility() == Visibility::Hidden || inputElement.value().isEmpty() ? Visibility::Hidden : Visibility::Visible); -
trunk/Source/WebCore/html/shadow/TextControlInnerElements.h
r278253 r284693 41 41 TextControlInnerContainer(Document&); 42 42 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; 43 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;43 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) override; 44 44 }; 45 45 … … 51 51 private: 52 52 TextControlInnerElement(Document&); 53 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;53 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) override; 54 54 55 55 bool isMouseFocusable() const override { return false; } … … 76 76 TextControlInnerTextElement(Document&); 77 77 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; 78 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;78 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) override; 79 79 bool isMouseFocusable() const override { return false; } 80 80 bool isTextControlInnerTextElement() const override { return true; } … … 89 89 TextControlPlaceholderElement(Document&); 90 90 91 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;91 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) override; 92 92 }; 93 93 … … 107 107 SearchFieldResultsButtonElement(Document&); 108 108 bool isMouseFocusable() const override { return false; } 109 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;109 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) override; 110 110 bool isSearchFieldResultsButtonElement() const override { return true; } 111 111 … … 126 126 SearchFieldCancelButtonElement(Document&); 127 127 bool isMouseFocusable() const override { return false; } 128 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;128 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) override; 129 129 }; 130 130 -
trunk/Source/WebCore/rendering/RenderElement.cpp
r284366 r284693 256 256 return nullptr; 257 257 258 auto style = composedTreeParentElement->styleResolver().styleForElement(*composedTreeParentElement, &parentStyle).renderStyle;258 auto style = composedTreeParentElement->styleResolver().styleForElement(*composedTreeParentElement, { &parentStyle }).renderStyle; 259 259 ASSERT(style->display() == DisplayType::Contents); 260 260 … … 265 265 } 266 266 267 return rendererForFirstLineStyle.element()->styleResolver().styleForElement(*element(), &parentStyle).renderStyle;267 return rendererForFirstLineStyle.element()->styleResolver().styleForElement(*element(), { &parentStyle }).renderStyle; 268 268 } 269 269 … … 1532 1532 auto& styleResolver = element()->styleResolver(); 1533 1533 1534 std::unique_ptr<RenderStyle> style = styleResolver.pseudoStyleForElement(*element(), pseudoElementRequest, *parentStyle);1534 std::unique_ptr<RenderStyle> style = styleResolver.pseudoStyleForElement(*element(), pseudoElementRequest, { parentStyle }); 1535 1535 1536 1536 if (style) -
trunk/Source/WebCore/rendering/style/KeyframeList.cpp
r272898 r284693 120 120 if (initialSize > 0 && m_keyframes[0].key()) { 121 121 KeyframeValue keyframeValue(0, nullptr); 122 keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, parentElementStyle, &zeroPercentKeyframe(), keyframeValue));122 keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, { parentElementStyle }, &zeroPercentKeyframe(), keyframeValue)); 123 123 insert(WTFMove(keyframeValue)); 124 124 } … … 127 127 if (initialSize > 0 && (m_keyframes[size() - 1].key() != 1)) { 128 128 KeyframeValue keyframeValue(1, nullptr); 129 keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, parentElementStyle, &hundredPercentKeyframe(), keyframeValue));129 keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, { parentElementStyle }, &hundredPercentKeyframe(), keyframeValue)); 130 130 insert(WTFMove(keyframeValue)); 131 131 } -
trunk/Source/WebCore/style/StyleResolver.cpp
r284672 r284693 160 160 161 161 if (auto* documentElement = m_document.documentElement()) { 162 m_rootDefaultStyle = styleForElement(*documentElement, m_document.renderStyle(), nullptr, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle;162 m_rootDefaultStyle = styleForElement(*documentElement, { m_document.renderStyle() }, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle; 163 163 // Turn off assertion against font lookups during style resolver initialization. We may need root style font for media queries. 164 164 m_document.fontSelector().incrementIsComputingRootStyleFont(); … … 219 219 } 220 220 221 ElementStyle Resolver::styleForElement(const Element& element, const Re nderStyle* parentStyle, const RenderStyle* parentBoxStyle, RuleMatchingBehavior matchingBehavior, const SelectorFilter* selectorFilter)222 { 223 auto state = State(element, parentStyle, m_overrideDocumentElementStyle);221 ElementStyle Resolver::styleForElement(const Element& element, const ResolutionContext& context, RuleMatchingBehavior matchingBehavior) 222 { 223 auto state = State(element, context.parentStyle, context.documentElementStyle); 224 224 225 225 if (state.parentStyle()) { … … 246 246 UserAgentStyle::ensureDefaultStyleSheetsForElement(element); 247 247 248 ElementRuleCollector collector(element, m_ruleSets, selectorFilter);248 ElementRuleCollector collector(element, m_ruleSets, context.selectorFilter); 249 249 collector.setMedium(&m_mediaQueryEvaluator); 250 250 … … 265 265 applyMatchedProperties(state, collector.matchResult()); 266 266 267 Adjuster adjuster(document(), *state.parentStyle(), parentBoxStyle, &element);267 Adjuster adjuster(document(), *state.parentStyle(), context.parentBoxStyle, &element); 268 268 adjuster.adjust(*state.style(), state.userAgentAppearanceStyle()); 269 269 … … 274 274 } 275 275 276 std::unique_ptr<RenderStyle> Resolver::styleForKeyframe(const Element& element, const RenderStyle* elementStyle, const Re nderStyle* parentElementStyle, const StyleRuleKeyframe* keyframe, KeyframeValue& keyframeValue)276 std::unique_ptr<RenderStyle> Resolver::styleForKeyframe(const Element& element, const RenderStyle* elementStyle, const ResolutionContext& context, const StyleRuleKeyframe* keyframe, KeyframeValue& keyframeValue) 277 277 { 278 278 MatchResult result; 279 279 result.authorDeclarations.append({ &keyframe->properties(), SelectorChecker::MatchAll, propertyAllowlistForPseudoId(elementStyle->styleType()) }); 280 280 281 auto state = State(element, nullptr, m_overrideDocumentElementStyle);281 auto state = State(element, nullptr, context.documentElementStyle); 282 282 283 283 state.setStyle(RenderStyle::clonePtr(*elementStyle)); 284 state.setParentStyle(RenderStyle::clonePtr( parentElementStyle ? *parentElementStyle : *elementStyle));284 state.setParentStyle(RenderStyle::clonePtr(context.parentStyle ? *context.parentStyle : *elementStyle)); 285 285 286 286 Builder builder(*state.style(), builderContext(state), result, { CascadeLevel::Author }); … … 308 308 } 309 309 310 void Resolver::keyframeStylesForAnimation(const Element& element, const RenderStyle* elementStyle, const Re nderStyle* parentElementStyle, KeyframeList& list)310 void Resolver::keyframeStylesForAnimation(const Element& element, const RenderStyle* elementStyle, const ResolutionContext& context, KeyframeList& list) 311 311 { 312 312 list.clear(); … … 370 370 for (auto key : keyframe->keys()) { 371 371 KeyframeValue keyframeValue(0, nullptr); 372 keyframeValue.setStyle(styleForKeyframe(element, elementStyle, parentElementStyle, keyframe.ptr(), keyframeValue));372 keyframeValue.setStyle(styleForKeyframe(element, elementStyle, context, keyframe.ptr(), keyframeValue)); 373 373 keyframeValue.setKey(key); 374 374 if (auto timingFunctionCSSValue = keyframe->properties().getPropertyCSSValue(CSSPropertyAnimationTimingFunction)) … … 378 378 } 379 379 380 list.fillImplicitKeyframes(element, *this, elementStyle, parentElementStyle);381 } 382 383 std::unique_ptr<RenderStyle> Resolver::pseudoStyleForElement(const Element& element, const PseudoElementRequest& pseudoElementRequest, const Re nderStyle& parentStyle, const RenderStyle* parentBoxStyle, const SelectorFilter* selectorFilter)384 { 385 auto state = State(element, &parentStyle, m_overrideDocumentElementStyle);380 list.fillImplicitKeyframes(element, *this, elementStyle, context.parentStyle); 381 } 382 383 std::unique_ptr<RenderStyle> Resolver::pseudoStyleForElement(const Element& element, const PseudoElementRequest& pseudoElementRequest, const ResolutionContext& context) 384 { 385 auto state = State(element, context.parentStyle, context.documentElementStyle); 386 386 387 387 if (state.parentStyle()) { … … 393 393 } 394 394 395 ElementRuleCollector collector(element, m_ruleSets, selectorFilter);395 ElementRuleCollector collector(element, m_ruleSets, context.selectorFilter); 396 396 collector.setPseudoElementRequest(pseudoElementRequest); 397 397 collector.setMedium(&m_mediaQueryEvaluator); … … 412 412 applyMatchedProperties(state, collector.matchResult()); 413 413 414 Adjuster adjuster(document(), *state.parentStyle(), parentBoxStyle, nullptr);414 Adjuster adjuster(document(), *state.parentStyle(), context.parentBoxStyle, nullptr); 415 415 adjuster.adjust(*state.style(), state.userAgentAppearanceStyle()); 416 416 -
trunk/Source/WebCore/style/StyleResolver.h
r284672 r284693 81 81 }; 82 82 83 struct ResolutionContext { 84 const RenderStyle* parentStyle; 85 const RenderStyle* parentBoxStyle { nullptr }; 86 // This needs to be provided during style resolution when up-to-date document element style is not available via DOM. 87 const RenderStyle* documentElementStyle { nullptr }; 88 const SelectorFilter* selectorFilter { nullptr }; 89 }; 90 83 91 class Resolver : public RefCounted<Resolver> { 84 92 WTF_MAKE_ISO_ALLOCATED(Resolver); … … 87 95 ~Resolver(); 88 96 89 ElementStyle styleForElement(const Element&, const Re nderStyle* parentStyle, const RenderStyle* parentBoxStyle = nullptr, RuleMatchingBehavior = RuleMatchingBehavior::MatchAllRules, const SelectorFilter* = nullptr);97 ElementStyle styleForElement(const Element&, const ResolutionContext&, RuleMatchingBehavior = RuleMatchingBehavior::MatchAllRules); 90 98 91 void keyframeStylesForAnimation(const Element&, const RenderStyle* elementStyle, const Re nderStyle* parentElementStyle, KeyframeList&);99 void keyframeStylesForAnimation(const Element&, const RenderStyle* elementStyle, const ResolutionContext&, KeyframeList&); 92 100 93 WEBCORE_EXPORT std::unique_ptr<RenderStyle> pseudoStyleForElement(const Element&, const PseudoElementRequest&, const Re nderStyle& parentStyle, const RenderStyle* parentBoxStyle = nullptr, const SelectorFilter* = nullptr);101 WEBCORE_EXPORT std::unique_ptr<RenderStyle> pseudoStyleForElement(const Element&, const PseudoElementRequest&, const ResolutionContext&); 94 102 95 103 std::unique_ptr<RenderStyle> styleForPage(int pageIndex); … … 107 115 const MediaQueryEvaluator& mediaQueryEvaluator() const { return m_mediaQueryEvaluator; } 108 116 109 const RenderStyle* overrideDocumentElementStyle() const { return m_overrideDocumentElementStyle; }110 void setOverrideDocumentElementStyle(const RenderStyle* style) { m_overrideDocumentElementStyle = style; }111 112 117 void addCurrentSVGFontFaceRules(); 113 118 114 std::unique_ptr<RenderStyle> styleForKeyframe(const Element&, const RenderStyle* elementStyle, const Re nderStyle* parentElementStyle, const StyleRuleKeyframe*, KeyframeValue&);119 std::unique_ptr<RenderStyle> styleForKeyframe(const Element&, const RenderStyle* elementStyle, const ResolutionContext&, const StyleRuleKeyframe*, KeyframeValue&); 115 120 bool isAnimationNameValid(const String&); 116 121 … … 165 170 Document& m_document; 166 171 167 const RenderStyle* m_overrideDocumentElementStyle { nullptr };168 169 172 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; 170 173 -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r283269 r284693 89 89 , enclosingScope(&enclosingScope) 90 90 { 91 resolver->setOverrideDocumentElementStyle(enclosingScope.resolver->overrideDocumentElementStyle());92 91 } 93 92 … … 96 95 if (!shadowRoot) 97 96 resolver->document().setIsResolvingTreeStyle(false); 98 99 resolver->setOverrideDocumentElementStyle(nullptr);100 97 } 101 98 … … 130 127 } 131 128 132 std::unique_ptr<RenderStyle> TreeResolver::styleForStyleable(const Styleable& styleable, const Re nderStyle& inheritedStyle)129 std::unique_ptr<RenderStyle> TreeResolver::styleForStyleable(const Styleable& styleable, const ResolutionContext& resolutionContext) 133 130 { 134 131 auto& element = styleable.element; … … 136 133 if (element.hasCustomStyleResolveCallbacks()) { 137 134 RenderStyle* shadowHostStyle = scope().shadowRoot ? m_update->elementStyle(*scope().shadowRoot->host()) : nullptr; 138 if (auto customStyle = element.resolveCustomStyle( inheritedStyle, shadowHostStyle)) {135 if (auto customStyle = element.resolveCustomStyle(resolutionContext, shadowHostStyle)) { 139 136 if (customStyle->relations) 140 137 commitRelations(WTFMove(customStyle->relations), *m_update); … … 147 144 return style; 148 145 149 auto elementStyle = scope().resolver->styleForElement(element, &inheritedStyle, parentBoxStyle(), RuleMatchingBehavior::MatchAllRules, &scope().selectorFilter);146 auto elementStyle = scope().resolver->styleForElement(element, resolutionContext); 150 147 151 148 if (elementStyle.relations) … … 211 208 return { }; 212 209 210 auto resolutionContext = makeResolutionContext(); 211 213 212 Styleable styleable { element, PseudoId::None }; 214 auto newStyle = styleForStyleable(styleable, parent().style);213 auto newStyle = styleForStyleable(styleable, resolutionContext); 215 214 216 215 if (!affectsRenderedSubtree(element, *newStyle)) … … 224 223 } 225 224 226 auto update = createAnimatedElementUpdate(WTFMove(newStyle), styleable, parent().change, parent().style, parentBoxStyle());225 auto update = createAnimatedElementUpdate(WTFMove(newStyle), styleable, parent().change, resolutionContext); 227 226 auto descendantsToResolve = computeDescendantsToResolve(update.change, element.styleValidity(), parent().descendantsToResolve); 228 227 229 228 if (&element == m_document.documentElement()) { 230 229 m_documentElementStyle = RenderStyle::clonePtr(*update.style); 231 scope().resolver->setOverrideDocumentElementStyle(m_documentElementStyle.get());232 230 233 231 if (!existingStyle || existingStyle->computedFontPixelSize() != update.style->computedFontPixelSize()) { … … 287 285 return { }; 288 286 289 auto& parentStyle = *elementUpdate.style; 290 auto* parentBoxStyle = parentBoxStyleForPseudo(elementUpdate); 291 292 auto pseudoStyle = scope().resolver->pseudoStyleForElement(element, { pseudoId }, parentStyle, parentBoxStyle, &scope().selectorFilter); 287 auto resolutionContext = makeResolutionContextForPseudoElement(elementUpdate); 288 289 auto pseudoStyle = scope().resolver->pseudoStyleForElement(element, { pseudoId }, resolutionContext); 293 290 if (!pseudoStyle) 294 291 return { }; … … 298 295 return { }; 299 296 300 return createAnimatedElementUpdate(WTFMove(pseudoStyle), { element, pseudoId }, elementUpdate.change, parentStyle, parentBoxStyle); 297 return createAnimatedElementUpdate(WTFMove(pseudoStyle), { element, pseudoId }, elementUpdate.change, resolutionContext); 298 } 299 300 ResolutionContext TreeResolver::makeResolutionContext() 301 { 302 return { 303 &parent().style, 304 parentBoxStyle(), 305 m_documentElementStyle.get(), 306 &scope().selectorFilter 307 }; 308 } 309 310 ResolutionContext TreeResolver::makeResolutionContextForPseudoElement(const ElementUpdate& elementUpdate) 311 { 312 return { 313 elementUpdate.style.get(), 314 parentBoxStyleForPseudoElement(elementUpdate), 315 m_documentElementStyle.get(), 316 &scope().selectorFilter 317 }; 301 318 } 302 319 … … 315 332 } 316 333 317 const RenderStyle* TreeResolver::parentBoxStyleForPseudo (const ElementUpdate& elementUpdate) const334 const RenderStyle* TreeResolver::parentBoxStyleForPseudoElement(const ElementUpdate& elementUpdate) const 318 335 { 319 336 switch (elementUpdate.style->display()) { … … 327 344 } 328 345 329 ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, const Styleable& styleable, Change parentChange, const Re nderStyle& parentStyle, const RenderStyle* parentBoxStyle)346 ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, const Styleable& styleable, Change parentChange, const ResolutionContext& resolutionContext) 330 347 { 331 348 auto& element = styleable.element; … … 346 363 // such that when CSS Transitions are updated the CSS Animations data is the same as during the previous style change event. 347 364 if ((oldStyle && oldStyle->hasAnimations()) || newStyle->hasAnimations()) 348 styleable.updateCSSAnimations(oldStyle, *newStyle, &parentStyle);365 styleable.updateCSSAnimations(oldStyle, *newStyle, resolutionContext); 349 366 } 350 367 … … 357 374 // Apply all keyframe effects to the new style. 358 375 auto animatedStyle = RenderStyle::clonePtr(*newStyle); 359 animationImpact = styleable.applyKeyframeEffects(*animatedStyle, *previousLastStyleChangeEventStyle, &parentStyle);376 animationImpact = styleable.applyKeyframeEffects(*animatedStyle, *previousLastStyleChangeEventStyle, resolutionContext); 360 377 newStyle = WTFMove(animatedStyle); 361 378 362 Adjuster adjuster(document, parentStyle,parentBoxStyle, styleable.pseudoId == PseudoId::None ? &element : nullptr);379 Adjuster adjuster(document, *resolutionContext.parentStyle, resolutionContext.parentBoxStyle, styleable.pseudoId == PseudoId::None ? &element : nullptr); 363 380 adjuster.adjustAnimatedStyle(*newStyle, animationImpact); 364 381 } else -
trunk/Source/WebCore/style/StyleTreeResolver.h
r283134 r284693 46 46 47 47 class Resolver; 48 struct ResolutionContext; 48 49 49 50 DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(TreeResolverScope); … … 56 57 57 58 private: 58 std::unique_ptr<RenderStyle> styleForStyleable(const Styleable&, const Re nderStyle& inheritedStyle);59 std::unique_ptr<RenderStyle> styleForStyleable(const Styleable&, const ResolutionContext&); 59 60 60 61 void resolveComposedTree(); … … 62 63 ElementUpdates resolveElement(Element&); 63 64 64 static ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, const Styleable&, Change, const Re nderStyle& parentStyle, const RenderStyle* parentBoxStyle);65 static ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, const Styleable&, Change, const ResolutionContext&); 65 66 std::optional<ElementUpdate> resolvePseudoStyle(Element&, const ElementUpdate&, PseudoId); 66 67 … … 100 101 void popParentsToDepth(unsigned depth); 101 102 103 ResolutionContext makeResolutionContext(); 104 ResolutionContext makeResolutionContextForPseudoElement(const ElementUpdate&); 102 105 const RenderStyle* parentBoxStyle() const; 103 const RenderStyle* parentBoxStyleForPseudo (const ElementUpdate&) const;106 const RenderStyle* parentBoxStyleForPseudoElement(const ElementUpdate&) const; 104 107 105 108 Document& m_document; -
trunk/Source/WebCore/style/Styleable.cpp
r284313 r284693 212 212 } 213 213 214 void Styleable::updateCSSAnimations(const RenderStyle* currentStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle) const214 void Styleable::updateCSSAnimations(const RenderStyle* currentStyle, const RenderStyle& newStyle, const Style::ResolutionContext& resolutionContext) const 215 215 { 216 216 auto& keyframeEffectStack = ensureKeyframeEffectStack(); … … 262 262 263 263 if (!foundMatchingAnimation) 264 newAnimations.add(CSSAnimation::create(*this, currentAnimation, currentStyle, newStyle, parentElementStyle));264 newAnimations.add(CSSAnimation::create(*this, currentAnimation, currentStyle, newStyle, resolutionContext)); 265 265 } 266 266 } … … 389 389 // as its start time to ensure that it will produce a style with progress > 0. 390 390 bool shouldUseTimelineTimeAtCreation = is<CSSTransition>(animation) && (!animation->startTime() || *animation->startTime() == styleable.element.document().timeline().currentTime()); 391 animation->resolve(animatedStyle, nullptr, shouldUseTimelineTimeAtCreation ? downcast<CSSTransition>(*animation).timelineTimeAtCreation() : std::nullopt);391 animation->resolve(animatedStyle, { nullptr }, shouldUseTimelineTimeAtCreation ? downcast<CSSTransition>(*animation).timelineTimeAtCreation() : std::nullopt); 392 392 return animatedStyle; 393 393 } … … 409 409 if (is<CSSAnimation>(animation) && animation->isRelevant()) { 410 410 auto animatedStyle = RenderStyle::clone(newStyle); 411 animation->resolve(animatedStyle, nullptr);411 animation->resolve(animatedStyle, { nullptr }); 412 412 return animatedStyle; 413 413 } -
trunk/Source/WebCore/style/Styleable.h
r284313 r284693 86 86 } 87 87 88 OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const RenderStyle* parentElementStyle) const88 OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const Style::ResolutionContext& resolutionContext) const 89 89 { 90 return element.ensureKeyframeEffectStack(pseudoId).applyKeyframeEffects(targetStyle, previousLastStyleChangeEventStyle, parentElementStyle);90 return element.ensureKeyframeEffectStack(pseudoId).applyKeyframeEffects(targetStyle, previousLastStyleChangeEventStyle, resolutionContext); 91 91 } 92 92 … … 156 156 void removeDeclarativeAnimationFromListsForOwningElement(WebAnimation&) const; 157 157 158 void updateCSSAnimations(const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle, const RenderStyle* parentElementStyle) const;158 void updateCSSAnimations(const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle, const Style::ResolutionContext&) const; 159 159 void updateCSSTransitions(const RenderStyle& currentStyle, const RenderStyle& newStyle) const; 160 160 }; -
trunk/Source/WebCore/svg/SVGElement.cpp
r284447 r284693 639 639 } 640 640 641 std::optional<Style::ElementStyle> SVGElement::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle*)641 std::optional<Style::ElementStyle> SVGElement::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle*) 642 642 { 643 643 // If the element is in a <use> tree we get the style from the definition tree. 644 644 if (RefPtr styleElement = this->correspondingElement()) { 645 auto style = styleElement->resolveStyle(&parentStyle); 645 auto styleElementResolutionContext = resolutionContext; 646 // Can't use the selector filter since we are going to another part of the tree. 647 styleElementResolutionContext.selectorFilter = nullptr; 648 auto style = styleElement->resolveStyle(styleElementResolutionContext); 646 649 Style::Adjuster::adjustSVGElementStyle(*style.renderStyle, *this); 647 650 return style; 648 651 } 649 652 650 return resolveStyle( &parentStyle);653 return resolveStyle(resolutionContext); 651 654 } 652 655 -
trunk/Source/WebCore/svg/SVGElement.h
r283851 r284693 106 106 void setCorrespondingElement(SVGElement*); 107 107 108 std::optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;108 std::optional<Style::ElementStyle> resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* shadowHostStyle) override; 109 109 110 110 static QualifiedName animatableAttributeForName(const AtomString&); -
trunk/Source/WebCore/svg/SVGElementRareData.h
r284093 r284693 78 78 if (!m_overrideComputedStyle || m_needsOverrideComputedStyleUpdate) { 79 79 // The style computed here contains no CSS Animations/Transitions or SMIL induced rules - this is needed to compute the "base value" for the SMIL animation sandwhich model. 80 m_overrideComputedStyle = element.styleResolver().styleForElement(element, parentStyle, nullptr, RuleMatchingBehavior::MatchAllRulesExcludingSMIL).renderStyle;80 m_overrideComputedStyle = element.styleResolver().styleForElement(element, { parentStyle }, RuleMatchingBehavior::MatchAllRulesExcludingSMIL).renderStyle; 81 81 m_needsOverrideComputedStyleUpdate = false; 82 82 } -
trunk/Source/WebCore/testing/Internals.cpp
r284523 r284693 6019 6019 return { }; 6020 6020 6021 auto style = styleResolver.pseudoStyleForElement(element, { PseudoId::Highlight, highlightName }, *parentStyle);6021 auto style = styleResolver.pseudoStyleForElement(element, { PseudoId::Highlight, highlightName }, { parentStyle }); 6022 6022 if (!style) 6023 6023 return { };
Note:
See TracChangeset
for help on using the changeset viewer.