Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Issue 2627953003: Make `getComputedStyle` return the correct style for collapsed <img> elements. (Closed)

Created:
3 years, 11 months ago by engedy
Modified:
3 years, 10 months ago
CC:
darktears, blink-reviews, blink-reviews-animation_chromium.org, blink-reviews-dom_chromium.org, blink-reviews-html_chromium.org, blink-reviews-style_chromium.org, chromium-reviews, dglazkov+blink, eae+blinkwatch, Eric Willigers, rjwright, rwlbuis, shans, sof
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Make `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)
engedy
@Elliott, @Dominic: This is a follow-up to [1] to address the discrepancy between the DOM-visible ...
3 years, 11 months ago (2017-01-12 18:12:27 UTC) #7
esprehn
Why do you need to cache the style like <option> ? I don't think you ...
3 years, 11 months ago (2017-01-12 19:45:38 UTC) #8
engedy
On 2017/01/12 19:45:38, esprehn wrote: > Why do you need to cache the style like ...
3 years, 11 months ago (2017-01-12 20:21:19 UTC) #9
esprehn
Yeah interesting, that is a bug in the design of this system that modifications are ...
3 years, 11 months ago (2017-01-12 20:28:06 UTC) #10
engedy
On 2017/01/12 20:28:06, esprehn wrote: > Yeah interesting, that is a bug in the design ...
3 years, 11 months ago (2017-01-12 20:42:58 UTC) #11
engedy
Done, please take another look. One more caveat: 3) Now we have an element-specific check ...
3 years, 11 months ago (2017-01-18 22:02:47 UTC) #17
engedy
@Elliott, what do you think of caveats 1..3?
3 years, 11 months ago (2017-01-20 16:52:52 UTC) #21
engedy
Friendly ping.
3 years, 11 months ago (2017-01-24 17:43:57 UTC) #22
engedy
@Elliott, friendly ping.
3 years, 10 months ago (2017-02-08 10:22:11 UTC) #23
esprehn
lgtm https://codereview.chromium.org/2627953003/diff/40001/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp File third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp (right): https://codereview.chromium.org/2627953003/diff/40001/third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp#newcode292 third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp:292: toHTMLImageElement(element()).isCollapsed()) { good catch!
3 years, 10 months ago (2017-02-15 02:08:46 UTC) #24
esprehn
On 2017/01/18 at 22:02:47, engedy wrote: > Done, please take another look. One more caveat: ...
3 years, 10 months ago (2017-02-15 02:09:26 UTC) #25
engedy
On 2017/02/15 02:09:26, esprehn wrote: > On 2017/01/18 at 22:02:47, engedy wrote: > > Done, ...
3 years, 10 months ago (2017-02-15 13:18:24 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2627953003/60001
3 years, 10 months ago (2017-02-15 13:23:36 UTC) #30
commit-bot: I haz the power
3 years, 10 months ago (2017-02-15 14:52:09 UTC) #33
Message was sent while issue was closed.
Committed patchset #3 (id:60001) as
https://chromium.googlesource.com/chromium/src/+/d77ba4c9ecb5315db4dc26ac3f42...

Powered by Google App Engine
This is Rietveld 408576698