Open Bug 1857498 Opened 2 years ago Updated 2 years ago

[wpt-sync] Sync PR 42393 - Remove AllowMarkStyleDirtyFromRecalcScope for <img> fallbacks

Categories

(Core :: Layout: Generated Content, Lists, and Counters, task, P4)

task

Tracking

()

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 42393 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/42393
Details from upstream follow.

Anders Hartvoll Ruud <andruud@chromium.org> wrote:

Remove AllowMarkStyleDirtyFromRecalcScope for <img> fallbacks

During HTMLImageElement::AdjustStyle, we do something very shady:
we poke into the UA shadow and mutate the inline style of some
of the elements in there. This causes style to be marked dirty
during style recalc, which is not a desirable situation.
The behavior would normally trigger a DCHECK, but it is currently
suppressed with by AllowMarkStyleDirtyFromRecalcScope.

Marking style dirty deeper in the current subtree works (sort of),
because we'll eventually reach those elements during the current
style recalc process anyway, so ultimately the dirtiness is
cleared. However, StyleResolver::ResolveStyle can also be called
outside of style recalc. For example, when producing styles
for kFirstLineInherited, we call ResolveStyle during layout.
In this case, there is no greater style recalc process ongoing,
so the dirtiness isn't cleared, and we trigger DCHECKs
(Issue 1486128).

This CL addresses the problem as follows:

  • When adjusting the style for the UA shadow host (\<img>),
    we capture the state descendants care about into an
    inherited object StyleHostData.
  • Later, when recalculating the style of descendants (inside
    the shadow), we give the elements an opportunity to produce
    an "extra" CSSPropertyValueSet which is added into the cascade.
    This CSSPropertyValueSet can be produced based on the previously
    captured StyleHostData.

Fixed: 953707, 1486128
Change-Id: I856eaa95df2b68fb35cbe00714f9a43af9537d4f
Reviewed-on: https://chromium-review.googlesource.com/4916302
WPT-Export-Revision: b480bdcf73e8ebffed2923cceb45872d15bde521

Component: web-platform-tests → Layout: Generated Content, Lists, and Counters
Product: Testing → Core
You need to log in before you can comment on or make changes to this bug.