Bug 1701510: Zero out the 'body' margin for all ImageDocuments (including iframes and printed images). r=emilio

This makes us match Blink and WebKit on how to render an iframe whose src
attribute is an image URL.  They seem to have always used 0 margin in this
case, and this seems preferable from an author's perspective (since the
standard HTML-body margin feels kind of arbitrary, when viewing an image).

Note that this change does also mean that images will be slightly closer to the
upper-left of the page, if they're viewed directly and then printed.  This
shouldn't cause them to be clipped or cause other issues; they'll still be
offset from the page edge by the printed-page margins, as well as any
unprintable areas that we get from the printer.

Differential Revision: https://phabricator.services.mozilla.com/D110294
This commit is contained in:
Daniel Holbert 2021-04-01 00:24:10 +00:00
parent b794f12f7f
commit 0414682ea1
6 changed files with 31 additions and 4 deletions

View File

@ -3,6 +3,7 @@
<head>
<title>Background color wrapper for clear image tests</title>
<style>
body { margin: 0; }
img {
background-color: rgb(0, 255, 0);
}

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<img src="blue-50x50.png">

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<style>
iframe {
border: none;
/* This fixed size is just so that we would cause overflow & trigger
scrollbars, if we were adding any margin to the internal document.
(We're not intending to do so...) */
height: 51px;
width: 51px;
}
</style>
<iframe src="blue-50x50.png"></iframe>

View File

@ -1,5 +1,6 @@
fuzzy-if(Android,0-8,0-30) == background-image-zoom-1.html background-image-zoom-1-ref.html
fails-if(usesRepeatResampling&&!(webrender&&winWidget)) == background-image-zoom-2.html about:blank
== image-in-iframe-1.html image-in-iframe-1-ref.html
== image-seam-1a.html image-seam-1-ref.html
== image-seam-1b.html image-seam-1-ref.html
fuzzy-if(Android,0-255,0-154) == image-seam-2.html image-seam-2-ref.html # Bug 1128229

View File

@ -8,6 +8,13 @@
* including those in frames.
*/
body {
/* To give the image access to our document's full viewport, we need to
override the margin that the html.css UA stylesheet would otherwise apply
to our body. */
margin: 0;
}
@media not print {
.shrinkToFit {
cursor: zoom-in;

View File

@ -9,10 +9,6 @@
*/
@media not print {
body {
margin: 0;
}
img {
text-align: center;
position: absolute;