Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map width and height to aspect-ratio in <canvas>, <input type=image>,…
… and <video>. As per https://html.spec.whatwg.org/#attributes-for-embedded-content-and-images: > The width and height attributes map to the aspect-ratio property on > img, canvas, and video elements, and input elements with a type > attribute in the Image Button state. See whatwg/html#6527 for the parsing issue with canvas and zero. For now allow both behaviors in the tests. We also remove the width-and-height-map-to-aspect-ratio pref, as it is true everywhere and has been for a while. Differential Revision: https://phabricator.services.mozilla.com/D109618 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1700640 gecko-commit: 985b66b916980b78328063dfdccdc5e5b71318e5 gecko-reviewers: boris
- Loading branch information
1 parent
8e9b781
commit 1bf1089
Showing
4 changed files
with
61 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 16 additions & 8 deletions
24
...ng/replaced-elements/attributes-for-embedded-content-and-images/resources/aspect-ratio.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
function test_computed_style_aspect_ratio(tag, attributes, expected) { | ||
var elem = document.createElement(tag); | ||
for (name in attributes) { | ||
let val = attributes[name]; | ||
if (val !== null) | ||
elem.setAttribute(name, val); | ||
} | ||
document.body.appendChild(elem); | ||
assert_equals(getComputedStyle(elem).aspectRatio, expected); | ||
test(function() { | ||
var elem = document.createElement(tag); | ||
for (name in attributes) { | ||
let val = attributes[name]; | ||
if (val !== null) | ||
elem.setAttribute(name, val); | ||
} | ||
document.body.appendChild(elem); | ||
let aspectRatio = getComputedStyle(elem).aspectRatio; | ||
if (Array.isArray(expected)) { | ||
assert_in_array(aspectRatio, expected); | ||
} else { | ||
assert_equals(aspectRatio, expected); | ||
} | ||
elem.remove(); | ||
}, `${tag} with ${JSON.stringify(attributes)}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters