aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/attr.rs7
-rw-r--r--components/script/dom/bindings/trace.rs4
-rw-r--r--components/script/dom/bluetoothremotegattservice.rs57
-rw-r--r--components/script/dom/browsingcontext.rs19
-rw-r--r--components/script/dom/cssstyledeclaration.rs54
-rw-r--r--components/script/dom/dedicatedworkerglobalscope.rs7
-rw-r--r--components/script/dom/document.rs24
-rw-r--r--components/script/dom/element.rs184
-rw-r--r--components/script/dom/file.rs2
-rw-r--r--components/script/dom/htmliframeelement.rs4
-rw-r--r--components/script/dom/storage.rs1
-rw-r--r--components/script/dom/webidls/BluetoothRemoteGATTService.webidl4
-rw-r--r--components/script/dom/webidls/Window.webidl2
-rw-r--r--components/script/dom/window.rs27
-rw-r--r--components/script/dom/worker.rs11
15 files changed, 251 insertions, 156 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index 95ff73e2cb7..43c1226b295 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -173,13 +173,18 @@ impl Attr {
pub fn set_value(&self, mut value: AttrValue, owner: &Element) {
assert!(Some(owner) == self.owner().r());
owner.will_mutate_attr();
- mem::swap(&mut *self.value.borrow_mut(), &mut value);
+ self.swap_value(&mut value);
if self.identifier.namespace == ns!() {
vtable_for(owner.upcast())
.attribute_mutated(self, AttributeMutation::Set(Some(&value)));
}
}
+ /// Used to swap the attribute's value without triggering mutation events
+ pub fn swap_value(&self, value: &mut AttrValue) {
+ mem::swap(&mut *self.value.borrow_mut(), value);
+ }
+
pub fn identifier(&self) -> &AttrIdentifier {
&self.identifier
}
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index e97e5cb923d..4a1c781a293 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -56,7 +56,7 @@ use js::jsval::JSVal;
use js::rust::Runtime;
use layout_interface::{LayoutChan, LayoutRPC};
use libc;
-use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData, WindowSizeType, ReferrerPolicy};
+use msg::constellation_msg::{FrameType, PipelineId, SubpageId, WindowSizeData, WindowSizeType, ReferrerPolicy};
use net_traits::image::base::{Image, ImageMetadata};
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
use net_traits::response::HttpsState;
@@ -290,7 +290,7 @@ no_jsmanaged_fields!(PropertyDeclarationBlock);
no_jsmanaged_fields!(HashSet<T>);
// These three are interdependent, if you plan to put jsmanaged data
// in one of these make sure it is propagated properly to containing structs
-no_jsmanaged_fields!(SubpageId, WindowSizeData, WindowSizeType, PipelineId);
+no_jsmanaged_fields!(FrameType, SubpageId, WindowSizeData, WindowSizeType, PipelineId);
no_jsmanaged_fields!(TimerEventId, TimerSource);
no_jsmanaged_fields!(WorkerId);
no_jsmanaged_fields!(QuirksMode);
diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs
index bf9312112c1..78427f7f6de 100644
--- a/components/script/dom/bluetoothremotegattservice.rs
+++ b/components/script/dom/bluetoothremotegattservice.rs
@@ -13,7 +13,7 @@ use dom::bindings::str::DOMString;
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
use dom::bluetoothdevice::BluetoothDevice;
use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
-use dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothUUID};
+use dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothServiceUUID, BluetoothUUID};
use ipc_channel::ipc::{self, IpcSender};
use net_traits::bluetooth_thread::BluetoothMethodMsg;
@@ -155,4 +155,59 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
},
}
}
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getincludedservice
+ fn GetIncludedService(&self,
+ service: BluetoothServiceUUID)
+ -> Fallible<Root<BluetoothRemoteGATTService>> {
+ let uuid = try!(BluetoothUUID::GetService(self.global().r(), service)).to_string();
+ let (sender, receiver) = ipc::channel().unwrap();
+ self.get_bluetooth_thread().send(
+ BluetoothMethodMsg::GetIncludedService(self.get_instance_id(),
+ uuid,
+ sender)).unwrap();
+ let service = receiver.recv().unwrap();
+ match service {
+ Ok(service) => {
+ Ok(BluetoothRemoteGATTService::new(self.global().r(),
+ &self.device.get(),
+ DOMString::from(service.uuid),
+ service.is_primary,
+ service.instance_id))
+ },
+ Err(error) => {
+ Err(Type(error))
+ },
+ }
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getincludedservices
+ fn GetIncludedServices(&self,
+ service: Option<BluetoothServiceUUID>)
+ -> Fallible<Vec<Root<BluetoothRemoteGATTService>>> {
+ let mut uuid: Option<String> = None;
+ if let Some(s) = service {
+ uuid = Some(try!(BluetoothUUID::GetService(self.global().r(), s)).to_string())
+ };
+ let (sender, receiver) = ipc::channel().unwrap();
+ self.get_bluetooth_thread().send(
+ BluetoothMethodMsg::GetIncludedServices(self.get_instance_id(),
+ uuid,
+ sender)).unwrap();
+ let services_vec = receiver.recv().unwrap();
+ match services_vec {
+ Ok(service_vec) => {
+ Ok(service_vec.into_iter()
+ .map(|service| BluetoothRemoteGATTService::new(self.global().r(),
+ &self.device.get(),
+ DOMString::from(service.uuid),
+ service.is_primary,
+ service.instance_id))
+ .collect())
+ },
+ Err(error) => {
+ Err(Type(error))
+ },
+ }
+ }
}
diff --git a/components/script/dom/browsingcontext.rs b/components/script/dom/browsingcontext.rs
index c46afe71971..99c72e1e4be 100644
--- a/components/script/dom/browsingcontext.rs
+++ b/components/script/dom/browsingcontext.rs
@@ -164,25 +164,14 @@ impl BrowsingContext {
self.active_index.set(0);
self.history.borrow_mut().clear();
}
-}
-
-pub struct ContextIterator {
- stack: Vec<Root<BrowsingContext>>,
-}
-pub trait IterableContext {
- fn iter(&self) -> ContextIterator;
- fn find(&self, id: PipelineId) -> Option<Root<BrowsingContext>>;
-}
-
-impl IterableContext for BrowsingContext {
- fn iter(&self) -> ContextIterator {
+ pub fn iter(&self) -> ContextIterator {
ContextIterator {
stack: vec!(Root::from_ref(self)),
}
}
- fn find(&self, id: PipelineId) -> Option<Root<BrowsingContext>> {
+ pub fn find(&self, id: PipelineId) -> Option<Root<BrowsingContext>> {
if self.id == id {
return Some(Root::from_ref(self));
}
@@ -194,6 +183,10 @@ impl IterableContext for BrowsingContext {
}
}
+pub struct ContextIterator {
+ stack: Vec<Root<BrowsingContext>>,
+}
+
impl Iterator for ContextIterator {
type Item = Root<BrowsingContext>;
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index df9251f3888..dac16d72bcf 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -13,14 +13,13 @@ use dom::element::{Element, StylePriority};
use dom::node::{Node, NodeDamage, window_from_node};
use dom::window::Window;
use std::ascii::AsciiExt;
-use std::borrow::ToOwned;
use std::cell::Ref;
+use std::slice;
use string_cache::Atom;
use style::parser::ParserContextExtraData;
use style::properties::{PropertyDeclaration, Shorthand};
use style::properties::{is_supported_property, parse_one_declaration};
use style::selector_impl::PseudoElement;
-use util::str::str_join;
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
#[dom_struct]
@@ -50,29 +49,6 @@ macro_rules! css_properties(
);
);
-fn serialize_shorthand(shorthand: Shorthand, declarations: &[Ref<PropertyDeclaration>]) -> String {
- // https://drafts.csswg.org/css-variables/#variables-in-shorthands
- if let Some(css) = declarations[0].with_variables_from_shorthand(shorthand) {
- if declarations[1..]
- .iter()
- .all(|d| d.with_variables_from_shorthand(shorthand) == Some(css)) {
- css.to_owned()
- } else {
- String::new()
- }
- } else {
- if declarations.iter().any(|d| d.with_variables()) {
- String::new()
- } else {
- let str_iter = declarations.iter().map(|d| d.value());
- // FIXME: this needs property-specific code, which probably should be in style/
- // "as appropriate according to the grammar of shorthand "
- // https://drafts.csswg.org/cssom/#serialize-a-css-value
- str_join(str_iter, " ")
- }
- }
-}
-
impl CSSStyleDeclaration {
pub fn new_inherited(owner: &Element,
pseudo: Option<PseudoElement>,
@@ -172,7 +148,19 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// Step 2.3
- return DOMString::from(serialize_shorthand(shorthand, &list));
+ // Work around closures not being Clone
+ #[derive(Clone)]
+ struct Map<'a, 'b: 'a>(slice::Iter<'a, Ref<'b, PropertyDeclaration>>);
+ impl<'a, 'b> Iterator for Map<'a, 'b> {
+ type Item = &'a PropertyDeclaration;
+ fn next(&mut self) -> Option<Self::Item> {
+ self.0.next().map(|r| &**r)
+ }
+ }
+
+ // TODO: important is hardcoded to false because method does not implement it yet
+ let serialized_value = shorthand.serialize_shorthand_value_to_string(Map(list.iter()), false);
+ return DOMString::from(serialized_value);
}
// Step 3 & 4
@@ -255,10 +243,8 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
let element = self.owner.upcast::<Element>();
// Step 8
- for decl in declarations {
- // Step 9
- element.update_inline_style(decl, priority);
- }
+ // Step 9
+ element.update_inline_style(declarations, priority);
let node = element.upcast::<Node>();
node.dirty(NodeDamage::NodeStyleDamaged);
@@ -317,20 +303,20 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 3
let value = self.GetPropertyValue(property.clone());
- let elem = self.owner.upcast::<Element>();
+ let element = self.owner.upcast::<Element>();
match Shorthand::from_name(&property) {
// Step 4
Some(shorthand) => {
for longhand in shorthand.longhands() {
- elem.remove_inline_style_property(longhand)
+ element.remove_inline_style_property(longhand)
}
}
// Step 5
- None => elem.remove_inline_style_property(&property),
+ None => element.remove_inline_style_property(&property),
}
- let node = elem.upcast::<Node>();
+ let node = element.upcast::<Node>();
node.dirty(NodeDamage::NodeStyleDamaged);
// Step 6
diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs
index 8373855ac14..d02c57845ea 100644
--- a/components/script/dom/dedicatedworkerglobalscope.rs
+++ b/components/script/dom/dedicatedworkerglobalscope.rs
@@ -213,7 +213,8 @@ impl DedicatedWorkerGlobalScope {
worker_url: Url,
id: PipelineId,
from_devtools_receiver: IpcReceiver<DevtoolScriptControlMsg>,
- main_thread_rt: Arc<Mutex<Option<SharedRt>>>,
+ parent_rt: SharedRt,
+ worker_rt_for_mainthread: Arc<Mutex<Option<SharedRt>>>,
worker: TrustedWorkerAddress,
parent_sender: Box<ScriptChan + Send>,
own_sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>,
@@ -240,8 +241,8 @@ impl DedicatedWorkerGlobalScope {
}
};
- let runtime = unsafe { new_rt_and_cx() };
- *main_thread_rt.lock().unwrap() = Some(SharedRt::new(&runtime));
+ let runtime = unsafe { new_rt_and_cx(parent_rt.rt()) };
+ *worker_rt_for_mainthread.lock().unwrap() = Some(SharedRt::new(&runtime));
let (devtools_mpsc_chan, devtools_mpsc_port) = channel();
ROUTER.route_ipc_receiver_to_mpsc_sender(from_devtools_receiver, devtools_mpsc_chan);
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index d204bd0d8c6..89755564bb6 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -2,7 +2,6 @@
* 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 devtools_traits::CSSError;
use document_loader::{DocumentLoader, LoadType};
use dom::activation::{ActivationSource, synthetic_click_activation};
use dom::attr::{Attr, AttrValue};
@@ -107,8 +106,8 @@ use parse::{ParserRoot, ParserRef, MutNullableParserField};
use script_thread::{MainThreadScriptMsg, Runnable};
use script_traits::UntrustedNodeAddress;
use script_traits::{AnimationState, MouseButton, MouseEventType, MozBrowserEvent};
-use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg};
-use script_traits::{TouchpadPressurePhase, TouchEventType, TouchId};
+use script_traits::{ScriptMsg as ConstellationMsg, TouchpadPressurePhase};
+use script_traits::{TouchEventType, TouchId};
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::boxed::FnBox;
@@ -232,8 +231,6 @@ pub struct Document {
dom_complete: Cell<u64>,
load_event_start: Cell<u64>,
load_event_end: Cell<u64>,
- /// Vector to store CSS errors
- css_errors_store: DOMRefCell<Vec<CSSError>>,
/// https://html.spec.whatwg.org/multipage/#concept-document-https-state
https_state: Cell<HttpsState>,
touchpad_pressure_phase: Cell<TouchpadPressurePhase>,
@@ -332,10 +329,6 @@ impl Document {
self.trigger_mozbrowser_event(MozBrowserEvent::SecurityChange(https_state));
}
- pub fn report_css_error(&self, css_error: CSSError) {
- self.css_errors_store.borrow_mut().push(css_error);
- }
-
// https://html.spec.whatwg.org/multipage/#fully-active
pub fn is_fully_active(&self) -> bool {
let browsing_context = match self.browsing_context() {
@@ -643,10 +636,10 @@ impl Document {
/// Sends this document's title to the compositor.
pub fn send_title_to_compositor(&self) {
let window = self.window();
- let compositor = window.compositor();
- compositor.send(ScriptToCompositorMsg::SetTitle(window.pipeline(),
- Some(String::from(self.Title()))))
- .unwrap();
+ window.constellation_chan()
+ .send(ConstellationMsg::SetTitle(window.pipeline(),
+ Some(String::from(self.Title()))))
+ .unwrap();
}
pub fn dirty_all_nodes(&self) {
@@ -1056,7 +1049,7 @@ impl Document {
key: Key,
state: KeyState,
modifiers: KeyModifiers,
- compositor: &IpcSender<ScriptToCompositorMsg>) {
+ constellation: &IpcSender<ConstellationMsg>) {
let focused = self.get_focused_element();
let body = self.GetBody();
@@ -1131,7 +1124,7 @@ impl Document {
}
if !prevented {
- compositor.send(ScriptToCompositorMsg::SendKeyEvent(key, state, modifiers)).unwrap();
+ constellation.send(ConstellationMsg::SendKeyEvent(key, state, modifiers)).unwrap();
}
// This behavior is unspecced
@@ -1705,7 +1698,6 @@ impl Document {
dom_complete: Cell::new(Default::default()),
load_event_start: Cell::new(Default::default()),
load_event_end: Cell::new(Default::default()),
- css_errors_store: DOMRefCell::new(vec![]),
https_state: Cell::new(HttpsState::None),
touchpad_pressure_phase: Cell::new(TouchpadPressurePhase::BeforeClick),
origin: origin,
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index f5832089202..cf40c038c81 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -5,7 +5,7 @@
//! Element nodes.
use app_units::Au;
-use cssparser::Color;
+use cssparser::{Color, ToCss};
use devtools_traits::AttrInfo;
use dom::activation::Activatable;
use dom::attr::AttrValue;
@@ -698,89 +698,145 @@ impl Element {
}
}
+ // this sync method is called upon modification of the style_attribute property,
+ // therefore, it should not trigger subsequent mutation events
+ fn sync_property_with_attrs_style(&self) {
+ let style_str = if let &Some(ref declarations) = &*self.style_attribute().borrow() {
+ declarations.to_css_string()
+ } else {
+ String::new()
+ };
+
+ let mut new_style = AttrValue::String(style_str);
+
+ if let Some(style_attr) = self.attrs.borrow().iter().find(|a| a.name() == &atom!("style")) {
+ style_attr.swap_value(&mut new_style);
+ return;
+ }
+
+ // explicitly not calling the push_new_attribute convenience method
+ // in order to avoid triggering mutation events
+ let window = window_from_node(self);
+ let attr = Attr::new(&window,
+ atom!("style"),
+ new_style,
+ atom!("style"),
+ ns!(),
+ Some(atom!("style")),
+ Some(self));
+
+ assert!(attr.GetOwnerElement().r() == Some(self));
+ self.attrs.borrow_mut().push(JS::from_ref(&attr));
+ }
+
pub fn remove_inline_style_property(&self, property: &str) {
- let mut inline_declarations = self.style_attribute.borrow_mut();
- if let &mut Some(ref mut declarations) = &mut *inline_declarations {
- let index = declarations.normal
- .iter()
- .position(|decl| decl.matches(property));
- if let Some(index) = index {
- Arc::make_mut(&mut declarations.normal).remove(index);
- return;
- }
+ fn remove(element: &Element, property: &str) {
+ let mut inline_declarations = element.style_attribute.borrow_mut();
+ if let &mut Some(ref mut declarations) = &mut *inline_declarations {
+ let index = declarations.normal
+ .iter()
+ .position(|decl| decl.matches(property));
+ if let Some(index) = index {
+ Arc::make_mut(&mut declarations.normal).remove(index);
+ return;
+ }
- let index = declarations.important
- .iter()
- .position(|decl| decl.matches(property));
- if let Some(index) = index {
- Arc::make_mut(&mut declarations.important).remove(index);
- return;
+ let index = declarations.important
+ .iter()
+ .position(|decl| decl.matches(property));
+ if let Some(index) = index {
+ Arc::make_mut(&mut declarations.important).remove(index);
+ return;
+ }
}
}
+
+ remove(self, property);
+ self.sync_property_with_attrs_style();
}
pub fn update_inline_style(&self,
- property_decl: PropertyDeclaration,
+ declarations: Vec<PropertyDeclaration>,
style_priority: StylePriority) {
- let mut inline_declarations = self.style_attribute().borrow_mut();
- if let &mut Some(ref mut declarations) = &mut *inline_declarations {
- let existing_declarations = if style_priority == StylePriority::Important {
- &mut declarations.important
- } else {
- &mut declarations.normal
- };
- // Usually, the reference count will be 1 here. But transitions could make it greater
- // than that.
- let existing_declarations = Arc::make_mut(existing_declarations);
- for declaration in &mut *existing_declarations {
- if declaration.name() == property_decl.name() {
- *declaration = property_decl;
- return;
+ fn update(element: &Element, mut declarations: Vec<PropertyDeclaration>, style_priority: StylePriority) {
+ let mut inline_declarations = element.style_attribute().borrow_mut();
+ if let &mut Some(ref mut existing_declarations) = &mut *inline_declarations {
+ let existing_declarations = if style_priority == StylePriority::Important {
+ &mut existing_declarations.important
+ } else {
+ &mut existing_declarations.normal
+ };
+
+ // Usually, the reference count will be 1 here. But transitions could make it greater
+ // than that.
+ let existing_declarations = Arc::make_mut(existing_declarations);
+
+ while let Some(mut incoming_declaration) = declarations.pop() {
+ let mut replaced = false;
+ for existing_declaration in &mut *existing_declarations {
+ if existing_declaration.name() == incoming_declaration.name() {
+ mem::swap(existing_declaration, &mut incoming_declaration);
+ replaced = true;
+ break;
+ }
+ }
+
+ if !replaced {
+ // inserting instead of pushing since the declarations are in reverse order
+ existing_declarations.insert(0, incoming_declaration);
+ }
}
+
+ return;
}
- existing_declarations.push(property_decl);
- return;
- }
- let (important, normal) = if style_priority == StylePriority::Important {
- (vec![property_decl], vec![])
- } else {
- (vec![], vec![property_decl])
- };
+ let (important, normal) = if style_priority == StylePriority::Important {
+ (declarations, vec![])
+ } else {
+ (vec![], declarations)
+ };
- *inline_declarations = Some(PropertyDeclarationBlock {
- important: Arc::new(important),
- normal: Arc::new(normal),
- });
+ *inline_declarations = Some(PropertyDeclarationBlock {
+ important: Arc::new(important),
+ normal: Arc::new(normal),
+ });
+ }
+
+ update(self, declarations, style_priority);
+ self.sync_property_with_attrs_style();
}
pub fn set_inline_style_property_priority(&self,
properties: &[&str],
style_priority: StylePriority) {
- let mut inline_declarations = self.style_attribute().borrow_mut();
- if let &mut Some(ref mut declarations) = &mut *inline_declarations {
- let (from, to) = if style_priority == StylePriority::Important {
- (&mut declarations.normal, &mut declarations.important)
- } else {
- (&mut declarations.important, &mut declarations.normal)
- };
-
- // Usually, the reference counts of `from` and `to` will be 1 here. But transitions
- // could make them greater than that.
- let from = Arc::make_mut(from);
- let to = Arc::make_mut(to);
- let mut new_from = Vec::new();
- for declaration in from.drain(..) {
- let name = declaration.name();
- if properties.iter().any(|p| name == **p) {
- to.push(declaration)
- } else {
- new_from.push(declaration)
- }
+ {
+ let mut inline_declarations = self.style_attribute().borrow_mut();
+ if let &mut Some(ref mut declarations) = &mut *inline_declarations {
+ let (from, to) = if style_priority == StylePriority::Important {
+ (&mut declarations.normal, &mut declarations.important)
+ } else {
+ (&mut declarations.important, &mut declarations.normal)
+ };
+
+ // Usually, the reference counts of `from` and `to` will be 1 here. But transitions
+ // could make them greater than that.
+ let from = Arc::make_mut(from);
+ let to = Arc::make_mut(to);
+ let mut new_from = Vec::new();
+ for declaration in from.drain(..) {
+ let name = declaration.name();
+ if properties.iter().any(|p| name == **p) {
+ to.push(declaration)
+ } else {
+ new_from.push(declaration)
+ }
+ }
+ mem::replace(from, new_from);
}
- mem::replace(from, new_from);
}
+
+ self.sync_property_with_attrs_style();
}
pub fn get_inline_style_declaration(&self,
diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs
index 62e1b0a95bd..f566b4426b4 100644
--- a/components/script/dom/file.rs
+++ b/components/script/dom/file.rs
@@ -51,8 +51,6 @@ impl File {
pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root<File> {
let name = DOMString::from(selected.filename.to_str().expect("File name encoding error"));
- // FIXME: fix this after PR #11221 is landed
- let id = selected.id;
let slice = DataSlice::empty();
let global = GlobalRef::Window(window);
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 8cec0aa6659..3913d46b884 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -34,7 +34,7 @@ use ipc_channel::ipc;
use js::jsapi::{JSAutoCompartment, RootedValue, JSContext, MutableHandleValue};
use js::jsval::{UndefinedValue, NullValue};
use layout_interface::ReflowQueryType;
-use msg::constellation_msg::{LoadData, NavigationDirection, PipelineId, SubpageId};
+use msg::constellation_msg::{FrameType, LoadData, NavigationDirection, PipelineId, SubpageId};
use net_traits::response::HttpsState;
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use script_traits::{IFrameLoadInfo, MozBrowserEvent, ScriptMsg as ConstellationMsg};
@@ -123,6 +123,7 @@ impl HTMLIFrameElement {
let (new_subpage_id, old_subpage_id) = self.generate_new_subpage_id();
let new_pipeline_id = self.pipeline_id.get().unwrap();
let private_iframe = self.privatebrowsing();
+ let frame_type = if self.Mozbrowser() { FrameType::MozBrowserIFrame } else { FrameType::IFrame };
let load_info = IFrameLoadInfo {
load_data: load_data,
@@ -132,6 +133,7 @@ impl HTMLIFrameElement {
new_pipeline_id: new_pipeline_id,
sandbox: sandboxed,
is_private: private_iframe,
+ frame_type: frame_type,
};
window.constellation_chan()
.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info))
diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs
index fa6b3f91a42..001fd19df3b 100644
--- a/components/script/dom/storage.rs
+++ b/components/script/dom/storage.rs
@@ -11,7 +11,6 @@ use dom::bindings::js::Root;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
-use dom::browsingcontext::IterableContext;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::storageevent::StorageEvent;
use dom::urlhelper::UrlHelper;
diff --git a/components/script/dom/webidls/BluetoothRemoteGATTService.webidl b/components/script/dom/webidls/BluetoothRemoteGATTService.webidl
index 3a41865de1e..e137ec727cd 100644
--- a/components/script/dom/webidls/BluetoothRemoteGATTService.webidl
+++ b/components/script/dom/webidls/BluetoothRemoteGATTService.webidl
@@ -17,6 +17,10 @@ interface BluetoothRemoteGATTService {
//Promise<BluetoothRemoteGATTCharacteristic>getCharacteristic(BluetoothCharacteristicUUID characteristic);
//Promise<sequence<BluetoothRemoteGATTCharacteristic>>
//getCharacteristics(optional BluetoothCharacteristicUUID characteristic);
+ [Throws]
+ BluetoothRemoteGATTService getIncludedService(BluetoothServiceUUID service);
+ [Throws]
+ sequence<BluetoothRemoteGATTService> getIncludedServices(optional BluetoothServiceUUID service);
//Promise<BluetoothRemoteGATTService>getIncludedService(BluetoothServiceUUID service);
//Promise<sequence<BluetoothRemoteGATTService>>getIncludedServices(optional BluetoothServiceUUID service);
};
diff --git a/components/script/dom/webidls/Window.webidl b/components/script/dom/webidls/Window.webidl
index 8f3cbedcc8e..608f066ff11 100644
--- a/components/script/dom/webidls/Window.webidl
+++ b/components/script/dom/webidls/Window.webidl
@@ -48,8 +48,8 @@
//readonly attribute ApplicationCache applicationCache;
// user prompts
- //void alert();
void alert(DOMString message);
+ void alert();
//boolean confirm(optional DOMString message = "");
//DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
//void print();
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index e5af0ebbf26..540266b6491 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -62,7 +62,7 @@ use script_runtime::{ScriptChan, ScriptPort};
use script_thread::SendableMainThreadScriptChan;
use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
use script_traits::{ConstellationControlMsg, UntrustedNodeAddress};
-use script_traits::{DocumentState, MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId};
+use script_traits::{DocumentState, MsDuration, TimerEvent, TimerEventId};
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource};
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
@@ -153,8 +153,6 @@ pub struct Window {
image_cache_chan: ImageCacheChan,
#[ignore_heap_size_of = "channels are hard"]
custom_message_chan: IpcSender<CustomResponseSender>,
- #[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"]
- compositor: IpcSender<ScriptToCompositorMsg>,
browsing_context: MutNullableHeap<JS<BrowsingContext>>,
performance: MutNullableHeap<JS<Performance>>,
navigation_start: u64,
@@ -340,10 +338,6 @@ impl Window {
&self.image_cache_thread
}
- pub fn compositor(&self) -> &IpcSender<ScriptToCompositorMsg> {
- &self.compositor
- }
-
pub fn browsing_context(&self) -> Root<BrowsingContext> {
self.browsing_context.get().unwrap()
}
@@ -437,6 +431,11 @@ pub fn base64_atob(input: DOMString) -> Fallible<DOMString> {
impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#dom-alert
+ fn Alert_(&self) {
+ self.Alert(DOMString::new());
+ }
+
+ // https://html.spec.whatwg.org/multipage/#dom-alert
fn Alert(&self, s: DOMString) {
// Right now, just print to the console
// Ensure that stderr doesn't trample through the alert() we use to
@@ -775,7 +774,7 @@ impl WindowMethods for Window {
// Step 1
//TODO determine if this operation is allowed
let size = Size2D::new(x.to_u32().unwrap_or(1), y.to_u32().unwrap_or(1));
- self.compositor.send(ScriptToCompositorMsg::ResizeTo(size)).unwrap()
+ self.constellation_chan.send(ConstellationMsg::ResizeTo(size)).unwrap()
}
// https://drafts.csswg.org/cssom-view/#dom-window-resizeby
@@ -790,7 +789,7 @@ impl WindowMethods for Window {
// Step 1
//TODO determine if this operation is allowed
let point = Point2D::new(x, y);
- self.compositor.send(ScriptToCompositorMsg::MoveTo(point)).unwrap()
+ self.constellation_chan.send(ConstellationMsg::MoveTo(point)).unwrap()
}
// https://drafts.csswg.org/cssom-view/#dom-window-moveby
@@ -976,13 +975,13 @@ impl Window {
let size = self.current_viewport.get().size;
self.current_viewport.set(Rect::new(Point2D::new(Au::from_f32_px(x), Au::from_f32_px(y)), size));
- self.compositor.send(ScriptToCompositorMsg::ScrollFragmentPoint(
- self.pipeline(), layer_id, point, smooth)).unwrap()
+ let message = ConstellationMsg::ScrollFragmentPoint(self.pipeline(), layer_id, point, smooth);
+ self.constellation_chan.send(message).unwrap();
}
pub fn client_window(&self) -> (Size2D<u32>, Point2D<i32>) {
let (send, recv) = ipc::channel::<(Size2D<u32>, Point2D<i32>)>().unwrap();
- self.compositor.send(ScriptToCompositorMsg::GetClientWindow(send)).unwrap();
+ self.constellation_chan.send(ConstellationMsg::GetClientWindow(send)).unwrap();
recv.recv().unwrap_or((Size2D::zero(), Point2D::zero()))
}
@@ -1180,7 +1179,7 @@ impl Window {
let pipeline_id = self.id;
let (send, recv) = ipc::channel::<Point2D<f32>>().unwrap();
- self.compositor.send(ScriptToCompositorMsg::GetScrollOffset(pipeline_id, layer_id, send)).unwrap();
+ self.constellation_chan.send(ConstellationMsg::GetScrollOffset(pipeline_id, layer_id, send)).unwrap();
recv.recv().unwrap_or(Point2D::zero())
}
@@ -1450,7 +1449,6 @@ impl Window {
file_task_source: FileReadingTaskSource,
image_cache_chan: ImageCacheChan,
custom_message_chan: IpcSender<CustomResponseSender>,
- compositor: IpcSender<ScriptToCompositorMsg>,
image_cache_thread: ImageCacheThread,
resource_threads: ResourceThreads,
bluetooth_thread: IpcSender<BluetoothMethodMsg>,
@@ -1490,7 +1488,6 @@ impl Window {
custom_message_chan: custom_message_chan,
console: Default::default(),
crypto: Default::default(),
- compositor: compositor,
navigator: Default::default(),
image_cache_thread: image_cache_thread,
mem_profiler_chan: mem_profiler_chan,
diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs
index e969328a210..0a18125f1bc 100644
--- a/components/script/dom/worker.rs
+++ b/components/script/dom/worker.rs
@@ -22,7 +22,7 @@ use dom::messageevent::MessageEvent;
use dom::workerglobalscope::WorkerGlobalScopeInit;
use ipc_channel::ipc;
use js::jsapi::{HandleValue, JSContext, JSRuntime, RootedValue};
-use js::jsapi::{JSAutoCompartment, JS_RequestInterruptCallback};
+use js::jsapi::{JSAutoCompartment, JS_GetRuntime, JS_RequestInterruptCallback};
use js::jsval::UndefinedValue;
use js::rust::Runtime;
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
@@ -91,6 +91,7 @@ impl Worker {
}
// https://html.spec.whatwg.org/multipage/#dom-worker
+ #[allow(unsafe_code)]
pub fn Constructor(global: GlobalRef, script_url: DOMString) -> Fallible<Root<Worker>> {
// Step 2-4.
let worker_url = match global.api_base_url().join(&script_url) {
@@ -145,8 +146,10 @@ impl Worker {
closing: closing,
};
+ let shared_rt = SharedRt { rt: unsafe { JS_GetRuntime(global.get_cx()) } };
+
DedicatedWorkerGlobalScope::run_worker_scope(
- init, worker_url, global.pipeline(), devtools_receiver, worker.runtime.clone(), worker_ref,
+ init, worker_url, global.pipeline(), devtools_receiver, shared_rt, worker.runtime.clone(), worker_ref,
global.script_chan(), sender, receiver, worker_load_origin);
Ok(worker)
@@ -309,6 +312,10 @@ impl SharedRt {
JS_RequestInterruptCallback(self.rt);
}
}
+
+ pub fn rt(&self) -> *mut JSRuntime {
+ self.rt
+ }
}
#[allow(unsafe_code)]