mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Adjust implementation of Document::create_event
With this change, it no longer calls TODO() and crashes WebContent
This commit is contained in:
parent
857c3501df
commit
96caf3aed1
Notes:
sideshowbarker
2024-07-17 10:25:19 +09:00
Author: https://github.com/stelar7 Commit: https://github.com/SerenityOS/serenity/commit/96caf3aed1 Pull-request: https://github.com/SerenityOS/serenity/pull/14211 Issue: https://github.com/SerenityOS/serenity/issues/14206
@ -952,10 +952,15 @@ NonnullRefPtr<Range> Document::create_range()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createevent
|
// https://dom.spec.whatwg.org/#dom-document-createevent
|
||||||
NonnullRefPtr<Event> Document::create_event(String const& interface)
|
DOM::ExceptionOr<NonnullRefPtr<Event>> Document::create_event(String const& interface)
|
||||||
{
|
{
|
||||||
auto interface_lowercase = interface.to_lowercase();
|
// NOTE: This is named event here, since we do step 5 and 6 as soon as possible for each case.
|
||||||
|
// 1. Let constructor be null.
|
||||||
RefPtr<Event> event;
|
RefPtr<Event> event;
|
||||||
|
|
||||||
|
// 2. If interface is an ASCII case-insensitive match for any of the strings in the first column in the following table,
|
||||||
|
// then set constructor to the interface in the second column on the same row as the matching string:
|
||||||
|
auto interface_lowercase = interface.to_lowercase();
|
||||||
if (interface_lowercase == "beforeunloadevent") {
|
if (interface_lowercase == "beforeunloadevent") {
|
||||||
event = Event::create(""); // FIXME: Create BeforeUnloadEvent
|
event = Event::create(""); // FIXME: Create BeforeUnloadEvent
|
||||||
} else if (interface_lowercase == "compositionevent") {
|
} else if (interface_lowercase == "compositionevent") {
|
||||||
@ -992,17 +997,29 @@ NonnullRefPtr<Event> Document::create_event(String const& interface)
|
|||||||
event = Event::create(""); // FIXME: Create TouchEvent
|
event = Event::create(""); // FIXME: Create TouchEvent
|
||||||
} else if (interface_lowercase.is_one_of("uievent", "uievents")) {
|
} else if (interface_lowercase.is_one_of("uievent", "uievents")) {
|
||||||
event = UIEvents::UIEvent::create("");
|
event = UIEvents::UIEvent::create("");
|
||||||
} else {
|
|
||||||
// FIXME:
|
|
||||||
// 3. If constructor is null, then throw a "NotSupportedError" DOMException.
|
|
||||||
// 4. If the interface indicated by constructor is not exposed on the relevant global object of this, then throw a "NotSupportedError" DOMException.
|
|
||||||
TODO();
|
|
||||||
}
|
}
|
||||||
// Setting type to empty string is handled by each constructor.
|
|
||||||
// FIXME:
|
// 3. If constructor is null, then throw a "NotSupportedError" DOMException.
|
||||||
// 7. Initialize event’s timeStamp attribute to a DOMHighResTimeStamp representing the high resolution time from the time origin to now.
|
if (!event) {
|
||||||
|
return DOM::NotSupportedError::create("No constructor for interface found");
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: 4. If the interface indicated by constructor is not exposed on the relevant global object of this, then throw a "NotSupportedError" DOMException.
|
||||||
|
|
||||||
|
// NOTE: These are done in the if-chain above
|
||||||
|
// 5. Let event be the result of creating an event given constructor.
|
||||||
|
// 6. Initialize event’s type attribute to the empty string.
|
||||||
|
// NOTE: This is handled by each constructor.
|
||||||
|
|
||||||
|
// FIXME: 7. Initialize event’s timeStamp attribute to the result of calling current high resolution time with this’s relevant global object.
|
||||||
|
|
||||||
|
// 8. Initialize event’s isTrusted attribute to false.
|
||||||
event->set_is_trusted(false);
|
event->set_is_trusted(false);
|
||||||
|
|
||||||
|
// 9. Unset event’s initialized flag.
|
||||||
event->set_initialized(false);
|
event->set_initialized(false);
|
||||||
|
|
||||||
|
// 10. Return event.
|
||||||
return event.release_nonnull();
|
return event.release_nonnull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ public:
|
|||||||
NonnullRefPtr<Text> create_text_node(String const& data);
|
NonnullRefPtr<Text> create_text_node(String const& data);
|
||||||
NonnullRefPtr<Comment> create_comment(String const& data);
|
NonnullRefPtr<Comment> create_comment(String const& data);
|
||||||
NonnullRefPtr<Range> create_range();
|
NonnullRefPtr<Range> create_range();
|
||||||
NonnullRefPtr<Event> create_event(String const& interface);
|
ExceptionOr<NonnullRefPtr<Event>> create_event(String const& interface);
|
||||||
|
|
||||||
void set_pending_parsing_blocking_script(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement*);
|
void set_pending_parsing_blocking_script(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement*);
|
||||||
HTML::HTMLScriptElement* pending_parsing_blocking_script() { return m_pending_parsing_blocking_script; }
|
HTML::HTMLScriptElement* pending_parsing_blocking_script() { return m_pending_parsing_blocking_script; }
|
||||||
|
Loading…
Reference in New Issue
Block a user