aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmliframeelement.rs
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-10-21 14:00:48 -0400
committerBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-10-22 11:13:58 -0400
commitbbab8831e0286be7ebf0c2dc964d6a6b6c30d65f (patch)
treeb525d0f5b04bc318b79c4f00f36ba4aaba44e9b9 /components/script/dom/htmliframeelement.rs
parentf5e8df9dac9330f2818906c471ed05f5975828c6 (diff)
downloadservo-bbab8831e0286be7ebf0c2dc964d6a6b6c30d65f.tar.gz
servo-bbab8831e0286be7ebf0c2dc964d6a6b6c30d65f.zip
Usage of JSRef<Attr> in before_remove_attr & after_set_attr
JSRef<Attr> does not require allocating a DOMString for value, which are unused in most cases. It also provides more access to Attr data.
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r--components/script/dom/htmliframeelement.rs63
1 files changed, 33 insertions, 30 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 230a78df5b2..05b5ccaf46c 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::attr::Attr;
use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
@@ -23,7 +24,6 @@ use servo_msg::constellation_msg::{PipelineId, SubpageId};
use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed};
use servo_msg::constellation_msg::{ConstellationChan, LoadIframeUrlMsg};
use servo_util::str::DOMString;
-use string_cache::Atom;
use std::ascii::StrAsciiExt;
use std::cell::Cell;
@@ -188,44 +188,47 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
Some(htmlelement as &VirtualMethods)
}
- fn after_set_attr(&self, name: &Atom, value: DOMString) {
+ fn after_set_attr(&self, attr: JSRef<Attr>) {
match self.super_type() {
- Some(ref s) => s.after_set_attr(name, value.clone()),
- _ => (),
- }
-
- if "sandbox" == name.as_slice() {
- let mut modes = AllowNothing as u8;
- for word in value.as_slice().split(' ') {
- modes |= match word.to_ascii_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.set(Some(modes));
+ Some(ref s) => s.after_set_attr(attr),
+ _ => ()
}
- if "src" == name.as_slice() {
- let node: JSRef<Node> = NodeCast::from_ref(*self);
- if node.is_in_doc() {
- self.process_the_iframe_attributes()
- }
+ match attr.local_name() {
+ &atom!("sandbox") => {
+ let mut modes = AllowNothing as u8;
+ for word in attr.value().as_slice().split(' ') {
+ modes |= match word.to_ascii_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.set(Some(modes));
+ },
+ &atom!("src") => {
+ let node: JSRef<Node> = NodeCast::from_ref(*self);
+ if node.is_in_doc() {
+ self.process_the_iframe_attributes()
+ }
+ },
+ _ => ()
}
}
- fn before_remove_attr(&self, name: &Atom, value: DOMString) {
+ fn before_remove_attr(&self, attr: JSRef<Attr>) {
match self.super_type() {
- Some(ref s) => s.before_remove_attr(name, value),
- _ => (),
+ Some(ref s) => s.before_remove_attr(attr),
+ _ => ()
}
- if "sandbox" == name.as_slice() {
- self.sandbox.set(None);
+ match attr.local_name() {
+ &atom!("sandbox") => self.sandbox.set(None),
+ _ => ()
}
}