[webkit-changes] [WebKit/WebKit] 184cdf: Implement blocking=render attribute for <script> a...
mattwoodrow
noreply at github.com
Thu Aug 15 16:52:31 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 184cdfcc57261e42ed198e5874c1514a90325cd2
https://github.com/WebKit/WebKit/commit/184cdfcc57261e42ed198e5874c1514a90325cd2
Author: Matt Woodrow <mattwoodrow at apple.com>
Date: 2024-08-15 (Thu, 15 Aug 2024)
Changed paths:
M LayoutTests/TestExpectations
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/blocking-idl-attr-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/element-render-blocking-033-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-async-inline-module-with-import-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-async-script-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-defer-script-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-inline-module-with-import-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-module-script-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/script-inserted-inline-module-with-import-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/script-inserted-module-script-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/script-inserted-script-expected.txt
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
M Source/WebCore/dom/ScriptElement.cpp
M Source/WebCore/dom/ScriptElement.h
M Source/WebCore/html/HTMLScriptElement.cpp
M Source/WebCore/html/HTMLScriptElement.h
M Source/WebCore/html/HTMLScriptElement.idl
M Source/WebCore/html/HTMLStyleElement.cpp
M Source/WebCore/html/HTMLStyleElement.h
M Source/WebCore/html/HTMLStyleElement.idl
M Source/WebCore/page/Page.cpp
Log Message:
-----------
Implement blocking=render attribute for <script> and <style>
https://bugs.webkit.org/show_bug.cgi?id=267232
<rdar://121008856>
Reviewed by Tim Nguyen.
Implements the 'blocking' attribute for both <script> and <style>.
For <script>, it makes the element render blocking (for async scripts with a src
attribute, or modules).
<style> elements are already always script blocking (even when not parser
inserted) - See bug 88869. These are already implicitly render blocking due to
this, so there's currently nothing else to do other than roundtrip the
attribute.
WebKit2 has an existing, related concept called layer tree freezing that
prevents rendering updates during page transitions (for top-level documents
only). This blocking is removed when the first contentful layout is completed,
or when render blocking ends. In some of the tests this means that rendering
updates start sooner than before, when render blocking starts and then ends
before we have sufficient page content to hit the 'contentful' milestone. It's
possible, but unlikely for real web content to do the same.
To avoid changing behaviour for sites that haven't used blocking="render"
explicitly, this passes information from the HTMLScriptElement to the Document
about whether the blocking was implicit or not. The Document then only overrides
the layer tree freezing if there was at least one explicit cause of render
blocking (or any of the other visual update prevented reasons).
This fixes most of the relevant tests, except for two that use script inserted
stylesheets. These are always render blocking (and script blocking) so they
Break the tests attempts to unblock rendering. Manually removing the stylesheet
components of the test results in the rest of the test passing correctly.
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/blocking-idl-attr-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-async-inline-module-with-import-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-async-script-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-defer-script-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-inline-module-with-import-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/parser-inserted-module-script-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/script-inserted-inline-module-with-import-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/script-inserted-module-script-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/dom/render-blocking/script-inserted-script-expected.txt:
* Source/WebCore/dom/ScriptElement.cpp:
(WebCore::ScriptElement::prepareScript):
(WebCore::ScriptElement::executePendingScript):
* Source/WebCore/dom/ScriptElement.h:
(WebCore::ScriptElement::potentiallyBlockRendering):
(WebCore::ScriptElement::unblockRendering):
* Source/WebCore/html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::removedFromAncestor):
(WebCore::HTMLScriptElement::attributeChanged):
(WebCore::HTMLScriptElement::blocking):
(WebCore::HTMLScriptElement::potentiallyBlockRendering):
(WebCore::HTMLScriptElement::unblockRendering):
* Source/WebCore/html/HTMLScriptElement.h:
* Source/WebCore/html/HTMLScriptElement.idl:
* Source/WebCore/html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::attributeChanged):
(WebCore::HTMLStyleElement::blocking):
* Source/WebCore/html/HTMLStyleElement.h:
* Source/WebCore/html/HTMLStyleElement.idl:
Canonical link: https://commits.webkit.org/282319@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list