Add/update comments with links to spec

Extracted out of #5649

* add more hyperlinks to associated specification for structs/methods
* follow redirects and update links
* replace broken links
* removal of WHATWG multipage page name since the page name is not
  guaranteed to be stable
This commit is contained in:
Corey Farwell 2015-04-11 11:35:40 -07:00
parent 7f422e2076
commit cc4a64e1fe
19 changed files with 112 additions and 35 deletions

View file

@ -560,8 +560,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
// FIXME: This is HTML only. // FIXME: This is HTML only.
let node: &Node = NodeCast::from_actual(self.element); let node: &Node = NodeCast::from_actual(self.element);
match node.type_id_for_layout() { match node.type_id_for_layout() {
// https://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html# // https://html.spec.whatwg.org/multipage/#selector-link
// selector-link
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => {

View file

@ -23,6 +23,7 @@ pub enum BlobTypeId {
File, File,
} }
// http://dev.w3.org/2006/webapi/FileAPI/#blob
#[dom_struct] #[dom_struct]
pub struct Blob { pub struct Blob {
reflector_: Reflector, reflector_: Reflector,
@ -59,10 +60,12 @@ impl Blob {
BlobBinding::Wrap) BlobBinding::Wrap)
} }
// http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob
pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<Blob>> { pub fn Constructor(global: GlobalRef) -> Fallible<Temporary<Blob>> {
Ok(Blob::new(global, None, "")) Ok(Blob::new(global, None, ""))
} }
// http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob
pub fn Constructor_(global: GlobalRef, blobParts: DOMString, blobPropertyBag: &BlobBinding::BlobPropertyBag) -> Fallible<Temporary<Blob>> { pub fn Constructor_(global: GlobalRef, blobParts: DOMString, blobPropertyBag: &BlobBinding::BlobPropertyBag) -> Fallible<Temporary<Blob>> {
//TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob //TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob
let bytes: Option<Vec<u8>> = Some(blobParts.into_bytes()); let bytes: Option<Vec<u8>> = Some(blobParts.into_bytes());
@ -77,6 +80,7 @@ impl Blob {
} }
impl<'a> BlobMethods for JSRef<'a, Blob> { impl<'a> BlobMethods for JSRef<'a, Blob> {
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-size
fn Size(self) -> u64{ fn Size(self) -> u64{
match self.bytes { match self.bytes {
None => 0, None => 0,
@ -84,10 +88,12 @@ impl<'a> BlobMethods for JSRef<'a, Blob> {
} }
} }
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-type
fn Type(self) -> DOMString { fn Type(self) -> DOMString {
self.typeString.clone() self.typeString.clone()
} }
// http://dev.w3.org/2006/webapi/FileAPI/#slice-method-algo
fn Slice(self, start: Option<i64>, end: Option<i64>, fn Slice(self, start: Option<i64>, end: Option<i64>,
contentType: Option<DOMString>) -> Temporary<Blob> { contentType: Option<DOMString>) -> Temporary<Blob> {
let size: i64 = self.Size().to_i64().unwrap(); let size: i64 = self.Size().to_i64().unwrap();
@ -135,10 +141,12 @@ impl<'a> BlobMethods for JSRef<'a, Blob> {
} }
} }
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-isClosed
//fn IsClosed(self) -> bool { //fn IsClosed(self) -> bool {
// self.isClosed_.clone() // self.isClosed_.clone()
//} //}
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-close
//fn Close(self) { //fn Close(self) {
// TODO // TODO
//} //}

View file

@ -13,6 +13,7 @@ use dom::bindings::num::Finite;
use dom::bindings::utils::{Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::canvasrenderingcontext2d::parse_color; use dom::canvasrenderingcontext2d::parse_color;
// https://html.spec.whatwg.org/multipage/#canvasgradient
#[dom_struct] #[dom_struct]
pub struct CanvasGradient { pub struct CanvasGradient {
reflector_: Reflector, reflector_: Reflector,
@ -42,6 +43,7 @@ impl CanvasGradient {
} }
impl<'a> CanvasGradientMethods for JSRef<'a, CanvasGradient> { impl<'a> CanvasGradientMethods for JSRef<'a, CanvasGradient> {
// https://html.spec.whatwg.org/multipage/#dom-canvasgradient-addcolorstop
fn AddColorStop(self, offset: Finite<f32>, color: String) { fn AddColorStop(self, offset: Finite<f32>, color: String) {
let default_black = RGBA { let default_black = RGBA {
red: 0.0, red: 0.0,

View file

@ -4,6 +4,7 @@
use dom::bindings::utils::Reflector; use dom::bindings::utils::Reflector;
// https://html.spec.whatwg.org/multipage/#canvaspattern
#[dom_struct] #[dom_struct]
pub struct CanvasPattern { pub struct CanvasPattern {
reflector_: Reflector, reflector_: Reflector,

View file

@ -45,6 +45,7 @@ use util::str::DOMString;
use url::Url; use url::Url;
use util::vec::byte_swap; use util::vec::byte_swap;
// https://html.spec.whatwg.org/multipage/#canvasrenderingcontext2d
#[dom_struct] #[dom_struct]
pub struct CanvasRenderingContext2D { pub struct CanvasRenderingContext2D {
reflector_: Reflector, reflector_: Reflector,
@ -164,7 +165,7 @@ impl CanvasRenderingContext2D {
// The rectangle (sx, sy, sw, sh) from the source image // The rectangle (sx, sy, sw, sh) from the source image
// is copied on the rectangle (dx, dy, dh, dw) of the destination canvas // is copied on the rectangle (dx, dy, dh, dw) of the destination canvas
// //
// https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage // https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
fn draw_html_canvas_element(&self, fn draw_html_canvas_element(&self,
canvas: JSRef<HTMLCanvasElement>, canvas: JSRef<HTMLCanvasElement>,
sx: f64, sy: f64, sw: f64, sh: f64, sx: f64, sy: f64, sw: f64, sh: f64,
@ -312,10 +313,12 @@ impl LayoutCanvasRenderingContext2DHelpers for LayoutJS<CanvasRenderingContext2D
// //
// FIXME: this behavior should might be generated by some annotattions to idl. // FIXME: this behavior should might be generated by some annotattions to idl.
impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D> { impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D> {
// https://html.spec.whatwg.org/multipage/#dom-context-2d-canvas
fn Canvas(self) -> Temporary<HTMLCanvasElement> { fn Canvas(self) -> Temporary<HTMLCanvasElement> {
Temporary::new(self.canvas) Temporary::new(self.canvas)
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-scale
fn Scale(self, x: f64, y: f64) { fn Scale(self, x: f64, y: f64) {
if !(x.is_finite() && y.is_finite()) { if !(x.is_finite() && y.is_finite()) {
return; return;
@ -325,6 +328,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.update_transform() self.update_transform()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-translate
fn Translate(self, x: f64, y: f64) { fn Translate(self, x: f64, y: f64) {
if !(x.is_finite() && y.is_finite()) { if !(x.is_finite() && y.is_finite()) {
return; return;
@ -334,6 +338,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.update_transform() self.update_transform()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-transform
fn Transform(self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) { fn Transform(self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) {
if !(a.is_finite() && b.is_finite() && c.is_finite() && if !(a.is_finite() && b.is_finite() && c.is_finite() &&
d.is_finite() && e.is_finite() && f.is_finite()) { d.is_finite() && e.is_finite() && f.is_finite()) {
@ -349,6 +354,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.update_transform() self.update_transform()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
fn SetTransform(self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) { fn SetTransform(self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) {
if !(a.is_finite() && b.is_finite() && c.is_finite() && if !(a.is_finite() && b.is_finite() && c.is_finite() &&
d.is_finite() && e.is_finite() && f.is_finite()) { d.is_finite() && e.is_finite() && f.is_finite()) {
@ -364,10 +370,12 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.update_transform() self.update_transform()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha
fn GlobalAlpha(self) -> f64 { fn GlobalAlpha(self) -> f64 {
self.global_alpha.get() self.global_alpha.get()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha
fn SetGlobalAlpha(self, alpha: f64) { fn SetGlobalAlpha(self, alpha: f64) {
if !alpha.is_finite() || alpha > 1.0 || alpha < 0.0 { if !alpha.is_finite() || alpha > 1.0 || alpha < 0.0 {
return; return;
@ -377,41 +385,48 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.renderer.send(CanvasMsg::SetGlobalAlpha(alpha as f32)).unwrap() self.renderer.send(CanvasMsg::SetGlobalAlpha(alpha as f32)).unwrap()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-fillrect
fn FillRect(self, x: f64, y: f64, width: f64, height: f64) { fn FillRect(self, x: f64, y: f64, width: f64, height: f64) {
if let Some(rect) = self.create_drawable_rect(x, y, width, height) { if let Some(rect) = self.create_drawable_rect(x, y, width, height) {
self.renderer.send(CanvasMsg::FillRect(rect)).unwrap(); self.renderer.send(CanvasMsg::FillRect(rect)).unwrap();
} }
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-clearrect
fn ClearRect(self, x: f64, y: f64, width: f64, height: f64) { fn ClearRect(self, x: f64, y: f64, width: f64, height: f64) {
if let Some(rect) = self.create_drawable_rect(x, y, width, height) { if let Some(rect) = self.create_drawable_rect(x, y, width, height) {
self.renderer.send(CanvasMsg::ClearRect(rect)).unwrap(); self.renderer.send(CanvasMsg::ClearRect(rect)).unwrap();
} }
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokerect
fn StrokeRect(self, x: f64, y: f64, width: f64, height: f64) { fn StrokeRect(self, x: f64, y: f64, width: f64, height: f64) {
if let Some(rect) = self.create_drawable_rect(x, y, width, height) { if let Some(rect) = self.create_drawable_rect(x, y, width, height) {
self.renderer.send(CanvasMsg::StrokeRect(rect)).unwrap(); self.renderer.send(CanvasMsg::StrokeRect(rect)).unwrap();
} }
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-beginpath
fn BeginPath(self) { fn BeginPath(self) {
self.renderer.send(CanvasMsg::BeginPath).unwrap(); self.renderer.send(CanvasMsg::BeginPath).unwrap();
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-closepath
fn ClosePath(self) { fn ClosePath(self) {
self.renderer.send(CanvasMsg::ClosePath).unwrap(); self.renderer.send(CanvasMsg::ClosePath).unwrap();
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-fill
fn Fill(self, _: CanvasWindingRule) { fn Fill(self, _: CanvasWindingRule) {
self.renderer.send(CanvasMsg::Fill).unwrap(); self.renderer.send(CanvasMsg::Fill).unwrap();
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-stroke
fn Stroke(self) { fn Stroke(self) {
self.renderer.send(CanvasMsg::Stroke).unwrap(); self.renderer.send(CanvasMsg::Stroke).unwrap();
} }
// https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage // https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
fn DrawImage(self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D, fn DrawImage(self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D,
dx: f64, dy: f64) -> Fallible<()> { dx: f64, dy: f64) -> Fallible<()> {
if !(dx.is_finite() && dy.is_finite()) { if !(dx.is_finite() && dy.is_finite()) {
@ -453,7 +468,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => { HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => {
let image = image.root(); let image = image.root();
let image_element = image.r(); let image_element = image.r();
// https://html.spec.whatwg.org/multipage/embedded-content.html#img-error // https://html.spec.whatwg.org/multipage/#img-error
// If the image argument is an HTMLImageElement object that is in the broken state, // If the image argument is an HTMLImageElement object that is in the broken state,
// then throw an InvalidStateError exception // then throw an InvalidStateError exception
let (image_data, image_size) = match self.fetch_image_data(&image_element) { let (image_data, image_size) = match self.fetch_image_data(&image_element) {
@ -473,7 +488,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
} }
} }
// https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage // https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
fn DrawImage_(self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D, fn DrawImage_(self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D,
dx: f64, dy: f64, dw: f64, dh: f64) -> Fallible<()> { dx: f64, dy: f64, dw: f64, dh: f64) -> Fallible<()> {
if !(dx.is_finite() && dy.is_finite() && if !(dx.is_finite() && dy.is_finite() &&
@ -512,7 +527,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => { HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => {
let image = image.root(); let image = image.root();
let image_element = image.r(); let image_element = image.r();
// https://html.spec.whatwg.org/multipage/embedded-content.html#img-error // https://html.spec.whatwg.org/multipage/#img-error
// If the image argument is an HTMLImageElement object that is in the broken state, // If the image argument is an HTMLImageElement object that is in the broken state,
// then throw an InvalidStateError exception // then throw an InvalidStateError exception
let (image_data, image_size) = match self.fetch_image_data(&image_element) { let (image_data, image_size) = match self.fetch_image_data(&image_element) {
@ -529,7 +544,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
} }
} }
// https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-drawimage // https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
fn DrawImage__(self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D, fn DrawImage__(self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D,
sx: f64, sy: f64, sw: f64, sh: f64, sx: f64, sy: f64, sw: f64, sh: f64,
dx: f64, dy: f64, dw: f64, dh: f64) -> Fallible<()> { dx: f64, dy: f64, dw: f64, dh: f64) -> Fallible<()> {
@ -556,7 +571,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => { HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => {
let image = image.root(); let image = image.root();
let image_element = image.r(); let image_element = image.r();
// https://html.spec.whatwg.org/multipage/embedded-content.html#img-error // https://html.spec.whatwg.org/multipage/#img-error
// If the image argument is an HTMLImageElement object that is in the broken state, // If the image argument is an HTMLImageElement object that is in the broken state,
// then throw an InvalidStateError exception // then throw an InvalidStateError exception
let (image_data, image_size) = match self.fetch_image_data(&image_element) { let (image_data, image_size) = match self.fetch_image_data(&image_element) {
@ -571,6 +586,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
} }
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-moveto
fn MoveTo(self, x: f64, y: f64) { fn MoveTo(self, x: f64, y: f64) {
if !(x.is_finite() && y.is_finite()) { if !(x.is_finite() && y.is_finite()) {
return; return;
@ -579,6 +595,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.renderer.send(CanvasMsg::MoveTo(Point2D(x as f32, y as f32))).unwrap(); self.renderer.send(CanvasMsg::MoveTo(Point2D(x as f32, y as f32))).unwrap();
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-lineto
fn LineTo(self, x: f64, y: f64) { fn LineTo(self, x: f64, y: f64) {
if !(x.is_finite() && y.is_finite()) { if !(x.is_finite() && y.is_finite()) {
return; return;
@ -587,6 +604,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.renderer.send(CanvasMsg::LineTo(Point2D(x as f32, y as f32))).unwrap(); self.renderer.send(CanvasMsg::LineTo(Point2D(x as f32, y as f32))).unwrap();
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-quadraticcurveto
fn QuadraticCurveTo(self, cpx: f64, cpy: f64, x: f64, y: f64) { fn QuadraticCurveTo(self, cpx: f64, cpy: f64, x: f64, y: f64) {
if !(cpx.is_finite() && cpy.is_finite() && if !(cpx.is_finite() && cpy.is_finite() &&
x.is_finite() && y.is_finite()) { x.is_finite() && y.is_finite()) {
@ -597,6 +615,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
Point2D(x as f32, y as f32))).unwrap(); Point2D(x as f32, y as f32))).unwrap();
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-beziercurveto
fn BezierCurveTo(self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, x: f64, y: f64) { fn BezierCurveTo(self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, x: f64, y: f64) {
if !(cp1x.is_finite() && cp1y.is_finite() && cp2x.is_finite() && cp2y.is_finite() && if !(cp1x.is_finite() && cp1y.is_finite() && cp2x.is_finite() && cp2y.is_finite() &&
x.is_finite() && y.is_finite()) { x.is_finite() && y.is_finite()) {
@ -608,6 +627,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
Point2D(x as f32, y as f32))).unwrap(); Point2D(x as f32, y as f32))).unwrap();
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-arc
fn Arc(self, x: Finite<f64>, y: Finite<f64>, r: Finite<f64>, fn Arc(self, x: Finite<f64>, y: Finite<f64>, r: Finite<f64>,
start: Finite<f64>, end: Finite<f64>, ccw: bool) -> Fallible<()> { start: Finite<f64>, end: Finite<f64>, ccw: bool) -> Fallible<()> {
let x = *x; let x = *x;
@ -625,6 +645,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
Ok(()) Ok(())
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-arcto
fn ArcTo(self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, r: f64) -> Fallible<()> { fn ArcTo(self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, r: f64) -> Fallible<()> {
if !([cp1x, cp1y, cp2x, cp2y, r].iter().all(|x| x.is_finite())) { if !([cp1x, cp1y, cp2x, cp2y, r].iter().all(|x| x.is_finite())) {
return Ok(()); return Ok(());
@ -648,15 +669,17 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.image_smoothing_enabled.set(value); self.image_smoothing_enabled.set(value);
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
fn StrokeStyle(self) -> StringOrCanvasGradientOrCanvasPattern { fn StrokeStyle(self) -> StringOrCanvasGradientOrCanvasPattern {
// FIXME(pcwalton, #4761): This is not spec-compliant. See: // FIXME(pcwalton, #4761): This is not spec-compliant. See:
// //
// https://html.spec.whatwg.org/multipage/scripting.html#serialisation-of-a-colour // https://html.spec.whatwg.org/multipage/#serialisation-of-a-colour
let mut result = String::new(); let mut result = String::new();
self.stroke_color.get().to_css(&mut result).unwrap(); self.stroke_color.get().to_css(&mut result).unwrap();
StringOrCanvasGradientOrCanvasPattern::eString(result) StringOrCanvasGradientOrCanvasPattern::eString(result)
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
fn SetStrokeStyle(self, value: StringOrCanvasGradientOrCanvasPattern) { fn SetStrokeStyle(self, value: StringOrCanvasGradientOrCanvasPattern) {
match value { match value {
StringOrCanvasGradientOrCanvasPattern::eString(string) => { StringOrCanvasGradientOrCanvasPattern::eString(string) => {
@ -676,15 +699,17 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
} }
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
fn FillStyle(self) -> StringOrCanvasGradientOrCanvasPattern { fn FillStyle(self) -> StringOrCanvasGradientOrCanvasPattern {
// FIXME(pcwalton, #4761): This is not spec-compliant. See: // FIXME(pcwalton, #4761): This is not spec-compliant. See:
// //
// https://html.spec.whatwg.org/multipage/scripting.html#serialisation-of-a-colour // https://html.spec.whatwg.org/multipage/#serialisation-of-a-colour
let mut result = String::new(); let mut result = String::new();
self.stroke_color.get().to_css(&mut result).unwrap(); self.stroke_color.get().to_css(&mut result).unwrap();
StringOrCanvasGradientOrCanvasPattern::eString(result) StringOrCanvasGradientOrCanvasPattern::eString(result)
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
fn SetFillStyle(self, value: StringOrCanvasGradientOrCanvasPattern) { fn SetFillStyle(self, value: StringOrCanvasGradientOrCanvasPattern) {
match value { match value {
StringOrCanvasGradientOrCanvasPattern::eString(string) => { StringOrCanvasGradientOrCanvasPattern::eString(string) => {
@ -705,6 +730,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
} }
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
fn CreateImageData(self, sw: f64, sh: f64) -> Fallible<Temporary<ImageData>> { fn CreateImageData(self, sw: f64, sh: f64) -> Fallible<Temporary<ImageData>> {
if !(sw.is_finite() && sh.is_finite()) { if !(sw.is_finite() && sh.is_finite()) {
return Err(NotSupported); return Err(NotSupported);
@ -717,10 +743,12 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
Ok(ImageData::new(self.global.root().r(), sw.abs().to_u32().unwrap(), sh.abs().to_u32().unwrap(), None)) Ok(ImageData::new(self.global.root().r(), sw.abs().to_u32().unwrap(), sh.abs().to_u32().unwrap(), None))
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
fn CreateImageData_(self, imagedata: JSRef<ImageData>) -> Fallible<Temporary<ImageData>> { fn CreateImageData_(self, imagedata: JSRef<ImageData>) -> Fallible<Temporary<ImageData>> {
Ok(ImageData::new(self.global.root().r(), imagedata.Width(), imagedata.Height(), None)) Ok(ImageData::new(self.global.root().r(), imagedata.Width(), imagedata.Height(), None))
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-getimagedata
fn GetImageData(self, sx: Finite<f64>, sy: Finite<f64>, sw: Finite<f64>, sh: Finite<f64>) -> Fallible<Temporary<ImageData>> { fn GetImageData(self, sx: Finite<f64>, sy: Finite<f64>, sw: Finite<f64>, sh: Finite<f64>) -> Fallible<Temporary<ImageData>> {
let sx = *sx; let sx = *sx;
let sy = *sy; let sy = *sy;
@ -740,6 +768,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
Ok(ImageData::new(self.global.root().r(), sw.abs().to_u32().unwrap(), sh.abs().to_u32().unwrap(), Some(data))) Ok(ImageData::new(self.global.root().r(), sw.abs().to_u32().unwrap(), sh.abs().to_u32().unwrap(), Some(data)))
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
fn PutImageData(self, imagedata: JSRef<ImageData>, dx: Finite<f64>, dy: Finite<f64>) { fn PutImageData(self, imagedata: JSRef<ImageData>, dx: Finite<f64>, dy: Finite<f64>) {
let dx = *dx; let dx = *dx;
let dy = *dy; let dy = *dy;
@ -758,6 +787,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.renderer.send(CanvasMsg::PutImageData(data, image_data_rect, dirty_rect)).unwrap() self.renderer.send(CanvasMsg::PutImageData(data, image_data_rect, dirty_rect)).unwrap()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
fn PutImageData_(self, imagedata: JSRef<ImageData>, dx: Finite<f64>, dy: Finite<f64>, fn PutImageData_(self, imagedata: JSRef<ImageData>, dx: Finite<f64>, dy: Finite<f64>,
dirtyX: Finite<f64>, dirtyY: Finite<f64>, dirtyWidth: Finite<f64>, dirtyHeight: Finite<f64>) { dirtyX: Finite<f64>, dirtyY: Finite<f64>, dirtyWidth: Finite<f64>, dirtyHeight: Finite<f64>) {
let dx = *dx; let dx = *dx;
@ -782,6 +812,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
self.renderer.send(CanvasMsg::PutImageData(data, image_data_rect, dirty_rect)).unwrap() self.renderer.send(CanvasMsg::PutImageData(data, image_data_rect, dirty_rect)).unwrap()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createlineargradient
fn CreateLinearGradient(self, x0: Finite<f64>, y0: Finite<f64>, fn CreateLinearGradient(self, x0: Finite<f64>, y0: Finite<f64>,
x1: Finite<f64>, y1: Finite<f64>) -> Fallible<Temporary<CanvasGradient>> { x1: Finite<f64>, y1: Finite<f64>) -> Fallible<Temporary<CanvasGradient>> {
let x0 = *x0; let x0 = *x0;
@ -796,6 +827,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
CanvasGradientStyle::Linear(LinearGradientStyle::new(x0, y0, x1, y1, Vec::new())))) CanvasGradientStyle::Linear(LinearGradientStyle::new(x0, y0, x1, y1, Vec::new()))))
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createradialgradient
fn CreateRadialGradient(self, x0: Finite<f64>, y0: Finite<f64>, r0: Finite<f64>, fn CreateRadialGradient(self, x0: Finite<f64>, y0: Finite<f64>, r0: Finite<f64>,
x1: Finite<f64>, y1: Finite<f64>, r1: Finite<f64>) -> Fallible<Temporary<CanvasGradient>> { x1: Finite<f64>, y1: Finite<f64>, r1: Finite<f64>) -> Fallible<Temporary<CanvasGradient>> {
let x0 = *x0; let x0 = *x0;
@ -812,10 +844,12 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
CanvasGradientStyle::Radial(RadialGradientStyle::new(x0, y0, r0, x1, y1, r1, Vec::new())))) CanvasGradientStyle::Radial(RadialGradientStyle::new(x0, y0, r0, x1, y1, r1, Vec::new()))))
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth
fn LineWidth(self) -> f64 { fn LineWidth(self) -> f64 {
self.line_width.get() self.line_width.get()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth
fn SetLineWidth(self, width: f64) { fn SetLineWidth(self, width: f64) {
if !width.is_finite() || width <= 0.0 { if !width.is_finite() || width <= 0.0 {
return; return;
@ -855,10 +889,12 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
} }
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-miterlimit
fn MiterLimit(self) -> f64 { fn MiterLimit(self) -> f64 {
self.miter_limit.get() self.miter_limit.get()
} }
// https://html.spec.whatwg.org/multipage/#dom-context-2d-miterlimit
fn SetMiterLimit(self, limit: f64) { fn SetMiterLimit(self, limit: f64) {
if !limit.is_finite() || limit <= 0.0 { if !limit.is_finite() || limit <= 0.0 {
return; return;

View file

@ -22,6 +22,7 @@ use std::borrow::ToOwned;
use std::cell::Ref; use std::cell::Ref;
use std::cmp; use std::cmp;
// https://dom.spec.whatwg.org/#characterdata
#[dom_struct] #[dom_struct]
pub struct CharacterData { pub struct CharacterData {
node: Node, node: Node,

View file

@ -11,6 +11,7 @@ use dom::window::WindowHelpers;
use devtools_traits::{DevtoolsControlMsg, ConsoleMessage}; use devtools_traits::{DevtoolsControlMsg, ConsoleMessage};
use util::str::DOMString; use util::str::DOMString;
// https://developer.mozilla.org/en-US/docs/Web/API/Console
#[dom_struct] #[dom_struct]
pub struct Console { pub struct Console {
reflector_: Reflector, reflector_: Reflector,
@ -31,6 +32,7 @@ impl Console {
} }
impl<'a> ConsoleMethods for JSRef<'a, Console> { impl<'a> ConsoleMethods for JSRef<'a, Console> {
// https://developer.mozilla.org/en-US/docs/Web/API/Console/log
fn Log(self, messages: Vec<DOMString>) { fn Log(self, messages: Vec<DOMString>) {
for message in messages { for message in messages {
println!("{}", message); println!("{}", message);
@ -45,24 +47,28 @@ impl<'a> ConsoleMethods for JSRef<'a, Console> {
} }
} }
// https://developer.mozilla.org/en-US/docs/Web/API/Console/info
fn Info(self, messages: Vec<DOMString>) { fn Info(self, messages: Vec<DOMString>) {
for message in messages { for message in messages {
println!("{}", message); println!("{}", message);
} }
} }
// https://developer.mozilla.org/en-US/docs/Web/API/Console/warn
fn Warn(self, messages: Vec<DOMString>) { fn Warn(self, messages: Vec<DOMString>) {
for message in messages { for message in messages {
println!("{}", message); println!("{}", message);
} }
} }
// https://developer.mozilla.org/en-US/docs/Web/API/Console/error
fn Error(self, messages: Vec<DOMString>) { fn Error(self, messages: Vec<DOMString>) {
for message in messages { for message in messages {
println!("{}", message); println!("{}", message);
} }
} }
// https://developer.mozilla.org/en-US/docs/Web/API/Console/assert
fn Assert(self, condition: bool, message: Option<DOMString>) { fn Assert(self, condition: bool, message: Option<DOMString>) {
if !condition { if !condition {
let message = match message { let message = match message {

View file

@ -21,6 +21,7 @@ use style::properties::PropertyDeclaration;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::borrow::ToOwned; use std::borrow::ToOwned;
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
#[dom_struct] #[dom_struct]
pub struct CSSStyleDeclaration { pub struct CSSStyleDeclaration {
reflector_: Reflector, reflector_: Reflector,
@ -335,6 +336,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
self.SetPropertyValue("float".to_owned(), value) self.SetPropertyValue("float".to_owned(), value)
} }
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
fn IndexedGetter(self, index: u32, found: &mut bool) -> DOMString { fn IndexedGetter(self, index: u32, found: &mut bool) -> DOMString {
let rval = self.Item(index); let rval = self.Item(index);
*found = index < self.Length(); *found = index < self.Length();

View file

@ -15,6 +15,7 @@ use js::jsapi::JSContext;
use js::jsval::{JSVal, NullValue}; use js::jsval::{JSVal, NullValue};
use util::str::DOMString; use util::str::DOMString;
// https://dom.spec.whatwg.org/#interface-customevent
#[dom_struct] #[dom_struct]
pub struct CustomEvent { pub struct CustomEvent {
event: Event, event: Event,
@ -53,10 +54,12 @@ impl CustomEvent {
} }
impl<'a> CustomEventMethods for JSRef<'a, CustomEvent> { impl<'a> CustomEventMethods for JSRef<'a, CustomEvent> {
// https://dom.spec.whatwg.org/#dom-customevent-detail
fn Detail(self, _cx: *mut JSContext) -> JSVal { fn Detail(self, _cx: *mut JSContext) -> JSVal {
self.detail.get() self.detail.get()
} }
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent
fn InitCustomEvent(self, fn InitCustomEvent(self,
_cx: *mut JSContext, _cx: *mut JSContext,
type_: DOMString, type_: DOMString,

View file

@ -91,6 +91,7 @@ impl<'a> Drop for AutoWorkerReset<'a> {
} }
} }
// https://html.spec.whatwg.org/multipage/#dedicatedworkerglobalscope
#[dom_struct] #[dom_struct]
pub struct DedicatedWorkerGlobalScope { pub struct DedicatedWorkerGlobalScope {
workerglobalscope: WorkerGlobalScope, workerglobalscope: WorkerGlobalScope,
@ -255,6 +256,7 @@ impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for JSRef<'a, DedicatedWorkerG
} }
impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalScope> { impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalScope> {
// https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage
fn PostMessage(self, cx: *mut JSContext, message: JSVal) -> ErrorResult { fn PostMessage(self, cx: *mut JSContext, message: JSVal) -> ErrorResult {
let data = try!(StructuredCloneData::write(cx, message)); let data = try!(StructuredCloneData::write(cx, message));
let worker = self.worker.borrow().as_ref().unwrap().clone(); let worker = self.worker.borrow().as_ref().unwrap().clone();

View file

@ -97,6 +97,7 @@ pub enum IsHTMLDocument {
NonHTMLDocument, NonHTMLDocument,
} }
// https://dom.spec.whatwg.org/#document
#[dom_struct] #[dom_struct]
pub struct Document { pub struct Document {
node: Node, node: Node,
@ -1098,7 +1099,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
} }
} }
// https://www.whatwg.org/html/#dom-document-lastmodified // https://html.spec.whatwg.org/#dom-document-lastmodified
fn LastModified(self) -> DOMString { fn LastModified(self) -> DOMString {
match self.last_modified { match self.last_modified {
Some(ref t) => t.clone(), Some(ref t) => t.clone(),
@ -1118,7 +1119,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
} }
// TODO: Support root SVG namespace: https://github.com/servo/servo/issues/5315 // TODO: Support root SVG namespace: https://github.com/servo/servo/issues/5315
// https://www.whatwg.org/specs/web-apps/current-work/#document.title // https://html.spec.whatwg.org/#document.title
fn Title(self) -> DOMString { fn Title(self) -> DOMString {
let title_element = self.GetDocumentElement().root().and_then(|root| { let title_element = self.GetDocumentElement().root().and_then(|root| {
NodeCast::from_ref(root.r()).traverse_preorder().find(|node| { NodeCast::from_ref(root.r()).traverse_preorder().find(|node| {
@ -1140,7 +1141,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
} }
// TODO: Support root SVG namespace: https://github.com/servo/servo/issues/5315 // TODO: Support root SVG namespace: https://github.com/servo/servo/issues/5315
// https://www.whatwg.org/specs/web-apps/current-work/#document.title // https://html.spec.whatwg.org/#document.title
fn SetTitle(self, title: DOMString) -> ErrorResult { fn SetTitle(self, title: DOMString) -> ErrorResult {
self.GetDocumentElement().root().map(|root| { self.GetDocumentElement().root().map(|root| {
let root: JSRef<Node> = NodeCast::from_ref(root.r()); let root: JSRef<Node> = NodeCast::from_ref(root.r());
@ -1179,7 +1180,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
Ok(()) Ok(())
} }
// https://www.whatwg.org/specs/web-apps/current-work/#dom-document-head // https://html.spec.whatwg.org/#dom-document-head
fn GetHead(self) -> Option<Temporary<HTMLHeadElement>> { fn GetHead(self) -> Option<Temporary<HTMLHeadElement>> {
self.get_html_element().and_then(|root| { self.get_html_element().and_then(|root| {
let root = root.root(); let root = root.root();
@ -1191,12 +1192,12 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
}) })
} }
// https://www.whatwg.org/specs/web-apps/current-work/#dom-document-currentscript // https://html.spec.whatwg.org/#dom-document-currentscript
fn GetCurrentScript(self) -> Option<Temporary<HTMLScriptElement>> { fn GetCurrentScript(self) -> Option<Temporary<HTMLScriptElement>> {
self.current_script.get() self.current_script.get()
} }
// https://www.whatwg.org/specs/web-apps/current-work/#dom-document-body // https://html.spec.whatwg.org/#dom-document-body
fn GetBody(self) -> Option<Temporary<HTMLElement>> { fn GetBody(self) -> Option<Temporary<HTMLElement>> {
self.get_html_element().and_then(|root| { self.get_html_element().and_then(|root| {
let root = root.root(); let root = root.root();
@ -1213,7 +1214,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
}) })
} }
// https://www.whatwg.org/specs/web-apps/current-work/#dom-document-body // https://html.spec.whatwg.org/#dom-document-body
fn SetBody(self, new_body: Option<JSRef<HTMLElement>>) -> ErrorResult { fn SetBody(self, new_body: Option<JSRef<HTMLElement>>) -> ErrorResult {
// Step 1. // Step 1.
let new_body = match new_body { let new_body = match new_body {
@ -1256,7 +1257,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
Ok(()) Ok(())
} }
// https://www.whatwg.org/specs/web-apps/current-work/#dom-document-getelementsbyname // https://html.spec.whatwg.org/#dom-document-getelementsbyname
fn GetElementsByName(self, name: DOMString) -> Temporary<NodeList> { fn GetElementsByName(self, name: DOMString) -> Temporary<NodeList> {
self.create_node_list(|node| { self.create_node_list(|node| {
let element: JSRef<Element> = match ElementCast::to_ref(node) { let element: JSRef<Element> = match ElementCast::to_ref(node) {

View file

@ -18,6 +18,7 @@ use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
use dom::nodelist::NodeList; use dom::nodelist::NodeList;
use util::str::DOMString; use util::str::DOMString;
// https://dom.spec.whatwg.org/#documentfragment
#[dom_struct] #[dom_struct]
pub struct DocumentFragment { pub struct DocumentFragment {
node: Node, node: Node,

View file

@ -13,6 +13,7 @@ use util::str::DOMString;
use std::borrow::ToOwned; use std::borrow::ToOwned;
// https://dom.spec.whatwg.org/#documenttype
/// The `DOCTYPE` tag. /// The `DOCTYPE` tag.
#[dom_struct] #[dom_struct]
pub struct DocumentType { pub struct DocumentType {
@ -71,14 +72,17 @@ impl DocumentType {
} }
impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> { impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
// https://dom.spec.whatwg.org/#dom-documenttype-name
fn Name(self) -> DOMString { fn Name(self) -> DOMString {
self.name.clone() self.name.clone()
} }
// https://dom.spec.whatwg.org/#dom-documenttype-publicid
fn PublicId(self) -> DOMString { fn PublicId(self) -> DOMString {
self.public_id.clone() self.public_id.clone()
} }
// https://dom.spec.whatwg.org/#dom-documenttype-systemid
fn SystemId(self) -> DOMString { fn SystemId(self) -> DOMString {
self.system_id.clone() self.system_id.clone()
} }

View file

@ -25,6 +25,7 @@ use util::str::DOMString;
use std::borrow::ToOwned; use std::borrow::ToOwned;
// https://dom.spec.whatwg.org/#domimplementation
#[dom_struct] #[dom_struct]
pub struct DOMImplementation { pub struct DOMImplementation {
reflector_: Reflector, reflector_: Reflector,

View file

@ -497,7 +497,7 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
} }
match self.local_name.as_slice() { match self.local_name.as_slice() {
/* List of void elements from /* List of void elements from
https://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-serialization-algorithm */ https://html.spec.whatwg.org/multipage/#html-fragment-serialisation-algorithm */
"area" | "base" | "basefont" | "bgsound" | "br" | "col" | "embed" | "area" | "base" | "basefont" | "bgsound" | "br" | "col" | "embed" |
"frame" | "hr" | "img" | "input" | "keygen" | "link" | "menuitem" | "frame" | "hr" | "img" | "input" | "keygen" | "link" | "menuitem" |
"meta" | "param" | "source" | "track" | "wbr" => true, "meta" | "param" | "source" | "track" | "wbr" => true,
@ -602,10 +602,10 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
} }
pub trait FocusElementHelpers { pub trait FocusElementHelpers {
/// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area /// https://html.spec.whatwg.org/multipage/#focusable-area
fn is_focusable_area(self) -> bool; fn is_focusable_area(self) -> bool;
/// https://html.spec.whatwg.org/multipage/scripting.html#concept-element-disabled /// https://html.spec.whatwg.org/multipage/#concept-element-disabled
fn is_actually_disabled(self) -> bool; fn is_actually_disabled(self) -> bool;
} }
@ -616,7 +616,7 @@ impl<'a> FocusElementHelpers for JSRef<'a, Element> {
} }
// TODO: Check whether the element is being rendered (i.e. not hidden). // TODO: Check whether the element is being rendered (i.e. not hidden).
// TODO: Check the tabindex focus flag. // TODO: Check the tabindex focus flag.
// https://html.spec.whatwg.org/multipage/interaction.html#specially-focusable // https://html.spec.whatwg.org/multipage/#specially-focusable
let node: JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(self);
match node.type_id() { match node.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) |
@ -1481,8 +1481,7 @@ impl<'a> style::node::TElement<'a> for JSRef<'a, Element> {
// FIXME: This is HTML only. // FIXME: This is HTML only.
let node: JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(self);
match node.type_id() { match node.type_id() {
// https://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html# // https://html.spec.whatwg.org/multipage/#selector-link
// selector-link
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => self.get_attr(&ns!(""), &atom!("href")), NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => self.get_attr(&ns!(""), &atom!("href")),
@ -1514,7 +1513,7 @@ impl<'a> style::node::TElement<'a> for JSRef<'a, Element> {
fn get_focus_state(self) -> bool { fn get_focus_state(self) -> bool {
// TODO: Also check whether the top-level browsing context has the system focus, // TODO: Also check whether the top-level browsing context has the system focus,
// and whether this element is a browsing context container. // and whether this element is a browsing context container.
// https://html.spec.whatwg.org/multipage/scripting.html#selector-focus // https://html.spec.whatwg.org/multipage/#selector-focus
let node: JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(self);
node.get_focus_state() node.get_focus_state()
} }
@ -1629,7 +1628,7 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
node.set_flag(CLICK_IN_PROGRESS, click) node.set_flag(CLICK_IN_PROGRESS, click)
} }
// https://html.spec.whatwg.org/multipage/interaction.html#nearest-activatable-element // https://html.spec.whatwg.org/multipage/#nearest-activatable-element
fn nearest_activable_element(self) -> Option<Temporary<Element>> { fn nearest_activable_element(self) -> Option<Temporary<Element>> {
match self.as_maybe_activatable() { match self.as_maybe_activatable() {
Some(el) => Some(Temporary::from_rooted(el.as_element().root().r())), Some(el) => Some(Temporary::from_rooted(el.as_element().root().r())),
@ -1650,7 +1649,7 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
/// Please call this method *only* for real click events /// Please call this method *only* for real click events
/// ///
/// https://html.spec.whatwg.org/multipage/interaction.html#run-authentic-click-activation-steps /// https://html.spec.whatwg.org/multipage/#run-authentic-click-activation-steps
/// ///
/// Use an element's synthetic click activation (or handle_event) for any script-triggered clicks. /// Use an element's synthetic click activation (or handle_event) for any script-triggered clicks.
/// If the spec says otherwise, check with Manishearth first /// If the spec says otherwise, check with Manishearth first

View file

@ -73,14 +73,17 @@ impl<'a> ImageDataHelpers for JSRef<'a, ImageData> {
} }
impl<'a> ImageDataMethods for JSRef<'a, ImageData> { impl<'a> ImageDataMethods for JSRef<'a, ImageData> {
// https://html.spec.whatwg.org/multipage/#dom-imagedata-width
fn Width(self) -> u32 { fn Width(self) -> u32 {
self.width self.width
} }
// https://html.spec.whatwg.org/multipage/#dom-imagedata-height
fn Height(self) -> u32 { fn Height(self) -> u32 {
self.height self.height
} }
// https://html.spec.whatwg.org/multipage/#dom-imagedata-data
fn Data(self, _: *mut JSContext) -> *mut JSObject { fn Data(self, _: *mut JSContext) -> *mut JSObject {
self.data self.data
} }

View file

@ -42,22 +42,27 @@ impl<'a> LocationMethods for JSRef<'a, Location> {
self.window.root().r().load_url(url); self.window.root().r().load_url(url);
} }
// https://url.spec.whatwg.org/#dom-urlutils-href
fn Href(self) -> USVString { fn Href(self) -> USVString {
UrlHelper::Href(&self.get_url()) UrlHelper::Href(&self.get_url())
} }
// https://url.spec.whatwg.org/#dom-urlutils-pathname
fn Pathname(self) -> USVString { fn Pathname(self) -> USVString {
UrlHelper::Pathname(&self.get_url()) UrlHelper::Pathname(&self.get_url())
} }
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
fn Stringify(self) -> DOMString { fn Stringify(self) -> DOMString {
self.Href().0 self.Href().0
} }
// https://url.spec.whatwg.org/#dom-urlutils-search
fn Search(self) -> USVString { fn Search(self) -> USVString {
UrlHelper::Search(&self.get_url()) UrlHelper::Search(&self.get_url())
} }
// https://url.spec.whatwg.org/#dom-urlutils-hash
fn Hash(self) -> USVString { fn Hash(self) -> USVString {
UrlHelper::Hash(&self.get_url()) UrlHelper::Hash(&self.get_url())
} }

View file

@ -11,10 +11,12 @@ use std::borrow::ToOwned;
pub struct UrlHelper; pub struct UrlHelper;
impl UrlHelper { impl UrlHelper {
// https://url.spec.whatwg.org/#dom-urlutils-href
pub fn Href(url: &Url) -> USVString { pub fn Href(url: &Url) -> USVString {
USVString(url.serialize()) USVString(url.serialize())
} }
// https://url.spec.whatwg.org/#dom-urlutils-search
pub fn Search(url: &Url) -> USVString { pub fn Search(url: &Url) -> USVString {
USVString(match url.query { USVString(match url.query {
None => "".to_owned(), None => "".to_owned(),
@ -23,6 +25,7 @@ impl UrlHelper {
}) })
} }
// https://url.spec.whatwg.org/#dom-urlutils-hash
pub fn Hash(url: &Url) -> USVString { pub fn Hash(url: &Url) -> USVString {
USVString(match url.fragment { USVString(match url.fragment {
None => "".to_owned(), None => "".to_owned(),
@ -31,8 +34,8 @@ impl UrlHelper {
}) })
} }
// https://url.spec.whatwg.org/#dom-urlutils-pathname
pub fn Pathname(url: &Url) -> USVString { pub fn Pathname(url: &Url) -> USVString {
// https://url.spec.whatwg.org/#dom-urlutils-pathname
// FIXME: Url null check is skipped for now // FIXME: Url null check is skipped for now
USVString(match url.scheme_data { USVString(match url.scheme_data {
SchemeData::NonRelative(ref scheme_data) => scheme_data.clone(), SchemeData::NonRelative(ref scheme_data) => scheme_data.clone(),
@ -40,7 +43,7 @@ impl UrlHelper {
}) })
} }
/// https://html.spec.whatwg.org/multipage/#same-origin // https://html.spec.whatwg.org/multipage/#same-origin
pub fn SameOrigin(urlA: &Url, urlB: &Url) -> bool { pub fn SameOrigin(urlA: &Url, urlB: &Url) -> bool {
if urlA.host() != urlB.host() { if urlA.host() != urlB.host() {
return false return false

View file

@ -49,7 +49,7 @@ pub fn char_is_whitespace(c: char) -> bool {
/// A "space character" according to: /// A "space character" according to:
/// ///
/// https://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#space-character /// https://html.spec.whatwg.org/multipage/#space-character
pub static HTML_SPACE_CHARACTERS: StaticCharVec = &[ pub static HTML_SPACE_CHARACTERS: StaticCharVec = &[
'\u{0020}', '\u{0020}',
'\u{0009}', '\u{0009}',
@ -65,8 +65,8 @@ pub fn split_html_space_chars<'a>(s: &'a str) ->
} }
/// Shared implementation to parse an integer according to /// Shared implementation to parse an integer according to
/// <https://www.whatwg.org/html/#rules-for-parsing-integers> or /// <https://html.spec.whatwg.org/#rules-for-parsing-integers> or
/// <https://www.whatwg.org/html/#rules-for-parsing-non-negative-integers>. /// <https://html.spec.whatwg.org/#rules-for-parsing-non-negative-integers>
fn do_parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i64> { fn do_parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i64> {
fn is_ascii_digit(c: &char) -> bool { fn is_ascii_digit(c: &char) -> bool {
match *c { match *c {
@ -111,7 +111,7 @@ fn do_parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i64> {
} }
/// Parse an integer according to /// Parse an integer according to
/// <https://www.whatwg.org/html/#rules-for-parsing-integers>. /// <https://html.spec.whatwg.org/#rules-for-parsing-integers>.
pub fn parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i32> { pub fn parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i32> {
do_parse_integer(input).and_then(|result| { do_parse_integer(input).and_then(|result| {
result.to_i32() result.to_i32()
@ -119,7 +119,7 @@ pub fn parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i32> {
} }
/// Parse an integer according to /// Parse an integer according to
/// <https://www.whatwg.org/html/#rules-for-parsing-non-negative-integers>. /// <https://html.spec.whatwg.org/#rules-for-parsing-non-negative-integers>
pub fn parse_unsigned_integer<T: Iterator<Item=char>>(input: T) -> Option<u32> { pub fn parse_unsigned_integer<T: Iterator<Item=char>>(input: T) -> Option<u32> {
do_parse_integer(input).and_then(|result| { do_parse_integer(input).and_then(|result| {
result.to_u32() result.to_u32()