-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from fe/nezha/feat/path_2d
[FEAT][1.81.0][NEZ] support path2d for JS
- Loading branch information
Showing
22 changed files
with
282 additions
and
29 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
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
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 |
---|---|---|
|
@@ -113,6 +113,7 @@ | |
"scale", | ||
"strokeText", | ||
"setTransform", | ||
"addPath", | ||
"transform", | ||
"translate", | ||
"reset", | ||
|
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
interface DOMMatrix extends DOMMatrixReadonly { | ||
new(init: string | double[]): DOMMatrix; | ||
new(init?: string | double[]): DOMMatrix; | ||
} |
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
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
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,41 @@ | ||
/* | ||
* Copyright (C) 2022-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
#include "path_2d.h" | ||
#include "binding_call_methods.h" | ||
#include "foundation/native_value_converter.h" | ||
|
||
namespace webf { | ||
|
||
Path2D* Path2D::Create(ExecutingContext* context, ExceptionState& exception_state) { | ||
return MakeGarbageCollected<Path2D>(context, exception_state); | ||
} | ||
|
||
Path2D::Path2D(ExecutingContext* context, ExceptionState& exception_state) | ||
: BindingObject(context->ctx()) { | ||
NativeValue arguments[0]; | ||
GetExecutingContext()->dartMethodPtr()->createBindingObject(GetExecutingContext()->isDedicated(), | ||
GetExecutingContext()->contextId(), bindingObject(), | ||
CreateBindingObjectType::kCreatePath2D, arguments, 0); | ||
} | ||
|
||
void Path2D::addPath(Path2D* path, DOMMatrixReadonly* dom_matrix, ExceptionState& exception_state) { | ||
NativeValue arguments[] = {NativeValueConverter<NativeTypePointer<Path2D>>::ToNativeValue(path), | ||
NativeValueConverter<NativeTypePointer<DOMMatrixReadonly>>::ToNativeValue(dom_matrix)}; | ||
InvokeBindingMethod(binding_call_methods::kaddPath, 2, arguments, exception_state); | ||
} | ||
|
||
void Path2D::addPath(webf::Path2D* path, webf::ExceptionState& exception_state) { | ||
NativeValue arguments[] = {NativeValueConverter<NativeTypePointer<Path2D>>::ToNativeValue(path)}; | ||
InvokeBindingMethod(binding_call_methods::kaddPath, 1, arguments, exception_state); | ||
} | ||
|
||
NativeValue Path2D::HandleCallFromDartSide(const AtomicString& method, | ||
int32_t argc, | ||
const NativeValue* argv, | ||
Dart_Handle dart_object) { | ||
return Native_NewNull(); | ||
} | ||
|
||
} // 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,13 @@ | ||
interface Path2D { | ||
closePath(): DartImpl<void>; | ||
moveTo(x: number, y: number): DartImpl<void>; | ||
lineTo(x: number, y: number): DartImpl<void>; | ||
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): DartImpl<void>; | ||
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): DartImpl<void>; | ||
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): DartImpl<void>; | ||
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): DartImpl<void>; | ||
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): DartImpl<void>; | ||
rect(x: number, y: number, w: number, h: number): DartImpl<void>; | ||
addPath(path: Path2D, matrix?: DOMMatrix): void; | ||
new(): Path2D; | ||
} |
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,37 @@ | ||
/* | ||
* Copyright (C) 2022-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
#ifndef WEBF_CORE_HTML_CANVAS_CANVAS_PATH_2D_H_ | ||
#define WEBF_CORE_HTML_CANVAS_CANVAS_PATH_2D_H_ | ||
|
||
#include "bindings/qjs/script_wrappable.h" | ||
#include "core/binding_object.h" | ||
#include "core/geometry/dom_matrix.h" | ||
|
||
namespace webf { | ||
|
||
class Path2D : public BindingObject { | ||
DEFINE_WRAPPERTYPEINFO(); | ||
|
||
public: | ||
using ImplType = Path2D*; | ||
static Path2D* Create(ExecutingContext* context, ExceptionState& exception_state); | ||
Path2D() = delete; | ||
|
||
explicit Path2D(ExecutingContext* context, ExceptionState& exception_state); | ||
|
||
void addPath(Path2D* path, DOMMatrixReadonly* dom_matrix, ExceptionState& exception_state); | ||
void addPath(Path2D* path, ExceptionState& exception_state); | ||
|
||
NativeValue HandleCallFromDartSide(const AtomicString& method, | ||
int32_t argc, | ||
const NativeValue* argv, | ||
Dart_Handle dart_object) override; | ||
|
||
private: | ||
}; // namespace webf | ||
|
||
} | ||
|
||
#endif // WEBF_CORE_HTML_CANVAS_CANVAS_PATH_2D_H_a |
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
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.