aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/htmliframeelement.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-03-14 12:00:42 +0100
committerMs2ger <ms2ger@gmail.com>2014-03-20 19:42:42 +0100
commit038a195eade5476601a183f4b74e669f8619d6a4 (patch)
tree1f956099ff9997778b5d1992dd9e15a8ba325d91 /src/components/script/dom/htmliframeelement.rs
parent0265fb9784baff3ea025198f3e5e73e6b81fe18e (diff)
downloadservo-038a195eade5476601a183f4b74e669f8619d6a4.tar.gz
servo-038a195eade5476601a183f4b74e669f8619d6a4.zip
Move attributes-related functions onto JS<Element>.
Diffstat (limited to 'src/components/script/dom/htmliframeelement.rs')
-rw-r--r--src/components/script/dom/htmliframeelement.rs71
1 files changed, 38 insertions, 33 deletions
diff --git a/src/components/script/dom/htmliframeelement.rs b/src/components/script/dom/htmliframeelement.rs
index 5098972ec15..a4999559cf5 100644
--- a/src/components/script/dom/htmliframeelement.rs
+++ b/src/components/script/dom/htmliframeelement.rs
@@ -7,7 +7,8 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLIFrameElementDerived
use dom::bindings::js::JS;
use dom::bindings::error::ErrorResult;
use dom::document::Document;
-use dom::element::HTMLIFrameElementTypeId;
+use dom::element::{HTMLIFrameElementTypeId, Element};
+use dom::element::{AttributeHandlers, AfterSetAttrListener, BeforeRemoveAttrListener};
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
use dom::node::{Node, ElementNodeTypeId};
@@ -114,40 +115,14 @@ impl HTMLIFrameElement {
Ok(())
}
- pub fn Sandbox(&self, _abstract_self: &JS<HTMLIFrameElement>) -> DOMString {
- self.htmlelement.element.get_string_attribute("sandbox")
+ pub fn Sandbox(&self, abstract_self: &JS<HTMLIFrameElement>) -> DOMString {
+ let element: JS<Element> = ElementCast::from(abstract_self);
+ element.get_string_attribute("sandbox")
}
- pub fn SetSandbox(&mut self, abstract_self: &JS<HTMLIFrameElement>, sandbox: DOMString) {
- self.htmlelement.element.set_string_attribute(&ElementCast::from(abstract_self),
- "sandbox",
- sandbox);
- }
-
- pub fn AfterSetAttr(&mut self, name: DOMString, value: DOMString) {
- if "sandbox" == name {
- let mut modes = AllowNothing as u8;
- for word in value.split(' ') {
- // FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
- let word_lower = word.to_ascii_lower();
- modes |= match word_lower.as_slice() {
- "allow-same-origin" => AllowSameOrigin,
- "allow-forms" => AllowForms,
- "allow-pointer-lock" => AllowPointerLock,
- "allow-popups" => AllowPopups,
- "allow-scripts" => AllowScripts,
- "allow-top-navigation" => AllowTopNavigation,
- _ => AllowNothing
- } as u8;
- }
- self.sandbox = Some(modes);
- }
- }
-
- pub fn BeforeRemoveAttr(&mut self, name: DOMString) {
- if "sandbox" == name {
- self.sandbox = None;
- }
+ pub fn SetSandbox(&mut self, abstract_self: &mut JS<HTMLIFrameElement>, sandbox: DOMString) {
+ let mut element: JS<Element> = ElementCast::from(abstract_self);
+ element.set_string_attribute("sandbox", sandbox);
}
pub fn AllowFullscreen(&self) -> bool {
@@ -234,3 +209,33 @@ impl HTMLIFrameElement {
None
}
}
+
+impl AfterSetAttrListener for JS<HTMLIFrameElement> {
+ fn AfterSetAttr(&mut self, name: DOMString, value: DOMString) {
+ if "sandbox" == name {
+ let mut modes = AllowNothing as u8;
+ for word in value.split(' ') {
+ // FIXME: Workaround for https://github.com/mozilla/rust/issues/10683
+ let word_lower = word.to_ascii_lower();
+ modes |= match word_lower.as_slice() {
+ "allow-same-origin" => AllowSameOrigin,
+ "allow-forms" => AllowForms,
+ "allow-pointer-lock" => AllowPointerLock,
+ "allow-popups" => AllowPopups,
+ "allow-scripts" => AllowScripts,
+ "allow-top-navigation" => AllowTopNavigation,
+ _ => AllowNothing
+ } as u8;
+ }
+ self.get_mut().sandbox = Some(modes);
+ }
+ }
+}
+
+impl BeforeRemoveAttrListener for JS<HTMLIFrameElement> {
+ fn BeforeRemoveAttr(&mut self, name: DOMString) {
+ if "sandbox" == name {
+ self.get_mut().sandbox = None;
+ }
+ }
+}