LibWeb/HTML: Only update the image data on fully loaded document

Documents created by DOMParser and fragment documents do not
have an origin set on the document by the spec. These documents
also happen to never become fully active.

By properly implementing the steps for the <img> element to only
update the image data for documents which are fully active, this
fixes a crash for img elements in these types of documents.

Unfortunately, this is not a full fix for the microtask queue case.
This is because it seems possible for node document for an <img>
element to be changed during the microtask queue for that document.
It is not clear to me how this can be fixed in a nice way.
This commit is contained in:
Shannon Booth 2025-06-21 15:31:29 +12:00 committed by Jelle Raaijmakers
parent bc85a9bace
commit 0bdcaf02d3
Notes: github-actions[bot] 2025-06-24 07:57:31 +00:00
7 changed files with 684 additions and 5 deletions

View file

@ -114,6 +114,8 @@ public:
private:
HTMLImageElement(DOM::Document&, DOM::QualifiedName);
void update_the_image_data_impl(bool restart_the_animations = false, bool maybe_omit_events = false);
virtual bool is_html_image_element() const override { return true; }
virtual void initialize(JS::Realm&) override;
@ -144,6 +146,8 @@ private:
Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
GC::Ptr<DOM::DocumentObserver> m_document_observer;
CORSSettingAttribute m_cors_setting { CORSSettingAttribute::NoCORS };
// https://html.spec.whatwg.org/multipage/images.html#last-selected-source