1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:18:11 +00:00

LibWeb: Add DOMPoint matrixTransform and DOMMatrix transformPoint

This commit is contained in:
Bastiaan van der Plaat 2023-08-15 13:16:45 +02:00 committed by Jelle Raaijmakers
parent 38bc8836d6
commit b4ae719664
9 changed files with 106 additions and 2 deletions

View file

@ -6,6 +6,7 @@
*/
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Geometry/DOMMatrix.h>
#include <LibWeb/Geometry/DOMPointReadOnly.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -34,6 +35,19 @@ JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::from_point(JS::VM& vm, DOMP
DOMPointReadOnly::~DOMPointReadOnly() = default;
// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-matrixtransform
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPoint>> DOMPointReadOnly::matrix_transform(DOMMatrixInit& matrix) const
{
// 1. Let matrixObject be the result of invoking create a DOMMatrix from the dictionary matrix.
auto maybe_matrix_object = DOMMatrix::create_from_dom_matrix_2d_init(realm(), matrix);
if (maybe_matrix_object.is_exception())
return maybe_matrix_object.exception();
auto matrix_object = maybe_matrix_object.release_value();
// 2. Return the result of invoking transform a point with a matrix, given the current point and matrixObject. The current point does not get modified.
return matrix_object->transform_point(*this);
}
void DOMPointReadOnly::initialize(JS::Realm& realm)
{
Base::initialize(realm);