aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-07-20 04:41:34 -0500
committerGitHub <noreply@github.com>2016-07-20 04:41:34 -0500
commitb6c0ed9a44b076928ea816ca529702eec25d0029 (patch)
tree444708b0079756882b70600ddd02beb7f2a4341c /components/script/dom/window.rs
parent2d01d41a506bcbc7f26a2284b9f42390d6ef96ab (diff)
parent72aa4f2f6243242a7490b789c24644aec49d8f9b (diff)
downloadservo-b6c0ed9a44b076928ea816ca529702eec25d0029.tar.gz
servo-b6c0ed9a44b076928ea816ca529702eec25d0029.zip
Auto merge of #12426 - asajeffrey:mozbrowser-event-targets, r=SimonSapin
Allow window elements as well as iframes to the the target of mozbrowser events <!-- Please describe your changes on the following line: --> Allow mozbrowser events, in particular mozbrowsererror events, to target a window. Needed for https://github.com/browserhtml/browserhtml/issues/1182 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #12420 - [X] These changes do not require tests because we're not testing our issue reporting system, which this is intended for. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12426) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 991e8fbfadc..4878f33f994 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -28,7 +28,9 @@ use dom::crypto::Crypto;
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration};
use dom::document::Document;
use dom::element::Element;
+use dom::event::Event;
use dom::eventtarget::EventTarget;
+use dom::htmliframeelement::build_mozbrowser_custom_event;
use dom::location::Location;
use dom::navigator::Navigator;
use dom::node::{Node, from_untrusted_node_address, window_from_node};
@@ -63,7 +65,7 @@ use script_runtime::{ScriptChan, ScriptPort, maybe_take_panic_result};
use script_thread::SendableMainThreadScriptChan;
use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
-use script_traits::{ConstellationControlMsg, UntrustedNodeAddress};
+use script_traits::{ConstellationControlMsg, MozBrowserEvent, UntrustedNodeAddress};
use script_traits::{DocumentState, MsDuration, TimerEvent, TimerEventId};
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource, WindowSizeData};
use std::ascii::AsciiExt;
@@ -1588,6 +1590,13 @@ impl Window {
_ => false,
}
}
+
+ #[allow(unsafe_code)]
+ pub fn dispatch_mozbrowser_event(&self, event: MozBrowserEvent) {
+ assert!(PREFS.is_mozbrowser_enabled());
+ let custom_event = build_mozbrowser_custom_event(&self, event);
+ custom_event.upcast::<Event>().fire(self.upcast());
+ }
}
impl Window {