Skip to content
Permalink
Browse files
Implement no-quirks mode for media/plugin/ua-inline documents
https://bugs.webkit.org/show_bug.cgi?id=228832
<rdar://problem/81851619>

Reviewed by Chris Dumez.

Update Chris Dumez's original patch for 2022, taking into account Bug 244950,
which addressed Text documents.

* LayoutTests/media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html: Update for non-quirks behavior.
* LayoutTests/media/modern-media-controls/media-documents/media-document-audio-ios-sizing-expected.txt: Ditto.
* LayoutTests/platform/ipad/media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html: Ditto.
* LayoutTests/platform/ipad/media/modern-media-controls/media-documents/media-document-audio-ios-sizing-expected.txt: Ditto.
* LayoutTests/platform/mac/editing/pasteboard/copy-standalone-image-expected.html: macOS requires a slightly different
expected output, as it appears to include an unexpected <br> in the paste output that does not appear on iOS or GTK.
* LayoutTests/platform/mac-wk1/fast/events/standalone-image-drag-to-editable-expected.txt: Rebaseline for non-quirks behavior.
* LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/read-media/pageload-image-expected.txt: Update to
expect PASS.
* LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/read-media/pageload-video-expected.txt: Ditto.
* Source/WebCore/html/ImageDocument.cpp:
(WebCore::ImageDocument::createDocumentStructure): Use NoQuirksMode.
* Source/WebCore/html/MediaDocument.cpp:
(WebCore::MediaDocument::MediaDocument): Use NoQuirksMode.
* Source/WebCore/html/PluginDocument.cpp:
(WebCore::PluginDocumentParser::createDocumentStructure): Configure view with explicit height and width.
(WebCore::PluginDocument::PluginDocument): Use NoQuirksMode.
* Source/WebCore/loader/SinkDocument.cpp:
(WebCore::SinkDocument::SinkDocument): Use NoQuirksMode.

Canonical link: https://commits.webkit.org/254526@main
  • Loading branch information
brentfulgham authored and Brent Fulgham committed Sep 15, 2022
1 parent f8cfeb9 commit fcbca01158eb1b28827ffc219a09bde9f52b10bc
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 21 deletions.
@@ -1,3 +1,3 @@

FAIL The document for a standalone media file should have one child in the body. assert_equals: Media documents should be in standards mode expected "CSS1Compat" but got "BackCompat"
PASS The document for a standalone media file should have one child in the body.

@@ -1,3 +1,3 @@

FAIL The document for a standalone media file should have one child in the body. assert_equals: Media documents should be in standards mode expected "CSS1Compat" but got "BackCompat"
PASS The document for a standalone media file should have one child in the body.

@@ -3,7 +3,7 @@ Testing the size of the media element in an audio media document on iOS.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS getComputedStyle(media).width became "320px"
PASS getComputedStyle(media).width became "390px"
PASS getComputedStyle(media).height is "50px"

PASS successfullyParsed is true
@@ -20,7 +20,7 @@
return;
}

