Skip to content

Commit

Permalink
Bug 1580000 [wpt PR 18945] - Compute img aspect ratio from width and …
Browse files Browse the repository at this point in the history
…height HTML attributes, a=testonly

Automatic update from web-platform-tests
Compute img aspect ratio from width and height HTML attributes

As per this intent to implement:
https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/blink-dev/hbhKRuBzZ4o

Spec:
WICG/intrinsicsize-attribute#16

Bug: 979891
Change-Id: I0f9ffa1584fa12a41393ef05daffb7238c97e990
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1790472
Commit-Queue: Christian Biesinger <cbiesingerchromium.org>
Reviewed-by: Emilio Cobos Álvarez <emiliochromium.org>
Auto-Submit: Christian Biesinger <cbiesingerchromium.org>
Cr-Commit-Position: refs/heads/master{#699465}

--

wpt-commits: 86ff86de45a67eccc781b84f50ab261c18aad5cf
wpt-pr: 18945

UltraBlame original commit: e8962724f6cc584847fedccd8c0912b6bd00dab6
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent c672500 commit e0adfd9
Show file tree
Hide file tree
Showing 3 changed files with 918 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
<
!
doctype
html
>
<
title
>
Canvas
width
and
height
attributes
are
used
to
infer
aspect
-
ratio
<
/
title
>
<
script
src
=
"
/
resources
/
testharness
.
js
"
>
<
/
script
>
<
script
src
=
"
/
resources
/
testharnessreport
.
js
"
>
<
/
script
>
<
style
>
canvas
{
width
:
100
%
;
max
-
width
:
100px
;
height
:
auto
;
}
<
/
style
>
<
body
>
<
script
>
let
t
=
async_test
(
"
Canvas
width
and
height
attributes
are
used
to
infer
aspect
-
ratio
"
)
;
function
assert_ratio
(
img
expected
)
{
let
epsilon
=
0
.
001
;
assert_approx_equals
(
parseInt
(
getComputedStyle
(
img
)
.
width
10
)
/
parseInt
(
getComputedStyle
(
img
)
.
height
10
)
expected
epsilon
)
;
}
/
/
Create
and
append
a
new
canvas
and
immediately
check
the
ratio
.
t
.
step
(
function
(
)
{
var
canvas
=
document
.
createElement
(
"
canvas
"
)
;
canvas
.
setAttribute
(
"
width
"
"
250
"
)
;
canvas
.
setAttribute
(
"
height
"
"
100
"
)
;
document
.
body
.
appendChild
(
canvas
)
;
/
/
Canvases
always
use
the
aspect
ratio
from
their
surface
size
.
assert_ratio
(
canvas
2
.
5
)
;
t
.
done
(
)
;
}
)
;
<
/
script
>
Loading

0 comments on commit e0adfd9

Please sign in to comment.