From e9de1b6d79dbbde09082af68e4fc6c91a3bd378f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 09:07:48 +0000 Subject: [PATCH] Commit from GitHub Actions (Run Code Linter) --- bridge/bindings/qjs/binding_initializer.cc | 2 +- bridge/core/api/executing_context.cc | 48 +++++++------ bridge/core/binding_object.h | 2 +- bridge/core/dom/element.cc | 5 +- bridge/core/executing_context.cc | 4 +- bridge/core/frame/module_manager.cc | 11 ++- bridge/core/geometry/dom_matrix.cc | 9 ++- bridge/core/geometry/dom_matrix.h | 12 ++-- bridge/core/geometry/dom_matrix_read_only.cc | 58 ++++++++-------- bridge/core/geometry/dom_matrix_read_only.h | 10 +-- bridge/core/geometry/dom_point.cc | 2 +- bridge/core/geometry/dom_point.h | 2 +- bridge/core/geometry/dom_point_read_only.cc | 23 ++++--- bridge/core/geometry/dom_point_read_only.h | 5 +- .../html/canvas/canvas_rendering_context_2d.h | 6 +- bridge/core/html/canvas/path_2d.cc | 13 ++-- bridge/core/html/canvas/path_2d.h | 14 ++-- bridge/core/page.cc | 15 ++--- bridge/foundation/dart_readable.cc | 1 - bridge/include/plugin_api/executing_context.h | 67 +++++++++---------- 20 files changed, 156 insertions(+), 153 deletions(-) diff --git a/bridge/bindings/qjs/binding_initializer.cc b/bridge/bindings/qjs/binding_initializer.cc index 9c087af470..6614749aaa 100644 --- a/bridge/bindings/qjs/binding_initializer.cc +++ b/bridge/bindings/qjs/binding_initializer.cc @@ -11,7 +11,6 @@ #include "qjs_bounding_client_rect.h" #include "qjs_canvas_gradient.h" #include "qjs_canvas_pattern.h" -#include "qjs_path_2d.h" #include "qjs_canvas_rendering_context.h" #include "qjs_canvas_rendering_context_2d.h" #include "qjs_character_data.h" @@ -72,6 +71,7 @@ #include "qjs_native_loader.h" #include "qjs_node.h" #include "qjs_node_list.h" +#include "qjs_path_2d.h" #include "qjs_performance.h" #include "qjs_performance_entry.h" #include "qjs_performance_mark.h" diff --git a/bridge/core/api/executing_context.cc b/bridge/core/api/executing_context.cc index aacdf6be72..265540ea09 100644 --- a/bridge/core/api/executing_context.cc +++ b/bridge/core/api/executing_context.cc @@ -7,9 +7,9 @@ #include "core/api/exception_state.h" #include "core/dom/document.h" #include "core/executing_context.h" +#include "core/frame/module_manager.h" #include "core/frame/window.h" #include "core/frame/window_or_worker_global_scope.h" -#include "core/frame/module_manager.h" #include "foundation/native_value_converter.h" namespace webf { @@ -41,7 +41,8 @@ NativeValue ExecutingContextWebFMethods::WebFInvokeModule(ExecutingContext* cont AtomicString module_name_atomic = AtomicString(context->ctx(), module_name); AtomicString method_atomic = webf::AtomicString(context->ctx(), method); - ScriptValue result = ModuleManager::__webf_invoke_module__(context, module_name_atomic, method_atomic, shared_exception_state->exception_state); + ScriptValue result = ModuleManager::__webf_invoke_module__(context, module_name_atomic, method_atomic, + shared_exception_state->exception_state); NativeValue return_result = result.ToNative(context->ctx(), shared_exception_state->exception_state); if (shared_exception_state->exception_state.HasException()) { @@ -52,14 +53,15 @@ NativeValue ExecutingContextWebFMethods::WebFInvokeModule(ExecutingContext* cont } NativeValue ExecutingContextWebFMethods::WebFInvokeModuleWithParams(ExecutingContext* context, - const char* module_name, - const char* method, - NativeValue* params, - SharedExceptionState* shared_exception_state) { + const char* module_name, + const char* method, + NativeValue* params, + SharedExceptionState* shared_exception_state) { AtomicString module_name_atomic = AtomicString(context->ctx(), module_name); AtomicString method_atomic = webf::AtomicString(context->ctx(), method); - const NativeValue* result = ModuleManager::__webf_invoke_module__(context, module_name_atomic, method_atomic, *params, nullptr, shared_exception_state->exception_state); + const NativeValue* result = ModuleManager::__webf_invoke_module__(context, module_name_atomic, method_atomic, *params, + nullptr, shared_exception_state->exception_state); if (shared_exception_state->exception_state.HasException()) { return Native_NewNull(); @@ -69,18 +71,20 @@ NativeValue ExecutingContextWebFMethods::WebFInvokeModuleWithParams(ExecutingCon return return_result; } -NativeValue ExecutingContextWebFMethods::WebFInvokeModuleWithParamsAndCallback(ExecutingContext* context, - const char* module_name, - const char* method, - NativeValue* params, - WebFNativeFunctionContext* callback_context, - SharedExceptionState* shared_exception_state) { +NativeValue ExecutingContextWebFMethods::WebFInvokeModuleWithParamsAndCallback( + ExecutingContext* context, + const char* module_name, + const char* method, + NativeValue* params, + WebFNativeFunctionContext* callback_context, + SharedExceptionState* shared_exception_state) { AtomicString module_name_atomic = AtomicString(context->ctx(), module_name); AtomicString method_atomic = webf::AtomicString(context->ctx(), method); auto callback_impl = WebFNativeFunction::Create(callback_context, shared_exception_state); - const NativeValue* result = ModuleManager::__webf_invoke_module__(context, module_name_atomic, method_atomic, *params, callback_impl, shared_exception_state->exception_state); + const NativeValue* result = ModuleManager::__webf_invoke_module__( + context, module_name_atomic, method_atomic, *params, callback_impl, shared_exception_state->exception_state); if (shared_exception_state->exception_state.HasException()) { return Native_NewNull(); @@ -101,22 +105,24 @@ int32_t ExecutingContextWebFMethods::SetTimeout(ExecutingContext* context, } int32_t ExecutingContextWebFMethods::SetInterval(ExecutingContext* context, - WebFNativeFunctionContext* callback_context, - int32_t timeout, - SharedExceptionState* shared_exception_state) { + WebFNativeFunctionContext* callback_context, + int32_t timeout, + SharedExceptionState* shared_exception_state) { auto callback_impl = WebFNativeFunction::Create(callback_context, shared_exception_state); return WindowOrWorkerGlobalScope::setInterval(context, callback_impl, timeout, shared_exception_state->exception_state); } -void ExecutingContextWebFMethods::ClearTimeout(ExecutingContext* context, int32_t timeout_id, - SharedExceptionState* shared_exception_state) { +void ExecutingContextWebFMethods::ClearTimeout(ExecutingContext* context, + int32_t timeout_id, + SharedExceptionState* shared_exception_state) { WindowOrWorkerGlobalScope::clearTimeout(context, timeout_id, shared_exception_state->exception_state); } -void ExecutingContextWebFMethods::ClearInterval(ExecutingContext* context, int32_t interval_id, - SharedExceptionState* shared_exception_state) { +void ExecutingContextWebFMethods::ClearInterval(ExecutingContext* context, + int32_t interval_id, + SharedExceptionState* shared_exception_state) { WindowOrWorkerGlobalScope::clearInterval(context, interval_id, shared_exception_state->exception_state); } diff --git a/bridge/core/binding_object.h b/bridge/core/binding_object.h index 57369e7ce4..c308b0fe18 100644 --- a/bridge/core/binding_object.h +++ b/bridge/core/binding_object.h @@ -70,7 +70,7 @@ enum BindingMethodCallOperations { kAsyncAnonymousFunction, }; -enum CreateBindingObjectType { +enum CreateBindingObjectType { kCreateDOMMatrix = 0, kCreatePath2D = 1, kCreateDOMPoint = 2, diff --git a/bridge/core/dom/element.cc b/bridge/core/dom/element.cc index eff9839b7c..dd373e716a 100644 --- a/bridge/core/dom/element.cc +++ b/bridge/core/dom/element.cc @@ -470,8 +470,9 @@ ScriptValue Element::___testGlobalToLocal__(double x, double y, webf::ExceptionS NativeValueConverter::ToNativeValue(y), }; - NativeValue result = InvokeBindingMethod(binding_call_methods::k__test_global_to_local__, 2, args, - FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + NativeValue result = InvokeBindingMethod( + binding_call_methods::k__test_global_to_local__, 2, args, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); return ScriptValue(ctx(), result); } diff --git a/bridge/core/executing_context.cc b/bridge/core/executing_context.cc index 66eff49727..9432aeebe9 100644 --- a/bridge/core/executing_context.cc +++ b/bridge/core/executing_context.cc @@ -492,7 +492,9 @@ void ExecutingContext::FlushUICommand(const webf::BindingObject* self, } } -bool ExecutingContext::SyncUICommandBuffer(const BindingObject* self, uint32_t reason, std::vector& deps) { +bool ExecutingContext::SyncUICommandBuffer(const BindingObject* self, + uint32_t reason, + std::vector& deps) { if (!uiCommandBuffer()->empty()) { if (is_dedicated_) { bool should_swap_ui_commands = false; diff --git a/bridge/core/frame/module_manager.cc b/bridge/core/frame/module_manager.cc index 9890f17e26..27ac883205 100644 --- a/bridge/core/frame/module_manager.cc +++ b/bridge/core/frame/module_manager.cc @@ -83,7 +83,6 @@ NativeValue* handleInvokeModuleTransientCallback(void* ptr, callback->Invoke(context, 2, params); } } - } static void ReturnResultToDart(Dart_PersistentHandle persistent_handle, @@ -163,11 +162,11 @@ ScriptValue ModuleManager::__webf_invoke_module__(ExecutingContext* context, return return_value; } NativeValue* ModuleManager::__webf_invoke_module__(ExecutingContext* context, - const AtomicString& module_name, - const AtomicString& method, - NativeValue& params, - const std::shared_ptr& callback, - ExceptionState& exception) { + const AtomicString& module_name, + const AtomicString& method, + NativeValue& params, + const std::shared_ptr& callback, + ExceptionState& exception) { if (exception.HasException()) { return nullptr; } diff --git a/bridge/core/geometry/dom_matrix.cc b/bridge/core/geometry/dom_matrix.cc index 30a2a20c16..ef62ce161b 100644 --- a/bridge/core/geometry/dom_matrix.cc +++ b/bridge/core/geometry/dom_matrix.cc @@ -17,16 +17,15 @@ DOMMatrix* DOMMatrix::Create(webf::ExecutingContext* context, webf::ExceptionSta return MakeGarbageCollected(context, exception_state); } -DOMMatrix::DOMMatrix(webf::ExecutingContext* context, webf::ExceptionState& exception_state): - DOMMatrixReadOnly(context, exception_state) {} +DOMMatrix::DOMMatrix(webf::ExecutingContext* context, webf::ExceptionState& exception_state) + : DOMMatrixReadOnly(context, exception_state) {} DOMMatrix::DOMMatrix(ExecutingContext* context, const std::shared_ptr& init, ExceptionState& exception_state) : DOMMatrixReadOnly(context, init, exception_state) {} -DOMMatrix::DOMMatrix(webf::ExecutingContext* context, webf::NativeBindingObject* native_binding_object): DOMMatrixReadOnly(context, native_binding_object) { - -} +DOMMatrix::DOMMatrix(webf::ExecutingContext* context, webf::NativeBindingObject* native_binding_object) + : DOMMatrixReadOnly(context, native_binding_object) {} } // namespace webf \ No newline at end of file diff --git a/bridge/core/geometry/dom_matrix.h b/bridge/core/geometry/dom_matrix.h index ac04deefc4..88bb3ddcfc 100644 --- a/bridge/core/geometry/dom_matrix.h +++ b/bridge/core/geometry/dom_matrix.h @@ -17,20 +17,16 @@ class DOMMatrix : public DOMMatrixReadOnly { static DOMMatrix* Create(ExecutingContext* context, const std::shared_ptr& init, ExceptionState& exception_state); - static DOMMatrix* Create(ExecutingContext* context, - ExceptionState& exception_state); + static DOMMatrix* Create(ExecutingContext* context, ExceptionState& exception_state); DOMMatrix() = delete; - explicit DOMMatrix(ExecutingContext* context, - ExceptionState& exception_state); + explicit DOMMatrix(ExecutingContext* context, ExceptionState& exception_state); explicit DOMMatrix(ExecutingContext* context, const std::shared_ptr& init, ExceptionState& exception_state); - explicit DOMMatrix(ExecutingContext* context, - NativeBindingObject* native_binding_object); + explicit DOMMatrix(ExecutingContext* context, NativeBindingObject* native_binding_object); - [[nodiscard]] - bool IsDOMMatrix() const override { return true; } + [[nodiscard]] bool IsDOMMatrix() const override { return true; } private: }; diff --git a/bridge/core/geometry/dom_matrix_read_only.cc b/bridge/core/geometry/dom_matrix_read_only.cc index 14a33b83ae..ff10e57411 100644 --- a/bridge/core/geometry/dom_matrix_read_only.cc +++ b/bridge/core/geometry/dom_matrix_read_only.cc @@ -3,13 +3,13 @@ */ #include "dom_matrix_read_only.h" -#include "bindings/qjs/converter_impl.h" #include "binding_call_methods.h" -#include "native_value_converter.h" +#include "bindings/qjs/converter_impl.h" #include "core/executing_context.h" #include "core/frame/module_manager.h" #include "core/geometry/dom_matrix.h" #include "core/geometry/dom_point.h" +#include "native_value_converter.h" namespace webf { DOMMatrixReadOnly* DOMMatrixReadOnly::Create(ExecutingContext* context, @@ -47,13 +47,12 @@ DOMMatrixReadOnly::DOMMatrixReadOnly(ExecutingContext* context, const std::shared_ptr& init, ExceptionState& exception_state) : BindingObject(context->ctx()) { - if (init->IsSequenceDouble()) { NativeValue arguments[1]; arguments[0] = NativeValueConverter>::ToNativeValue(init->GetAsSequenceDouble()); - GetExecutingContext()->dartMethodPtr()->createBindingObject(GetExecutingContext()->isDedicated(), - GetExecutingContext()->contextId(), bindingObject(), - CreateBindingObjectType::kCreateDOMMatrix, arguments, 1); + GetExecutingContext()->dartMethodPtr()->createBindingObject( + GetExecutingContext()->isDedicated(), GetExecutingContext()->contextId(), bindingObject(), + CreateBindingObjectType::kCreateDOMMatrix, arguments, 1); } else if (init->IsDOMMatrixInit()) { std::vector domMatrixInitVectorDouble; auto domMatrixInit = init->GetAsDOMMatrixInit(); @@ -77,9 +76,9 @@ DOMMatrixReadOnly::DOMMatrixReadOnly(ExecutingContext* context, arguments[0] = NativeValueConverter>::ToNativeValue(domMatrixInitVectorDouble); arguments[1] = NativeValueConverter::ToNativeValue(domMatrixInit->is2D()); arguments[2] = NativeValueConverter::ToNativeValue(domMatrixInit->isIdentity()); - GetExecutingContext()->dartMethodPtr()->createBindingObject(GetExecutingContext()->isDedicated(), - GetExecutingContext()->contextId(), bindingObject(), - CreateBindingObjectType::kCreateDOMMatrix, arguments, 1); + GetExecutingContext()->dartMethodPtr()->createBindingObject( + GetExecutingContext()->isDedicated(), GetExecutingContext()->contextId(), bindingObject(), + CreateBindingObjectType::kCreateDOMMatrix, arguments, 1); } } @@ -204,8 +203,8 @@ void DOMMatrixReadOnly::setM44(double v, ExceptionState& exception_state) { } DOMMatrix* DOMMatrixReadOnly::flipX(ExceptionState& exception_state) const { - NativeValue value = InvokeBindingMethod(binding_call_methods::kflipX, 0, - nullptr, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue value = InvokeBindingMethod(binding_call_methods::kflipX, 0, nullptr, + FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = NativeValueConverter>::FromNativeValue(value); if (native_binding_object == nullptr) @@ -213,8 +212,8 @@ DOMMatrix* DOMMatrixReadOnly::flipX(ExceptionState& exception_state) const { return MakeGarbageCollected(GetExecutingContext(), native_binding_object); } DOMMatrix* DOMMatrixReadOnly::flipY(ExceptionState& exception_state) const { - NativeValue value = InvokeBindingMethod(binding_call_methods::kflipY, 0, - nullptr, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue value = InvokeBindingMethod(binding_call_methods::kflipY, 0, nullptr, + FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = NativeValueConverter>::FromNativeValue(value); if (native_binding_object == nullptr) @@ -222,8 +221,8 @@ DOMMatrix* DOMMatrixReadOnly::flipY(ExceptionState& exception_state) const { return MakeGarbageCollected(GetExecutingContext(), native_binding_object); } DOMMatrix* DOMMatrixReadOnly::inverse(ExceptionState& exception_state) const { - NativeValue value = InvokeBindingMethod(binding_call_methods::kinverse, 0, - nullptr, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue value = InvokeBindingMethod(binding_call_methods::kinverse, 0, nullptr, + FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = NativeValueConverter>::FromNativeValue(value); if (native_binding_object == nullptr) @@ -232,9 +231,7 @@ DOMMatrix* DOMMatrixReadOnly::inverse(ExceptionState& exception_state) const { } DOMMatrix* DOMMatrixReadOnly::multiply(DOMMatrix* matrix, ExceptionState& exception_state) const { - NativeValue arguments[] = { - NativeValueConverter>::ToNativeValue(matrix) - }; + NativeValue arguments[] = {NativeValueConverter>::ToNativeValue(matrix)}; NativeValue value = InvokeBindingMethod(binding_call_methods::kmultiply, sizeof(arguments) / sizeof(NativeValue), arguments, FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = @@ -325,7 +322,7 @@ DOMMatrix* DOMMatrixReadOnly::rotateFromVector(double x, double y, ExceptionStat } DOMMatrix* DOMMatrixReadOnly::scale(ExceptionState& exception_state) const { - return this->scale(1, 1,1, 0, 0, 0, exception_state); + return this->scale(1, 1, 1, 0, 0, 0, exception_state); } DOMMatrix* DOMMatrixReadOnly::scale(double sx, ExceptionState& exception_state) const { return this->scale(sx, 1, 1, 0, 0, 0, exception_state); @@ -339,7 +336,12 @@ DOMMatrix* DOMMatrixReadOnly::scale(double sx, double sy, double sz, ExceptionSt DOMMatrix* DOMMatrixReadOnly::scale(double sx, double sy, double sz, double ox, ExceptionState& exception_state) const { return this->scale(sx, sy, sz, ox, 0, 0, exception_state); } -DOMMatrix* DOMMatrixReadOnly::scale(double sx, double sy, double sz, double ox, double oy, ExceptionState& exception_state) const { +DOMMatrix* DOMMatrixReadOnly::scale(double sx, + double sy, + double sz, + double ox, + double oy, + ExceptionState& exception_state) const { return this->scale(sx, sy, sz, ox, oy, 0, exception_state); } DOMMatrix* DOMMatrixReadOnly::scale(double sx, @@ -365,7 +367,7 @@ DOMMatrix* DOMMatrixReadOnly::scale(double sx, } DOMMatrix* DOMMatrixReadOnly::scale3d(ExceptionState& exception_state) const { - return this->scale3d(1, 0,0, 0, exception_state); + return this->scale3d(1, 0, 0, 0, exception_state); } DOMMatrix* DOMMatrixReadOnly::scale3d(double scale, ExceptionState& exception_state) const { return this->scale3d(scale, 0, 0, 0, exception_state); @@ -458,18 +460,16 @@ DOMMatrix* DOMMatrixReadOnly::skewY(double sy, ExceptionState& exception_state) // } // toJSON(): DartImpl; AtomicString DOMMatrixReadOnly::toString(ExceptionState& exception_state) const { - NativeValue dart_result = - InvokeBindingMethod(binding_call_methods::ktoString, 0, nullptr, - FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue dart_result = InvokeBindingMethod(binding_call_methods::ktoString, 0, nullptr, + FlushUICommandReason::kDependentsOnElement, exception_state); return NativeValueConverter::FromNativeValue(ctx(), std::move(dart_result)); } DOMPoint* DOMMatrixReadOnly::transformPoint(DOMPoint* point, ExceptionState& exception_state) const { - NativeValue arguments[] = { - NativeValueConverter>::ToNativeValue(point) - }; - NativeValue value = InvokeBindingMethod(binding_call_methods::ktransformPoint, sizeof(arguments) / sizeof(NativeValue), - arguments, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue arguments[] = {NativeValueConverter>::ToNativeValue(point)}; + NativeValue value = + InvokeBindingMethod(binding_call_methods::ktransformPoint, sizeof(arguments) / sizeof(NativeValue), arguments, + FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = NativeValueConverter>::FromNativeValue(value); diff --git a/bridge/core/geometry/dom_matrix_read_only.h b/bridge/core/geometry/dom_matrix_read_only.h index dc489f6e49..13be749d0b 100644 --- a/bridge/core/geometry/dom_matrix_read_only.h +++ b/bridge/core/geometry/dom_matrix_read_only.h @@ -23,8 +23,7 @@ class DOMMatrixReadOnly : public BindingObject { static DOMMatrixReadOnly* Create(ExecutingContext* context, const std::shared_ptr& init, ExceptionState& exception_state); - static DOMMatrixReadOnly* Create(ExecutingContext* context, - ExceptionState& exception_state); + static DOMMatrixReadOnly* Create(ExecutingContext* context, ExceptionState& exception_state); static DOMMatrix* fromMatrix(ExecutingContext* context, DOMMatrixReadOnly* matrix, ExceptionState& exception_state); DOMMatrixReadOnly() = delete; @@ -101,7 +100,8 @@ class DOMMatrixReadOnly : public BindingObject { DOMMatrix* scale(double sx, double sy, double sz, ExceptionState& exception_state) const; DOMMatrix* scale(double sx, double sy, double sz, double ox, ExceptionState& exception_state) const; DOMMatrix* scale(double sx, double sy, double sz, double ox, double oy, ExceptionState& exception_state) const; - DOMMatrix* scale(double sx, double sy, double sz, double ox, double oy, double oz, ExceptionState& exception_state) const; + DOMMatrix* scale(double sx, double sy, double sz, double ox, double oy, double oz, ExceptionState& exception_state) + const; DOMMatrix* scale3d(ExceptionState& exception_state) const; DOMMatrix* scale3d(double scale, ExceptionState& exception_state) const; DOMMatrix* scale3d(double scale, double ox, ExceptionState& exception_state) const; @@ -127,13 +127,13 @@ class DOMMatrixReadOnly : public BindingObject { int32_t argc, const NativeValue* argv, Dart_Handle dart_object) override; + protected: explicit DOMMatrixReadOnly(ExecutingContext* context, NativeBindingObject* native_binding_object); -private: + private: [[nodiscard]] double getMatrixProperty(const AtomicString& prop) const; void setMatrixProperty(const AtomicString& prop, double v, ExceptionState& exception_state); - }; } // namespace webf diff --git a/bridge/core/geometry/dom_point.cc b/bridge/core/geometry/dom_point.cc index 19507d1613..695c3ce6b7 100644 --- a/bridge/core/geometry/dom_point.cc +++ b/bridge/core/geometry/dom_point.cc @@ -29,7 +29,7 @@ DOMPoint* DOMPoint::Create(ExecutingContext* context, return MakeGarbageCollected(context, init, y, z, exception_state); } DOMPoint* DOMPoint::Create(ExecutingContext* context, - const std::shared_ptr& init , + const std::shared_ptr& init, double y, double z, double w, diff --git a/bridge/core/geometry/dom_point.h b/bridge/core/geometry/dom_point.h index d62b31d797..bfe59305d1 100644 --- a/bridge/core/geometry/dom_point.h +++ b/bridge/core/geometry/dom_point.h @@ -63,4 +63,4 @@ struct DowncastTraits { }; } // namespace webf -#endif // WEBF_CORE_GEOMETRY_DOM_POINT_H_ +#endif // WEBF_CORE_GEOMETRY_DOM_POINT_H_ diff --git a/bridge/core/geometry/dom_point_read_only.cc b/bridge/core/geometry/dom_point_read_only.cc index c586f6cb58..97293d1322 100644 --- a/bridge/core/geometry/dom_point_read_only.cc +++ b/bridge/core/geometry/dom_point_read_only.cc @@ -4,11 +4,11 @@ #include "dom_point_read_only.h" #include "binding_call_methods.h" -#include "native_value_converter.h" #include "bindings/qjs/converter_impl.h" #include "core/executing_context.h" -#include "core/geometry/dom_point.h" #include "core/geometry/dom_matrix.h" +#include "core/geometry/dom_point.h" +#include "native_value_converter.h" namespace webf { @@ -42,7 +42,9 @@ DOMPointReadOnly* DOMPointReadOnly::Create(webf::ExecutingContext* context, return MakeGarbageCollected(context, init, y, z, w, exception_state); } -DOMPoint* DOMPointReadOnly::fromPoint(ExecutingContext* context, DOMPointReadOnly* point, ExceptionState& exception_state) { +DOMPoint* DOMPointReadOnly::fromPoint(ExecutingContext* context, + DOMPointReadOnly* point, + ExceptionState& exception_state) { NativeValue arguments[] = {NativeValueConverter>::ToNativeValue(point)}; AtomicString module_name = AtomicString(context->ctx(), "DOMPoint"); AtomicString method_name = AtomicString(context->ctx(), "fromPoint"); @@ -67,7 +69,9 @@ DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context, webf::Except CreateBindingObjectType::kCreateDOMPoint, nullptr, 0); } -DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context, const std::shared_ptr& init, webf::ExceptionState& exception_state) +DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context, + const std::shared_ptr& init, + webf::ExceptionState& exception_state) : BindingObject(context->ctx()) { this->createWithDOMPointInit(context, exception_state, init); } @@ -172,11 +176,10 @@ void DOMPointReadOnly::setW(double v, ExceptionState& exception_state) { } DOMPoint* DOMPointReadOnly::matrixTransform(DOMMatrix* matrix, ExceptionState& exception_state) const { - NativeValue arguments[] = { - NativeValueConverter>::ToNativeValue(matrix) - }; - NativeValue value = InvokeBindingMethod(binding_call_methods::kmatrixTransform, sizeof(arguments) / sizeof(NativeValue), - arguments, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue arguments[] = {NativeValueConverter>::ToNativeValue(matrix)}; + NativeValue value = + InvokeBindingMethod(binding_call_methods::kmatrixTransform, sizeof(arguments) / sizeof(NativeValue), arguments, + FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = NativeValueConverter>::FromNativeValue(value); @@ -186,7 +189,7 @@ DOMPoint* DOMPointReadOnly::matrixTransform(DOMMatrix* matrix, ExceptionState& e } NativeValue DOMPointReadOnly::HandleCallFromDartSide(const AtomicString& method, - int32_t argc, + int32_t argc, const NativeValue* argv, Dart_Handle dart_object) { return Native_NewNull(); diff --git a/bridge/core/geometry/dom_point_read_only.h b/bridge/core/geometry/dom_point_read_only.h index 833574fd86..93321654a5 100644 --- a/bridge/core/geometry/dom_point_read_only.h +++ b/bridge/core/geometry/dom_point_read_only.h @@ -81,7 +81,8 @@ class DOMPointReadOnly : public BindingObject { int32_t argc, const NativeValue* argv, Dart_Handle dart_object) override; -protected: + + protected: explicit DOMPointReadOnly(ExecutingContext* context, NativeBindingObject* native_binding_object); private: @@ -92,7 +93,7 @@ class DOMPointReadOnly : public BindingObject { double w = 0, double z = 1); - [[nodiscard]] double getPointProperty(const AtomicString& prop) const; + [[nodiscard]] double getPointProperty(const AtomicString& prop) const; void setPointProperty(const AtomicString& prop, double v, ExceptionState& exception_state); }; diff --git a/bridge/core/html/canvas/canvas_rendering_context_2d.h b/bridge/core/html/canvas/canvas_rendering_context_2d.h index 43bc0b76d7..fd7494dd5e 100644 --- a/bridge/core/html/canvas/canvas_rendering_context_2d.h +++ b/bridge/core/html/canvas/canvas_rendering_context_2d.h @@ -7,8 +7,8 @@ #include "canvas_gradient.h" #include "canvas_pattern.h" -#include "path_2d.h" #include "canvas_rendering_context.h" +#include "path_2d.h" #include "qjs_union_dom_stringcanvas_gradient.h" #include "qjs_unionhtml_image_elementhtml_canvas_element.h" #include "qjs_unionpath_2_d_dom_string.h" @@ -48,7 +48,9 @@ class CanvasRenderingContext2D : public CanvasRenderingContext { void fill(ExceptionState& exception_state); void fill(std::shared_ptr pathOrPattern, ExceptionState& exception_state); - void fill(std::shared_ptr pathOrPattern, const AtomicString& fillRule, ExceptionState& exception_state); + void fill(std::shared_ptr pathOrPattern, + const AtomicString& fillRule, + ExceptionState& exception_state); std::shared_ptr strokeStyle(); void setStrokeStyle(const std::shared_ptr& style, ExceptionState& exception_state); diff --git a/bridge/core/html/canvas/path_2d.cc b/bridge/core/html/canvas/path_2d.cc index 88446f0d75..e60b482b4d 100644 --- a/bridge/core/html/canvas/path_2d.cc +++ b/bridge/core/html/canvas/path_2d.cc @@ -18,8 +18,7 @@ Path2D* Path2D::Create(ExecutingContext* context, return MakeGarbageCollected(context, init, exception_state); } -Path2D::Path2D(ExecutingContext* context, ExceptionState& exception_state) - : BindingObject(context->ctx()) { +Path2D::Path2D(ExecutingContext* context, ExceptionState& exception_state) : BindingObject(context->ctx()) { GetExecutingContext()->dartMethodPtr()->createBindingObject(GetExecutingContext()->isDedicated(), GetExecutingContext()->contextId(), bindingObject(), CreateBindingObjectType::kCreatePath2D, nullptr, 0); @@ -28,7 +27,7 @@ Path2D::Path2D(ExecutingContext* context, ExceptionState& exception_state) Path2D::Path2D(ExecutingContext* context, const std::shared_ptr& init, ExceptionState& exception_state) - : BindingObject(context->ctx()) { + : BindingObject(context->ctx()) { NativeValue arguments[1]; if (init->IsDomString()) { arguments[0] = NativeValueConverter::ToNativeValue(ctx(), init->GetAsDomString()); @@ -43,7 +42,7 @@ Path2D::Path2D(ExecutingContext* context, void Path2D::addPath(Path2D* path, DOMMatrixReadOnly* dom_matrix, ExceptionState& exception_state) { NativeValue arguments[] = {NativeValueConverter>::ToNativeValue(path), - NativeValueConverter>::ToNativeValue(dom_matrix)}; + NativeValueConverter>::ToNativeValue(dom_matrix)}; InvokeBindingMethod(binding_call_methods::kaddPath, 2, arguments, FlushUICommandReason::kDependentsOnElement, exception_state); } @@ -79,9 +78,9 @@ void Path2D::roundRect(double x, } NativeValue Path2D::HandleCallFromDartSide(const AtomicString& method, - int32_t argc, - const NativeValue* argv, - Dart_Handle dart_object) { + int32_t argc, + const NativeValue* argv, + Dart_Handle dart_object) { return Native_NewNull(); } diff --git a/bridge/core/html/canvas/path_2d.h b/bridge/core/html/canvas/path_2d.h index 65eed77122..a9c5ac66ce 100644 --- a/bridge/core/html/canvas/path_2d.h +++ b/bridge/core/html/canvas/path_2d.h @@ -8,8 +8,8 @@ #include "bindings/qjs/script_wrappable.h" #include "core/binding_object.h" #include "core/geometry/dom_matrix.h" -#include "qjs_unionpath_2_d_dom_string.h" #include "qjs_union_double_sequencedouble.h" +#include "qjs_unionpath_2_d_dom_string.h" namespace webf { @@ -19,7 +19,7 @@ class Path2D : public BindingObject { public: using ImplType = Path2D*; static Path2D* Create(ExecutingContext* context, ExceptionState& exception_state); - static Path2D* Create(ExecutingContext* context, + static Path2D* Create(ExecutingContext* context, const std::shared_ptr& init, ExceptionState& exception_state); Path2D() = delete; @@ -40,13 +40,13 @@ class Path2D : public BindingObject { ExceptionState& exception_state); NativeValue HandleCallFromDartSide(const AtomicString& method, - int32_t argc, - const NativeValue* argv, - Dart_Handle dart_object) override; + int32_t argc, + const NativeValue* argv, + Dart_Handle dart_object) override; - private: + private: }; // namespace webf -} +} // namespace webf #endif // WEBF_CORE_HTML_CANVAS_CANVAS_PATH_2D_H_a \ No newline at end of file diff --git a/bridge/core/page.cc b/bridge/core/page.cc index f99fc30963..d84054aee9 100644 --- a/bridge/core/page.cc +++ b/bridge/core/page.cc @@ -87,7 +87,7 @@ NativeValue* WebFPage::invokeModuleEvent(SharedNativeString* native_module_name, if (listener == nullptr) { return nullptr; } - + auto callback_value = listener->value(); if (auto* callback = DynamicTo(callback_value.get())) { ScriptValue arguments[] = {event != nullptr ? event->ToValue() : ScriptValue::Empty(ctx), extraObject}; @@ -108,22 +108,21 @@ NativeValue* WebFPage::invokeModuleEvent(SharedNativeString* native_module_name, memcpy(return_value, &tmp, sizeof(NativeValue)); return return_value; } else if (auto* callback = DynamicTo(callback_value.get())) { - NativeValue* params = new NativeValue[2]; - + NativeValue* params = new NativeValue[2]; + ExceptionState exception_state; ScriptValue eventValue = event != nullptr ? event->ToValue() : ScriptValue::Empty(ctx); params[0] = eventValue.ToNative(ctx, exception_state); - params[1] = *extra; - - + params[1] = *extra; + if (exception_state.HasException()) { context_->HandleException(exception_state); return nullptr; - } + } callback->Invoke(context_, 2, params); return nullptr; - } + } } bool WebFPage::evaluateScript(const char* script, diff --git a/bridge/foundation/dart_readable.cc b/bridge/foundation/dart_readable.cc index 73801a83b2..9b475e552d 100644 --- a/bridge/foundation/dart_readable.cc +++ b/bridge/foundation/dart_readable.cc @@ -44,5 +44,4 @@ void DartReadable::operator delete[](void* memory) noexcept { dart_free(memory); } - } // namespace webf diff --git a/bridge/include/plugin_api/executing_context.h b/bridge/include/plugin_api/executing_context.h index f1237d2521..b4ce30b3d3 100644 --- a/bridge/include/plugin_api/executing_context.h +++ b/bridge/include/plugin_api/executing_context.h @@ -5,10 +5,10 @@ #ifndef WEBF_CORE_RUST_API_EXECUTING_CONTEXT_H_ #define WEBF_CORE_RUST_API_EXECUTING_CONTEXT_H_ -#include "foundation/native_value.h" #include "core/native/native_function.h" #include "document.h" #include "exception_state.h" +#include "foundation/native_value.h" #include "window.h" namespace webf { @@ -21,29 +21,23 @@ using PublicContextGetDocument = WebFValue (*)( using PublicContextGetWindow = WebFValue (*)(ExecutingContext*); using PublicContextGetExceptionState = WebFValue (*)(); using PublicFinishRecordingUIOperations = void (*)(ExecutingContext* context); -using PublicWebFInvokeModule = NativeValue (*)(ExecutingContext*, - const char*, - const char*, - SharedExceptionState*); -using PublicWebFInvokeModuleWithParams = NativeValue (*)(ExecutingContext*, - const char*, - const char*, - NativeValue*, - SharedExceptionState*); +using PublicWebFInvokeModule = NativeValue (*)(ExecutingContext*, const char*, const char*, SharedExceptionState*); +using PublicWebFInvokeModuleWithParams = + NativeValue (*)(ExecutingContext*, const char*, const char*, NativeValue*, SharedExceptionState*); using PublicWebFInvokeModuleWithParamsAndCallback = NativeValue (*)(ExecutingContext*, - const char*, - const char*, - NativeValue*, - WebFNativeFunctionContext*, - SharedExceptionState*); + const char*, + const char*, + NativeValue*, + WebFNativeFunctionContext*, + SharedExceptionState*); using PublicContextSetTimeout = int32_t (*)(ExecutingContext*, WebFNativeFunctionContext*, int32_t, SharedExceptionState*); using PublicContextSetInterval = int32_t (*)(ExecutingContext*, - WebFNativeFunctionContext*, - int32_t, - SharedExceptionState*); + WebFNativeFunctionContext*, + int32_t, + SharedExceptionState*); using PublicContextClearTimeout = void (*)(ExecutingContext*, int32_t, SharedExceptionState*); using PublicContextClearInterval = void (*)(ExecutingContext*, int32_t, SharedExceptionState*); @@ -55,30 +49,32 @@ struct ExecutingContextWebFMethods { static WebFValue CreateExceptionState(); static void FinishRecordingUIOperations(ExecutingContext* context); static NativeValue WebFInvokeModule(ExecutingContext* context, - const char* module_name, - const char* method, - SharedExceptionState* shared_exception_state); + const char* module_name, + const char* method, + SharedExceptionState* shared_exception_state); static NativeValue WebFInvokeModuleWithParams(ExecutingContext* context, - const char* module_name, - const char* method, - NativeValue* params, - SharedExceptionState* shared_exception_state); + const char* module_name, + const char* method, + NativeValue* params, + SharedExceptionState* shared_exception_state); static NativeValue WebFInvokeModuleWithParamsAndCallback(ExecutingContext* context, - const char* module_name, - const char* method, - NativeValue* params, - WebFNativeFunctionContext* callback_context, - SharedExceptionState* shared_exception_state); + const char* module_name, + const char* method, + NativeValue* params, + WebFNativeFunctionContext* callback_context, + SharedExceptionState* shared_exception_state); static int32_t SetTimeout(ExecutingContext* context, WebFNativeFunctionContext* callback_context, int32_t timeout, SharedExceptionState* shared_exception_state); static int32_t SetInterval(ExecutingContext* context, - WebFNativeFunctionContext* callback_context, - int32_t timeout, - SharedExceptionState* shared_exception_state); + WebFNativeFunctionContext* callback_context, + int32_t timeout, + SharedExceptionState* shared_exception_state); static void ClearTimeout(ExecutingContext* context, int32_t timeout_id, SharedExceptionState* shared_exception_state); - static void ClearInterval(ExecutingContext* context, int32_t interval_id, SharedExceptionState* shared_exception_state); + static void ClearInterval(ExecutingContext* context, + int32_t interval_id, + SharedExceptionState* shared_exception_state); double version{1.0}; PublicContextGetDocument context_get_document{document}; @@ -87,7 +83,8 @@ struct ExecutingContextWebFMethods { PublicFinishRecordingUIOperations context_finish_recording_ui_operations{FinishRecordingUIOperations}; PublicWebFInvokeModule context_webf_invoke_module{WebFInvokeModule}; PublicWebFInvokeModuleWithParams context_webf_invoke_module_with_params{WebFInvokeModuleWithParams}; - PublicWebFInvokeModuleWithParamsAndCallback context_webf_invoke_module_with_params_and_callback{WebFInvokeModuleWithParamsAndCallback}; + PublicWebFInvokeModuleWithParamsAndCallback context_webf_invoke_module_with_params_and_callback{ + WebFInvokeModuleWithParamsAndCallback}; PublicContextSetTimeout context_set_timeout{SetTimeout}; PublicContextSetInterval context_set_interval{SetInterval}; PublicContextClearTimeout context_clear_timeout{ClearTimeout};