object-fit: scale-down is ignored when srcset attribute and w descriptor is used
Reported by
radek.s...@gmail.com,
Mar 5 2018
|
|||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 Steps to reproduce the problem: 1. Open url https://codepen.io/zipper/pen/vdwVLb 2. Image inside div is incorrectly scaled. 3. Similar behaviour is observed when sizes attribute is used https://codepen.io/zipper/pen/gvJBdp. What is the expected behavior? Image should be 400px wide, since it has "object-fit" property set to "scale-down" value. What went wrong? Image is up-scaled. Its size is either corresponding to sizes attribute or viewport width (when sizes is omitted). But source image is smaller and because of "object-fit: scale-down" it shouldn't be upscaled. On the other hand, "object-fit: cover" works (when width and height are explicitly set in CSS), see https://codepen.io/zipper/pen/PQvxwG - the sizes attributes is overridden by object-fit property. Did this work before? N/A Does this work in other browsers? Yes Chrome version: 64.0.3282.186 Channel: stable OS Version: 10.0 Flash Version: Tested in FireFox and MS Edge, both shows the image in correct size (400px, not up-scaled). One possible use case, when this may happen, is when the images are generated on back-end. We may not have large enough file to generate certain size. In that case we just send smaller file with appropriate width descriptor in srcset attribute, but the sizes attribute is not affected. Sizes attribute is not generated by the server, its copy-pasted from static template, since it depends on actual layout of the page (so it is basically written by a developer and doesn't change). This way we can prevent image from being up-scaled yet we can use responsive images and the behaviour can be controlled through CSS.
,
Mar 6 2018
radek.sery@ Thanks for the issue. Able to reproduce the issue on Windows 10, Mac OS 10.12.6 and Ubuntu 14.04 on the latest Canary 67.0.3361.0 and Stable 64.0.3282.186 by following the steps given above. On navigating to the given codepen, can see that the image not scaled correctly. Attached is the screen shot for reference. This is a Non-Regression issue as this behavior is observed from M60 Chrome builds. Hence marking this as Untriaged for further updates from Dev. Thanks..
,
Mar 9 2018
,
Mar 9 2018
Test case. This might be an easy fix so I'll look into it.
,
Mar 14 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/80441f0a1eb089bf4e9d755a7af5c3bfd3b787ec commit 80441f0a1eb089bf4e9d755a7af5c3bfd3b787ec Author: Stephen Chenney <schenney@chromium.org> Date: Wed Mar 14 14:51:01 2018 Fix the sizing when a srcset is used with scale-down The object-fit: scale-down property requires that the image be sized to the smaller of "none" or "contain". When a srcset is used, the IntrinsicSize of the image is scaled such that the srcset fills the expected area. This causes scale-down to consider the intrinsic size to be bigger than the actual image, and size things too large. This change modifies the intrinsic size for content-fit: scale-down in LayoutReplaced::ComputeObjectFit to un-apply the ImageDevicePixelRatio, that is the scale that resized the src. Chrome's behavior now matches Firefox. BUG= 818630 Change-Id: Ifbd63bbd6d905673e8058b49173b604cd9c8083e Reviewed-on: https://chromium-review.googlesource.com/957131 Commit-Queue: Stephen Chenney <schenney@chromium.org> Reviewed-by: Philip Rogers <pdr@chromium.org> Cr-Commit-Position: refs/heads/master@{#543082} [add] https://crrev.com/80441f0a1eb089bf4e9d755a7af5c3bfd3b787ec/third_party/WebKit/LayoutTests/fast/hidpi/image-srcset-fit-scale-down-expected.html [add] https://crrev.com/80441f0a1eb089bf4e9d755a7af5c3bfd3b787ec/third_party/WebKit/LayoutTests/fast/hidpi/image-srcset-fit-scale-down.html [modify] https://crrev.com/80441f0a1eb089bf4e9d755a7af5c3bfd3b787ec/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
,
Mar 14 2018
This fix will roll out in Chrome 67. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by krajshree@chromium.org
, Mar 6 2018Labels: Needs-Triage-M64