Bug 1645712 [wpt PR 24143] - Fixes img without src but with title doesn't respect CSS dimensions., a=testonly
authorYu Han <yuzhehan@chromium.org>
Mon, 22 Jun 2020 10:41:33 +0000
changeset 536833 5e1ec38dd7a121a93b8831c899102e13d69fd377
parent 536832 fcb96ec497a6f4d5fd284bea46b80d4ebf7735b1
child 536834 2b3d5e91ef77dc3ec3db0016cb6b59a89313c011
push id119680
push userwptsync@mozilla.com
push dateTue, 23 Jun 2020 11:08:22 +0000
treeherderautoland@7ca3d4bada73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1645712, 24143, 958250, 2239473, 779100
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1645712 [wpt PR 24143] - Fixes img without src but with title doesn't respect CSS dimensions., a=testonly Automatic update from web-platform-tests Fixes img without src but with title doesn't respect CSS dimensions. Prior to this CL, img with CSS height, width and a title attribute is treated as inline text without the CSS dimensions applied. The reason is that title attribute is treated as a backup for alt text [1]. Thus, this prevents the img to be treated as replaced element with intrinsic dimensions [2]:represents-2, but it's treated as non-replaced text [2]:represents-3 where the CSS dimensions are ignored. The fix is instead of checking the HTMLElement::AltText(), check only the presence of alt attribute when determining if the element should be treated as a replaced element. I had considered making the fix in [1] so that AltText() doesn't fallback to title. However, I decided against it to minimized the impact of this change and only fix it when the img doesn't represent an image and defaults to its fallback behavior. [1] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/html/html_image_element.cc;l=321 [2] https://html.spec.whatwg.org/multipage/rendering.html#images-3 Bug: 958250 Change-Id: I78b3d84d8237b72505fdc5389702d119d61ae405 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2239473 Commit-Queue: Yu Han <yuzhehan@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Reviewed-by: Mason Freed <masonfreed@chromium.org> Cr-Commit-Position: refs/heads/master@{#779100} -- wpt-commits: 21698f651c777373dc6e89c5f0e3969237387fdc wpt-pr: 24143
testing/web-platform/tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-title-only-w-sizing.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-title-only-w-sizing.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>Images with only title should be treated as a replaced element</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="author" href="mailto:yuzhehan@chromium.org" title="Yu Han">
+<link rel="help" href="https://crbug.com/958250">
+<link ref="help" href="https://html.spec.whatwg.org/multipage/rendering.html#images-3">
+<style>
+  .title-only {
+    width: 100px;
+    height: 150px;
+  }
+</style>
+<img class="title-only" title="title">
+<img width="100" height="150px" title="title">
+<script>
+async_test(t => {
+  onload = t.step_func_done(function() {
+    for (const img of document.querySelectorAll("img")) {
+      assert_equals(img.offsetWidth, 100, `width: ${img.outerHTML}`);
+      assert_equals(img.offsetHeight, 150, `height: ${img.outerHTML}`);
+    }
+  });
+});
+</script>