diff options
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r-- | components/script/dom/htmliframeelement.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 3c5377b8c98..f279c2cff79 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -50,15 +50,17 @@ use style::context::ReflowGoal; use url::Url; use util::prefs::mozbrowser_enabled; -#[derive(HeapSizeOf)] -enum SandboxAllowance { - AllowNothing = 0x00, - AllowSameOrigin = 0x01, - AllowTopNavigation = 0x02, - AllowForms = 0x04, - AllowScripts = 0x08, - AllowPointerLock = 0x10, - AllowPopups = 0x20 +bitflags! { + #[derive(JSTraceable, HeapSizeOf)] + flags SandboxAllowance: u8 { + const ALLOW_NOTHING = 0x00, + const ALLOW_SAME_ORIGIN = 0x01, + const ALLOW_TOP_NAVIGATION = 0x02, + const ALLOW_FORMS = 0x04, + const ALLOW_SCRIPTS = 0x08, + const ALLOW_POINTER_LOCK = 0x10, + const ALLOW_POPUPS = 0x20 + } } #[dom_struct] @@ -67,7 +69,7 @@ pub struct HTMLIFrameElement { pipeline_id: Cell<Option<PipelineId>>, subpage_id: Cell<Option<SubpageId>>, sandbox: MutNullableHeap<JS<DOMTokenList>>, - sandbox_allowance: Cell<Option<u8>>, + sandbox_allowance: Cell<Option<SandboxAllowance>>, load_blocker: DOMRefCell<Option<LoadBlocker>>, visibility: Cell<bool>, } @@ -589,17 +591,17 @@ impl VirtualMethods for HTMLIFrameElement { match attr.local_name() { &atom!("sandbox") => { self.sandbox_allowance.set(mutation.new_value(attr).map(|value| { - let mut modes = SandboxAllowance::AllowNothing as u8; + let mut modes = ALLOW_NOTHING; for token in value.as_tokens() { modes |= match &*token.to_ascii_lowercase() { - "allow-same-origin" => SandboxAllowance::AllowSameOrigin, - "allow-forms" => SandboxAllowance::AllowForms, - "allow-pointer-lock" => SandboxAllowance::AllowPointerLock, - "allow-popups" => SandboxAllowance::AllowPopups, - "allow-scripts" => SandboxAllowance::AllowScripts, - "allow-top-navigation" => SandboxAllowance::AllowTopNavigation, - _ => SandboxAllowance::AllowNothing - } as u8; + "allow-same-origin" => ALLOW_SAME_ORIGIN, + "allow-forms" => ALLOW_FORMS, + "allow-pointer-lock" => ALLOW_POINTER_LOCK, + "allow-popups" => ALLOW_POPUPS, + "allow-scripts" => ALLOW_SCRIPTS, + "allow-top-navigation" => ALLOW_TOP_NAVIGATION, + _ => ALLOW_NOTHING + }; } modes })); |