shouldBecomeEqualToString("getComputedStyle(media).width", "320px", () => {
shouldBecomeEqualToString("getComputedStyle(media).width", "390px", () => {
shouldBeEqualToString("getComputedStyle(media).height", "50px");

debug("");
@@ -3,7 +3,7 @@ Testing the size of the media element in an audio media document on iOS.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS getComputedStyle(media).width became "650px"
PASS getComputedStyle(media).width became "800px"
PASS getComputedStyle(media).height is "50px"

PASS successfullyParsed is true
@@ -20,7 +20,7 @@
return;
}

shouldBecomeEqualToString("getComputedStyle(media).width", "650px", () => {
shouldBecomeEqualToString("getComputedStyle(media).width", "800px", () => {
shouldBeEqualToString("getComputedStyle(media).height", "50px");

debug("");
@@ -0,0 +1,27 @@
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderFrameSet {FRAMESET} at (0,0) size 800x600
RenderFrame {FRAME} at (0,0) size 800x100
layer at (0,0) size 785x102
RenderView at (0,0) size 785x100
layer at (0,0) size 785x102
RenderBlock {HTML} at (0,0) size 785x102
RenderBody {BODY} at (0,0) size 785x102
RenderBlock {DIV} at (0,0) size 785x102 [border: (1px solid #000000)]
RenderBlock (anonymous) at (1,1) size 783x36
RenderText {#text} at (0,0) size 702x18
text run at (0,0) width 702: "This layout test is checks that we don't crash when a stand alone image is dragged into a content editable div. "
RenderBR {BR} at (701,0) size 1x18
RenderInline {A} at (0,0) size 153x18 [color=#0000EE]
RenderText {#text} at (0,18) size 153x18
text run at (0,18) width 153: "rdar://problem/5021127"
RenderImage {IMG} at (1,37) size 25x25
RenderFrame {FRAME} at (0,106) size 800x100
layer at (0,0) size 800x100
RenderView at (0,0) size 800x100
layer at (0,0) size 800x100
RenderBlock {HTML} at (0,0) size 800x100
RenderBody {BODY} at (0,0) size 800x100
RenderImage {IMG} at (0,0) size 25x25
@@ -0,0 +1,15 @@
<html>
<body>
<p>This is an automatic test of copying an image document.</p>
<p>To perform this test manually, click once in the image frame, choose Edit -> Copy
then click in the red box and paste the image. If the image pastes successfully the
test is passed.</p>

<iframe name="imageframe" src="../../../../editing/resources/abe.png"></iframe>

<div id="dest" contenteditable="true"><br><img src="../../../../editing/resources/abe.png" style="-webkit-user-select:none;"></div>
<script>
frames['imageframe'].focus();
</script>
</body>
</html>
@@ -33,9 +33,9 @@ layer at (20,20) size 644x433
RenderIFrame {IFRAME} at (0,0) size 0x0
layer at (0,0) size 1x1
RenderView at (0,0) size 0x0
layer at (0,0) size 0x1
RenderBlock {HTML} at (0,0) size 0x1
RenderBody {BODY} at (0,0) size 0x1
layer at (0,0) size 0x0
RenderBlock {HTML} at (0,0) size 0x0
RenderBody {BODY} at (0,0) size 0x0
RenderImage {IMG} at (0,0) size 1x1
RenderIFrame {IFRAME} at (0,0) size 0x0
layer at (0,0) size 16x2171
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2019 Apple Inc. All rights reserved.
* Copyright (C) 2006-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -209,7 +209,7 @@ ImageDocument::ImageDocument(Frame& frame, const URL& url)
#endif
, m_shouldShrinkImage(frame.settings().shrinksStandaloneImagesToFit() && frame.isMainFrame())
{
setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
setCompatibilityMode(DocumentCompatibilityMode::NoQuirksMode);
lockCompatibilityMode();
}

@@ -223,6 +223,7 @@ void ImageDocument::createDocumentStructure()
auto rootElement = HTMLHtmlElement::create(*this);
appendChild(rootElement);
rootElement->insertedByParser();
rootElement->setInlineStyleProperty(CSSPropertyHeight, 100, CSSUnitType::CSS_PERCENTAGE);

frame()->injectUserScripts(UserScriptInjectionTime::DocumentStart);

@@ -231,7 +232,7 @@ void ImageDocument::createDocumentStructure()
rootElement->appendChild(head);

auto body = HTMLBodyElement::create(*this);
body->setAttribute(styleAttr, "margin: 0px"_s);
body->setAttribute(styleAttr, "margin: 0px; height: 100%"_s);
if (MIMETypeRegistry::isPDFMIMEType(document().loader()->responseMIMEType()))
body->setInlineStyleProperty(CSSPropertyBackgroundColor, "white"_s);
rootElement->appendChild(body);
@@ -240,7 +241,7 @@ void ImageDocument::createDocumentStructure()
if (m_shouldShrinkImage)
imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; margin:auto; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);"_s);
else
imageElement->setAttribute(styleAttr, "-webkit-user-select:none; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);"_s);
imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);"_s);
imageElement->setLoadManually(true);
imageElement->setSrc(AtomString { url().string() });
imageElement->cachedImage()->setResponse(loader()->response());
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
* Copyright (C) 2008-2022 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -141,7 +141,7 @@ void MediaDocumentParser::appendBytes(DocumentWriter&, const uint8_t*, size_t)
MediaDocument::MediaDocument(Frame* frame, const Settings& settings, const URL& url)
: HTMLDocument(frame, settings, url, { }, { DocumentClass::Media })
{
setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
setCompatibilityMode(DocumentCompatibilityMode::NoQuirksMode);
lockCompatibilityMode();
if (frame)
m_outgoingReferrer = frame->loader().outgoingReferrer();
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2017 Apple Inc. All rights reserved.
* Copyright (C) 2006-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -72,6 +72,8 @@ void PluginDocumentParser::createDocumentStructure()
auto rootElement = HTMLHtmlElement::create(document);
document.appendChild(rootElement);
rootElement->insertedByParser();
rootElement->setInlineStyleProperty(CSSPropertyHeight, 100, CSSUnitType::CSS_PERCENTAGE);
rootElement->setInlineStyleProperty(CSSPropertyWidth, 100, CSSUnitType::CSS_PERCENTAGE);

if (document.frame())
document.frame()->injectUserScripts(UserScriptInjectionTime::DocumentStart);
@@ -85,9 +87,9 @@ void PluginDocumentParser::createDocumentStructure()
body->setAttributeWithoutSynchronization(marginwidthAttr, "0"_s);
body->setAttributeWithoutSynchronization(marginheightAttr, "0"_s);
#if PLATFORM(IOS_FAMILY)
body->setAttribute(styleAttr, "background-color: rgb(217,224,233)"_s);
body->setAttribute(styleAttr, "background-color: rgb(217,224,233); height: 100%; width: 100%; overflow:hidden; margin: 0"_s);
#else
body->setAttribute(styleAttr, "background-color: rgb(38,38,38)"_s);
body->setAttribute(styleAttr, "background-color: rgb(38,38,38); height: 100%; width: 100%; overflow:hidden; margin: 0"_s);
#endif

rootElement->appendChild(body);
@@ -147,7 +149,7 @@ void PluginDocumentParser::appendBytes(DocumentWriter&, const uint8_t*, size_t)
PluginDocument::PluginDocument(Frame& frame, const URL& url)
: HTMLDocument(&frame, frame.settings(), url, { }, { DocumentClass::Plugin })
{
setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
setCompatibilityMode(DocumentCompatibilityMode::NoQuirksMode);
lockCompatibilityMode();
}

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -56,7 +56,7 @@ class SinkDocumentParser final : public RawDataDocumentParser {
SinkDocument::SinkDocument(Frame& frame, const URL& url)
: HTMLDocument(&frame, frame.settings(), url, { })
{
setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
setCompatibilityMode(DocumentCompatibilityMode::NoQuirksMode);
lockCompatibilityMode();
}

0 comments on commit fcbca01

Please sign in to comment.