aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-04-27 13:06:29 -0500
committerbors-servo <metajack+bors@gmail.com>2015-04-27 13:06:29 -0500
commit9ec2ce0decff852f24280a59c779220f243bcff6 (patch)
treea9cf827ddefa7eae59f218f78aeea121866fa9fc /components/script
parent8a4555cc53bc1bbb21a08eb6f010cb1215034419 (diff)
parent16973624c83e2ddd7889b1779cbefe6480196c28 (diff)
downloadservo-9ec2ce0decff852f24280a59c779220f243bcff6.tar.gz
servo-9ec2ce0decff852f24280a59c779220f243bcff6.zip
Auto merge of #5868 - nox:document-legacy, r=jdm
<!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5868) <!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/document.rs29
-rw-r--r--components/script/dom/htmlbodyelement.rs6
-rw-r--r--components/script/dom/webidls/Document.webidl74
-rw-r--r--components/script/dom/webidls/HTMLBodyElement.webidl5
4 files changed, 98 insertions, 16 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 8cd3655d7c5..cbfc214f040 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -11,8 +11,8 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
-use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast};
-use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, ElementCast};
+use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLBodyElementCast};
+use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLHeadElementCast, ElementCast};
use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast};
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLAnchorElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementDerived, HTMLAppletElementDerived};
@@ -226,6 +226,8 @@ pub trait DocumentHelpers<'a> {
modifiers: KeyModifiers, compositor: &mut Box<ScriptListener+'static>);
fn node_from_nodes_and_strings(self, nodes: Vec<NodeOrString>)
-> Fallible<Temporary<Node>>;
+ fn get_body_attribute(self, local_name: &Atom) -> DOMString;
+ fn set_body_attribute(self, local_name: &Atom, value: DOMString);
/// Handles a mouse-move event coming from the compositor.
fn handle_mouse_move_event(self,
@@ -742,6 +744,21 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
}
}
+ fn get_body_attribute(self, local_name: &Atom) -> DOMString {
+ match self.GetBody().and_then(HTMLBodyElementCast::to_temporary).root() {
+ Some(ref body) => {
+ ElementCast::from_ref(body.r()).get_string_attribute(local_name)
+ },
+ None => "".to_owned()
+ }
+ }
+
+ fn set_body_attribute(self, local_name: &Atom, value: DOMString) {
+ if let Some(ref body) = self.GetBody().and_then(HTMLBodyElementCast::to_temporary).root() {
+ ElementCast::from_ref(body.r()).set_string_attribute(local_name, value);
+ }
+ }
+
fn set_current_script(self, script: Option<JSRef<HTMLScriptElement>>) {
self.current_script.set(script.map(JS::from_rooted));
}
@@ -1493,6 +1510,14 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
Ok(())
}
+ fn BgColor(self) -> DOMString {
+ self.get_body_attribute(&atom!("bgcolor"))
+ }
+
+ fn SetBgColor(self, value: DOMString) {
+ self.set_body_attribute(&atom!("bgcolor"), value)
+ }
+
global_event_handlers!();
event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange);
}
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index 1fb38160cd2..bf11d11c43c 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -19,6 +19,7 @@ use dom::virtualmethods::VirtualMethods;
use dom::window::WindowHelpers;
use cssparser::RGBA;
+use string_cache::Atom;
use util::str::{self, DOMString};
use std::borrow::ToOwned;
@@ -57,6 +58,11 @@ impl HTMLBodyElement {
}
impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
+
+ // https://html.spec.whatwg.org/#dom-body-bgcolor
+ make_getter!(BgColor, "bgcolor");
+ make_setter!(SetBgColor, "bgcolor");
+
fn GetOnunload(self) -> Option<EventHandlerNonNull> {
let win = window_from_node(self).root();
win.r().GetOnunload()
diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl
index eb7e17ed38c..2f01882ddb4 100644
--- a/components/script/dom/webidls/Document.webidl
+++ b/components/script/dom/webidls/Document.webidl
@@ -8,16 +8,17 @@
* https://www.whatwg.org/specs/web-apps/current-work/#the-document-object
*/
-/* https://dom.spec.whatwg.org/#interface-document */
+// https://dom.spec.whatwg.org/#interface-document
[Constructor]
interface Document : Node {
+ [SameObject]
readonly attribute DOMImplementation implementation;
readonly attribute DOMString URL;
readonly attribute Element? activeElement;
readonly attribute DOMString documentURI;
readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet;
- readonly attribute DOMString inputEncoding;
+ readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
readonly attribute DOMString contentType;
readonly attribute DocumentType? doctype;
@@ -66,35 +67,86 @@ Document implements ParentNode;
enum DocumentReadyState { "loading", "interactive", "complete" };
-/* https://www.whatwg.org/specs/web-apps/current-work/#the-document-object */
-partial interface Document {
+// https://www.whatwg.org/specs/web-apps/current-work/#the-document-object
+// [OverrideBuiltins]
+partial /*sealed*/ interface Document {
// resource metadata management
- readonly attribute DocumentReadyState readyState;
- readonly attribute DOMString lastModified;
- readonly attribute Location location;
+ // [PutForwards=href, Unforgeable]
+ readonly attribute Location/*?*/ location;
+ // attribute DOMString domain;
+ // readonly attribute DOMString referrer;
[Throws]
attribute DOMString cookie;
+ readonly attribute DOMString lastModified;
+ readonly attribute DocumentReadyState readyState;
// DOM tree accessors
+ // getter object (DOMString name);
attribute DOMString title;
[SetterThrows]
attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
+ [SameObject]
readonly attribute HTMLCollection images;
+ [SameObject]
readonly attribute HTMLCollection embeds;
+ [SameObject]
readonly attribute HTMLCollection plugins;
+ [SameObject]
readonly attribute HTMLCollection links;
+ [SameObject]
readonly attribute HTMLCollection forms;
+ [SameObject]
readonly attribute HTMLCollection scripts;
- readonly attribute HTMLCollection anchors;
- readonly attribute HTMLCollection applets;
NodeList getElementsByName(DOMString elementName);
+ // NodeList getItems(optional DOMString typeNames = ""); // microdata
+ // [SameObject]
+ // readonly attribute DOMElementMap cssElementMap;
readonly attribute HTMLScriptElement? currentScript;
+ // dynamic markup insertion
+ // Document open(optional DOMString type = "text/html", optional DOMString replace = "");
+ // WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace = false);
+ // void close();
+ // void write(DOMString... text);
+ // void writeln(DOMString... text);
+
+ // user interaction
+ readonly attribute Window/*Proxy?*/ defaultView;
+ // readonly attribute Element? activeElement;
+ // boolean hasFocus();
+ // attribute DOMString designMode;
+ // boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
+ // boolean queryCommandEnabled(DOMString commandId);
+ // boolean queryCommandIndeterm(DOMString commandId);
+ // 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;
- // user interaction
- readonly attribute Window defaultView;
+ // also has obsolete members
};
Document implements GlobalEventHandlers;
+
+// https://html.spec.whatwg.org/#Document-partial
+partial interface Document {
+ // [TreatNullAs=EmptyString] attribute DOMString fgColor;
+ // [TreatNullAs=EmptyString] attribute DOMString linkColor;
+ // [TreatNullAs=EmptyString] attribute DOMString vlinkColor;
+ // [TreatNullAs=EmptyString] attribute DOMString alinkColor;
+ [TreatNullAs=EmptyString] attribute DOMString bgColor;
+
+ [SameObject]
+ readonly attribute HTMLCollection anchors;
+ [SameObject]
+ readonly attribute HTMLCollection applets;
+
+ // void clear();
+ // void captureEvents();
+ // void releaseEvents();
+
+ // readonly attribute HTMLAllCollection all;
+};
diff --git a/components/script/dom/webidls/HTMLBodyElement.webidl b/components/script/dom/webidls/HTMLBodyElement.webidl
index 981ff03490a..f68f51e866e 100644
--- a/components/script/dom/webidls/HTMLBodyElement.webidl
+++ b/components/script/dom/webidls/HTMLBodyElement.webidl
@@ -3,9 +3,8 @@
* 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://www.whatwg.org/html/#htmlbodyelement
+// https://html.spec.whatwg.org/#the-body-element
interface HTMLBodyElement : HTMLElement {
-
// also has obsolete members
};
HTMLBodyElement implements WindowEventHandlers;
@@ -16,6 +15,6 @@ partial interface HTMLBodyElement {
//[TreatNullAs=EmptyString] attribute DOMString link;
//[TreatNullAs=EmptyString] attribute DOMString vLink;
//[TreatNullAs=EmptyString] attribute DOMString aLink;
- //[TreatNullAs=EmptyString] attribute DOMString bgColor;
+ [TreatNullAs=EmptyString] attribute DOMString bgColor;
// attribute DOMString background;
};