remove mozbrowser code

This commit is contained in:
Paul Rouget 2018-02-07 14:31:57 +01:00
parent e7c754fb64
commit da349ee8a9
22 changed files with 78 additions and 1003 deletions

View file

@ -63,7 +63,7 @@ use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
use js::jsval::JSVal;
use js::rust::Runtime;
use metrics::{InteractiveMetrics, InteractiveWindow};
use msg::constellation_msg::{BrowsingContextId, FrameType, PipelineId, TopLevelBrowsingContextId};
use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceThreads};
use net_traits::filemanager_thread::RelativePos;
use net_traits::image::base::{Image, ImageMetadata};
@ -351,7 +351,7 @@ unsafe_no_jsmanaged_fields!(PropertyDeclarationBlock);
// These three are interdependent, if you plan to put jsmanaged data
// in one of these make sure it is propagated properly to containing structs
unsafe_no_jsmanaged_fields!(DocumentActivity, WindowSizeData, WindowSizeType);
unsafe_no_jsmanaged_fields!(BrowsingContextId, FrameType, PipelineId, TopLevelBrowsingContextId);
unsafe_no_jsmanaged_fields!(BrowsingContextId, PipelineId, TopLevelBrowsingContextId);
unsafe_no_jsmanaged_fields!(TimerEventId, TimerSource);
unsafe_no_jsmanaged_fields!(TimelineMarkerType);
unsafe_no_jsmanaged_fields!(WorkerId);

View file

@ -98,7 +98,7 @@ use js::jsapi::{JSContext, JSObject, JSRuntime};
use js::jsapi::JS_GetRuntime;
use metrics::{InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory, ProgressiveWebMetric};
use mime::{Mime, TopLevel, SubLevel};
use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState, TopLevelBrowsingContextId};
use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState};
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
use net_traits::CookieSource::NonHTTP;
use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl};
@ -111,7 +111,7 @@ use script_layout_interface::message::{Msg, NodesFromPointQueryType, ReflowGoal}
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
use script_thread::{MainThreadScriptMsg, ScriptThread};
use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType};
use script_traits::{MozBrowserEvent, MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress};
use script_traits::{MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress};
use servo_arc::Arc;
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
@ -451,7 +451,6 @@ impl Document {
pub fn set_https_state(&self, https_state: HttpsState) {
self.https_state.set(https_state);
self.trigger_mozbrowser_event(MozBrowserEvent::SecurityChange(https_state));
}
pub fn is_fully_active(&self) -> bool {
@ -754,13 +753,9 @@ impl Document {
pub fn set_ready_state(&self, state: DocumentReadyState) {
match state {
DocumentReadyState::Loading => {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserconnected
self.trigger_mozbrowser_event(MozBrowserEvent::Connected);
update_with_current_time_ms(&self.dom_loading);
},
DocumentReadyState::Complete => {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
self.trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);
update_with_current_time_ms(&self.dom_complete);
},
DocumentReadyState::Interactive => update_with_current_time_ms(&self.dom_interactive),
@ -826,9 +821,6 @@ impl Document {
/// Handles any updates when the document's title has changed.
pub fn title_changed(&self) {
if self.browsing_context().is_some() {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsertitlechange
self.trigger_mozbrowser_event(MozBrowserEvent::TitleChange(String::from(self.Title())));
self.send_title_to_constellation();
}
}
@ -1410,15 +1402,6 @@ impl Document {
}
}
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
if PREFS.is_mozbrowser_enabled() {
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
let event = ScriptMsg::MozBrowserEvent(parent_pipeline_id, event);
self.send_to_constellation(event);
}
}
}
/// <https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe>
pub fn request_animation_frame(&self, callback: AnimationFrameCallback) -> u32 {
let ident = self.animation_frame_ident.get() + 1;
@ -1857,20 +1840,6 @@ impl Document {
.find(|node| node.browsing_context_id() == Some(browsing_context_id))
}
/// Find a mozbrowser iframe element in the document.
pub fn find_mozbrowser_iframe(&self,
top_level_browsing_context_id: TopLevelBrowsingContextId)
-> Option<DomRoot<HTMLIFrameElement>>
{
match self.find_iframe(BrowsingContextId::from(top_level_browsing_context_id)) {
None => None,
Some(iframe) => {
assert!(iframe.Mozbrowser());
Some(iframe)
},
}
}
pub fn get_dom_loading(&self) -> u64 {
self.dom_loading.get()
}

View file

@ -28,8 +28,6 @@ use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
use net_traits::ReferrerPolicy;
use num_traits::ToPrimitive;
use script_traits::MozBrowserEvent;
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::default::Default;
use style::attr::AttrValue;
@ -608,13 +606,8 @@ pub fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option<String>, ref
// Step 8: navigate to the URL.
if let Some(target) = target {
if PREFS.is_mozbrowser_enabled() && !is_current_browsing_context(target.Value()) {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowseropenwindow
// TODO: referrer and opener
// TODO: should we send the normalized url or the non-normalized href?
let event = MozBrowserEvent::OpenWindow(url.into_string(), Some(String::from(target.Value())), None);
document.trigger_mozbrowser_event(event);
return
if !is_current_browsing_context(target.Value()) {
// https://github.com/servo/servo/issues/13241
}
}

View file

@ -5,51 +5,34 @@
use document_loader::{LoadBlocker, LoadType};
use dom::attr::Attr;
use dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementErrorEventDetail;
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementIconChangeEventDetail;
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementLocationChangeEventDetail;
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::WindowBinding::WindowMethods;
use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{LayoutDom, DomRoot, MutNullableDom};
use dom::bindings::str::DOMString;
use dom::customevent::CustomEvent;
use dom::document::Document;
use dom::domtokenlist::DOMTokenList;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
use dom::event::Event;
use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
use dom::htmlelement::HTMLElement;
use dom::node::{Node, NodeDamage, UnbindContext, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use dom::window::{ReflowReason, Window};
use dom::window::ReflowReason;
use dom::windowproxy::WindowProxy;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
use ipc_channel::ipc;
use js::jsapi::{JSAutoCompartment, JSContext, MutableHandleValue};
use js::jsval::{NullValue, UndefinedValue};
use msg::constellation_msg::{FrameType, BrowsingContextId, PipelineId, TopLevelBrowsingContextId, TraversalDirection};
use net_traits::response::HttpsState;
use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
use script_layout_interface::message::ReflowGoal;
use script_thread::ScriptThread;
use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, JsEvalResult, LoadData, UpdatePipelineIdReason};
use script_traits::{MozBrowserEvent, NewLayoutInfo, ScriptMsg};
use script_traits::{NewLayoutInfo, ScriptMsg};
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
use servo_config::servo_version;
use servo_url::ServoUrl;
use std::cell::Cell;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
@ -165,8 +148,6 @@ impl HTMLIFrameElement {
let old_pipeline_id = self.pipeline_id();
let new_pipeline_id = PipelineId::new();
self.pending_pipeline_id.set(Some(new_pipeline_id));
let private_iframe = self.privatebrowsing();
let frame_type = if self.Mozbrowser() { FrameType::MozBrowserIFrame } else { FrameType::IFrame };
let global_scope = window.upcast::<GlobalScope>();
let load_info = IFrameLoadInfo {
@ -174,8 +155,7 @@ impl HTMLIFrameElement {
browsing_context_id: browsing_context_id,
top_level_browsing_context_id: top_level_browsing_context_id,
new_pipeline_id: new_pipeline_id,
is_private: private_iframe,
frame_type: frame_type,
is_private: false, // FIXME
replace: replace,
};
@ -189,7 +169,7 @@ impl HTMLIFrameElement {
.unwrap();
let new_layout_info = NewLayoutInfo {
parent_info: Some((global_scope.pipeline_id(), frame_type)),
parent_info: Some(global_scope.pipeline_id()),
new_pipeline_id: new_pipeline_id,
browsing_context_id: browsing_context_id,
top_level_browsing_context_id: top_level_browsing_context_id,
@ -216,11 +196,6 @@ impl HTMLIFrameElement {
.unwrap();
}
}
if PREFS.is_mozbrowser_enabled() {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
self.dispatch_mozbrowser_event(MozBrowserEvent::LoadStart);
}
}
/// <https://html.spec.whatwg.org/multipage/#process-the-iframe-attributes>
@ -258,17 +233,6 @@ impl HTMLIFrameElement {
self.navigate_or_reload_child_browsing_context(Some(load_data), NavigationType::Regular, false);
}
#[allow(unsafe_code)]
pub fn dispatch_mozbrowser_event(&self, event: MozBrowserEvent) {
assert!(PREFS.is_mozbrowser_enabled());
if self.Mozbrowser() {
let window = window_from_node(self);
let custom_event = build_mozbrowser_custom_event(&window, event);
custom_event.upcast::<Event>().fire(self.upcast());
}
}
fn create_nested_browsing_context(&self) {
// Synchronously create a new context and navigate it to about:blank.
let url = ServoUrl::parse("about:blank").unwrap();
@ -276,12 +240,8 @@ impl HTMLIFrameElement {
let window = window_from_node(self);
let pipeline_id = Some(window.upcast::<GlobalScope>().pipeline_id());
let load_data = LoadData::new(url, pipeline_id, document.get_referrer_policy(), Some(document.url().clone()));
let (browsing_context_id, top_level_browsing_context_id) = if self.Mozbrowser() {
let top_level_browsing_context_id = TopLevelBrowsingContextId::new();
(BrowsingContextId::from(top_level_browsing_context_id), top_level_browsing_context_id)
} else {
(BrowsingContextId::new(), window.window_proxy().top_level_browsing_context_id())
};
let browsing_context_id = BrowsingContextId::new();
let top_level_browsing_context_id = window.window_proxy().top_level_browsing_context_id();
self.pipeline_id.set(None);
self.pending_pipeline_id.set(None);
self.top_level_browsing_context_id.set(Some(top_level_browsing_context_id));
@ -358,11 +318,6 @@ impl HTMLIFrameElement {
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));
}
}
}
@ -395,16 +350,6 @@ impl HTMLIFrameElement {
let window = window_from_node(self);
window.reflow(ReflowGoal::Full, ReflowReason::IFrameLoadEvent);
}
/// Check whether the iframe has the mozprivatebrowsing attribute set
pub fn privatebrowsing(&self) -> bool {
if self.Mozbrowser() {
let element = self.upcast::<Element>();
element.has_attribute(&LocalName::from("mozprivatebrowsing"))
} else {
false
}
}
}
pub trait HTMLIFrameElementLayoutMethods {
@ -455,117 +400,6 @@ impl HTMLIFrameElementLayoutMethods for LayoutDom<HTMLIFrameElement> {
}
}
#[allow(unsafe_code)]
pub fn build_mozbrowser_custom_event(window: &Window, event: MozBrowserEvent) -> DomRoot<CustomEvent> {
// 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.
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(window.upcast(),
event_name,
true,
true,
detail.handle())
}
#[allow(unsafe_code)]
unsafe fn build_mozbrowser_event_detail(event: MozBrowserEvent,
cx: *mut JSContext,
rval: MutableHandleValue) {
match event {
MozBrowserEvent::AsyncScroll | MozBrowserEvent::Close | MozBrowserEvent::ContextMenu |
MozBrowserEvent::LoadEnd | MozBrowserEvent::LoadStart |
MozBrowserEvent::Connected | MozBrowserEvent::OpenSearch |
MozBrowserEvent::UsernameAndPasswordRequired => {
rval.set(NullValue());
}
MozBrowserEvent::Error(error_type, description, report) => {
BrowserElementErrorEventDetail {
type_: Some(DOMString::from(error_type.name())),
description: Some(DOMString::from(description)),
report: Some(DOMString::from(report)),
version: Some(DOMString::from_string(servo_version())),
}.to_jsval(cx, rval);
},
MozBrowserEvent::SecurityChange(https_state) => {
BrowserElementSecurityChangeDetail {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsersecuritychange
state: Some(DOMString::from(match https_state {
HttpsState::Modern => "secure",
HttpsState::Deprecated => "broken",
HttpsState::None => "insecure",
}.to_owned())),
// FIXME - Not supported yet:
trackingContent: None,
mixedContent: None,
trackingState: None,
extendedValidation: None,
mixedState: None,
}.to_jsval(cx, rval);
}
MozBrowserEvent::TitleChange(ref string) => {
string.to_jsval(cx, rval);
}
MozBrowserEvent::LocationChange(url, can_go_back, can_go_forward) => {
BrowserElementLocationChangeEventDetail {
url: Some(DOMString::from(url)),
canGoBack: Some(can_go_back),
canGoForward: Some(can_go_forward),
}.to_jsval(cx, rval);
}
MozBrowserEvent::OpenTab(url) => {
BrowserElementOpenTabEventDetail {
url: Some(DOMString::from(url)),
}.to_jsval(cx, rval);
}
MozBrowserEvent::OpenWindow(url, target, features) => {
BrowserElementOpenWindowEventDetail {
url: Some(DOMString::from(url)),
target: target.map(DOMString::from),
features: features.map(DOMString::from),
}.to_jsval(cx, rval);
}
MozBrowserEvent::IconChange(rel, href, sizes) => {
BrowserElementIconChangeEventDetail {
rel: Some(DOMString::from(rel)),
href: Some(DOMString::from(href)),
sizes: Some(DOMString::from(sizes)),
}.to_jsval(cx, rval);
}
MozBrowserEvent::ShowModalPrompt(prompt_type, title, message, return_value) => {
BrowserShowModalPromptEventDetail {
promptType: Some(DOMString::from(prompt_type)),
title: Some(DOMString::from(title)),
message: Some(DOMString::from(message)),
returnValue: Some(DOMString::from(return_value)),
}.to_jsval(cx, rval)
}
MozBrowserEvent::VisibilityChange(visibility) => {
BrowserElementVisibilityChangeEventDetail {
visible: Some(visibility),
}.to_jsval(cx, rval);
}
}
}
pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> ErrorResult {
if iframe.Mozbrowser() {
if let Some(_) = iframe.top_level_browsing_context_id() {
let window = window_from_node(iframe);
let msg = ScriptMsg::TraverseHistory(direction);
window.upcast::<GlobalScope>().script_to_constellation_chan().send(msg).unwrap();
return Ok(());
}
}
debug!(concat!("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)
}
impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
make_url_getter!(Src, "src");
@ -604,83 +438,11 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
Some(document)
}
// Experimental mozbrowser implementation is based on the webidl
// present in the gecko source tree, and the documentation here:
// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn Mozbrowser(&self) -> bool {
if window_from_node(self).is_mozbrowser() {
let element = self.upcast::<Element>();
element.has_attribute(&local_name!("mozbrowser"))
} else {
false
}
}
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn SetMozbrowser(&self, value: bool) {
let element = self.upcast::<Element>();
element.set_bool_attribute(&local_name!("mozbrowser"), value);
}
// https://html.spec.whatwg.org/multipage/#attr-iframe-allowfullscreen
make_bool_getter!(AllowFullscreen, "allowfullscreen");
// https://html.spec.whatwg.org/multipage/#attr-iframe-allowfullscreen
make_bool_setter!(SetAllowFullscreen, "allowfullscreen");
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
fn GoBack(&self) -> ErrorResult {
Navigate(self, TraversalDirection::Back(1))
}
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goForward
fn GoForward(&self) -> ErrorResult {
Navigate(self, TraversalDirection::Forward(1))
}
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/reload
fn Reload(&self, _hard_reload: bool) -> ErrorResult {
if self.Mozbrowser() {
if self.upcast::<Node>().is_in_doc_with_browsing_context() {
self.navigate_or_reload_child_browsing_context(None, NavigationType::Regular, true);
}
Ok(())
} else {
debug!(concat!("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/setVisible
fn SetVisible(&self, visible: bool) -> ErrorResult {
if self.Mozbrowser() {
self.set_visible(visible);
Ok(())
} else {
debug!(concat!("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!(concat!("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)
}
// https://html.spec.whatwg.org/multipage/#dom-dim-width
make_getter!(Width, "width");
// https://html.spec.whatwg.org/multipage/#dom-dim-width
@ -695,21 +457,6 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
make_getter!(FrameBorder, "frameborder");
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:attr-iframe-frameborder
make_setter!(SetFrameBorder, "frameborder");
// check-tidy: no specs after this line
fn SetMozprivatebrowsing(&self, value: bool) {
let element = self.upcast::<Element>();
element.set_bool_attribute(&LocalName::from("mozprivatebrowsing"), value);
}
fn Mozprivatebrowsing(&self) -> bool {
if window_from_node(self).is_mozbrowser() {
let element = self.upcast::<Element>();
element.has_attribute(&LocalName::from("mozprivatebrowsing"))
} else {
false
}
}
}
impl VirtualMethods for HTMLIFrameElement {

View file

@ -24,7 +24,7 @@ use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
use net_traits::ReferrerPolicy;
use script_traits::{MozBrowserEvent, ScriptMsg};
use script_traits::ScriptMsg;
use servo_arc::Arc;
use std::borrow::ToOwned;
use std::cell::Cell;
@ -309,18 +309,12 @@ impl HTMLLinkElement {
}, link_url, cors_setting, integrity_metadata.to_owned());
}
fn handle_favicon_url(&self, rel: &str, href: &str, sizes: &Option<String>) {
fn handle_favicon_url(&self, _rel: &str, href: &str, _sizes: &Option<String>) {
let document = document_from_node(self);
match document.base_url().join(href) {
Ok(url) => {
let event = ScriptMsg::NewFavicon(url.clone());
document.window().upcast::<GlobalScope>().script_to_constellation_chan().send(event).unwrap();
let mozbrowser_event = match *sizes {
Some(ref sizes) => MozBrowserEvent::IconChange(rel.to_owned(), url.to_string(), sizes.to_owned()),
None => MozBrowserEvent::IconChange(rel.to_owned(), url.to_string(), "".to_owned())
};
document.trigger_mozbrowser_event(mozbrowser_event);
}
Err(e) => debug!("Parsing url {} failed: {}", href, e)
}

View file

@ -1,227 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API
callback BrowserElementNextPaintEventCallback = void ();
//enum BrowserFindCaseSensitivity { "case-sensitive", "case-insensitive" };
//enum BrowserFindDirection { "forward", "backward" };
//dictionary BrowserElementDownloadOptions {
// DOMString? filename;
// DOMString? referrer;
//};
//dictionary BrowserElementExecuteScriptOptions {
// DOMString? url;
// DOMString? origin;
//};
[NoInterfaceObject, Exposed=(Window,Worker)]
interface BrowserElement {
};
dictionary BrowserElementSecurityChangeDetail {
// state:
// "insecure" indicates that the data corresponding to
// the request was received over an insecure channel.
//
// "broken" indicates an unknown security state. This
// may mean that the request is being loaded as part
// of a page in which some content was received over
// an insecure channel.
//
// "secure" indicates that the data corresponding to the
// request was received over a secure channel.
DOMString state;
// trackingState:
// "loaded_tracking_content": tracking content has been loaded.
// "blocked_tracking_content": tracking content has been blocked from loading.
DOMString trackingState;
// mixedState:
// "blocked_mixed_active_content": Mixed active content has been blocked from loading.
// "loaded_mixed_active_content": Mixed active content has been loaded.
DOMString mixedState;
boolean extendedValidation;
boolean trackingContent;
boolean mixedContent;
};
dictionary BrowserElementErrorEventDetail {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsererror
// just requires a "type" field, but we also provide
// an optional human-readable description, and
// an optional machine-readable report (e.g. a backtrace for panics)
DOMString type;
DOMString description;
DOMString report;
DOMString version;
};
dictionary BrowserElementLocationChangeEventDetail {
DOMString url;
boolean canGoBack;
boolean canGoForward;
};
dictionary BrowserElementIconChangeEventDetail {
DOMString rel;
DOMString href;
DOMString sizes;
};
dictionary BrowserShowModalPromptEventDetail {
DOMString promptType;
DOMString title;
DOMString message;
DOMString returnValue;
// TODO(simartin) unblock() callback
};
dictionary BrowserElementOpenTabEventDetail {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowseropentab
DOMString url;
};
dictionary BrowserElementOpenWindowEventDetail {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowseropenwindow
DOMString url;
DOMString target;
DOMString features;
// Element frameElement;
};
dictionary BrowserElementVisibilityChangeEventDetail {
boolean visible;
};
BrowserElement implements BrowserElementCommon;
BrowserElement implements BrowserElementPrivileged;
[NoInterfaceObject, Exposed=(Window,Worker)]
interface BrowserElementCommon {
[Throws,
Pref="dom.mozbrowser.enabled"]
void setVisible(boolean visible);
[Throws,
Pref="dom.mozbrowser.enabled"]
boolean getVisible();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void setActive(boolean active);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//boolean getActive();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void addNextPaintListener(BrowserElementNextPaintEventCallback listener);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void removeNextPaintListener(BrowserElementNextPaintEventCallback listener);
};
[NoInterfaceObject, Exposed=(Window,Worker)]
interface BrowserElementPrivileged {
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void sendMouseEvent(DOMString type,
// unsigned long x,
// unsigned long y,
// unsigned long button,
// unsigned long clickCount,
// unsigned long modifiers);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled",
// Func="TouchEvent::PrefEnabled"]
//void sendTouchEvent(DOMString type,
// sequence<unsigned long> identifiers,
// sequence<long> x,
// sequence<long> y,
// sequence<unsigned long> rx,
// sequence<unsigned long> ry,
// sequence<float> rotationAngles,
// sequence<float> forces,
// unsigned long count,
// unsigned long modifiers);
[Func="::dom::window::Window::global_is_mozbrowser", Throws]
void goBack();
[Func="::dom::window::Window::global_is_mozbrowser", Throws]
void goForward();
[Func="::dom::window::Window::global_is_mozbrowser", Throws]
void reload(optional boolean hardReload = false);
[Func="::dom::window::Window::global_is_mozbrowser", Throws]
void stop();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//DOMRequest download(DOMString url,
// optional BrowserElementDownloadOptions options);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//DOMRequest purgeHistory();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//DOMRequest getScreenshot([EnforceRange] unsigned long width,
// [EnforceRange] unsigned long height,
// optional DOMString mimeType="");
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void zoom(float zoom);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//DOMRequest getCanGoBack();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//DOMRequest getCanGoForward();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//DOMRequest getContentDimensions();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//DOMRequest setInputMethodActive(boolean isActive);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void setNFCFocus(boolean isFocus);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void findAll(DOMString searchString, BrowserFindCaseSensitivity caseSensitivity);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void findNext(BrowserFindDirection direction);
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//void clearMatch();
//[Throws,
// Pref="dom.mozBrowserFramesEnabled"]
//DOMRequest executeScript(DOMString script,
// optional BrowserElementExecuteScriptOptions options);
};

View file

@ -46,13 +46,3 @@ partial interface HTMLIFrameElement {
// [CEReactions, TreatNullAs=EmptyString]
// attribute DOMString marginWidth;
};
partial interface HTMLIFrameElement {
[CEReactions, Func="::dom::window::Window::global_is_mozbrowser"]
attribute boolean mozbrowser;
[CEReactions, Func="::dom::window::Window::global_is_mozbrowser"]
attribute boolean mozprivatebrowsing;
};
HTMLIFrameElement implements BrowserElement;

View file

@ -164,8 +164,6 @@ partial interface Window {
void debug(DOMString arg);
void gc();
void trap();
[Func="Window::global_is_mozbrowser", Throws]
void openURLInDefaultBrowser(DOMString href);
};
// WebDriver extensions

View file

@ -32,10 +32,8 @@ use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSSt
use dom::customelementregistry::CustomElementRegistry;
use dom::document::{AnimationFrameCallback, Document};
use dom::element::Element;
use dom::event::Event;
use dom::globalscope::GlobalScope;
use dom::history::History;
use dom::htmliframeelement::build_mozbrowser_custom_event;
use dom::location::Location;
use dom::mediaquerylist::{MediaQueryList, WeakMediaQueryListVec};
use dom::messageevent::MessageEvent;
@ -54,18 +52,17 @@ use euclid::{Point2D, Vector2D, Rect, Size2D};
use fetch;
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use js::jsapi::{HandleObject, HandleValue, JSAutoCompartment, JSContext};
use js::jsapi::{HandleValue, JSAutoCompartment, JSContext};
use js::jsapi::{JS_GC, JS_GetRuntime};
use js::jsval::UndefinedValue;
use layout_image::fetch_image_for_layout;
use microtask::MicrotaskQueue;
use msg::constellation_msg::{FrameType, PipelineId};
use msg::constellation_msg::PipelineId;
use net_traits::{ResourceThreads, ReferrerPolicy};
use net_traits::image_cache::{ImageCache, ImageResponder, ImageResponse};
use net_traits::image_cache::{PendingImageId, PendingImageResponse};
use net_traits::storage_thread::StorageType;
use num_traits::ToPrimitive;
use open;
use profile_traits::mem::ProfilerChan as MemProfilerChan;
use profile_traits::time::ProfilerChan as TimeProfilerChan;
use script_layout_interface::{TrustedNodeAddress, PendingImageState};
@ -76,14 +73,13 @@ use script_layout_interface::rpc::{NodeScrollIdResponse, ResolvedStyleResponse,
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThreadEventCategory, Runtime};
use script_thread::{ImageCacheMsg, MainThreadScriptChan, MainThreadScriptMsg};
use script_thread::{ScriptThread, SendableMainThreadScriptChan};
use script_traits::{ConstellationControlMsg, DocumentState, LoadData, MozBrowserEvent};
use script_traits::{ConstellationControlMsg, DocumentState, LoadData};
use script_traits::{ScriptToConstellationChan, ScriptMsg, ScrollState, TimerEvent, TimerEventId};
use script_traits::{TimerSchedulerMsg, UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use selectors::attr::CaseSensitivity;
use servo_arc;
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_geometry::{f32_rect_to_au_rect, MaxRect};
use servo_url::{Host, MutableOrigin, ImmutableOrigin, ServoUrl};
use std::borrow::ToOwned;
@ -200,7 +196,7 @@ pub struct Window {
resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
/// Parent id associated with this page, if any.
parent_info: Option<(PipelineId, FrameType)>,
parent_info: Option<PipelineId>,
/// Global static data related to the DOM.
dom_static: GlobalStaticData,
@ -343,7 +339,7 @@ impl Window {
&self.script_chan.0
}
pub fn parent_info(&self) -> Option<(PipelineId, FrameType)> {
pub fn parent_info(&self) -> Option<PipelineId> {
self.parent_info
}
@ -520,7 +516,7 @@ impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#dom-alert
fn Alert(&self, s: DOMString) {
// Right now, just print to the console
// Print to the console.
// Ensure that stderr doesn't trample through the alert() we use to
// communicate test results (see executorservo.py in wptrunner).
{
@ -992,17 +988,6 @@ impl WindowMethods for Window {
*self.status.borrow_mut() = status
}
// check-tidy: no specs after this line
fn OpenURLInDefaultBrowser(&self, href: DOMString) -> ErrorResult {
let url = ServoUrl::parse(&href).map_err(|e| {
Error::Type(format!("Couldn't parse URL: {}", e))
})?;
match open::that(url.as_str()) {
Ok(_) => Ok(()),
Err(e) => Err(Error::Type(format!("Couldn't open URL: {}", e))),
}
}
// https://drafts.csswg.org/cssom-view/#dom-window-matchmedia
fn MatchMedia(&self, query: DOMString) -> DomRoot<MediaQueryList> {
let mut input = ParserInput::new(&query);
@ -1682,31 +1667,7 @@ impl Window {
// https://html.spec.whatwg.org/multipage/#top-level-browsing-context
pub fn is_top_level(&self) -> bool {
match self.parent_info {
Some((_, FrameType::IFrame)) => false,
_ => true,
}
}
/// Returns whether this window is mozbrowser.
pub fn is_mozbrowser(&self) -> bool {
PREFS.is_mozbrowser_enabled() && self.parent_info().is_none()
}
/// Returns whether mozbrowser is enabled and `obj` has been created
/// in a top-level `Window` global.
#[allow(unsafe_code)]
pub unsafe fn global_is_mozbrowser(_: *mut JSContext, obj: HandleObject) -> bool {
GlobalScope::from_object(obj.get())
.downcast::<Window>()
.map_or(false, |window| window.is_mozbrowser())
}
#[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());
self.parent_info.is_none()
}
pub fn evaluate_media_queries_and_report_changes(&self) {
@ -1769,7 +1730,7 @@ impl Window {
timer_event_chan: IpcSender<TimerEvent>,
layout_chan: Sender<Msg>,
pipelineid: PipelineId,
parent_info: Option<(PipelineId, FrameType)>,
parent_info: Option<PipelineId>,
window_size: Option<WindowSizeData>,
origin: MutableOrigin,
navigation_start: u64,

View file

@ -60,7 +60,6 @@ use net_traits::trim_http_whitespace;
use network_listener::{NetworkListener, PreInvoke};
use script_traits::DocumentActivity;
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::cell::Cell;
@ -572,20 +571,6 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
unreachable!()
};
let bypass_cross_origin_check = {
// We want to be able to do cross-origin requests in browser.html.
// If the XHR happens in a top level window and the mozbrowser
// preference is enabled, we allow bypassing the CORS check.
// This is a temporary measure until we figure out Servo privilege
// story. See https://github.com/servo/servo/issues/9582
if let Some(win) = DomRoot::downcast::<Window>(self.global()) {
let is_root_pipeline = win.parent_info().is_none();
is_root_pipeline && PREFS.is_mozbrowser_enabled()
} else {
false
}
};
let mut request = RequestInit {
method: self.request_method.borrow().clone(),
url: self.request_url.borrow().clone().unwrap(),
@ -608,10 +593,6 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
.. RequestInit::default()
};
if bypass_cross_origin_check {
request.mode = RequestMode::Navigate;
}
// step 4 (second half)
match extracted_or_serialized {
Some((_, ref content_type)) => {