summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Bindings
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibWeb/Bindings')
-rw-r--r--Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp44
-rw-r--r--Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h42
-rw-r--r--Libraries/LibWeb/Bindings/DocumentWrapper.cpp8
-rw-r--r--Libraries/LibWeb/Bindings/DocumentWrapper.h6
-rw-r--r--Libraries/LibWeb/Bindings/ElementWrapper.cpp12
-rw-r--r--Libraries/LibWeb/Bindings/ElementWrapper.h12
-rw-r--r--Libraries/LibWeb/Bindings/EventTargetWrapper.cpp4
-rw-r--r--Libraries/LibWeb/Bindings/EventTargetWrapper.h2
-rw-r--r--Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp6
-rw-r--r--Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.h6
-rw-r--r--Libraries/LibWeb/Bindings/ImageDataWrapper.cpp6
-rw-r--r--Libraries/LibWeb/Bindings/ImageDataWrapper.h6
-rw-r--r--Libraries/LibWeb/Bindings/LocationObject.cpp36
-rw-r--r--Libraries/LibWeb/Bindings/LocationObject.h18
-rw-r--r--Libraries/LibWeb/Bindings/MouseEventWrapper.cpp4
-rw-r--r--Libraries/LibWeb/Bindings/MouseEventWrapper.h4
-rw-r--r--Libraries/LibWeb/Bindings/NavigatorObject.cpp2
-rw-r--r--Libraries/LibWeb/Bindings/NavigatorObject.h2
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.cpp17
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.h16
-rw-r--r--Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp8
-rw-r--r--Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h8
22 files changed, 135 insertions, 134 deletions
diff --git a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp
index b112afc222..eecd6b1b4f 100644
--- a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp
@@ -85,7 +85,7 @@ static CanvasRenderingContext2D* impl_from(JS::Interpreter& interpreter)
return &static_cast<CanvasRenderingContext2DWrapper*>(this_object)->impl();
}
-JS::Value CanvasRenderingContext2DWrapper::fill_rect(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::fill_rect)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -108,7 +108,7 @@ JS::Value CanvasRenderingContext2DWrapper::fill_rect(JS::Interpreter& interprete
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::stroke_rect(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::stroke_rect)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -131,7 +131,7 @@ JS::Value CanvasRenderingContext2DWrapper::stroke_rect(JS::Interpreter& interpre
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::draw_image(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::draw_image)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -154,7 +154,7 @@ JS::Value CanvasRenderingContext2DWrapper::draw_image(JS::Interpreter& interpret
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::scale(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::scale)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -172,7 +172,7 @@ JS::Value CanvasRenderingContext2DWrapper::scale(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::translate(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::translate)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -190,7 +190,7 @@ JS::Value CanvasRenderingContext2DWrapper::translate(JS::Interpreter& interprete
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::fill_style_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(CanvasRenderingContext2DWrapper::fill_style_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -198,7 +198,7 @@ JS::Value CanvasRenderingContext2DWrapper::fill_style_getter(JS::Interpreter& in
return JS::js_string(interpreter, impl->fill_style());
}
-void CanvasRenderingContext2DWrapper::fill_style_setter(JS::Interpreter& interpreter, JS::Value value)
+JS_DEFINE_NATIVE_SETTER(CanvasRenderingContext2DWrapper::fill_style_setter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -209,7 +209,7 @@ void CanvasRenderingContext2DWrapper::fill_style_setter(JS::Interpreter& interpr
impl->set_fill_style(string);
}
-JS::Value CanvasRenderingContext2DWrapper::stroke_style_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(CanvasRenderingContext2DWrapper::stroke_style_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -217,7 +217,7 @@ JS::Value CanvasRenderingContext2DWrapper::stroke_style_getter(JS::Interpreter&
return JS::js_string(interpreter, impl->stroke_style());
}
-void CanvasRenderingContext2DWrapper::stroke_style_setter(JS::Interpreter& interpreter, JS::Value value)
+JS_DEFINE_NATIVE_SETTER(CanvasRenderingContext2DWrapper::stroke_style_setter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -228,7 +228,7 @@ void CanvasRenderingContext2DWrapper::stroke_style_setter(JS::Interpreter& inter
impl->set_stroke_style(string);
}
-JS::Value CanvasRenderingContext2DWrapper::line_width_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(CanvasRenderingContext2DWrapper::line_width_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -236,7 +236,7 @@ JS::Value CanvasRenderingContext2DWrapper::line_width_getter(JS::Interpreter& in
return JS::Value(impl->line_width());
}
-void CanvasRenderingContext2DWrapper::line_width_setter(JS::Interpreter& interpreter, JS::Value value)
+JS_DEFINE_NATIVE_SETTER(CanvasRenderingContext2DWrapper::line_width_setter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -247,7 +247,7 @@ void CanvasRenderingContext2DWrapper::line_width_setter(JS::Interpreter& interpr
impl->set_line_width(line_width);
}
-JS::Value CanvasRenderingContext2DWrapper::begin_path(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::begin_path)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -256,7 +256,7 @@ JS::Value CanvasRenderingContext2DWrapper::begin_path(JS::Interpreter& interpret
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::close_path(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::close_path)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -265,7 +265,7 @@ JS::Value CanvasRenderingContext2DWrapper::close_path(JS::Interpreter& interpret
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::stroke(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::stroke)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -274,7 +274,7 @@ JS::Value CanvasRenderingContext2DWrapper::stroke(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::fill(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::fill)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -301,7 +301,7 @@ JS::Value CanvasRenderingContext2DWrapper::fill(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::move_to(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::move_to)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -316,7 +316,7 @@ JS::Value CanvasRenderingContext2DWrapper::move_to(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::line_to(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::line_to)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -331,7 +331,7 @@ JS::Value CanvasRenderingContext2DWrapper::line_to(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::quadratic_curve_to(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::quadratic_curve_to)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -352,7 +352,7 @@ JS::Value CanvasRenderingContext2DWrapper::quadratic_curve_to(JS::Interpreter& i
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::create_image_data(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::create_image_data)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -363,11 +363,11 @@ JS::Value CanvasRenderingContext2DWrapper::create_image_data(JS::Interpreter& in
auto height = interpreter.argument(1).to_i32(interpreter);
if (interpreter.exception())
return {};
- auto image_data = impl->create_image_data(interpreter.global_object(), width, height);
+ auto image_data = impl->create_image_data(global_object, width, height);
return wrap(interpreter.heap(), *image_data);
}
-JS::Value CanvasRenderingContext2DWrapper::put_image_data(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(CanvasRenderingContext2DWrapper::put_image_data)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -392,7 +392,7 @@ JS::Value CanvasRenderingContext2DWrapper::put_image_data(JS::Interpreter& inter
return JS::js_undefined();
}
-JS::Value CanvasRenderingContext2DWrapper::canvas_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(CanvasRenderingContext2DWrapper::canvas_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
diff --git a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h
index eed7cc1771..783ddf8627 100644
--- a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h
+++ b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h
@@ -42,31 +42,31 @@ public:
private:
virtual const char* class_name() const override { return "CanvasRenderingContext2DWrapper"; }
- static JS::Value fill_rect(JS::Interpreter&);
- static JS::Value stroke_rect(JS::Interpreter&);
- static JS::Value draw_image(JS::Interpreter&);
- static JS::Value scale(JS::Interpreter&);
- static JS::Value translate(JS::Interpreter&);
- static JS::Value begin_path(JS::Interpreter&);
- static JS::Value close_path(JS::Interpreter&);
- static JS::Value stroke(JS::Interpreter&);
- static JS::Value fill(JS::Interpreter&);
- static JS::Value move_to(JS::Interpreter&);
- static JS::Value line_to(JS::Interpreter&);
- static JS::Value quadratic_curve_to(JS::Interpreter&);
- static JS::Value create_image_data(JS::Interpreter&);
- static JS::Value put_image_data(JS::Interpreter&);
+ JS_DECLARE_NATIVE_FUNCTION(fill_rect);
+ JS_DECLARE_NATIVE_FUNCTION(stroke_rect);
+ JS_DECLARE_NATIVE_FUNCTION(draw_image);
+ JS_DECLARE_NATIVE_FUNCTION(scale);
+ JS_DECLARE_NATIVE_FUNCTION(translate);
+ JS_DECLARE_NATIVE_FUNCTION(begin_path);
+ JS_DECLARE_NATIVE_FUNCTION(close_path);
+ JS_DECLARE_NATIVE_FUNCTION(stroke);
+ JS_DECLARE_NATIVE_FUNCTION(fill);
+ JS_DECLARE_NATIVE_FUNCTION(move_to);
+ JS_DECLARE_NATIVE_FUNCTION(line_to);
+ JS_DECLARE_NATIVE_FUNCTION(quadratic_curve_to);
+ JS_DECLARE_NATIVE_FUNCTION(create_image_data);
+ JS_DECLARE_NATIVE_FUNCTION(put_image_data);
- static JS::Value fill_style_getter(JS::Interpreter&);
- static void fill_style_setter(JS::Interpreter&, JS::Value);
+ JS_DECLARE_NATIVE_GETTER(fill_style_getter);
+ JS_DECLARE_NATIVE_SETTER(fill_style_setter);
- static JS::Value stroke_style_getter(JS::Interpreter&);
- static void stroke_style_setter(JS::Interpreter&, JS::Value);
+ JS_DECLARE_NATIVE_GETTER(stroke_style_getter);
+ JS_DECLARE_NATIVE_SETTER(stroke_style_setter);
- static void line_width_setter(JS::Interpreter&, JS::Value);
- static JS::Value line_width_getter(JS::Interpreter&);
+ JS_DECLARE_NATIVE_GETTER(line_width_getter);
+ JS_DECLARE_NATIVE_SETTER(line_width_setter);
- static JS::Value canvas_getter(JS::Interpreter&);
+ JS_DECLARE_NATIVE_GETTER(canvas_getter);
NonnullRefPtr<CanvasRenderingContext2D> m_impl;
};
diff --git a/Libraries/LibWeb/Bindings/DocumentWrapper.cpp b/Libraries/LibWeb/Bindings/DocumentWrapper.cpp
index 06954130d6..4e8f35a8c1 100644
--- a/Libraries/LibWeb/Bindings/DocumentWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/DocumentWrapper.cpp
@@ -72,7 +72,7 @@ static Document* document_from(JS::Interpreter& interpreter)
return &static_cast<DocumentWrapper*>(this_object)->node();
}
-JS::Value DocumentWrapper::get_element_by_id(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(DocumentWrapper::get_element_by_id)
{
auto* document = document_from(interpreter);
if (!document)
@@ -88,7 +88,7 @@ JS::Value DocumentWrapper::get_element_by_id(JS::Interpreter& interpreter)
return wrap(interpreter.heap(), const_cast<Element&>(*element));
}
-JS::Value DocumentWrapper::query_selector(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(DocumentWrapper::query_selector)
{
auto* document = document_from(interpreter);
if (!document)
@@ -105,7 +105,7 @@ JS::Value DocumentWrapper::query_selector(JS::Interpreter& interpreter)
return wrap(interpreter.heap(), *element);
}
-JS::Value DocumentWrapper::query_selector_all(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(DocumentWrapper::query_selector_all)
{
auto* document = document_from(interpreter);
if (!document)
@@ -118,7 +118,7 @@ JS::Value DocumentWrapper::query_selector_all(JS::Interpreter& interpreter)
// FIXME: Throw if selector is invalid
auto elements = document->query_selector_all(selector);
// FIXME: This should be a static NodeList, not a plain JS::Array.
- auto* node_list = JS::Array::create(interpreter.global_object());
+ auto* node_list = JS::Array::create(global_object);
for (auto& element : elements) {
node_list->indexed_properties().append(wrap(interpreter.heap(), element));
}
diff --git a/Libraries/LibWeb/Bindings/DocumentWrapper.h b/Libraries/LibWeb/Bindings/DocumentWrapper.h
index 9cf4c765b3..539c2f9bf8 100644
--- a/Libraries/LibWeb/Bindings/DocumentWrapper.h
+++ b/Libraries/LibWeb/Bindings/DocumentWrapper.h
@@ -42,9 +42,9 @@ public:
private:
virtual const char* class_name() const override { return "DocumentWrapper"; }
- static JS::Value get_element_by_id(JS::Interpreter&);
- static JS::Value query_selector(JS::Interpreter&);
- static JS::Value query_selector_all(JS::Interpreter&);
+ JS_DECLARE_NATIVE_FUNCTION(get_element_by_id);
+ JS_DECLARE_NATIVE_FUNCTION(query_selector);
+ JS_DECLARE_NATIVE_FUNCTION(query_selector_all);
};
}
diff --git a/Libraries/LibWeb/Bindings/ElementWrapper.cpp b/Libraries/LibWeb/Bindings/ElementWrapper.cpp
index a17c43b51b..32f82d4570 100644
--- a/Libraries/LibWeb/Bindings/ElementWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/ElementWrapper.cpp
@@ -72,7 +72,7 @@ static Element* impl_from(JS::Interpreter& interpreter)
return &static_cast<ElementWrapper*>(this_object)->node();
}
-JS::Value ElementWrapper::get_attribute(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(ElementWrapper::get_attribute)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -92,7 +92,7 @@ JS::Value ElementWrapper::get_attribute(JS::Interpreter& interpreter)
return JS::js_string(interpreter, attribute_value);
}
-JS::Value ElementWrapper::set_attribute(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(ElementWrapper::set_attribute)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -113,14 +113,14 @@ JS::Value ElementWrapper::set_attribute(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value ElementWrapper::inner_html_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(ElementWrapper::inner_html_getter)
{
if (auto* impl = impl_from(interpreter))
return JS::js_string(interpreter, impl->inner_html());
return {};
}
-void ElementWrapper::inner_html_setter(JS::Interpreter& interpreter, JS::Value value)
+JS_DEFINE_NATIVE_SETTER(ElementWrapper::inner_html_setter)
{
if (auto* impl = impl_from(interpreter)) {
auto string = value.to_string(interpreter);
@@ -130,14 +130,14 @@ void ElementWrapper::inner_html_setter(JS::Interpreter& interpreter, JS::Value v
}
}
-JS::Value ElementWrapper::id_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(ElementWrapper::id_getter)
{
if (auto* impl = impl_from(interpreter))
return JS::js_string(interpreter, impl->attribute(HTML::AttributeNames::id));
return {};
}
-void ElementWrapper::id_setter(JS::Interpreter& interpreter, JS::Value value)
+JS_DEFINE_NATIVE_SETTER(ElementWrapper::id_setter)
{
if (auto* impl = impl_from(interpreter)) {
auto string = value.to_string(interpreter);
diff --git a/Libraries/LibWeb/Bindings/ElementWrapper.h b/Libraries/LibWeb/Bindings/ElementWrapper.h
index df75234d96..e8bf71ae3b 100644
--- a/Libraries/LibWeb/Bindings/ElementWrapper.h
+++ b/Libraries/LibWeb/Bindings/ElementWrapper.h
@@ -42,14 +42,14 @@ public:
private:
virtual const char* class_name() const override { return "ElementWrapper"; }
- static JS::Value inner_html_getter(JS::Interpreter&);
- static void inner_html_setter(JS::Interpreter&, JS::Value);
+ JS_DECLARE_NATIVE_GETTER(inner_html_getter);
+ JS_DECLARE_NATIVE_SETTER(inner_html_setter);
- static JS::Value id_getter(JS::Interpreter&);
- static void id_setter(JS::Interpreter&, JS::Value);
+ JS_DECLARE_NATIVE_GETTER(id_getter);
+ JS_DECLARE_NATIVE_SETTER(id_setter);
- static JS::Value get_attribute(JS::Interpreter&);
- static JS::Value set_attribute(JS::Interpreter&);
+ JS_DECLARE_NATIVE_FUNCTION(get_attribute);
+ JS_DECLARE_NATIVE_FUNCTION(set_attribute);
};
}
diff --git a/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp b/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp
index e53d6f89aa..f6eab59429 100644
--- a/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp
@@ -49,9 +49,9 @@ EventTargetWrapper::~EventTargetWrapper()
{
}
-JS::Value EventTargetWrapper::add_event_listener(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(EventTargetWrapper::add_event_listener)
{
- auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
+ auto* this_object = interpreter.this_value(global_object).to_object(interpreter);
if (!this_object)
return {};
if (interpreter.argument_count() < 2)
diff --git a/Libraries/LibWeb/Bindings/EventTargetWrapper.h b/Libraries/LibWeb/Bindings/EventTargetWrapper.h
index f07aef6007..6bb430efec 100644
--- a/Libraries/LibWeb/Bindings/EventTargetWrapper.h
+++ b/Libraries/LibWeb/Bindings/EventTargetWrapper.h
@@ -42,7 +42,7 @@ public:
private:
virtual const char* class_name() const override { return "EventTargetWrapper"; }
- static JS::Value add_event_listener(JS::Interpreter&);
+ JS_DECLARE_NATIVE_FUNCTION(add_event_listener);
NonnullRefPtr<EventTarget> m_impl;
};
diff --git a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp
index f194b38019..111f1a4b4e 100644
--- a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp
@@ -70,7 +70,7 @@ static HTMLCanvasElement* impl_from(JS::Interpreter& interpreter)
return &static_cast<HTMLCanvasElementWrapper*>(this_object)->node();
}
-JS::Value HTMLCanvasElementWrapper::get_context(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(HTMLCanvasElementWrapper::get_context)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -84,14 +84,14 @@ JS::Value HTMLCanvasElementWrapper::get_context(JS::Interpreter& interpreter)
return wrap(interpreter.heap(), *context);
}
-JS::Value HTMLCanvasElementWrapper::width_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(HTMLCanvasElementWrapper::width_getter)
{
if (auto* impl = impl_from(interpreter))
return JS::Value(impl->requested_width());
return {};
}
-JS::Value HTMLCanvasElementWrapper::height_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(HTMLCanvasElementWrapper::height_getter)
{
if (auto* impl = impl_from(interpreter))
return JS::Value(impl->requested_height());
diff --git a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.h b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.h
index 4f5ae3fc79..41e7b03d2b 100644
--- a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.h
+++ b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.h
@@ -42,10 +42,10 @@ public:
private:
virtual const char* class_name() const override { return "HTMLCanvasElementWrapper"; }
- static JS::Value get_context(JS::Interpreter&);
+ JS_DECLARE_NATIVE_FUNCTION(get_context);
- static JS::Value width_getter(JS::Interpreter&);
- static JS::Value height_getter(JS::Interpreter&);
+ JS_DECLARE_NATIVE_GETTER(width_getter);
+ JS_DECLARE_NATIVE_GETTER(height_getter);
};
}
diff --git a/Libraries/LibWeb/Bindings/ImageDataWrapper.cpp b/Libraries/LibWeb/Bindings/ImageDataWrapper.cpp
index 8c52fcae39..a62dcf2f5c 100644
--- a/Libraries/LibWeb/Bindings/ImageDataWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/ImageDataWrapper.cpp
@@ -67,7 +67,7 @@ static ImageData* impl_from(JS::Interpreter& interpreter)
return &static_cast<ImageDataWrapper*>(this_object)->impl();
}
-JS::Value ImageDataWrapper::width_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(ImageDataWrapper::width_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -75,7 +75,7 @@ JS::Value ImageDataWrapper::width_getter(JS::Interpreter& interpreter)
return JS::Value(impl->width());
}
-JS::Value ImageDataWrapper::height_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(ImageDataWrapper::height_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -83,7 +83,7 @@ JS::Value ImageDataWrapper::height_getter(JS::Interpreter& interpreter)
return JS::Value(impl->height());
}
-JS::Value ImageDataWrapper::data_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(ImageDataWrapper::data_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
diff --git a/Libraries/LibWeb/Bindings/ImageDataWrapper.h b/Libraries/LibWeb/Bindings/ImageDataWrapper.h
index 99552553fd..7772e6f0a0 100644
--- a/Libraries/LibWeb/Bindings/ImageDataWrapper.h
+++ b/Libraries/LibWeb/Bindings/ImageDataWrapper.h
@@ -42,9 +42,9 @@ public:
private:
virtual const char* class_name() const override { return "ImageDataWrapper"; }
- static JS::Value width_getter(JS::Interpreter&);
- static JS::Value height_getter(JS::Interpreter&);
- static JS::Value data_getter(JS::Interpreter&);
+ JS_DECLARE_NATIVE_GETTER(width_getter);
+ JS_DECLARE_NATIVE_GETTER(height_getter);
+ JS_DECLARE_NATIVE_GETTER(data_getter);
NonnullRefPtr<ImageData> m_impl;
};
diff --git a/Libraries/LibWeb/Bindings/LocationObject.cpp b/Libraries/LibWeb/Bindings/LocationObject.cpp
index 27dddc64d7..b921edf892 100644
--- a/Libraries/LibWeb/Bindings/LocationObject.cpp
+++ b/Libraries/LibWeb/Bindings/LocationObject.cpp
@@ -54,36 +54,36 @@ LocationObject::~LocationObject()
{
}
-JS::Value LocationObject::href_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(LocationObject::href_getter)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
return JS::js_string(interpreter, window.impl().document().url().to_string());
}
-void LocationObject::href_setter(JS::Interpreter& interpreter, JS::Value value)
+JS_DEFINE_NATIVE_SETTER(LocationObject::href_setter)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
auto new_href = value.to_string(interpreter);
if (interpreter.exception())
return;
window.impl().did_set_location_href({}, new_href);
}
-JS::Value LocationObject::pathname_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(LocationObject::pathname_getter)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
return JS::js_string(interpreter, window.impl().document().url().path());
}
-JS::Value LocationObject::hostname_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(LocationObject::hostname_getter)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
return JS::js_string(interpreter, window.impl().document().url().host());
}
-JS::Value LocationObject::host_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(LocationObject::host_getter)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
auto url = window.impl().document().url();
StringBuilder builder;
builder.append(url.host());
@@ -92,9 +92,9 @@ JS::Value LocationObject::host_getter(JS::Interpreter& interpreter)
return JS::js_string(interpreter, builder.to_string());
}
-JS::Value LocationObject::hash_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(LocationObject::hash_getter)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
auto fragment = window.impl().document().url().fragment();
if (!fragment.length())
return JS::js_string(interpreter, "");
@@ -104,9 +104,9 @@ JS::Value LocationObject::hash_getter(JS::Interpreter& interpreter)
return JS::js_string(interpreter, builder.to_string());
}
-JS::Value LocationObject::search_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(LocationObject::search_getter)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
auto query = window.impl().document().url().query();
if (!query.length())
return JS::js_string(interpreter, "");
@@ -116,18 +116,18 @@ JS::Value LocationObject::search_getter(JS::Interpreter& interpreter)
return JS::js_string(interpreter, builder.to_string());
}
-JS::Value LocationObject::protocol_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(LocationObject::protocol_getter)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
StringBuilder builder;
builder.append(window.impl().document().url().protocol());
builder.append(':');
return JS::js_string(interpreter, builder.to_string());
}
-JS::Value LocationObject::reload(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
{
- auto& window = static_cast<WindowObject&>(interpreter.global_object());
+ auto& window = static_cast<WindowObject&>(global_object);
window.impl().did_call_location_reload({});
return JS::js_undefined();
}
diff --git a/Libraries/LibWeb/Bindings/LocationObject.h b/Libraries/LibWeb/Bindings/LocationObject.h
index 3e253913fe..253dbf39c1 100644
--- a/Libraries/LibWeb/Bindings/LocationObject.h
+++ b/Libraries/LibWeb/Bindings/LocationObject.h
@@ -40,17 +40,17 @@ public:
private:
virtual const char* class_name() const override { return "LocationObject"; }
- static JS::Value reload(JS::Interpreter&);
+ JS_DECLARE_NATIVE_FUNCTION(reload);
- static JS::Value href_getter(JS::Interpreter&);
- static void href_setter(JS::Interpreter&, JS::Value);
+ JS_DECLARE_NATIVE_GETTER(href_getter);
+ JS_DECLARE_NATIVE_SETTER(href_setter);
- static JS::Value host_getter(JS::Interpreter&);
- static JS::Value hostname_getter(JS::Interpreter&);
- static JS::Value pathname_getter(JS::Interpreter&);
- static JS::Value hash_getter(JS::Interpreter&);
- static JS::Value search_getter(JS::Interpreter&);
- static JS::Value protocol_getter(JS::Interpreter&);
+ JS_DECLARE_NATIVE_GETTER(host_getter);
+ JS_DECLARE_NATIVE_GETTER(hostname_getter);
+ JS_DECLARE_NATIVE_GETTER(pathname_getter);
+ JS_DECLARE_NATIVE_GETTER(hash_getter);
+ JS_DECLARE_NATIVE_GETTER(search_getter);
+ JS_DECLARE_NATIVE_GETTER(protocol_getter);
};
}
diff --git a/Libraries/LibWeb/Bindings/MouseEventWrapper.cpp b/Libraries/LibWeb/Bindings/MouseEventWrapper.cpp
index 57ec50b853..6633bf5a85 100644
--- a/Libraries/LibWeb/Bindings/MouseEventWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/MouseEventWrapper.cpp
@@ -65,14 +65,14 @@ static MouseEvent* impl_from(JS::Interpreter& interpreter)
return &static_cast<MouseEventWrapper*>(this_object)->event();
}
-JS::Value MouseEventWrapper::offset_x_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(MouseEventWrapper::offset_x_getter)
{
if (auto* impl = impl_from(interpreter))
return JS::Value(impl->offset_x());
return {};
}
-JS::Value MouseEventWrapper::offset_y_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(MouseEventWrapper::offset_y_getter)
{
if (auto* impl = impl_from(interpreter))
return JS::Value(impl->offset_y());
diff --git a/Libraries/LibWeb/Bindings/MouseEventWrapper.h b/Libraries/LibWeb/Bindings/MouseEventWrapper.h
index 606e4017df..ffa778b1fc 100644
--- a/Libraries/LibWeb/Bindings/MouseEventWrapper.h
+++ b/Libraries/LibWeb/Bindings/MouseEventWrapper.h
@@ -42,8 +42,8 @@ public:
private:
virtual const char* class_name() const override { return "MouseEventWrapper"; }
- static JS::Value offset_x_getter(JS::Interpreter&);
- static JS::Value offset_y_getter(JS::Interpreter&);
+ JS_DECLARE_NATIVE_GETTER(offset_x_getter);
+ JS_DECLARE_NATIVE_GETTER(offset_y_getter);
};
}
diff --git a/Libraries/LibWeb/Bindings/NavigatorObject.cpp b/Libraries/LibWeb/Bindings/NavigatorObject.cpp
index 1cf7dad679..28fbfb23fb 100644
--- a/Libraries/LibWeb/Bindings/NavigatorObject.cpp
+++ b/Libraries/LibWeb/Bindings/NavigatorObject.cpp
@@ -55,7 +55,7 @@ NavigatorObject::~NavigatorObject()
{
}
-JS::Value NavigatorObject::user_agent_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(NavigatorObject::user_agent_getter)
{
return JS::js_string(interpreter, ResourceLoader::the().user_agent());
}
diff --git a/Libraries/LibWeb/Bindings/NavigatorObject.h b/Libraries/LibWeb/Bindings/NavigatorObject.h
index 5f12f4b8a6..b7b69be585 100644
--- a/Libraries/LibWeb/Bindings/NavigatorObject.h
+++ b/Libraries/LibWeb/Bindings/NavigatorObject.h
@@ -40,7 +40,7 @@ public:
private:
virtual const char* class_name() const override { return "NavigatorObject"; }
- static JS::Value user_agent_getter(JS::Interpreter&);
+ JS_DECLARE_NATIVE_GETTER(user_agent_getter);
};
}
diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp
index 244e631306..8fc0e92dd4 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -94,7 +94,7 @@ static Window* impl_from(JS::Interpreter& interpreter)
return &static_cast<WindowObject*>(this_object)->impl();
}
-JS::Value WindowObject::alert(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(WindowObject::alert)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -109,7 +109,7 @@ JS::Value WindowObject::alert(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value WindowObject::confirm(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(WindowObject::confirm)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -123,7 +123,7 @@ JS::Value WindowObject::confirm(JS::Interpreter& interpreter)
return JS::Value(impl->confirm(message));
}
-JS::Value WindowObject::set_interval(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_interval)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -149,7 +149,7 @@ JS::Value WindowObject::set_interval(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_timeout)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -175,7 +175,7 @@ JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value WindowObject::request_animation_frame(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(WindowObject::request_animation_frame)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -190,7 +190,7 @@ JS::Value WindowObject::request_animation_frame(JS::Interpreter& interpreter)
return JS::Value(impl->request_animation_frame(*static_cast<JS::Function*>(callback_object)));
}
-JS::Value WindowObject::cancel_animation_frame(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(WindowObject::cancel_animation_frame)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -204,7 +204,7 @@ JS::Value WindowObject::cancel_animation_frame(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value WindowObject::document_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(WindowObject::document_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -212,9 +212,10 @@ JS::Value WindowObject::document_getter(JS::Interpreter& interpreter)
return wrap(interpreter.heap(), impl->document());
}
-void WindowObject::document_setter(JS::Interpreter&, JS::Value)
+JS_DEFINE_NATIVE_SETTER(WindowObject::document_setter)
{
// FIXME: Figure out what we should do here. Just ignore attempts to set window.document for now.
+ UNUSED_PARAM(value);
}
}
diff --git a/Libraries/LibWeb/Bindings/WindowObject.h b/Libraries/LibWeb/Bindings/WindowObject.h
index 39b00db246..dff689c8e4 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.h
+++ b/Libraries/LibWeb/Bindings/WindowObject.h
@@ -48,15 +48,15 @@ private:
virtual const char* class_name() const override { return "WindowObject"; }
virtual void visit_children(Visitor&) override;
- static JS::Value document_getter(JS::Interpreter&);
- static void document_setter(JS::Interpreter&, JS::Value);
+ JS_DECLARE_NATIVE_GETTER(document_getter);
+ JS_DECLARE_NATIVE_SETTER(document_setter);
- static JS::Value alert(JS::Interpreter&);
- static JS::Value confirm(JS::Interpreter&);
- static JS::Value set_interval(JS::Interpreter&);
- static JS::Value set_timeout(JS::Interpreter&);
- static JS::Value request_animation_frame(JS::Interpreter&);
- static JS::Value cancel_animation_frame(JS::Interpreter&);
+ JS_DECLARE_NATIVE_FUNCTION(alert);
+ JS_DECLARE_NATIVE_FUNCTION(confirm);
+ JS_DECLARE_NATIVE_FUNCTION(set_interval);
+ JS_DECLARE_NATIVE_FUNCTION(set_timeout);
+ JS_DECLARE_NATIVE_FUNCTION(request_animation_frame);
+ JS_DECLARE_NATIVE_FUNCTION(cancel_animation_frame);
NonnullRefPtr<Window> m_impl;
diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
index e03baa8304..ea871c6663 100644
--- a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
+++ b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
@@ -66,7 +66,7 @@ static XMLHttpRequest* impl_from(JS::Interpreter& interpreter)
return &static_cast<XMLHttpRequestWrapper*>(this_object)->impl();
}
-JS::Value XMLHttpRequestPrototype::open(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(XMLHttpRequestPrototype::open)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -81,7 +81,7 @@ JS::Value XMLHttpRequestPrototype::open(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value XMLHttpRequestPrototype::send(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_FUNCTION(XMLHttpRequestPrototype::send)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -90,7 +90,7 @@ JS::Value XMLHttpRequestPrototype::send(JS::Interpreter& interpreter)
return JS::js_undefined();
}
-JS::Value XMLHttpRequestPrototype::ready_state_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(XMLHttpRequestPrototype::ready_state_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
@@ -98,7 +98,7 @@ JS::Value XMLHttpRequestPrototype::ready_state_getter(JS::Interpreter& interpret
return JS::Value((i32)impl->ready_state());
}
-JS::Value XMLHttpRequestPrototype::response_text_getter(JS::Interpreter& interpreter)
+JS_DEFINE_NATIVE_GETTER(XMLHttpRequestPrototype::response_text_getter)
{
auto* impl = impl_from(interpreter);
if (!impl)
diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h
index 3fa5d48869..50ba87d236 100644
--- a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h
+++ b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.h
@@ -39,11 +39,11 @@ public:
private:
virtual const char* class_name() const override { return "XMLHttpRequestPrototype"; }
- static JS::Value open(JS::Interpreter&);
- static JS::Value send(JS::Interpreter&);
+ JS_DECLARE_NATIVE_FUNCTION(open);
+ JS_DECLARE_NATIVE_FUNCTION(send);
- static JS::Value ready_state_getter(JS::Interpreter&);
- static JS::Value response_text_getter(JS::Interpreter&);
+ JS_DECLARE_NATIVE_GETTER(ready_state_getter);
+ JS_DECLARE_NATIVE_GETTER(response_text_getter);
};
}