WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
206161
getComputedStyle(img).height returns string of a rounded int not a float
https://bugs.webkit.org/show_bug.cgi?id=206161
Summary
getComputedStyle(img).height returns string of a rounded int not a float
cathiechen
Reported
2020-01-12 21:04:34 PST
According to the spec getComputedStyle(img).height should return the "Used Value" if img isn't display:none. The "Used Value" of height is (used width) / (intrinsic ratio). So it can be a float, while WebKit always returns rouned int. (
https://www.w3.org/TR/CSS21/visudet.html#propdef-height
) The related test: LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio.html
Attachments
testcase
(719 bytes, text/html)
2020-01-14 02:26 PST
,
Frédéric Wang (:fredw)
no flags
Details
testcase
(722 bytes, text/html)
2020-01-14 02:28 PST
,
Frédéric Wang (:fredw)
no flags
Details
Add_img_test_cases
(1.88 KB, text/html)
2020-01-15 04:07 PST
,
cathiechen
no flags
Details
Add_img_test_cases
(1.92 KB, text/html)
2020-01-15 05:55 PST
,
cathiechen
no flags
Details
Patch
(6.13 KB, patch)
2020-01-17 07:03 PST
,
cathiechen
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Frédéric Wang (:fredw)
Comment 1
2020-01-14 02:25:45 PST
These are the relevant spec definitions: getComputedStyle():
https://drafts.csswg.org/cssom/#extensions-to-the-window-interface
CSS declaration block:
https://drafts.csswg.org/cssom/#css-declaration-block
CSS declaration:
https://drafts.csswg.org/cssom/#css-declaration
Serialize a CSS declaration:
https://drafts.csswg.org/cssom/#serialize-a-css-declaration
Serialize a CSS value:
https://drafts.csswg.org/cssom/#serialize-a-css-value
Serialize a CSS component value:
https://drafts.csswg.org/cssom/#serialize-a-css-component-value
<length> The <number> component serialized as per <number> followed by the unit in its canonical form as defined in its respective specification. ISSUE 12: Probably should distinguish between specified and computed / resolved values. <number> A base-ten number using digits 0-9 (U+0030 to U+0039) in the shortest form possible, using "." to separate decimals (if any), rounding the value if necessary to not produce more than 6 decimals, preceded by "-" (U+002D) if it is negative. Note: scientific notation is not used. <percentage> The <number> component serialized as per <number> followed by the literal string "%" (U+0025).
Frédéric Wang (:fredw)
Comment 2
2020-01-14 02:26:58 PST
Created
attachment 387638
[details]
testcase Serialization seems to happen as expected in Gecko/Blink/WebKit with the attached testcase.
Frédéric Wang (:fredw)
Comment 3
2020-01-14 02:28:37 PST
Created
attachment 387639
[details]
testcase
cathiechen
Comment 4
2020-01-15 04:07:58 PST
Created
attachment 387775
[details]
Add_img_test_cases Hi Fred, This issue seems only related to RenderReplaced, i.e, use intrinsic aspect-ratio to compute width / height. In RenderReplaced::computeReplacedLogicalWidth and RenderReplaced::computeReplacedLogicalHeight, roundToInt is called. PS: Append <img> test to your case.
cathiechen
Comment 5
2020-01-15 05:55:25 PST
Created
attachment 387784
[details]
Add_img_test_cases
cathiechen
Comment 6
2020-01-17 07:03:15 PST
Created
attachment 388035
[details]
Patch
Radar WebKit Bug Importer
Comment 7
2022-05-24 15:00:17 PDT
<
rdar://problem/93860607
>
Sammy Gill
Comment 8
2022-05-31 14:16:52 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/1191
EWS
Comment 9
2022-06-21 16:29:20 PDT
Committed
r295701
(
251706@main
): <
https://commits.webkit.org/251706@main
> Reviewed commits have been landed. Closing PR #1191 and removing active labels.
Sammy Gill
Comment 10
2022-06-29 10:34:49 PDT
Re-opening for pull request
https://github.com/WebKit/WebKit/pull/1902
EWS
Comment 11
2022-06-29 10:47:31 PDT
Committed
251955@main
(5d047d546dd9): <
https://commits.webkit.org/251955@main
> Reviewed commits have been landed. Closing PR #1902 and removing active labels.
Sammy Gill
Comment 12
2022-06-30 13:32:20 PDT
Patch has been reverted due to regression reported in 242079. Reopening.
Sammy Gill
Comment 13
2022-07-06 14:25:43 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/2138
EWS
Comment 14
2022-07-18 15:56:06 PDT
Committed
252583@main
(e2c4f937d459): <
https://commits.webkit.org/252583@main
> Reviewed commits have been landed. Closing PR #2138 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug