mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Allow window elements as well as iframes to the the target of mozbrowser events.
This commit is contained in:
parent
fa432a5a34
commit
72aa4f2f62
8 changed files with 162 additions and 152 deletions
|
@ -1043,14 +1043,14 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
|
|
||||||
debug!("Panic handler for pipeline {:?}: {}.", pipeline_id, reason);
|
debug!("Panic handler for pipeline {:?}: {}.", pipeline_id, reason);
|
||||||
|
|
||||||
|
// Notify the browser chrome that the pipeline has failed
|
||||||
|
self.trigger_mozbrowsererror(pipeline_id, reason, backtrace);
|
||||||
|
|
||||||
if let Some(pipeline_id) = pipeline_id {
|
if let Some(pipeline_id) = pipeline_id {
|
||||||
let pipeline_url = self.pipelines.get(&pipeline_id).map(|pipeline| pipeline.url.clone());
|
let pipeline_url = self.pipelines.get(&pipeline_id).map(|pipeline| pipeline.url.clone());
|
||||||
let parent_info = self.pipelines.get(&pipeline_id).and_then(|pipeline| pipeline.parent_info);
|
let parent_info = self.pipelines.get(&pipeline_id).and_then(|pipeline| pipeline.parent_info);
|
||||||
let window_size = self.pipelines.get(&pipeline_id).and_then(|pipeline| pipeline.size);
|
let window_size = self.pipelines.get(&pipeline_id).and_then(|pipeline| pipeline.size);
|
||||||
|
|
||||||
// Notify the browser chrome that the pipeline has failed
|
|
||||||
self.trigger_mozbrowsererror(pipeline_id, reason, backtrace);
|
|
||||||
|
|
||||||
self.close_pipeline(pipeline_id, ExitPipelineMode::Force);
|
self.close_pipeline(pipeline_id, ExitPipelineMode::Force);
|
||||||
self.pipelines.remove(&pipeline_id);
|
self.pipelines.remove(&pipeline_id);
|
||||||
|
|
||||||
|
@ -1082,12 +1082,10 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
self.handled_panic = true;
|
self.handled_panic = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: trigger a mozbrowsererror even if there's no pipeline id
|
|
||||||
fn handle_log_entry(&mut self, pipeline_id: Option<PipelineId>, thread_name: Option<String>, entry: LogEntry) {
|
fn handle_log_entry(&mut self, pipeline_id: Option<PipelineId>, thread_name: Option<String>, entry: LogEntry) {
|
||||||
match (pipeline_id, entry) {
|
match entry {
|
||||||
(Some(pipeline_id), LogEntry::Panic(reason, backtrace)) =>
|
LogEntry::Panic(reason, backtrace) => self.trigger_mozbrowsererror(pipeline_id, reason, backtrace),
|
||||||
self.trigger_mozbrowsererror(pipeline_id, reason, backtrace),
|
LogEntry::Error(reason) | LogEntry::Warn(reason) => {
|
||||||
(None, LogEntry::Panic(reason, _)) | (_, LogEntry::Error(reason)) | (_, LogEntry::Warn(reason)) => {
|
|
||||||
// VecDeque::truncate is unstable
|
// VecDeque::truncate is unstable
|
||||||
if WARNINGS_BUFFER_SIZE <= self.handled_warnings.len() {
|
if WARNINGS_BUFFER_SIZE <= self.handled_warnings.len() {
|
||||||
self.handled_warnings.pop_front();
|
self.handled_warnings.pop_front();
|
||||||
|
@ -1284,7 +1282,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsershowmodalprompt
|
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsershowmodalprompt
|
||||||
let event = MozBrowserEvent::ShowModalPrompt("alert".to_owned(), "Alert".to_owned(),
|
let event = MozBrowserEvent::ShowModalPrompt("alert".to_owned(), "Alert".to_owned(),
|
||||||
String::from(message), "".to_owned());
|
String::from(message), "".to_owned());
|
||||||
root_pipeline.trigger_mozbrowser_event(subpage_id, event);
|
root_pipeline.trigger_mozbrowser_event(Some(subpage_id), event);
|
||||||
}
|
}
|
||||||
None => return warn!("Alert sent to Pipeline {:?} after closure.", root_pipeline_id),
|
None => return warn!("Alert sent to Pipeline {:?} after closure.", root_pipeline_id),
|
||||||
}
|
}
|
||||||
|
@ -1578,7 +1576,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
|
|
||||||
fn handle_mozbrowser_event_msg(&mut self,
|
fn handle_mozbrowser_event_msg(&mut self,
|
||||||
containing_pipeline_id: PipelineId,
|
containing_pipeline_id: PipelineId,
|
||||||
subpage_id: SubpageId,
|
subpage_id: Option<SubpageId>,
|
||||||
event: MozBrowserEvent) {
|
event: MozBrowserEvent) {
|
||||||
assert!(PREFS.is_mozbrowser_enabled());
|
assert!(PREFS.is_mozbrowser_enabled());
|
||||||
|
|
||||||
|
@ -2271,7 +2269,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
let can_go_backward = !frame.prev.is_empty();
|
let can_go_backward = !frame.prev.is_empty();
|
||||||
let can_go_forward = !frame.next.is_empty();
|
let can_go_forward = !frame.next.is_empty();
|
||||||
let event = MozBrowserEvent::LocationChange(url, can_go_backward, can_go_forward);
|
let event = MozBrowserEvent::LocationChange(url, can_go_backward, can_go_forward);
|
||||||
parent_pipeline.trigger_mozbrowser_event(subpage_id, event);
|
parent_pipeline.trigger_mozbrowser_event(Some(subpage_id), event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2280,35 +2278,43 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsererror
|
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsererror
|
||||||
// Note that this does not require the pipeline to be an immediate child of the root
|
// Note that this does not require the pipeline to be an immediate child of the root
|
||||||
// TODO: allow the pipeline id to be optional, triggering the error on the root if it's not provided.
|
fn trigger_mozbrowsererror(&mut self, pipeline_id: Option<PipelineId>, reason: String, backtrace: String) {
|
||||||
fn trigger_mozbrowsererror(&mut self, pipeline_id: PipelineId, reason: String, backtrace: String) {
|
|
||||||
if !PREFS.is_mozbrowser_enabled() { return; }
|
if !PREFS.is_mozbrowser_enabled() { return; }
|
||||||
|
|
||||||
let ancestor_info = self.get_mozbrowser_ancestor_info(pipeline_id);
|
let mut report = String::new();
|
||||||
|
for (thread_name, warning) in self.handled_warnings.drain(..) {
|
||||||
|
report.push_str("\nWARNING: ");
|
||||||
|
if let Some(thread_name) = thread_name {
|
||||||
|
report.push_str("<");
|
||||||
|
report.push_str(&*thread_name);
|
||||||
|
report.push_str(">: ");
|
||||||
|
}
|
||||||
|
report.push_str(&*warning);
|
||||||
|
}
|
||||||
|
report.push_str("\nERROR: ");
|
||||||
|
report.push_str(&*reason);
|
||||||
|
report.push_str("\n\n");
|
||||||
|
report.push_str(&*backtrace);
|
||||||
|
|
||||||
if let Some(ancestor_info) = ancestor_info {
|
let event = MozBrowserEvent::Error(MozBrowserErrorType::Fatal, Some(reason), Some(report));
|
||||||
match self.pipelines.get(&ancestor_info.0) {
|
|
||||||
Some(ancestor) => {
|
if let Some(pipeline_id) = pipeline_id {
|
||||||
let mut report = String::new();
|
if let Some((ancestor_id, subpage_id)) = self.get_mozbrowser_ancestor_info(pipeline_id) {
|
||||||
for (thread_name, warning) in self.handled_warnings.drain(..) {
|
if let Some(ancestor) = self.pipelines.get(&ancestor_id) {
|
||||||
report.push_str("\nWARNING: ");
|
return ancestor.trigger_mozbrowser_event(Some(subpage_id), event);
|
||||||
if let Some(thread_name) = thread_name {
|
}
|
||||||
report.push_str("<");
|
|
||||||
report.push_str(&*thread_name);
|
|
||||||
report.push_str(">: ");
|
|
||||||
}
|
|
||||||
report.push_str(&*warning);
|
|
||||||
}
|
|
||||||
report.push_str("\nERROR: ");
|
|
||||||
report.push_str(&*reason);
|
|
||||||
report.push_str("\n\n");
|
|
||||||
report.push_str(&*backtrace);
|
|
||||||
let event = MozBrowserEvent::Error(MozBrowserErrorType::Fatal, Some(reason), Some(report));
|
|
||||||
ancestor.trigger_mozbrowser_event(ancestor_info.1, event);
|
|
||||||
},
|
|
||||||
None => return warn!("Mozbrowsererror via closed pipeline {:?}.", ancestor_info.0),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(root_frame_id) = self.root_frame_id {
|
||||||
|
if let Some(root_frame) = self.frames.get(&root_frame_id) {
|
||||||
|
if let Some(root_pipeline) = self.pipelines.get(&root_frame.current) {
|
||||||
|
return root_pipeline.trigger_mozbrowser_event(None, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
warn!("Mozbrowser error after root pipeline closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focused_pipeline_in_tree(&self, frame_id: FrameId) -> bool {
|
fn focused_pipeline_in_tree(&self, frame_id: FrameId) -> bool {
|
||||||
|
|
|
@ -376,7 +376,7 @@ impl Pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trigger_mozbrowser_event(&self,
|
pub fn trigger_mozbrowser_event(&self,
|
||||||
subpage_id: SubpageId,
|
subpage_id: Option<SubpageId>,
|
||||||
event: MozBrowserEvent) {
|
event: MozBrowserEvent) {
|
||||||
assert!(PREFS.is_mozbrowser_enabled());
|
assert!(PREFS.is_mozbrowser_enabled());
|
||||||
|
|
||||||
|
|
|
@ -1281,7 +1281,7 @@ impl Document {
|
||||||
if PREFS.is_mozbrowser_enabled() {
|
if PREFS.is_mozbrowser_enabled() {
|
||||||
if let Some((containing_pipeline_id, subpage_id, _)) = self.window.parent_info() {
|
if let Some((containing_pipeline_id, subpage_id, _)) = self.window.parent_info() {
|
||||||
let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
|
let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
|
||||||
subpage_id,
|
Some(subpage_id),
|
||||||
event);
|
event);
|
||||||
self.window.constellation_chan().send(event).unwrap();
|
self.window.constellation_chan().send(event).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,25 +161,11 @@ impl HTMLIFrameElement {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn dispatch_mozbrowser_event(&self, event: MozBrowserEvent) {
|
pub fn dispatch_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||||
// TODO(gw): Support mozbrowser event types that have detail which is not a string.
|
|
||||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API
|
|
||||||
// for a list of mozbrowser events.
|
|
||||||
assert!(PREFS.is_mozbrowser_enabled());
|
assert!(PREFS.is_mozbrowser_enabled());
|
||||||
|
|
||||||
if self.Mozbrowser() {
|
if self.Mozbrowser() {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let custom_event = unsafe {
|
let custom_event = build_mozbrowser_custom_event(&window, event);
|
||||||
let cx = window.get_cx();
|
|
||||||
let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get());
|
|
||||||
rooted!(in(cx) let mut detail = UndefinedValue());
|
|
||||||
let event_name = Atom::from(event.name());
|
|
||||||
self.build_mozbrowser_event_detail(event, cx, detail.handle_mut());
|
|
||||||
CustomEvent::new(GlobalRef::Window(window.r()),
|
|
||||||
event_name,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
detail.handle())
|
|
||||||
};
|
|
||||||
custom_event.upcast::<Event>().fire(self.upcast());
|
custom_event.upcast::<Event>().fire(self.upcast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,97 +322,104 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait MozBrowserEventDetailBuilder {
|
#[allow(unsafe_code)]
|
||||||
#[allow(unsafe_code)]
|
pub fn build_mozbrowser_custom_event(window: &Window, event: MozBrowserEvent) -> Root<CustomEvent> {
|
||||||
unsafe fn build_mozbrowser_event_detail(&self,
|
// TODO(gw): Support mozbrowser event types that have detail which is not a string.
|
||||||
event: MozBrowserEvent,
|
// See https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API
|
||||||
cx: *mut JSContext,
|
// for a list of mozbrowser events.
|
||||||
rval: MutableHandleValue);
|
let cx = window.get_cx();
|
||||||
|
let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get());
|
||||||
|
rooted!(in(cx) let mut detail = UndefinedValue());
|
||||||
|
let event_name = Atom::from(event.name());
|
||||||
|
unsafe { build_mozbrowser_event_detail(event, cx, detail.handle_mut()); }
|
||||||
|
CustomEvent::new(GlobalRef::Window(window),
|
||||||
|
event_name,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
detail.handle())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
#[allow(unsafe_code)]
|
||||||
#[allow(unsafe_code)]
|
unsafe fn build_mozbrowser_event_detail(event: MozBrowserEvent,
|
||||||
unsafe fn build_mozbrowser_event_detail(&self,
|
cx: *mut JSContext,
|
||||||
event: MozBrowserEvent,
|
rval: MutableHandleValue) {
|
||||||
cx: *mut JSContext,
|
match event {
|
||||||
rval: MutableHandleValue) {
|
MozBrowserEvent::AsyncScroll | MozBrowserEvent::Close | MozBrowserEvent::ContextMenu |
|
||||||
match event {
|
MozBrowserEvent::LoadEnd | MozBrowserEvent::LoadStart |
|
||||||
MozBrowserEvent::AsyncScroll | MozBrowserEvent::Close | MozBrowserEvent::ContextMenu |
|
MozBrowserEvent::Connected | MozBrowserEvent::OpenSearch |
|
||||||
MozBrowserEvent::LoadEnd | MozBrowserEvent::LoadStart |
|
MozBrowserEvent::UsernameAndPasswordRequired => {
|
||||||
MozBrowserEvent::Connected | MozBrowserEvent::OpenSearch |
|
rval.set(NullValue());
|
||||||
MozBrowserEvent::UsernameAndPasswordRequired => {
|
}
|
||||||
rval.set(NullValue());
|
MozBrowserEvent::Error(error_type, description, report) => {
|
||||||
}
|
BrowserElementErrorEventDetail {
|
||||||
MozBrowserEvent::Error(error_type, description, report) => {
|
type_: Some(DOMString::from(error_type.name())),
|
||||||
BrowserElementErrorEventDetail {
|
description: description.map(DOMString::from),
|
||||||
type_: Some(DOMString::from(error_type.name())),
|
report: report.map(DOMString::from),
|
||||||
description: description.map(DOMString::from),
|
version: Some(DOMString::from_string(servo_version().into())),
|
||||||
report: report.map(DOMString::from),
|
}.to_jsval(cx, rval);
|
||||||
version: Some(DOMString::from_string(servo_version().into())),
|
},
|
||||||
}.to_jsval(cx, rval);
|
MozBrowserEvent::SecurityChange(https_state) => {
|
||||||
},
|
BrowserElementSecurityChangeDetail {
|
||||||
MozBrowserEvent::SecurityChange(https_state) => {
|
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsersecuritychange
|
||||||
BrowserElementSecurityChangeDetail {
|
state: Some(DOMString::from(match https_state {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsersecuritychange
|
HttpsState::Modern => "secure",
|
||||||
state: Some(DOMString::from(match https_state {
|
HttpsState::Deprecated => "broken",
|
||||||
HttpsState::Modern => "secure",
|
HttpsState::None => "insecure",
|
||||||
HttpsState::Deprecated => "broken",
|
}.to_owned())),
|
||||||
HttpsState::None => "insecure",
|
// FIXME - Not supported yet:
|
||||||
}.to_owned())),
|
trackingContent: None,
|
||||||
// FIXME - Not supported yet:
|
mixedContent: None,
|
||||||
trackingContent: None,
|
trackingState: None,
|
||||||
mixedContent: None,
|
extendedValidation: None,
|
||||||
trackingState: None,
|
mixedState: None,
|
||||||
extendedValidation: None,
|
}.to_jsval(cx, rval);
|
||||||
mixedState: None,
|
}
|
||||||
}.to_jsval(cx, rval);
|
MozBrowserEvent::TitleChange(ref string) => {
|
||||||
}
|
string.to_jsval(cx, rval);
|
||||||
MozBrowserEvent::TitleChange(ref string) => {
|
}
|
||||||
string.to_jsval(cx, rval);
|
MozBrowserEvent::LocationChange(url, can_go_back, can_go_forward) => {
|
||||||
}
|
BrowserElementLocationChangeEventDetail {
|
||||||
MozBrowserEvent::LocationChange(url, can_go_back, can_go_forward) => {
|
url: Some(DOMString::from(url)),
|
||||||
BrowserElementLocationChangeEventDetail {
|
canGoBack: Some(can_go_back),
|
||||||
url: Some(DOMString::from(url)),
|
canGoForward: Some(can_go_forward),
|
||||||
canGoBack: Some(can_go_back),
|
}.to_jsval(cx, rval);
|
||||||
canGoForward: Some(can_go_forward),
|
}
|
||||||
}.to_jsval(cx, rval);
|
MozBrowserEvent::OpenTab(url) => {
|
||||||
}
|
BrowserElementOpenTabEventDetail {
|
||||||
MozBrowserEvent::OpenTab(url) => {
|
url: Some(DOMString::from(url)),
|
||||||
BrowserElementOpenTabEventDetail {
|
}.to_jsval(cx, rval);
|
||||||
url: Some(DOMString::from(url)),
|
}
|
||||||
}.to_jsval(cx, rval);
|
MozBrowserEvent::OpenWindow(url, target, features) => {
|
||||||
}
|
BrowserElementOpenWindowEventDetail {
|
||||||
MozBrowserEvent::OpenWindow(url, target, features) => {
|
url: Some(DOMString::from(url)),
|
||||||
BrowserElementOpenWindowEventDetail {
|
target: target.map(DOMString::from),
|
||||||
url: Some(DOMString::from(url)),
|
features: features.map(DOMString::from),
|
||||||
target: target.map(DOMString::from),
|
}.to_jsval(cx, rval);
|
||||||
features: features.map(DOMString::from),
|
}
|
||||||
}.to_jsval(cx, rval);
|
MozBrowserEvent::IconChange(rel, href, sizes) => {
|
||||||
}
|
BrowserElementIconChangeEventDetail {
|
||||||
MozBrowserEvent::IconChange(rel, href, sizes) => {
|
rel: Some(DOMString::from(rel)),
|
||||||
BrowserElementIconChangeEventDetail {
|
href: Some(DOMString::from(href)),
|
||||||
rel: Some(DOMString::from(rel)),
|
sizes: Some(DOMString::from(sizes)),
|
||||||
href: Some(DOMString::from(href)),
|
}.to_jsval(cx, rval);
|
||||||
sizes: Some(DOMString::from(sizes)),
|
}
|
||||||
}.to_jsval(cx, rval);
|
MozBrowserEvent::ShowModalPrompt(prompt_type, title, message, return_value) => {
|
||||||
}
|
BrowserShowModalPromptEventDetail {
|
||||||
MozBrowserEvent::ShowModalPrompt(prompt_type, title, message, return_value) => {
|
promptType: Some(DOMString::from(prompt_type)),
|
||||||
BrowserShowModalPromptEventDetail {
|
title: Some(DOMString::from(title)),
|
||||||
promptType: Some(DOMString::from(prompt_type)),
|
message: Some(DOMString::from(message)),
|
||||||
title: Some(DOMString::from(title)),
|
returnValue: Some(DOMString::from(return_value)),
|
||||||
message: Some(DOMString::from(message)),
|
}.to_jsval(cx, rval)
|
||||||
returnValue: Some(DOMString::from(return_value)),
|
}
|
||||||
}.to_jsval(cx, rval)
|
MozBrowserEvent::VisibilityChange(visibility) => {
|
||||||
}
|
BrowserElementVisibilityChangeEventDetail {
|
||||||
MozBrowserEvent::VisibilityChange(visibility) => {
|
visible: Some(visibility),
|
||||||
BrowserElementVisibilityChangeEventDetail {
|
}.to_jsval(cx, rval);
|
||||||
visible: Some(visibility),
|
|
||||||
}.to_jsval(cx, rval);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> ErrorResult {
|
pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> ErrorResult {
|
||||||
if iframe.Mozbrowser() {
|
if iframe.Mozbrowser() {
|
||||||
if iframe.upcast::<Node>().is_in_doc() {
|
if iframe.upcast::<Node>().is_in_doc() {
|
||||||
|
|
|
@ -28,7 +28,9 @@ use dom::crypto::Crypto;
|
||||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration};
|
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration};
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
use dom::event::Event;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::htmliframeelement::build_mozbrowser_custom_event;
|
||||||
use dom::location::Location;
|
use dom::location::Location;
|
||||||
use dom::navigator::Navigator;
|
use dom::navigator::Navigator;
|
||||||
use dom::node::{Node, from_untrusted_node_address, window_from_node};
|
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::SendableMainThreadScriptChan;
|
||||||
use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
|
use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
|
||||||
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
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::{DocumentState, MsDuration, TimerEvent, TimerEventId};
|
||||||
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource, WindowSizeData};
|
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource, WindowSizeData};
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
|
@ -1594,6 +1596,13 @@ impl Window {
|
||||||
_ => false,
|
_ => 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 {
|
impl Window {
|
||||||
|
|
|
@ -1383,17 +1383,17 @@ impl ScriptThread {
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
|
/// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
|
||||||
fn handle_mozbrowser_event_msg(&self,
|
fn handle_mozbrowser_event_msg(&self,
|
||||||
parent_pipeline_id: PipelineId,
|
parent_pipeline_id: PipelineId,
|
||||||
subpage_id: SubpageId,
|
subpage_id: Option<SubpageId>,
|
||||||
event: MozBrowserEvent) {
|
event: MozBrowserEvent) {
|
||||||
let borrowed_context = self.root_browsing_context();
|
match self.root_browsing_context().find(parent_pipeline_id) {
|
||||||
|
None => warn!("Mozbrowser event after pipeline {:?} closed.", parent_pipeline_id),
|
||||||
let frame_element = borrowed_context.find(parent_pipeline_id).and_then(|context| {
|
Some(context) => match subpage_id {
|
||||||
let doc = context.active_document();
|
None => context.active_window().dispatch_mozbrowser_event(event),
|
||||||
doc.find_iframe(subpage_id)
|
Some(subpage_id) => match context.active_document().find_iframe(subpage_id) {
|
||||||
});
|
None => warn!("Mozbrowser event after iframe {:?}/{:?} closed.", parent_pipeline_id, subpage_id),
|
||||||
|
Some(frame_element) => frame_element.dispatch_mozbrowser_event(event),
|
||||||
if let Some(ref frame_element) = frame_element {
|
},
|
||||||
frame_element.dispatch_mozbrowser_event(event);
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,8 +176,9 @@ pub enum ConstellationControlMsg {
|
||||||
NotifyVisibilityChange(PipelineId, PipelineId, bool),
|
NotifyVisibilityChange(PipelineId, PipelineId, bool),
|
||||||
/// Notifies script thread that a url should be loaded in this iframe.
|
/// Notifies script thread that a url should be loaded in this iframe.
|
||||||
Navigate(PipelineId, SubpageId, LoadData),
|
Navigate(PipelineId, SubpageId, LoadData),
|
||||||
/// Requests the script thread forward a mozbrowser event to an iframe it owns
|
/// Requests the script thread forward a mozbrowser event to an iframe it owns,
|
||||||
MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent),
|
/// or to the window if no subpage id is provided.
|
||||||
|
MozBrowserEvent(PipelineId, Option<SubpageId>, MozBrowserEvent),
|
||||||
/// Updates the current subpage and pipeline IDs of a given iframe
|
/// Updates the current subpage and pipeline IDs of a given iframe
|
||||||
UpdateSubpageId(PipelineId, SubpageId, SubpageId, PipelineId),
|
UpdateSubpageId(PipelineId, SubpageId, SubpageId, PipelineId),
|
||||||
/// Set an iframe to be focused. Used when an element in an iframe gains focus.
|
/// Set an iframe to be focused. Used when an element in an iframe gains focus.
|
||||||
|
|
|
@ -84,8 +84,9 @@ pub enum ScriptMsg {
|
||||||
LoadComplete(PipelineId),
|
LoadComplete(PipelineId),
|
||||||
/// A new load has been requested.
|
/// A new load has been requested.
|
||||||
LoadUrl(PipelineId, LoadData),
|
LoadUrl(PipelineId, LoadData),
|
||||||
/// Dispatch a mozbrowser event to a given iframe. Only available in experimental mode.
|
/// Dispatch a mozbrowser event to a given iframe,
|
||||||
MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent),
|
/// or to the window if no subpage id is provided.
|
||||||
|
MozBrowserEvent(PipelineId, Option<SubpageId>, MozBrowserEvent),
|
||||||
/// HTMLIFrameElement Forward or Back navigation.
|
/// HTMLIFrameElement Forward or Back navigation.
|
||||||
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
|
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
|
||||||
/// Favicon detected
|
/// Favicon detected
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue