mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
implement and use From<bool> for enum and back
implement and use From<bool> for EventBubbles (and back direction) implement and use From<bool> for EventCancelable (and back direction)
This commit is contained in:
parent
7a9dc57761
commit
0a5ac3b207
10 changed files with 68 additions and 78 deletions
|
@ -48,20 +48,15 @@ impl UIEvent {
|
|||
view: Option<&Window>,
|
||||
detail: i32) -> Root<UIEvent> {
|
||||
let ev = UIEvent::new_uninitialized(window);
|
||||
ev.InitUIEvent(type_, can_bubble == EventBubbles::Bubbles,
|
||||
cancelable == EventCancelable::Cancelable, view, detail);
|
||||
ev.InitUIEvent(type_, bool::from(can_bubble), bool::from(cancelable), view, detail);
|
||||
ev
|
||||
}
|
||||
|
||||
pub fn Constructor(global: GlobalRef,
|
||||
type_: DOMString,
|
||||
init: &UIEventBinding::UIEventInit) -> Fallible<Root<UIEvent>> {
|
||||
let bubbles = if init.parent.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble };
|
||||
let cancelable = if init.parent.cancelable {
|
||||
EventCancelable::Cancelable
|
||||
} else {
|
||||
EventCancelable::NotCancelable
|
||||
};
|
||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||
let event = UIEvent::new(global.as_window(), type_,
|
||||
bubbles, cancelable,
|
||||
init.view.r(), init.detail);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue