mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 04:37:44 +00:00
LibWeb: Introduce the WebGL namespace and add WebGLContextEvent
This commit is contained in:
parent
7d1fcb0cb3
commit
b0c2aee2e4
8 changed files with 74 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <LibWeb/Bindings/ProgressEventWrapper.h>
|
||||
#include <LibWeb/Bindings/PromiseRejectionEventWrapper.h>
|
||||
#include <LibWeb/Bindings/SubmitEventWrapper.h>
|
||||
#include <LibWeb/Bindings/WebGLContextEventWrapper.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
|
@ -47,6 +48,8 @@ EventWrapper* wrap(JS::GlobalObject& global_object, DOM::Event& event)
|
|||
return static_cast<ProgressEventWrapper*>(wrap_impl(global_object, static_cast<XHR::ProgressEvent&>(event)));
|
||||
if (is<UIEvents::UIEvent>(event))
|
||||
return static_cast<UIEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::UIEvent&>(event)));
|
||||
if (is<WebGL::WebGLContextEvent>(event))
|
||||
return static_cast<WebGLContextEventWrapper*>(wrap_impl(global_object, static_cast<WebGL::WebGLContextEvent&>(event)));
|
||||
return static_cast<EventWrapper*>(wrap_impl(global_object, event));
|
||||
}
|
||||
|
||||
|
|
|
@ -339,6 +339,8 @@
|
|||
#include <LibWeb/Bindings/URLPrototype.h>
|
||||
#include <LibWeb/Bindings/URLSearchParamsConstructor.h>
|
||||
#include <LibWeb/Bindings/URLSearchParamsPrototype.h>
|
||||
#include <LibWeb/Bindings/WebGLContextEventConstructor.h>
|
||||
#include <LibWeb/Bindings/WebGLContextEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WebSocketConstructor.h>
|
||||
#include <LibWeb/Bindings/WebSocketPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowConstructor.h>
|
||||
|
@ -526,6 +528,7 @@
|
|||
ADD_WINDOW_OBJECT_INTERFACE(UIEvent) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(URLSearchParams) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(URL) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(WebGLContextEvent) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(WebSocket) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(Worker) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(XMLHttpRequest) \
|
||||
|
|
|
@ -377,6 +377,10 @@ class Resource;
|
|||
class ResourceLoader;
|
||||
}
|
||||
|
||||
namespace Web::WebGL {
|
||||
class WebGLContextEvent;
|
||||
}
|
||||
|
||||
namespace Web::XHR {
|
||||
class ProgressEvent;
|
||||
class XMLHttpRequest;
|
||||
|
@ -576,6 +580,7 @@ class URLSearchParamsIteratorWrapper;
|
|||
class URLSearchParamsPrototype;
|
||||
class URLSearchParamsWrapper;
|
||||
class URLWrapper;
|
||||
class WebGLContextEventWrapper;
|
||||
class WebSocketWrapper;
|
||||
class WindowObject;
|
||||
class WindowProxy;
|
||||
|
|
45
Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h
Normal file
45
Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
||||
struct WebGLContextEventInit final : public DOM::EventInit {
|
||||
String status_message { String::empty() };
|
||||
};
|
||||
|
||||
class WebGLContextEvent final : public DOM::Event {
|
||||
public:
|
||||
using WrapperType = Bindings::WebGLContextEventWrapper;
|
||||
|
||||
static NonnullRefPtr<WebGLContextEvent> create(FlyString const& type, WebGLContextEventInit const& event_init)
|
||||
{
|
||||
return adopt_ref(*new WebGLContextEvent(type, event_init));
|
||||
}
|
||||
|
||||
static NonnullRefPtr<WebGLContextEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& type, WebGLContextEventInit const& event_init)
|
||||
{
|
||||
return adopt_ref(*new WebGLContextEvent(type, event_init));
|
||||
}
|
||||
|
||||
virtual ~WebGLContextEvent() override = default;
|
||||
|
||||
String const& status_message() const { return m_status_message; }
|
||||
|
||||
private:
|
||||
WebGLContextEvent(FlyString const& type, WebGLContextEventInit const& event_init)
|
||||
: DOM::Event(type, event_init)
|
||||
, m_status_message(event_init.status_message)
|
||||
{
|
||||
}
|
||||
|
||||
String m_status_message { String::empty() };
|
||||
};
|
||||
|
||||
}
|
11
Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.idl
Normal file
11
Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
interface WebGLContextEvent : Event {
|
||||
constructor(DOMString type, optional WebGLContextEventInit eventInit = {});
|
||||
readonly attribute DOMString statusMessage;
|
||||
};
|
||||
|
||||
dictionary WebGLContextEventInit : EventInit {
|
||||
DOMString statusMessage = "";
|
||||
};
|
|
@ -172,6 +172,7 @@ libweb_js_wrapper(UIEvents/MouseEvent)
|
|||
libweb_js_wrapper(UIEvents/UIEvent)
|
||||
libweb_js_wrapper(URL/URL)
|
||||
libweb_js_wrapper(URL/URLSearchParams ITERABLE)
|
||||
libweb_js_wrapper(WebGL/WebGLContextEvent)
|
||||
libweb_js_wrapper(WebSockets/WebSocket)
|
||||
libweb_js_wrapper(XHR/ProgressEvent)
|
||||
libweb_js_wrapper(XHR/XMLHttpRequest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue