diff options
3 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 1cade07f81..a7eab5c996 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -313,4 +313,11 @@ void CanvasRenderingContext2D::put_image_data(const ImageData& image_data, float did_draw(Gfx::FloatRect(x, y, image_data.width(), image_data.height())); } +// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-save +void CanvasRenderingContext2D::save() +{ + // The save() method steps are to push a copy of the current drawing state onto the drawing state stack. + m_drawing_state_stack.append(m_drawing_state); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index 90e7cf7c9b..7d2552a370 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -69,6 +69,8 @@ public: RefPtr<ImageData> create_image_data(int width, int height) const; void put_image_data(const ImageData&, float x, float y); + void save(); + HTMLCanvasElement* canvas() { return m_element; } private: @@ -89,6 +91,7 @@ private: }; DrawingState m_drawing_state; + Vector<DrawingState> m_drawing_state_stack; Gfx::Path m_path; }; diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl index c5a5b7bf6f..05b5870207 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl @@ -31,6 +31,8 @@ interface CanvasRenderingContext2D { ImageData createImageData(double sw, double sh); undefined putImageData(ImageData imagedata, double dx, double dy); + undefined save(); + readonly attribute HTMLCanvasElement canvas; }; |