diff options
author | Linus Groh <mail@linusgroh.de> | 2021-12-27 14:32:31 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-27 16:43:23 +0100 |
commit | 3e0e965f244bb6ac4715ce9a5791ce6902f979a2 (patch) | |
tree | ca25848b37445beadfd1653b6a523e4a90ecf09d /Userland | |
parent | 7d435b5adacdaa8f038669d10fba9f615265897a (diff) | |
download | serenity-3e0e965f244bb6ac4715ce9a5791ce6902f979a2.zip |
LibWeb: Implement CanvasRenderingContext2D.restore()
Diffstat (limited to 'Userland')
3 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index a7eab5c996..5ec1a7a6c3 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -320,4 +320,13 @@ void CanvasRenderingContext2D::save() m_drawing_state_stack.append(m_drawing_state); } +// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-restore +void CanvasRenderingContext2D::restore() +{ + // The restore() method steps are to pop the top entry in the drawing state stack, and reset the drawing state it describes. If there is no saved state, then the method must do nothing. + if (m_drawing_state_stack.is_empty()) + return; + m_drawing_state = m_drawing_state_stack.take_last(); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index 7d2552a370..d0accdc0f2 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -70,6 +70,7 @@ public: void put_image_data(const ImageData&, float x, float y); void save(); + void restore(); HTMLCanvasElement* canvas() { return m_element; } diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl index 05b5870207..7f4b8dbc8d 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl @@ -32,6 +32,7 @@ interface CanvasRenderingContext2D { undefined putImageData(ImageData imagedata, double dx, double dy); undefined save(); + undefined restore(); readonly attribute HTMLCanvasElement canvas; |