mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 17:47:44 +00:00
LibWeb: Add HTML::EventNames and UIEvents::EventNames
This commit is contained in:
parent
e68348298f
commit
9950270808
15 changed files with 271 additions and 19 deletions
|
@ -46,6 +46,7 @@
|
|||
#include <LibWeb/DOM/Window.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/HTML/AttributeNames.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/HTMLBodyElement.h>
|
||||
#include <LibWeb/HTML/HTMLFrameSetElement.h>
|
||||
#include <LibWeb/HTML/HTMLHeadElement.h>
|
||||
|
@ -608,7 +609,7 @@ void Document::set_focused_element(Element* element)
|
|||
void Document::set_ready_state(const String& ready_state)
|
||||
{
|
||||
m_ready_state = ready_state;
|
||||
dispatch_event(Event::create("readystatechange"));
|
||||
dispatch_event(Event::create(HTML::EventNames::readystatechange));
|
||||
}
|
||||
|
||||
Page* Document::page()
|
||||
|
@ -623,7 +624,7 @@ const Page* Document::page() const
|
|||
|
||||
EventTarget* Document::get_parent(const Event& event)
|
||||
{
|
||||
if (event.type() == "load")
|
||||
if (event.type() == HTML::EventNames::load)
|
||||
return nullptr;
|
||||
|
||||
return &window();
|
||||
|
@ -632,7 +633,7 @@ EventTarget* Document::get_parent(const Event& event)
|
|||
void Document::completely_finish_loading()
|
||||
{
|
||||
// FIXME: This needs to handle iframes.
|
||||
dispatch_event(DOM::Event::create("load"));
|
||||
dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/DOM/Window.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
@ -199,7 +200,7 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
|
|||
|
||||
event->append_to_path(*target, target_override, related_target, touch_targets, false);
|
||||
|
||||
bool is_activation_event = is<UIEvents::MouseEvent>(*event) && event->type() == "click";
|
||||
bool is_activation_event = is<UIEvents::MouseEvent>(*event) && event->type() == HTML::EventNames::click;
|
||||
|
||||
if (is_activation_event && target->activation_behaviour)
|
||||
activation_target = target;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <LibWeb/DOM/EventListener.h>
|
||||
#include <LibWeb/DOM/Window.h>
|
||||
#include <LibWeb/DOM/XMLHttpRequest.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
|
||||
|
@ -83,7 +84,7 @@ void XMLHttpRequest::send()
|
|||
if (!weak_this)
|
||||
return;
|
||||
const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done);
|
||||
const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create("error"));
|
||||
const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create(HTML::EventNames::error));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -96,14 +97,14 @@ void XMLHttpRequest::send()
|
|||
return;
|
||||
const_cast<XMLHttpRequest&>(*weak_this).m_response = data;
|
||||
const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done);
|
||||
const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create("load"));
|
||||
const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||
},
|
||||
[weak_this = make_weak_ptr()](auto& error) {
|
||||
if (!weak_this)
|
||||
return;
|
||||
dbg() << "XHR failed to load: " << error;
|
||||
const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done);
|
||||
const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create("error"));
|
||||
const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create(HTML::EventNames::error));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue