diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-04 23:54:58 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-04 23:54:58 +0200 |
commit | 9d099835f92bfaba503b3fe95a2dfb998c65bab4 (patch) | |
tree | 2930ab301ed9aff7e72c46246355e6d82044843e /Libraries/LibWeb/Bindings | |
parent | 2db8716a6fb6106ad6bf59a628137c4e4474e1a9 (diff) | |
download | serenity-9d099835f92bfaba503b3fe95a2dfb998c65bab4.zip |
LibWeb: Add CanvasRenderingContext2D scale() and translate() stubs
These don't do anything for now.
Diffstat (limited to 'Libraries/LibWeb/Bindings')
-rw-r--r-- | Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp | 24 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp index 5af008f98a..64ae861ff1 100644 --- a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp +++ b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp @@ -45,6 +45,8 @@ CanvasRenderingContext2DWrapper::CanvasRenderingContext2DWrapper(CanvasRendering { put_native_property("fillStyle", fill_style_getter, fill_style_setter); put_native_function("fillRect", fill_rect, 4); + put_native_function("scale", scale, 2); + put_native_function("translate", translate, 2); } CanvasRenderingContext2DWrapper::~CanvasRenderingContext2DWrapper() @@ -71,6 +73,28 @@ JS::Value CanvasRenderingContext2DWrapper::fill_rect(JS::Interpreter& interprete return JS::js_undefined(); } +JS::Value CanvasRenderingContext2DWrapper::scale(JS::Interpreter& interpreter) +{ + auto* impl = impl_from(interpreter); + if (!impl) + return {}; + auto& arguments = interpreter.call_frame().arguments; + if (arguments.size() >= 2) + impl->scale(arguments[0].to_number().as_double(), arguments[1].to_number().as_double()); + return JS::js_undefined(); +} + +JS::Value CanvasRenderingContext2DWrapper::translate(JS::Interpreter& interpreter) +{ + auto* impl = impl_from(interpreter); + if (!impl) + return {}; + auto& arguments = interpreter.call_frame().arguments; + if (arguments.size() >= 2) + impl->translate(arguments[0].to_number().as_double(), arguments[1].to_number().as_double()); + return JS::js_undefined(); +} + JS::Value CanvasRenderingContext2DWrapper::fill_style_getter(JS::Interpreter& interpreter) { auto* impl = impl_from(interpreter); diff --git a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h index 8e8f1ad1a0..5ab2e0ce97 100644 --- a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h +++ b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.h @@ -43,6 +43,8 @@ private: virtual const char* class_name() const override { return "CanvasRenderingContext2DWrapper"; } static JS::Value fill_rect(JS::Interpreter&); + static JS::Value scale(JS::Interpreter&); + static JS::Value translate(JS::Interpreter&); static JS::Value fill_style_getter(JS::Interpreter&); static void fill_style_setter(JS::Interpreter&, JS::Value); |