Skip to content

Always provide a CSSSelectorParserContext to pseudoElementIdentifierFromString in WebCore/animation#59160

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
annevk:pseudoElementIdentifierFromString
Feb 25, 2026
Merged

Always provide a CSSSelectorParserContext to pseudoElementIdentifierFromString in WebCore/animation#59160
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
annevk:pseudoElementIdentifierFromString

Conversation

@annevk
Copy link
Contributor

@annevk annevk commented Feb 21, 2026

@annevk annevk self-assigned this Feb 21, 2026
@annevk annevk added the Animations Bugs related to CSS + SVG animations and transitions label Feb 21, 2026
@webkit-early-warning-system

This comment was marked as outdated.

@annevk

This comment was marked as outdated.

@webkit-ews-buildbot

This comment was marked as outdated.

@webkit-ews-buildbot

This comment was marked as outdated.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 21, 2026
bool compareAnimationEventsByCompositeOrder(const AnimationEventBase&, const AnimationEventBase&);
String pseudoElementIdentifierAsString(const std::optional<Style::PseudoElementIdentifier>&);
std::pair<bool, std::optional<Style::PseudoElementIdentifier>> pseudoElementIdentifierFromString(const String&, Document*);
std::pair<bool, std::optional<Style::PseudoElementIdentifier>> pseudoElementIdentifierFromString(const String&, Document&);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just provide the CSSSelectorParserContext. (I would probably move this function and its twin, pseudoElementIdentifierAsString, to less animation specific files, but that's for another time).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am interested in doing this, but I first want to know what pseudo-element API gaps the animation API still has.

if (RefPtr document = context.client.document())
return LineWidth::snapLengthAsBorderWidth(blendedValue, document->deviceScaleFactor());
return blendedValue;
return LineWidth::snapLengthAsBorderWidth(blendedValue, context.client.document().deviceScaleFactor());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label Feb 24, 2026
@annevk annevk changed the title Always provide a document to pseudoElementIdentifierFromString in WebCore/animation Always provide a CSSSelectorParserContext to pseudoElementIdentifierFromString in WebCore/animation Feb 24, 2026
@annevk annevk force-pushed the pseudoElementIdentifierFromString branch from 2b64801 to f1a7222 Compare February 24, 2026 13:41
@annevk annevk requested a review from weinig February 24, 2026 13:42
{
RefPtr node = dynamicDowncast<Node>(target());
auto [parsed, pseudoElementIdentifier] = pseudoElementIdentifierFromString(m_pseudoElement, node ? protect(node->document()).ptr() : nullptr);
auto [parsed, pseudoElementIdentifier] = pseudoElementIdentifierFromString(m_pseudoElement, CSSSelectorParserContext { node ? protect(node->document()).get() : document });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think using the node is useful here anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can be different though. Would be a somewhat obscure test if one can be constructed at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make a difference for the CSSParserContext. It's also pretty arbitrary in this context that we end up branching on the existance of the target node, that means the exact document doesn't really matter to us in this specific case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why it doesn't make a difference? If we ever added some kind of pseudo-element quirk it could matter, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so, but my second point still stands

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but then it should be a separate change from this refactor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems ok if you want to do this in a followup, but it shouldn't be risky to do it in the same change


ASSERT(document());
auto& settings = document()->settings();
auto& settings = document().settings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you Ref that baby while you're nearby?

if (RefPtr document = this->document()) {
auto& settings = document->settings();
auto isMarker = m_pseudoElementIdentifier && m_pseudoElementIdentifier->type == PseudoElementType::Marker;
auto& settings = document().settings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use Ref here too.

Copy link
Contributor

@graouts graouts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could makes the Ref changes when referencing settings if you like, but I do realize it would mean further changes to where those settings are used.


ASSERT(document());
auto& settings = document()->settings();
auto& settings = document().settings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref


ASSERT(document());
auto& settings = document()->settings();
auto& settings = document().settings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref


ASSERT(document());
auto& settings = document()->settings();
auto& settings = document().settings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref

bool isPropertyAdditiveOrCumulative(KeyframeInterpolation::Property) const final;

WeakPtr<Document, WeakPtrImplWithEventTargetData> m_document;
WeakRef<Document, WeakPtrImplWithEventTargetData> m_document;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice.


ASSERT(effect.document());
auto& settings = effect.document()->settings();
auto& settings = effect.document().settings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref

@annevk
Copy link
Contributor Author

annevk commented Feb 25, 2026

@graouts according to expectation files AcceleratedEffect.cpp doesn't have anything unsafe left. It's not clear to me that we need to reference settings as most of the methods on there are trivial. I suspect the same applies to the usage in KeyframeEffect.cpp. As we don't want to unnecessarily ref I'm not going to apply those suggestions.

(Eventually we'll get an anti-ref checker that would highlight where we could have avoided taking a reference.)

@annevk annevk added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 25, 2026
…romString in WebCore/animation

https://bugs.webkit.org/show_bug.cgi?id=308385

Reviewed by Antoine Quint and Tim Nguyen.

For KeyframeEffect the document can in fact not be null and for
synthetic animation events we can forward a document from JavaScript.

Canonical link: https://commits.webkit.org/308181@main
@webkit-commit-queue webkit-commit-queue force-pushed the pseudoElementIdentifierFromString branch from f1a7222 to 7663646 Compare February 25, 2026 05:51
@webkit-commit-queue
Copy link
Collaborator

Committed 308181@main (7663646): https://commits.webkit.org/308181@main

Reviewed commits have been landed. Closing PR #59160 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 7663646 into WebKit:main Feb 25, 2026
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 25, 2026
@annevk annevk deleted the pseudoElementIdentifierFromString branch February 25, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Animations Bugs related to CSS + SVG animations and transitions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants