Commit 785aa959 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Make the background-color of the <img> element light gray

Implement ingenious idea for image document.

Bug: 844743
Change-Id: I6fa9b373999a77e1a8eb8fd399b8f0e59834063c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2455448
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815588}
parent 48924233
......@@ -422,6 +422,15 @@ void ImageDocument::UpdateImageStyle() {
else if (cursor_mode == kZoomOut)
image_style.Append("cursor: zoom-out;");
if (GetFrame()->IsMainFrame()) {
if (image_is_loaded_) {
image_style.Append("background-color: hsl(0, 0%, 90%);");
image_style.Append("transition: background-color 300ms;");
} else if (image_size_is_known_) {
image_style.Append("background-color: hsl(0, 0%, 25%);");
}
}
image_element_->setAttribute(html_names::kStyleAttr,
image_style.ToAtomicString());
}
......@@ -437,6 +446,7 @@ void ImageDocument::ImageUpdated() {
return;
image_size_is_known_ = true;
UpdateImageStyle();
if (ShouldShrinkToFit()) {
// Force resizing of the image
......
......@@ -4,4 +4,6 @@ CONSOLE ERROR: Refused to apply inline style because it violates the following C
CONSOLE ERROR: Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'none'". Either the 'unsafe-inline' keyword, a hash ('sha256-VPZ2mdsWWlqXOFgt1tAllbbJhG8t9bh6emP1o9GwJxY='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.
CONSOLE ERROR: Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'none'". Either the 'unsafe-inline' keyword, a hash ('sha256-VPZ2mdsWWlqXOFgt1tAllbbJhG8t9bh6emP1o9GwJxY='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.
Ensure that we don't crash when loading an ImageDocument that sets CSP headers
......@@ -4,5 +4,5 @@ Passes if the image shinks to fit the width.
viewport meta: <meta name="viewport" content="width=device-width, minimum-scale=0.1">
image style: -webkit-user-select: none;margin: auto;cursor: zoom-in;
image style: -webkit-user-select: none;margin: auto;cursor: zoom-in;background-color: hsl(0, 0%, 90%);transition: background-color 300ms;
image actual width: 100
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment