aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmliframeelement.rs54
-rw-r--r--components/script/dom/webidls/BrowserElement.webidl22
-rw-r--r--components/script/dom/window.rs8
3 files changed, 74 insertions, 10 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 44122f07fe4..54712f44cad 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -11,12 +11,13 @@ use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementLocat
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementOpenTabEventDetail;
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementOpenWindowEventDetail;
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementSecurityChangeDetail;
+use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementVisibilityChangeEventDetail;
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserShowModalPromptEventDetail;
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::conversions::ToJSValConvertible;
-use dom::bindings::error::{Error, ErrorResult};
+use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, LayoutJS};
@@ -66,6 +67,7 @@ pub struct HTMLIFrameElement {
subpage_id: Cell<Option<SubpageId>>,
sandbox: Cell<Option<u8>>,
load_blocker: DOMRefCell<Option<LoadBlocker>>,
+ visibility: Cell<bool>,
}
impl HTMLIFrameElement {
@@ -196,6 +198,7 @@ impl HTMLIFrameElement {
subpage_id: Cell::new(None),
sandbox: Cell::new(None),
load_blocker: DOMRefCell::new(None),
+ visibility: Cell::new(true),
}
}
@@ -221,6 +224,26 @@ impl HTMLIFrameElement {
self.pipeline_id.get()
}
+ pub fn change_visibility_status(&self, visibility: bool) {
+ if self.visibility.get() != visibility {
+ self.visibility.set(visibility);
+
+ // Visibility changes are only exposed to Mozbrowser iframes
+ if self.Mozbrowser() {
+ self.dispatch_mozbrowser_event(MozBrowserEvent::VisibilityChange(visibility));
+ }
+ }
+ }
+
+ pub fn set_visible(&self, visible: bool) {
+ if let Some(pipeline_id) = self.pipeline_id.get() {
+ let window = window_from_node(self);
+ let window = window.r();
+ let msg = ConstellationMsg::SetVisible(pipeline_id, visible);
+ window.constellation_chan().send(msg).unwrap();
+ }
+ }
+
/// https://html.spec.whatwg.org/multipage/#iframe-load-event-steps steps 1-4
pub fn iframe_load_event_steps(&self, loaded_pipeline: PipelineId) {
// TODO(#9592): assert that the load blocker is present at all times when we
@@ -387,6 +410,11 @@ impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
returnValue: Some(DOMString::from(return_value)),
}.to_jsval(cx, rval)
}
+ MozBrowserEvent::VisibilityChange(visibility) => {
+ BrowserElementVisibilityChangeEventDetail {
+ visible: Some(visibility),
+ }.to_jsval(cx, rval);
+ }
}
}
}
@@ -498,6 +526,30 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
}
}
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/setVisible
+ fn SetVisible(&self, visible: bool) -> ErrorResult {
+ if self.Mozbrowser() {
+ self.set_visible(visible);
+ Ok(())
+ } else {
+ debug!("this frame is not mozbrowser: mozbrowser attribute missing, or not a top
+ level window, or mozbrowser preference not set (use --pref dom.mozbrowser.enabled)");
+ Err(Error::NotSupported)
+ }
+ }
+
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/getVisible
+ fn GetVisible(&self) -> Fallible<bool> {
+ if self.Mozbrowser() {
+ Ok(self.visibility.get())
+ } else {
+ debug!("this frame is not mozbrowser: mozbrowser attribute missing, or not a top
+ level window, or mozbrowser preference not set (use --pref dom.mozbrowser.enabled)");
+ Err(Error::NotSupported)
+ }
+ }
+
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/stop
fn Stop(&self) -> ErrorResult {
Err(Error::NotSupported)
diff --git a/components/script/dom/webidls/BrowserElement.webidl b/components/script/dom/webidls/BrowserElement.webidl
index 9351cc9377a..f183b5cf813 100644
--- a/components/script/dom/webidls/BrowserElement.webidl
+++ b/components/script/dom/webidls/BrowserElement.webidl
@@ -96,20 +96,24 @@ dictionary BrowserElementOpenWindowEventDetail {
// Element frameElement;
};
+dictionary BrowserElementVisibilityChangeEventDetail {
+ boolean visible;
+};
+
BrowserElement implements BrowserElementCommon;
BrowserElement implements BrowserElementPrivileged;
[NoInterfaceObject]
interface BrowserElementCommon {
- //[Throws,
- // Pref="dom.mozBrowserFramesEnabled",
- // CheckAnyPermissions="browser embed-widgets"]
- //void setVisible(boolean visible);
-
- //[Throws,
- // Pref="dom.mozBrowserFramesEnabled",
- // CheckAnyPermissions="browser embed-widgets"]
- //DOMRequest getVisible();
+ [Throws,
+ Pref="dom.mozbrowser.enabled",
+ CheckAnyPermissions="browser embed-widgets"]
+ void setVisible(boolean visible);
+
+ [Throws,
+ Pref="dom.mozbrowser.enabled",
+ CheckAnyPermissions="browser embed-widgets"]
+ boolean getVisible();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled",
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 4bfbb1993d1..b778b37abd7 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -1477,6 +1477,14 @@ impl Window {
self.timers.suspend();
}
+ pub fn slow_down_timers(&self) {
+ self.timers.slow_down();
+ }
+
+ pub fn speed_up_timers(&self) {
+ self.timers.speed_up();
+ }
+
pub fn need_emit_timeline_marker(&self, timeline_type: TimelineMarkerType) -> bool {
let markers = self.devtools_markers.borrow();
markers.contains(&timeline_type)