-
-
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.
[WIP]feat: support w3c deviceOrientationEvent
- add device orientation Event in bridge
- Loading branch information
Showing
12 changed files
with
180 additions
and
0 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
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 |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
] | ||
}, | ||
"hashchange", | ||
"deviceorientation", | ||
"input", | ||
{ | ||
"class": "FocusEvent", | ||
|
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,66 @@ | ||
/* | ||
* Copyright (C) 2024-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
#include "deviceorientation_event.h" | ||
#include "qjs_device_orientation_event.h" | ||
|
||
namespace webf { | ||
|
||
DeviceorientationEvent* DeviceorientationEvent::Create(ExecutingContext* context, | ||
const AtomicString& type, | ||
ExceptionState& exception_state) { | ||
return MakeGarbageCollected<DeviceorientationEvent>(context, type, exception_state); | ||
} | ||
|
||
DeviceorientationEvent* DeviceorientationEvent::Create(ExecutingContext* context, | ||
const AtomicString& type, | ||
const std::shared_ptr<DeviceorientationEventInit>& initializer, | ||
ExceptionState& exception_state) { | ||
return MakeGarbageCollected<DeviceorientationEvent>(context, type, initializer, exception_state); | ||
} | ||
|
||
DeviceorientationEvent::DeviceorientationEvent(ExecutingContext* context, const AtomicString& type, ExceptionState& exception_state) | ||
: Event(context, type) {} | ||
|
||
DeviceorientationEvent::DeviceorientationEvent(ExecutingContext* context, | ||
const AtomicString& type, | ||
const std::shared_ptr<DeviceorientationEventInit>& initializer, | ||
ExceptionState& exception_state) | ||
: Event(context, type), | ||
absolute_(initializer->hasAbsolute ? initializer->absolute()), | ||
alpha_(initializer->hasAlpha() ? initializer->alpha() : 0.0), | ||
beta_(initializer->hasBeta() ? initializer->beta() : 0.0), | ||
gamma_(initializer->hasGamma() ? initializer->gamma() : 0.0) {} | ||
|
||
DeviceorientationEvent::DeviceorientationEvent(ExecutingContext* context, | ||
const AtomicString& type, | ||
NativeDeviceorientationEvent* native_orientation_event) | ||
: Event(context, type, &native_orientation_event->native_event), | ||
absolute_(native_orientation_event->absolute), | ||
alpha_(native_orientation_event->alpha), | ||
beta_(native_orientation_event->beta), | ||
gamma_(native_orientation_event->gamma) { | ||
} | ||
|
||
bool DeviceorientationEvent::IsDeviceorientationEvent() const { | ||
return true; | ||
} | ||
|
||
bool DeviceorientationEvent::absolute() const { | ||
return absolute_; | ||
} | ||
|
||
double DeviceorientationEvent::alpha() const { | ||
return alpha_; | ||
} | ||
|
||
double DeviceorientationEvent::beta() const { | ||
return beta_; | ||
} | ||
|
||
double DeviceorientationEvent::gamma() const { | ||
return gamma_; | ||
} | ||
|
||
} // 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,11 @@ | ||
import {Event} from "../dom/events/event"; | ||
import {DeviceorientationEventInit} from "./device_orientation_event_init"; | ||
|
||
interface DeviceorientationEvent extends Event { | ||
readonly absolute: boolean; | ||
readonly alpha: number; | ||
readonly beta: number; | ||
readonly gamma: number; | ||
[key: string]: any; | ||
new(type: string, init?: DeviceorientationEventInit): DeviceorientationEvent; | ||
} |
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,55 @@ | ||
/* | ||
* Copyright (C) 2024-present The WebF authors. All rights reserved. | ||
*/ | ||
|
||
#ifndef BRIDGE_CORE_EVENTS_GESTURE_EVENT_H_ | ||
#define BRIDGE_CORE_EVENTS_GESTURE_EVENT_H_ | ||
|
||
#include "bindings/qjs/dictionary_base.h" | ||
#include "bindings/qjs/source_location.h" | ||
#include "core/dom/events/event.h" | ||
#include "qjs_device_orientation_event_init.h" | ||
|
||
namespace webf { | ||
|
||
struct NativeDeviceorientationEvent; | ||
|
||
class DeviceorientationEvent : public Event { | ||
DEFINE_WRAPPERTYPEINFO(); | ||
|
||
public: | ||
using ImplType = DeviceorientationEvent*; | ||
|
||
static DeviceorientationEvent* Create(ExecutingContext* context, const AtomicString& type, ExceptionState& exception_state); | ||
|
||
static DeviceorientationEvent* Create(ExecutingContext* context, | ||
const AtomicString& type, | ||
const std::shared_ptr<DeviceorientationEventInit>& initializer, | ||
ExceptionState& exception_state); | ||
|
||
explicit DeviceorientationEvent(ExecutingContext* context, const AtomicString& type, ExceptionState& exception_state); | ||
|
||
explicit DeviceorientationEvent(ExecutingContext* context, | ||
const AtomicString& type, | ||
const std::shared_ptr<DeviceorientationEventInit>& initializer, | ||
ExceptionState& exception_state); | ||
|
||
explicit DeviceorientationEvent(ExecutingContext* context, const AtomicString& type, NativeDeviceorientationEvent* native_orientation_event); | ||
|
||
bool absolute() const; | ||
double alpha() const; | ||
double beta() const; | ||
double gamma() const; | ||
|
||
bool IsDeviceorientationEvent() const override; | ||
|
||
private: | ||
bool absolute_; | ||
double alpha_; | ||
double beta_; | ||
double gamma_; | ||
}; | ||
|
||
} // namespace webf | ||
|
||
#endif // BRIDGE_CORE_EVENTS_GESTURE_EVENT_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,10 @@ | ||
import { EventInit } from "../dom/events/event_init"; | ||
|
||
// @ts-ignore | ||
@Dictionary() | ||
export interface DeviceorientationEventInit extends EventInit { | ||
absolute?: boolean; | ||
alpha?: number; | ||
beta?: number; | ||
gamma?: number; | ||
} |
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 |
---|---|---|
|
@@ -224,6 +224,7 @@ | |
"wheel", | ||
"zoom", | ||
"intersectionchange", | ||
"deviceorientation", | ||
"gcopen" | ||
] | ||
} |
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