Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/input-and-textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
openwebf-bot committed Jan 24, 2025
2 parents 96a7dbe + e0f595f commit 0971887
Show file tree
Hide file tree
Showing 108 changed files with 2,508 additions and 867 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/code_linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
cppcheck:
runs-on: macos-12
runs-on: macos-14
name: Cppcheck
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -50,11 +50,9 @@ jobs:
extensions: 'h,cc,c'
clangFormatVersion: 12
inplace: True
- uses: EndBug/add-and-commit@v4
- uses: EndBug/add-and-commit@v9
with:
author_name: openwebf-bot
author_email: [email protected]
message: 'Committing clang-format changes'
default_author: github_actions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/example_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
nodeVersion: "16"
cmakeVersion: "3.26.3"
flutterVersion: "3.24.0"
flutterVersion: "3.27.1"

jobs:
build_windows-app_in_windows:
Expand Down
92 changes: 7 additions & 85 deletions .github/workflows/publish_to_dart_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,10 @@ on:
env:
nodeVersion: "16"
cmakeVersion: "3.22.x"
flutterVersion: "2.2.0"
flutterVersion: "3.24.0"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_windows_binary:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v2
with:
node-version: ${{ env.nodeVersion }}
- uses: jwlawson/[email protected]
with:
cmake-version: ${{ env.cmakeVersion }}
- run: npm i
- name: Build windows dll
run: npm run build:bridge:windows:release
- uses: actions/upload-artifact@v2
with:
name: windows_binary
path: bridge/build/windows/

build_linux_binary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v2
with:
node-version: "16"
- uses: jwlawson/[email protected]
with:
cmake-version: "3.22.x"
- run: |
sudo apt-get update
sudo apt-get install chrpath ninja-build pkg-config -y
- run: npm i
- run: npm run build:bridge:linux:release
- uses: actions/upload-artifact@v2
with:
name: linux_binary
path: bridge/build/linux/
build_macos_binary:
runs-on: macos-latest
steps:
Expand All @@ -69,7 +28,7 @@ jobs:
run: npm install
- name: Build bridge binary
run: npm run build:bridge:macos:release
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: macos_binary
path: bridge/build/macos/
Expand All @@ -89,38 +48,12 @@ jobs:
run: npm install
- name: Build bridge binary
run: npm run build:bridge:ios:release
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: ios_binary
path: bridge/build/ios/
build_android_binary:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v2
with:
node-version: "16"
- uses: nttld/[email protected]
id: setup-ndk
with:
ndk-version: r22b
- uses: jwlawson/[email protected]
with:
cmake-version: ${{ env.cmakeVersion }}
- name: NPM INSTALL
run: npm install
- name: Build bridge binary
run: npm run build:bridge:android:release
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- uses: actions/upload-artifact@v2
with:
name: android_binary
path: bridge/build/android/
publish:
needs: [build_linux_binary, build_android_binary, build_ios_binary, build_macos_binary, build_windows_binary]
needs: [build_ios_binary, build_macos_binary]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -131,28 +64,17 @@ jobs:
flutter-version: ${{ env.flutterVersion }}
- name: NPM INSTALL
run: npm install
- uses: actions/download-artifact@v2
with:
name: linux_binary
path: bridge/build/linux/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: ios_binary
path: bridge/build/ios/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: macos_binary
path: bridge/build/macos/
- uses: actions/download-artifact@v2
with:
name: android_binary
path: bridge/build/android/
- uses: actions/download-artifact@v2
with:
name: windows_binary
path: bridge/build/windows/
- name: Prepare distribute binaries
run: node scripts/pre_publish_webf.js
- run: git log
- name: Publish
uses: k-paxian/dart-package-publisher@master
with:
Expand Down
2 changes: 2 additions & 0 deletions bridge/.pubignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cmake-*
scripts/code_generator
23 changes: 22 additions & 1 deletion bridge/core/api/element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
*/

#include "plugin_api/element.h"
#include "core/api/exception_state.h"
#include "core/dom/container_node.h"
#include "core/dom/element.h"

namespace webf {} // namespace webf
namespace webf {

void ElementPublicMethods::ToBlob(Element* ptr,
WebFNativeFunctionContext* callback_context,
SharedExceptionState* shared_exception_state) {
auto* element = static_cast<webf::Element*>(ptr);
auto callback_impl = WebFNativeFunction::Create(callback_context, shared_exception_state);
return element->toBlob(callback_impl, shared_exception_state->exception_state);
}

void ElementPublicMethods::ToBlobWithDevicePixelRatio(Element* ptr,
double device_pixel_ratio,
WebFNativeFunctionContext* callback_context,
SharedExceptionState* shared_exception_state) {
auto* element = static_cast<webf::Element*>(ptr);
auto callback_impl = WebFNativeFunction::Create(callback_context, shared_exception_state);
return element->toBlob(device_pixel_ratio, callback_impl, shared_exception_state->exception_state);
}

} // namespace webf
76 changes: 76 additions & 0 deletions bridge/core/api/executing_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
#include "core/api/exception_state.h"
#include "core/dom/document.h"
#include "core/executing_context.h"
#include "core/frame/legacy/location.h"
#include "core/frame/module_manager.h"
#include "core/frame/window.h"
#include "core/frame/window_or_worker_global_scope.h"
#include "foundation/native_value_converter.h"

namespace webf {

Expand All @@ -32,6 +35,71 @@ void ExecutingContextWebFMethods::FinishRecordingUIOperations(webf::ExecutingCon
context->uiCommandBuffer()->AddCommand(UICommand::kFinishRecordingCommand, nullptr, nullptr, nullptr, false);
}

NativeValue ExecutingContextWebFMethods::WebFInvokeModule(ExecutingContext* context,
const char* module_name,
const char* method,
SharedExceptionState* shared_exception_state) {
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);
NativeValue return_result = result.ToNative(context->ctx(), shared_exception_state->exception_state);

if (shared_exception_state->exception_state.HasException()) {
return Native_NewNull();
}

return return_result;
}

NativeValue ExecutingContextWebFMethods::WebFInvokeModuleWithParams(ExecutingContext* context,
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);

if (shared_exception_state->exception_state.HasException() || result == nullptr) {
return Native_NewNull();
}

NativeValue return_result = *result;
return return_result;
}

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);

if (shared_exception_state->exception_state.HasException()) {
return Native_NewNull();
}

NativeValue return_result = *result;
return return_result;
}

void ExecutingContextWebFMethods::WebFLocationReload(ExecutingContext* context,
SharedExceptionState* shared_exception_state) {
Location::__webf_location_reload__(context, shared_exception_state->exception_state);
}

int32_t ExecutingContextWebFMethods::SetTimeout(ExecutingContext* context,
WebFNativeFunctionContext* callback_context,
int32_t timeout,
Expand Down Expand Up @@ -64,4 +132,12 @@ void ExecutingContextWebFMethods::ClearInterval(ExecutingContext* context,
WindowOrWorkerGlobalScope::clearInterval(context, interval_id, shared_exception_state->exception_state);
}

void ExecutingContextWebFMethods::SetRunRustFutureTasks(ExecutingContext* context,
WebFNativeFunctionContext* callback_context,
SharedExceptionState* shared_exception_state) {
auto callback_impl = WebFNativeFunction::Create(callback_context, shared_exception_state);

context->SetRunRustFutureTasks(callback_impl);
}

} // namespace webf
2 changes: 1 addition & 1 deletion bridge/core/binding_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void NativeBindingObject::HandleCallFromDartSide(const DartIsolateContext* dart_
BindingObject::BindingObject(JSContext* ctx) : ScriptWrappable(ctx), binding_object_(new NativeBindingObject(this)) {}
BindingObject::~BindingObject() {
// Set below properties to nullptr to avoid dart callback to native.
binding_object_->disposed_ = true;
binding_object_->disposed_.store(true, std::memory_order_release);
binding_object_->binding_target_ = nullptr;
binding_object_->invoke_binding_methods_from_dart = nullptr;
binding_object_->invoke_bindings_methods_from_native = nullptr;
Expand Down
6 changes: 4 additions & 2 deletions bridge/core/binding_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ struct NativeBindingObject : public DartReadable {
const NativeValue* argv,
Dart_PersistentHandle dart_object,
DartInvokeResultCallback result_callback);

bool disposed_{false};
static bool IsDisposed(const NativeBindingObject* native_binding_object) {
return native_binding_object->disposed_.load(std::memory_order_acquire);
}
BindingObject* binding_target_{nullptr};
InvokeBindingMethodsFromDart invoke_binding_methods_from_dart{nullptr};
InvokeBindingsMethodsFromNative invoke_bindings_methods_from_native{nullptr};
void* extra{nullptr};
std::atomic<bool> disposed_{false};
};

enum BindingMethodCallOperations {
Expand Down
1 change: 1 addition & 0 deletions bridge/core/dart_isolate_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

#include "dart_isolate_context.h"
#include <algorithm>
#include <unordered_set>
#include "defined_properties_initializer.h"
#include "event_factory.h"
Expand Down
Loading

0 comments on commit 0971887

Please sign in to comment.