LibWeb: Rename HTMLScriptElement "non-blocking" to "force async"

This has been renamed in the spec, so let's do it here too.
This commit is contained in:
Andreas Kling 2022-11-20 14:22:14 +01:00
parent 7b9138be55
commit 7d45927d41
Notes: sideshowbarker 2024-07-17 04:14:13 +09:00
4 changed files with 10 additions and 10 deletions

View File

@ -132,7 +132,7 @@ void HTMLScriptElement::prepare_script()
// 4. If parser document is non-null and the element does not have an async attribute, then set the element's "non-blocking" flag to true.
if (parser_document && !has_attribute(HTML::AttributeNames::async)) {
m_non_blocking = true;
m_force_async = true;
}
// 5. Let source text be the element's child text content.
@ -184,7 +184,7 @@ void HTMLScriptElement::prepare_script()
// 9. If parser document is non-null, then set the element's parser document back to parser document and set the element's "non-blocking" flag to false.
if (parser_document) {
m_parser_document = parser_document;
m_non_blocking = false;
m_force_async = false;
}
// 10. Set the element's "already started" flag.
@ -366,8 +366,8 @@ void HTMLScriptElement::prepare_script()
// -> If the script's type is "classic", and the element has a src attribute, and the element does not have an async attribute, and the element does not have the "non-blocking" flag set
// -> If the script's type is "module", and the element does not have an async attribute, and the element does not have the "non-blocking" flag set
else if ((m_script_type == ScriptType::Classic && has_attribute(HTML::AttributeNames::src) && !has_attribute(HTML::AttributeNames::async) && !m_non_blocking)
|| (m_script_type == ScriptType::Module && !has_attribute(HTML::AttributeNames::async) && !m_non_blocking)) {
else if ((m_script_type == ScriptType::Classic && has_attribute(HTML::AttributeNames::src) && !has_attribute(HTML::AttributeNames::async) && !m_force_async)
|| (m_script_type == ScriptType::Module && !has_attribute(HTML::AttributeNames::async) && !m_force_async)) {
// Add the element to the end of the list of scripts that will execute in order as soon as possible associated with the element's preparation-time document.
m_preparation_time_document->add_script_to_execute_in_order_as_soon_as_possible({}, *this);

View File

@ -21,7 +21,7 @@ class HTMLScriptElement final
public:
virtual ~HTMLScriptElement() override;
bool is_non_blocking() const { return m_non_blocking; }
bool is_force_async() const { return m_force_async; }
bool is_ready_to_be_parser_executed() const { return m_ready_to_be_parser_executed; }
bool failed_to_load() const { return m_failed_to_load; }
@ -29,7 +29,7 @@ public:
void set_parser_document(Badge<T>, DOM::Document& document) { m_parser_document = &document; }
template<OneOf<XMLDocumentBuilder, HTMLParser> T>
void set_non_blocking(Badge<T>, bool b) { m_non_blocking = b; }
void set_force_async(Badge<T>, bool b) { m_force_async = b; }
template<OneOf<XMLDocumentBuilder, HTMLParser> T>
void set_already_started(Badge<T>, bool b) { m_already_started = b; }
@ -71,7 +71,7 @@ public:
JS::GCPtr<DOM::Document> m_preparation_time_document;
// https://html.spec.whatwg.org/multipage/scripting.html#script-force-async
bool m_non_blocking { false };
bool m_force_async { false };
// https://html.spec.whatwg.org/multipage/scripting.html#already-started
bool m_already_started { false };

View File

@ -806,7 +806,7 @@ void HTMLParser::handle_in_head(HTMLToken& token)
auto element = create_element_for(token, Namespace::HTML, *adjusted_insertion_location.parent);
auto& script_element = verify_cast<HTMLScriptElement>(*element);
script_element.set_parser_document(Badge<HTMLParser> {}, document());
script_element.set_non_blocking(Badge<HTMLParser> {}, false);
script_element.set_force_async(Badge<HTMLParser> {}, false);
script_element.set_source_line_number({}, token.start_position().line + 1); // FIXME: This +1 is incorrect for script tags whose script does not start on a new line
if (m_parsing_fragment) {

View File

@ -66,12 +66,12 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
auto node = DOM::create_element(m_document, name, {});
// When an XML parser with XML scripting support enabled creates a script element,
// it must have its parser document set and its "non-blocking" flag must be unset.
// it must have its parser document set and its "force async" flag must be unset.
// FIXME: If the parser was created as part of the XML fragment parsing algorithm, then the element must be marked as "already started" also.
if (m_scripting_support == XMLScriptingSupport::Enabled && HTML::TagNames::script == name) {
auto& script_element = static_cast<HTML::HTMLScriptElement&>(*node);
script_element.set_parser_document(Badge<XMLDocumentBuilder> {}, m_document);
script_element.set_non_blocking(Badge<XMLDocumentBuilder> {}, false);
script_element.set_force_async(Badge<XMLDocumentBuilder> {}, false);
}
if (HTML::TagNames::template_ == m_current_node->node_name()) {
// When an XML parser would append a node to a template element, it must instead append it to the template element's template contents (a DocumentFragment node).