Chromium Code Reviews
DescriptionMake `getComputedStyle` return the correct style for collapsed <img> elements.
HTMLImageElements can be in the `collapsed` state, meaning they are not
included in the layout. Previously, this was implemented by overriding
layoutObjectIsNeeded() to return false so that no LayoutObject would be
created.
A disadvantage of this solution was that the style returned through the
`window.getComputedStyle` method was not consistent with the element's
effective style, for example, the `display` property was still set to `inline`.
As a matter of fact, the ComputedStyle calculated during layout was not even
persisted, and the style returned through the DOM API was calculated on-demand
in Element::ensureComputedStyle. This code path is also oblivious of style
customizations that would otherwise be applied during style recalculation by
Element::customStyleForLayoutObject for some element types.
Therefore this CL instead implements the `collapsed` state by explicitly
setting the `display` property from StyleAdjuster::adjustComputedStyle, which
is consulted directly by StyleResolver::styleForElement, and is therefore
applied in both Element::ensureComputedStyle and Element::styleForLayoutObject.
As a side effect, SharedStyleFinder now has to perform HTLMImageElement-specific
checks to prevent sharing styles between `collapsed` and `non-collapsed` images.
Marking the ComputedStyle for `collapsed` images as unique is not sufficient,
because it does not prevent reusing the ComputedStyle from a `non-collapsed`
image element on a `collapsed` one.
BUG=609747, 682243
Review-Url: https://codereview.chromium.org/2627953003
Cr-Commit-Position: refs/heads/master@{#450694}
Committed: https://chromium.googlesource.com/chromium/src/+/d77ba4c9ecb5315db4dc26ac3f42ff767e94ae63
Patch Set 1 #Patch Set 2 : Move logic to StyleAdjuster. #
Total comments: 1
Patch Set 3 : Rebase. #Messages
Total messages: 33 (19 generated)
|