-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb/UIEvents: Implement TextEvent
- Loading branch information
1 parent
b6ac9bf
commit 4218f05
Showing
10 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,6 +345,7 @@ SyntaxError | |
Text | ||
TextDecoder | ||
TextEncoder | ||
TextEvent | ||
TextMetrics | ||
TextTrack | ||
TextTrackCue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2024, Jamie Mansfield <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <LibWeb/Bindings/Intrinsics.h> | ||
#include <LibWeb/Bindings/TextEventPrototype.h> | ||
#include <LibWeb/UIEvents/TextEvent.h> | ||
|
||
namespace Web::UIEvents { | ||
|
||
JS_DEFINE_ALLOCATOR(TextEvent); | ||
|
||
JS::NonnullGCPtr<TextEvent> TextEvent::create(JS::Realm& realm, FlyString const& event_name) | ||
{ | ||
return realm.heap().allocate<TextEvent>(realm, realm, event_name); | ||
} | ||
|
||
TextEvent::TextEvent(JS::Realm& realm, FlyString const& event_name) | ||
: UIEvent(realm, event_name) | ||
{ | ||
} | ||
|
||
TextEvent::~TextEvent() = default; | ||
|
||
void TextEvent::initialize(JS::Realm& realm) | ||
{ | ||
Base::initialize(realm); | ||
WEB_SET_PROTOTYPE_FOR_INTERFACE(TextEvent); | ||
} | ||
|
||
// https://w3c.github.io/uievents/#dom-textevent-inittextevent | ||
void TextEvent::init_text_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& data) | ||
{ | ||
// Initializes attributes of a TextEvent object. This method has the same behavior as UIEvent.initUIEvent(). | ||
// The value of detail remains undefined. | ||
|
||
// 1. If this’s dispatch flag is set, then return. | ||
if (dispatched()) | ||
return; | ||
|
||
// 2. Initialize this with type, bubbles, and cancelable. | ||
initialize_event(type, bubbles, cancelable); | ||
|
||
// Implementation Defined: Initialise other values. | ||
m_view = view; | ||
m_data = data; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2024, Jamie Mansfield <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <LibWeb/UIEvents/UIEvent.h> | ||
|
||
namespace Web::UIEvents { | ||
|
||
class TextEvent final : public UIEvent { | ||
WEB_PLATFORM_OBJECT(TextEvent, UIEvent); | ||
JS_DECLARE_ALLOCATOR(TextEvent); | ||
|
||
public: | ||
[[nodiscard]] static JS::NonnullGCPtr<TextEvent> create(JS::Realm&, FlyString const& event_name); | ||
|
||
virtual ~TextEvent() override; | ||
|
||
// https://w3c.github.io/uievents/#dom-textevent-data | ||
String data() const { return m_data; } | ||
|
||
void init_text_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& data); | ||
|
||
private: | ||
TextEvent(JS::Realm&, FlyString const& event_name); | ||
|
||
virtual void initialize(JS::Realm&) override; | ||
|
||
String m_data; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import <UIEvents/UIEvent.idl> | ||
|
||
// https://w3c.github.io/uievents/#textevent | ||
[Exposed=Window] | ||
interface TextEvent : UIEvent { | ||
readonly attribute DOMString data; | ||
undefined initTextEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional Window? view = null, optional DOMString data = "undefined"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters