getComputedStyle(element).width|height always returns 'auto' for objects to which width|height doesn't apply |
|||||||||
Issue descriptionThis is a tiny issue about resolved value of non-applicable 'width' or 'height' property. I guess most web developers don't care about whether the resolved value is always 'auto' or the real computed value. Feel free to mark it as WontFix. <span id="span" style="width: 20%">SPAN</span> <script> console.log(getComputedStyle(span).width) </script> Chrome shows 'auto'. FireFox shows '20%'. According to specs: - https://www.w3.org/TR/CSS2/visudet.html#the-width-property: The 'width' property doesn't apply to non-replaced inline elements - https://drafts.csswg.org/cssom/#resolved-value: getComputeStyle() returns resolved values. For a property that doesn't apply, the resolved value is the computed value - https://www.w3.org/TR/CSS2/cascade.html#computed-value: The computed value exists even when the property doesn't apply the resolved value of 'width' of an inline element should be the computed value which should be '20%' instead of 'auto' for the above case.
,
Apr 6 2017
,
Apr 7 2017
,
Apr 7 2017
,
Apr 7 2017
,
Oct 26 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/4531dfc9b26fa49e93c76f2168ee35e7e00783f0 commit 4531dfc9b26fa49e93c76f2168ee35e7e00783f0 Author: Fredrik Söderquist <fs@opera.com> Date: Thu Oct 26 16:45:46 2017 Rework computed style handling for 'width' and 'height' getComputedStyle(...) for 'width' and 'height' would always return 'auto' for layout objects to which said property did not "apply" (by some fuzzy heuristic.) This specifically broke for some SVG elements where 'width' and 'height' apply (<rect>, <image> and <foreignObject>), but is also wrong more generally - per CSSOM [1]. Rework the relevant parts of ComputedStyleCSSValueMapping::Get to consider if the used value or the computed value should be used for the respective property. The new helper (WidthOrHeightShouldReturnUsedValue) replaces the old WidthOrHeightPropertyAppliesToObject, while removing the explicit return of an 'auto' identifier. 'auto' (or any other computed value) will now be returned via ZoomAdjustedPixelValueForLength if the resolved value is not the used value. This is a behavioral change, and matches the behavior of Gecko. Fold the old svg/css/getComputedStyle-svg-text-width-height.html test into a new one that cover more (SVG) cases. [1] https://drafts.csswg.org/cssom/#resolved-value Bug: 708888 , 772707 Change-Id: I573362a03c9e0d98251bdbcf4e9854a5a5d8dd67 Reviewed-on: https://chromium-review.googlesource.com/707103 Reviewed-by: Philip Rogers <pdr@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Commit-Queue: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/master@{#511848} [modify] https://crrev.com/4531dfc9b26fa49e93c76f2168ee35e7e00783f0/third_party/WebKit/LayoutTests/external/wpt/html/semantics/embedded-content/the-object-element/object-attributes-expected.txt [modify] https://crrev.com/4531dfc9b26fa49e93c76f2168ee35e7e00783f0/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-resolved-values-expected.txt [modify] https://crrev.com/4531dfc9b26fa49e93c76f2168ee35e7e00783f0/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt [modify] https://crrev.com/4531dfc9b26fa49e93c76f2168ee35e7e00783f0/third_party/WebKit/LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html [modify] https://crrev.com/4531dfc9b26fa49e93c76f2168ee35e7e00783f0/third_party/WebKit/LayoutTests/inspector-protocol/dom-snapshot/dom-snapshot-getSnapshot-expected.txt [modify] https://crrev.com/4531dfc9b26fa49e93c76f2168ee35e7e00783f0/third_party/WebKit/LayoutTests/svg/css/getComputedStyle-listing-expected.txt [delete] https://crrev.com/a750f6b5df4c79c4673e472d1c9b8911a1e68282/third_party/WebKit/LayoutTests/svg/css/getComputedStyle-svg-text-width-height.html [add] https://crrev.com/4531dfc9b26fa49e93c76f2168ee35e7e00783f0/third_party/WebKit/LayoutTests/svg/css/getcomputedstyle-width-height.html [modify] https://crrev.com/4531dfc9b26fa49e93c76f2168ee35e7e00783f0/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
,
Oct 30 2017
,
Dec 6 2017
,
Dec 6
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 6
The #c0 test case has been fixed by #c6 CL. |
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by r...@opera.com
, Apr 6 2017