mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibWeb: Implement WindowEventHandlers
This commit is contained in:
parent
ebf2184636
commit
3fe66bddf4
Notes:
sideshowbarker
2024-07-17 09:52:33 +09:00
Author: https://github.com/Lubrsi
Commit: 3fe66bddf4
Pull-request: https://github.com/SerenityOS/serenity/pull/14406
Reviewed-by: https://github.com/linusg
15 changed files with 186 additions and 9 deletions
|
@ -4,7 +4,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLFrameSetElement.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -15,6 +17,19 @@ HTMLFrameSetElement::HTMLFrameSetElement(DOM::Document& document, DOM::Qualified
|
|||
|
||||
HTMLFrameSetElement::~HTMLFrameSetElement() = default;
|
||||
|
||||
void HTMLFrameSetElement::parse_attribute(FlyString const& name, String const& value)
|
||||
{
|
||||
HTMLElement::parse_attribute(name, value);
|
||||
|
||||
#undef __ENUMERATE
|
||||
#define __ENUMERATE(attribute_name, event_name) \
|
||||
if (name == HTML::AttributeNames::attribute_name) { \
|
||||
element_event_handler_attribute_changed(event_name, value); \
|
||||
}
|
||||
ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE)
|
||||
#undef __ENUMERATE
|
||||
}
|
||||
|
||||
DOM::EventTarget& HTMLFrameSetElement::global_event_handlers_to_event_target(FlyString const& event_name)
|
||||
{
|
||||
// NOTE: This is a little weird, but IIUC document.body.onload actually refers to window.onload
|
||||
|
@ -25,4 +40,11 @@ DOM::EventTarget& HTMLFrameSetElement::global_event_handlers_to_event_target(Fly
|
|||
return *this;
|
||||
}
|
||||
|
||||
DOM::EventTarget& HTMLFrameSetElement::window_event_handlers_to_event_target()
|
||||
{
|
||||
// All WindowEventHandlers on HTMLFrameSetElement (e.g. document.body.onrejectionhandled) are mapped to window.on{event}.
|
||||
// NOTE: document.body can return either a HTMLBodyElement or HTMLFrameSetElement, so both these elements must support this mapping.
|
||||
return document().window();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue