diff options
Diffstat (limited to 'components/script/dom')
38 files changed, 178 insertions, 106 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 8a4913bfe20..f33a8834a08 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -83,7 +83,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::sync::mpsc::{Receiver, Sender}; use std::time::SystemTime; use string_cache::{Atom, Namespace, QualName}; -use style::attr::{AttrIdentifier, AttrValue}; +use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto}; use style::element_state::*; use style::properties::PropertyDeclarationBlock; use style::restyle_hints::ElementSnapshot; @@ -91,7 +91,6 @@ use style::selector_impl::PseudoElement; use style::values::specified::Length; use url::Origin as UrlOrigin; use url::Url; -use util::str::LengthOrPercentageOrAuto; use uuid::Uuid; use webrender_traits::WebGLError; diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 9272c7f6da1..0897ccc24ae 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -577,7 +577,7 @@ impl Document { } /// Return the element that currently has focus. - // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-focusevent-doc-focus + // https://w3c.github.io/uievents/#events-focusevent-doc-focus pub fn get_focused_element(&self) -> Option<Root<Element>> { self.focused.get() } @@ -706,7 +706,7 @@ impl Document { self.begin_focus_transaction(); } - // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-click + // https://w3c.github.io/uievents/#event-type-click let client_x = client_point.x as i32; let client_y = client_point.y as i32; let clickCount = 1; @@ -728,7 +728,7 @@ impl Document { None); let event = event.upcast::<Event>(); - // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#trusted-events + // https://w3c.github.io/uievents/#trusted-events event.set_trusted(true); // https://html.spec.whatwg.org/multipage/#run-authentic-click-activation-steps match mouse_event_type { @@ -1093,9 +1093,9 @@ impl Document { event.fire(target); let mut prevented = event.DefaultPrevented(); - // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keys-cancelable-keys + // https://w3c.github.io/uievents/#keys-cancelable-keys if state != KeyState::Released && props.is_printable() && !prevented { - // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keypress-event-order + // https://w3c.github.io/uievents/#keypress-event-order let event = KeyboardEvent::new(&self.window, DOMString::from("keypress"), true, diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index dabf3bf4cb9..1fb53e6ce06 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -70,15 +70,14 @@ impl DOMTokenListMethods for DOMTokenList { } // https://dom.spec.whatwg.org/#dom-domtokenlist-contains - fn Contains(&self, token: DOMString) -> Fallible<bool> { - self.check_token_exceptions(&token).map(|token| { - self.attribute().map_or(false, |attr| { - let attr = attr.r(); - attr.value() - .as_tokens() - .iter() - .any(|atom: &Atom| *atom == token) - }) + fn Contains(&self, token: DOMString) -> bool { + let token = Atom::from(token); + self.attribute().map_or(false, |attr| { + let attr = attr.r(); + attr.value() + .as_tokens() + .iter() + .any(|atom: &Atom| *atom == token) }) } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index bb97931a9d9..0432be3987c 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -85,6 +85,7 @@ use std::mem; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace, QualName}; +use style::attr::LengthOrPercentageOrAuto; use style::element_state::*; use style::parser::ParserContextExtraData; use style::properties::DeclaredValue; @@ -93,7 +94,6 @@ use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_sty use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl}; use style::values::CSSFloat; use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage}; -use util::str::LengthOrPercentageOrAuto; // TODO: Update focus state when the top-level browsing context gains or loses system focus, // and when the element enters or leaves a browsing context container. @@ -130,7 +130,6 @@ impl Element { create_element(name, prefix, document, creator) } - pub fn new_inherited(local_name: Atom, namespace: Namespace, prefix: Option<DOMString>, document: &Document) -> Element { @@ -2223,7 +2222,8 @@ impl<'a> ::selectors::Element for Root<Element> { NonTSPseudoClass::Disabled | NonTSPseudoClass::Checked | NonTSPseudoClass::Indeterminate | - NonTSPseudoClass::ReadWrite => + NonTSPseudoClass::ReadWrite | + NonTSPseudoClass::PlaceholderShown => Element::state(self).contains(pseudo_class.state_flag()), } } @@ -2494,6 +2494,17 @@ impl Element { pub fn set_read_write_state(&self, value: bool) { self.set_state(IN_READ_WRITE_STATE, value) } + + pub fn placeholder_shown_state(&self) -> bool { + self.state.get().contains(IN_PLACEHOLDER_SHOWN_STATE) + } + + pub fn set_placeholder_shown_state(&self, value: bool) { + if self.placeholder_shown_state() != value { + self.set_state(IN_PLACEHOLDER_SHOWN_STATE, value); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); + } + } } impl Element { diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index c69e61cae80..4fb575dd1e2 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -64,7 +64,7 @@ impl HTMLAnchorElement { let attribute = self.upcast::<Element>().get_attribute(&ns!(), &atom!("href")); *self.url.borrow_mut() = attribute.and_then(|attribute| { let document = document_from_node(self); - document.url().join(&attribute.value()).ok() + document.base_url().join(&attribute.value()).ok() }); } diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index e15d559cee3..23b9b79cc5d 100644 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -266,14 +266,14 @@ impl Activatable for HTMLButtonElement { ButtonType::Submit => { // TODO: is document owner fully active? if let Some(owner) = self.form_owner() { - owner.submit(SubmittedFrom::NotFromFormSubmitMethod, + owner.submit(SubmittedFrom::NotFromForm, FormSubmitter::ButtonElement(self.clone())); } } ButtonType::Reset => { // TODO: is document owner fully active? if let Some(owner) = self.form_owner() { - owner.reset(ResetFrom::NotFromFormResetMethod); + owner.reset(ResetFrom::NotFromForm); } } _ => (), diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 30ab440b00e..66121a422bb 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -155,12 +155,12 @@ impl HTMLFormElementMethods for HTMLFormElement { // https://html.spec.whatwg.org/multipage/#the-form-element:concept-form-submit fn Submit(&self) { - self.submit(SubmittedFrom::FromFormSubmitMethod, FormSubmitter::FormElement(self)); + self.submit(SubmittedFrom::FromForm, FormSubmitter::FormElement(self)); } // https://html.spec.whatwg.org/multipage/#dom-form-reset fn Reset(&self) { - self.reset(ResetFrom::FromFormResetMethod); + self.reset(ResetFrom::FromForm); } // https://html.spec.whatwg.org/multipage/#dom-form-elements @@ -233,14 +233,14 @@ impl HTMLFormElementMethods for HTMLFormElement { #[derive(Copy, Clone, HeapSizeOf, PartialEq)] pub enum SubmittedFrom { - FromFormSubmitMethod, - NotFromFormSubmitMethod + FromForm, + NotFromForm } #[derive(Copy, Clone, HeapSizeOf)] pub enum ResetFrom { - FromFormResetMethod, - NotFromFormResetMethod + FromForm, + NotFromForm } @@ -368,7 +368,7 @@ impl HTMLFormElement { let base = doc.url(); // TODO: Handle browsing contexts // Step 4 - if submit_method_flag == SubmittedFrom::NotFromFormSubmitMethod && + if submit_method_flag == SubmittedFrom::NotFromForm && !submitter.no_validate(self) { if self.interactive_validation().is_err() { @@ -378,7 +378,7 @@ impl HTMLFormElement { } } // Step 5 - if submit_method_flag == SubmittedFrom::NotFromFormSubmitMethod { + if submit_method_flag == SubmittedFrom::NotFromForm { let event = self.upcast::<EventTarget>() .fire_event("submit", EventBubbles::Bubbles, diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index 7259814fdd9..1041319f907 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; -use util::str::LengthOrPercentageOrAuto; +use style::attr::LengthOrPercentageOrAuto; #[dom_struct] pub struct HTMLHRElement { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 4c5fb336c69..bc37f526f88 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -42,10 +42,10 @@ use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed}; use script_traits::{IFrameLoadInfo, MozBrowserEvent, ScriptMsg as ConstellationMsg}; use std::cell::Cell; use string_cache::Atom; +use style::attr::LengthOrPercentageOrAuto; use style::context::ReflowGoal; use url::Url; use util::prefs::mozbrowser_enabled; -use util::str::LengthOrPercentageOrAuto; #[derive(HeapSizeOf)] enum SandboxAllowance { diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 8bd29e7678f..49f771824d3 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -31,8 +31,8 @@ use script_runtime::ScriptThreadEventCategory::UpdateReplacedElement; use script_thread::Runnable; use std::sync::Arc; use string_cache::Atom; +use style::attr::LengthOrPercentageOrAuto; use url::Url; -use util::str::LengthOrPercentageOrAuto; #[derive(JSTraceable, HeapSizeOf)] #[allow(dead_code)] diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index c9efb81ea7e..a7bb9846bb9 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -709,6 +709,17 @@ impl HTMLInputElement { self.value_changed.set(false); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } + + fn update_placeholder_shown_state(&self) { + match self.input_type.get() { + InputType::InputText | InputType::InputPassword => {}, + _ => return, + } + let has_placeholder = !self.placeholder.borrow().is_empty(); + let has_value = !self.textinput.borrow().is_empty(); + let el = self.upcast::<Element>(); + el.set_placeholder_shown_state(has_placeholder && !has_value); + } } impl VirtualMethods for HTMLInputElement { @@ -757,6 +768,7 @@ impl VirtualMethods for HTMLInputElement { self.size.set(size.unwrap_or(DEFAULT_INPUT_SIZE)); } &atom!("type") => { + let el = self.upcast::<Element>(); match mutation { AttributeMutation::Set(_) => { let new_type = match attr.value().as_atom() { @@ -774,7 +786,6 @@ impl VirtualMethods for HTMLInputElement { let (old_value_mode, old_idl_value) = (self.value_mode(), self.Value()); self.input_type.set(new_type); - let el = self.upcast::<Element>(); if new_type == InputType::InputText { let read_write = !(self.ReadOnly() || el.disabled_state()); el.set_read_write_state(read_write); @@ -831,11 +842,14 @@ impl VirtualMethods for HTMLInputElement { el.set_read_write_state(read_write); } } + + self.update_placeholder_shown_state(); }, &atom!("value") if !self.value_changed.get() => { let value = mutation.new_value(attr).map(|value| (**value).to_owned()); self.textinput.borrow_mut().set_content( value.map_or(DOMString::new(), DOMString::from)); + self.update_placeholder_shown_state(); }, &atom!("name") if self.input_type.get() == InputType::InputRadio => { self.radio_group_updated( @@ -854,13 +868,15 @@ impl VirtualMethods for HTMLInputElement { } } &atom!("placeholder") => { - // FIXME(ajeffrey): Should we do in-place mutation of the placeholder? - let mut placeholder = self.placeholder.borrow_mut(); - placeholder.clear(); - if let AttributeMutation::Set(_) = mutation { - placeholder.extend( - attr.value().chars().filter(|&c| c != '\n' && c != '\r')); + { + let mut placeholder = self.placeholder.borrow_mut(); + placeholder.clear(); + if let AttributeMutation::Set(_) = mutation { + placeholder.extend( + attr.value().chars().filter(|&c| c != '\n' && c != '\r')); + } } + self.update_placeholder_shown_state(); }, &atom!("readonly") if self.input_type.get() == InputType::InputText => { let el = self.upcast::<Element>(); @@ -936,6 +952,7 @@ impl VirtualMethods for HTMLInputElement { }, DispatchInput => { self.value_changed.set(true); + self.update_placeholder_shown_state(); if event.IsTrusted() { let window = window_from_node(self); @@ -1091,7 +1108,7 @@ impl Activatable for HTMLInputElement { // FIXME (Manishearth): support document owners (needs ability to get parent browsing context) // Check if document owner is fully active self.form_owner().map(|o| { - o.submit(SubmittedFrom::NotFromFormSubmitMethod, + o.submit(SubmittedFrom::NotFromForm, FormSubmitter::InputElement(self.clone())) }); }, @@ -1100,7 +1117,7 @@ impl Activatable for HTMLInputElement { // FIXME (Manishearth): support document owners (needs ability to get parent browsing context) // Check if document owner is fully active self.form_owner().map(|o| { - o.reset(ResetFrom::NotFromFormResetMethod) + o.reset(ResetFrom::NotFromForm) }); }, InputType::InputCheckbox | InputType::InputRadio => { @@ -1204,7 +1221,7 @@ impl Activatable for HTMLInputElement { // lazily test for > 1 submission-blocking inputs return; } - form.submit(SubmittedFrom::NotFromFormSubmitMethod, + form.submit(SubmittedFrom::NotFromForm, FormSubmitter::FormElement(form.r())); } } diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index f640ea796d2..1f9f49516dd 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -532,8 +532,8 @@ impl HTMLScriptElement { is_js } - pub fn mark_already_started(&self) { - self.already_started.set(true); + pub fn set_already_started(&self, already_started: bool) { + self.already_started.set(already_started); } fn dispatch_event(&self, @@ -593,7 +593,7 @@ impl VirtualMethods for HTMLScriptElement { // https://html.spec.whatwg.org/multipage/#already-started if self.already_started.get() { - copy.downcast::<HTMLScriptElement>().unwrap().mark_already_started(); + copy.downcast::<HTMLScriptElement>().unwrap().set_already_started(true); } } } diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 036771e178a..ae54b915342 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -16,7 +16,7 @@ use dom::htmltablerowelement::HTMLTableRowElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; -use util::str::LengthOrPercentageOrAuto; +use style::attr::LengthOrPercentageOrAuto; const DEFAULT_COLSPAN: u32 = 1; diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index 26a373a3630..a86381967b4 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -24,8 +24,7 @@ use dom::node::{Node, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use std::cell::Cell; use string_cache::Atom; -use style::attr::parse_unsigned_integer; -use util::str::LengthOrPercentageOrAuto; +use style::attr::{LengthOrPercentageOrAuto, parse_unsigned_integer}; #[dom_struct] pub struct HTMLTableElement { diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index e5616257863..4cfa1a61011 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -647,7 +647,7 @@ fn key_location(key: Key) -> u32 { } } -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-KeyboardEvent-charCode +// https://w3c.github.io/uievents/#dom-keyboardevent-charcode fn key_charcode(key: Key, mods: KeyModifiers) -> Option<u32> { let key_string = key_value(key, mods); if key_string.len() == 1 { @@ -657,10 +657,10 @@ fn key_charcode(key: Key, mods: KeyModifiers) -> Option<u32> { } } -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#legacy-key-models +// https://w3c.github.io/uievents/#legacy-key-models fn key_keycode(key: Key) -> u32 { match key { - // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#legacy-key-models + // https://w3c.github.io/uievents/#legacy-key-models Key::Backspace => 8, Key::Tab => 9, Key::Enter => 13, @@ -680,7 +680,7 @@ fn key_keycode(key: Key) -> u32 { Key::Down => 40, Key::Delete => 46, - // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#optionally-fixed-virtual-key-codes + // https://w3c.github.io/uievents/#optionally-fixed-virtual-key-codes Key::Semicolon => 186, Key::Equal => 187, Key::Comma => 188, @@ -820,7 +820,7 @@ impl KeyboardEventMethods for KeyboardEvent { self.is_composing.get() } - // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-KeyboardEvent-getModifierState + // https://w3c.github.io/uievents/#dom-keyboardevent-getmodifierstate fn GetModifierState(&self, keyArg: DOMString) -> bool { match &*keyArg { "Ctrl" => self.CtrlKey(), diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 93e2d4606bc..bde5515238b 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -22,6 +22,9 @@ use dom::bindings::weakref::{WeakRef, WeakRefVec}; use dom::characterdata::CharacterData; use dom::document::Document; use dom::documentfragment::DocumentFragment; +use dom::element::Element; +use dom::htmlbodyelement::HTMLBodyElement; +use dom::htmlscriptelement::HTMLScriptElement; use dom::node::{Node, UnbindContext}; use dom::text::Text; use heapsize::HeapSizeOf; @@ -893,6 +896,44 @@ impl RangeMethods for Range { // Step 6. s } + + // https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-range-interface + fn CreateContextualFragment(&self, fragment: DOMString) -> Fallible<Root<DocumentFragment>> { + // Step 1. + let node = self.StartContainer(); + let element = match node.type_id() { + NodeTypeId::Document(_) | NodeTypeId::DocumentFragment => None, + NodeTypeId::Element(_) => Some(node), + NodeTypeId::CharacterData(CharacterDataTypeId::Comment) | + NodeTypeId::CharacterData(CharacterDataTypeId::Text) => node.GetParentNode(), + NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) | + NodeTypeId::DocumentType => unreachable!(), + }; + + // Step 2. + let should_create_body = element.as_ref().map_or(true, |elem| { + let elem = elem.downcast::<Element>().unwrap(); + elem.local_name() == &atom!("html") && elem.html_element_in_html_document() + }); + let element: Root<Node> = if should_create_body { + Root::upcast(HTMLBodyElement::new(atom!("body"), None, &self.StartContainer().owner_doc())) + } else { + Root::upcast(element.unwrap()) + }; + + // Step 3. + let fragment_node = try!(element.parse_fragment(fragment)); + + // Step 4. + for node in fragment_node.upcast::<Node>().traverse_preorder() { + if let Some(script) = node.downcast::<HTMLScriptElement>() { + script.set_already_started(false); + } + } + + // Step 5. + Ok(fragment_node) + } } #[derive(JSTraceable)] diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs index 5b0a6f3243e..16461315ca1 100644 --- a/components/script/dom/uievent.rs +++ b/components/script/dom/uievent.rs @@ -18,7 +18,7 @@ use std::cell::Cell; use std::default::Default; use string_cache::Atom; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#interface-UIEvent +// https://w3c.github.io/uievents/#interface-uievent #[dom_struct] pub struct UIEvent { event: Event, diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 1553e8b5b0a..8ecffe60b33 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -13,6 +13,7 @@ use dom::urlhelper::UrlHelper; use dom::urlsearchparams::URLSearchParams; use std::borrow::ToOwned; use std::default::Default; +use url::quirks::domain_to_unicode; use url::{Host, Url}; // https://url.spec.whatwg.org/#url @@ -100,6 +101,10 @@ impl URL { USVString("".to_owned()) } } + + pub fn DomainToUnicode(_: GlobalRef, origin: USVString) -> USVString { + USVString(domain_to_unicode(&origin.0)) + } } impl URLMethods for URL { diff --git a/components/script/dom/webidls/DOMTokenList.webidl b/components/script/dom/webidls/DOMTokenList.webidl index 1b50c34c918..2b7da5dea74 100644 --- a/components/script/dom/webidls/DOMTokenList.webidl +++ b/components/script/dom/webidls/DOMTokenList.webidl @@ -9,7 +9,7 @@ interface DOMTokenList { [Pure] getter DOMString? item(unsigned long index); - [Pure, Throws] + [Pure] boolean contains(DOMString token); [Throws] void add(DOMString... tokens); diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index dd6ff9c924e..0e5c7b661a6 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -14,9 +14,9 @@ interface Document : Node { readonly attribute DOMImplementation implementation; [Constant] readonly attribute USVString URL; - readonly attribute Element? activeElement; [Constant] readonly attribute USVString documentURI; + // readonly attribute USVString origin; readonly attribute DOMString compatMode; readonly attribute DOMString characterSet; readonly attribute DOMString charset; // legacy alias of .characterSet @@ -53,7 +53,7 @@ interface Document : Node { [NewObject, Throws] Attr createAttribute(DOMString localName); [NewObject, Throws] - Attr createAttributeNS(DOMString? namespace, DOMString localName); + Attr createAttributeNS(DOMString? namespace, DOMString qualifiedName); [NewObject, Throws] Event createEvent(DOMString interface_); @@ -91,6 +91,7 @@ partial /*sealed*/ interface Document { // DOM tree accessors getter object (DOMString name); attribute DOMString title; + // attribute DOMString dir; [SetterThrows] attribute HTMLElement? body; readonly attribute HTMLHeadElement? head; @@ -107,9 +108,6 @@ partial /*sealed*/ interface Document { [SameObject] readonly attribute HTMLCollection scripts; NodeList getElementsByName(DOMString elementName); - // NodeList getItems(optional DOMString typeNames = ""); // microdata - // [SameObject] - // readonly attribute DOMElementMap cssElementMap; readonly attribute HTMLScriptElement? currentScript; // dynamic markup insertion @@ -121,7 +119,7 @@ partial /*sealed*/ interface Document { // user interaction readonly attribute Window/*Proxy?*/ defaultView; - // readonly attribute Element? activeElement; + readonly attribute Element? activeElement; boolean hasFocus(); // attribute DOMString designMode; // boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = ""); @@ -130,7 +128,6 @@ partial /*sealed*/ interface Document { // boolean queryCommandState(DOMString commandId); // boolean queryCommandSupported(DOMString commandId); // DOMString queryCommandValue(DOMString commandId); - // readonly attribute HTMLCollection commands; // special event handler IDL attributes that only apply to Document objects [LenientThis] attribute EventHandler onreadystatechange; diff --git a/components/script/dom/webidls/Element.webidl b/components/script/dom/webidls/Element.webidl index bec84acc8ce..ee27b78d4e4 100644 --- a/components/script/dom/webidls/Element.webidl +++ b/components/script/dom/webidls/Element.webidl @@ -30,49 +30,49 @@ interface Element : Node { [SameObject, PutForwards=value] readonly attribute DOMTokenList classList; + [Pure] + boolean hasAttributes(); [SameObject] readonly attribute NamedNodeMap attributes; [Pure] sequence<DOMString> getAttributeNames(); [Pure] - boolean hasAttributes(); - [Pure] DOMString? getAttribute(DOMString name); [Pure] DOMString? getAttributeNS(DOMString? namespace, DOMString localName); - [Pure] - Attr? getAttributeNode(DOMString name); - [Pure] - Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName); [Throws] void setAttribute(DOMString name, DOMString value); [Throws] void setAttributeNS(DOMString? namespace, DOMString name, DOMString value); void removeAttribute(DOMString name); void removeAttributeNS(DOMString? namespace, DOMString localName); - [Throws] - Attr removeAttributeNode(Attr oldAttr); boolean hasAttribute(DOMString name); boolean hasAttributeNS(DOMString? namespace, DOMString localName); + [Pure] + Attr? getAttributeNode(DOMString name); + [Pure] + Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName); [Throws] Attr? setAttributeNode(Attr attr); [Throws] Attr? setAttributeNodeNS(Attr attr); + [Throws] + Attr removeAttributeNode(Attr oldAttr); [Pure, Throws] Element? closest(DOMString selectors); - [Pure, Throws] boolean matches(DOMString selectors); [Pure, Throws] - boolean webkitMatchesSelector(DOMString selectors); + boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches HTMLCollection getElementsByTagName(DOMString localName); HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); HTMLCollection getElementsByClassName(DOMString classNames); + [Throws] - Element? insertAdjacentElement(DOMString where_, Element element); + Element? insertAdjacentElement(DOMString where_, Element element); // historical [Throws] void insertAdjacentText(DOMString where_, DOMString data); }; diff --git a/components/script/dom/webidls/HTMLAnchorElement.webidl b/components/script/dom/webidls/HTMLAnchorElement.webidl index ddfc155cc1f..f78d1dae6dd 100644 --- a/components/script/dom/webidls/HTMLAnchorElement.webidl +++ b/components/script/dom/webidls/HTMLAnchorElement.webidl @@ -14,7 +14,7 @@ interface HTMLAnchorElement : HTMLElement { attribute DOMString target; // attribute DOMString download; - //[PutForwards=value] attribute DOMSettableTokenList ping; + // attribute USVString ping; // attribute DOMString rel; readonly attribute DOMTokenList relList; // attribute DOMString hreflang; diff --git a/components/script/dom/webidls/HTMLAreaElement.webidl b/components/script/dom/webidls/HTMLAreaElement.webidl index 6f1a6891518..14883df3613 100644 --- a/components/script/dom/webidls/HTMLAreaElement.webidl +++ b/components/script/dom/webidls/HTMLAreaElement.webidl @@ -9,7 +9,7 @@ interface HTMLAreaElement : HTMLElement { // attribute DOMString shape; // attribute DOMString target; // attribute DOMString download; - //[PutForwards=value] attribute DOMSettableTokenList ping; + // attribute USVString ping; // attribute DOMString rel; readonly attribute DOMTokenList relList; // hreflang and type are not reflected diff --git a/components/script/dom/webidls/HTMLElement.webidl b/components/script/dom/webidls/HTMLElement.webidl index 19222109d63..188c0421154 100644 --- a/components/script/dom/webidls/HTMLElement.webidl +++ b/components/script/dom/webidls/HTMLElement.webidl @@ -13,10 +13,7 @@ interface HTMLElement : Element { // microdata // attribute boolean itemScope; - //[PutForwards=value] readonly attribute DOMSettableTokenList itemType; // attribute DOMString itemId; - //[PutForwards=value] readonly attribute DOMSettableTokenList itemRef; - //[PutForwards=value] readonly attribute DOMSettableTokenList itemProp; //readonly attribute HTMLPropertiesCollection properties; // attribute any itemValue; // acts as DOMString on setting @@ -29,7 +26,7 @@ interface HTMLElement : Element { // attribute DOMString accessKey; //readonly attribute DOMString accessKeyLabel; // attribute boolean draggable; - //[PutForwards=value] readonly attribute DOMSettableTokenList dropzone; + //[SameObject, PutForwards=value] readonly attribute DOMTokenList dropzone; // attribute HTMLMenuElement? contextMenu; // attribute boolean spellcheck; //void forceSpellCheck(); diff --git a/components/script/dom/webidls/HTMLIFrameElement.webidl b/components/script/dom/webidls/HTMLIFrameElement.webidl index 0d78b56fb98..65ccbe84048 100644 --- a/components/script/dom/webidls/HTMLIFrameElement.webidl +++ b/components/script/dom/webidls/HTMLIFrameElement.webidl @@ -7,7 +7,6 @@ interface HTMLIFrameElement : HTMLElement { attribute DOMString src; // attribute DOMString srcdoc; // attribute DOMString name; - //[PutForwards=value] readonly attribute DOMSettableTokenList sandbox; attribute DOMString sandbox; // attribute boolean seamless; // attribute boolean allowFullscreen; diff --git a/components/script/dom/webidls/HTMLLinkElement.webidl b/components/script/dom/webidls/HTMLLinkElement.webidl index 1bcf2e727f2..8c1bf496590 100644 --- a/components/script/dom/webidls/HTMLLinkElement.webidl +++ b/components/script/dom/webidls/HTMLLinkElement.webidl @@ -11,7 +11,7 @@ interface HTMLLinkElement : HTMLElement { attribute DOMString media; attribute DOMString hreflang; attribute DOMString type; - //[PutForwards=value] readonly attribute DOMSettableTokenList sizes; + // [SameObject, PutForwards=value] readonly attribute DOMTokenList sizes; // also has obsolete members }; diff --git a/components/script/dom/webidls/HTMLOutputElement.webidl b/components/script/dom/webidls/HTMLOutputElement.webidl index 9506d56df65..f0baeb8fa03 100644 --- a/components/script/dom/webidls/HTMLOutputElement.webidl +++ b/components/script/dom/webidls/HTMLOutputElement.webidl @@ -4,7 +4,7 @@ // https://html.spec.whatwg.org/multipage/#htmloutputelement interface HTMLOutputElement : HTMLElement { - //[PutForwards=value] readonly attribute DOMSettableTokenList htmlFor; + // [SameObject, PutForwards=value] readonly attribute DOMTokenList htmlFor; readonly attribute HTMLFormElement? form; // attribute DOMString name; diff --git a/components/script/dom/webidls/HTMLTableCellElement.webidl b/components/script/dom/webidls/HTMLTableCellElement.webidl index bbb04109d09..33863b3dc20 100644 --- a/components/script/dom/webidls/HTMLTableCellElement.webidl +++ b/components/script/dom/webidls/HTMLTableCellElement.webidl @@ -7,7 +7,7 @@ interface HTMLTableCellElement : HTMLElement { attribute unsigned long colSpan; // attribute unsigned long rowSpan; - //[PutForwards=value] readonly attribute DOMSettableTokenList headers; + // attribute DOMString headers; readonly attribute long cellIndex; // also has obsolete members diff --git a/components/script/dom/webidls/KeyboardEvent.webidl b/components/script/dom/webidls/KeyboardEvent.webidl index a9027ededcd..5a9865c8a6d 100644 --- a/components/script/dom/webidls/KeyboardEvent.webidl +++ b/components/script/dom/webidls/KeyboardEvent.webidl @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* * The origin of this IDL file is - * https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#interface-KeyboardEvent + * https://w3c.github.io/uievents/#interface-keyboardevent * */ @@ -26,7 +26,7 @@ interface KeyboardEvent : UIEvent { boolean getModifierState (DOMString keyArg); }; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-interface-KeyboardEvent-initializers +// https://w3c.github.io/uievents/#idl-interface-KeyboardEvent-initializers partial interface KeyboardEvent { // Originally introduced (and deprecated) in DOM Level 3 void initKeyboardEvent (DOMString typeArg, boolean bubblesArg, boolean cancelableArg, Window? viewArg, @@ -34,7 +34,7 @@ partial interface KeyboardEvent { boolean repeat, DOMString locale); }; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#KeyboardEvent-supplemental-interface +// https://w3c.github.io/uievents/#legacy-interface-KeyboardEvent partial interface KeyboardEvent { // The following support legacy user agents readonly attribute unsigned long charCode; @@ -42,7 +42,7 @@ partial interface KeyboardEvent { readonly attribute unsigned long which; }; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#interface-KeyboardEvent +// https://w3c.github.io/uievents/#dictdef-keyboardeventinit dictionary KeyboardEventInit : SharedKeyboardAndMouseEventInit { DOMString key = ""; DOMString code = ""; @@ -51,7 +51,7 @@ dictionary KeyboardEventInit : SharedKeyboardAndMouseEventInit { boolean isComposing = false; }; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-KeyboardEventInit-supplemental +// https://w3c.github.io/uievents/#legacy-dictionary-KeyboardEventInit /*partial dictionary KeyboardEventInit { unsigned long charCode = 0; unsigned long keyCode = 0; diff --git a/components/script/dom/webidls/MouseEvent.webidl b/components/script/dom/webidls/MouseEvent.webidl index ea9e7772a62..e309ce0924c 100644 --- a/components/script/dom/webidls/MouseEvent.webidl +++ b/components/script/dom/webidls/MouseEvent.webidl @@ -2,7 +2,7 @@ * 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://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-MouseEvent +// https://w3c.github.io/uievents/#interface-mouseevent [Constructor(DOMString typeArg, optional MouseEventInit mouseEventInitDict)] interface MouseEvent : UIEvent { readonly attribute long screenX; @@ -23,7 +23,7 @@ interface MouseEvent : UIEvent { readonly attribute long which; }; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-MouseEventInit +// https://w3c.github.io/uievents/#dictdef-eventmodifierinit dictionary MouseEventInit : SharedKeyboardAndMouseEventInit { long screenX = 0; long screenY = 0; @@ -34,7 +34,7 @@ dictionary MouseEventInit : SharedKeyboardAndMouseEventInit { EventTarget? relatedTarget = null; }; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-MouseEvent-1 +// https://w3c.github.io/uievents/#idl-interface-MouseEvent-initializers partial interface MouseEvent { // Deprecated in DOM Level 3 void initMouseEvent (DOMString typeArg, boolean bubblesArg, boolean cancelableArg, diff --git a/components/script/dom/webidls/NamedNodeMap.webidl b/components/script/dom/webidls/NamedNodeMap.webidl index c28d2566a0e..66156943b08 100644 --- a/components/script/dom/webidls/NamedNodeMap.webidl +++ b/components/script/dom/webidls/NamedNodeMap.webidl @@ -11,7 +11,7 @@ interface NamedNodeMap { [Pure] getter Attr? item(unsigned long index); [Pure] - getter Attr? getNamedItem(DOMString name); + getter Attr? getNamedItem(DOMString qualifiedName); [Pure] Attr? getNamedItemNS(DOMString? namespace, DOMString localName); [Throws] @@ -19,7 +19,7 @@ interface NamedNodeMap { [Throws] Attr? setNamedItemNS(Attr attr); [Throws] - Attr removeNamedItem(DOMString name); + Attr removeNamedItem(DOMString qualifiedName); [Throws] - Attr removeNamedItemNS(DOMString? namespace, DOMString name); + Attr removeNamedItemNS(DOMString? namespace, DOMString localName); }; diff --git a/components/script/dom/webidls/ParentNode.webidl b/components/script/dom/webidls/ParentNode.webidl index 678b3aeafa5..667dcc4671d 100644 --- a/components/script/dom/webidls/ParentNode.webidl +++ b/components/script/dom/webidls/ParentNode.webidl @@ -22,9 +22,6 @@ interface ParentNode { [Throws] void append((Node or DOMString)... nodes); - //Element? query(DOMString relativeSelectors); - //[NewObject] - //Elements queryAll(DOMString relativeSelectors); [Pure, Throws] Element? querySelector(DOMString selectors); [NewObject, Throws] diff --git a/components/script/dom/webidls/Range.webidl b/components/script/dom/webidls/Range.webidl index 1b49656378e..b4d5303ab2f 100644 --- a/components/script/dom/webidls/Range.webidl +++ b/components/script/dom/webidls/Range.webidl @@ -76,9 +76,9 @@ interface Range { // https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-range-interface partial interface Range { - // [NewObject, Throws] - // DocumentFragment createContextualFragment(DOMString fragment); -};// + [NewObject, Throws] + DocumentFragment createContextualFragment(DOMString fragment); +}; // http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface partial interface Range { diff --git a/components/script/dom/webidls/SharedMouseAndKeyboardEventInit.webidl b/components/script/dom/webidls/SharedMouseAndKeyboardEventInit.webidl index c7b67c551f9..906be401f78 100644 --- a/components/script/dom/webidls/SharedMouseAndKeyboardEventInit.webidl +++ b/components/script/dom/webidls/SharedMouseAndKeyboardEventInit.webidl @@ -2,7 +2,7 @@ * 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://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-SharedKeyboardAndMouseEventInit +// https://w3c.github.io/uievents/#dictdef-eventmodifierinit dictionary SharedKeyboardAndMouseEventInit : UIEventInit { boolean ctrlKey = false; boolean shiftKey = false; diff --git a/components/script/dom/webidls/UIEvent.webidl b/components/script/dom/webidls/UIEvent.webidl index d1019981b89..58f04ff24dc 100644 --- a/components/script/dom/webidls/UIEvent.webidl +++ b/components/script/dom/webidls/UIEvent.webidl @@ -2,7 +2,7 @@ * 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://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-UIEvent +// https://w3c.github.io/uievents/#interface-uievent [Constructor(DOMString type, optional UIEventInit eventInitDict)] interface UIEvent : Event { // readonly attribute WindowProxy? view; @@ -10,14 +10,14 @@ interface UIEvent : Event { readonly attribute long detail; }; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-UIEventInit +// https://w3c.github.io/uievents/#dictdef-uieventinit-uieventinit dictionary UIEventInit : EventInit { // WindowProxy? view = null; Window? view = null; long detail = 0; }; -// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-UIEvent-1 +// https://w3c.github.io/uievents/#idl-interface-UIEvent-initializers partial interface UIEvent { // Deprecated in DOM Level 3 void initUIEvent (DOMString typeArg, boolean bubblesArg, boolean cancelableArg, Window? viewArg, long detailArg); diff --git a/components/script/dom/webidls/URL.webidl b/components/script/dom/webidls/URL.webidl index 6843bd8b6c2..dc4c71f512e 100644 --- a/components/script/dom/webidls/URL.webidl +++ b/components/script/dom/webidls/URL.webidl @@ -7,7 +7,7 @@ Exposed=(Window,Worker)*/] interface URL { static USVString domainToASCII(USVString domain); - // static USVString domainToUnicode(USVString domain); + static USVString domainToUnicode(USVString domain); [SetterThrows] /*stringifier*/ attribute USVString href; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index b52c57e4674..90c1ee1bdba 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; +use blob_url_store::BlobURLStore; use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType, WorkerId}; use dom::bindings::callback::ExceptionHandling; use dom::bindings::cell::DOMRefCell; @@ -165,6 +166,9 @@ pub struct Window { scheduler_chan: IpcSender<TimerEventRequest>, timers: OneshotTimers, + /// Blob URL store + blob_url_store: DOMRefCell<BlobURLStore>, + next_worker_id: Cell<WorkerId>, /// For sending messages to the memory profiler. @@ -1581,6 +1585,7 @@ impl Window { console: Default::default(), crypto: Default::default(), navigator: Default::default(), + blob_url_store: DOMRefCell::new(BlobURLStore::new()), image_cache_thread: image_cache_thread, mem_profiler_chan: mem_profiler_chan, time_profiler_chan: time_profiler_chan, diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 06b3894ded3..89b4ed59bf9 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -2,7 +2,9 @@ * 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 blob_url_store::BlobURLStore; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId, DevtoolsPageInfo}; +use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::FunctionBinding::Function; use dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods; use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception}; @@ -113,6 +115,9 @@ pub struct WorkerGlobalScope { console: MutNullableHeap<JS<Console>>, crypto: MutNullableHeap<JS<Crypto>>, timers: OneshotTimers, + /// Blob URL store + blob_url_store: DOMRefCell<BlobURLStore>, + #[ignore_heap_size_of = "Defined in std"] mem_profiler_chan: mem::ProfilerChan, #[ignore_heap_size_of = "Defined in std"] @@ -172,6 +177,7 @@ impl WorkerGlobalScope { console: Default::default(), crypto: Default::default(), timers: OneshotTimers::new(timer_event_chan, init.scheduler_chan.clone()), + blob_url_store: DOMRefCell::new(BlobURLStore::new()), mem_profiler_chan: init.mem_profiler_chan, time_profiler_chan: init.time_profiler_chan, to_devtools_sender: init.to_devtools_sender, |