1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:07:36 +00:00

LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated

This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
This commit is contained in:
Andreas Kling 2022-08-28 13:42:07 +02:00
parent bb547ce1c4
commit 6f433c8656
445 changed files with 4797 additions and 4268 deletions

View file

@ -88,7 +88,7 @@ HTML::Origin determine_the_origin(BrowsingContext const& browsing_context, Optio
}
// https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context
NonnullRefPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context(Page& page, RefPtr<DOM::Document> creator, RefPtr<DOM::Element> embedder)
NonnullRefPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context(Page& page, JS::GCPtr<DOM::Document> creator, JS::GCPtr<DOM::Element> embedder)
{
// 1. Let browsingContext be a new browsing context.
BrowsingContextContainer* container = (embedder && is<BrowsingContextContainer>(*embedder)) ? static_cast<BrowsingContextContainer*>(embedder.ptr()) : nullptr;
@ -117,19 +117,17 @@ NonnullRefPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context(Pa
// FIXME: 7. Let agent be the result of obtaining a similar-origin window agent given origin, group, and false.
RefPtr<Window> window;
JS::GCPtr<Window> window;
// 8. Let realm execution context be the result of creating a new JavaScript realm given agent and the following customizations:
auto realm_execution_context = Bindings::create_a_new_javascript_realm(
Bindings::main_thread_vm(),
[&](JS::Realm& realm) -> JS::GlobalObject* {
[&](JS::Realm& realm) -> JS::Object* {
// - For the global object, create a new Window object.
window = HTML::Window::create();
auto* global_object = realm.heap().allocate_without_realm<Bindings::WindowObject>(realm, *window);
VERIFY(window->wrapper() == global_object);
return global_object;
window = HTML::Window::create(realm);
return window.ptr();
},
[](JS::Realm&) -> JS::GlobalObject* {
[](JS::Realm&) -> JS::Object* {
// FIXME: - For the global this binding, use browsingContext's WindowProxy object.
return nullptr;
});
@ -172,7 +170,7 @@ NonnullRefPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context(Pa
// FIXME: load timing info is loadTimingInfo,
// FIXME: navigation id is null,
// and which is ready for post-load tasks.
auto document = DOM::Document::create();
auto document = DOM::Document::create(*window);
// Non-standard
document->set_window({}, *window);
@ -197,7 +195,7 @@ NonnullRefPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context(Pa
document->append_child(html_node);
// 19. Set the active document of browsingContext to document.
browsing_context->m_active_document = document;
browsing_context->m_active_document = JS::make_handle(*document);
// 20. If browsingContext's creator URL is non-null, then set document's referrer to the serialization of it.
if (browsing_context->m_creator_url.has_value()) {
@ -209,7 +207,7 @@ NonnullRefPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context(Pa
// 22. Append a new session history entry to browsingContext's session history whose URL is about:blank and document is document.
browsing_context->m_session_history.append(HTML::SessionHistoryEntry {
.url = AK::URL("about:blank"),
.document = document,
.document = document.ptr(),
.serialized_state = {},
.policy_container = {},
.scroll_restoration_mode = {},
@ -277,7 +275,7 @@ bool BrowsingContext::is_focused_context() const
void BrowsingContext::set_active_document(DOM::Document* document)
{
if (m_active_document == document)
if (m_active_document.ptr() == document)
return;
m_cursor_position = {};
@ -298,7 +296,7 @@ void BrowsingContext::set_active_document(DOM::Document* document)
m_name = String::empty();
}
m_active_document = document;
m_active_document = JS::make_handle(document);
if (m_active_document) {
m_active_document->attach_to_browsing_context({}, *this);
@ -392,7 +390,7 @@ void BrowsingContext::scroll_to_anchor(String const& fragment)
auto candidates = active_document()->get_elements_by_name(fragment);
for (auto& candidate : candidates->collect_matching_elements()) {
if (is<HTML::HTMLAnchorElement>(*candidate)) {
element = verify_cast<HTML::HTMLAnchorElement>(*candidate);
element = &verify_cast<HTML::HTMLAnchorElement>(*candidate);
break;
}
}
@ -603,7 +601,7 @@ bool BrowsingContext::has_a_rendering_opportunity() const
}
// https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-browsing-context
RefPtr<DOM::Node> BrowsingContext::currently_focused_area()
JS::GCPtr<DOM::Node> BrowsingContext::currently_focused_area()
{
// 1. If topLevelBC does not have system focus, then return null.
if (!is_focused_context())
@ -756,4 +754,14 @@ bool BrowsingContext::still_on_its_initial_about_blank_document() const
&& m_session_history[0].document->is_initial_about_blank();
}
DOM::Document const* BrowsingContext::active_document() const
{
return m_active_document.cell();
}
DOM::Document* BrowsingContext::active_document()
{
return m_active_document.cell();
}
}

View file

@ -26,7 +26,7 @@ namespace Web::HTML {
class BrowsingContext : public TreeNode<BrowsingContext> {
public:
static NonnullRefPtr<BrowsingContext> create_a_new_browsing_context(Page&, RefPtr<DOM::Document> creator, RefPtr<DOM::Element> embedder);
static NonnullRefPtr<BrowsingContext> create_a_new_browsing_context(Page&, JS::GCPtr<DOM::Document> creator, JS::GCPtr<DOM::Element> embedder);
~BrowsingContext();
@ -41,8 +41,8 @@ public:
bool is_top_level() const;
bool is_focused_context() const;
DOM::Document const* active_document() const { return m_active_document; }
DOM::Document* active_document() { return m_active_document; }
DOM::Document const* active_document() const;
DOM::Document* active_document();
void set_active_document(DOM::Document*);
@ -109,7 +109,7 @@ public:
bool has_a_rendering_opportunity() const;
RefPtr<DOM::Node> currently_focused_area();
JS::GCPtr<DOM::Node> currently_focused_area();
String const& name() const { return m_name; }
void set_name(String const& name) { m_name = name; }
@ -143,7 +143,7 @@ private:
Optional<HTML::Origin> m_creator_origin;
WeakPtr<HTML::BrowsingContextContainer> m_container;
RefPtr<DOM::Document> m_active_document;
JS::Handle<DOM::Document> m_active_document;
Gfx::IntSize m_size;
Gfx::IntPoint m_viewport_scroll_offset;

View file

@ -11,8 +11,9 @@
namespace Web::HTML {
class BrowsingContextContainer : public HTMLElement {
WEB_PLATFORM_OBJECT(BrowsingContextContainer, HTMLElement);
public:
BrowsingContextContainer(DOM::Document&, DOM::QualifiedName);
virtual ~BrowsingContextContainer() override;
BrowsingContext* nested_browsing_context() { return m_nested_browsing_context; }
@ -26,6 +27,8 @@ public:
DOM::Document const* get_svg_document() const;
protected:
BrowsingContextContainer(DOM::Document&, DOM::QualifiedName);
void create_new_nested_browsing_context();
void discard_nested_browsing_context();
@ -41,3 +44,5 @@ namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::BrowsingContextContainer>() const { return is_browsing_context_container(); }
}
WRAPPER_HACK(BrowsingContextContainer, Web::HTML)

View file

@ -15,7 +15,7 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource
// NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly.
using CanvasImageSource = Variant<NonnullRefPtr<HTMLImageElement>, NonnullRefPtr<HTMLCanvasElement>>;
using CanvasImageSource = Variant<JS::Handle<HTMLImageElement>, JS::Handle<HTMLCanvasElement>>;
// https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage
class CanvasDrawImage {

View file

@ -16,14 +16,14 @@ class CanvasGradient final
: public RefCounted<CanvasGradient>
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::CanvasGradientWrapper;
enum class Type {
Linear,
Radial,
Conic,
};
using WrapperType = Bindings::CanvasGradientWrapper;
static NonnullRefPtr<CanvasGradient> create_radial(double x0, double y0, double r0, double x1, double y1, double r1);
static NonnullRefPtr<CanvasGradient> create_linear(double x0, double y0, double x1, double y1);
static NonnullRefPtr<CanvasGradient> create_conic(double start_angle, double x, double y);

View file

@ -11,7 +11,6 @@
#include <LibGfx/Quad.h>
#include <LibGfx/Rect.h>
#include <LibWeb/Bindings/CanvasRenderingContext2DWrapper.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/CanvasRenderingContext2D.h>
#include <LibWeb/HTML/HTMLCanvasElement.h>
@ -25,7 +24,7 @@
namespace Web::HTML {
CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement& element)
: RefCountForwarder(element)
: m_element(JS::make_handle(element))
{
}
@ -33,17 +32,17 @@ CanvasRenderingContext2D::~CanvasRenderingContext2D() = default;
HTMLCanvasElement& CanvasRenderingContext2D::canvas_element()
{
return ref_count_target();
return *m_element;
}
HTMLCanvasElement const& CanvasRenderingContext2D::canvas_element() const
{
return ref_count_target();
return *m_element;
}
NonnullRefPtr<HTMLCanvasElement> CanvasRenderingContext2D::canvas_for_binding() const
JS::NonnullGCPtr<HTMLCanvasElement> CanvasRenderingContext2D::canvas_for_binding() const
{
return canvas_element();
return *m_element;
}
void CanvasRenderingContext2D::fill_rect(float x, float y, float width, float height)
@ -520,15 +519,15 @@ DOM::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImag
// 1. Switch on image:
auto usability = TRY(image.visit(
// HTMLOrSVGImageElement
[](HTMLImageElement const& image_element) -> DOM::ExceptionOr<Optional<CanvasImageSourceUsability>> {
[](JS::Handle<HTMLImageElement> const& image_element) -> DOM::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// FIXME: If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
// If image is not fully decodable, then return bad.
if (!image_element.bitmap())
if (!image_element->bitmap())
return { CanvasImageSourceUsability::Bad };
// If image has an intrinsic width or intrinsic height (or both) equal to zero, then return bad.
if (image_element.bitmap()->width() == 0 || image_element.bitmap()->height() == 0)
if (image_element->bitmap()->width() == 0 || image_element->bitmap()->height() == 0)
return { CanvasImageSourceUsability::Bad };
return Optional<CanvasImageSourceUsability> {};
},
@ -538,9 +537,9 @@ DOM::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImag
// HTMLCanvasElement
// FIXME: OffscreenCanvas
[](HTMLCanvasElement const& canvas_element) -> DOM::ExceptionOr<Optional<CanvasImageSourceUsability>> {
[](JS::Handle<HTMLCanvasElement> const& canvas_element) -> DOM::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// If image has either a horizontal dimension or a vertical dimension equal to zero, then throw an "InvalidStateError" DOMException.
if (canvas_element.width() == 0 || canvas_element.height() == 0)
if (canvas_element->width() == 0 || canvas_element->height() == 0)
return DOM::InvalidStateError::create("Canvas width or height is zero");
return Optional<CanvasImageSourceUsability> {};
}));
@ -557,7 +556,7 @@ bool image_is_not_origin_clean(CanvasImageSource const& image)
// An object image is not origin-clean if, switching on image's type:
return image.visit(
// HTMLOrSVGImageElement
[](HTMLImageElement const&) {
[](JS::Handle<HTMLImageElement> const&) {
// FIXME: image's current request's image data is CORS-cross-origin.
return false;
},
@ -567,7 +566,7 @@ bool image_is_not_origin_clean(CanvasImageSource const& image)
// HTMLCanvasElement
// FIXME: ImageBitmap
[](HTMLCanvasElement const&) {
[](JS::Handle<HTMLCanvasElement> const&) {
// FIXME: image's bitmap's origin-clean flag is false.
return false;
});

View file

@ -34,10 +34,10 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource
// NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly.
using CanvasImageSource = Variant<NonnullRefPtr<HTMLImageElement>, NonnullRefPtr<HTMLCanvasElement>>;
using CanvasImageSource = Variant<JS::Handle<HTMLImageElement>, JS::Handle<HTMLCanvasElement>>;
class CanvasRenderingContext2D
: public RefCountForwarder<HTMLCanvasElement>
: public RefCounted<CanvasRenderingContext2D>
, public Bindings::Wrappable
, public CanvasPath
, public CanvasState
@ -81,7 +81,7 @@ public:
virtual void reset_to_default_state() override;
NonnullRefPtr<HTMLCanvasElement> canvas_for_binding() const;
JS::NonnullGCPtr<HTMLCanvasElement> canvas_for_binding() const;
virtual RefPtr<TextMetrics> measure_text(String const& text) override;
@ -112,6 +112,8 @@ private:
void stroke_internal(Gfx::Path const&);
void fill_internal(Gfx::Path&, String const& fill_rule);
JS::Handle<HTMLCanvasElement> m_element;
// https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-origin-clean
bool m_origin_clean { true };
};

View file

@ -5,22 +5,22 @@
*/
#include <LibWeb/Bindings/CloseEventPrototype.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/HTML/CloseEvent.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
CloseEvent* CloseEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, CloseEventInit const& event_init)
CloseEvent* CloseEvent::create(HTML::Window& window_object, FlyString const& event_name, CloseEventInit const& event_init)
{
return window_object.heap().allocate<CloseEvent>(window_object.realm(), window_object, event_name, event_init);
}
CloseEvent* CloseEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, CloseEventInit const& event_init)
CloseEvent* CloseEvent::create_with_global_object(HTML::Window& window_object, FlyString const& event_name, CloseEventInit const& event_init)
{
return create(window_object, event_name, event_init);
}
CloseEvent::CloseEvent(Bindings::WindowObject& window_object, FlyString const& event_name, CloseEventInit const& event_init)
CloseEvent::CloseEvent(HTML::Window& window_object, FlyString const& event_name, CloseEventInit const& event_init)
: DOM::Event(window_object, event_name, event_init)
, m_was_clean(event_init.was_clean)
, m_code(event_init.code)

View file

@ -18,18 +18,16 @@ struct CloseEventInit : public DOM::EventInit {
};
class CloseEvent : public DOM::Event {
JS_OBJECT(CloseEvent, DOM::Event);
WEB_PLATFORM_OBJECT(CloseEvent, DOM::Event);
public:
static CloseEvent* create(Bindings::WindowObject&, FlyString const& event_name, CloseEventInit const& event_init = {});
static CloseEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, CloseEventInit const& event_init);
static CloseEvent* create(HTML::Window&, FlyString const& event_name, CloseEventInit const& event_init = {});
static CloseEvent* create_with_global_object(HTML::Window&, FlyString const& event_name, CloseEventInit const& event_init);
CloseEvent(Bindings::WindowObject&, FlyString const& event_name, CloseEventInit const& event_init);
CloseEvent(HTML::Window&, FlyString const& event_name, CloseEventInit const& event_init);
virtual ~CloseEvent() override;
CloseEvent& impl() { return *this; }
bool was_clean() const { return m_was_clean; }
u16 code() const { return m_code; }
String reason() const { return m_reason; }

View file

@ -4,22 +4,26 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/DOMParserWrapper.h>
#include <LibWeb/Bindings/DOMParserPrototype.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/HTML/DOMParser.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/XML/XMLDocumentBuilder.h>
namespace Web::HTML {
DOMParser::DOMParser() = default;
DOMParser::DOMParser(HTML::Window& window)
: m_window(JS::make_handle(window))
{
}
DOMParser::~DOMParser() = default;
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
NonnullRefPtr<DOM::Document> DOMParser::parse_from_string(String const& string, Bindings::DOMParserSupportedType type)
JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(String const& string, Bindings::DOMParserSupportedType type)
{
// 1. Let document be a new Document, whose content type is type and url is this's relevant global object's associated Document's URL.
// FIXME: Pass in this's relevant global object's associated Document's URL.
auto document = DOM::Document::create();
auto document = DOM::Document::create(Bindings::main_thread_internal_window_object(), m_window->associated_document().url());
document->set_content_type(Bindings::idl_enum_to_string(type));
// 2. Switch on type:
@ -31,7 +35,7 @@ NonnullRefPtr<DOM::Document> DOMParser::parse_from_string(String const& string,
// 2. Create an HTML parser parser, associated with document.
// 3. Place string into the input stream for parser. The encoding confidence is irrelevant.
// FIXME: We don't have the concept of encoding confidence yet.
auto parser = HTMLParser::create(document, string, "UTF-8");
auto parser = HTMLParser::create(*document, string, "UTF-8");
// 4. Start parser and let it run until it has consumed all the characters just inserted into the input stream.
// FIXME: This is to match the default URL. Instead, pass in this's relevant global object's associated Document's URL.
@ -41,7 +45,7 @@ NonnullRefPtr<DOM::Document> DOMParser::parse_from_string(String const& string,
// 1. Create an XML parser parse, associated with document, and with XML scripting support disabled.
XML::Parser parser(string, { .resolve_external_resource = resolve_xml_resource });
XMLDocumentBuilder builder { document, XMLScriptingSupport::Disabled };
XMLDocumentBuilder builder { *document, XMLScriptingSupport::Disabled };
// 2. Parse string using parser.
auto result = parser.parse_with_listener(builder);
// 3. If the previous step resulted in an XML well-formedness or XML namespace well-formedness error, then:
@ -50,10 +54,10 @@ NonnullRefPtr<DOM::Document> DOMParser::parse_from_string(String const& string,
// 1. Assert: document has no child nodes.
document->remove_all_children(true);
// 2. Let root be the result of creating an element given document, "parsererror", and "http://www.mozilla.org/newlayout/xml/parsererror.xml".
auto root = DOM::create_element(document, "parsererror", "http://www.mozilla.org/newlayout/xml/parsererror.xml");
auto root = DOM::create_element(*document, "parsererror", "http://www.mozilla.org/newlayout/xml/parsererror.xml");
// FIXME: 3. Optionally, add attributes or children to root to describe the nature of the parsing error.
// 4. Append root to document.
document->append_child(root);
document->append_child(*root);
}
}

View file

@ -23,17 +23,19 @@ class DOMParser final
public:
using WrapperType = Bindings::DOMParserWrapper;
static DOM::ExceptionOr<NonnullRefPtr<DOMParser>> create_with_global_object(Bindings::WindowObject&)
static DOM::ExceptionOr<NonnullRefPtr<DOMParser>> create_with_global_object(HTML::Window& window)
{
return adopt_ref(*new DOMParser());
return adopt_ref(*new DOMParser(window));
}
virtual ~DOMParser() override;
NonnullRefPtr<DOM::Document> parse_from_string(String const&, Bindings::DOMParserSupportedType type);
JS::NonnullGCPtr<DOM::Document> parse_from_string(String const&, Bindings::DOMParserSupportedType type);
private:
DOMParser();
explicit DOMParser(HTML::Window&);
JS::Handle<HTML::Window> m_window;
};
}

View file

@ -6,27 +6,33 @@
#include <AK/CharacterTypes.h>
#include <LibWeb/Bindings/DOMStringMapPrototype.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/HTML/DOMStringMap.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
DOMStringMap* DOMStringMap::create(DOM::Element& element)
JS::NonnullGCPtr<DOMStringMap> DOMStringMap::create(DOM::Element& element)
{
auto& realm = element.document().preferred_window_object().realm();
return realm.heap().allocate<DOMStringMap>(realm, element);
auto& realm = element.document().window().realm();
return *realm.heap().allocate<DOMStringMap>(realm, element);
}
DOMStringMap::DOMStringMap(DOM::Element& element)
: PlatformObject(element.document().preferred_window_object().ensure_web_prototype<Bindings::DOMStringMapPrototype>("DOMStringMap"))
: PlatformObject(element.document().window().ensure_web_prototype<Bindings::DOMStringMapPrototype>("DOMStringMap"))
, m_associated_element(element)
{
}
DOMStringMap::~DOMStringMap() = default;
void DOMStringMap::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_associated_element.ptr());
}
// https://html.spec.whatwg.org/multipage/dom.html#concept-domstringmap-pairs
Vector<DOMStringMap::NameValuePair> DOMStringMap::get_name_value_pairs() const
{

View file

@ -14,16 +14,13 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/dom.html#domstringmap
class DOMStringMap final : public Bindings::PlatformObject {
JS_OBJECT(DOMStringMap, Bindings::PlatformObject);
WEB_PLATFORM_OBJECT(DOMStringMap, Bindings::PlatformObject);
public:
static DOMStringMap* create(DOM::Element&);
explicit DOMStringMap(DOM::Element&);
static JS::NonnullGCPtr<DOMStringMap> create(DOM::Element&);
virtual ~DOMStringMap() override;
DOMStringMap& impl() { return *this; }
Vector<String> supported_property_names() const;
String determine_value_of_named_property(String const&) const;
@ -34,6 +31,10 @@ public:
bool delete_existing_named_property(String const&);
private:
explicit DOMStringMap(DOM::Element&);
virtual void visit_edges(Cell::Visitor&) override;
struct NameValuePair {
String name;
String value;
@ -42,12 +43,9 @@ private:
Vector<NameValuePair> get_name_value_pairs() const;
// https://html.spec.whatwg.org/multipage/dom.html#concept-domstringmap-element
NonnullRefPtr<DOM::Element> m_associated_element;
JS::NonnullGCPtr<DOM::Element> m_associated_element;
};
}
namespace Web::Bindings {
inline JS::Object* wrap(JS::Realm&, Web::HTML::DOMStringMap& object) { return &object; }
using DOMStringMapWrapper = Web::HTML::DOMStringMap;
}
WRAPPER_HACK(DOMStringMap, Web::HTML)

View file

@ -5,22 +5,22 @@
*/
#include <LibWeb/Bindings/ErrorEventPrototype.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/HTML/ErrorEvent.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
ErrorEvent* ErrorEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
ErrorEvent* ErrorEvent::create(HTML::Window& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
{
return window_object.heap().allocate<ErrorEvent>(window_object.realm(), window_object, event_name, event_init);
}
ErrorEvent* ErrorEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
ErrorEvent* ErrorEvent::create_with_global_object(HTML::Window& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
{
return create(window_object, event_name, event_init);
}
ErrorEvent::ErrorEvent(Bindings::WindowObject& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
ErrorEvent::ErrorEvent(HTML::Window& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
: DOM::Event(window_object, event_name)
, m_message(event_init.message)
, m_filename(event_init.filename)

View file

@ -21,18 +21,16 @@ struct ErrorEventInit : public DOM::EventInit {
// https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
class ErrorEvent final : public DOM::Event {
JS_OBJECT(ErrorEvent, DOM::Event);
WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event);
public:
static ErrorEvent* create(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init = {});
static ErrorEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init);
static ErrorEvent* create(HTML::Window&, FlyString const& event_name, ErrorEventInit const& event_init = {});
static ErrorEvent* create_with_global_object(HTML::Window&, FlyString const& event_name, ErrorEventInit const& event_init);
ErrorEvent(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init);
ErrorEvent(HTML::Window&, FlyString const& event_name, ErrorEventInit const& event_init);
virtual ~ErrorEvent() override;
ErrorEvent& impl() { return *this; }
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-message
String const& message() const { return m_message; }

View file

@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/DOM/DOMEventListener.h>
#include <LibWeb/HTML/EventHandler.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {

View file

@ -141,12 +141,12 @@ void EventLoop::process()
// - Any Document B whose browsing context's container document is A must be listed after A in the list.
// - If there are two documents A and B whose browsing contexts are both child browsing contexts whose container documents are another Document C, then the order of A and B in the list must match the shadow-including tree order of their respective browsing context containers in C's node tree.
// FIXME: NOTE: The sort order specified above is missing here!
NonnullRefPtrVector<DOM::Document> docs = documents_in_this_event_loop();
Vector<JS::Handle<DOM::Document>> docs = documents_in_this_event_loop();
auto for_each_fully_active_document_in_docs = [&](auto&& callback) {
for (auto& document : docs) {
if (document.is_fully_active())
callback(document);
if (document->is_fully_active())
callback(*document);
}
};
@ -215,7 +215,7 @@ void EventLoop::process()
// 3. For each win of the same-loop windows for this event loop,
// perform the start an idle period algorithm for win with computeDeadline. [REQUESTIDLECALLBACK]
for (auto& win : same_loop_windows())
win.start_an_idle_period();
win->start_an_idle_period();
}
// FIXME: 14. If this is a worker event loop, then:
@ -248,8 +248,8 @@ void queue_global_task(HTML::Task::Source source, JS::Object& global_object, Fun
// 2. Let document be global's associated Document, if global is a Window object; otherwise null.
DOM::Document* document { nullptr };
if (is<Bindings::WindowObject>(global_object)) {
auto& window_object = verify_cast<Bindings::WindowObject>(global_object);
if (is<HTML::Window>(global_object)) {
auto& window_object = verify_cast<HTML::Window>(global_object);
document = &window_object.impl().associated_document();
}
@ -320,12 +320,12 @@ void EventLoop::perform_a_microtask_checkpoint()
m_performing_a_microtask_checkpoint = false;
}
NonnullRefPtrVector<DOM::Document> EventLoop::documents_in_this_event_loop() const
Vector<JS::Handle<DOM::Document>> EventLoop::documents_in_this_event_loop() const
{
NonnullRefPtrVector<DOM::Document> documents;
Vector<JS::Handle<DOM::Document>> documents;
for (auto& document : m_documents) {
VERIFY(document);
documents.append(*document);
documents.append(JS::make_handle(*document.ptr()));
}
return documents;
}
@ -368,11 +368,11 @@ void EventLoop::unregister_environment_settings_object(Badge<EnvironmentSettings
}
// https://html.spec.whatwg.org/multipage/webappapis.html#same-loop-windows
NonnullRefPtrVector<Window> EventLoop::same_loop_windows() const
Vector<JS::Handle<HTML::Window>> EventLoop::same_loop_windows() const
{
NonnullRefPtrVector<Window> windows;
Vector<JS::Handle<HTML::Window>> windows;
for (auto& document : documents_in_this_event_loop())
windows.append(document.window());
windows.append(JS::make_handle(document->window()));
return windows;
}
@ -394,7 +394,7 @@ double EventLoop::compute_deadline() const
// 1. If windowInSameLoop's map of animation frame callbacks is not empty,
// or if the user agent believes that the windowInSameLoop might have pending rendering updates,
// set hasPendingRenders to true.
if (window.has_animation_frame_callbacks())
if (window->has_animation_frame_callbacks())
has_pending_renders = true;
// FIXME: 2. Let timerCallbackEstimates be the result of getting the values of windowInSameLoop's map of active timers.
// FIXME: 3. For each timeoutDeadline of timerCallbackEstimates, if timeoutDeadline is less than deadline, set deadline to timeoutDeadline.

View file

@ -53,9 +53,9 @@ public:
void register_document(Badge<DOM::Document>, DOM::Document&);
void unregister_document(Badge<DOM::Document>, DOM::Document&);
NonnullRefPtrVector<DOM::Document> documents_in_this_event_loop() const;
Vector<JS::Handle<DOM::Document>> documents_in_this_event_loop() const;
NonnullRefPtrVector<Window> same_loop_windows() const;
Vector<JS::Handle<HTML::Window>> same_loop_windows() const;
void push_onto_backup_incumbent_settings_object_stack(Badge<EnvironmentSettingsObject>, EnvironmentSettingsObject& environment_settings_object);
void pop_backup_incumbent_settings_object_stack(Badge<EnvironmentSettingsObject>);

View file

@ -12,7 +12,7 @@ namespace Web::HTML {
Task::Task(Source source, DOM::Document* document, Function<void()> steps)
: m_source(source)
, m_steps(move(steps))
, m_document(document)
, m_document(JS::make_handle(document))
{
}
@ -27,7 +27,17 @@ void Task::execute()
bool Task::is_runnable() const
{
// A task is runnable if its document is either null or fully active.
return !m_document || m_document->is_fully_active();
return !m_document.ptr() || m_document->is_fully_active();
}
DOM::Document* Task::document()
{
return m_document.ptr();
}
DOM::Document const* Task::document() const
{
return m_document.ptr();
}
}

View file

@ -9,6 +9,7 @@
#include <AK/Function.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/RefPtr.h>
#include <LibJS/Heap/Handle.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
@ -38,8 +39,8 @@ public:
Source source() const { return m_source; }
void execute();
DOM::Document* document() { return m_document; }
DOM::Document const* document() const { return m_document; }
DOM::Document* document();
DOM::Document const* document() const;
bool is_runnable() const;
@ -48,7 +49,7 @@ private:
Source m_source { Source::Unspecified };
Function<void()> m_steps;
RefPtr<DOM::Document> m_document;
JS::Handle<DOM::Document> m_document;
};
}

View file

@ -4,13 +4,17 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLAnchorElementPrototype.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLAnchorElementPrototype>("HTMLAnchorElement"));
activation_behavior = [this](auto const& event) {
run_activation_behavior(event);
};

View file

@ -14,10 +14,9 @@ namespace Web::HTML {
class HTMLAnchorElement final
: public HTMLElement
, public HTMLHyperlinkElementUtils {
public:
using WrapperType = Bindings::HTMLAnchorElementWrapper;
WEB_PLATFORM_OBJECT(HTMLAnchorElement, HTMLElement);
HTMLAnchorElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLAnchorElement() override;
String target() const { return attribute(HTML::AttributeNames::target); }
@ -30,6 +29,8 @@ public:
virtual bool is_html_anchor_element() const override { return true; }
private:
HTMLAnchorElement(DOM::Document&, DOM::QualifiedName);
void run_activation_behavior(Web::DOM::Event const&);
// ^DOM::Element
@ -54,3 +55,5 @@ namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLAnchorElement>() const { return is_html_anchor_element(); }
}
WRAPPER_HACK(HTMLAnchorElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLAreaElementPrototype.h>
#include <LibWeb/HTML/HTMLAreaElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLAreaElement::HTMLAreaElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLAreaElementPrototype>("HTMLAreaElement"));
}
HTMLAreaElement::~HTMLAreaElement() = default;

View file

@ -15,13 +15,14 @@ namespace Web::HTML {
class HTMLAreaElement final
: public HTMLElement
, public HTMLHyperlinkElementUtils {
public:
using WrapperType = Bindings::HTMLAreaElementWrapper;
WEB_PLATFORM_OBJECT(HTMLAreaElement, HTMLElement);
HTMLAreaElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLAreaElement() override;
private:
HTMLAreaElement(DOM::Document&, DOM::QualifiedName);
// ^DOM::Element
virtual void parse_attribute(FlyString const& name, String const& value) override;
@ -39,3 +40,5 @@ private:
};
}
WRAPPER_HACK(HTMLAreaElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLAudioElementPrototype.h>
#include <LibWeb/HTML/HTMLAudioElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLAudioElement::HTMLAudioElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLMediaElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLAudioElementPrototype>("HTMLAudioElement"));
}
HTMLAudioElement::~HTMLAudioElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLAudioElement final : public HTMLMediaElement {
public:
using WrapperType = Bindings::HTMLAudioElementWrapper;
WEB_PLATFORM_OBJECT(HTMLAudioElement, HTMLMediaElement);
HTMLAudioElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLAudioElement() override;
private:
HTMLAudioElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLAudioElement, Web::HTML)

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLBRElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLBRElement.h>
#include <LibWeb/Layout/BreakNode.h>
@ -13,6 +14,7 @@ namespace Web::HTML {
HTMLBRElement::HTMLBRElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLBRElementPrototype>("HTMLBRElement"));
}
HTMLBRElement::~HTMLBRElement() = default;

View file

@ -11,13 +11,17 @@
namespace Web::HTML {
class HTMLBRElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLBRElementWrapper;
WEB_PLATFORM_OBJECT(HTMLBRElement, HTMLElement);
HTMLBRElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLBRElement() override;
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
private:
HTMLBRElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLBRElement, Web::HTML)

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLBaseElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLBaseElement.h>
@ -12,6 +13,7 @@ namespace Web::HTML {
HTMLBaseElement::HTMLBaseElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLBaseElementPrototype>("HTMLBaseElement"));
}
HTMLBaseElement::~HTMLBaseElement() = default;
@ -25,7 +27,7 @@ void HTMLBaseElement::inserted()
// NOTE: inserted() is called after this element has been inserted into the document.
auto first_base_element_with_href_in_document = document().first_base_element_with_href_in_tree_order();
if (first_base_element_with_href_in_document == this)
if (first_base_element_with_href_in_document.ptr() == this)
set_the_frozen_base_url();
}
@ -39,7 +41,7 @@ void HTMLBaseElement::parse_attribute(FlyString const& name, String const& value
return;
auto first_base_element_with_href_in_document = document().first_base_element_with_href_in_tree_order();
if (first_base_element_with_href_in_document == this)
if (first_base_element_with_href_in_document.ptr() == this)
set_the_frozen_base_url();
}

View file

@ -11,10 +11,9 @@
namespace Web::HTML {
class HTMLBaseElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLBaseElementWrapper;
WEB_PLATFORM_OBJECT(HTMLBaseElement, HTMLElement);
HTMLBaseElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLBaseElement() override;
String href() const;
@ -26,6 +25,8 @@ public:
virtual void parse_attribute(FlyString const& name, String const& value) override;
private:
HTMLBaseElement(DOM::Document&, DOM::QualifiedName);
virtual bool is_html_base_element() const override { return true; }
// https://html.spec.whatwg.org/multipage/semantics.html#frozen-base-url
@ -41,3 +42,5 @@ namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLBaseElement>() const { return is_html_base_element(); }
}
WRAPPER_HACK(HTMLBaseElement, Web::HTML)

View file

@ -12,14 +12,19 @@
namespace Web::HTML {
class HTMLBlinkElement final : public HTMLElement {
WEB_PLATFORM_OBJECT(HTMLBlinkElement, HTMLElement);
public:
HTMLBlinkElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLBlinkElement() override;
private:
HTMLBlinkElement(DOM::Document&, DOM::QualifiedName);
void blink();
NonnullRefPtr<Core::Timer> m_timer;
};
}
WRAPPER_HACK(HTMLBlinkElement, Web::HTML)

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLBodyElementPrototype.h>
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/DOM/Document.h>
@ -15,6 +16,7 @@ namespace Web::HTML {
HTMLBodyElement::HTMLBodyElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLBodyElementPrototype>("HTMLBodyElement"));
}
HTMLBodyElement::~HTMLBodyElement() = default;

View file

@ -14,16 +14,17 @@ namespace Web::HTML {
class HTMLBodyElement final
: public HTMLElement
, public WindowEventHandlers {
public:
using WrapperType = Bindings::HTMLBodyElementWrapper;
WEB_PLATFORM_OBJECT(HTMLBodyElement, HTMLElement);
HTMLBodyElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLBodyElement() override;
virtual void parse_attribute(FlyString const&, String const&) override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
private:
HTMLBodyElement(DOM::Document&, DOM::QualifiedName);
// ^HTML::GlobalEventHandlers
virtual EventTarget& global_event_handlers_to_event_target(FlyString const& event_name) override;
@ -34,3 +35,5 @@ private:
};
}
WRAPPER_HACK(HTMLBodyElement, Web::HTML)

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLButtonElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLButtonElement.h>
#include <LibWeb/HTML/HTMLFormElement.h>
@ -13,6 +14,8 @@ namespace Web::HTML {
HTMLButtonElement::HTMLButtonElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLButtonElementPrototype>("HTMLButtonElement"));
// https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element:activation-behaviour
activation_behavior = [this](auto&) {
// 1. If element is disabled, then return.

View file

@ -19,12 +19,10 @@ namespace Web::HTML {
class HTMLButtonElement final
: public HTMLElement
, public FormAssociatedElement {
WEB_PLATFORM_OBJECT(HTMLButtonElement, HTMLElement);
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLButtonElement)
public:
using WrapperType = Bindings::HTMLButtonElementWrapper;
HTMLButtonElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLButtonElement() override;
enum class TypeAttributeState {
@ -54,6 +52,11 @@ public:
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
private:
HTMLButtonElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLButtonElement, Web::HTML)

View file

@ -14,11 +14,11 @@
namespace Web::HTML {
class HTMLCanvasElement final : public HTMLElement {
WEB_PLATFORM_OBJECT(HTMLCanvasElement, HTMLElement);
public:
using WrapperType = Bindings::HTMLCanvasElementWrapper;
using RenderingContext = Variant<NonnullRefPtr<CanvasRenderingContext2D>, NonnullRefPtr<WebGL::WebGLRenderingContext>, Empty>;
HTMLCanvasElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLCanvasElement() override;
Gfx::Bitmap const* bitmap() const { return m_bitmap; }
@ -38,6 +38,8 @@ public:
void present();
private:
HTMLCanvasElement(DOM::Document&, DOM::QualifiedName);
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
enum class HasOrCreatedContext {
@ -54,3 +56,5 @@ private:
};
}
WRAPPER_HACK(HTMLCanvasElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLDListElementPrototype.h>
#include <LibWeb/HTML/HTMLDListElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLDListElement::HTMLDListElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLDListElementPrototype>("HTMLDListElement"));
}
HTMLDListElement::~HTMLDListElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLDListElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLDListElementWrapper;
WEB_PLATFORM_OBJECT(HTMLDListElement, HTMLElement);
HTMLDListElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLDListElement() override;
private:
HTMLDListElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLDListElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLDataElementPrototype.h>
#include <LibWeb/HTML/HTMLDataElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLDataElement::HTMLDataElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLDataElementPrototype>("HTMLDataElement"));
}
HTMLDataElement::~HTMLDataElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLDataElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLDataElementWrapper;
WEB_PLATFORM_OBJECT(HTMLDataElement, HTMLElement);
HTMLDataElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLDataElement() override;
private:
HTMLDataElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLDataElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLDataListElementPrototype.h>
#include <LibWeb/HTML/HTMLDataListElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLDataListElement::HTMLDataListElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLDataListElementPrototype>("HTMLDataListElement"));
}
HTMLDataListElement::~HTMLDataListElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLDataListElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLDataListElementWrapper;
WEB_PLATFORM_OBJECT(HTMLDataListElement, HTMLElement);
HTMLDataListElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLDataListElement() override;
private:
HTMLDataListElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLDataListElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLDetailsElementPrototype.h>
#include <LibWeb/HTML/HTMLDetailsElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLDetailsElement::HTMLDetailsElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLDetailsElementPrototype>("HTMLDetailsElement"));
}
HTMLDetailsElement::~HTMLDetailsElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLDetailsElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLDetailsElementWrapper;
WEB_PLATFORM_OBJECT(HTMLDetailsElement, HTMLElement);
HTMLDetailsElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLDetailsElement() override;
private:
HTMLDetailsElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLDetailsElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLDialogElementPrototype.h>
#include <LibWeb/HTML/HTMLDialogElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLDialogElement::HTMLDialogElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLDialogElementPrototype>("HTMLDialogElement"));
}
HTMLDialogElement::~HTMLDialogElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLDialogElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLDialogElementWrapper;
WEB_PLATFORM_OBJECT(HTMLDialogElement, HTMLElement);
HTMLDialogElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLDialogElement() override;
private:
HTMLDialogElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLDialogElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLDirectoryElementPrototype.h>
#include <LibWeb/HTML/HTMLDirectoryElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLDirectoryElement::HTMLDirectoryElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLDirectoryElementPrototype>("HTMLDirectoryElement"));
}
HTMLDirectoryElement::~HTMLDirectoryElement() = default;

View file

@ -12,11 +12,15 @@ namespace Web::HTML {
// NOTE: This element is marked as obsolete, but is still listed as required by the specification.
class HTMLDirectoryElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLDirectoryElementWrapper;
WEB_PLATFORM_OBJECT(HTMLDirectoryElement, HTMLElement);
HTMLDirectoryElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLDirectoryElement() override;
private:
HTMLDirectoryElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLDirectoryElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLDivElementPrototype.h>
#include <LibWeb/HTML/HTMLDivElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLDivElement::HTMLDivElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLDivElementPrototype>("HTMLDivElement"));
}
HTMLDivElement::~HTMLDivElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLDivElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLDivElementWrapper;
WEB_PLATFORM_OBJECT(HTMLDivElement, HTMLElement);
HTMLDivElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLDivElement() override;
private:
HTMLDivElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLDivElement, Web::HTML)

View file

@ -7,6 +7,7 @@
#include <AK/StringBuilder.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Parser.h>
#include <LibWeb/Bindings/HTMLElementPrototype.h>
#include <LibWeb/DOM/DOMException.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ExceptionOr.h>
@ -30,12 +31,19 @@ namespace Web::HTML {
HTMLElement::HTMLElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: Element(document, move(qualified_name))
, m_dataset(JS::make_handle(DOMStringMap::create(*this)))
, m_dataset(DOMStringMap::create(*this))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLElementPrototype>("HTMLElement"));
}
HTMLElement::~HTMLElement() = default;
void HTMLElement::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_dataset.ptr());
}
HTMLElement::ContentEditableState HTMLElement::content_editable_state() const
{
auto contenteditable = attribute(HTML::AttributeNames::contenteditable);
@ -200,7 +208,7 @@ void HTMLElement::parse_attribute(FlyString const& name, String const& value)
}
// https://html.spec.whatwg.org/multipage/interaction.html#focus-update-steps
static void run_focus_update_steps(NonnullRefPtrVector<DOM::Node> old_chain, NonnullRefPtrVector<DOM::Node> new_chain, DOM::Node& new_focus_target)
static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vector<JS::Handle<DOM::Node>> new_chain, DOM::Node& new_focus_target)
{
// 1. If the last entry in old chain and the last entry in new chain are the same,
// pop the last entry from old chain and the last entry from new chain and redo this step.
@ -221,33 +229,33 @@ static void run_focus_update_steps(NonnullRefPtrVector<DOM::Node> old_chain, Non
// then fire an event named change at the element,
// with the bubbles attribute initialized to true.
RefPtr<DOM::EventTarget> blur_event_target;
if (is<DOM::Element>(entry)) {
JS::GCPtr<DOM::EventTarget> blur_event_target;
if (is<DOM::Element>(*entry)) {
// 2. If entry is an element, let blur event target be entry.
blur_event_target = entry;
} else if (is<DOM::Document>(entry)) {
blur_event_target = entry.ptr();
} else if (is<DOM::Document>(*entry)) {
// If entry is a Document object, let blur event target be that Document object's relevant global object.
blur_event_target = static_cast<DOM::Document&>(entry).window();
blur_event_target = &static_cast<DOM::Document&>(*entry).window();
}
// 3. If entry is the last entry in old chain, and entry is an Element,
// and the last entry in new chain is also an Element,
// then let related blur target be the last entry in new chain.
// Otherwise, let related blur target be null.
RefPtr<DOM::EventTarget> related_blur_target;
JS::GCPtr<DOM::EventTarget> related_blur_target;
if (!old_chain.is_empty()
&& &entry == &old_chain.last()
&& is<DOM::Element>(entry)
&& is<DOM::Element>(*entry)
&& !new_chain.is_empty()
&& is<DOM::Element>(new_chain.last())) {
related_blur_target = new_chain.last();
&& is<DOM::Element>(*new_chain.last())) {
related_blur_target = new_chain.last().ptr();
}
// 4. If blur event target is not null, fire a focus event named blur at blur event target,
// with related blur target as the related target.
if (blur_event_target) {
// FIXME: Implement the "fire a focus event" spec operation.
auto blur_event = UIEvents::FocusEvent::create(verify_cast<DOM::Node>(*blur_event_target).document().preferred_window_object(), HTML::EventNames::blur);
auto blur_event = UIEvents::FocusEvent::create(verify_cast<DOM::Node>(*blur_event_target).document().window(), HTML::EventNames::blur);
blur_event->set_related_target(related_blur_target);
blur_event_target->dispatch_event(*blur_event);
}
@ -261,50 +269,50 @@ static void run_focus_update_steps(NonnullRefPtrVector<DOM::Node> old_chain, Non
for (auto& entry : new_chain.in_reverse()) {
// 1. If entry is a focusable area: designate entry as the focused area of the document.
// FIXME: This isn't entirely right.
if (is<DOM::Element>(entry))
entry.document().set_focused_element(&static_cast<DOM::Element&>(entry));
if (is<DOM::Element>(*entry))
entry->document().set_focused_element(&static_cast<DOM::Element&>(*entry));
RefPtr<DOM::EventTarget> focus_event_target;
if (is<DOM::Element>(entry)) {
JS::GCPtr<DOM::EventTarget> focus_event_target;
if (is<DOM::Element>(*entry)) {
// 2. If entry is an element, let focus event target be entry.
focus_event_target = entry;
} else if (is<DOM::Document>(entry)) {
focus_event_target = entry.ptr();
} else if (is<DOM::Document>(*entry)) {
// If entry is a Document object, let focus event target be that Document object's relevant global object.
focus_event_target = static_cast<DOM::Document&>(entry).window();
focus_event_target = &static_cast<DOM::Document&>(*entry).window();
}
// 3. If entry is the last entry in new chain, and entry is an Element,
// and the last entry in old chain is also an Element,
// then let related focus target be the last entry in old chain.
// Otherwise, let related focus target be null.
RefPtr<DOM::EventTarget> related_focus_target;
JS::GCPtr<DOM::EventTarget> related_focus_target;
if (!new_chain.is_empty()
&& &entry == &new_chain.last()
&& is<DOM::Element>(entry)
&& is<DOM::Element>(*entry)
&& !old_chain.is_empty()
&& is<DOM::Element>(old_chain.last())) {
related_focus_target = old_chain.last();
&& is<DOM::Element>(*old_chain.last())) {
related_focus_target = old_chain.last().ptr();
}
// 4. If focus event target is not null, fire a focus event named focus at focus event target,
// with related focus target as the related target.
if (focus_event_target) {
// FIXME: Implement the "fire a focus event" spec operation.
auto focus_event = UIEvents::FocusEvent::create(verify_cast<DOM::Node>(*focus_event_target).document().preferred_window_object(), HTML::EventNames::focus);
auto focus_event = UIEvents::FocusEvent::create(verify_cast<DOM::Node>(*focus_event_target).document().window(), HTML::EventNames::focus);
focus_event->set_related_target(related_focus_target);
focus_event_target->dispatch_event(*focus_event);
}
}
}
// https://html.spec.whatwg.org/multipage/interaction.html#focus-chain
static NonnullRefPtrVector<DOM::Node> focus_chain(DOM::Node* subject)
static Vector<JS::Handle<DOM::Node>> focus_chain(DOM::Node* subject)
{
// FIXME: Move this somewhere more spec-friendly.
if (!subject)
return {};
// 1. Let output be an empty list.
NonnullRefPtrVector<DOM::Node> output;
Vector<JS::Handle<DOM::Node>> output;
// 2. Let currentObject be subject.
auto* current_object = subject;
@ -312,7 +320,7 @@ static NonnullRefPtrVector<DOM::Node> focus_chain(DOM::Node* subject)
// 3. While true:
while (true) {
// 1. Append currentObject to output.
output.append(*current_object);
output.append(JS::make_handle(*current_object));
// FIXME: 2. If currentObject is an area element's shape, then append that area element to output.
@ -369,7 +377,7 @@ static void run_focusing_steps(DOM::Node* new_focus_target, DOM::Node* fallback_
if (!new_focus_target->document().browsing_context())
return;
auto& top_level_browsing_context = new_focus_target->document().browsing_context()->top_level_browsing_context();
if (new_focus_target == top_level_browsing_context.currently_focused_area())
if (new_focus_target == top_level_browsing_context.currently_focused_area().ptr())
return;
// 6. Let old chain be the current focus chain of the top-level browsing context in which
@ -411,7 +419,7 @@ bool HTMLElement::fire_a_synthetic_pointer_event(FlyString const& type, DOM::Ele
// 1. Let event be the result of creating an event using PointerEvent.
// 2. Initialize event's type attribute to e.
// FIXME: Actually create a PointerEvent!
auto event = UIEvents::MouseEvent::create(document().preferred_window_object(), type);
auto event = UIEvents::MouseEvent::create(document().window(), type);
// 3. Initialize event's bubbles and cancelable attributes to true.
event->set_bubbles(true);

View file

@ -16,10 +16,9 @@ namespace Web::HTML {
class HTMLElement
: public DOM::Element
, public HTML::GlobalEventHandlers {
public:
using WrapperType = Bindings::HTMLElementWrapper;
WEB_PLATFORM_OBJECT(HTMLElement, DOM::Element);
HTMLElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLElement() override;
String title() const { return attribute(HTML::AttributeNames::title); }
@ -38,8 +37,8 @@ public:
bool cannot_navigate() const;
DOMStringMap* dataset() { return m_dataset.cell(); }
DOMStringMap const* dataset() const { return m_dataset.cell(); }
DOMStringMap* dataset() { return m_dataset.ptr(); }
DOMStringMap const* dataset() const { return m_dataset.ptr(); }
void focus();
@ -51,8 +50,12 @@ public:
virtual bool is_labelable() const { return false; }
protected:
HTMLElement(DOM::Document&, DOM::QualifiedName);
virtual void parse_attribute(FlyString const& name, String const& value) override;
virtual void visit_edges(Cell::Visitor&) override;
private:
virtual bool is_html_element() const final { return true; }
@ -66,7 +69,7 @@ private:
};
ContentEditableState content_editable_state() const;
JS::Handle<DOMStringMap> m_dataset;
JS::NonnullGCPtr<DOMStringMap> m_dataset;
// https://html.spec.whatwg.org/multipage/interaction.html#locked-for-focus
bool m_locked_for_focus { false };
@ -81,3 +84,5 @@ namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLElement>() const { return is_html_element(); }
}
WRAPPER_HACK(HTMLElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLEmbedElementPrototype.h>
#include <LibWeb/HTML/HTMLEmbedElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLEmbedElement::HTMLEmbedElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLEmbedElementPrototype>("HTMLEmbedElement"));
}
HTMLEmbedElement::~HTMLEmbedElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLEmbedElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLEmbedElementWrapper;
WEB_PLATFORM_OBJECT(HTMLEmbedElement, HTMLElement);
HTMLEmbedElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLEmbedElement() override;
private:
HTMLEmbedElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLEmbedElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLFieldSetElementPrototype.h>
#include <LibWeb/HTML/HTMLFieldSetElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLFieldSetElement::HTMLFieldSetElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLFieldSetElementPrototype>("HTMLFieldSetElement"));
}
HTMLFieldSetElement::~HTMLFieldSetElement() = default;

View file

@ -14,12 +14,10 @@ namespace Web::HTML {
class HTMLFieldSetElement final
: public HTMLElement
, public FormAssociatedElement {
WEB_PLATFORM_OBJECT(HTMLFieldSetElement, HTMLElement);
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLFieldSetElement)
public:
using WrapperType = Bindings::HTMLFieldSetElementWrapper;
HTMLFieldSetElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLFieldSetElement() override;
String const& type() const
@ -34,6 +32,11 @@ public:
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const override { return true; }
private:
HTMLFieldSetElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLFieldSetElement, Web::HTML)

View file

@ -4,15 +4,18 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLFontElementPrototype.h>
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/HTML/HTMLFontElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLFontElement::HTMLFontElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLFontElementPrototype>("HTMLFontElement"));
}
HTMLFontElement::~HTMLFontElement() = default;

View file

@ -11,13 +11,17 @@
namespace Web::HTML {
class HTMLFontElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLFontElementWrapper;
WEB_PLATFORM_OBJECT(HTMLFontElement, HTMLElement);
HTMLFontElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLFontElement() override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
private:
HTMLFontElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLFontElement, Web::HTML)

View file

@ -5,6 +5,7 @@
*/
#include <AK/StringBuilder.h>
#include <LibWeb/Bindings/HTMLFormElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/EventNames.h>
@ -25,11 +26,19 @@ namespace Web::HTML {
HTMLFormElement::HTMLFormElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLFormElementPrototype>("HTMLFormElement"));
}
HTMLFormElement::~HTMLFormElement() = default;
void HTMLFormElement::submit_form(RefPtr<HTMLElement> submitter, bool from_submit_binding)
void HTMLFormElement::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
for (auto& element : m_associated_elements)
visitor.visit(element.ptr());
}
void HTMLFormElement::submit_form(JS::GCPtr<HTMLElement> submitter, bool from_submit_binding)
{
if (cannot_navigate())
return;
@ -58,14 +67,14 @@ void HTMLFormElement::submit_form(RefPtr<HTMLElement> submitter, bool from_submi
// FIXME: If the submitter element's no-validate state is false...
RefPtr<HTMLElement> submitter_button;
JS::GCPtr<HTMLElement> submitter_button;
if (submitter != this)
submitter_button = submitter;
SubmitEventInit event_init {};
event_init.submitter = submitter_button;
auto submit_event = SubmitEvent::create(document().preferred_window_object(), EventNames::submit, event_init);
auto submit_event = SubmitEvent::create(document().window(), EventNames::submit, event_init);
submit_event->set_bubbles(true);
submit_event->set_cancelable(true);
bool continue_ = dispatch_event(*submit_event);

View file

@ -12,16 +12,15 @@
namespace Web::HTML {
class HTMLFormElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLFormElementWrapper;
WEB_PLATFORM_OBJECT(HTMLFormElement, HTMLElement);
HTMLFormElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLFormElement() override;
String action() const;
String method() const { return attribute(HTML::AttributeNames::method); }
void submit_form(RefPtr<HTMLElement> submitter, bool from_submit_binding = false);
void submit_form(JS::GCPtr<HTMLElement> submitter, bool from_submit_binding = false);
// NOTE: This is for the JS bindings. Use submit_form instead.
void submit();
@ -33,9 +32,15 @@ public:
unsigned length() const;
private:
HTMLFormElement(DOM::Document&, DOM::QualifiedName);
virtual void visit_edges(Cell::Visitor&) override;
bool m_firing_submission_events { false };
Vector<WeakPtr<HTMLElement>> m_associated_elements;
Vector<JS::GCPtr<HTMLElement>> m_associated_elements;
};
}
WRAPPER_HACK(HTMLFormElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLFrameElementPrototype.h>
#include <LibWeb/HTML/HTMLFrameElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLFrameElement::HTMLFrameElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLFrameElementPrototype>("HTMLFrameElement"));
}
HTMLFrameElement::~HTMLFrameElement() = default;

View file

@ -12,11 +12,15 @@ namespace Web::HTML {
// NOTE: This element is marked as obsolete, but is still listed as required by the specification.
class HTMLFrameElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLFrameElementWrapper;
WEB_PLATFORM_OBJECT(HTMLFrameElement, HTMLElement);
HTMLFrameElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLFrameElement() override;
private:
HTMLFrameElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLFrameElement, Web::HTML)

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLFrameSetElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLFrameSetElement.h>
#include <LibWeb/HTML/Window.h>
@ -13,6 +14,7 @@ namespace Web::HTML {
HTMLFrameSetElement::HTMLFrameSetElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLFrameSetElementPrototype>("HTMLFrameSetElement"));
}
HTMLFrameSetElement::~HTMLFrameSetElement() = default;

View file

@ -15,12 +15,14 @@ namespace Web::HTML {
class HTMLFrameSetElement final
: public HTMLElement
, public WindowEventHandlers {
public:
using WrapperType = Bindings::HTMLFrameSetElementWrapper;
WEB_PLATFORM_OBJECT(HTMLFrameSetElement, HTMLElement);
HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLFrameSetElement() override;
private:
HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName);
virtual void parse_attribute(FlyString const&, String const&) override;
private:
@ -32,3 +34,5 @@ private:
};
}
WRAPPER_HACK(HTMLFrameSetElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLHRElementPrototype.h>
#include <LibWeb/HTML/HTMLHRElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLHRElement::HTMLHRElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLHRElementPrototype>("HTMLHRElement"));
}
HTMLHRElement::~HTMLHRElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLHRElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLHRElementWrapper;
WEB_PLATFORM_OBJECT(HTMLHRElement, HTMLElement);
HTMLHRElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLHRElement() override;
private:
HTMLHRElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLHRElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLHeadElementPrototype.h>
#include <LibWeb/HTML/HTMLHeadElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLHeadElement::HTMLHeadElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLHeadElementPrototype>("HTMLHeadElement"));
}
HTMLHeadElement::~HTMLHeadElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLHeadElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLHeadElementWrapper;
WEB_PLATFORM_OBJECT(HTMLHeadElement, HTMLElement);
HTMLHeadElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLHeadElement() override;
private:
HTMLHeadElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLHeadElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLHeadingElementPrototype.h>
#include <LibWeb/HTML/HTMLHeadingElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLHeadingElementPrototype>("HTMLHeadingElement"));
}
HTMLHeadingElement::~HTMLHeadingElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLHeadingElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLHeadingElementWrapper;
WEB_PLATFORM_OBJECT(HTMLHeadingElement, HTMLElement);
HTMLHeadingElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLHeadingElement() override;
private:
HTMLHeadingElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLHeadingElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLHtmlElementPrototype.h>
#include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLHtmlElementPrototype>("HTMLHtmlElement"));
}
HTMLHtmlElement::~HTMLHtmlElement() = default;

View file

@ -11,15 +11,16 @@
namespace Web::HTML {
class HTMLHtmlElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLHtmlElementWrapper;
WEB_PLATFORM_OBJECT(HTMLHtmlElement, HTMLElement);
HTMLHtmlElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLHtmlElement() override;
bool should_use_body_background_properties() const;
private:
HTMLHtmlElement(DOM::Document&, DOM::QualifiedName);
virtual bool is_html_html_element() const override { return true; }
};
@ -29,3 +30,5 @@ namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLHtmlElement>() const { return is_html_html_element(); }
}
WRAPPER_HACK(HTMLHtmlElement, Web::HTML)

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLIFrameElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/HTML/BrowsingContext.h>
@ -16,6 +17,7 @@ namespace Web::HTML {
HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: BrowsingContextContainer(document, move(qualified_name))
{
set_prototype(&document.window().ensure_web_prototype<Bindings::HTMLIFrameElementPrototype>("HTMLIFrameElement"));
}
HTMLIFrameElement::~HTMLIFrameElement() = default;
@ -92,7 +94,7 @@ void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element)
// FIXME: 4. Set childDocument's iframe load in progress flag.
// 5. Fire an event named load at element.
element.dispatch_event(*DOM::Event::create(element.document().preferred_window_object(), HTML::EventNames::load));
element.dispatch_event(*DOM::Event::create(element.document().window(), HTML::EventNames::load));
// FIXME: 6. Unset childDocument's iframe load in progress flag.
}

View file

@ -11,15 +11,16 @@
namespace Web::HTML {
class HTMLIFrameElement final : public BrowsingContextContainer {
public:
using WrapperType = Bindings::HTMLIFrameElementWrapper;
WEB_PLATFORM_OBJECT(HTMLIFrameElement, BrowsingContextContainer);
HTMLIFrameElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLIFrameElement() override;
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
private:
HTMLIFrameElement(DOM::Document&, DOM::QualifiedName);
virtual void inserted() override;
virtual void removed_from(Node*) override;
virtual void parse_attribute(FlyString const& name, String const& value) override;
@ -30,3 +31,5 @@ private:
void run_iframe_load_event_steps(HTML::HTMLIFrameElement&);
}
WRAPPER_HACK(HTMLIFrameElement, Web::HTML)

View file

@ -5,6 +5,7 @@
*/
#include <LibGfx/Bitmap.h>
#include <LibWeb/Bindings/HTMLImageElementPrototype.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/DOM/Document.h>
@ -22,11 +23,13 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q
: HTMLElement(document, move(qualified_name))
, m_image_loader(*this)
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLImageElementPrototype>("HTMLImageElement"));
m_image_loader.on_load = [this] {
set_needs_style_update(true);
this->document().set_needs_layout();
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
dispatch_event(*DOM::Event::create(this->document().preferred_window_object(), EventNames::load));
dispatch_event(*DOM::Event::create(this->document().window(), EventNames::load));
});
};
@ -35,7 +38,7 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q
set_needs_style_update(true);
this->document().set_needs_layout();
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
dispatch_event(*DOM::Event::create(this->document().preferred_window_object(), EventNames::error));
dispatch_event(*DOM::Event::create(this->document().window(), EventNames::error));
});
};

View file

@ -18,12 +18,10 @@ namespace Web::HTML {
class HTMLImageElement final
: public HTMLElement
, public FormAssociatedElement {
WEB_PLATFORM_OBJECT(HTMLImageElement, HTMLElement);
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLImageElement)
public:
using WrapperType = Bindings::HTMLImageElementWrapper;
HTMLImageElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLImageElement() override;
virtual void parse_attribute(FlyString const& name, String const& value) override;
@ -43,6 +41,8 @@ public:
unsigned natural_height() const;
private:
HTMLImageElement(DOM::Document&, DOM::QualifiedName);
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
void animate();
@ -53,3 +53,5 @@ private:
};
}
WRAPPER_HACK(HTMLImageElement, Web::HTML)

View file

@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLInputElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/ShadowRoot.h>
@ -24,6 +25,8 @@ HTMLInputElement::HTMLInputElement(DOM::Document& document, DOM::QualifiedName q
: HTMLElement(document, move(qualified_name))
, m_value(String::empty())
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLInputElementPrototype>("HTMLInputElement"));
activation_behavior = [this](auto&) {
// The activation behavior for input elements are these steps:
@ -36,6 +39,13 @@ HTMLInputElement::HTMLInputElement(DOM::Document& document, DOM::QualifiedName q
HTMLInputElement::~HTMLInputElement() = default;
void HTMLInputElement::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_text_node.ptr());
visitor.visit(m_legacy_pre_activation_behavior_checked_element_in_group.ptr());
}
RefPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
{
if (type_state() == TypeAttributeState::Hidden)
@ -90,17 +100,17 @@ void HTMLInputElement::run_input_activation_behavior()
return;
// 2. Fire an event named input at the element with the bubbles and composed attributes initialized to true.
auto input_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::input);
auto input_event = DOM::Event::create(document().window(), HTML::EventNames::input);
input_event->set_bubbles(true);
input_event->set_composed(true);
dispatch_event(*input_event);
// 3. Fire an event named change at the element with the bubbles attribute initialized to true.
auto change_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::change);
auto change_event = DOM::Event::create(document().window(), HTML::EventNames::change);
change_event->set_bubbles(true);
dispatch_event(*change_event);
} else if (type_state() == TypeAttributeState::SubmitButton) {
RefPtr<HTMLFormElement> form;
JS::GCPtr<HTMLFormElement> form;
// 1. If the element does not have a form owner, then return.
if (!(form = this->form()))
return;
@ -112,7 +122,7 @@ void HTMLInputElement::run_input_activation_behavior()
// 3. Submit the form owner from the element.
form->submit_form(this);
} else {
dispatch_event(*DOM::Event::create(document().preferred_window_object(), EventNames::change));
dispatch_event(*DOM::Event::create(document().window(), EventNames::change));
}
}
@ -125,13 +135,13 @@ void HTMLInputElement::did_edit_text_node(Badge<BrowsingContext>)
// NOTE: This is a bit ad-hoc, but basically implements part of "4.10.5.5 Common event behaviors"
// https://html.spec.whatwg.org/multipage/input.html#common-input-element-events
queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
auto input_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::input);
auto input_event = DOM::Event::create(document().window(), HTML::EventNames::input);
input_event->set_bubbles(true);
input_event->set_composed(true);
dispatch_event(*input_event);
// FIXME: This should only fire when the input is "committed", whatever that means.
auto change_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::change);
auto change_event = DOM::Event::create(document().window(), HTML::EventNames::change);
change_event->set_bubbles(true);
dispatch_event(*change_event);
});
@ -184,13 +194,13 @@ void HTMLInputElement::create_shadow_tree_if_needed()
break;
}
auto shadow_root = adopt_ref(*new DOM::ShadowRoot(document(), *this));
auto* shadow_root = heap().allocate<DOM::ShadowRoot>(realm(), document(), *this);
auto initial_value = m_value;
if (initial_value.is_null())
initial_value = String::empty();
auto element = document().create_element(HTML::TagNames::div).release_value();
element->set_attribute(HTML::AttributeNames::style, "white-space: pre; padding-top: 1px; padding-bottom: 1px; padding-left: 2px; padding-right: 2px");
m_text_node = adopt_ref(*new DOM::Text(document(), initial_value));
m_text_node = heap().allocate<DOM::Text>(realm(), document(), initial_value);
m_text_node->set_always_editable(true);
m_text_node->set_owner_input_element({}, *this);
element->append_child(*m_text_node);
@ -348,7 +358,7 @@ void HTMLInputElement::legacy_pre_activation_behavior()
document().for_each_in_inclusive_subtree_of_type<HTML::HTMLInputElement>([&](auto& element) {
if (element.checked() && element.name() == name) {
m_legacy_pre_activation_behavior_checked_element_in_group = element;
m_legacy_pre_activation_behavior_checked_element_in_group = &element;
return IterationDecision::Break;
}
return IterationDecision::Continue;

View file

@ -40,12 +40,10 @@ namespace Web::HTML {
class HTMLInputElement final
: public HTMLElement
, public FormAssociatedElement {
WEB_PLATFORM_OBJECT(HTMLInputElement, HTMLElement);
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLInputElement)
public:
using WrapperType = Bindings::HTMLInputElementWrapper;
HTMLInputElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLInputElement() override;
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
@ -106,12 +104,16 @@ public:
virtual bool is_labelable() const override { return type_state() != TypeAttributeState::Hidden; }
private:
HTMLInputElement(DOM::Document&, DOM::QualifiedName);
// ^DOM::EventTarget
virtual void did_receive_focus() override;
virtual void legacy_pre_activation_behavior() override;
virtual void legacy_cancelled_activation_behavior() override;
virtual void legacy_cancelled_activation_behavior_was_not_called() override;
virtual void visit_edges(Cell::Visitor&) override;
static TypeAttributeState parse_type_attribute(StringView);
void create_shadow_tree_if_needed();
void run_input_activation_behavior();
@ -120,7 +122,7 @@ private:
// https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm
String value_sanitization_algorithm(String) const;
RefPtr<DOM::Text> m_text_node;
JS::GCPtr<DOM::Text> m_text_node;
bool m_checked { false };
// https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag
@ -131,10 +133,12 @@ private:
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:legacy-pre-activation-behavior
bool m_before_legacy_pre_activation_behavior_checked { false };
RefPtr<HTMLInputElement> m_legacy_pre_activation_behavior_checked_element_in_group;
JS::GCPtr<HTMLInputElement> m_legacy_pre_activation_behavior_checked_element_in_group;
TypeAttributeState m_type { TypeAttributeState::Text };
String m_value;
};
}
WRAPPER_HACK(HTMLInputElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLLIElementPrototype.h>
#include <LibWeb/HTML/HTMLLIElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLLIElement::HTMLLIElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLLIElementPrototype>("HTMLLIElement"));
}
HTMLLIElement::~HTMLLIElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLLIElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLLIElementWrapper;
WEB_PLATFORM_OBJECT(HTMLLIElement, HTMLElement);
HTMLLIElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLLIElement() override;
private:
HTMLLIElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLLIElement, Web::HTML)

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLLabelElementPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLLabelElement.h>
#include <LibWeb/Layout/Label.h>
@ -13,6 +14,7 @@ namespace Web::HTML {
HTMLLabelElement::HTMLLabelElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLLabelElementPrototype>("HTMLLabelElement"));
}
HTMLLabelElement::~HTMLLabelElement() = default;

View file

@ -11,15 +11,19 @@
namespace Web::HTML {
class HTMLLabelElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLLabelElementWrapper;
WEB_PLATFORM_OBJECT(HTMLLabelElement, HTMLElement);
HTMLLabelElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLLabelElement() override;
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
String for_() const { return attribute(HTML::AttributeNames::for_); }
private:
HTMLLabelElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLLabelElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLLegendElementPrototype.h>
#include <LibWeb/HTML/HTMLLegendElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLLegendElement::HTMLLegendElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLLegendElementPrototype>("HTMLLegendElement"));
}
HTMLLegendElement::~HTMLLegendElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLLegendElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLLegendElementWrapper;
WEB_PLATFORM_OBJECT(HTMLLegendElement, HTMLElement);
HTMLLegendElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLLegendElement() override;
private:
HTMLLegendElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLLegendElement, Web::HTML)

View file

@ -9,6 +9,7 @@
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <AK/URL.h>
#include <LibWeb/Bindings/HTMLLinkElementPrototype.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLLinkElement.h>
@ -21,6 +22,7 @@ namespace Web::HTML {
HTMLLinkElement::HTMLLinkElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLLinkElementPrototype>("HTMLLinkElement"));
}
HTMLLinkElement::~HTMLLinkElement() = default;

View file

@ -16,10 +16,9 @@ namespace Web::HTML {
class HTMLLinkElement final
: public HTMLElement
, public ResourceClient {
public:
using WrapperType = Bindings::HTMLLinkElementWrapper;
WEB_PLATFORM_OBJECT(HTMLLinkElement, HTMLElement);
HTMLLinkElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLLinkElement() override;
virtual void inserted() override;
@ -32,6 +31,8 @@ public:
bool load_favicon_and_use_if_window_is_active();
private:
HTMLLinkElement(DOM::Document&, DOM::QualifiedName);
void parse_attribute(FlyString const&, String const&) override;
// ^ResourceClient
@ -59,3 +60,5 @@ private:
};
}
WRAPPER_HACK(HTMLLinkElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLMapElementPrototype.h>
#include <LibWeb/HTML/HTMLMapElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLMapElement::HTMLMapElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLMapElementPrototype>("HTMLMapElement"));
}
HTMLMapElement::~HTMLMapElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLMapElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLMapElementWrapper;
WEB_PLATFORM_OBJECT(HTMLMapElement, HTMLElement);
HTMLMapElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLMapElement() override;
private:
HTMLMapElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLMapElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLMarqueeElementPrototype.h>
#include <LibWeb/HTML/HTMLMarqueeElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLMarqueeElement::HTMLMarqueeElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLMarqueeElementPrototype>("HTMLMarqueeElement"));
}
HTMLMarqueeElement::~HTMLMarqueeElement() = default;

