Skip to content

Commit

Permalink
refactor: DOMPointReadonly to DOMPointReadOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
jwxbond committed Nov 6, 2024
1 parent 027ab87 commit ba5fb0a
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 63 deletions.
4 changes: 2 additions & 2 deletions bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ if ($ENV{WEBF_JS_ENGINE} MATCHES "quickjs")
core/geometry/dom_matrix.cc
core/geometry/dom_matrix_read_only.cc
core/geometry/dom_point.cc
core/geometry/dom_point_readonly.cc
core/geometry/dom_point_read_only.cc
core/html/forms/html_button_element.cc
core/html/forms/html_input_element.cc
core/html/forms/html_form_element.cc
Expand Down Expand Up @@ -509,7 +509,7 @@ if ($ENV{WEBF_JS_ENGINE} MATCHES "quickjs")
out/qjs_dom_matrix.cc
out/qjs_dom_matrix_read_only.cc
out/qjs_dom_point.cc
out/qjs_dom_point_readonly.cc
out/qjs_dom_point_read_only.cc
out/qjs_union_double_sequencedouble.cc
out/qjs_unionhtml_image_elementhtml_canvas_element.cc
out/qjs_union_dom_stringcanvas_gradient.cc
Expand Down
4 changes: 2 additions & 2 deletions bridge/bindings/qjs/binding_initializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "qjs_dom_matrix.h"
#include "qjs_dom_matrix_read_only.h"
#include "qjs_dom_point.h"
#include "qjs_dom_point_readonly.h"
#include "qjs_dom_point_read_only.h"
#include "qjs_dom_string_map.h"
#include "qjs_dom_token_list.h"
#include "qjs_element.h"
Expand Down Expand Up @@ -168,7 +168,7 @@ void InstallBindings(ExecutingContext* context) {
QJSPath2D::Install(context);
QJSDOMMatrixReadOnly::Install(context);
QJSDOMMatrix::Install(context);
QJSDOMPointReadonly::Install(context);
QJSDOMPointReadOnly::Install(context);
QJSDOMPoint::Install(context);
QJSCSSStyleDeclaration::Install(context);
QJSInlineCssStyleDeclaration::Install(context);
Expand Down
2 changes: 1 addition & 1 deletion bridge/bindings/qjs/wrapper_type_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ enum {
JS_CLASS_DOM_MATRIX,
JS_CLASS_DOM_MATRIX_READ_ONLY,
JS_CLASS_DOM_POINT,
JS_CLASS_DOM_POINT_READONLY,
JS_CLASS_DOM_POINT_READ_ONLY,
JS_CLASS_HTML_TEMPLATE_ELEMENT,
JS_CLASS_HTML_UNKNOWN_ELEMENT,
JS_CLASS_HTML_INPUT_ELEMENT,
Expand Down
12 changes: 6 additions & 6 deletions bridge/core/geometry/dom_point.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ DOMPoint* DOMPoint::Create(ExecutingContext* context,
}

DOMPoint::DOMPoint(webf::ExecutingContext* context, webf::ExceptionState& exception_state)
: DOMPointReadonly(context, exception_state) {}
: DOMPointReadOnly(context, exception_state) {}

DOMPoint::DOMPoint(ExecutingContext* context, double x, ExceptionState& exception_state)
: DOMPointReadonly(context, x, exception_state) {}
: DOMPointReadOnly(context, x, exception_state) {}
DOMPoint::DOMPoint(ExecutingContext* context, double x, double y, ExceptionState& exception_state)
: DOMPointReadonly(context, x, y, exception_state) {}
: DOMPointReadOnly(context, x, y, exception_state) {}
DOMPoint::DOMPoint(ExecutingContext* context, double x, double y, double z, ExceptionState& exception_state)
: DOMPointReadonly(context, x, y, z, exception_state) {}
: DOMPointReadOnly(context, x, y, z, exception_state) {}
DOMPoint::DOMPoint(ExecutingContext* context, double x, double y, double z, double w, ExceptionState& exception_state)
: DOMPointReadonly(context, x, y, z, w, exception_state) {}
DOMPoint::DOMPoint(webf::ExecutingContext* context, webf::NativeBindingObject* native_binding_object): DOMPointReadonly(context, native_binding_object) {}
: DOMPointReadOnly(context, x, y, z, w, exception_state) {}
DOMPoint::DOMPoint(webf::ExecutingContext* context, webf::NativeBindingObject* native_binding_object): DOMPointReadOnly(context, native_binding_object) {}

} // namespace webf
2 changes: 1 addition & 1 deletion bridge/core/geometry/dom_point.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
interface DOMPoint extends DOMPointReadonly {
interface DOMPoint extends DOMPointReadOnly {
new(x?: number, y?:number, z?:number, w?:number): DOMPoint;
}
6 changes: 3 additions & 3 deletions bridge/core/geometry/dom_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include "bindings/qjs/script_wrappable.h"
#include "core/binding_object.h"
#include "dom_point_readonly.h"
#include "dom_point_read_only.h"

namespace webf {

class DOMPoint : public DOMPointReadonly {
class DOMPoint : public DOMPointReadOnly {
DEFINE_WRAPPERTYPEINFO();

public:
Expand All @@ -38,7 +38,7 @@ class DOMPoint : public DOMPointReadonly {
};
template <>
struct DowncastTraits<DOMPoint> {
static bool AllowFrom(const DOMPointReadonly& matrix) { return matrix.IsDOMPoint(); }
static bool AllowFrom(const DOMPointReadOnly& matrix) { return matrix.IsDOMPoint(); }
};
} // namespace webf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright (C) 2022-present The WebF authors. All rights reserved.
*/

#include "dom_point_readonly.h"
#include "dom_point_read_only.h"

#include <binding_call_methods.h>
#include "binding_call_methods.h"
#include <native_value_converter.h>

#include "core/executing_context.h"
Expand All @@ -13,44 +13,44 @@

namespace webf {

DOMPointReadonly* DOMPointReadonly::Create(webf::ExecutingContext* context, webf::ExceptionState& exception_state) {
return MakeGarbageCollected<DOMPointReadonly>(context, exception_state);
DOMPointReadOnly* DOMPointReadOnly::Create(webf::ExecutingContext* context, webf::ExceptionState& exception_state) {
return MakeGarbageCollected<DOMPointReadOnly>(context, exception_state);
}
DOMPointReadonly* DOMPointReadonly::Create(webf::ExecutingContext* context,
DOMPointReadOnly* DOMPointReadOnly::Create(webf::ExecutingContext* context,
double x,
webf::ExceptionState& exception_state) {
return MakeGarbageCollected<DOMPointReadonly>(context, x, exception_state);
return MakeGarbageCollected<DOMPointReadOnly>(context, x, exception_state);
}
DOMPointReadonly* DOMPointReadonly::Create(webf::ExecutingContext* context,
DOMPointReadOnly* DOMPointReadOnly::Create(webf::ExecutingContext* context,
double x,
double y,
webf::ExceptionState& exception_state) {
return MakeGarbageCollected<DOMPointReadonly>(context, x, y, exception_state);
return MakeGarbageCollected<DOMPointReadOnly>(context, x, y, exception_state);
}
DOMPointReadonly* DOMPointReadonly::Create(webf::ExecutingContext* context,
DOMPointReadOnly* DOMPointReadOnly::Create(webf::ExecutingContext* context,
double x,
double y,
double z,
webf::ExceptionState& exception_state) {
return MakeGarbageCollected<DOMPointReadonly>(context, x, y, z, exception_state);
return MakeGarbageCollected<DOMPointReadOnly>(context, x, y, z, exception_state);
}
DOMPointReadonly* DOMPointReadonly::Create(webf::ExecutingContext* context,
DOMPointReadOnly* DOMPointReadOnly::Create(webf::ExecutingContext* context,
double x,
double y,
double z,
double w,
webf::ExceptionState& exception_state) {
return MakeGarbageCollected<DOMPointReadonly>(context, x, y, z, w, exception_state);
return MakeGarbageCollected<DOMPointReadOnly>(context, x, y, z, w, exception_state);
}

DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context, webf::ExceptionState& exception_state)
DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context, webf::ExceptionState& exception_state)
: BindingObject(context->ctx()) {
GetExecutingContext()->dartMethodPtr()->createBindingObject(GetExecutingContext()->isDedicated(),
GetExecutingContext()->contextId(), bindingObject(),
CreateBindingObjectType::kCreateDOMPoint, nullptr, 0);
}

DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context, double x, webf::ExceptionState& exception_state)
DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context, double x, webf::ExceptionState& exception_state)
: BindingObject(context->ctx()) {
NativeValue arguments[] = {NativeValueConverter<NativeTypeDouble>::ToNativeValue(x)};

Expand All @@ -59,7 +59,7 @@ DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context, double x, we
CreateBindingObjectType::kCreateDOMPoint, arguments, sizeof(arguments) / sizeof(NativeValue));
}

DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context,
DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context,
double x,
double y,
webf::ExceptionState& exception_state)
Expand All @@ -72,7 +72,7 @@ DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context,
CreateBindingObjectType::kCreateDOMPoint, arguments, sizeof(arguments) / sizeof(NativeValue));
}

DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context,
DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context,
double x,
double y,
double w,
Expand All @@ -87,7 +87,7 @@ DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context,
CreateBindingObjectType::kCreateDOMPoint, arguments, sizeof(arguments) / sizeof(NativeValue));
}

DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context,
DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context,
double x,
double y,
double w,
Expand All @@ -104,46 +104,46 @@ DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context,
CreateBindingObjectType::kCreateDOMPoint, arguments, sizeof(arguments) / sizeof(NativeValue));
}

DOMPointReadonly::DOMPointReadonly(webf::ExecutingContext* context, webf::NativeBindingObject* native_binding_object)
DOMPointReadOnly::DOMPointReadOnly(webf::ExecutingContext* context, webf::NativeBindingObject* native_binding_object)
: BindingObject(context->ctx(), native_binding_object) {}

double DOMPointReadonly::getPointProperty(const AtomicString& prop) const {
double DOMPointReadOnly::getPointProperty(const AtomicString& prop) const {
NativeValue dart_result = GetBindingProperty(prop, FlushUICommandReason::kDependentsOnElement, ASSERT_NO_EXCEPTION());
return NativeValueConverter<NativeTypeDouble>::FromNativeValue(dart_result);
}

void DOMPointReadonly::setPointProperty(const AtomicString& prop, double v, ExceptionState& exception_state) {
void DOMPointReadOnly::setPointProperty(const AtomicString& prop, double v, ExceptionState& exception_state) {
if (DynamicTo<DOMPoint>(this)) {
SetBindingProperty(prop, NativeValueConverter<NativeTypeDouble>::ToNativeValue(v), exception_state);
}
}

double DOMPointReadonly::x() const {
double DOMPointReadOnly::x() const {
return getPointProperty(binding_call_methods::kx);
}
void DOMPointReadonly::setX(double v, ExceptionState& exception_state) {
void DOMPointReadOnly::setX(double v, ExceptionState& exception_state) {
setPointProperty(binding_call_methods::kx, v, exception_state);
}
double DOMPointReadonly::y() {
double DOMPointReadOnly::y() {
return getPointProperty(binding_call_methods::ky);
}
void DOMPointReadonly::setY(double v, ExceptionState& exception_state) {
void DOMPointReadOnly::setY(double v, ExceptionState& exception_state) {
setPointProperty(binding_call_methods::ky, v, exception_state);
}
double DOMPointReadonly::z() const {
double DOMPointReadOnly::z() const {
return getPointProperty(binding_call_methods::kz);
}
void DOMPointReadonly::setZ(double v, ExceptionState& exception_state) {
void DOMPointReadOnly::setZ(double v, ExceptionState& exception_state) {
setPointProperty(binding_call_methods::kz, v, exception_state);
}
double DOMPointReadonly::w() const {
double DOMPointReadOnly::w() const {
return getPointProperty(binding_call_methods::kw);
}
void DOMPointReadonly::setW(double v, ExceptionState& exception_state) {
void DOMPointReadOnly::setW(double v, ExceptionState& exception_state) {
setPointProperty(binding_call_methods::kw, v, exception_state);
}

DOMPoint* DOMPointReadonly::matrixTransform(DOMMatrix* matrix, ExceptionState& exception_state) const {
DOMPoint* DOMPointReadOnly::matrixTransform(DOMMatrix* matrix, ExceptionState& exception_state) const {
NativeValue arguments[] = {
NativeValueConverter<NativeTypePointer<DOMMatrix>>::ToNativeValue(matrix)
};
Expand All @@ -157,7 +157,7 @@ DOMPoint* DOMPointReadonly::matrixTransform(DOMMatrix* matrix, ExceptionState& e
return MakeGarbageCollected<DOMPoint>(GetExecutingContext(), native_binding_object);
}

NativeValue DOMPointReadonly::HandleCallFromDartSide(const AtomicString& method,
NativeValue DOMPointReadOnly::HandleCallFromDartSide(const AtomicString& method,
int32_t argc,
const NativeValue* argv,
Dart_Handle dart_object) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
interface DOMPointReadonly {
interface DOMPointReadOnly {
x: number;
y: number;
z: number;
w: number;
matrixTransform(matrix: DOMMatrix): DOMPoint;
new(x?: number, y?:number, z?:number, w?:number): DOMPointReadonly;
new(x?: number, y?:number, z?:number, w?:number): DOMPointReadOnly;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,34 @@ struct DOMPointData {
class DOMPoint;
class DOMMatrix;

class DOMPointReadonly : public BindingObject {
class DOMPointReadOnly : public BindingObject {
DEFINE_WRAPPERTYPEINFO();

public:
using ImplType = DOMPointReadonly*;
using ImplType = DOMPointReadOnly*;

static DOMPointReadonly* Create(ExecutingContext* context, ExceptionState& exception_state);
static DOMPointReadonly* Create(ExecutingContext* context, double x, ExceptionState& exception_state);
static DOMPointReadonly* Create(ExecutingContext* context, double x, double y, ExceptionState& exception_state);
static DOMPointReadonly* Create(ExecutingContext* context,
static DOMPointReadOnly* Create(ExecutingContext* context, ExceptionState& exception_state);
static DOMPointReadOnly* Create(ExecutingContext* context, double x, ExceptionState& exception_state);
static DOMPointReadOnly* Create(ExecutingContext* context, double x, double y, ExceptionState& exception_state);
static DOMPointReadOnly* Create(ExecutingContext* context,
double x,
double y,
double z,
ExceptionState& exception_state);
static DOMPointReadonly* Create(ExecutingContext* context,
static DOMPointReadOnly* Create(ExecutingContext* context,
double x,
double y,
double z,
double w,
ExceptionState& exception_state);

DOMPointReadonly() = delete;
DOMPointReadOnly() = delete;

explicit DOMPointReadonly(ExecutingContext* context, ExceptionState& exception_state);
explicit DOMPointReadonly(ExecutingContext* context, double x, ExceptionState& exception_state);
explicit DOMPointReadonly(ExecutingContext* context, double x, double y, ExceptionState& exception_state);
explicit DOMPointReadonly(ExecutingContext* context, double x, double y, double z, ExceptionState& exception_state);
explicit DOMPointReadonly(ExecutingContext* context,
explicit DOMPointReadOnly(ExecutingContext* context, ExceptionState& exception_state);
explicit DOMPointReadOnly(ExecutingContext* context, double x, ExceptionState& exception_state);
explicit DOMPointReadOnly(ExecutingContext* context, double x, double y, ExceptionState& exception_state);
explicit DOMPointReadOnly(ExecutingContext* context, double x, double y, double z, ExceptionState& exception_state);
explicit DOMPointReadOnly(ExecutingContext* context,
double x,
double y,
double z,
Expand All @@ -72,7 +72,7 @@ class DOMPointReadonly : public BindingObject {
const NativeValue* argv,
Dart_Handle dart_object) override;
protected:
explicit DOMPointReadonly(ExecutingContext* context, NativeBindingObject* native_binding_object);
explicit DOMPointReadOnly(ExecutingContext* context, NativeBindingObject* native_binding_object);

private:
[[nodiscard]] double getPointProperty(const AtomicString& prop) const;
Expand Down
3 changes: 1 addition & 2 deletions bridge/scripts/code_generator/src/idl/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ export function addIndent(str: String, space: number) {
export function getClassName(blob: IDLBlob) {
let raw = camelCase(blob.filename[4].toUpperCase() + blob.filename.slice(5));
if (raw.slice(0, 3) == 'dom') {
console.log("className:" + raw)
if (raw === 'domMatrixReadonly') {
return `DOMMatrixReadOnly`;
} else if (raw === 'domPointReadonly') {
return `DOMPointReadonly`;
return `DOMPointReadOnly`;
}
return 'DOM' + raw.slice(3);
}
Expand Down

0 comments on commit ba5fb0a

Please sign in to comment.