From 7e9ea964a8056f2d73208985b89b4c90d7d2afa2 Mon Sep 17 00:00:00 2001 From: Bastiaan van der Plaat Date: Sat, 9 Sep 2023 21:59:09 +0200 Subject: [PATCH] LibWeb: Use TRY in DOMMatrix and DOMPointReadOnly --- Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp | 10 ++-------- .../Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp | 5 +---- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp index dfa313c89b..6023d77e46 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp @@ -258,10 +258,7 @@ void DOMMatrix::set_f(double value) WebIDL::ExceptionOr> DOMMatrix::multiply_self(DOMMatrixInit other) { // 1. Let otherObject be the result of invoking create a DOMMatrix from the dictionary other. - auto maybe_other_object = DOMMatrix::create_from_dom_matrix_2d_init(realm(), other); - if (maybe_other_object.is_exception()) - return maybe_other_object.exception(); - auto other_object = maybe_other_object.release_value(); + auto other_object = TRY(DOMMatrix::create_from_dom_matrix_2d_init(realm(), other)); // 2. The otherObject matrix gets post-multiplied to the current matrix. m_matrix = m_matrix * other_object->m_matrix; @@ -278,10 +275,7 @@ WebIDL::ExceptionOr> DOMMatrix::multiply_self(DOMMat WebIDL::ExceptionOr> DOMMatrix::pre_multiply_self(DOMMatrixInit other) { // 1. Let otherObject be the result of invoking create a DOMMatrix from the dictionary other. - auto maybe_other_object = DOMMatrix::create_from_dom_matrix_2d_init(realm(), other); - if (maybe_other_object.is_exception()) - return maybe_other_object.exception(); - auto other_object = maybe_other_object.release_value(); + auto other_object = TRY(DOMMatrix::create_from_dom_matrix_2d_init(realm(), other)); // 2. The otherObject matrix gets pre-multiplied to the current matrix. m_matrix = other_object->m_matrix * m_matrix; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp index 7f9f77fc64..5274819dfc 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp @@ -39,10 +39,7 @@ DOMPointReadOnly::~DOMPointReadOnly() = default; WebIDL::ExceptionOr> 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(); + auto matrix_object = TRY(DOMMatrix::create_from_dom_matrix_2d_init(realm(), matrix)); // 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);