1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:27:39 +00:00

LibWeb: Flesh out prepare_script and execute_script

This fills in a bunch of the FIXMEs that was in prepare_script.

execute_script is almost finished, it's just missing the module side.

As an aside, let's not assert when inserting a script element with
innerHTML.
This commit is contained in:
Luke 2021-01-28 20:31:20 +00:00 committed by Andreas Kling
parent dbbc378fb2
commit 3f5532d43e
8 changed files with 188 additions and 40 deletions

View file

@ -42,6 +42,7 @@
#include <LibWeb/DOM/DOMImplementation.h>
#include <LibWeb/DOM/NonElementParentNode.h>
#include <LibWeb/DOM/ParentNode.h>
#include <LibWeb/HTML/HTMLScriptElement.h>
namespace Web::DOM {
@ -220,6 +221,13 @@ public:
const NonnullRefPtr<DOMImplementation> implementation() const { return m_implementation; }
RefPtr<HTML::HTMLScriptElement> current_script() const { return m_current_script; }
void set_current_script(Badge<HTML::HTMLScriptElement>, RefPtr<HTML::HTMLScriptElement> script) { m_current_script = script; }
u32 ignore_destructive_writes_counter() const { return m_ignore_destructive_writes_counter; }
void increment_ignore_destructive_writes_counter() { m_ignore_destructive_writes_counter++; }
void decrement_ignore_destructive_writes_counter() { m_ignore_destructive_writes_counter--; }
virtual EventTarget* get_parent(const Event&) override;
private:
@ -289,8 +297,11 @@ private:
bool m_ready_for_post_load_tasks { false };
NonnullRefPtr<DOMImplementation> m_implementation;
RefPtr<HTML::HTMLScriptElement> m_current_script;
bool m_should_invalidate_styles_on_attribute_changes { true };
u32 m_ignore_destructive_writes_counter { 0 };
};
}

View file

@ -30,6 +30,7 @@ interface Document : Node {
readonly attribute Element? documentElement;
attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
readonly attribute HTMLScriptElement? currentScript;
readonly attribute DOMString readyState;