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