aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/bindings/global.rs11
-rw-r--r--components/script/dom/bindings/js.rs6
-rw-r--r--components/script/dom/document.rs11
-rw-r--r--components/script/dom/element.rs28
-rw-r--r--components/script/dom/htmlbodyelement.rs10
-rw-r--r--components/script/dom/htmlbuttonelement.rs2
-rw-r--r--components/script/dom/htmlelement.rs16
-rw-r--r--components/script/dom/htmlformelement.rs2
-rw-r--r--components/script/dom/htmlinputelement.rs8
-rw-r--r--components/script/dom/htmlscriptelement.rs23
-rw-r--r--components/script/dom/htmlselectelement.rs4
-rw-r--r--components/script/dom/htmltableelement.rs32
-rw-r--r--components/script/dom/htmltextareaelement.rs2
-rw-r--r--components/script/dom/node.rs44
-rw-r--r--components/script/dom/webidls/Document.webidl2
-rw-r--r--components/script/dom/webidls/HTMLTableElement.webidl2
-rw-r--r--components/script/dom/window.rs2
-rw-r--r--components/script/dom/xmldocument.rs9
-rw-r--r--components/script/dom/xmlhttprequest.rs16
-rw-r--r--components/script/webdriver_handlers.rs2
20 files changed, 140 insertions, 92 deletions
diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs
index 9cac7d9b940..e50f8ace9d0 100644
--- a/components/script/dom/bindings/global.rs
+++ b/components/script/dom/bindings/global.rs
@@ -143,6 +143,17 @@ impl<'a> GlobalRef<'a> {
}
}
+ /// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url)
+ /// for this global scope.
+ pub fn api_base_url(&self) -> Url {
+ match *self {
+ // https://html.spec.whatwg.org/multipage/#script-settings-for-browsing-contexts:api-base-url
+ GlobalRef::Window(ref window) => window.Document().base_url(),
+ // https://html.spec.whatwg.org/multipage/#script-settings-for-workers:api-base-url
+ GlobalRef::Worker(ref worker) => worker.get_url().clone(),
+ }
+ }
+
/// `ScriptChan` used to send messages to the event loop of this global's
/// thread.
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index 1736758e739..d171715d474 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -606,6 +606,12 @@ impl<T: Reflectable> PartialEq for Root<T> {
}
}
+impl<T: Reflectable> Clone for Root<T> {
+ fn clone(&self) -> Root<T> {
+ Root::from_ref(&*self)
+ }
+}
+
impl<T: Reflectable> Drop for Root<T> {
fn drop(&mut self) {
unsafe {
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 367ffb11d0c..ad68be7175f 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -903,7 +903,7 @@ impl Document {
for element in new_target.upcast::<Node>()
.inclusive_ancestors()
.filter_map(Root::downcast::<Element>) {
- if element.get_hover_state() {
+ if element.hover_state() {
break;
}
@@ -1774,7 +1774,7 @@ impl Document {
let mut map = self.modified_elements.borrow_mut();
let snapshot = map.entry(JS::from_ref(el)).or_insert(ElementSnapshot::new());
if snapshot.state.is_none() {
- snapshot.state = Some(el.get_state());
+ snapshot.state = Some(el.state());
}
}
@@ -1802,7 +1802,7 @@ impl Element {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement))
- if self.get_disabled_state() => true,
+ if self.disabled_state() => true,
_ => false,
}
}
@@ -2423,8 +2423,8 @@ impl DocumentMethods for Document {
}
// https://html.spec.whatwg.org/multipage/#dom-document-location
- fn Location(&self) -> Root<Location> {
- self.location.or_init(|| Location::new(&self.window))
+ fn GetLocation(&self) -> Option<Root<Location>> {
+ self.browsing_context().map(|_| self.location.or_init(|| Location::new(&self.window)))
}
// https://dom.spec.whatwg.org/#dom-parentnode-children
@@ -2777,4 +2777,3 @@ pub enum FocusEventType {
Focus, // Element gained focus. Doesn't bubble.
Blur, // Element lost focus. Doesn't bubble.
}
-
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index d51aafd25e8..4e2af78f31a 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -791,8 +791,7 @@ impl Element {
}
}
- // https://html.spec.whatwg.org/multipage/#root-element
- pub fn get_root_element(&self) -> Root<Element> {
+ pub fn root_element(&self) -> Root<Element> {
if self.node.is_in_doc() {
self.upcast::<Node>()
.owner_doc()
@@ -865,7 +864,7 @@ impl Element {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) => {
- self.get_disabled_state()
+ self.disabled_state()
}
// TODO:
// an optgroup element that has a disabled attribute
@@ -1875,7 +1874,7 @@ impl<'a> ::selectors::Element for Root<Element> {
NonTSPseudoClass::Disabled |
NonTSPseudoClass::Checked |
NonTSPseudoClass::Indeterminate =>
- Element::get_state(self).contains(pseudo_class.state_flag()),
+ Element::state(self).contains(pseudo_class.state_flag()),
}
}
@@ -2078,7 +2077,7 @@ impl Element {
self.set_click_in_progress(false);
}
- pub fn get_state(&self) -> ElementState {
+ pub fn state(&self) -> ElementState {
self.state.get()
}
@@ -2097,7 +2096,7 @@ impl Element {
self.state.set(state);
}
- pub fn get_active_state(&self) -> bool {
+ pub fn active_state(&self) -> bool {
self.state.get().contains(IN_ACTIVE_STATE)
}
@@ -2105,7 +2104,7 @@ impl Element {
self.set_state(IN_ACTIVE_STATE, value)
}
- pub fn get_focus_state(&self) -> bool {
+ pub fn focus_state(&self) -> bool {
self.state.get().contains(IN_FOCUS_STATE)
}
@@ -2114,7 +2113,7 @@ impl Element {
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
}
- pub fn get_hover_state(&self) -> bool {
+ pub fn hover_state(&self) -> bool {
self.state.get().contains(IN_HOVER_STATE)
}
@@ -2122,7 +2121,7 @@ impl Element {
self.set_state(IN_HOVER_STATE, value)
}
- pub fn get_enabled_state(&self) -> bool {
+ pub fn enabled_state(&self) -> bool {
self.state.get().contains(IN_ENABLED_STATE)
}
@@ -2130,7 +2129,7 @@ impl Element {
self.set_state(IN_ENABLED_STATE, value)
}
- pub fn get_disabled_state(&self) -> bool {
+ pub fn disabled_state(&self) -> bool {
self.state.get().contains(IN_DISABLED_STATE)
}
@@ -2142,7 +2141,7 @@ impl Element {
impl Element {
pub fn check_ancestors_disabled_state_for_form_control(&self) {
let node = self.upcast::<Node>();
- if self.get_disabled_state() {
+ if self.disabled_state() {
return;
}
for ancestor in node.ancestors() {
@@ -2151,7 +2150,7 @@ impl Element {
if !ancestor.is::<HTMLFieldSetElement>() {
continue;
}
- if !ancestor.downcast::<Element>().unwrap().get_disabled_state() {
+ if !ancestor.downcast::<Element>().unwrap().disabled_state() {
continue;
}
if ancestor.is_parent_of(node) {
@@ -2176,13 +2175,13 @@ impl Element {
}
pub fn check_parent_disabled_state_for_option(&self) {
- if self.get_disabled_state() {
+ if self.disabled_state() {
return;
}
let node = self.upcast::<Node>();
if let Some(ref parent) = node.GetParentNode() {
if parent.is::<HTMLOptGroupElement>() &&
- parent.downcast::<Element>().unwrap().get_disabled_state() {
+ parent.downcast::<Element>().unwrap().disabled_state() {
self.set_disabled_state(true);
self.set_enabled_state(false);
}
@@ -2233,4 +2232,3 @@ impl AtomicElementFlags {
self.0.fetch_or(flags.bits() as usize, Ordering::Relaxed);
}
}
-
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index 8ac184ea51d..ca133b88dbb 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -47,6 +47,16 @@ impl HTMLBodyElement {
let element = HTMLBodyElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBodyElementBinding::Wrap)
}
+
+ /// https://drafts.csswg.org/cssom-view/#the-html-body-element
+ pub fn is_the_html_body_element(&self) -> bool {
+ let self_node = self.upcast::<Node>();
+ let root_elem = self.upcast::<Element>().root_element();
+ let root_node = root_elem.upcast::<Node>();
+ root_node.is_parent_of(self_node) &&
+ self_node.preceding_siblings().all(|n| !n.is::<HTMLBodyElement>())
+ }
+
}
impl HTMLBodyElementMethods for HTMLBodyElement {
diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs
index 342d4173343..22fed30a2df 100644
--- a/components/script/dom/htmlbuttonelement.rs
+++ b/components/script/dom/htmlbuttonelement.rs
@@ -213,7 +213,7 @@ impl Activatable for HTMLButtonElement {
fn is_instance_activatable(&self) -> bool {
//https://html.spec.whatwg.org/multipage/#the-button-element
- !self.upcast::<Element>().get_disabled_state()
+ !self.upcast::<Element>().disabled_state()
}
// https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index aa2ee98ad1f..566a86d8804 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -200,7 +200,7 @@ impl HTMLElementMethods for HTMLElement {
// https://html.spec.whatwg.org/multipage/#dom-click
fn Click(&self) {
- if !self.upcast::<Element>().get_disabled_state() {
+ if !self.upcast::<Element>().disabled_state() {
synthetic_click_activation(self.upcast::<Element>(),
false,
false,
@@ -223,7 +223,7 @@ impl HTMLElementMethods for HTMLElement {
// https://html.spec.whatwg.org/multipage/#dom-blur
fn Blur(&self) {
// TODO: Run the unfocusing steps.
- if !self.upcast::<Element>().get_focus_state() {
+ if !self.upcast::<Element>().focus_state() {
return;
}
// https://html.spec.whatwg.org/multipage/#unfocusing-steps
@@ -233,7 +233,7 @@ impl HTMLElementMethods for HTMLElement {
document.commit_focus_transaction(FocusType::Element);
}
- // https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
+ // https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
fn GetOffsetParent(&self) -> Option<Root<Element>> {
if self.is::<HTMLBodyElement>() || self.is::<HTMLHtmlElement>() {
return None;
@@ -246,7 +246,7 @@ impl HTMLElementMethods for HTMLElement {
element
}
- // https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
+ // https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsettop
fn OffsetTop(&self) -> i32 {
if self.is::<HTMLBodyElement>() {
return 0;
@@ -259,7 +259,7 @@ impl HTMLElementMethods for HTMLElement {
rect.origin.y.to_nearest_px()
}
- // https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
+ // https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetleft
fn OffsetLeft(&self) -> i32 {
if self.is::<HTMLBodyElement>() {
return 0;
@@ -272,7 +272,7 @@ impl HTMLElementMethods for HTMLElement {
rect.origin.x.to_nearest_px()
}
- // https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
+ // https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetwidth
fn OffsetWidth(&self) -> i32 {
let node = self.upcast::<Node>();
let window = window_from_node(self);
@@ -281,7 +281,7 @@ impl HTMLElementMethods for HTMLElement {
rect.size.width.to_nearest_px()
}
- // https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
+ // https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetheight
fn OffsetHeight(&self) -> i32 {
let node = self.upcast::<Node>();
let window = window_from_node(self);
@@ -449,7 +449,7 @@ impl HTMLElement {
};
// Traverse entire tree for <label> elements with `for` attribute matching `id`
- let root_element = element.get_root_element();
+ let root_element = element.root_element();
let root_node = root_element.upcast::<Node>();
let children = root_node.traverse_preorder()
.filter_map(Root::downcast::<Element>)
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index f46b69b9e89..70a2a7ad730 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -400,7 +400,7 @@ impl HTMLFormElement {
for child in node.traverse_preorder() {
// Step 3.1: The field element is disabled.
match child.downcast::<Element>() {
- Some(el) if !el.get_disabled_state() => (),
+ Some(el) if !el.disabled_state() => (),
_ => continue,
}
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 65cc0e0767b..174a312448f 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -272,7 +272,7 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_selection_for_layout(self) -> Option<Range<isize>> {
- if !(*self.unsafe_get()).upcast::<Element>().get_focus_state() {
+ if !(*self.unsafe_get()).upcast::<Element>().focus_state() {
return None;
}
@@ -324,7 +324,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#dom-input-checked
fn Checked(&self) -> bool {
- self.upcast::<Element>().get_state().contains(IN_CHECKED_STATE)
+ self.upcast::<Element>().state().contains(IN_CHECKED_STATE)
}
// https://html.spec.whatwg.org/multipage/#dom-input-checked
@@ -466,7 +466,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#dom-input-indeterminate
fn Indeterminate(&self) -> bool {
- self.upcast::<Element>().get_state().contains(IN_INDETERMINATE_STATE)
+ self.upcast::<Element>().state().contains(IN_INDETERMINATE_STATE)
}
// https://html.spec.whatwg.org/multipage/#dom-input-indeterminate
@@ -663,7 +663,7 @@ impl HTMLInputElement {
fn mutable(&self) -> bool {
// https://html.spec.whatwg.org/multipage/#the-input-element:concept-fe-mutable
// https://html.spec.whatwg.org/multipage/#the-readonly-attribute:concept-fe-mutable
- !(self.upcast::<Element>().get_disabled_state() || self.ReadOnly())
+ !(self.upcast::<Element>().disabled_state() || self.ReadOnly())
}
// https://html.spec.whatwg.org/multipage/#the-input-element:concept-form-reset-control
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index 3a609a0977f..efe5fe54535 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -28,6 +28,7 @@ use dom::window::ScriptHelpers;
use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecoderTrap, Encoding, EncodingRef};
use html5ever::tree_builder::NextParserState;
+use hyper::http::RawStatus;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use js::jsapi::RootedValue;
@@ -136,20 +137,35 @@ struct ScriptContext {
metadata: Option<Metadata>,
/// The initial URL requested.
url: Url,
+ /// Indicates whether the request failed, and why
+ status: Result<(), String>
}
impl AsyncResponseListener for ScriptContext {
fn headers_available(&mut self, metadata: Metadata) {
+ let status_code = match metadata.status {
+ Some(RawStatus(c, _)) => c,
+ _ => 0
+ };
+
+ self.status = match status_code {
+ 0 => Err("No http status code received".to_owned()),
+ 200...299 => Ok(()), // HTTP ok status codes
+ _ => Err(format!("HTTP error code {}", status_code))
+ };
+
self.metadata = Some(metadata);
}
fn data_available(&mut self, payload: Vec<u8>) {
- let mut payload = payload;
- self.data.append(&mut payload);
+ if self.status.is_ok() {
+ let mut payload = payload;
+ self.data.append(&mut payload);
+ }
}
fn response_complete(&mut self, status: Result<(), String>) {
- let load = status.map(|_| {
+ let load = status.and(self.status.clone()).map(|_| {
let data = mem::replace(&mut self.data, vec!());
let metadata = self.metadata.take().unwrap();
(metadata, data)
@@ -292,6 +308,7 @@ impl HTMLScriptElement {
data: vec!(),
metadata: None,
url: url.clone(),
+ status: Ok(())
}));
let (action_sender, action_receiver) = ipc::channel().unwrap();
diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs
index d42ba617a75..45161f5ee2d 100644
--- a/components/script/dom/htmlselectelement.rs
+++ b/components/script/dom/htmlselectelement.rs
@@ -67,7 +67,7 @@ impl HTMLSelectElement {
last_selected = Some(Root::from_ref(opt.r()));
}
let element = opt.upcast::<Element>();
- if first_enabled.is_none() && !element.get_disabled_state() {
+ if first_enabled.is_none() && !element.disabled_state() {
first_enabled = Some(Root::from_ref(opt.r()));
}
}
@@ -90,7 +90,7 @@ impl HTMLSelectElement {
}
for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) {
let element = opt.upcast::<Element>();
- if opt.Selected() && element.get_enabled_state() {
+ if opt.Selected() && element.enabled_state() {
data_set.push(FormDatum {
ty: self.Type(),
name: self.Name(),
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs
index 94c0b6dc986..ab611716b90 100644
--- a/components/script/dom/htmltableelement.rs
+++ b/components/script/dom/htmltableelement.rs
@@ -8,13 +8,15 @@ use dom::bindings::codegen::Bindings::HTMLTableElementBinding;
use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::inheritance::Castable;
-use dom::bindings::js::{LayoutJS, Root, RootedReference};
+use dom::bindings::js::{JS, LayoutJS, Root, RootedReference};
use dom::document::Document;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
+use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmlelement::HTMLElement;
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
+use dom::htmltablerowelement::HTMLTableRowElement;
use dom::htmltablesectionelement::HTMLTableSectionElement;
-use dom::node::{Node, document_from_node};
+use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use std::cell::Cell;
use string_cache::Atom;
@@ -51,6 +53,32 @@ impl HTMLTableElement {
}
impl HTMLTableElementMethods for HTMLTableElement {
+ // https://html.spec.whatwg.org/multipage/#dom-table-rows
+ fn Rows(&self) -> Root<HTMLCollection> {
+ #[allow(unrooted_must_root)]
+ #[derive(JSTraceable, HeapSizeOf)]
+ struct TableRowFilter {
+ sections: Vec<JS<Node>>
+ }
+
+ impl CollectionFilter for TableRowFilter {
+ fn filter(&self, elem: &Element, root: &Node) -> bool {
+ elem.is::<HTMLTableRowElement>()
+ && (root.is_parent_of(elem.upcast())
+ || self.sections.iter().any(|ref section| section.is_parent_of(elem.upcast())))
+ }
+ }
+
+ let filter = TableRowFilter {
+ sections: self.upcast::<Node>()
+ .children()
+ .filter_map(|ref node|
+ node.downcast::<HTMLTableSectionElement>().map(|_| JS::from_rooted(node)))
+ .collect()
+ };
+ HTMLCollection::new(window_from_node(self).r(), self.upcast(), box filter)
+ }
+
// https://html.spec.whatwg.org/multipage/#dom-table-caption
fn GetCaption(&self) -> Option<Root<HTMLTableCaptionElement>> {
self.upcast::<Node>().children().filter_map(Root::downcast).next()
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index 50f34c9ff85..a9f8f170889 100644
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -64,7 +64,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_absolute_selection_for_layout(self) -> Option<Range<usize>> {
- if (*self.unsafe_get()).upcast::<Element>().get_focus_state() {
+ if (*self.unsafe_get()).upcast::<Element>().focus_state() {
Some((*self.unsafe_get()).textinput.borrow_for_layout()
.get_absolute_selection_range())
} else {
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 99648369357..1e71966e4e7 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -594,12 +594,8 @@ impl Node {
let html_element = document.GetDocumentElement();
- let is_body_element = html_element.r().and_then(|root| {
- let node = root.upcast::<Node>();
- node.children().find(|child| { child.is::<HTMLBodyElement>() }).map(|node| {
- *node.r() == *self
- })
- }).unwrap_or(false);
+ let is_body_element = self.downcast::<HTMLBodyElement>()
+ .map_or(false, |e| e.is_the_html_body_element());
let scroll_area = window.scroll_area_query(self.to_trusted_node_address());
@@ -1166,34 +1162,20 @@ impl Iterator for PrecedingNodeIterator {
Some(current) => current,
};
- if self.root == current {
- self.current = None;
- return None
- }
-
- let node = current;
- if let Some(previous_sibling) = node.GetPreviousSibling() {
+ self.current = if self.root == current {
+ None
+ } else if let Some(previous_sibling) = current.GetPreviousSibling() {
if self.root == previous_sibling {
- self.current = None;
- return None
- }
-
- if let Some(last_child) = previous_sibling.descending_last_children().last() {
- self.current = Some(last_child);
- return previous_sibling.descending_last_children().last()
+ None
+ } else if let Some(last_child) = previous_sibling.descending_last_children().last() {
+ Some(last_child)
+ } else {
+ Some(previous_sibling)
}
-
- self.current = Some(previous_sibling);
- return node.GetPreviousSibling()
+ } else {
+ current.GetParentNode()
};
-
- if let Some(parent_node) = node.GetParentNode() {
- self.current = Some(parent_node);
- return node.GetParentNode()
- }
-
- self.current = None;
- None
+ self.current.clone()
}
}
diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl
index 7ca1dec527f..1d12bc7aabb 100644
--- a/components/script/dom/webidls/Document.webidl
+++ b/components/script/dom/webidls/Document.webidl
@@ -81,7 +81,7 @@ enum DocumentReadyState { "loading", "interactive", "complete" };
partial /*sealed*/ interface Document {
// resource metadata management
[/*PutForwards=href, */Unforgeable]
- readonly attribute Location/*?*/ location;
+ readonly attribute Location? location;
readonly attribute DOMString domain;
// readonly attribute DOMString referrer;
[Throws]
diff --git a/components/script/dom/webidls/HTMLTableElement.webidl b/components/script/dom/webidls/HTMLTableElement.webidl
index edf8d1d720f..2697f4c1e93 100644
--- a/components/script/dom/webidls/HTMLTableElement.webidl
+++ b/components/script/dom/webidls/HTMLTableElement.webidl
@@ -16,7 +16,7 @@ interface HTMLTableElement : HTMLElement {
//void deleteTFoot();
//readonly attribute HTMLCollection tBodies;
HTMLTableSectionElement createTBody();
- //readonly attribute HTMLCollection rows;
+ readonly attribute HTMLCollection rows;
//HTMLElement insertRow(optional long index = -1);
//void deleteRow(long index);
// attribute boolean sortable;
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index bd8ae5b9f39..da415c5d0f2 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -441,7 +441,7 @@ impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#dom-location
fn Location(&self) -> Root<Location> {
- self.Document().Location()
+ self.Document().GetLocation().unwrap()
}
// https://html.spec.whatwg.org/multipage/#dom-sessionstorage
diff --git a/components/script/dom/xmldocument.rs b/components/script/dom/xmldocument.rs
index 6fc1ebfd267..9d156682fa2 100644
--- a/components/script/dom/xmldocument.rs
+++ b/components/script/dom/xmldocument.rs
@@ -4,7 +4,6 @@
use document_loader::DocumentLoader;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
-use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::codegen::Bindings::XMLDocumentBinding::{self, XMLDocumentMethods};
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable;
@@ -76,17 +75,17 @@ impl XMLDocument {
impl XMLDocumentMethods for XMLDocument {
// https://html.spec.whatwg.org/multipage/#dom-document-location
- fn Location(&self) -> Root<Location> {
- self.document.Location()
+ fn GetLocation(&self) -> Option<Root<Location>> {
+ self.upcast::<Document>().GetLocation()
}
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
- self.document.SupportedPropertyNames()
+ self.upcast::<Document>().SupportedPropertyNames()
}
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter
fn NamedGetter(&self, _cx: *mut JSContext, name: DOMString, found: &mut bool) -> *mut JSObject {
- self.document.NamedGetter(_cx, name, found)
+ self.upcast::<Document>().NamedGetter(_cx, name, found)
}
}
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 4569a9e7d4a..1d7c2bffd34 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -10,9 +10,9 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::codegen::Bindings::XMLHttpRequestBinding;
+use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::BodyInit;
use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestMethods;
use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestResponseType;
-use dom::bindings::codegen::UnionTypes::BlobOrStringOrURLSearchParams;
use dom::bindings::conversions::{ToJSValConvertible};
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::global::{GlobalRef, GlobalRoot};
@@ -65,8 +65,6 @@ use url::percent_encoding::{utf8_percent_encode, USERNAME_ENCODE_SET, PASSWORD_E
use util::prefs;
use util::str::DOMString;
-pub type SendParam = BlobOrStringOrURLSearchParams;
-
#[derive(JSTraceable, PartialEq, Copy, Clone, HeapSizeOf)]
enum XMLHttpRequestState {
Unsent = 0,
@@ -352,7 +350,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
}
// Step 2
- let base = self.global().r().get_url();
+ let base = self.global().r().api_base_url();
// Step 6
let mut parsed_url = match base.join(&url.0) {
Ok(parsed) => parsed,
@@ -530,7 +528,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
}
// https://xhr.spec.whatwg.org/#the-send()-method
- fn Send(&self, data: Option<SendParam>) -> ErrorResult {
+ fn Send(&self, data: Option<BodyInit>) -> ErrorResult {
// Step 1, 2
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
return Err(Error::InvalidState);
@@ -1397,21 +1395,21 @@ impl XHRTimeoutCallback {
trait Extractable {
fn extract(&self) -> (Vec<u8>, Option<DOMString>);
}
-impl Extractable for SendParam {
+impl Extractable for BodyInit {
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
fn extract(&self) -> (Vec<u8>, Option<DOMString>) {
match *self {
- BlobOrStringOrURLSearchParams::String(ref s) => {
+ BodyInit::String(ref s) => {
let encoding = UTF_8 as EncodingRef;
(encoding.encode(s, EncoderTrap::Replace).unwrap(),
Some(DOMString::from("text/plain;charset=UTF-8")))
},
- BlobOrStringOrURLSearchParams::URLSearchParams(ref usp) => {
+ BodyInit::URLSearchParams(ref usp) => {
// Default encoding is UTF-8.
(usp.serialize(None).into_bytes(),
Some(DOMString::from("application/x-www-form-urlencoded;charset=UTF-8")))
},
- BlobOrStringOrURLSearchParams::Blob(ref b) => {
+ BodyInit::Blob(ref b) => {
let data = b.get_data();
let content_type = if b.Type().as_ref().is_empty() {
None
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index acd375b6690..142b8c79d8b 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -295,7 +295,7 @@ pub fn handle_is_enabled(page: &Rc<Page>,
reply.send(match find_node_by_unique_id(page, pipeline, element_id) {
Some(ref node) => {
match node.downcast::<Element>() {
- Some(elem) => Ok(elem.get_enabled_state()),
+ Some(elem) => Ok(elem.enabled_state()),
None => Err(())
}
},