mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:57:35 +00:00
LibWeb: Add CharacterData and Text IDL interfaces
This commit is contained in:
parent
354f9aafd5
commit
73645e11c4
7 changed files with 36 additions and 6 deletions
|
@ -24,17 +24,18 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibWeb/Bindings/DocumentWrapper.h>
|
#include <LibWeb/Bindings/CharacterDataWrapper.h>
|
||||||
#include <LibWeb/Bindings/DocumentTypeWrapper.h>
|
#include <LibWeb/Bindings/DocumentTypeWrapper.h>
|
||||||
|
#include <LibWeb/Bindings/DocumentWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLAnchorElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLAnchorElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLBodyElementWrapper.h>
|
|
||||||
#include <LibWeb/Bindings/HTMLBRElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLBRElementWrapper.h>
|
||||||
|
#include <LibWeb/Bindings/HTMLBodyElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLCanvasElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLCanvasElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLFormElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLFormElementWrapper.h>
|
||||||
|
#include <LibWeb/Bindings/HTMLHRElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLHeadElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLHeadElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLHeadingElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLHeadingElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLHRElementWrapper.h>
|
|
||||||
#include <LibWeb/Bindings/HTMLHtmlElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLHtmlElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLIFrameElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLIFrameElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLImageElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLImageElementWrapper.h>
|
||||||
|
@ -48,15 +49,17 @@
|
||||||
#include <LibWeb/Bindings/HTMLTableRowElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLTableRowElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/HTMLTitleElementWrapper.h>
|
#include <LibWeb/Bindings/HTMLTitleElementWrapper.h>
|
||||||
#include <LibWeb/Bindings/NodeWrapper.h>
|
#include <LibWeb/Bindings/NodeWrapper.h>
|
||||||
|
#include <LibWeb/Bindings/TextWrapper.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
|
#include <LibWeb/DOM/Node.h>
|
||||||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||||
#include <LibWeb/HTML/HTMLBodyElement.h>
|
|
||||||
#include <LibWeb/HTML/HTMLBRElement.h>
|
#include <LibWeb/HTML/HTMLBRElement.h>
|
||||||
|
#include <LibWeb/HTML/HTMLBodyElement.h>
|
||||||
#include <LibWeb/HTML/HTMLCanvasElement.h>
|
#include <LibWeb/HTML/HTMLCanvasElement.h>
|
||||||
#include <LibWeb/HTML/HTMLFormElement.h>
|
#include <LibWeb/HTML/HTMLFormElement.h>
|
||||||
|
#include <LibWeb/HTML/HTMLHRElement.h>
|
||||||
#include <LibWeb/HTML/HTMLHeadElement.h>
|
#include <LibWeb/HTML/HTMLHeadElement.h>
|
||||||
#include <LibWeb/HTML/HTMLHeadingElement.h>
|
#include <LibWeb/HTML/HTMLHeadingElement.h>
|
||||||
#include <LibWeb/HTML/HTMLHRElement.h>
|
|
||||||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||||
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
||||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||||
|
@ -69,7 +72,6 @@
|
||||||
#include <LibWeb/HTML/HTMLTableElement.h>
|
#include <LibWeb/HTML/HTMLTableElement.h>
|
||||||
#include <LibWeb/HTML/HTMLTableRowElement.h>
|
#include <LibWeb/HTML/HTMLTableRowElement.h>
|
||||||
#include <LibWeb/HTML/HTMLTitleElement.h>
|
#include <LibWeb/HTML/HTMLTitleElement.h>
|
||||||
#include <LibWeb/DOM/Node.h>
|
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
namespace Bindings {
|
namespace Bindings {
|
||||||
|
@ -124,6 +126,10 @@ NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node)
|
||||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLElement>(node)));
|
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLElement>(node)));
|
||||||
if (is<DOM::Element>(node))
|
if (is<DOM::Element>(node))
|
||||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::Element>(node)));
|
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::Element>(node)));
|
||||||
|
if (is<DOM::Text>(node))
|
||||||
|
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::Text>(node)));
|
||||||
|
if (is<DOM::CharacterData>(node))
|
||||||
|
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::CharacterData>(node)));
|
||||||
return static_cast<NodeWrapper*>(wrap_impl(global_object, node));
|
return static_cast<NodeWrapper*>(wrap_impl(global_object, node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ set(SOURCES
|
||||||
CSS/StyleValue.cpp
|
CSS/StyleValue.cpp
|
||||||
DOM/AttributeNames.cpp
|
DOM/AttributeNames.cpp
|
||||||
DOM/CharacterData.cpp
|
DOM/CharacterData.cpp
|
||||||
|
DOM/CharacterData.idl
|
||||||
DOM/Comment.cpp
|
DOM/Comment.cpp
|
||||||
DOM/Document.cpp
|
DOM/Document.cpp
|
||||||
DOM/DocumentType.cpp
|
DOM/DocumentType.cpp
|
||||||
|
@ -37,6 +38,7 @@ set(SOURCES
|
||||||
DOM/Position.cpp
|
DOM/Position.cpp
|
||||||
DOM/TagNames.cpp
|
DOM/TagNames.cpp
|
||||||
DOM/Text.cpp
|
DOM/Text.cpp
|
||||||
|
DOM/Text.idl
|
||||||
DOM/Timer.cpp
|
DOM/Timer.cpp
|
||||||
DOM/Window.cpp
|
DOM/Window.cpp
|
||||||
DOM/XMLHttpRequest.cpp
|
DOM/XMLHttpRequest.cpp
|
||||||
|
@ -162,12 +164,14 @@ function(libweb_js_wrapper class)
|
||||||
add_custom_target(generate_${basename}Wrapper.cpp DEPENDS Bindings/${class}Wrapper.cpp)
|
add_custom_target(generate_${basename}Wrapper.cpp DEPENDS Bindings/${class}Wrapper.cpp)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
libweb_js_wrapper(DOM/CharacterData)
|
||||||
libweb_js_wrapper(DOM/Document)
|
libweb_js_wrapper(DOM/Document)
|
||||||
libweb_js_wrapper(DOM/DocumentType)
|
libweb_js_wrapper(DOM/DocumentType)
|
||||||
libweb_js_wrapper(DOM/Element)
|
libweb_js_wrapper(DOM/Element)
|
||||||
libweb_js_wrapper(DOM/Event)
|
libweb_js_wrapper(DOM/Event)
|
||||||
libweb_js_wrapper(DOM/EventTarget)
|
libweb_js_wrapper(DOM/EventTarget)
|
||||||
libweb_js_wrapper(DOM/Node)
|
libweb_js_wrapper(DOM/Node)
|
||||||
|
libweb_js_wrapper(DOM/Text)
|
||||||
libweb_js_wrapper(HTML/CanvasRenderingContext2D)
|
libweb_js_wrapper(HTML/CanvasRenderingContext2D)
|
||||||
libweb_js_wrapper(HTML/HTMLAnchorElement)
|
libweb_js_wrapper(HTML/HTMLAnchorElement)
|
||||||
libweb_js_wrapper(HTML/HTMLBodyElement)
|
libweb_js_wrapper(HTML/HTMLBodyElement)
|
||||||
|
|
|
@ -36,11 +36,15 @@ class CharacterData
|
||||||
: public Node
|
: public Node
|
||||||
, public NonDocumentTypeChildNode<CharacterData> {
|
, public NonDocumentTypeChildNode<CharacterData> {
|
||||||
public:
|
public:
|
||||||
|
using WrapperType = Bindings::CharacterDataWrapper;
|
||||||
|
|
||||||
virtual ~CharacterData() override;
|
virtual ~CharacterData() override;
|
||||||
|
|
||||||
const String& data() const { return m_data; }
|
const String& data() const { return m_data; }
|
||||||
void set_data(const String& data) { m_data = data; }
|
void set_data(const String& data) { m_data = data; }
|
||||||
|
|
||||||
|
unsigned length() const { return m_data.length(); }
|
||||||
|
|
||||||
virtual String text_content() const override { return m_data; }
|
virtual String text_content() const override { return m_data; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
9
Libraries/LibWeb/DOM/CharacterData.idl
Normal file
9
Libraries/LibWeb/DOM/CharacterData.idl
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
interface CharacterData : Node {
|
||||||
|
|
||||||
|
attribute DOMString data;
|
||||||
|
readonly attribute unsigned long length;
|
||||||
|
|
||||||
|
readonly attribute Element? nextElementSibling;
|
||||||
|
readonly attribute Element? previousElementSibling;
|
||||||
|
|
||||||
|
}
|
|
@ -34,6 +34,8 @@ namespace Web::DOM {
|
||||||
|
|
||||||
class Text final : public CharacterData {
|
class Text final : public CharacterData {
|
||||||
public:
|
public:
|
||||||
|
using WrapperType = Bindings::TextWrapper;
|
||||||
|
|
||||||
explicit Text(Document&, const String&);
|
explicit Text(Document&, const String&);
|
||||||
virtual ~Text() override;
|
virtual ~Text() override;
|
||||||
|
|
||||||
|
|
3
Libraries/LibWeb/DOM/Text.idl
Normal file
3
Libraries/LibWeb/DOM/Text.idl
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
interface Text : CharacterData {
|
||||||
|
|
||||||
|
}
|
|
@ -91,6 +91,7 @@ class XMLHttpRequest;
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
class CanvasRenderingContext2DWrapper;
|
class CanvasRenderingContext2DWrapper;
|
||||||
|
class CharacterDataWrapper;
|
||||||
class DocumentTypeWrapper;
|
class DocumentTypeWrapper;
|
||||||
class DocumentWrapper;
|
class DocumentWrapper;
|
||||||
class ElementWrapper;
|
class ElementWrapper;
|
||||||
|
@ -122,6 +123,7 @@ class ImageDataWrapper;
|
||||||
class LocationObject;
|
class LocationObject;
|
||||||
class MouseEventWrapper;
|
class MouseEventWrapper;
|
||||||
class NodeWrapper;
|
class NodeWrapper;
|
||||||
|
class TextWrapper;
|
||||||
class UIEventWrapper;
|
class UIEventWrapper;
|
||||||
class WindowObject;
|
class WindowObject;
|
||||||
class Wrappable;
|
class Wrappable;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue