-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
david
committed
Dec 13, 2024
1 parent
1a85319
commit e7c24cc
Showing
33 changed files
with
1,486 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Copyright (C) 2019-2022 The Kraken authors. All rights reserved. | ||
* Copyright (C) 2022-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
|
||
#include "binding_initializer.h" | ||
#include "v8_window_or_worker_global_scope.h" | ||
|
||
namespace webf { | ||
|
||
void InstallBindings(ExecutingContext* context) { | ||
// Must follow the inheritance order when install. | ||
// Exp: Node extends EventTarget, EventTarget must be install first. | ||
V8WindowOrWorkerGlobalScope::Install(context); | ||
/*TODO support DOM API | ||
QJSLocation::Install(context); | ||
QJSModuleManager::Install(context); | ||
QJSConsole::Install(context); | ||
QJSEventTarget::Install(context); | ||
QJSWindow::Install(context); | ||
QJSEvent::Install(context); | ||
QJSUIEvent::Install(context); | ||
QJSErrorEvent::Install(context); | ||
QJSPromiseRejectionEvent::Install(context); | ||
QJSMessageEvent::Install(context); | ||
QJSAnimationEvent::Install(context); | ||
QJSCloseEvent::Install(context); | ||
QJSHybridRouterChangeEvent::Install(context); | ||
QJSFocusEvent::Install(context); | ||
QJSGestureEvent::Install(context); | ||
QJSHashchangeEvent::Install(context); | ||
QJSInputEvent::Install(context); | ||
QJSCustomEvent::Install(context); | ||
QJSMouseEvent::Install(context); | ||
QJSPointerEvent::Install(context); | ||
QJSTouchEvent::Install(context); | ||
QJSPopStateEvent::Install(context); | ||
QJSTransitionEvent::Install(context); | ||
QJSIntersectionChangeEvent::Install(context); | ||
QJSKeyboardEvent::Install(context); | ||
QJSNode::Install(context); | ||
QJSNodeList::Install(context); | ||
QJSDocument::Install(context); | ||
QJSDocumentFragment::Install(context); | ||
QJSCharacterData::Install(context); | ||
QJSText::Install(context); | ||
QJSComment::Install(context); | ||
QJSElement::Install(context); | ||
QJSHTMLElement::Install(context); | ||
QJSWidgetElement::Install(context); | ||
QJSHTMLDivElement::Install(context); | ||
QJSHTMLHeadElement::Install(context); | ||
QJSHTMLBodyElement::Install(context); | ||
QJSHTMLHtmlElement::Install(context); | ||
QJSHTMLIFrameElement::Install(context); | ||
QJSHTMLAnchorElement::Install(context); | ||
QJSHTMLImageElement::Install(context); | ||
QJSHTMLInputElement::Install(context); | ||
QJSHTMLTextareaElement::Install(context); | ||
QJSHTMLButtonElement::Install(context); | ||
QJSHTMLFormElement::Install(context); | ||
QJSImage::Install(context); | ||
QJSHTMLScriptElement::Install(context); | ||
QJSHTMLLinkElement::Install(context); | ||
QJSHTMLUnknownElement::Install(context); | ||
QJSHTMLTemplateElement::Install(context); | ||
QJSHTMLCanvasElement::Install(context); | ||
QJSCanvasRenderingContext::Install(context); | ||
QJSCanvasRenderingContext2D::Install(context); | ||
QJSCanvasPattern::Install(context); | ||
QJSCanvasGradient::Install(context); | ||
QJSPath2D::Install(context); | ||
QJSDOMMatrixReadOnly::Install(context); | ||
QJSDOMMatrix::Install(context); | ||
QJSDOMPointReadOnly::Install(context); | ||
QJSDOMPoint::Install(context); | ||
QJSCSSStyleDeclaration::Install(context); | ||
QJSInlineCssStyleDeclaration::Install(context); | ||
QJSComputedCssStyleDeclaration::Install(context); | ||
QJSBoundingClientRect::Install(context); | ||
QJSScreen::Install(context); | ||
QJSBlob::Install(context); | ||
QJSTouch::Install(context); | ||
QJSTouchList::Install(context); | ||
QJSDOMStringMap::Install(context); | ||
QJSMutationObserver::Install(context); | ||
QJSMutationRecord::Install(context); | ||
QJSMutationObserverRegistration::Install(context); | ||
QJSDOMTokenList::Install(context); | ||
QJSPerformance::Install(context); | ||
QJSPerformanceEntry::Install(context); | ||
QJSPerformanceMark::Install(context); | ||
QJSPerformanceMeasure::Install(context); | ||
QJSHTMLCollection::Install(context); | ||
QJSHTMLAllCollection::Install(context); | ||
// SVG | ||
QJSSVGElement::Install(context); | ||
QJSSVGGraphicsElement::Install(context); | ||
QJSSVGGeometryElement::Install(context); | ||
QJSSVGSVGElement::Install(context); | ||
QJSSVGRectElement::Install(context); | ||
QJSSVGTextContentElement::Install(context); | ||
QJSSVGTextPositioningElement::Install(context); | ||
QJSSVGPathElement::Install(context); | ||
QJSSVGTextElement::Install(context); | ||
QJSSVGGElement::Install(context); | ||
QJSSVGCircleElement::Install(context); | ||
QJSSVGEllipseElement::Install(context); | ||
QJSSVGStyleElement::Install(context); | ||
QJSSVGLineElement::Install(context); | ||
QJSNativeLoader::Install(context); | ||
// Legacy bindings, not standard. | ||
QJSElementAttributes::Install(context); | ||
*/ | ||
} | ||
|
||
} // namespace webf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (C) 2019-2022 The Kraken authors. All rights reserved. | ||
* Copyright (C) 2022-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
|
||
#ifndef WEBF_BINDING_INITIALIZER_H | ||
#define WEBF_BINDING_INITIALIZER_H | ||
|
||
namespace webf { | ||
|
||
class ExecutingContext; | ||
|
||
void InstallBindings(ExecutingContext* context); | ||
|
||
} // namespace webf | ||
|
||
#endif //WEBF_BINDING_INITIALIZER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright (C) 2019-2022 The Kraken authors. All rights reserved. | ||
* Copyright (C) 2022-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
#ifndef WEBF_BRIDGE_BINDINGS_V8_GENERATED_CODE_HELPER_H_ | ||
#define WEBF_BRIDGE_BINDINGS_V8_GENERATED_CODE_HELPER_H_ | ||
|
||
#include "atomic_string.h" | ||
#include "script_value.h" | ||
|
||
#endif //WEBF_BRIDGE_BINDINGS_V8_GENERATED_CODE_HELPER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (C) 2019-2022 The Kraken authors. All rights reserved. | ||
* Copyright (C) 2022-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
#include "member_installer.h" | ||
#include "core/executing_context.h" | ||
|
||
namespace webf { | ||
|
||
void MemberInstaller::InstallFunctions(ExecutingContext* context, | ||
std::initializer_list<FunctionConfig> config) { | ||
v8::Isolate* isolate = context->ctx(); | ||
v8::Local<v8::Context> v8_context = isolate->GetCurrentContext(); | ||
v8::Local<v8::Object> global = v8_context->Global(); | ||
|
||
for (const auto& function : config) { | ||
v8::Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New(isolate, function.callback); | ||
v8::Local<v8::Function> v8_function = function_template->GetFunction(v8_context).ToLocalChecked(); | ||
|
||
global->Set(v8_context, v8::String::NewFromUtf8(isolate, function.name).ToLocalChecked(), v8_function).Check(); | ||
} | ||
} | ||
|
||
} // namespace webf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2019-2022 The Kraken authors. All rights reserved. | ||
* Copyright (C) 2022-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
#ifndef WEBF_BRIDGE_BINDINGS_V8_MEMBER_INSTALLER_H_ | ||
#define WEBF_BRIDGE_BINDINGS_V8_MEMBER_INSTALLER_H_ | ||
|
||
#include <initializer_list> | ||
#include <v8/v8.h> | ||
|
||
namespace webf { | ||
|
||
class ExecutingContext; | ||
|
||
// A set of utility functions to define attributes members as ES properties. | ||
class MemberInstaller { | ||
public: | ||
struct FunctionConfig { | ||
FunctionConfig& operator=(const FunctionConfig&) = delete; | ||
const char* name; | ||
v8::FunctionCallback callback; | ||
}; | ||
|
||
static void InstallFunctions(ExecutingContext* context, std::initializer_list<FunctionConfig> config); | ||
}; | ||
|
||
} // namespace webf | ||
|
||
#endif //WEBF_BRIDGE_BINDINGS_V8_MEMBER_INSTALLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.