summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2020-11-21 19:15:57 +0000
committerAndreas Kling <kling@serenityos.org>2020-11-22 18:20:56 +0100
commit99502708087031172bca0e0dc423b28d82517ea8 (patch)
tree3c7d4b5050d8f7c2987474689f6f713c0a4b311c /Libraries/LibWeb/DOM
parente68348298f1f0905d6014c8bd5f6da2a3b6233d8 (diff)
downloadserenity-99502708087031172bca0e0dc423b28d82517ea8.zip
LibWeb: Add HTML::EventNames and UIEvents::EventNames
Diffstat (limited to 'Libraries/LibWeb/DOM')
-rw-r--r--Libraries/LibWeb/DOM/Document.cpp7
-rw-r--r--Libraries/LibWeb/DOM/EventDispatcher.cpp3
-rw-r--r--Libraries/LibWeb/DOM/XMLHttpRequest.cpp7
3 files changed, 10 insertions, 7 deletions
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp
index 358f4b80be..2cc6af2768 100644
--- a/Libraries/LibWeb/DOM/Document.cpp
+++ b/Libraries/LibWeb/DOM/Document.cpp
@@ -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));
}
}
diff --git a/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Libraries/LibWeb/DOM/EventDispatcher.cpp
index 94b02acb39..49bcd9a0ee 100644
--- a/Libraries/LibWeb/DOM/EventDispatcher.cpp
+++ b/Libraries/LibWeb/DOM/EventDispatcher.cpp
@@ -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;
diff --git a/Libraries/LibWeb/DOM/XMLHttpRequest.cpp b/Libraries/LibWeb/DOM/XMLHttpRequest.cpp
index 43e8ddeccb..092ad060c8 100644
--- a/Libraries/LibWeb/DOM/XMLHttpRequest.cpp
+++ b/Libraries/LibWeb/DOM/XMLHttpRequest.cpp
@@ -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));
});
}