diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2015-08-27 02:27:42 +0530 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-08-27 02:27:42 +0530 |
commit | 4678ec16bb7e3aa242f30d6a9d675d5aeaec7cf7 (patch) | |
tree | d495d9e4171c209393e9b9adb645a4cfb9cd0f3a | |
parent | b33c5427bc350e42503e2de1a8f832c63522b2d0 (diff) | |
download | servo-4678ec16bb7e3aa242f30d6a9d675d5aeaec7cf7.tar.gz servo-4678ec16bb7e3aa242f30d6a9d675d5aeaec7cf7.zip |
remove to_borrowed_ref, fix Activatable
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 8 | ||||
-rw-r--r-- | components/script/dom/element.rs | 10 | ||||
-rw-r--r-- | components/script/dom/htmlanchorelement.rs | 10 | ||||
-rw-r--r-- | components/script/dom/htmlinputelement.rs | 16 |
4 files changed, 18 insertions, 26 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 35a1687f488..a88904df663 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5808,14 +5808,6 @@ impl ${name}Cast { } #[inline] - pub fn to_borrowed_ref<'a, 'b, T: ${toBound}+Reflectable>(base: &'a &'b T) -> Option<&'a &'b ${name}> { - match base.${checkFn}() { - true => Some(unsafe { mem::transmute(base) }), - false => None - } - } - - #[inline] #[allow(unrooted_must_root)] pub fn to_layout_js<T: ${toBound}+Reflectable>(base: &LayoutJS<T>) -> Option<LayoutJS<${name}>> { unsafe { diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index d4f56c13084..b0f28f62cab 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1854,7 +1854,7 @@ impl<'a> ::selectors::Element for Root<Element> { } pub trait ActivationElementHelpers<'a> { - fn as_maybe_activatable(&'a self) -> Option<&'a (Activatable + 'a)>; + fn as_maybe_activatable(self) -> Option<&'a (Activatable + 'a)>; fn click_in_progress(self) -> bool; fn set_click_in_progress(self, click: bool); fn nearest_activable_element(self) -> Option<Root<Element>>; @@ -1862,15 +1862,15 @@ pub trait ActivationElementHelpers<'a> { } impl<'a> ActivationElementHelpers<'a> for &'a Element { - fn as_maybe_activatable(&'a self) -> Option<&'a (Activatable + 'a)> { - let node = NodeCast::from_ref(*self); + fn as_maybe_activatable(self) -> Option<&'a (Activatable + 'a)> { + let node = NodeCast::from_ref(self); let element = match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => { - let element = HTMLInputElementCast::to_borrowed_ref(self).unwrap(); + let element = HTMLInputElementCast::to_ref(self).unwrap(); Some(element as &'a (Activatable + 'a)) }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => { - let element = HTMLAnchorElementCast::to_borrowed_ref(self).unwrap(); + let element = HTMLAnchorElementCast::to_ref(self).unwrap(); Some(element as &'a (Activatable + 'a)) }, _ => { diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 33b118c1be8..b21b4e39e81 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -102,9 +102,9 @@ impl<'a> HTMLAnchorElementMethods for &'a HTMLAnchorElement { } } -impl<'a> Activatable for &'a HTMLAnchorElement { +impl Activatable for HTMLAnchorElement { fn as_element<'b>(&'b self) -> &'b Element { - ElementCast::from_ref(*self) + ElementCast::from_ref(self) } fn is_instance_activatable(&self) -> bool { @@ -113,7 +113,7 @@ impl<'a> Activatable for &'a HTMLAnchorElement { // hyperlink" // https://html.spec.whatwg.org/multipage/#the-a-element // "The activation behaviour of a elements *that create hyperlinks*" - ElementCast::from_ref(*self).has_attribute(&atom!("href")) + ElementCast::from_ref(self).has_attribute(&atom!("href")) } @@ -129,13 +129,13 @@ impl<'a> Activatable for &'a HTMLAnchorElement { //https://html.spec.whatwg.org/multipage/#the-a-element:activation-behaviour fn activation_behavior(&self, event: &Event, target: &EventTarget) { //Step 1. If the node document is not fully active, abort. - let doc = document_from_node(*self); + let doc = document_from_node(self); if !doc.r().is_fully_active() { return; } //TODO: Step 2. Check if browsing context is specified and act accordingly. //Step 3. Handle <img ismap/>. - let element = ElementCast::from_ref(*self); + let element = ElementCast::from_ref(self); let mouse_event = MouseEventCast::to_ref(event).unwrap(); let mut ismap_suffix = None; if let Some(element) = ElementCast::to_ref(target) { diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 2116a1b89ac..9c29f967f99 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -652,9 +652,9 @@ impl<'a> FormControl<'a> for &'a HTMLInputElement { } } -impl<'a> Activatable for &'a HTMLInputElement { +impl Activatable for HTMLInputElement { fn as_element<'b>(&'b self) -> &'b Element { - ElementCast::from_ref(*self) + ElementCast::from_ref(self) } fn is_instance_activatable(&self) -> bool { @@ -698,7 +698,7 @@ impl<'a> Activatable for &'a HTMLInputElement { InputType::InputRadio => { //TODO: if not in document, use root ancestor instead of document let owner = self.form_owner(); - let doc = document_from_node(*self); + let doc = document_from_node(self); let doc_node = NodeCast::from_ref(doc.r()); let group = self.get_radio_group_name();; @@ -803,19 +803,19 @@ impl<'a> Activatable for &'a HTMLInputElement { // https://html.spec.whatwg.org/multipage/#checkbox-state-(type=checkbox):activation-behavior // https://html.spec.whatwg.org/multipage/#radio-button-state-(type=radio):activation-behavior if self.mutable() { - let win = window_from_node(*self); + let win = window_from_node(self); let event = Event::new(GlobalRef::Window(win.r()), "input".to_owned(), EventBubbles::Bubbles, EventCancelable::NotCancelable); - let target = EventTargetCast::from_ref(*self); + let target = EventTargetCast::from_ref(self); event.r().fire(target); let event = Event::new(GlobalRef::Window(win.r()), "change".to_owned(), EventBubbles::Bubbles, EventCancelable::NotCancelable); - let target = EventTargetCast::from_ref(*self); + let target = EventTargetCast::from_ref(self); event.r().fire(target); } }, @@ -826,7 +826,7 @@ impl<'a> Activatable for &'a HTMLInputElement { // https://html.spec.whatwg.org/multipage/#implicit-submission #[allow(unsafe_code)] fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) { - let doc = document_from_node(*self); + let doc = document_from_node(self); let node = NodeCast::from_ref(doc.r()); let owner = self.form_owner(); let form = match owner { @@ -834,7 +834,7 @@ impl<'a> Activatable for &'a HTMLInputElement { Some(ref f) => f }; - let elem = ElementCast::from_ref(*self); + let elem = ElementCast::from_ref(self); if elem.click_in_progress() { return; } |