Skip to content

Commit 47a04de

Browse files
mfreed7Commit Bot
authored andcommitted
Change image preview document to no-quirks mode
Quirks mode layout is slower than no-quirks. This change should not affect the appearance of the image preview document. Bug: 1131185 Change-Id: I79e8b523fa518ddd7a230ea7f669df63e023b9e5 Cq-Do-Not-Cancel-Tryjobs: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425008 Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Mason Freed <[email protected]> Reviewed-by: Fredrik Söderquist <[email protected]> Cr-Commit-Position: refs/heads/master@{#810100}
1 parent 33155c5 commit 47a04de

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

chrome/test/data/extensions/api_test/executescript/destructive/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function testRemoveSelf(page, pattern) {
197197
var kDefaultPattern = /</;
198198

199199
if (page.includes('start')) {
200-
pattern = pattern || /^<html><\/html>$/;
200+
pattern = pattern || /^<\s*html[^>]*><\/html>$/;
201201
pattern = TEST_HOST === 'synchronous' ? pattern : kDefaultPattern;
202202
} else if (page.includes('end')) {
203203
pattern = pattern || kDefaultPattern;

third_party/blink/renderer/core/html/image_document.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ ImageDocument::ImageDocument(const DocumentInit& initializer)
208208
shrink_to_fit_mode_(GetFrame()->GetSettings()->GetViewportEnabled()
209209
? kViewport
210210
: kDesktop) {
211-
SetCompatibilityMode(kQuirksMode);
211+
SetCompatibilityMode(kNoQuirksMode);
212212
LockCompatibilityMode();
213213
}
214214

@@ -227,6 +227,8 @@ IntSize ImageDocument::ImageSize() const {
227227
void ImageDocument::CreateDocumentStructure(
228228
ImageResourceContent* image_content) {
229229
auto* root_element = MakeGarbageCollected<HTMLHtmlElement>(*this);
230+
root_element->SetInlineStyleProperty(
231+
CSSPropertyID::kHeight, 100, CSSPrimitiveValue::UnitType::kPercentage);
230232
AppendChild(root_element);
231233
root_element->InsertedByParser();
232234

@@ -245,7 +247,7 @@ void ImageDocument::CreateDocumentStructure(
245247
if (ShouldShrinkToFit()) {
246248
// Display the image prominently centered in the frame.
247249
body->setAttribute(html_names::kStyleAttr,
248-
"margin: 0px; background: #0e0e0e;");
250+
"margin: 0px; background: #0e0e0e; height: 100%");
249251

250252
// See w3c example on how to center an element:
251253
// https://www.w3.org/Style/Examples/007/center.en.html
@@ -267,7 +269,7 @@ void ImageDocument::CreateDocumentStructure(
267269
ShadowRoot& shadow_root = body->EnsureUserAgentShadowRoot();
268270
shadow_root.AppendChild(div_element_);
269271
} else {
270-
body->setAttribute(html_names::kStyleAttr, "margin: 0px;");
272+
body->setAttribute(html_names::kStyleAttr, "margin: 0px; height: 100%");
271273
}
272274

273275
WillInsertBody();

third_party/blink/web_tests/http/tests/security/contentSecurityPolicy/image-document-default-src-none-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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-H/s/dWGkGDaCkKqmo0VNeHrTgvJjinI5uvu7UmY6EB8='), 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.
1+
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-irYXJOS8dfWxS3v4lGnL1OcyQjamq/FGUi7NhXhtBOk='), 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.
22

33
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.
44

0 commit comments

Comments
 (0)