mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Code review comments and upstream merge conflicts
Incorporated code review comments in components/net/http_loader.rs Resolved merge conflicts in cargo.lock file. Updated ReferrerPolicy in lib.rs
This commit is contained in:
commit
26dac98546
340 changed files with 9134 additions and 452 deletions
|
@ -25,6 +25,7 @@ angle = {git = "https://github.com/servo/angle", branch = "servo"}
|
|||
app_units = "0.3"
|
||||
audio-video-metadata = "0.1.2"
|
||||
bitflags = "0.7"
|
||||
bluetooth_traits = {path = "../bluetooth_traits"}
|
||||
canvas_traits = {path = "../canvas_traits"}
|
||||
caseless = "0.1.0"
|
||||
cookie = {version = "0.2.5", features = ["serialize-rustc"]}
|
||||
|
|
|
@ -94,6 +94,7 @@ impl DocumentLoader {
|
|||
|
||||
pub fn new_with_threads(resource_threads: ResourceThreads,
|
||||
initial_load: Option<Url>) -> DocumentLoader {
|
||||
debug!("Initial blocking load {:?}.", initial_load);
|
||||
let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect();
|
||||
|
||||
DocumentLoader {
|
||||
|
@ -105,6 +106,7 @@ impl DocumentLoader {
|
|||
|
||||
/// Add a load to the list of blocking loads.
|
||||
fn add_blocking_load(&mut self, load: LoadType) {
|
||||
debug!("Adding blocking load {:?} ({}).", load, self.blocking_loads.len());
|
||||
self.blocking_loads.push(load);
|
||||
}
|
||||
|
||||
|
@ -119,6 +121,7 @@ impl DocumentLoader {
|
|||
|
||||
/// Mark an in-progress network request complete.
|
||||
pub fn finish_load(&mut self, load: &LoadType) {
|
||||
debug!("Removing blocking load {:?} ({}).", load, self.blocking_loads.len());
|
||||
let idx = self.blocking_loads.iter().position(|unfinished| *unfinished == *load);
|
||||
self.blocking_loads.remove(idx.expect(&format!("unknown completed load {:?}", load)));
|
||||
}
|
||||
|
|
|
@ -6276,7 +6276,7 @@ class CGCallback(CGClass):
|
|||
})
|
||||
bodyWithoutThis = string.Template(
|
||||
setupCall +
|
||||
"rooted!(in(s.get_context()) let thisObjJS = ptr::null_mut());"
|
||||
"rooted!(in(s.get_context()) let thisObjJS = ptr::null_mut());\n"
|
||||
"return ${methodName}(${callArgs});").substitute({
|
||||
"callArgs": ", ".join(argnamesWithoutThis),
|
||||
"methodName": 'self.' + method.name,
|
||||
|
|
|
@ -58,8 +58,8 @@ use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
|
|||
use js::jsval::JSVal;
|
||||
use js::rust::Runtime;
|
||||
use libc;
|
||||
use msg::constellation_msg::{FrameId, FrameType, PipelineId, ReferrerPolicy};
|
||||
use net_traits::{Metadata, NetworkError, ResourceThreads};
|
||||
use msg::constellation_msg::{FrameId, FrameType, PipelineId};
|
||||
use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceThreads};
|
||||
use net_traits::filemanager_thread::RelativePos;
|
||||
use net_traits::image::base::{Image, ImageMetadata};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
|
||||
use bluetooth_traits::{BluetoothError, BluetoothMethodMsg};
|
||||
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence};
|
||||
use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
|
||||
use core::clone::Clone;
|
||||
use dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothMethods, BluetoothRequestDeviceFilter};
|
||||
use dom::bindings::codegen::Bindings::BluetoothBinding::RequestDeviceOptions;
|
||||
|
@ -18,9 +21,6 @@ use dom::globalscope::GlobalScope;
|
|||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use net_traits::bluetooth_scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence};
|
||||
use net_traits::bluetooth_scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
|
||||
use net_traits::bluetooth_thread::{BluetoothError, BluetoothMethodMsg};
|
||||
use std::rc::Rc;
|
||||
|
||||
const FILTER_EMPTY_ERROR: &'static str = "'filters' member, if present, must be nonempty to find any devices.";
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
|
||||
use bluetooth_traits::BluetoothMethodMsg;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
|
||||
BluetoothCharacteristicPropertiesMethods;
|
||||
|
@ -25,7 +26,6 @@ use dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID};
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
use std::rc::Rc;
|
||||
|
||||
// Maximum length of an attribute value.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
|
||||
use bluetooth_traits::BluetoothMethodMsg;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::
|
||||
|
@ -21,7 +22,6 @@ use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic,
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
use std::rc::Rc;
|
||||
|
||||
// http://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattdescriptor
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
|
||||
use bluetooth_traits::BluetoothMethodMsg;
|
||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
||||
|
@ -18,7 +19,6 @@ use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
|
||||
use bluetooth_traits::BluetoothMethodMsg;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||
use dom::bindings::error::Error::{self, Security};
|
||||
|
@ -18,7 +19,6 @@ use dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothServiceUUID, Blue
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
use std::rc::Rc;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice
|
||||
|
|
|
@ -96,9 +96,8 @@ use ipc_channel::ipc::{self, IpcSender};
|
|||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
||||
use js::jsapi::JS_GetRuntime;
|
||||
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
|
||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
|
||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
|
||||
use net_traits::{FetchResponseMsg, IpcSend};
|
||||
use msg::constellation_msg::{FrameId, Key, KeyModifiers, KeyState};
|
||||
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
|
||||
use net_traits::CookieSource::NonHTTP;
|
||||
use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl};
|
||||
use net_traits::request::RequestInit;
|
||||
|
@ -606,7 +605,7 @@ impl Document {
|
|||
|
||||
self.ready_state.set(state);
|
||||
|
||||
self.upcast::<EventTarget>().fire_simple_event("readystatechange");
|
||||
self.upcast::<EventTarget>().fire_event(atom!("readystatechange"));
|
||||
}
|
||||
|
||||
/// Return whether scripting is enabled or not
|
||||
|
@ -1400,7 +1399,7 @@ impl Document {
|
|||
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::MozBrowserEvent(parent_pipeline_id,
|
||||
Some(global_scope.pipeline_id()),
|
||||
global_scope.pipeline_id(),
|
||||
event);
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
}
|
||||
|
@ -1513,8 +1512,10 @@ impl Document {
|
|||
}
|
||||
}
|
||||
|
||||
let loader = self.loader.borrow();
|
||||
if !loader.is_blocked() && !loader.events_inhibited() {
|
||||
if !self.loader.borrow().is_blocked() && !self.loader.borrow().events_inhibited() {
|
||||
// Schedule a task to fire a "load" event (if no blocking loads have arrived in the mean time)
|
||||
// NOTE: we can end up executing this code more than once, in case more blocking loads arrive.
|
||||
debug!("Document loads are complete.");
|
||||
let win = self.window();
|
||||
let msg = MainThreadScriptMsg::DocumentLoadsComplete(
|
||||
win.upcast::<GlobalScope>().pipeline_id());
|
||||
|
@ -1630,11 +1631,11 @@ impl Document {
|
|||
}
|
||||
|
||||
/// Find an iframe element in the document.
|
||||
pub fn find_iframe(&self, pipeline: PipelineId) -> Option<Root<HTMLIFrameElement>> {
|
||||
pub fn find_iframe(&self, frame_id: FrameId) -> Option<Root<HTMLIFrameElement>> {
|
||||
self.upcast::<Node>()
|
||||
.traverse_preorder()
|
||||
.filter_map(Root::downcast::<HTMLIFrameElement>)
|
||||
.find(|node| node.pipeline_id() == Some(pipeline))
|
||||
.find(|node| node.frame_id() == frame_id)
|
||||
}
|
||||
|
||||
pub fn get_dom_loading(&self) -> u64 {
|
||||
|
|
|
@ -330,7 +330,9 @@ impl Runnable for EventRunnable {
|
|||
|
||||
fn handler(self: Box<EventRunnable>) {
|
||||
let target = self.target.root();
|
||||
target.fire_event(&*self.name, self.bubbles, self.cancelable);
|
||||
let bubbles = self.bubbles.clone();
|
||||
let cancelable = self.cancelable.clone();
|
||||
target.fire_event_with_params(self.name, bubbles, cancelable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,6 +347,6 @@ impl Runnable for SimpleEventRunnable {
|
|||
|
||||
fn handler(self: Box<SimpleEventRunnable>) {
|
||||
let target = self.target.root();
|
||||
target.fire_simple_event(&*self.name);
|
||||
target.fire_event(self.name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -490,21 +490,42 @@ impl EventTarget {
|
|||
!self.handlers.borrow().is_empty()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#fire-a-simple-event
|
||||
pub fn fire_simple_event(&self, name: &str) -> Root<Event> {
|
||||
self.fire_event(name, EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable)
|
||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||
pub fn fire_event(&self, name: Atom) -> Root<Event> {
|
||||
self.fire_event_with_params(name,
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||
pub fn fire_event(&self, name: &str,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable)
|
||||
-> Root<Event> {
|
||||
let event = Event::new(&self.global(), Atom::from(name), bubbles, cancelable);
|
||||
pub fn fire_bubbling_event(&self, name: Atom) -> Root<Event> {
|
||||
self.fire_event_with_params(name,
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||
pub fn fire_cancelable_event(&self, name: Atom) -> Root<Event> {
|
||||
self.fire_event_with_params(name,
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::Cancelable)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||
pub fn fire_bubbling_cancelable_event(&self, name: Atom) -> Root<Event> {
|
||||
self.fire_event_with_params(name,
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::Cancelable)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||
pub fn fire_event_with_params(&self,
|
||||
name: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable)
|
||||
-> Root<Event> {
|
||||
let event = Event::new(&self.global(), name, bubbles, cancelable);
|
||||
event.fire(self);
|
||||
|
||||
event
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ use dom::node::{Node, document_from_node, window_from_node};
|
|||
use dom::urlhelper::UrlHelper;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use html5ever_atoms::LocalName;
|
||||
use msg::constellation_msg::ReferrerPolicy;
|
||||
use net_traits::ReferrerPolicy;
|
||||
use num_traits::ToPrimitive;
|
||||
use script_traits::MozBrowserEvent;
|
||||
use std::default::Default;
|
||||
|
|
|
@ -206,24 +206,24 @@ impl HTMLCollection {
|
|||
HTMLCollection::create(window, root, box ElementChildFilter)
|
||||
}
|
||||
|
||||
pub fn elements_iter_after(&self, after: &Node) -> HTMLCollectionElementsIter {
|
||||
pub fn elements_iter_after<'a>(&'a self, after: &'a Node) -> impl Iterator<Item=Root<Element>> + 'a {
|
||||
// Iterate forwards from a node.
|
||||
HTMLCollectionElementsIter {
|
||||
node_iter: box after.following_nodes(&self.root),
|
||||
node_iter: after.following_nodes(&self.root),
|
||||
root: Root::from_ref(&self.root),
|
||||
filter: &self.filter,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn elements_iter(&self) -> HTMLCollectionElementsIter {
|
||||
pub fn elements_iter<'a>(&'a self) -> impl Iterator<Item=Root<Element>> + 'a {
|
||||
// Iterate forwards from the root.
|
||||
self.elements_iter_after(&*self.root)
|
||||
}
|
||||
|
||||
pub fn elements_iter_before(&self, before: &Node) -> HTMLCollectionElementsIter {
|
||||
pub fn elements_iter_before<'a>(&'a self, before: &'a Node) -> impl Iterator<Item=Root<Element>> + 'a {
|
||||
// Iterate backwards from a node.
|
||||
HTMLCollectionElementsIter {
|
||||
node_iter: box before.preceding_nodes(&self.root),
|
||||
node_iter: before.preceding_nodes(&self.root),
|
||||
root: Root::from_ref(&self.root),
|
||||
filter: &self.filter,
|
||||
}
|
||||
|
@ -235,13 +235,13 @@ impl HTMLCollection {
|
|||
}
|
||||
|
||||
// TODO: Make this generic, and avoid code duplication
|
||||
pub struct HTMLCollectionElementsIter<'a> {
|
||||
node_iter: Box<Iterator<Item = Root<Node>>>,
|
||||
struct HTMLCollectionElementsIter<'a, I> {
|
||||
node_iter: I,
|
||||
root: Root<Node>,
|
||||
filter: &'a Box<CollectionFilter>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for HTMLCollectionElementsIter<'a> {
|
||||
impl<'a, I: Iterator<Item=Root<Node>>> Iterator for HTMLCollectionElementsIter<'a, I> {
|
||||
type Item = Root<Element>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
|
@ -285,13 +285,15 @@ impl HTMLCollectionMethods for HTMLCollection {
|
|||
// Iterate forwards, starting at the cursor.
|
||||
let offset = index - (cached_index + 1);
|
||||
let node: Root<Node> = Root::upcast(element);
|
||||
self.set_cached_cursor(index, self.elements_iter_after(&node).nth(offset as usize))
|
||||
let mut iter = self.elements_iter_after(&node);
|
||||
self.set_cached_cursor(index, iter.nth(offset as usize))
|
||||
} else {
|
||||
// The cursor is after the element we're looking for
|
||||
// Iterate backwards, starting at the cursor.
|
||||
let offset = cached_index - (index + 1);
|
||||
let node: Root<Node> = Root::upcast(element);
|
||||
self.set_cached_cursor(index, self.elements_iter_before(&node).nth(offset as usize))
|
||||
let mut iter = self.elements_iter_before(&node);
|
||||
self.set_cached_cursor(index, iter.nth(offset as usize))
|
||||
}
|
||||
} else {
|
||||
// Cache miss
|
||||
|
|
|
@ -94,7 +94,7 @@ impl Runnable for DetailsNotificationRunnable {
|
|||
fn handler(self: Box<DetailsNotificationRunnable>) {
|
||||
let target = self.element.root();
|
||||
if target.check_toggle_count(self.toggle_number) {
|
||||
target.upcast::<EventTarget>().fire_simple_event("toggle");
|
||||
target.upcast::<EventTarget>().fire_event(atom!("toggle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ use dom::bindings::str::DOMString;
|
|||
use dom::blob::Blob;
|
||||
use dom::document::Document;
|
||||
use dom::element::Element;
|
||||
use dom::event::{EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::file::File;
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
@ -305,16 +304,14 @@ impl HTMLFormElement {
|
|||
{
|
||||
if self.interactive_validation().is_err() {
|
||||
// TODO: Implement event handlers on all form control elements
|
||||
self.upcast::<EventTarget>().fire_simple_event("invalid");
|
||||
self.upcast::<EventTarget>().fire_event(atom!("invalid"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Step 5
|
||||
if submit_method_flag == SubmittedFrom::NotFromForm {
|
||||
let event = self.upcast::<EventTarget>()
|
||||
.fire_event("submit",
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::Cancelable);
|
||||
.fire_bubbling_cancelable_event(atom!("submit"));
|
||||
if event.DefaultPrevented() {
|
||||
return;
|
||||
}
|
||||
|
@ -484,9 +481,7 @@ impl HTMLFormElement {
|
|||
// Step 5-6
|
||||
let unhandled_invalid_controls = invalid_controls.into_iter().filter_map(|field| {
|
||||
let event = field.as_event_target()
|
||||
.fire_event("invalid",
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::Cancelable);
|
||||
.fire_cancelable_event(atom!("invalid"));
|
||||
if !event.DefaultPrevented() { return Some(field); }
|
||||
None
|
||||
}).collect::<Vec<FormSubmittableElement>>();
|
||||
|
@ -615,9 +610,7 @@ impl HTMLFormElement {
|
|||
}
|
||||
|
||||
let event = self.upcast::<EventTarget>()
|
||||
.fire_event("reset",
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::Cancelable);
|
||||
.fire_bubbling_cancelable_event(atom!("reset"));
|
||||
if event.DefaultPrevented() {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -207,6 +207,11 @@ impl HTMLIFrameElement {
|
|||
self.pipeline_id.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn frame_id(&self) -> FrameId {
|
||||
self.frame_id
|
||||
}
|
||||
|
||||
pub fn change_visibility_status(&self, visibility: bool) {
|
||||
if self.visibility.get() != visibility {
|
||||
self.visibility.set(visibility);
|
||||
|
@ -239,7 +244,7 @@ impl HTMLIFrameElement {
|
|||
// TODO Step 3 - set child document `mut iframe load` flag
|
||||
|
||||
// Step 4
|
||||
self.upcast::<EventTarget>().fire_simple_event("load");
|
||||
self.upcast::<EventTarget>().fire_event(atom!("load"));
|
||||
|
||||
let mut blocker = self.load_blocker.borrow_mut();
|
||||
LoadBlocker::terminate(&mut blocker);
|
||||
|
@ -409,7 +414,7 @@ unsafe fn build_mozbrowser_event_detail(event: MozBrowserEvent,
|
|||
|
||||
pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> ErrorResult {
|
||||
if iframe.Mozbrowser() {
|
||||
if iframe.upcast::<Node>().is_in_doc() {
|
||||
if iframe.upcast::<Node>().is_in_doc_with_browsing_context() {
|
||||
let window = window_from_node(iframe);
|
||||
let msg = ConstellationMsg::TraverseHistory(iframe.pipeline_id(), direction);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||
|
@ -495,7 +500,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
|||
// 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() {
|
||||
if self.upcast::<Node>().is_in_doc_with_browsing_context() {
|
||||
self.navigate_or_reload_child_browsing_context(None, true);
|
||||
}
|
||||
Ok(())
|
||||
|
@ -593,7 +598,16 @@ impl VirtualMethods for HTMLIFrameElement {
|
|||
},
|
||||
&local_name!("src") => {
|
||||
if let AttributeMutation::Set(_) = mutation {
|
||||
if self.upcast::<Node>().is_in_doc() {
|
||||
// https://html.spec.whatwg.org/multipage/#the-iframe-element
|
||||
// "Similarly, whenever an iframe element with a non-null nested browsing context
|
||||
// but with no srcdoc attribute specified has its src attribute set, changed, or removed,
|
||||
// the user agent must process the iframe attributes,"
|
||||
// but we can't check that directly, since the child browsing context
|
||||
// may be in a different script thread. Instread, we check to see if the parent
|
||||
// is in a document tree and has a browsing context, which is what causes
|
||||
// the child browsing context to be created.
|
||||
if self.upcast::<Node>().is_in_doc_with_browsing_context() {
|
||||
debug!("iframe {} src set while in browsing context.", self.frame_id);
|
||||
self.process_the_iframe_attributes();
|
||||
}
|
||||
}
|
||||
|
@ -616,7 +630,14 @@ impl VirtualMethods for HTMLIFrameElement {
|
|||
s.bind_to_tree(tree_in_doc);
|
||||
}
|
||||
|
||||
if tree_in_doc {
|
||||
// https://html.spec.whatwg.org/multipage/#the-iframe-element
|
||||
// "When an iframe element is inserted into a document that has
|
||||
// a browsing context, the user agent must create a new
|
||||
// browsing context, set the element's nested browsing context
|
||||
// to the newly-created browsing context, and then process the
|
||||
// iframe attributes for the "first time"."
|
||||
if self.upcast::<Node>().is_in_doc_with_browsing_context() {
|
||||
debug!("iframe {} bound to browsing context.", self.frame_id);
|
||||
self.process_the_iframe_attributes();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,12 +105,12 @@ impl Runnable for ImageResponseHandlerRunnable {
|
|||
|
||||
// Fire image.onload
|
||||
if trigger_image_load {
|
||||
element.upcast::<EventTarget>().fire_simple_event("load");
|
||||
element.upcast::<EventTarget>().fire_event(atom!("load"));
|
||||
}
|
||||
|
||||
// Fire image.onerror
|
||||
if trigger_image_error {
|
||||
element.upcast::<EventTarget>().fire_simple_event("error");
|
||||
element.upcast::<EventTarget>().fire_event(atom!("error"));
|
||||
}
|
||||
|
||||
// Trigger reflow
|
||||
|
@ -180,8 +180,8 @@ impl HTMLImageElement {
|
|||
// Step 11, substep 5
|
||||
let img = self.img.root();
|
||||
img.current_request.borrow_mut().source_url = Some(self.src.into());
|
||||
img.upcast::<EventTarget>().fire_simple_event("error");
|
||||
img.upcast::<EventTarget>().fire_simple_event("loadend");
|
||||
img.upcast::<EventTarget>().fire_event(atom!("error"));
|
||||
img.upcast::<EventTarget>().fire_event(atom!("loadend"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -849,12 +849,8 @@ impl HTMLInputElement {
|
|||
let filelist = FileList::new(&window, files);
|
||||
self.filelist.set(Some(&filelist));
|
||||
|
||||
target.fire_event("input",
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable);
|
||||
target.fire_event("change",
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable);
|
||||
target.fire_bubbling_event(atom!("input"));
|
||||
target.fire_bubbling_event(atom!("change"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1290,12 +1286,8 @@ impl Activatable for HTMLInputElement {
|
|||
// https://html.spec.whatwg.org/multipage/#radio-button-state-(type=radio):activation-behavior
|
||||
// Check if document owner is fully active
|
||||
let target = self.upcast::<EventTarget>();
|
||||
target.fire_event("input",
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable);
|
||||
target.fire_event("change",
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable);
|
||||
target.fire_bubbling_event(atom!("input"));
|
||||
target.fire_bubbling_event(atom!("change"));
|
||||
},
|
||||
InputType::InputFile => self.select_files(None),
|
||||
_ => ()
|
||||
|
|
|
@ -30,8 +30,7 @@ use hyper::mime::{Mime, TopLevel, SubLevel};
|
|||
use hyper_serde::Serde;
|
||||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use msg::constellation_msg::ReferrerPolicy;
|
||||
use net_traits::{FetchResponseListener, FetchMetadata, Metadata, NetworkError};
|
||||
use net_traits::{FetchResponseListener, FetchMetadata, Metadata, NetworkError, ReferrerPolicy};
|
||||
use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
use script_layout_interface::message::Msg;
|
||||
|
@ -325,7 +324,7 @@ impl FetchResponseListener for StylesheetContext {
|
|||
if let Some(ref meta) = self.metadata {
|
||||
if let Some(Serde(ContentType(Mime(TopLevel::Text, SubLevel::Css, _)))) = meta.content_type {
|
||||
} else {
|
||||
self.elem.root().upcast::<EventTarget>().fire_simple_event("error");
|
||||
self.elem.root().upcast::<EventTarget>().fire_event(atom!("error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -380,9 +379,9 @@ impl FetchResponseListener for StylesheetContext {
|
|||
|
||||
document.finish_load(LoadType::Stylesheet(self.url.clone()));
|
||||
|
||||
let event = if successful { "load" } else { "error" };
|
||||
let event = if successful { atom!("load") } else { atom!("error") };
|
||||
|
||||
elem.upcast::<EventTarget>().fire_simple_event(event);
|
||||
elem.upcast::<EventTarget>().fire_event(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ impl WeakMediaQueryListVec {
|
|||
pub fn evaluate_and_report_changes(&self) {
|
||||
for mql in self.cell.borrow().iter() {
|
||||
if let MediaQueryListMatchState::Changed(_) = mql.root().unwrap().evaluate_changes() {
|
||||
mql.root().unwrap().upcast::<EventTarget>().fire_simple_event("change");
|
||||
mql.root().unwrap().upcast::<EventTarget>().fire_event(atom!("change"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -399,6 +399,7 @@ pub mod testbinding;
|
|||
pub mod testbindingiterable;
|
||||
pub mod testbindingpairiterable;
|
||||
pub mod testbindingproxy;
|
||||
pub mod testrunner;
|
||||
pub mod text;
|
||||
pub mod textdecoder;
|
||||
pub mod textencoder;
|
||||
|
|
|
@ -771,6 +771,10 @@ impl Node {
|
|||
self.owner_doc().is_html_document()
|
||||
}
|
||||
|
||||
pub fn is_in_doc_with_browsing_context(&self) -> bool {
|
||||
self.is_in_doc() && self.owner_doc().browsing_context().is_some()
|
||||
}
|
||||
|
||||
pub fn children(&self) -> NodeSiblingIterator {
|
||||
NodeSiblingIterator {
|
||||
current: self.GetFirstChild(),
|
||||
|
@ -849,22 +853,23 @@ impl Node {
|
|||
|
||||
let tr = new_child();
|
||||
|
||||
let after_node = if index == -1 {
|
||||
None
|
||||
} else {
|
||||
match get_items().elements_iter()
|
||||
.map(Root::upcast::<Node>)
|
||||
.map(Some)
|
||||
.chain(iter::once(None))
|
||||
.nth(index as usize) {
|
||||
None => return Err(Error::IndexSize),
|
||||
Some(node) => node,
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
let tr_node = tr.upcast::<Node>();
|
||||
try!(self.InsertBefore(tr_node, after_node.r()));
|
||||
if index == -1 {
|
||||
try!(self.InsertBefore(tr_node, None));
|
||||
} else {
|
||||
let items = get_items();
|
||||
let node = match items.elements_iter()
|
||||
.map(Root::upcast::<Node>)
|
||||
.map(Some)
|
||||
.chain(iter::once(None))
|
||||
.nth(index as usize) {
|
||||
None => return Err(Error::IndexSize),
|
||||
Some(node) => node,
|
||||
};
|
||||
try!(self.InsertBefore(tr_node, node.r()));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Root::upcast::<HTMLElement>(tr))
|
||||
|
|
|
@ -25,7 +25,7 @@ use dom::headers::{Guard, Headers};
|
|||
use dom::promise::Promise;
|
||||
use dom::xmlhttprequest::Extractable;
|
||||
use hyper::method::Method as HttpMethod;
|
||||
use msg::constellation_msg::ReferrerPolicy as MsgReferrerPolicy;
|
||||
use net_traits::ReferrerPolicy as MsgReferrerPolicy;
|
||||
use net_traits::request::{Origin, Window};
|
||||
use net_traits::request::CacheMode as NetTraitsRequestCache;
|
||||
use net_traits::request::CredentialsMode as NetTraitsRequestCredentials;
|
||||
|
|
|
@ -18,6 +18,7 @@ use dom::globalscope::GlobalScope;
|
|||
use js::jsapi::{HandleValue, JSContext};
|
||||
use script_thread::Runnable;
|
||||
use script_traits::{ScriptMsg, DOMMessage};
|
||||
use servo_atoms::Atom;
|
||||
use std::cell::Cell;
|
||||
use url::Url;
|
||||
|
||||
|
@ -56,12 +57,12 @@ impl ServiceWorker {
|
|||
|
||||
pub fn dispatch_simple_error(address: TrustedServiceWorkerAddress) {
|
||||
let service_worker = address.root();
|
||||
service_worker.upcast().fire_simple_event("error");
|
||||
service_worker.upcast().fire_event(atom!("error"));
|
||||
}
|
||||
|
||||
pub fn set_transition_state(&self, state: ServiceWorkerState) {
|
||||
self.state.set(state);
|
||||
self.upcast::<EventTarget>().fire_simple_event("statechange");
|
||||
self.upcast::<EventTarget>().fire_event(Atom::from("statechange"));
|
||||
}
|
||||
|
||||
pub fn get_script_url(&self) -> Url {
|
||||
|
|
|
@ -15,6 +15,7 @@ use dom::promise::Promise;
|
|||
use dom::serviceworker::ServiceWorker;
|
||||
use dom::serviceworkerregistration::ServiceWorkerRegistration;
|
||||
use script_thread::ScriptThread;
|
||||
use servo_atoms::Atom;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::default::Default;
|
||||
use std::rc::Rc;
|
||||
|
@ -45,7 +46,7 @@ pub trait Controllable {
|
|||
impl Controllable for ServiceWorkerContainer {
|
||||
fn set_controller(&self, active_worker: &ServiceWorker) {
|
||||
self.controller.set(Some(active_worker));
|
||||
self.upcast::<EventTarget>().fire_simple_event("controllerchange");
|
||||
self.upcast::<EventTarget>().fire_event(Atom::from("controllerchange"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as Req
|
|||
use rand::random;
|
||||
use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx, ScriptChan};
|
||||
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
|
||||
use servo_atoms::Atom;
|
||||
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
@ -268,7 +269,7 @@ impl ServiceWorkerGlobalScope {
|
|||
// TODO XXXcreativcoder This will eventually use a FetchEvent interface to fire event
|
||||
// when we have the Request and Response dom api's implemented
|
||||
// https://slightlyoff.github.io/ServiceWorker/spec/service_worker_1/index.html#fetch-event-section
|
||||
self.upcast::<EventTarget>().fire_simple_event("fetch");
|
||||
self.upcast::<EventTarget>().fire_event(Atom::from("fetch"));
|
||||
let _ = mediator.response_chan.send(None);
|
||||
}
|
||||
}
|
||||
|
|
53
components/script/dom/testrunner.rs
Normal file
53
components/script/dom/testrunner.rs
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* 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/. */
|
||||
|
||||
use bluetooth_traits::BluetoothMethodMsg;
|
||||
use dom::bindings::codegen::Bindings::TestRunnerBinding;
|
||||
use dom::bindings::codegen::Bindings::TestRunnerBinding::TestRunnerMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/tests#test-runner
|
||||
#[dom_struct]
|
||||
pub struct TestRunner {
|
||||
reflector_: Reflector,
|
||||
}
|
||||
|
||||
impl TestRunner {
|
||||
pub fn new_inherited() -> TestRunner {
|
||||
TestRunner {
|
||||
reflector_: Reflector::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: &GlobalScope) -> Root<TestRunner> {
|
||||
reflect_dom_object(box TestRunner::new_inherited(),
|
||||
global,
|
||||
TestRunnerBinding::Wrap)
|
||||
}
|
||||
|
||||
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
||||
self.global().as_window().bluetooth_thread()
|
||||
}
|
||||
}
|
||||
|
||||
impl TestRunnerMethods for TestRunner {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/tests#setBluetoothMockDataSet
|
||||
fn SetBluetoothMockDataSet(&self, dataSetName: DOMString) -> ErrorResult {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(BluetoothMethodMsg::Test(String::from(dataSetName), sender)).unwrap();
|
||||
match receiver.recv().unwrap().into() {
|
||||
Ok(()) => {
|
||||
Ok(())
|
||||
},
|
||||
Err(error) => {
|
||||
Err(Error::from(error))
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
16
components/script/dom/webidls/TestRunner.webidl
Normal file
16
components/script/dom/webidls/TestRunner.webidl
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* 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://webbluetoothcg.github.io/web-bluetooth/tests#test-runner
|
||||
|
||||
// callback BluetoothManualChooserEventsCallback = void(sequence<DOMString> events);
|
||||
|
||||
[Pref="dom.bluetooth.testing.enabled", Exposed=Window]
|
||||
interface TestRunner {
|
||||
[Throws]
|
||||
void setBluetoothMockDataSet(DOMString dataSetName);
|
||||
// void setBluetoothManualChooser();
|
||||
// void getBluetoothManualChooserEvents(BluetoothManualChooserEventsCallback callback);
|
||||
// void sendBluetoothManualChooserEvent(DOMString event, DOMString argument);
|
||||
};
|
|
@ -185,3 +185,10 @@ Window implements WindowLocalStorage;
|
|||
|
||||
// http://w3c.github.io/animation-timing/#framerequestcallback
|
||||
callback FrameRequestCallback = void (DOMHighResTimeStamp time);
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/tests#test-interfaces
|
||||
partial interface Window {
|
||||
[Pref="dom.bluetooth.testing.enabled", Exposed=Window]
|
||||
readonly attribute TestRunner testRunner;
|
||||
//readonly attribute EventSender eventSender;
|
||||
};
|
||||
|
|
|
@ -498,7 +498,7 @@ impl Runnable for ConnectionEstablishedTask {
|
|||
}
|
||||
|
||||
// Step 6.
|
||||
ws.upcast().fire_simple_event("open");
|
||||
ws.upcast().fire_event(atom!("open"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ impl Runnable for CloseTask {
|
|||
|
||||
// Step 2.
|
||||
if self.failed {
|
||||
ws.upcast().fire_simple_event("error");
|
||||
ws.upcast().fire_event(atom!("error"));
|
||||
}
|
||||
|
||||
// Step 3.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use app_units::Au;
|
||||
use bluetooth_traits::BluetoothMethodMsg;
|
||||
use cssparser::Parser;
|
||||
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
|
||||
use dom::bindings::callback::ExceptionHandling;
|
||||
|
@ -44,6 +45,7 @@ use dom::performance::Performance;
|
|||
use dom::promise::Promise;
|
||||
use dom::screen::Screen;
|
||||
use dom::storage::Storage;
|
||||
use dom::testrunner::TestRunner;
|
||||
use euclid::{Point2D, Rect, Size2D};
|
||||
use fetch;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
|
@ -51,9 +53,8 @@ use js::jsapi::{HandleObject, HandleValue, JSAutoCompartment, JSContext};
|
|||
use js::jsapi::{JS_GC, JS_GetRuntime, SetWindowProxy};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::Runtime;
|
||||
use msg::constellation_msg::{FrameType, PipelineId, ReferrerPolicy};
|
||||
use net_traits::ResourceThreads;
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
use msg::constellation_msg::{FrameType, PipelineId};
|
||||
use net_traits::{ResourceThreads, ReferrerPolicy};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||
use net_traits::storage_thread::StorageType;
|
||||
use num_traits::ToPrimitive;
|
||||
|
@ -239,6 +240,8 @@ pub struct Window {
|
|||
|
||||
/// All the MediaQueryLists we need to update
|
||||
media_query_lists: WeakMediaQueryListVec,
|
||||
|
||||
test_runner: MutNullableHeap<JS<TestRunner>>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -881,6 +884,10 @@ impl WindowMethods for Window {
|
|||
fn Fetch(&self, input: RequestOrUSVString, init: &RequestInit) -> Rc<Promise> {
|
||||
fetch::Fetch(&self.upcast(), input, init)
|
||||
}
|
||||
|
||||
fn TestRunner(&self) -> Root<TestRunner> {
|
||||
self.test_runner.or_init(|| TestRunner::new(self.upcast()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -1588,6 +1595,7 @@ impl Window {
|
|||
error_reporter: error_reporter,
|
||||
scroll_offsets: DOMRefCell::new(HashMap::new()),
|
||||
media_query_lists: WeakMediaQueryListVec::new(),
|
||||
test_runner: Default::default(),
|
||||
};
|
||||
|
||||
WindowBinding::Wrap(runtime.cx(), win)
|
||||
|
|
|
@ -138,7 +138,7 @@ impl Worker {
|
|||
|
||||
pub fn dispatch_simple_error(address: TrustedWorkerAddress) {
|
||||
let worker = address.root();
|
||||
worker.upcast().fire_simple_event("error");
|
||||
worker.upcast().fire_event(atom!("error"));
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
|
@ -48,9 +48,9 @@ use ipc_channel::router::ROUTER;
|
|||
use js::jsapi::{JSContext, JS_ParseJSON};
|
||||
use js::jsapi::JS_ClearPendingException;
|
||||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::{CoreResourceThread, FetchMetadata, FilteredMetadata};
|
||||
use net_traits::{FetchResponseListener, LoadOrigin, NetworkError};
|
||||
use net_traits::{FetchResponseListener, LoadOrigin, NetworkError, ReferrerPolicy};
|
||||
use net_traits::CoreResourceMsg::Fetch;
|
||||
use net_traits::request::{CredentialsMode, Destination, RequestInit, RequestMode};
|
||||
use net_traits::trim_http_whitespace;
|
||||
|
|
|
@ -32,6 +32,7 @@ extern crate audio_video_metadata;
|
|||
#[allow(unused_extern_crates)]
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate bluetooth_traits;
|
||||
extern crate canvas_traits;
|
||||
extern crate caseless;
|
||||
extern crate cookie as cookie_rs;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
//! a page runs its course and the script thread returns to processing events in the main event
|
||||
//! loop.
|
||||
|
||||
use bluetooth_traits::BluetoothMethodMsg;
|
||||
use devtools;
|
||||
use devtools_traits::{DevtoolScriptControlMsg, DevtoolsPageInfo};
|
||||
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
|
||||
|
@ -71,9 +72,8 @@ use js::jsval::UndefinedValue;
|
|||
use js::rust::Runtime;
|
||||
use layout_wrapper::ServoLayoutNode;
|
||||
use mem::heap_size_of_self_and_children;
|
||||
use msg::constellation_msg::{FrameType, PipelineId, PipelineNamespace, ReferrerPolicy};
|
||||
use net_traits::{CoreResourceMsg, IpcSend, Metadata, ResourceThreads};
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
use msg::constellation_msg::{FrameId, FrameType, PipelineId, PipelineNamespace};
|
||||
use net_traits::{CoreResourceMsg, IpcSend, Metadata, ReferrerPolicy, ResourceThreads};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
||||
use net_traits::request::{CredentialsMode, Destination, RequestInit};
|
||||
use network_listener::NetworkListener;
|
||||
|
@ -135,6 +135,8 @@ pub unsafe fn trace_thread(tr: *mut JSTracer) {
|
|||
struct InProgressLoad {
|
||||
/// The pipeline which requested this load.
|
||||
pipeline_id: PipelineId,
|
||||
/// The frame being loaded into.
|
||||
frame_id: FrameId,
|
||||
/// The parent pipeline and frame type associated with this load, if any.
|
||||
parent_info: Option<(PipelineId, FrameType)>,
|
||||
/// The current window size associated with this pipeline.
|
||||
|
@ -154,12 +156,14 @@ struct InProgressLoad {
|
|||
impl InProgressLoad {
|
||||
/// Create a new InProgressLoad object.
|
||||
fn new(id: PipelineId,
|
||||
frame_id: FrameId,
|
||||
parent_info: Option<(PipelineId, FrameType)>,
|
||||
layout_chan: Sender<message::Msg>,
|
||||
window_size: Option<WindowSizeData>,
|
||||
url: Url) -> InProgressLoad {
|
||||
InProgressLoad {
|
||||
pipeline_id: id,
|
||||
frame_id: frame_id,
|
||||
parent_info: parent_info,
|
||||
layout_chan: layout_chan,
|
||||
window_size: window_size,
|
||||
|
@ -452,15 +456,15 @@ impl ScriptThreadFactory for ScriptThread {
|
|||
|
||||
let (sender, receiver) = channel();
|
||||
let layout_chan = sender.clone();
|
||||
let pipeline_id = state.id;
|
||||
thread::spawn_named(format!("ScriptThread {:?}", state.id),
|
||||
move || {
|
||||
thread_state::initialize(thread_state::SCRIPT);
|
||||
PipelineId::install(pipeline_id);
|
||||
PipelineId::install(state.id);
|
||||
PipelineNamespace::install(state.pipeline_namespace_id);
|
||||
let roots = RootCollection::new();
|
||||
let _stack_roots_tls = StackRootTLS::new(&roots);
|
||||
let id = state.id;
|
||||
let frame_id = state.frame_id;
|
||||
let parent_info = state.parent_info;
|
||||
let mem_profiler_chan = state.mem_profiler_chan.clone();
|
||||
let window_size = state.window_size;
|
||||
|
@ -474,7 +478,7 @@ impl ScriptThreadFactory for ScriptThread {
|
|||
|
||||
let mut failsafe = ScriptMemoryFailsafe::new(&script_thread);
|
||||
|
||||
let new_load = InProgressLoad::new(id, parent_info, layout_chan, window_size,
|
||||
let new_load = InProgressLoad::new(id, frame_id, parent_info, layout_chan, window_size,
|
||||
load_data.url.clone());
|
||||
script_thread.start_page_load(new_load, load_data);
|
||||
|
||||
|
@ -888,8 +892,8 @@ impl ScriptThread {
|
|||
|
||||
fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) {
|
||||
match msg {
|
||||
ConstellationControlMsg::Navigate(parent_pipeline_id, pipeline_id, load_data, replace) =>
|
||||
self.handle_navigate(parent_pipeline_id, Some(pipeline_id), load_data, replace),
|
||||
ConstellationControlMsg::Navigate(parent_pipeline_id, frame_id, load_data, replace) =>
|
||||
self.handle_navigate(parent_pipeline_id, Some(frame_id), load_data, replace),
|
||||
ConstellationControlMsg::SendEvent(id, event) =>
|
||||
self.handle_event(id, event),
|
||||
ConstellationControlMsg::ResizeInactive(id, new_size) =>
|
||||
|
@ -902,22 +906,22 @@ impl ScriptThread {
|
|||
self.handle_thaw_msg(pipeline_id),
|
||||
ConstellationControlMsg::ChangeFrameVisibilityStatus(pipeline_id, visible) =>
|
||||
self.handle_visibility_change_msg(pipeline_id, visible),
|
||||
ConstellationControlMsg::NotifyVisibilityChange(parent_pipeline_id, pipeline_id, visible) =>
|
||||
self.handle_visibility_change_complete_msg(parent_pipeline_id, pipeline_id, visible),
|
||||
ConstellationControlMsg::NotifyVisibilityChange(parent_pipeline_id, frame_id, visible) =>
|
||||
self.handle_visibility_change_complete_msg(parent_pipeline_id, frame_id, visible),
|
||||
ConstellationControlMsg::MozBrowserEvent(parent_pipeline_id,
|
||||
pipeline_id,
|
||||
frame_id,
|
||||
event) =>
|
||||
self.handle_mozbrowser_event_msg(parent_pipeline_id,
|
||||
pipeline_id,
|
||||
frame_id,
|
||||
event),
|
||||
ConstellationControlMsg::UpdatePipelineId(parent_pipeline_id,
|
||||
old_pipeline_id,
|
||||
frame_id,
|
||||
new_pipeline_id) =>
|
||||
self.handle_update_pipeline_id(parent_pipeline_id,
|
||||
old_pipeline_id,
|
||||
frame_id,
|
||||
new_pipeline_id),
|
||||
ConstellationControlMsg::FocusIFrame(parent_pipeline_id, pipeline_id) =>
|
||||
self.handle_focus_iframe_msg(parent_pipeline_id, pipeline_id),
|
||||
ConstellationControlMsg::FocusIFrame(parent_pipeline_id, frame_id) =>
|
||||
self.handle_focus_iframe_msg(parent_pipeline_id, frame_id),
|
||||
ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, msg) =>
|
||||
self.handle_webdriver_msg(pipeline_id, msg),
|
||||
ConstellationControlMsg::TickAllAnimations(pipeline_id) =>
|
||||
|
@ -927,10 +931,10 @@ impl ScriptThread {
|
|||
ConstellationControlMsg::WebFontLoaded(pipeline_id) =>
|
||||
self.handle_web_font_loaded(pipeline_id),
|
||||
ConstellationControlMsg::DispatchFrameLoadEvent {
|
||||
target: pipeline_id, parent: parent_pipeline_id } =>
|
||||
self.handle_frame_load_event(parent_pipeline_id, pipeline_id),
|
||||
ConstellationControlMsg::FramedContentChanged(parent_pipeline_id, pipeline_id) =>
|
||||
self.handle_framed_content_changed(parent_pipeline_id, pipeline_id),
|
||||
target: frame_id, parent: parent_id, child: child_id } =>
|
||||
self.handle_frame_load_event(parent_id, frame_id, child_id),
|
||||
ConstellationControlMsg::FramedContentChanged(parent_pipeline_id, frame_id) =>
|
||||
self.handle_framed_content_changed(parent_pipeline_id, frame_id),
|
||||
ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) =>
|
||||
self.handle_css_error_reporting(pipeline_id, filename, line, column, msg),
|
||||
ConstellationControlMsg::Reload(pipeline_id) =>
|
||||
|
@ -1139,6 +1143,7 @@ impl ScriptThread {
|
|||
let NewLayoutInfo {
|
||||
parent_pipeline_id,
|
||||
new_pipeline_id,
|
||||
frame_id,
|
||||
frame_type,
|
||||
load_data,
|
||||
pipeline_port,
|
||||
|
@ -1175,7 +1180,7 @@ impl ScriptThread {
|
|||
.unwrap();
|
||||
|
||||
// Kick off the fetch for the new resource.
|
||||
let new_load = InProgressLoad::new(new_pipeline_id, Some((parent_pipeline_id, frame_type)),
|
||||
let new_load = InProgressLoad::new(new_pipeline_id, frame_id, Some((parent_pipeline_id, frame_type)),
|
||||
layout_chan, parent_window.window_size(),
|
||||
load_data.url.clone());
|
||||
self.start_page_load(new_load, load_data);
|
||||
|
@ -1187,12 +1192,15 @@ impl ScriptThread {
|
|||
None => return warn!("Message sent to closed pipeline {}.", pipeline),
|
||||
};
|
||||
if doc.loader().is_blocked() {
|
||||
debug!("Script thread got loads complete while loader is blocked.");
|
||||
return;
|
||||
}
|
||||
|
||||
doc.mut_loader().inhibit_events();
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-end step 7
|
||||
// Schedule a task to fire a "load" event (if no blocking loads have arrived in the mean time)
|
||||
// NOTE: we can end up executing this code more than once, in case more blocking loads arrive.
|
||||
let handler = box DocumentProgressHandler::new(Trusted::new(&doc));
|
||||
self.dom_manipulation_task_source.queue(handler, doc.window().upcast()).unwrap();
|
||||
|
||||
|
@ -1259,7 +1267,7 @@ impl ScriptThread {
|
|||
}
|
||||
|
||||
/// Updates iframe element after a change in visibility
|
||||
fn handle_visibility_change_complete_msg(&self, parent_pipeline_id: PipelineId, id: PipelineId, visible: bool) {
|
||||
fn handle_visibility_change_complete_msg(&self, parent_pipeline_id: PipelineId, id: FrameId, visible: bool) {
|
||||
if let Some(root_context) = self.browsing_context.get() {
|
||||
if let Some(ref inner_context) = root_context.find(parent_pipeline_id) {
|
||||
if let Some(iframe) = inner_context.active_document().find_iframe(id) {
|
||||
|
@ -1328,12 +1336,12 @@ impl ScriptThread {
|
|||
|
||||
fn handle_focus_iframe_msg(&self,
|
||||
parent_pipeline_id: PipelineId,
|
||||
pipeline_id: PipelineId) {
|
||||
frame_id: FrameId) {
|
||||
let borrowed_context = self.root_browsing_context();
|
||||
let context = borrowed_context.find(parent_pipeline_id).unwrap();
|
||||
|
||||
let doc = context.active_document();
|
||||
let frame_element = doc.find_iframe(pipeline_id);
|
||||
let frame_element = doc.find_iframe(frame_id);
|
||||
|
||||
if let Some(ref frame_element) = frame_element {
|
||||
doc.begin_focus_transaction();
|
||||
|
@ -1344,11 +1352,11 @@ impl ScriptThread {
|
|||
|
||||
fn handle_framed_content_changed(&self,
|
||||
parent_pipeline_id: PipelineId,
|
||||
pipeline_id: PipelineId) {
|
||||
frame_id: FrameId) {
|
||||
let root_context = self.root_browsing_context();
|
||||
let context = root_context.find(parent_pipeline_id).unwrap();
|
||||
let doc = context.active_document();
|
||||
let frame_element = doc.find_iframe(pipeline_id);
|
||||
let frame_element = doc.find_iframe(frame_id);
|
||||
if let Some(ref frame_element) = frame_element {
|
||||
frame_element.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
let window = context.active_window();
|
||||
|
@ -1362,14 +1370,14 @@ impl ScriptThread {
|
|||
/// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
|
||||
fn handle_mozbrowser_event_msg(&self,
|
||||
parent_pipeline_id: PipelineId,
|
||||
pipeline_id: Option<PipelineId>,
|
||||
frame_id: Option<FrameId>,
|
||||
event: MozBrowserEvent) {
|
||||
match self.root_browsing_context().find(parent_pipeline_id) {
|
||||
None => warn!("Mozbrowser event after pipeline {:?} closed.", parent_pipeline_id),
|
||||
Some(context) => match pipeline_id {
|
||||
Some(context) => match frame_id {
|
||||
None => context.active_window().dispatch_mozbrowser_event(event),
|
||||
Some(pipeline_id) => match context.active_document().find_iframe(pipeline_id) {
|
||||
None => warn!("Mozbrowser event after iframe {:?}/{:?} closed.", parent_pipeline_id, pipeline_id),
|
||||
Some(frame_id) => match context.active_document().find_iframe(frame_id) {
|
||||
None => warn!("Mozbrowser event after iframe {:?}/{:?} closed.", parent_pipeline_id, frame_id),
|
||||
Some(frame_element) => frame_element.dispatch_mozbrowser_event(event),
|
||||
},
|
||||
},
|
||||
|
@ -1378,13 +1386,13 @@ impl ScriptThread {
|
|||
|
||||
fn handle_update_pipeline_id(&self,
|
||||
parent_pipeline_id: PipelineId,
|
||||
old_pipeline_id: PipelineId,
|
||||
frame_id: FrameId,
|
||||
new_pipeline_id: PipelineId) {
|
||||
let borrowed_context = self.root_browsing_context();
|
||||
|
||||
let frame_element = borrowed_context.find(parent_pipeline_id).and_then(|context| {
|
||||
let doc = context.active_document();
|
||||
doc.find_iframe(old_pipeline_id)
|
||||
doc.find_iframe(frame_id)
|
||||
});
|
||||
|
||||
frame_element.unwrap().update_pipeline_id(new_pipeline_id);
|
||||
|
@ -1567,13 +1575,15 @@ impl ScriptThread {
|
|||
}
|
||||
|
||||
/// Notify the containing document of a child frame that has completed loading.
|
||||
fn handle_frame_load_event(&self, parent_pipeline_id: PipelineId, id: PipelineId) {
|
||||
let document = match self.root_browsing_context().find(parent_pipeline_id) {
|
||||
fn handle_frame_load_event(&self, parent_id: PipelineId, frame_id: FrameId, child_id: PipelineId) {
|
||||
let document = match self.root_browsing_context().find(parent_id) {
|
||||
Some(browsing_context) => browsing_context.active_document(),
|
||||
None => return warn!("Message sent to closed pipeline {}.", parent_pipeline_id),
|
||||
None => return warn!("Message sent to closed pipeline {}.", parent_id),
|
||||
};
|
||||
if let Some(iframe) = document.find_iframe(id) {
|
||||
iframe.iframe_load_event_steps(id);
|
||||
if let Some(iframe) = document.find_iframe(frame_id) {
|
||||
if iframe.pipeline_id() == Some(child_id) {
|
||||
iframe.iframe_load_event_steps(child_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1609,7 +1619,7 @@ impl ScriptThread {
|
|||
root_context.and_then(|root_context| {
|
||||
root_context.find(parent_id).and_then(|context| {
|
||||
let doc = context.active_document();
|
||||
doc.find_iframe(incomplete.pipeline_id)
|
||||
doc.find_iframe(incomplete.frame_id)
|
||||
})
|
||||
})
|
||||
});
|
||||
|
@ -2037,7 +2047,7 @@ impl ScriptThread {
|
|||
/// The entry point for content to notify that a new load has been requested
|
||||
/// for the given pipeline (specifically the "navigate" algorithm).
|
||||
fn handle_navigate(&self, parent_pipeline_id: PipelineId,
|
||||
pipeline_id: Option<PipelineId>,
|
||||
frame_id: Option<FrameId>,
|
||||
load_data: LoadData,
|
||||
replace: bool) {
|
||||
// Step 7.
|
||||
|
@ -2057,12 +2067,12 @@ impl ScriptThread {
|
|||
}
|
||||
}
|
||||
|
||||
match pipeline_id {
|
||||
Some(pipeline_id) => {
|
||||
match frame_id {
|
||||
Some(frame_id) => {
|
||||
let root_context = self.root_browsing_context();
|
||||
let iframe = root_context.find(parent_pipeline_id).and_then(|context| {
|
||||
let doc = context.active_document();
|
||||
doc.find_iframe(pipeline_id)
|
||||
doc.find_iframe(frame_id)
|
||||
});
|
||||
if let Some(iframe) = iframe.r() {
|
||||
iframe.navigate_or_reload_child_browsing_context(Some(load_data), replace);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue