mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibWeb: Add HTMLElement wrapper
Expose the "title" attribute just to expose something. :^)
This commit is contained in:
parent
244b243d22
commit
1914f52371
10 changed files with 36 additions and 14 deletions
|
@ -39,7 +39,7 @@ namespace Web {
|
||||||
namespace Bindings {
|
namespace Bindings {
|
||||||
|
|
||||||
HTMLCanvasElementWrapper::HTMLCanvasElementWrapper(JS::GlobalObject& global_object, HTMLCanvasElement& element)
|
HTMLCanvasElementWrapper::HTMLCanvasElementWrapper(JS::GlobalObject& global_object, HTMLCanvasElement& element)
|
||||||
: ElementWrapper(global_object, element)
|
: HTMLElementWrapper(global_object, element)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/Bindings/ElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLElementWrapper.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
namespace Bindings {
|
namespace Bindings {
|
||||||
|
|
||||||
class HTMLCanvasElementWrapper : public ElementWrapper {
|
class HTMLCanvasElementWrapper : public HTMLElementWrapper {
|
||||||
public:
|
public:
|
||||||
HTMLCanvasElementWrapper(JS::GlobalObject&, HTMLCanvasElement&);
|
HTMLCanvasElementWrapper(JS::GlobalObject&, HTMLCanvasElement&);
|
||||||
virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;
|
virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Web {
|
||||||
namespace Bindings {
|
namespace Bindings {
|
||||||
|
|
||||||
HTMLImageElementWrapper::HTMLImageElementWrapper(JS::GlobalObject& global_object, HTMLImageElement& element)
|
HTMLImageElementWrapper::HTMLImageElementWrapper(JS::GlobalObject& global_object, HTMLImageElement& element)
|
||||||
: ElementWrapper(global_object, element)
|
: HTMLElementWrapper(global_object, element)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/Bindings/ElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLElementWrapper.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
namespace Bindings {
|
namespace Bindings {
|
||||||
|
|
||||||
class HTMLImageElementWrapper : public ElementWrapper {
|
class HTMLImageElementWrapper : public HTMLElementWrapper {
|
||||||
public:
|
public:
|
||||||
HTMLImageElementWrapper(JS::GlobalObject&, HTMLImageElement&);
|
HTMLImageElementWrapper(JS::GlobalObject&, HTMLImageElement&);
|
||||||
virtual ~HTMLImageElementWrapper() override;
|
virtual ~HTMLImageElementWrapper() override;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <LibWeb/Bindings/DocumentWrapper.h>
|
#include <LibWeb/Bindings/DocumentWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLCanvasElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLCanvasElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLImageElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLImageElementWrapper.h>
|
||||||
|
#include <LibWeb/Bindings/HTMLElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/NodeWrapper.h>
|
#include <LibWeb/Bindings/NodeWrapper.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/HTMLCanvasElement.h>
|
#include <LibWeb/DOM/HTMLCanvasElement.h>
|
||||||
|
@ -45,6 +46,8 @@ NodeWrapper* wrap(JS::Heap& heap, Node& node)
|
||||||
return static_cast<NodeWrapper*>(wrap_impl(heap, to<HTMLCanvasElement>(node)));
|
return static_cast<NodeWrapper*>(wrap_impl(heap, to<HTMLCanvasElement>(node)));
|
||||||
if (is<HTMLImageElement>(node))
|
if (is<HTMLImageElement>(node))
|
||||||
return static_cast<NodeWrapper*>(wrap_impl(heap, to<HTMLImageElement>(node)));
|
return static_cast<NodeWrapper*>(wrap_impl(heap, to<HTMLImageElement>(node)));
|
||||||
|
if (is<HTMLElement>(node))
|
||||||
|
return static_cast<NodeWrapper*>(wrap_impl(heap, to<HTMLElement>(node)));
|
||||||
if (is<Element>(node))
|
if (is<Element>(node))
|
||||||
return static_cast<NodeWrapper*>(wrap_impl(heap, to<Element>(node)));
|
return static_cast<NodeWrapper*>(wrap_impl(heap, to<Element>(node)));
|
||||||
return static_cast<NodeWrapper*>(wrap_impl(heap, node));
|
return static_cast<NodeWrapper*>(wrap_impl(heap, node));
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
virtual bool is_node_wrapper() const { return false; }
|
virtual bool is_node_wrapper() const { return false; }
|
||||||
virtual bool is_document_wrapper() const { return false; }
|
virtual bool is_document_wrapper() const { return false; }
|
||||||
virtual bool is_element_wrapper() const { return false; }
|
virtual bool is_element_wrapper() const { return false; }
|
||||||
|
virtual bool is_htmlelement_wrapper() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Wrapper(Object& prototype)
|
explicit Wrapper(Object& prototype)
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
Bindings/CanvasRenderingContext2DWrapper.cpp
|
Bindings/CanvasRenderingContext2DWrapper.cpp
|
||||||
Bindings/DocumentWrapper.cpp
|
|
||||||
Bindings/DocumentWrapper.h
|
|
||||||
Bindings/ElementWrapper.cpp
|
|
||||||
Bindings/ElementWrapper.h
|
|
||||||
Bindings/EventListenerWrapper.cpp
|
Bindings/EventListenerWrapper.cpp
|
||||||
Bindings/EventTargetWrapper.cpp
|
|
||||||
Bindings/EventTargetWrapper.h
|
|
||||||
Bindings/EventWrapper.cpp
|
Bindings/EventWrapper.cpp
|
||||||
Bindings/HTMLCanvasElementWrapper.cpp
|
Bindings/HTMLCanvasElementWrapper.cpp
|
||||||
Bindings/HTMLImageElementWrapper.cpp
|
Bindings/HTMLImageElementWrapper.cpp
|
||||||
|
@ -14,8 +8,6 @@ set(SOURCES
|
||||||
Bindings/LocationObject.cpp
|
Bindings/LocationObject.cpp
|
||||||
Bindings/MouseEventWrapper.cpp
|
Bindings/MouseEventWrapper.cpp
|
||||||
Bindings/NavigatorObject.cpp
|
Bindings/NavigatorObject.cpp
|
||||||
Bindings/NodeWrapper.cpp
|
|
||||||
Bindings/NodeWrapper.h
|
|
||||||
Bindings/NodeWrapperFactory.cpp
|
Bindings/NodeWrapperFactory.cpp
|
||||||
Bindings/WindowObject.cpp
|
Bindings/WindowObject.cpp
|
||||||
Bindings/Wrappable.cpp
|
Bindings/Wrappable.cpp
|
||||||
|
@ -128,7 +120,19 @@ set(GENERATED_SOURCES
|
||||||
../../Services/ProtocolServer/ProtocolServerEndpoint.h
|
../../Services/ProtocolServer/ProtocolServerEndpoint.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY wrapper_sources)
|
||||||
|
function(add_wrapper_sources)
|
||||||
|
get_property(tmp GLOBAL PROPERTY wrapper_sources)
|
||||||
|
foreach(arg ${ARGV})
|
||||||
|
set(tmp ${tmp}
|
||||||
|
${arg}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
set_property(GLOBAL PROPERTY wrapper_sources "${tmp}")
|
||||||
|
endfunction(add_wrapper_sources)
|
||||||
|
|
||||||
function(libweb_js_wrapper class)
|
function(libweb_js_wrapper class)
|
||||||
|
add_wrapper_sources(Bindings/${class}Wrapper.cpp Bindings/${class}Wrapper.h)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT Bindings/${class}Wrapper.h
|
OUTPUT Bindings/${class}Wrapper.h
|
||||||
COMMAND /bin/mkdir -p Bindings
|
COMMAND /bin/mkdir -p Bindings
|
||||||
|
@ -146,12 +150,17 @@ function(libweb_js_wrapper class)
|
||||||
MAIN_DEPENDENCY DOM/${class}.idl
|
MAIN_DEPENDENCY DOM/${class}.idl
|
||||||
)
|
)
|
||||||
add_custom_target(generate_${class}Wrapper.h DEPENDS Bindings/${class}Wrapper.h)
|
add_custom_target(generate_${class}Wrapper.h DEPENDS Bindings/${class}Wrapper.h)
|
||||||
|
add_custom_target(generate_${class}Wrapper.cpp DEPENDS Bindings/${class}Wrapper.cpp)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
libweb_js_wrapper(EventTarget)
|
libweb_js_wrapper(EventTarget)
|
||||||
libweb_js_wrapper(Node)
|
libweb_js_wrapper(Node)
|
||||||
libweb_js_wrapper(Document)
|
libweb_js_wrapper(Document)
|
||||||
libweb_js_wrapper(Element)
|
libweb_js_wrapper(Element)
|
||||||
|
libweb_js_wrapper(HTMLElement)
|
||||||
|
|
||||||
|
get_property(WRAPPER_SOURCES GLOBAL PROPERTY wrapper_sources)
|
||||||
|
set(SOURCES ${SOURCES} ${WRAPPER_SOURCES})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT CSS/PropertyID.h
|
OUTPUT CSS/PropertyID.h
|
||||||
|
|
|
@ -32,10 +32,13 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLElement : public Element {
|
class HTMLElement : public Element {
|
||||||
public:
|
public:
|
||||||
|
using WrapperType = Bindings::HTMLElementWrapper;
|
||||||
|
|
||||||
HTMLElement(Document&, const FlyString& tag_name);
|
HTMLElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLElement() override;
|
virtual ~HTMLElement() override;
|
||||||
|
|
||||||
String title() const { return attribute(HTML::AttributeNames::title); }
|
String title() const { return attribute(HTML::AttributeNames::title); }
|
||||||
|
void set_title(const String& value) { set_attribute(HTML::AttributeNames::title, value); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool is_html_element() const final { return true; }
|
virtual bool is_html_element() const final { return true; }
|
||||||
|
|
5
Libraries/LibWeb/DOM/HTMLElement.idl
Normal file
5
Libraries/LibWeb/DOM/HTMLElement.idl
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
interface HTMLElement : Element {
|
||||||
|
|
||||||
|
attribute DOMString title;
|
||||||
|
|
||||||
|
}
|
|
@ -81,6 +81,7 @@ class EventWrapper;
|
||||||
class EventListenerWrapper;
|
class EventListenerWrapper;
|
||||||
class EventTargetWrapper;
|
class EventTargetWrapper;
|
||||||
class HTMLCanvasElementWrapper;
|
class HTMLCanvasElementWrapper;
|
||||||
|
class HTMLElementWrapper;
|
||||||
class HTMLImageElementWrapper;
|
class HTMLImageElementWrapper;
|
||||||
class ImageDataWrapper;
|
class ImageDataWrapper;
|
||||||
class LocationObject;
|
class LocationObject;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue