Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
openwebf-bot authored and andycall committed Dec 28, 2023
1 parent 0511737 commit 4286354
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 71 deletions.
14 changes: 8 additions & 6 deletions bridge/core/binding_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -159,9 +160,10 @@ NativeValue BindingObject::InvokeBindingMethod(BindingMethodCallOperations bindi
NativeValue native_method = NativeValueConverter<NativeTypeInt64>::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";
Expand Down
2 changes: 1 addition & 1 deletion bridge/core/binding_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include <set>
#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 {

Expand Down
20 changes: 15 additions & 5 deletions bridge/core/css/computed_css_style_declaration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ bool ComputedCssStyleDeclaration::SetItem(const AtomicString& key,
NativeValue arguments[] = {
NativeValueConverter<NativeTypeString>::ToNativeValue(ctx(), key),
NativeValueConverter<NativeTypeString>::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;
}

Expand All @@ -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<NativeTypeInt64>::FromNativeValue(result);
}

Expand All @@ -59,19 +63,25 @@ void ComputedCssStyleDeclaration::setProperty(const AtomicString& key,

AtomicString ComputedCssStyleDeclaration::removeProperty(const AtomicString& key, ExceptionState& exception_state) {
NativeValue arguments[] = {NativeValueConverter<NativeTypeString>::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<NativeTypeString>::FromNativeValue(ctx(), std::move(result));
}

bool ComputedCssStyleDeclaration::NamedPropertyQuery(const AtomicString& key, ExceptionState& exception_state) {
NativeValue arguments[] = {NativeValueConverter<NativeTypeString>::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<NativeTypeBool>::FromNativeValue(result);
}

void ComputedCssStyleDeclaration::NamedPropertyEnumerator(std::vector<AtomicString>& 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<NativeTypeArray<NativeTypeString>>::FromNativeValue(ctx(), result);
for (auto& i : arr) {
names.emplace_back(i);
Expand Down
16 changes: 9 additions & 7 deletions bridge/core/dart_isolate_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void DartIsolateContext::Dispose(multi_threading::Callback callback) {
running_dart_isolates--;
FinalizeJSRuntime();
callback();
});
});
}

void DartIsolateContext::InitializeNewPageInJSThread(PageGroup* page_group,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions bridge/core/dart_isolate_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class PageGroup {
std::vector<WebFPage*> pages_;
};


struct DartWireContext {
ScriptValue jsObject;
};
Expand Down Expand Up @@ -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_;
Expand Down
27 changes: 18 additions & 9 deletions bridge/core/dart_methods.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -168,15 +169,19 @@ 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

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);
},
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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";
Expand Down
16 changes: 11 additions & 5 deletions bridge/core/dom/element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ BoundingClientRect* Element::getBoundingClientRect(ExceptionState& exception_sta
}

std::vector<BoundingClientRect*> 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 {};
}
Expand Down Expand Up @@ -144,7 +146,9 @@ void Element::scrollBy(const std::shared_ptr<ScrollToOptions>& options, Exceptio
NativeValueConverter<NativeTypeDouble>::ToNativeValue(options->hasLeft() ? options->left() : 0.0),
NativeValueConverter<NativeTypeDouble>::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) {
Expand Down Expand Up @@ -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<ElementSnapshotReader*>(ptr);
Expand Down Expand Up @@ -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<NativeTypeDouble>::FromNativeValue(
window->GetBindingProperty(binding_call_methods::kdevicePixelRatio, FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state));
double device_pixel_ratio = NativeValueConverter<NativeTypeDouble>::FromNativeValue(window->GetBindingProperty(
binding_call_methods::kdevicePixelRatio,
FlushUICommandReason::kDependentsOnElement | FlushUICommandReason::kDependentsOnLayout, exception_state));
return toBlob(device_pixel_ratio, exception_state);
}

Expand Down
6 changes: 4 additions & 2 deletions bridge/core/dom/legacy/element_attributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<NativeTypeString>::FromNativeValue(element_->ctx(), std::move(dart_result));
}
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion bridge/core/frame/legacy/location.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Loading

0 comments on commit 4286354

Please sign in to comment.