From 428635475539e80d5ba49a820c36a085aeb5797f Mon Sep 17 00:00:00 2001 From: openwebf-bot Date: Thu, 28 Dec 2023 07:52:51 +0000 Subject: [PATCH] Committing clang-format changes --- bridge/core/binding_object.cc | 14 +++++----- bridge/core/binding_object.h | 2 +- .../css/computed_css_style_declaration.cc | 20 ++++++++++---- bridge/core/dart_isolate_context.cc | 16 ++++++----- bridge/core/dart_isolate_context.h | 6 +++-- bridge/core/dart_methods.cc | 27 ++++++++++++------- bridge/core/dom/element.cc | 16 +++++++---- bridge/core/dom/legacy/element_attributes.cc | 6 +++-- bridge/core/frame/legacy/location.cc | 2 +- bridge/core/frame/window.cc | 27 ++++++++++++++----- bridge/core/html/canvas/canvas_pattern.cc | 3 ++- .../canvas/canvas_rendering_context_2d.cc | 10 ++++--- .../core/html/canvas/html_canvas_element.cc | 3 ++- bridge/core/html/html_image_element.cc | 3 ++- bridge/foundation/ui_command_buffer.cc | 10 +++---- bridge/include/webf_bridge.h | 11 ++++++-- bridge/multiple_threading/dispatcher.cc | 12 +++++---- bridge/multiple_threading/dispatcher.h | 5 ++-- bridge/multiple_threading/task.h | 5 ++-- bridge/webf_bridge.cc | 6 +++-- bridge/webf_bridge_test.cc | 3 ++- 21 files changed, 136 insertions(+), 71 deletions(-) diff --git a/bridge/core/binding_object.cc b/bridge/core/binding_object.cc index 79f87868c1..0cb6458680 100644 --- a/bridge/core/binding_object.cc +++ b/bridge/core/binding_object.cc @@ -118,9 +118,10 @@ NativeValue BindingObject::InvokeBindingMethod(const AtomicString& method, GetDispatcher()->PostToDartSync( GetExecutingContext()->isDedicated(), contextId(), - [&](bool cancel, double contextId, const NativeBindingObject* binding_object, NativeValue* return_value, NativeValue* method, - int32_t argc, const NativeValue* argv) { - if (cancel) return; + [&](bool cancel, double contextId, const NativeBindingObject* binding_object, NativeValue* return_value, + NativeValue* method, int32_t argc, const NativeValue* argv) { + if (cancel) + return; #if ENABLE_LOG WEBF_LOG(INFO) << "[Dispatcher]: PostToDartSync method: InvokeBindingMethod; Callback Start"; @@ -159,9 +160,10 @@ NativeValue BindingObject::InvokeBindingMethod(BindingMethodCallOperations bindi NativeValue native_method = NativeValueConverter::ToNativeValue(binding_method_call_operation); GetDispatcher()->PostToDartSync( GetExecutingContext()->isDedicated(), contextId(), - [&](bool cancel, double contextId, const NativeBindingObject* binding_object, NativeValue* return_value, NativeValue* method, - int32_t argc, const NativeValue* argv) { - if (cancel) return; + [&](bool cancel, double contextId, const NativeBindingObject* binding_object, NativeValue* return_value, + NativeValue* method, int32_t argc, const NativeValue* argv) { + if (cancel) + return; #if ENABLE_LOG WEBF_LOG(INFO) << "[Dispatcher]: PostToDartSync method: InvokeBindingMethod; Callback Start"; diff --git a/bridge/core/binding_object.h b/bridge/core/binding_object.h index 13751cb0b5..3bded23de2 100644 --- a/bridge/core/binding_object.h +++ b/bridge/core/binding_object.h @@ -11,9 +11,9 @@ #include #include "bindings/qjs/atomic_string.h" #include "bindings/qjs/script_wrappable.h" +#include "core/dart_methods.h" #include "foundation/native_type.h" #include "foundation/native_value.h" -#include "core/dart_methods.h" namespace webf { diff --git a/bridge/core/css/computed_css_style_declaration.cc b/bridge/core/css/computed_css_style_declaration.cc index 3392301e22..ac331e22ca 100644 --- a/bridge/core/css/computed_css_style_declaration.cc +++ b/bridge/core/css/computed_css_style_declaration.cc @@ -34,7 +34,9 @@ bool ComputedCssStyleDeclaration::SetItem(const AtomicString& key, NativeValue arguments[] = { NativeValueConverter::ToNativeValue(ctx(), key), NativeValueConverter::ToNativeValue(ctx(), value.ToLegacyDOMString(ctx()))}; - InvokeBindingMethod(binding_call_methods::ksetProperty, 2, arguments, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + InvokeBindingMethod(binding_call_methods::ksetProperty, 2, arguments, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, + exception_state); return true; } @@ -43,7 +45,9 @@ bool ComputedCssStyleDeclaration::DeleteItem(const webf::AtomicString& key, webf } int64_t ComputedCssStyleDeclaration::length() const { - NativeValue result = GetBindingProperty(binding_call_methods::klength, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, ASSERT_NO_EXCEPTION()); + NativeValue result = GetBindingProperty( + binding_call_methods::klength, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, ASSERT_NO_EXCEPTION()); return NativeValueConverter::FromNativeValue(result); } @@ -59,19 +63,25 @@ void ComputedCssStyleDeclaration::setProperty(const AtomicString& key, AtomicString ComputedCssStyleDeclaration::removeProperty(const AtomicString& key, ExceptionState& exception_state) { NativeValue arguments[] = {NativeValueConverter::ToNativeValue(ctx(), key)}; - NativeValue result = InvokeBindingMethod(binding_call_methods::kremoveProperty, 1, arguments, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + NativeValue result = InvokeBindingMethod( + binding_call_methods::kremoveProperty, 1, arguments, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); return NativeValueConverter::FromNativeValue(ctx(), std::move(result)); } bool ComputedCssStyleDeclaration::NamedPropertyQuery(const AtomicString& key, ExceptionState& exception_state) { NativeValue arguments[] = {NativeValueConverter::ToNativeValue(ctx(), key)}; - NativeValue result = InvokeBindingMethod(binding_call_methods::kcheckCSSProperty, 1, arguments, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + NativeValue result = InvokeBindingMethod( + binding_call_methods::kcheckCSSProperty, 1, arguments, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); return NativeValueConverter::FromNativeValue(result); } void ComputedCssStyleDeclaration::NamedPropertyEnumerator(std::vector& names, ExceptionState& exception_state) { - NativeValue result = InvokeBindingMethod(binding_call_methods::kgetFullCSSPropertyList, 0, nullptr, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + NativeValue result = InvokeBindingMethod( + binding_call_methods::kgetFullCSSPropertyList, 0, nullptr, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); auto&& arr = NativeValueConverter>::FromNativeValue(ctx(), result); for (auto& i : arr) { names.emplace_back(i); diff --git a/bridge/core/dart_isolate_context.cc b/bridge/core/dart_isolate_context.cc index 296f8e3e48..f1fc7d9d5a 100644 --- a/bridge/core/dart_isolate_context.cc +++ b/bridge/core/dart_isolate_context.cc @@ -122,7 +122,7 @@ void DartIsolateContext::Dispose(multi_threading::Callback callback) { running_dart_isolates--; FinalizeJSRuntime(); callback(); - }); + }); } void DartIsolateContext::InitializeNewPageInJSThread(PageGroup* page_group, @@ -142,7 +142,8 @@ void DartIsolateContext::DisposePageAndKilledJSThread(DartIsolateContext* dart_i Dart_Handle dart_handle, DisposePageCallback result_callback) { delete page; - dart_isolate_context->dispatcher_->PostToDart(true, HandleDisposePageAndKillJSThread, dart_isolate_context, thread_group_id, dart_handle, result_callback); + dart_isolate_context->dispatcher_->PostToDart(true, HandleDisposePageAndKillJSThread, dart_isolate_context, + thread_group_id, dart_handle, result_callback); } void DartIsolateContext::DisposePageInJSThread(DartIsolateContext* dart_isolate_context, @@ -201,7 +202,10 @@ void DartIsolateContext::HandleDisposePage(Dart_Handle persistent_handle, Dispos Dart_DeletePersistentHandle_DL(persistent_handle); } -void DartIsolateContext::HandleDisposePageAndKillJSThread(DartIsolateContext* dart_isolate_context, int thread_group_id, Dart_Handle persistent_handle, DisposePageCallback result_callback) { +void DartIsolateContext::HandleDisposePageAndKillJSThread(DartIsolateContext* dart_isolate_context, + int thread_group_id, + Dart_Handle persistent_handle, + DisposePageCallback result_callback) { dart_isolate_context->dispatcher_->KillJSThreadSync(thread_group_id); Dart_Handle handle = Dart_HandleFromPersistent_DL(persistent_handle); @@ -223,10 +227,8 @@ void DartIsolateContext::RemovePage(double thread_identity, if (page_group->Empty()) { page->executingContext()->SetContextInValid(); - dispatcher_->PostToJs( - true, thread_group_id, DisposePageAndKilledJSThread, - this, page, thread_group_id, - dart_handle, result_callback); + dispatcher_->PostToJs(true, thread_group_id, DisposePageAndKilledJSThread, this, page, thread_group_id, dart_handle, + result_callback); } else { dispatcher_->PostToJs(true, thread_group_id, DisposePageInJSThread, this, page, dart_handle, result_callback); } diff --git a/bridge/core/dart_isolate_context.h b/bridge/core/dart_isolate_context.h index c460fae947..8ee9ec7e26 100644 --- a/bridge/core/dart_isolate_context.h +++ b/bridge/core/dart_isolate_context.h @@ -29,7 +29,6 @@ class PageGroup { std::vector pages_; }; - struct DartWireContext { ScriptValue jsObject; }; @@ -85,7 +84,10 @@ class DartIsolateContext { AllocateNewPageCallback result_callback, WebFPage* new_page); static void HandleDisposePage(Dart_Handle persistent_handle, DisposePageCallback result_callback); - static void HandleDisposePageAndKillJSThread(DartIsolateContext* dart_isolate_context, int thread_group_id, Dart_Handle persistent_handle, DisposePageCallback result_callback); + static void HandleDisposePageAndKillJSThread(DartIsolateContext* dart_isolate_context, + int thread_group_id, + Dart_Handle persistent_handle, + DisposePageCallback result_callback); int is_valid_{false}; std::thread::id running_thread_; diff --git a/bridge/core/dart_methods.cc b/bridge/core/dart_methods.cc index 4d7133b020..18ca6dd8ae 100644 --- a/bridge/core/dart_methods.cc +++ b/bridge/core/dart_methods.cc @@ -51,7 +51,8 @@ NativeValue* DartMethodPointer::invokeModule(bool is_dedicated, is_dedicated, context_id, [&](bool cancel, void* callback_context, double context_id, SharedNativeString* moduleName, SharedNativeString* method, NativeValue* params, AsyncModuleCallback callback) -> webf::NativeValue* { - if (cancel) return nullptr; + if (cancel) + return nullptr; return invoke_module_(callback_context, context_id, moduleName, method, params, callback); }, callback_context, context_id, moduleName, method, params, callback); @@ -168,7 +169,10 @@ void DartMethodPointer::toBlob(bool is_dedicated, element_ptr, devicePixelRatio); } -void DartMethodPointer::flushUICommand(bool is_dedicated, double context_id, void* native_binding_object, uint32_t reason) { +void DartMethodPointer::flushUICommand(bool is_dedicated, + double context_id, + void* native_binding_object, + uint32_t reason) { #if ENABLE_LOG WEBF_LOG(INFO) << "[Dispatcher] DartMethodPointer::flushUICommand SYNC call START"; #endif @@ -176,7 +180,8 @@ void DartMethodPointer::flushUICommand(bool is_dedicated, double context_id, voi dart_isolate_context_->dispatcher()->PostToDartSync( is_dedicated, context_id, [&](bool cancel, double context_id, void* native_binding_object, uint32_t reason) -> void { - if (cancel) return; + if (cancel) + return; flush_ui_command_(context_id, native_binding_object, reason); }, @@ -200,7 +205,8 @@ void DartMethodPointer::createBindingObject(bool is_dedicated, dart_isolate_context_->dispatcher()->PostToDartSync( is_dedicated, context_id, [&](bool cancel, double context_id, void* native_binding_object, int32_t type, void* args, int32_t argc) -> void { - if (cancel) return; + if (cancel) + return; create_binding_object_(context_id, native_binding_object, type, args, argc); }, context_id, native_binding_object, type, args, argc); @@ -221,7 +227,8 @@ bool DartMethodPointer::getWidgetElementShape(bool is_dedicated, int8_t is_success = dart_isolate_context_->dispatcher()->PostToDartSync( is_dedicated, context_id, [&](bool cancel, double context_id, void* native_binding_object, NativeValue* value) -> int8_t { - if (cancel) return 0; + if (cancel) + return 0; return get_widget_element_shape_(context_id, native_binding_object, value); }, context_id, native_binding_object, value); @@ -279,10 +286,12 @@ const char* DartMethodPointer::environment(bool is_dedicated, double context_id) #if ENABLE_LOG WEBF_LOG(INFO) << "[Dispatcher] DartMethodPointer::environment callSync START"; #endif - const char* result = dart_isolate_context_->dispatcher()->PostToDartSync(is_dedicated, context_id, [&](bool cancel) -> const char* { - if (cancel) return nullptr; - return environment_(); - }); + const char* result = + dart_isolate_context_->dispatcher()->PostToDartSync(is_dedicated, context_id, [&](bool cancel) -> const char* { + if (cancel) + return nullptr; + return environment_(); + }); #if ENABLE_LOG WEBF_LOG(INFO) << "[Dispatcher] DartMethodPointer::environment callSync END"; diff --git a/bridge/core/dom/element.cc b/bridge/core/dom/element.cc index 85c4cf8038..a0390765ca 100644 --- a/bridge/core/dom/element.cc +++ b/bridge/core/dom/element.cc @@ -82,7 +82,9 @@ BoundingClientRect* Element::getBoundingClientRect(ExceptionState& exception_sta } std::vector Element::getClientRects(ExceptionState& exception_state) { - NativeValue result = InvokeBindingMethod(binding_call_methods::kgetClientRects, 0, nullptr, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + NativeValue result = InvokeBindingMethod( + binding_call_methods::kgetClientRects, 0, nullptr, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); if (exception_state.HasException()) { return {}; } @@ -144,7 +146,9 @@ void Element::scrollBy(const std::shared_ptr& options, Exceptio NativeValueConverter::ToNativeValue(options->hasLeft() ? options->left() : 0.0), NativeValueConverter::ToNativeValue(options->hasTop() ? options->top() : 0.0), }; - InvokeBindingMethod(binding_call_methods::kscrollBy, 2, args, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + InvokeBindingMethod(binding_call_methods::kscrollBy, 2, args, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, + exception_state); } void Element::scrollTo(ExceptionState& exception_state) { @@ -387,7 +391,8 @@ class ElementSnapshotReader { }; void ElementSnapshotReader::Start() { - context_->FlushUICommand(element_, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout); + context_->FlushUICommand(element_, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout); auto callback = [](void* ptr, double contextId, char* error, uint8_t* bytes, int32_t length) -> void { auto* reader = static_cast(ptr); @@ -429,8 +434,9 @@ void ElementSnapshotReader::HandleFailed(const char* error) { ScriptPromise Element::toBlob(ExceptionState& exception_state) { Window* window = GetExecutingContext()->window(); - double device_pixel_ratio = NativeValueConverter::FromNativeValue( - window->GetBindingProperty(binding_call_methods::kdevicePixelRatio, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state)); + double device_pixel_ratio = NativeValueConverter::FromNativeValue(window->GetBindingProperty( + binding_call_methods::kdevicePixelRatio, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state)); return toBlob(device_pixel_ratio, exception_state); } diff --git a/bridge/core/dom/legacy/element_attributes.cc b/bridge/core/dom/legacy/element_attributes.cc index ed904e84e9..a37eca9899 100644 --- a/bridge/core/dom/legacy/element_attributes.cc +++ b/bridge/core/dom/legacy/element_attributes.cc @@ -31,7 +31,8 @@ AtomicString ElementAttributes::getAttribute(const AtomicString& name, Exception if (attributes_.count(name) == 0) { if (element_->IsWidgetElement()) { // Fallback to directly FFI access to dart. - NativeValue dart_result = element_->GetBindingProperty(name, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue dart_result = + element_->GetBindingProperty(name, FlushUICommandReason::kDependentsOnElement, exception_state); if (dart_result.tag == NativeTag::TAG_STRING) { return NativeValueConverter::FromNativeValue(element_->ctx(), std::move(dart_result)); } @@ -83,7 +84,8 @@ bool ElementAttributes::hasAttribute(const AtomicString& name, ExceptionState& e if (!has_attribute && element_->IsWidgetElement()) { // Fallback to directly FFI access to dart. - NativeValue dart_result = element_->GetBindingProperty(name, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue dart_result = + element_->GetBindingProperty(name, FlushUICommandReason::kDependentsOnElement, exception_state); return dart_result.tag != NativeTag::TAG_NULL; } diff --git a/bridge/core/frame/legacy/location.cc b/bridge/core/frame/legacy/location.cc index 04a6d3fd10..f6cc9e0593 100644 --- a/bridge/core/frame/legacy/location.cc +++ b/bridge/core/frame/legacy/location.cc @@ -3,8 +3,8 @@ * Copyright (C) 2022-present The WebF authors. All rights reserved. */ #include "location.h" -#include "core/frame/window.h" #include "core/executing_context.h" +#include "core/frame/window.h" namespace webf { diff --git a/bridge/core/frame/window.cc b/bridge/core/frame/window.cc index 9542bc8dec..0e2b5a2e0f 100644 --- a/bridge/core/frame/window.cc +++ b/bridge/core/frame/window.cc @@ -109,13 +109,16 @@ Window* Window::open(const AtomicString& url, ExceptionState& exception_state) { const NativeValue args[] = { NativeValueConverter::ToNativeValue(ctx(), url), }; - InvokeBindingMethod(binding_call_methods::kopen, 1, args, FlushUICommandReason::kDependentsOnElement, exception_state); + InvokeBindingMethod(binding_call_methods::kopen, 1, args, FlushUICommandReason::kDependentsOnElement, + exception_state); return this; } Screen* Window::screen() { if (screen_ == nullptr) { - NativeValue value = GetBindingProperty(binding_call_methods::kscreen, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, ASSERT_NO_EXCEPTION()); + NativeValue value = GetBindingProperty( + binding_call_methods::kscreen, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, ASSERT_NO_EXCEPTION()); screen_ = MakeGarbageCollected( this, NativeValueConverter>::FromNativeValue(value)); } @@ -131,7 +134,9 @@ void Window::scroll(double x, double y, ExceptionState& exception_state) { NativeValueConverter::ToNativeValue(x), NativeValueConverter::ToNativeValue(y), }; - InvokeBindingMethod(binding_call_methods::kscroll, 2, args, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + InvokeBindingMethod(binding_call_methods::kscroll, 2, args, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, + exception_state); } void Window::scroll(const std::shared_ptr& options, ExceptionState& exception_state) { @@ -139,7 +144,9 @@ void Window::scroll(const std::shared_ptr& options, ExceptionSt NativeValueConverter::ToNativeValue(options->hasLeft() ? options->left() : 0.0), NativeValueConverter::ToNativeValue(options->hasTop() ? options->top() : 0.0), }; - InvokeBindingMethod(binding_call_methods::kscroll, 2, args, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + InvokeBindingMethod(binding_call_methods::kscroll, 2, args, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, + exception_state); } void Window::scrollBy(ExceptionState& exception_state) { @@ -151,7 +158,9 @@ void Window::scrollBy(double x, double y, ExceptionState& exception_state) { NativeValueConverter::ToNativeValue(x), NativeValueConverter::ToNativeValue(y), }; - InvokeBindingMethod(binding_call_methods::kscrollBy, 2, args, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + InvokeBindingMethod(binding_call_methods::kscrollBy, 2, args, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, + exception_state); } void Window::scrollBy(const std::shared_ptr& options, ExceptionState& exception_state) { @@ -159,7 +168,9 @@ void Window::scrollBy(const std::shared_ptr& options, Exception NativeValueConverter::ToNativeValue(options->hasLeft() ? options->left() : 0.0), NativeValueConverter::ToNativeValue(options->hasTop() ? options->top() : 0.0), }; - InvokeBindingMethod(binding_call_methods::kscrollBy, 2, args, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + InvokeBindingMethod(binding_call_methods::kscrollBy, 2, args, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, + exception_state); } void Window::scrollTo(ExceptionState& exception_state) { @@ -195,7 +206,9 @@ void Window::postMessage(const ScriptValue& message, ComputedCssStyleDeclaration* Window::getComputedStyle(Element* element, ExceptionState& exception_state) { NativeValue arguments[] = {NativeValueConverter>::ToNativeValue(element)}; - NativeValue result = InvokeBindingMethod(binding_call_methods::kgetComputedStyle, 1, arguments, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); + NativeValue result = InvokeBindingMethod( + binding_call_methods::kgetComputedStyle, 1, arguments, + FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state); return MakeGarbageCollected( GetExecutingContext(), NativeValueConverter>::FromNativeValue(result)); } diff --git a/bridge/core/html/canvas/canvas_pattern.cc b/bridge/core/html/canvas/canvas_pattern.cc index 838da61225..85c143c4c8 100644 --- a/bridge/core/html/canvas/canvas_pattern.cc +++ b/bridge/core/html/canvas/canvas_pattern.cc @@ -13,7 +13,8 @@ CanvasPattern::CanvasPattern(ExecutingContext* context, NativeBindingObject* nat void CanvasPattern::setTransform(DOMMatrix* dom_matrix, ExceptionState& exception_state) { NativeValue arguments[] = {NativeValueConverter>::ToNativeValue(dom_matrix)}; - InvokeBindingMethod(binding_call_methods::ksetTransform, 1, arguments, FlushUICommandReason::kDependentsOnElement, exception_state); + InvokeBindingMethod(binding_call_methods::ksetTransform, 1, arguments, FlushUICommandReason::kDependentsOnElement, + exception_state); } NativeValue CanvasPattern::HandleCallFromDartSide(const AtomicString& method, diff --git a/bridge/core/html/canvas/canvas_rendering_context_2d.cc b/bridge/core/html/canvas/canvas_rendering_context_2d.cc index b8effcc545..669d15afd7 100644 --- a/bridge/core/html/canvas/canvas_rendering_context_2d.cc +++ b/bridge/core/html/canvas/canvas_rendering_context_2d.cc @@ -35,8 +35,9 @@ CanvasGradient* CanvasRenderingContext2D::createLinearGradient(double x0, NativeValueConverter::ToNativeValue(y0), NativeValueConverter::ToNativeValue(x1), NativeValueConverter::ToNativeValue(y1)}; - NativeValue value = InvokeBindingMethod(binding_call_methods::kcreateLinearGradient, - sizeof(arguments) / sizeof(NativeValue), arguments, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue value = + InvokeBindingMethod(binding_call_methods::kcreateLinearGradient, sizeof(arguments) / sizeof(NativeValue), + arguments, FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = NativeValueConverter>::FromNativeValue(value); return MakeGarbageCollected(GetExecutingContext(), native_binding_object); @@ -57,8 +58,9 @@ CanvasGradient* CanvasRenderingContext2D::createRadialGradient(double x0, NativeValueConverter::ToNativeValue(y1), NativeValueConverter::ToNativeValue(r1), }; - NativeValue value = InvokeBindingMethod(binding_call_methods::kcreateRadialGradient, - sizeof(arguments) / sizeof(NativeValue), arguments, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue value = + InvokeBindingMethod(binding_call_methods::kcreateRadialGradient, sizeof(arguments) / sizeof(NativeValue), + arguments, FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = NativeValueConverter>::FromNativeValue(value); return MakeGarbageCollected(GetExecutingContext(), native_binding_object); diff --git a/bridge/core/html/canvas/html_canvas_element.cc b/bridge/core/html/canvas/html_canvas_element.cc index 7693d667af..0f5e03c40f 100644 --- a/bridge/core/html/canvas/html_canvas_element.cc +++ b/bridge/core/html/canvas/html_canvas_element.cc @@ -16,7 +16,8 @@ HTMLCanvasElement::HTMLCanvasElement(Document& document) : HTMLElement(html_name CanvasRenderingContext* HTMLCanvasElement::getContext(const AtomicString& type, ExceptionState& exception_state) { NativeValue arguments[] = {NativeValueConverter::ToNativeValue(ctx(), type)}; - NativeValue value = InvokeBindingMethod(binding_call_methods::kgetContext, 1, arguments, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue value = InvokeBindingMethod(binding_call_methods::kgetContext, 1, arguments, + FlushUICommandReason::kDependentsOnElement, exception_state); NativeBindingObject* native_binding_object = NativeValueConverter>::FromNativeValue(value); diff --git a/bridge/core/html/html_image_element.cc b/bridge/core/html/html_image_element.cc index 6972f1962a..6d2825476e 100644 --- a/bridge/core/html/html_image_element.cc +++ b/bridge/core/html/html_image_element.cc @@ -22,7 +22,8 @@ ScriptPromise HTMLImageElement::decode(ExceptionState& exception_state) const { AtomicString HTMLImageElement::src() const { ExceptionState exception_state; - NativeValue native_value = GetBindingProperty(binding_call_methods::ksrc, FlushUICommandReason::kDependentsOnElement, exception_state); + NativeValue native_value = + GetBindingProperty(binding_call_methods::ksrc, FlushUICommandReason::kDependentsOnElement, exception_state); typename NativeTypeString::ImplType v = NativeValueConverter::FromNativeValue(ctx(), std::move(native_value)); if (UNLIKELY(exception_state.HasException())) { diff --git a/bridge/foundation/ui_command_buffer.cc b/bridge/foundation/ui_command_buffer.cc index c8f43f02a9..bbcfee33ef 100644 --- a/bridge/foundation/ui_command_buffer.cc +++ b/bridge/foundation/ui_command_buffer.cc @@ -44,8 +44,7 @@ UICommandKind GetKindFromUICommand(UICommand command) { } UICommandBuffer::UICommandBuffer(ExecutingContext* context) - : context_(context), buffer_((UICommandItem*)malloc(sizeof(UICommandItem) * MAXIMUM_UI_COMMAND_SIZE)) { -} + : context_(context), buffer_((UICommandItem*)malloc(sizeof(UICommandItem) * MAXIMUM_UI_COMMAND_SIZE)) {} UICommandBuffer::~UICommandBuffer() { free(buffer_); @@ -64,8 +63,10 @@ void UICommandBuffer::addCommand(UICommand command, } if (command == UICommand::kFinishRecordingCommand) { - if (size_ == 0) return; - if (buffer_[size_ - 1].type == static_cast(UICommand::kFinishRecordingCommand)) return; + if (size_ == 0) + return; + if (buffer_[size_ - 1].type == static_cast(UICommand::kFinishRecordingCommand)) + return; } UICommandItem item{static_cast(command), args_01.get(), nativePtr, nativePtr2}; @@ -78,7 +79,6 @@ void UICommandBuffer::updateFlags(UICommand command) { kind_flag = kind_flag | type; } - void UICommandBuffer::addCommand(const UICommandItem& item, bool request_ui_update) { if (UNLIKELY(!context_->dartIsolateContext()->valid())) { return; diff --git a/bridge/include/webf_bridge.h b/bridge/include/webf_bridge.h index 9523ae70db..1e1f48664a 100644 --- a/bridge/include/webf_bridge.h +++ b/bridge/include/webf_bridge.h @@ -42,7 +42,10 @@ WEBF_EXPORT_C void* initDartIsolateContextSync(int64_t dart_port, uint64_t* dart_methods, int32_t dart_methods_len); WEBF_EXPORT_C -void allocateNewPage(double thread_identity, void* dart_isolate_context, Dart_Handle dart_handle, AllocateNewPageCallback result_callback); +void allocateNewPage(double thread_identity, + void* dart_isolate_context, + Dart_Handle dart_handle, + AllocateNewPageCallback result_callback); WEBF_EXPORT_C void* allocateNewPageSync(double thread_identity, void* dart_isolate_context); @@ -51,7 +54,11 @@ WEBF_EXPORT_C int64_t newPageIdSync(); WEBF_EXPORT_C -void disposePage(double dedicated_thread, void* dart_isolate_context, void* page, Dart_Handle dart_handle, DisposePageCallback result_callback); +void disposePage(double dedicated_thread, + void* dart_isolate_context, + void* page, + Dart_Handle dart_handle, + DisposePageCallback result_callback); WEBF_EXPORT_C void disposePageSync(double dedicated_thread, void* dart_isolate_context, void* page); diff --git a/bridge/multiple_threading/dispatcher.cc b/bridge/multiple_threading/dispatcher.cc index befad8a504..d417241a6d 100644 --- a/bridge/multiple_threading/dispatcher.cc +++ b/bridge/multiple_threading/dispatcher.cc @@ -4,9 +4,9 @@ #include "dispatcher.h" -#include "foundation/logging.h" #include "core/dart_isolate_context.h" #include "core/page.h" +#include "foundation/logging.h" using namespace webf; @@ -40,7 +40,8 @@ void Dispatcher::KillJSThreadSync(int32_t js_context_id) { assert(js_threads_.count(js_context_id) > 0); auto& looper = js_threads_[js_context_id]; PostToJsSync( - true, js_context_id, [](bool cancel, Looper* looper) { looper->ExecuteOpaqueFinalizer(); }, js_threads_[js_context_id].get()); + true, js_context_id, [](bool cancel, Looper* looper) { looper->ExecuteOpaqueFinalizer(); }, + js_threads_[js_context_id].get()); looper->Stop(); js_threads_.erase(js_context_id); } @@ -62,14 +63,14 @@ void Dispatcher::Dispose(webf::multi_threading::Callback callback) { for (auto&& thread : js_threads_) { auto* page_group = static_cast(thread.second->opaque()); - for(auto& page : (*page_group->pages())) { + for (auto& page : (*page_group->pages())) { page->executingContext()->SetContextInValid(); } } std::set pending_tasks = pending_dart_tasks_; - for(auto task : pending_tasks) { + for (auto task : pending_tasks) { const DartWork dart_work = *task; #if ENABLE_LOG WEBF_LOG(VERBOSE) << "[Dispatcher]: BEGIN EXEC SYNC DART WORKER"; @@ -173,7 +174,8 @@ void Dispatcher::FinalizeAllJSThreads(webf::multi_threading::Callback callback) WEBF_LOG(VERBOSE) << "[Dispatcher]: WAITING FOR JS THREAD COMPLETE"; #endif // Waiting for the final dart task return. - while(!is_final_async_dart_task_complete) {} + while (!is_final_async_dart_task_complete) { + } #if ENABLE_LOG WEBF_LOG(VERBOSE) << "[Dispatcher]: ALL JS THREAD FINALIZED SUCCESS"; diff --git a/bridge/multiple_threading/dispatcher.h b/bridge/multiple_threading/dispatcher.h index 91d2a4afd6..6de4c26127 100644 --- a/bridge/multiple_threading/dispatcher.h +++ b/bridge/multiple_threading/dispatcher.h @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include #include "logging.h" @@ -91,7 +91,8 @@ class Dispatcher { auto& looper = js_threads_[thread_group_id]; const DartWork work = [task, &looper](bool cancel) { #if ENABLE_LOG - WEBF_LOG(WARN) << " BLOCKED THREAD " << std::this_thread::get_id() << " HAD BEEN RESUMED" << " is_cancel: " << cancel; + WEBF_LOG(WARN) << " BLOCKED THREAD " << std::this_thread::get_id() << " HAD BEEN RESUMED" + << " is_cancel: " << cancel; #endif looper->is_blocked_ = false; diff --git a/bridge/multiple_threading/task.h b/bridge/multiple_threading/task.h index 87c3c78960..07ba3488f2 100644 --- a/bridge/multiple_threading/task.h +++ b/bridge/multiple_threading/task.h @@ -5,10 +5,10 @@ #ifndef MULTI_THREADING_TASK_H #define MULTI_THREADING_TASK_H +#include #include #include #include -#include #include "foundation/logging.h" @@ -72,7 +72,8 @@ class ConcreteSyncTask : public SyncTask { using ReturnType = std::invoke_result_t; ConcreteSyncTask(Func&& func, Args&&... args) - : task_(std::bind(std::forward(func), std::placeholders::_1, std::forward(args)...)), future_(task_.get_future()) {} + : task_(std::bind(std::forward(func), std::placeholders::_1, std::forward(args)...)), + future_(task_.get_future()) {} void operator()(bool cancel = false) override { #if ENABLE_LOG diff --git a/bridge/webf_bridge.cc b/bridge/webf_bridge.cc index f78821a399..9250e6f07b 100644 --- a/bridge/webf_bridge.cc +++ b/bridge/webf_bridge.cc @@ -101,7 +101,8 @@ void disposePage(double thread_identity, Dart_PersistentHandle persistent_handle = Dart_NewPersistentHandle_DL(dart_handle); - ((webf::DartIsolateContext*)dart_isolate_context)->RemovePage(thread_identity, static_cast(page_), persistent_handle, result_callback); + ((webf::DartIsolateContext*)dart_isolate_context) + ->RemovePage(thread_identity, static_cast(page_), persistent_handle, result_callback); #if ENABLE_LOG WEBF_LOG(INFO) << "[Dispatcher]: disposePage Call END"; #endif @@ -112,7 +113,8 @@ void disposePageSync(double thread_identity, void* ptr, void* page_) { WEBF_LOG(INFO) << "[Dispatcher]: disposePageSync Call BEGIN"; #endif auto* dart_isolate_context = (webf::DartIsolateContext*)ptr; - ((webf::DartIsolateContext*)dart_isolate_context)->RemovePageSync(thread_identity, static_cast(page_)); + ((webf::DartIsolateContext*)dart_isolate_context) + ->RemovePageSync(thread_identity, static_cast(page_)); #if ENABLE_LOG WEBF_LOG(INFO) << "[Dispatcher]: disposePageSync Call END"; #endif diff --git a/bridge/webf_bridge_test.cc b/bridge/webf_bridge_test.cc index 2805edb362..42e1b7d8da 100644 --- a/bridge/webf_bridge_test.cc +++ b/bridge/webf_bridge_test.cc @@ -33,7 +33,8 @@ void* initTestFramework(void* page_) { auto page = reinterpret_cast(page_); return page->dartIsolateContext()->dispatcher()->PostToJsSync( page->isDedicated(), page->contextId(), - [](bool cancel, webf::WebFPage* page) -> void* { return new webf::WebFTestContext(page->executingContext()); }, page); + [](bool cancel, webf::WebFPage* page) -> void* { return new webf::WebFTestContext(page->executingContext()); }, + page); } void executeTest(void* testContext, Dart_Handle dart_handle, ExecuteResultCallback executeCallback) {