mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb/SVG: Process script element when its text content changes
This commit is contained in:
committed by
Jelle Raaijmakers
parent
db7aa68340
commit
a187d5f28f
@@ -4308,6 +4308,7 @@ void HTMLParser::process_using_the_rules_for_foreign_content(HTMLToken& token)
|
||||
|
||||
// If the active speculative HTML parser is null and the user agent supports SVG, then Process the SVG script element according to the SVG rules. [SVG]
|
||||
// FIXME: If the active speculative HTML parser is null
|
||||
script_element.set_parser_inserted({});
|
||||
script_element.process_the_script_element();
|
||||
|
||||
// Decrement the parser's script nesting level by one.
|
||||
|
||||
@@ -35,6 +35,24 @@ void SVGScriptElement::visit_edges(Cell::Visitor& visitor)
|
||||
visitor.visit(m_script);
|
||||
}
|
||||
|
||||
void SVGScriptElement::inserted()
|
||||
{
|
||||
Base::inserted();
|
||||
if (m_parser_inserted)
|
||||
return;
|
||||
|
||||
process_the_script_element();
|
||||
}
|
||||
|
||||
void SVGScriptElement::children_changed(ChildrenChangedMetadata const* metadata)
|
||||
{
|
||||
Base::children_changed(metadata);
|
||||
if (m_parser_inserted)
|
||||
return;
|
||||
|
||||
process_the_script_element();
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing
|
||||
void SVGScriptElement::process_the_script_element()
|
||||
{
|
||||
@@ -114,6 +132,8 @@ void SVGScriptElement::process_the_script_element()
|
||||
} else {
|
||||
// Inline script content
|
||||
script_content = child_text_content();
|
||||
if (script_content.is_empty())
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. The 'script' element's "already processed" flag is set to true.
|
||||
|
||||
@@ -21,8 +21,12 @@ class SVGScriptElement
|
||||
public:
|
||||
void process_the_script_element();
|
||||
|
||||
void set_parser_inserted(Badge<HTML::HTMLParser>) { m_parser_inserted = true; }
|
||||
void set_source_line_number(Badge<HTML::HTMLParser>, size_t source_line_number) { m_source_line_number = source_line_number; }
|
||||
|
||||
virtual void inserted() override;
|
||||
virtual void children_changed(ChildrenChangedMetadata const*) override;
|
||||
|
||||
protected:
|
||||
SVGScriptElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
@@ -34,6 +38,7 @@ private:
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
bool m_already_processed { false };
|
||||
bool m_parser_inserted { false };
|
||||
|
||||
GC::Ptr<HTML::ClassicScript> m_script;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user