aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmliframeelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r--components/script/dom/htmliframeelement.rs63
1 files changed, 25 insertions, 38 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index f38a591bd45..99af406790b 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -180,7 +180,7 @@ impl RawHTMLIFrameElementHelpers for HTMLIFrameElement {
#[allow(unsafe_code)]
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
- element::get_attr_for_layout(ElementCast::from_actual(&*self),
+ element::get_attr_for_layout(ElementCast::from_ref(&*self),
&ns!(""),
&atom!("width")).map(|attribute| {
str::parse_length(&**attribute.value_for_layout())
@@ -191,7 +191,7 @@ impl RawHTMLIFrameElementHelpers for HTMLIFrameElement {
#[allow(unsafe_code)]
fn get_height(&self) -> LengthOrPercentageOrAuto {
unsafe {
- element::get_attr_for_layout(ElementCast::from_actual(&*self),
+ element::get_attr_for_layout(ElementCast::from_ref(&*self),
&ns!(""),
&atom!("height")).map(|attribute| {
str::parse_length(&**attribute.value_for_layout())
@@ -232,6 +232,27 @@ impl HTMLIFrameElement {
}
}
+pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> Fallible<()> {
+ if iframe.Mozbrowser() {
+ let node = NodeCast::from_ref(iframe);
+ if node.is_in_doc() {
+ let window = window_from_node(iframe);
+ let window = window.r();
+
+ let pipeline_info = Some((iframe.containing_page_pipeline_id().unwrap(),
+ iframe.subpage_id().unwrap()));
+ let ConstellationChan(ref chan) = window.constellation_chan();
+ let msg = ConstellationMsg::Navigate(pipeline_info, direction);
+ chan.send(msg).unwrap();
+ }
+
+ Ok(())
+ } else {
+ debug!("this frame is not mozbrowser (or experimental_enabled is false)");
+ Err(NotSupported)
+ }
+}
+
impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
fn Src(self) -> DOMString {
let element = ElementCast::from_ref(self);
@@ -308,46 +329,12 @@ impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
fn GoBack(self) -> Fallible<()> {
- if self.Mozbrowser() {
- let node = NodeCast::from_ref(self);
- if node.is_in_doc() {
- let window = window_from_node(self);
- let window = window.r();
-
- let pipeline_info = Some((self.containing_page_pipeline_id().unwrap(),
- self.subpage_id().unwrap()));
- let ConstellationChan(ref chan) = window.constellation_chan();
- let msg = ConstellationMsg::Navigate(pipeline_info, NavigationDirection::Back);
- chan.send(msg).unwrap();
- }
-
- Ok(())
- } else {
- debug!("this frame is not mozbrowser (or experimental_enabled is false)");
- Err(NotSupported)
- }
+ Navigate(self, NavigationDirection::Back)
}
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goForward
fn GoForward(self) -> Fallible<()> {
- if self.Mozbrowser() {
- let node = NodeCast::from_ref(self);
- if node.is_in_doc() {
- let window = window_from_node(self);
- let window = window.r();
-
- let pipeline_info = Some((self.containing_page_pipeline_id().unwrap(),
- self.subpage_id().unwrap()));
- let ConstellationChan(ref chan) = window.constellation_chan();
- let msg = ConstellationMsg::Navigate(pipeline_info, NavigationDirection::Forward);
- chan.send(msg).unwrap();
- }
-
- Ok(())
- } else {
- debug!("this frame is not mozbrowser (or experimental_enabled is false)");
- Err(NotSupported)
- }
+ Navigate(self, NavigationDirection::Forward)
}
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/reload