View file

@ -12,14 +12,16 @@ namespace Web::HTML {
// NOTE: This element is marked as obsolete, but is still listed as required by the specification.
class HTMLMarqueeElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLMarqueeElementWrapper;
WEB_PLATFORM_OBJECT(HTMLMarqueeElement, HTMLElement);
HTMLMarqueeElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLMarqueeElement() override;
private:
HTMLMarqueeElement(DOM::Document&, DOM::QualifiedName);
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
};
}
WRAPPER_HACK(HTMLMarqueeElement, Web::HTML)

View file

@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLMediaElementWrapper.h>
#include <LibWeb/Bindings/HTMLMediaElementPrototype.h>
#include <LibWeb/HTML/HTMLMediaElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLMediaElement::HTMLMediaElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLMediaElementPrototype>("HTMLMediaElement"));
}
HTMLMediaElement::~HTMLMediaElement() = default;

View file

@ -11,13 +11,17 @@
namespace Web::HTML {
class HTMLMediaElement : public HTMLElement {
public:
using WrapperType = Bindings::HTMLMediaElementWrapper;
WEB_PLATFORM_OBJECT(HTMLMediaElement, HTMLElement);
HTMLMediaElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLMediaElement() override;
Bindings::CanPlayTypeResult can_play_type(String const& type) const;
protected:
HTMLMediaElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLMediaElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLMenuElementPrototype.h>
#include <LibWeb/HTML/HTMLMenuElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLMenuElement::HTMLMenuElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLMenuElementPrototype>("HTMLMenuElement"));
}
HTMLMenuElement::~HTMLMenuElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLMenuElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLMenuElementWrapper;
WEB_PLATFORM_OBJECT(HTMLMenuElement, HTMLElement);
HTMLMenuElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLMenuElement() override;
private:
HTMLMenuElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLMenuElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLMetaElementPrototype.h>
#include <LibWeb/HTML/HTMLMetaElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLMetaElement::HTMLMetaElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLMetaElementPrototype>("HTMLMetaElement"));
}
HTMLMetaElement::~HTMLMetaElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLMetaElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLMetaElementWrapper;
WEB_PLATFORM_OBJECT(HTMLMetaElement, HTMLElement);
HTMLMetaElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLMetaElement() override;
private:
HTMLMetaElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLMetaElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLMeterElementPrototype.h>
#include <LibWeb/HTML/HTMLMeterElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLMeterElement::HTMLMeterElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLMeterElementPrototype>("HTMLMeterElement"));
}
HTMLMeterElement::~HTMLMeterElement() = default;

View file

@ -12,15 +12,19 @@
namespace Web::HTML {
class HTMLMeterElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLMeterElementWrapper;
WEB_PLATFORM_OBJECT(HTMLMeterElement, HTMLElement);
HTMLMeterElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLMeterElement() override;
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
private:
HTMLMeterElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLMeterElement, Web::HTML)

View file

@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/HTMLModElementPrototype.h>
#include <LibWeb/HTML/HTMLModElement.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {
HTMLModElement::HTMLModElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
set_prototype(&window().ensure_web_prototype<Bindings::HTMLModElementPrototype>("HTMLModElement"));
}
HTMLModElement::~HTMLModElement() = default;

View file

@ -11,11 +11,15 @@
namespace Web::HTML {
class HTMLModElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLModElementWrapper;
WEB_PLATFORM_OBJECT(HTMLModElement, HTMLElement);
HTMLModElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLModElement() override;
private:
HTMLModElement(DOM::Document&, DOM::QualifiedName);
};
}
WRAPPER_HACK(HTMLModElement, Web::HTML)

Some files were not shown because too many files have changed in this diff Show more