New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 773284 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 418901



Sign in to add a comment

Small (or zero) pixel densities yield incorrect naturalWidth/Height

Project Member Reported by f...@opera.com, Oct 10 2017

Issue description

Subtests:

  <img srcset="/images/green-256x256.png 10000x" data-expect="0"> and
  <img srcset="/images/green-256x256.png 256w" sizes="0px" data-expect="0">

of http://wpt.fyi/html/semantics/embedded-content/the-img-element/current-pixel-density/basic.html , fails because empty sizes can not be returned from ImageResourceContent::ImageSize (it clamps pre-scaling non-empty dimensions to 1.)

 
Project Member

Comment 1 by bugdroid1@chromium.org, Oct 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/936948502c48693965289070e089df54cc32a273

commit 936948502c48693965289070e089df54cc32a273
Author: Fredrik Söderquist <fs@opera.com>
Date: Fri Oct 13 08:38:13 2017

Handle small/zero pixel densities correctly for img.naturalWidth/Height

ImageResourceContent::ImageSize has some special logic for clamping
image dimension that end up as "zero" (LayoutUnits) to one after having
been scaled by the multiplier it is passed.
This "correction" means that for images with a small/zero pixel density,
we'll end up returning 1 even when the density corrected dimension is
(integral) 0.

To handle this, pass 1 as the multiplier to avoid the dimension clamping
and perform the pixel scaling "manually".
While doing this also move the pixel density correction code to
HTMLImageElement, and get rid of the code from ImageResourceContent,
since it only used for <img> naturalWidth/naturalHeight.
This makes ImageResourceContent::SizeType only have a single value, so
remove the enumeration and the argument.

Bug: 773272,  773284 
Change-Id: Ie4a907d6cb7f262c876a5010bb7dd6a92af1cb9a
Reviewed-on: https://chromium-review.googlesource.com/708815
Reviewed-by: Philip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#508646}
[modify] https://crrev.com/936948502c48693965289070e089df54cc32a273/third_party/WebKit/LayoutTests/external/wpt/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt
[modify] https://crrev.com/936948502c48693965289070e089df54cc32a273/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h
[modify] https://crrev.com/936948502c48693965289070e089df54cc32a273/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
[modify] https://crrev.com/936948502c48693965289070e089df54cc32a273/third_party/WebKit/Source/core/html/HTMLImageElement.h
[modify] https://crrev.com/936948502c48693965289070e089df54cc32a273/third_party/WebKit/Source/core/loader/resource/ImageResourceContent.cpp
[modify] https://crrev.com/936948502c48693965289070e089df54cc32a273/third_party/WebKit/Source/core/loader/resource/ImageResourceContent.h

Comment 2 by f...@opera.com, Oct 13 2017

Status: Fixed (was: Assigned)

Sign in to add a comment