WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
150443
<img>.naturalWidth should return the density-corrected intrinsic width
https://bugs.webkit.org/show_bug.cgi?id=150443
Summary
<img>.naturalWidth should return the density-corrected intrinsic width
Simon Pieters (:zcorpan)
Reported
2015-10-22 03:39:04 PDT
Consider <img srcset="
http://placehold.it/240
2x" onload="alert(this.naturalWidth)"> Per spec it should alert 120. WebKit alerts 240. Gecko and Blink match the spec, I don't know about Edge.
https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-naturalwidth
I would recommend waiting with fixing this bug until .currentSrc is implemented, since exploiting this bug can be a poor man's .currentSrc; see
http://stackoverflow.com/questions/33231426/get-the-currentsrc-of-responsive-image-on-safari/33278821
Attachments
Patch
(4.96 KB, patch)
2019-12-25 06:53 PST
,
Noam Rosenthal
no flags
Details
Formatted Diff
Diff
Patch
(12.26 KB, patch)
2019-12-25 13:58 PST
,
Noam Rosenthal
no flags
Details
Formatted Diff
Diff
Patch
(12.25 KB, patch)
2020-01-08 10:32 PST
,
Noam Rosenthal
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Noam Rosenthal
Comment 1
2019-12-25 06:53:24 PST
Created
attachment 386408
[details]
Patch
Noam Rosenthal
Comment 2
2019-12-25 13:58:43 PST
Created
attachment 386412
[details]
Patch
Simon Fraser (smfr)
Comment 3
2020-01-08 10:05:40 PST
Comment on
attachment 386412
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=386412&action=review
> Source/WebCore/html/HTMLImageElement.cpp:534 > +float HTMLImageElement::effectiveImageDevicePixelRatio() const
The "device" in the name is confusing, but I guess we already have m_imageDevicePixelRatio.
> Source/WebCore/loader/cache/CachedImage.h:81 > + LayoutSize nonClampedImageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType = UsedSize) const;
Maybe unclamped
> LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/intrinsicsize/intrinsicsize-with-responsive-images.tentative-expected.txt:8 > -FAIL Test image /images/green.png with width = 800, height = 800, and no specified sizes assert_equals: naturalWidth expected 400 but got 100 > +FAIL Test image /images/green.png with width = 800, height = 800, and no specified sizes assert_equals: naturalWidth expected 400 but got 33
Do you understand this behavior change?
Noam Rosenthal
Comment 4
2020-01-08 10:17:14 PST
> Maybe unclamped
OKEY
>> +FAIL Test image /images/green.png with width = 800, height = 800, and no specified sizes assert_equals: naturalWidth expected 400 but got 33
> Do you understand this behavior change?
Yes, it's the expected behavior change. That test happens to have images with srcset, and it's asking for their natural width/height.
Noam Rosenthal
Comment 5
2020-01-08 10:32:59 PST
Created
attachment 387112
[details]
Patch
EWS
Comment 6
2020-01-08 11:55:48 PST
Comment on
attachment 387112
[details]
Patch Rejecting
attachment 387112
[details]
from commit-queue.
noam@webkit.org
does not have committer permissions according to
https://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/contributors.json
. - If you do not have committer rights please read
http://webkit.org/coding/contributing.html
for instructions on how to use bugzilla flags. - If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/contributors.json by adding yourself to the file (no review needed). The commit-queue restarts itself every 2 hours. After restart the commit-queue will correctly respect your committer rights.
WebKit Commit Bot
Comment 7
2020-01-08 15:38:55 PST
Comment on
attachment 387112
[details]
Patch Clearing flags on attachment: 387112 Committed
r254229
: <
https://trac.webkit.org/changeset/254229
>
WebKit Commit Bot
Comment 8
2020-01-08 15:38:57 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 9
2020-01-08 15:39:24 PST
<
rdar://problem/58424497
>
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