aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/gamepad.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-19 17:47:27 -0400
committerGitHub <noreply@github.com>2018-09-19 17:47:27 -0400
commitdf2adebefdfa3da49f173e480fa1e56450f9bda2 (patch)
tree1f05b49bac02318455a59d5b143c186fd872bdb9 /components/script/dom/gamepad.rs
parent2ca7a134736bb4759ff209c1bc0b6dc3cc1984c9 (diff)
parentc37a345dc9f4dda6ea29c42f96f6c7201c42cbac (diff)
downloadservo-df2adebefdfa3da49f173e480fa1e56450f9bda2.tar.gz
servo-df2adebefdfa3da49f173e480fa1e56450f9bda2.zip
Auto merge of #21737 - chansuke:format_script, r=jdm
Format script component --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix part of #21373. - [x] These changes do not require tests because they format code only. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21737) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/gamepad.rs')
-rw-r--r--components/script/dom/gamepad.rs46
1 files changed, 26 insertions, 20 deletions
diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs
index 769b1ee548f..d4858de99f8 100644
--- a/components/script/dom/gamepad.rs
+++ b/components/script/dom/gamepad.rs
@@ -37,20 +37,22 @@ pub struct Gamepad {
pose: Option<Dom<VRPose>>,
#[ignore_malloc_size_of = "Defined in rust-webvr"]
hand: WebVRGamepadHand,
- display_id: u32
+ display_id: u32,
}
impl Gamepad {
- fn new_inherited(gamepad_id: u32,
- id: String,
- index: i32,
- connected: bool,
- timestamp: f64,
- mapping_type: String,
- buttons: &GamepadButtonList,
- pose: Option<&VRPose>,
- hand: WebVRGamepadHand,
- display_id: u32) -> Gamepad {
+ fn new_inherited(
+ gamepad_id: u32,
+ id: String,
+ index: i32,
+ connected: bool,
+ timestamp: f64,
+ mapping_type: String,
+ buttons: &GamepadButtonList,
+ pose: Option<&VRPose>,
+ hand: WebVRGamepadHand,
+ display_id: u32,
+ ) -> Gamepad {
Self {
reflector_: Reflector::new(),
gamepad_id: gamepad_id,
@@ -63,15 +65,17 @@ impl Gamepad {
buttons: Dom::from_ref(buttons),
pose: pose.map(Dom::from_ref),
hand: hand,
- display_id: display_id
+ display_id: display_id,
}
}
#[allow(unsafe_code)]
- pub fn new_from_vr(global: &GlobalScope,
- index: i32,
- data: &WebVRGamepadData,
- state: &WebVRGamepadState) -> DomRoot<Gamepad> {
+ pub fn new_from_vr(
+ global: &GlobalScope,
+ index: i32,
+ data: &WebVRGamepadData,
+ state: &WebVRGamepadState,
+ ) -> DomRoot<Gamepad> {
let buttons = GamepadButtonList::new_from_vr(&global, &state.buttons);
let pose = VRPose::new(&global, &state.pose);
@@ -86,10 +90,10 @@ impl Gamepad {
&buttons,
Some(&pose),
data.hand.clone(),
- data.display_id
+ data.display_id,
)),
global,
- GamepadBinding::Wrap
+ GamepadBinding::Wrap,
);
let cx = global.get_cx();
@@ -145,7 +149,7 @@ impl GamepadMethods for Gamepad {
let value = match self.hand {
WebVRGamepadHand::Unknown => "",
WebVRGamepadHand::Left => "left",
- WebVRGamepadHand::Right => "right"
+ WebVRGamepadHand::Right => "right",
};
value.into()
}
@@ -204,6 +208,8 @@ impl Gamepad {
pub fn notify_event(&self, event_type: GamepadEventType) {
let event = GamepadEvent::new_with_type(&self.global(), event_type, &self);
- event.upcast::<Event>().fire(self.global().as_window().upcast::<EventTarget>());
+ event
+ .upcast::<Event>()
+ .fire(self.global().as_window().upcast::<EventTarget>());
}
}