Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reverting to/from css-logical properties #22614

Merged
merged 1 commit into from Apr 3, 2020

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Apr 1, 2020

The properties defined by css-logical (and more generally surrogates)
pose a hard problem for 'revert' in the StyleCascade, because
declarations such as 'margin-bottom:revert' may actually need to revert
to a different property in the previous origin (e.g. margin-block-end).

An example is the h1 element, which is styled by html.css using
css-logical properties. When the author then reverts using a
corresponding physical property, we can't simply look up the cascaded
value for that same physical property in the UA origin: we must be
aware that the css-logical property won the cascade at that level.

So when we we're applying an author declaration 'margin-bottom:revert',
we have to find the target property for the revert, which is either
margin-bottom (if that property won the cascade at the target origin),
or the corresponding css-logical property. However, to find the target
property, we need to know during the application of margin-bottom that
a corresponding logical property (surrogate) needs to be taken into
account. AutoSurrogateScope was created for this purpose, which sets
(and resets) a "current surrogate" field on CascadeResolver. This
current surrogate is used when resolving reverts, in order to find
the correct target property.

Also, we don't control the order in which physical/logical properties
are applied. This means we could be applying the physical property
first, which is unaware of any logical properties that should have been
taken into account for revert. In other words, if we apply
'margin-bottom:revert' without the context of a "current surrogate" set,
we'll fall back to unconditionally using margin-bottom as the target
property, which may be incorrect if there also exists a logical
property we'll get to later. This is why the force-reapply code exists:
when both the physical and logical property exists in the cascade,
the physical property must be applied (or re-applied) during
AutoSurrogateScope, otherwise revert will not behave correctly.

Bug: 579788
Change-Id: I864a4c9afdd94f130c42635d28d45c843d5fb617
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2130850
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756419}

Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

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

The review process for this patch is being conducted in the Chromium project.

The properties defined by css-logical (and more generally surrogates)
pose a hard problem for 'revert' in the StyleCascade, because
declarations such as 'margin-bottom:revert' may actually need to revert
to a different property in the previous origin (e.g. margin-block-end).

An example is the h1 element, which is styled by html.css using
css-logical properties. When the author then reverts using a
corresponding physical property, we can't simply look up the cascaded
value for that same physical property in the UA origin: we must be
aware that the css-logical property won the cascade _at that level_.

So when we we're applying an author declaration 'margin-bottom:revert',
we have to find the *target property* for the revert, which is either
margin-bottom (if that property won the cascade at the target origin),
or the corresponding css-logical property. However, to find the target
property, we need to know during the application of margin-bottom that
a corresponding logical property (surrogate) needs to be taken into
account. AutoSurrogateScope was created for this purpose, which sets
(and resets) a "current surrogate" field on CascadeResolver. This
current surrogate is used when resolving reverts, in order to find
the correct target property.

Also, we don't control the order in which physical/logical properties
are applied. This means we could be applying the physical property
first, which is unaware of any logical properties that should have been
taken into account for revert. In other words, if we apply
'margin-bottom:revert' without the context of a "current surrogate" set,
we'll fall back to unconditionally using margin-bottom as the target
property, which may be incorrect if there also exists a logical
property we'll get to later. This is why the force-reapply code exists:
when both the physical and logical property exists in the cascade,
the physical property must be applied (or re-applied) during
AutoSurrogateScope, otherwise revert will not behave correctly.

Bug: 579788
Change-Id: I864a4c9afdd94f130c42635d28d45c843d5fb617
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2130850
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756419}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants