mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Make the traits for the IDL interfaces take &self
This commit is contained in:
parent
856fda7f2e
commit
709d347872
99 changed files with 1192 additions and 1192 deletions
|
@ -162,19 +162,19 @@ impl Attr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AttrMethods for &'a Attr {
|
impl AttrMethods for Attr {
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-localname
|
// https://dom.spec.whatwg.org/#dom-attr-localname
|
||||||
fn LocalName(self) -> DOMString {
|
fn LocalName(&self) -> DOMString {
|
||||||
(**self.local_name()).to_owned()
|
(**self.local_name()).to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-value
|
// https://dom.spec.whatwg.org/#dom-attr-value
|
||||||
fn Value(self) -> DOMString {
|
fn Value(&self) -> DOMString {
|
||||||
(**self.value()).to_owned()
|
(**self.value()).to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-value
|
// https://dom.spec.whatwg.org/#dom-attr-value
|
||||||
fn SetValue(self, value: DOMString) {
|
fn SetValue(&self, value: DOMString) {
|
||||||
match self.owner() {
|
match self.owner() {
|
||||||
None => *self.value.borrow_mut() = AttrValue::String(value),
|
None => *self.value.borrow_mut() = AttrValue::String(value),
|
||||||
Some(owner) => {
|
Some(owner) => {
|
||||||
|
@ -185,32 +185,32 @@ impl<'a> AttrMethods for &'a Attr {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-textcontent
|
// https://dom.spec.whatwg.org/#dom-attr-textcontent
|
||||||
fn TextContent(self) -> DOMString {
|
fn TextContent(&self) -> DOMString {
|
||||||
self.Value()
|
self.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-textcontent
|
// https://dom.spec.whatwg.org/#dom-attr-textcontent
|
||||||
fn SetTextContent(self, value: DOMString) {
|
fn SetTextContent(&self, value: DOMString) {
|
||||||
self.SetValue(value)
|
self.SetValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-nodevalue
|
// https://dom.spec.whatwg.org/#dom-attr-nodevalue
|
||||||
fn NodeValue(self) -> DOMString {
|
fn NodeValue(&self) -> DOMString {
|
||||||
self.Value()
|
self.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-nodevalue
|
// https://dom.spec.whatwg.org/#dom-attr-nodevalue
|
||||||
fn SetNodeValue(self, value: DOMString) {
|
fn SetNodeValue(&self, value: DOMString) {
|
||||||
self.SetValue(value)
|
self.SetValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-name
|
// https://dom.spec.whatwg.org/#dom-attr-name
|
||||||
fn Name(self) -> DOMString {
|
fn Name(&self) -> DOMString {
|
||||||
(*self.name).to_owned()
|
(*self.name).to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-namespaceuri
|
// https://dom.spec.whatwg.org/#dom-attr-namespaceuri
|
||||||
fn GetNamespaceURI(self) -> Option<DOMString> {
|
fn GetNamespaceURI(&self) -> Option<DOMString> {
|
||||||
let Namespace(ref atom) = self.namespace;
|
let Namespace(ref atom) = self.namespace;
|
||||||
match &**atom {
|
match &**atom {
|
||||||
"" => None,
|
"" => None,
|
||||||
|
@ -219,17 +219,17 @@ impl<'a> AttrMethods for &'a Attr {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-prefix
|
// https://dom.spec.whatwg.org/#dom-attr-prefix
|
||||||
fn GetPrefix(self) -> Option<DOMString> {
|
fn GetPrefix(&self) -> Option<DOMString> {
|
||||||
self.prefix().as_ref().map(|p| (**p).to_owned())
|
self.prefix().as_ref().map(|p| (**p).to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-ownerelement
|
// https://dom.spec.whatwg.org/#dom-attr-ownerelement
|
||||||
fn GetOwnerElement(self) -> Option<Root<Element>> {
|
fn GetOwnerElement(&self) -> Option<Root<Element>> {
|
||||||
self.owner()
|
self.owner()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-attr-specified
|
// https://dom.spec.whatwg.org/#dom-attr-specified
|
||||||
fn Specified(self) -> bool {
|
fn Specified(&self) -> bool {
|
||||||
true // Always returns true
|
true // Always returns true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4571,7 +4571,7 @@ class CGInterfaceTrait(CGThing):
|
||||||
return "".join(", %s: %s" % argument for argument in arguments)
|
return "".join(", %s: %s" % argument for argument in arguments)
|
||||||
|
|
||||||
methods = [
|
methods = [
|
||||||
CGGeneric("fn %s(self%s) -> %s;\n" % (name, fmt(arguments), rettype))
|
CGGeneric("fn %s(&self%s) -> %s;\n" % (name, fmt(arguments), rettype))
|
||||||
for name, arguments, rettype in members()
|
for name, arguments, rettype in members()
|
||||||
]
|
]
|
||||||
if methods:
|
if methods:
|
||||||
|
|
|
@ -86,9 +86,9 @@ impl Blob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BlobMethods for &'a Blob {
|
impl BlobMethods for Blob {
|
||||||
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-size
|
// https://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,
|
||||||
Some(ref bytes) => bytes.len() as u64
|
Some(ref bytes) => bytes.len() as u64
|
||||||
|
@ -96,12 +96,12 @@ impl<'a> BlobMethods for &'a Blob {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-type
|
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-type
|
||||||
fn Type(self) -> DOMString {
|
fn Type(&self) -> DOMString {
|
||||||
self.typeString.clone()
|
self.typeString.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/2006/webapi/FileAPI/#slice-method-algo
|
// https://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>) -> Root<Blob> {
|
contentType: Option<DOMString>) -> Root<Blob> {
|
||||||
let size: i64 = self.Size().to_i64().unwrap();
|
let size: i64 = self.Size().to_i64().unwrap();
|
||||||
let relativeStart: i64 = match start {
|
let relativeStart: i64 = match start {
|
||||||
|
@ -149,12 +149,12 @@ impl<'a> BlobMethods for &'a Blob {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-isClosed
|
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-isClosed
|
||||||
fn IsClosed(self) -> bool {
|
fn IsClosed(&self) -> bool {
|
||||||
self.isClosed_.get()
|
self.isClosed_.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-close
|
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-close
|
||||||
fn Close(self) {
|
fn Close(&self) {
|
||||||
// Step 1
|
// Step 1
|
||||||
if self.isClosed_.get() {
|
if self.isClosed_.get() {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -43,9 +43,9 @@ impl CanvasGradient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CanvasGradientMethods for &'a CanvasGradient {
|
impl CanvasGradientMethods for CanvasGradient {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-canvasgradient-addcolorstop
|
// https://html.spec.whatwg.org/multipage/#dom-canvasgradient-addcolorstop
|
||||||
fn AddColorStop(self, offset: Finite<f64>, color: String) -> ErrorResult {
|
fn AddColorStop(&self, offset: Finite<f64>, color: String) -> ErrorResult {
|
||||||
if *offset < 0f64 || *offset > 1f64 {
|
if *offset < 0f64 || *offset > 1f64 {
|
||||||
return Err(IndexSize);
|
return Err(IndexSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -446,20 +446,20 @@ impl LayoutCanvasRenderingContext2DHelpers for LayoutJS<CanvasRenderingContext2D
|
||||||
// Restricted values are guarded in glue code. Therefore we need not add a guard.
|
// Restricted values are guarded in glue code. Therefore we need not add a guard.
|
||||||
//
|
//
|
||||||
// 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 &'a CanvasRenderingContext2D {
|
impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-canvas
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-canvas
|
||||||
fn Canvas(self) -> Root<HTMLCanvasElement> {
|
fn Canvas(&self) -> Root<HTMLCanvasElement> {
|
||||||
self.canvas.root()
|
self.canvas.root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-save
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-save
|
||||||
fn Save(self) {
|
fn Save(&self) {
|
||||||
self.saved_states.borrow_mut().push(self.state.borrow().clone());
|
self.saved_states.borrow_mut().push(self.state.borrow().clone());
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SaveContext)).unwrap();
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SaveContext)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-restore
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-restore
|
||||||
fn Restore(self) {
|
fn Restore(&self) {
|
||||||
let mut saved_states = self.saved_states.borrow_mut();
|
let mut saved_states = self.saved_states.borrow_mut();
|
||||||
if let Some(state) = saved_states.pop() {
|
if let Some(state) = saved_states.pop() {
|
||||||
self.state.borrow_mut().clone_from(&state);
|
self.state.borrow_mut().clone_from(&state);
|
||||||
|
@ -468,7 +468,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-scale
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -479,7 +479,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-rotate
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-rotate
|
||||||
fn Rotate(self, angle: f64) {
|
fn Rotate(&self, angle: f64) {
|
||||||
if angle == 0.0 || !angle.is_finite() {
|
if angle == 0.0 || !angle.is_finite() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-translate
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-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()) {
|
||||||
return;
|
return;
|
||||||
|
@ -521,7 +521,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
// 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()) {
|
||||||
return;
|
return;
|
||||||
|
@ -537,19 +537,19 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-resettransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-resettransform
|
||||||
fn ResetTransform(self) {
|
fn ResetTransform(&self) {
|
||||||
self.state.borrow_mut().transform = Matrix2D::identity();
|
self.state.borrow_mut().transform = Matrix2D::identity();
|
||||||
self.update_transform()
|
self.update_transform()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha
|
||||||
fn GlobalAlpha(self) -> f64 {
|
fn GlobalAlpha(&self) -> f64 {
|
||||||
let state = self.state.borrow();
|
let state = self.state.borrow();
|
||||||
state.global_alpha
|
state.global_alpha
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -561,7 +561,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalcompositeoperation
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalcompositeoperation
|
||||||
fn GlobalCompositeOperation(self) -> DOMString {
|
fn GlobalCompositeOperation(&self) -> DOMString {
|
||||||
let state = self.state.borrow();
|
let state = self.state.borrow();
|
||||||
match state.global_composition {
|
match state.global_composition {
|
||||||
CompositionOrBlending::Composition(op) => op.to_str().to_owned(),
|
CompositionOrBlending::Composition(op) => op.to_str().to_owned(),
|
||||||
|
@ -570,7 +570,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalcompositeoperation
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalcompositeoperation
|
||||||
fn SetGlobalCompositeOperation(self, op_str: DOMString) {
|
fn SetGlobalCompositeOperation(&self, op_str: DOMString) {
|
||||||
if let Some(op) = CompositionOrBlending::from_str(&op_str) {
|
if let Some(op) = CompositionOrBlending::from_str(&op_str) {
|
||||||
self.state.borrow_mut().global_composition = op;
|
self.state.borrow_mut().global_composition = op;
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
|
@ -580,7 +580,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-fillrect
|
// 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.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::FillRect(rect))).unwrap();
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::FillRect(rect))).unwrap();
|
||||||
self.mark_as_dirty();
|
self.mark_as_dirty();
|
||||||
|
@ -588,7 +588,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-clearrect
|
// 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.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::Canvas2d(Canvas2dMsg::ClearRect(rect)))
|
.send(CanvasMsg::Canvas2d(Canvas2dMsg::ClearRect(rect)))
|
||||||
|
@ -598,7 +598,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokerect
|
// 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.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::Canvas2d(Canvas2dMsg::StrokeRect(rect)))
|
.send(CanvasMsg::Canvas2d(Canvas2dMsg::StrokeRect(rect)))
|
||||||
|
@ -608,36 +608,36 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-beginpath
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-beginpath
|
||||||
fn BeginPath(self) {
|
fn BeginPath(&self) {
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::BeginPath)).unwrap();
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::BeginPath)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-closepath
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-closepath
|
||||||
fn ClosePath(self) {
|
fn ClosePath(&self) {
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::ClosePath)).unwrap();
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::ClosePath)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-fill
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-fill
|
||||||
fn Fill(self, _: CanvasWindingRule) {
|
fn Fill(&self, _: CanvasWindingRule) {
|
||||||
// TODO: Process winding rule
|
// TODO: Process winding rule
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::Fill)).unwrap();
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::Fill)).unwrap();
|
||||||
self.mark_as_dirty();
|
self.mark_as_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-stroke
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-stroke
|
||||||
fn Stroke(self) {
|
fn Stroke(&self) {
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::Stroke)).unwrap();
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::Stroke)).unwrap();
|
||||||
self.mark_as_dirty();
|
self.mark_as_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-clip
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-clip
|
||||||
fn Clip(self, _: CanvasWindingRule) {
|
fn Clip(&self, _: CanvasWindingRule) {
|
||||||
// TODO: Process winding rule
|
// TODO: Process winding rule
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::Clip)).unwrap();
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::Clip)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#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()) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -647,7 +647,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#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() &&
|
||||||
dw.is_finite() && dh.is_finite()) {
|
dw.is_finite() && dh.is_finite()) {
|
||||||
|
@ -658,7 +658,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#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<()> {
|
||||||
if !(sx.is_finite() && sy.is_finite() && sw.is_finite() && sh.is_finite() &&
|
if !(sx.is_finite() && sy.is_finite() && sw.is_finite() && sh.is_finite() &&
|
||||||
|
@ -670,7 +670,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-moveto
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -682,7 +682,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-lineto
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -694,7 +694,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-rect
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-rect
|
||||||
fn Rect(self, x: f64, y: f64, width: f64, height: f64) {
|
fn Rect(&self, x: f64, y: f64, width: f64, height: f64) {
|
||||||
if [x, y, width, height].iter().all(|val| val.is_finite()) {
|
if [x, y, width, height].iter().all(|val| val.is_finite()) {
|
||||||
let rect = Rect::new(Point2D::new(x as f32, y as f32),
|
let rect = Rect::new(Point2D::new(x as f32, y as f32),
|
||||||
Size2D::new(width as f32, height as f32));
|
Size2D::new(width as f32, height as f32));
|
||||||
|
@ -704,7 +704,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-quadraticcurveto
|
// 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()) {
|
||||||
return;
|
return;
|
||||||
|
@ -718,7 +718,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-beziercurveto
|
// 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()) {
|
||||||
return;
|
return;
|
||||||
|
@ -733,7 +733,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-arc
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-arc
|
||||||
fn Arc(self, x: f64, y: f64, r: f64,
|
fn Arc(&self, x: f64, y: f64, r: f64,
|
||||||
start: f64, end: f64, ccw: bool) -> Fallible<()> {
|
start: f64, end: f64, ccw: bool) -> Fallible<()> {
|
||||||
if !([x, y, r, start, end].iter().all(|x| x.is_finite())) {
|
if !([x, y, r, start, end].iter().all(|x| x.is_finite())) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -753,7 +753,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-arcto
|
// 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(());
|
||||||
}
|
}
|
||||||
|
@ -771,18 +771,18 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-context-2d-imagesmoothingenabled
|
// https://html.spec.whatwg.org/#dom-context-2d-imagesmoothingenabled
|
||||||
fn ImageSmoothingEnabled(self) -> bool {
|
fn ImageSmoothingEnabled(&self) -> bool {
|
||||||
let state = self.state.borrow();
|
let state = self.state.borrow();
|
||||||
state.image_smoothing_enabled
|
state.image_smoothing_enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-context-2d-imagesmoothingenabled
|
// https://html.spec.whatwg.org/#dom-context-2d-imagesmoothingenabled
|
||||||
fn SetImageSmoothingEnabled(self, value: bool) -> () {
|
fn SetImageSmoothingEnabled(&self, value: bool) -> () {
|
||||||
self.state.borrow_mut().image_smoothing_enabled = value;
|
self.state.borrow_mut().image_smoothing_enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||||
fn StrokeStyle(self) -> StringOrCanvasGradientOrCanvasPattern {
|
fn StrokeStyle(&self) -> StringOrCanvasGradientOrCanvasPattern {
|
||||||
match self.state.borrow().stroke_style {
|
match self.state.borrow().stroke_style {
|
||||||
CanvasFillOrStrokeStyle::Color(ref rgba) => {
|
CanvasFillOrStrokeStyle::Color(ref rgba) => {
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
|
@ -796,7 +796,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
// 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) => {
|
||||||
match parse_color(&string) {
|
match parse_color(&string) {
|
||||||
|
@ -822,7 +822,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||||
fn FillStyle(self) -> StringOrCanvasGradientOrCanvasPattern {
|
fn FillStyle(&self) -> StringOrCanvasGradientOrCanvasPattern {
|
||||||
match self.state.borrow().fill_style {
|
match self.state.borrow().fill_style {
|
||||||
CanvasFillOrStrokeStyle::Color(ref rgba) => {
|
CanvasFillOrStrokeStyle::Color(ref rgba) => {
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
|
@ -836,7 +836,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
// 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) => {
|
||||||
if let Ok(rgba) = parse_color(&string) {
|
if let Ok(rgba) = parse_color(&string) {
|
||||||
|
@ -862,7 +862,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||||
fn CreateImageData(self, sw: Finite<f64>, sh: Finite<f64>) -> Fallible<Root<ImageData>> {
|
fn CreateImageData(&self, sw: Finite<f64>, sh: Finite<f64>) -> Fallible<Root<ImageData>> {
|
||||||
if *sw == 0.0 || *sh == 0.0 {
|
if *sw == 0.0 || *sh == 0.0 {
|
||||||
return Err(IndexSize)
|
return Err(IndexSize)
|
||||||
}
|
}
|
||||||
|
@ -873,12 +873,12 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||||
fn CreateImageData_(self, imagedata: &ImageData) -> Fallible<Root<ImageData>> {
|
fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible<Root<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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-getimagedata
|
||||||
fn GetImageData(self,
|
fn GetImageData(&self,
|
||||||
sx: Finite<f64>,
|
sx: Finite<f64>,
|
||||||
sy: Finite<f64>,
|
sy: Finite<f64>,
|
||||||
sw: Finite<f64>,
|
sw: Finite<f64>,
|
||||||
|
@ -928,13 +928,13 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||||
fn PutImageData(self, imagedata: &ImageData, dx: Finite<f64>, dy: Finite<f64>) {
|
fn PutImageData(&self, imagedata: &ImageData, dx: Finite<f64>, dy: Finite<f64>) {
|
||||||
self.PutImageData_(imagedata, dx, dy, Finite::wrap(0f64), Finite::wrap(0f64),
|
self.PutImageData_(imagedata, dx, dy, Finite::wrap(0f64), Finite::wrap(0f64),
|
||||||
Finite::wrap(imagedata.Width() as f64), Finite::wrap(imagedata.Height() as f64))
|
Finite::wrap(imagedata.Width() as f64), Finite::wrap(imagedata.Height() as f64))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||||
fn PutImageData_(self, imagedata: &ImageData, dx: Finite<f64>, dy: Finite<f64>,
|
fn PutImageData_(&self, imagedata: &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 data = imagedata.get_data_array(&self.global.root().r());
|
let data = imagedata.get_data_array(&self.global.root().r());
|
||||||
let offset = Point2D::new(*dx, *dy);
|
let offset = Point2D::new(*dx, *dy);
|
||||||
|
@ -949,14 +949,14 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createlineargradient
|
// 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>) -> Root<CanvasGradient> {
|
x1: Finite<f64>, y1: Finite<f64>) -> Root<CanvasGradient> {
|
||||||
CanvasGradient::new(self.global.root().r(),
|
CanvasGradient::new(self.global.root().r(),
|
||||||
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
|
// 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>)
|
x1: Finite<f64>, y1: Finite<f64>, r1: Finite<f64>)
|
||||||
-> Fallible<Root<CanvasGradient>> {
|
-> Fallible<Root<CanvasGradient>> {
|
||||||
if *r0 < 0. || *r1 < 0. {
|
if *r0 < 0. || *r1 < 0. {
|
||||||
|
@ -969,7 +969,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern
|
||||||
fn CreatePattern(self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D,
|
fn CreatePattern(&self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D,
|
||||||
repetition: DOMString) -> Fallible<Root<CanvasPattern>> {
|
repetition: DOMString) -> Fallible<Root<CanvasPattern>> {
|
||||||
let (image_data, image_size) = match image {
|
let (image_data, image_size) = match image {
|
||||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => {
|
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => {
|
||||||
|
@ -1019,13 +1019,13 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth
|
||||||
fn LineWidth(self) -> f64 {
|
fn LineWidth(&self) -> f64 {
|
||||||
let state = self.state.borrow();
|
let state = self.state.borrow();
|
||||||
state.line_width
|
state.line_width
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -1037,7 +1037,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linecap
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linecap
|
||||||
fn LineCap(self) -> DOMString {
|
fn LineCap(&self) -> DOMString {
|
||||||
let state = self.state.borrow();
|
let state = self.state.borrow();
|
||||||
match state.line_cap {
|
match state.line_cap {
|
||||||
LineCapStyle::Butt => "butt".to_owned(),
|
LineCapStyle::Butt => "butt".to_owned(),
|
||||||
|
@ -1047,7 +1047,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linecap
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linecap
|
||||||
fn SetLineCap(self, cap_str: DOMString) {
|
fn SetLineCap(&self, cap_str: DOMString) {
|
||||||
if let Some(cap) = LineCapStyle::from_str(&cap_str) {
|
if let Some(cap) = LineCapStyle::from_str(&cap_str) {
|
||||||
self.state.borrow_mut().line_cap = cap;
|
self.state.borrow_mut().line_cap = cap;
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SetLineCap(cap))).unwrap()
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SetLineCap(cap))).unwrap()
|
||||||
|
@ -1055,7 +1055,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linejoin
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linejoin
|
||||||
fn LineJoin(self) -> DOMString {
|
fn LineJoin(&self) -> DOMString {
|
||||||
let state = self.state.borrow();
|
let state = self.state.borrow();
|
||||||
match state.line_join {
|
match state.line_join {
|
||||||
LineJoinStyle::Round => "round".to_owned(),
|
LineJoinStyle::Round => "round".to_owned(),
|
||||||
|
@ -1065,7 +1065,7 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linejoin
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-linejoin
|
||||||
fn SetLineJoin(self, join_str: DOMString) {
|
fn SetLineJoin(&self, join_str: DOMString) {
|
||||||
if let Some(join) = LineJoinStyle::from_str(&join_str) {
|
if let Some(join) = LineJoinStyle::from_str(&join_str) {
|
||||||
self.state.borrow_mut().line_join = join;
|
self.state.borrow_mut().line_join = join;
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SetLineJoin(join))).unwrap()
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SetLineJoin(join))).unwrap()
|
||||||
|
@ -1073,13 +1073,13 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-miterlimit
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-miterlimit
|
||||||
fn MiterLimit(self) -> f64 {
|
fn MiterLimit(&self) -> f64 {
|
||||||
let state = self.state.borrow();
|
let state = self.state.borrow();
|
||||||
state.miter_limit
|
state.miter_limit
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-miterlimit
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -1091,12 +1091,12 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsetx
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsetx
|
||||||
fn ShadowOffsetX(self) -> f64 {
|
fn ShadowOffsetX(&self) -> f64 {
|
||||||
self.state.borrow().shadow_offset_x
|
self.state.borrow().shadow_offset_x
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsetx
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsetx
|
||||||
fn SetShadowOffsetX(self, value: f64) {
|
fn SetShadowOffsetX(&self, value: f64) {
|
||||||
if !value.is_finite() || value == self.state.borrow().shadow_offset_x {
|
if !value.is_finite() || value == self.state.borrow().shadow_offset_x {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1105,12 +1105,12 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsety
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsety
|
||||||
fn ShadowOffsetY(self) -> f64 {
|
fn ShadowOffsetY(&self) -> f64 {
|
||||||
self.state.borrow().shadow_offset_y
|
self.state.borrow().shadow_offset_y
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsety
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsety
|
||||||
fn SetShadowOffsetY(self, value: f64) {
|
fn SetShadowOffsetY(&self, value: f64) {
|
||||||
if !value.is_finite() || value == self.state.borrow().shadow_offset_y {
|
if !value.is_finite() || value == self.state.borrow().shadow_offset_y {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1119,12 +1119,12 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowblur
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowblur
|
||||||
fn ShadowBlur(self) -> f64 {
|
fn ShadowBlur(&self) -> f64 {
|
||||||
self.state.borrow().shadow_blur
|
self.state.borrow().shadow_blur
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowblur
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowblur
|
||||||
fn SetShadowBlur(self, value: f64) {
|
fn SetShadowBlur(&self, value: f64) {
|
||||||
if !value.is_finite() || value < 0f64 || value == self.state.borrow().shadow_blur {
|
if !value.is_finite() || value < 0f64 || value == self.state.borrow().shadow_blur {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1133,14 +1133,14 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor
|
||||||
fn ShadowColor(self) -> DOMString {
|
fn ShadowColor(&self) -> DOMString {
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
serialize(&self.state.borrow().shadow_color, &mut result).unwrap();
|
serialize(&self.state.borrow().shadow_color, &mut result).unwrap();
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor
|
||||||
fn SetShadowColor(self, value: DOMString) {
|
fn SetShadowColor(&self, value: DOMString) {
|
||||||
if let Ok(color) = parse_color(&value) {
|
if let Ok(color) = parse_color(&value) {
|
||||||
self.state.borrow_mut().shadow_color = color;
|
self.state.borrow_mut().shadow_color = color;
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
|
|
|
@ -47,24 +47,24 @@ impl CharacterData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CharacterDataMethods for &'a CharacterData {
|
impl CharacterDataMethods for CharacterData {
|
||||||
// https://dom.spec.whatwg.org/#dom-characterdata-data
|
// https://dom.spec.whatwg.org/#dom-characterdata-data
|
||||||
fn Data(self) -> DOMString {
|
fn Data(&self) -> DOMString {
|
||||||
self.data.borrow().clone()
|
self.data.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-characterdata-data
|
// https://dom.spec.whatwg.org/#dom-characterdata-data
|
||||||
fn SetData(self, data: DOMString) {
|
fn SetData(&self, data: DOMString) {
|
||||||
*self.data.borrow_mut() = data;
|
*self.data.borrow_mut() = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-characterdata-length
|
// https://dom.spec.whatwg.org/#dom-characterdata-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
self.data.borrow().chars().count() as u32
|
self.data.borrow().chars().count() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-characterdata-substringdataoffset-count
|
// https://dom.spec.whatwg.org/#dom-characterdata-substringdataoffset-count
|
||||||
fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> {
|
fn SubstringData(&self, offset: u32, count: u32) -> Fallible<DOMString> {
|
||||||
let data = self.data.borrow();
|
let data = self.data.borrow();
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let length = data.chars().count() as u32;
|
let length = data.chars().count() as u32;
|
||||||
|
@ -78,22 +78,22 @@ impl<'a> CharacterDataMethods for &'a CharacterData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-characterdata-appenddatadata
|
// https://dom.spec.whatwg.org/#dom-characterdata-appenddatadata
|
||||||
fn AppendData(self, data: DOMString) {
|
fn AppendData(&self, data: DOMString) {
|
||||||
self.append_data(&*data);
|
self.append_data(&*data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-characterdata-insertdataoffset-data
|
// https://dom.spec.whatwg.org/#dom-characterdata-insertdataoffset-data
|
||||||
fn InsertData(self, offset: u32, arg: DOMString) -> ErrorResult {
|
fn InsertData(&self, offset: u32, arg: DOMString) -> ErrorResult {
|
||||||
self.ReplaceData(offset, 0, arg)
|
self.ReplaceData(offset, 0, arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-characterdata-deletedataoffset-count
|
// https://dom.spec.whatwg.org/#dom-characterdata-deletedataoffset-count
|
||||||
fn DeleteData(self, offset: u32, count: u32) -> ErrorResult {
|
fn DeleteData(&self, offset: u32, count: u32) -> ErrorResult {
|
||||||
self.ReplaceData(offset, count, "".to_owned())
|
self.ReplaceData(offset, count, "".to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-characterdata-replacedataoffset-count-data
|
// https://dom.spec.whatwg.org/#dom-characterdata-replacedataoffset-count-data
|
||||||
fn ReplaceData(self, offset: u32, count: u32, arg: DOMString) -> ErrorResult {
|
fn ReplaceData(&self, offset: u32, count: u32, arg: DOMString) -> ErrorResult {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let length = self.data.borrow().chars().count() as u32;
|
let length = self.data.borrow().chars().count() as u32;
|
||||||
if offset > length {
|
if offset > length {
|
||||||
|
@ -116,34 +116,34 @@ impl<'a> CharacterDataMethods for &'a CharacterData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-before
|
// https://dom.spec.whatwg.org/#dom-childnode-before
|
||||||
fn Before(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Before(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).before(nodes)
|
NodeCast::from_ref(self).before(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-after
|
// https://dom.spec.whatwg.org/#dom-childnode-after
|
||||||
fn After(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn After(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).after(nodes)
|
NodeCast::from_ref(self).after(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
|
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
|
||||||
fn ReplaceWith(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn ReplaceWith(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).replace_with(nodes)
|
NodeCast::from_ref(self).replace_with(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-remove
|
// https://dom.spec.whatwg.org/#dom-childnode-remove
|
||||||
fn Remove(self) {
|
fn Remove(&self) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.remove_self();
|
node.remove_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
||||||
fn GetPreviousElementSibling(self) -> Option<Root<Element>> {
|
fn GetPreviousElementSibling(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).preceding_siblings()
|
NodeCast::from_ref(self).preceding_siblings()
|
||||||
.filter_map(ElementCast::to_root).next()
|
.filter_map(ElementCast::to_root).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
||||||
fn GetNextElementSibling(self) -> Option<Root<Element>> {
|
fn GetNextElementSibling(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).following_siblings()
|
NodeCast::from_ref(self).following_siblings()
|
||||||
.filter_map(ElementCast::to_root).next()
|
.filter_map(ElementCast::to_root).next()
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,19 +68,19 @@ impl CloseEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CloseEventMethods for &'a CloseEvent {
|
impl CloseEventMethods for CloseEvent {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-closeevent-wasclean
|
// https://html.spec.whatwg.org/multipage/#dom-closeevent-wasclean
|
||||||
fn WasClean(self) -> bool {
|
fn WasClean(&self) -> bool {
|
||||||
self.wasClean
|
self.wasClean
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-closeevent-code
|
// https://html.spec.whatwg.org/multipage/#dom-closeevent-code
|
||||||
fn Code(self) -> u16 {
|
fn Code(&self) -> u16 {
|
||||||
self.code
|
self.code
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-closeevent-reason
|
// https://html.spec.whatwg.org/multipage/#dom-closeevent-reason
|
||||||
fn Reason(self) -> DOMString {
|
fn Reason(&self) -> DOMString {
|
||||||
self.reason.clone()
|
self.reason.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ impl Console {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ConsoleMethods for &'a Console {
|
impl ConsoleMethods for Console {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/log
|
// 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);
|
||||||
propagate_console_msg(&self, prepare_message(LogLevel::Log, message));
|
propagate_console_msg(&self, prepare_message(LogLevel::Log, message));
|
||||||
|
@ -40,7 +40,7 @@ impl<'a> ConsoleMethods for &'a Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
||||||
fn Debug(self, messages: Vec<DOMString>) {
|
fn Debug(&self, messages: Vec<DOMString>) {
|
||||||
for message in messages {
|
for message in messages {
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
propagate_console_msg(&self, prepare_message(LogLevel::Debug, message));
|
propagate_console_msg(&self, prepare_message(LogLevel::Debug, message));
|
||||||
|
@ -48,7 +48,7 @@ impl<'a> ConsoleMethods for &'a Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/info
|
// 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);
|
||||||
propagate_console_msg(&self, prepare_message(LogLevel::Info, message));
|
propagate_console_msg(&self, prepare_message(LogLevel::Info, message));
|
||||||
|
@ -56,7 +56,7 @@ impl<'a> ConsoleMethods for &'a Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/warn
|
// 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);
|
||||||
propagate_console_msg(&self, prepare_message(LogLevel::Warn, message));
|
propagate_console_msg(&self, prepare_message(LogLevel::Warn, message));
|
||||||
|
@ -64,7 +64,7 @@ impl<'a> ConsoleMethods for &'a Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/error
|
// 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);
|
||||||
propagate_console_msg(&self, prepare_message(LogLevel::Error, message));
|
propagate_console_msg(&self, prepare_message(LogLevel::Error, message));
|
||||||
|
@ -72,7 +72,7 @@ impl<'a> ConsoleMethods for &'a Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/assert
|
// 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 {
|
||||||
Some(ref message) => &**message,
|
Some(ref message) => &**message,
|
||||||
|
|
|
@ -40,10 +40,10 @@ impl Crypto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CryptoMethods for &'a Crypto {
|
impl CryptoMethods for Crypto {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#Crypto-method-getRandomValues
|
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#Crypto-method-getRandomValues
|
||||||
fn GetRandomValues(self, _cx: *mut JSContext, input: *mut JSObject)
|
fn GetRandomValues(&self, _cx: *mut JSContext, input: *mut JSObject)
|
||||||
-> Fallible<*mut JSObject> {
|
-> Fallible<*mut JSObject> {
|
||||||
let mut length = 0;
|
let mut length = 0;
|
||||||
let mut data = ptr::null_mut();
|
let mut data = ptr::null_mut();
|
||||||
|
|
|
@ -39,10 +39,10 @@ pub enum CSSModificationAccess {
|
||||||
macro_rules! css_properties(
|
macro_rules! css_properties(
|
||||||
( $([$getter:ident, $setter:ident, $cssprop:expr]),* ) => (
|
( $([$getter:ident, $setter:ident, $cssprop:expr]),* ) => (
|
||||||
$(
|
$(
|
||||||
fn $getter(self) -> DOMString {
|
fn $getter(&self) -> DOMString {
|
||||||
self.GetPropertyValue($cssprop.to_owned())
|
self.GetPropertyValue($cssprop.to_owned())
|
||||||
}
|
}
|
||||||
fn $setter(self, value: DOMString) -> ErrorResult {
|
fn $setter(&self, value: DOMString) -> ErrorResult {
|
||||||
self.SetPropertyValue($cssprop.to_owned(), value)
|
self.SetPropertyValue($cssprop.to_owned(), value)
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
@ -90,9 +90,9 @@ impl CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
|
impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-length
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
let elem = ElementCast::from_ref(owner.r());
|
let elem = ElementCast::from_ref(owner.r());
|
||||||
let len = match *elem.style_attribute().borrow() {
|
let len = match *elem.style_attribute().borrow() {
|
||||||
|
@ -103,7 +103,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-item
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-item
|
||||||
fn Item(self, index: u32) -> DOMString {
|
fn Item(&self, index: u32) -> DOMString {
|
||||||
let index = index as usize;
|
let index = index as usize;
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
let elem = ElementCast::from_ref(owner.r());
|
let elem = ElementCast::from_ref(owner.r());
|
||||||
|
@ -124,7 +124,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
||||||
fn GetPropertyValue(self, property: DOMString) -> DOMString {
|
fn GetPropertyValue(&self, property: DOMString) -> DOMString {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
|
@ -167,7 +167,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
|
||||||
fn GetPropertyPriority(self, property: DOMString) -> DOMString {
|
fn GetPropertyPriority(&self, property: DOMString) -> DOMString {
|
||||||
// Step 1
|
// Step 1
|
||||||
let property = Atom::from_slice(&property.to_ascii_lowercase());
|
let property = Atom::from_slice(&property.to_ascii_lowercase());
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
|
||||||
fn SetProperty(self, property: DOMString, value: DOMString,
|
fn SetProperty(&self, property: DOMString, value: DOMString,
|
||||||
priority: DOMString) -> ErrorResult {
|
priority: DOMString) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if self.readonly {
|
if self.readonly {
|
||||||
|
@ -250,7 +250,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertypriority
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertypriority
|
||||||
fn SetPropertyPriority(self, property: DOMString, priority: DOMString) -> ErrorResult {
|
fn SetPropertyPriority(&self, property: DOMString, priority: DOMString) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if self.readonly {
|
if self.readonly {
|
||||||
return Err(Error::NoModificationAllowed);
|
return Err(Error::NoModificationAllowed);
|
||||||
|
@ -284,12 +284,12 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
|
||||||
fn SetPropertyValue(self, property: DOMString, value: DOMString) -> ErrorResult {
|
fn SetPropertyValue(&self, property: DOMString, value: DOMString) -> ErrorResult {
|
||||||
self.SetProperty(property, value, "".to_owned())
|
self.SetProperty(property, value, "".to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
|
||||||
fn RemoveProperty(self, property: DOMString) -> Fallible<DOMString> {
|
fn RemoveProperty(&self, property: DOMString) -> Fallible<DOMString> {
|
||||||
// Step 1
|
// Step 1
|
||||||
if self.readonly {
|
if self.readonly {
|
||||||
return Err(Error::NoModificationAllowed);
|
return Err(Error::NoModificationAllowed);
|
||||||
|
@ -320,17 +320,17 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
|
||||||
fn CssFloat(self) -> DOMString {
|
fn CssFloat(&self) -> DOMString {
|
||||||
self.GetPropertyValue("float".to_owned())
|
self.GetPropertyValue("float".to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
|
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
|
||||||
fn SetCssFloat(self, value: DOMString) -> ErrorResult {
|
fn SetCssFloat(&self, value: DOMString) -> ErrorResult {
|
||||||
self.SetPropertyValue("float".to_owned(), value)
|
self.SetPropertyValue("float".to_owned(), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
|
// https://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();
|
||||||
rval
|
rval
|
||||||
|
|
|
@ -62,14 +62,14 @@ impl CustomEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CustomEventMethods for &'a CustomEvent {
|
impl CustomEventMethods for CustomEvent {
|
||||||
// https://dom.spec.whatwg.org/#dom-customevent-detail
|
// 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
|
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent
|
||||||
fn InitCustomEvent(self,
|
fn InitCustomEvent(&self,
|
||||||
_cx: *mut JSContext,
|
_cx: *mut JSContext,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
can_bubble: bool,
|
can_bubble: bool,
|
||||||
|
|
|
@ -354,9 +354,9 @@ impl DedicatedWorkerGlobalScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DedicatedWorkerGlobalScopeMethods for &'a DedicatedWorkerGlobalScope {
|
impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage
|
// https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage
|
||||||
fn PostMessage(self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
|
fn PostMessage(&self, cx: *mut JSContext, message: HandleValue) -> 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();
|
||||||
self.parent_sender.send(CommonScriptMsg::RunnableMsg(
|
self.parent_sender.send(CommonScriptMsg::RunnableMsg(
|
||||||
|
|
|
@ -1127,19 +1127,19 @@ impl Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DocumentMethods for &'a Document {
|
impl DocumentMethods for Document {
|
||||||
// https://dom.spec.whatwg.org/#dom-document-implementation
|
// https://dom.spec.whatwg.org/#dom-document-implementation
|
||||||
fn Implementation(self) -> Root<DOMImplementation> {
|
fn Implementation(&self) -> Root<DOMImplementation> {
|
||||||
self.implementation.or_init(|| DOMImplementation::new(self))
|
self.implementation.or_init(|| DOMImplementation::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-url
|
// https://dom.spec.whatwg.org/#dom-document-url
|
||||||
fn URL(self) -> DOMString {
|
fn URL(&self) -> DOMString {
|
||||||
self.url().serialize()
|
self.url().serialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-activeelement
|
// https://html.spec.whatwg.org/multipage/#dom-document-activeelement
|
||||||
fn GetActiveElement(self) -> Option<Root<Element>> {
|
fn GetActiveElement(&self) -> Option<Root<Element>> {
|
||||||
// TODO: Step 2.
|
// TODO: Step 2.
|
||||||
|
|
||||||
match self.get_focused_element() {
|
match self.get_focused_element() {
|
||||||
|
@ -1152,7 +1152,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-hasfocus
|
// https://html.spec.whatwg.org/#dom-document-hasfocus
|
||||||
fn HasFocus(self) -> bool {
|
fn HasFocus(&self) -> bool {
|
||||||
let target = self; // Step 1.
|
let target = self; // Step 1.
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
|
@ -1173,12 +1173,12 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-documenturi
|
// https://dom.spec.whatwg.org/#dom-document-documenturi
|
||||||
fn DocumentURI(self) -> DOMString {
|
fn DocumentURI(&self) -> DOMString {
|
||||||
self.URL()
|
self.URL()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-compatmode
|
// https://dom.spec.whatwg.org/#dom-document-compatmode
|
||||||
fn CompatMode(self) -> DOMString {
|
fn CompatMode(&self) -> DOMString {
|
||||||
match self.quirks_mode.get() {
|
match self.quirks_mode.get() {
|
||||||
LimitedQuirks | NoQuirks => "CSS1Compat".to_owned(),
|
LimitedQuirks | NoQuirks => "CSS1Compat".to_owned(),
|
||||||
Quirks => "BackCompat".to_owned()
|
Quirks => "BackCompat".to_owned()
|
||||||
|
@ -1186,22 +1186,22 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-characterset
|
// https://dom.spec.whatwg.org/#dom-document-characterset
|
||||||
fn CharacterSet(self) -> DOMString {
|
fn CharacterSet(&self) -> DOMString {
|
||||||
self.encoding_name.borrow().clone()
|
self.encoding_name.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-inputencoding
|
// https://dom.spec.whatwg.org/#dom-document-inputencoding
|
||||||
fn InputEncoding(self) -> DOMString {
|
fn InputEncoding(&self) -> DOMString {
|
||||||
self.encoding_name.borrow().clone()
|
self.encoding_name.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-content_type
|
// https://dom.spec.whatwg.org/#dom-document-content_type
|
||||||
fn ContentType(self) -> DOMString {
|
fn ContentType(&self) -> DOMString {
|
||||||
self.content_type.clone()
|
self.content_type.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-doctype
|
// https://dom.spec.whatwg.org/#dom-document-doctype
|
||||||
fn GetDoctype(self) -> Option<Root<DocumentType>> {
|
fn GetDoctype(&self) -> Option<Root<DocumentType>> {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.children()
|
node.children()
|
||||||
.filter_map(|c| DocumentTypeCast::to_ref(c.r()).map(Root::from_ref))
|
.filter_map(|c| DocumentTypeCast::to_ref(c.r()).map(Root::from_ref))
|
||||||
|
@ -1209,39 +1209,39 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-documentelement
|
// https://dom.spec.whatwg.org/#dom-document-documentelement
|
||||||
fn GetDocumentElement(self) -> Option<Root<Element>> {
|
fn GetDocumentElement(&self) -> Option<Root<Element>> {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.child_elements().next()
|
node.child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagname
|
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagname
|
||||||
fn GetElementsByTagName(self, tag_name: DOMString) -> Root<HTMLCollection> {
|
fn GetElementsByTagName(&self, tag_name: DOMString) -> Root<HTMLCollection> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
HTMLCollection::by_tag_name(window.r(), NodeCast::from_ref(self), tag_name)
|
HTMLCollection::by_tag_name(window.r(), NodeCast::from_ref(self), tag_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens
|
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens
|
||||||
fn GetElementsByTagNameNS(self, maybe_ns: Option<DOMString>, tag_name: DOMString)
|
fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>, tag_name: DOMString)
|
||||||
-> Root<HTMLCollection> {
|
-> Root<HTMLCollection> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
HTMLCollection::by_tag_name_ns(window.r(), NodeCast::from_ref(self), tag_name, maybe_ns)
|
HTMLCollection::by_tag_name_ns(window.r(), NodeCast::from_ref(self), tag_name, maybe_ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
|
// https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
|
||||||
fn GetElementsByClassName(self, classes: DOMString) -> Root<HTMLCollection> {
|
fn GetElementsByClassName(&self, classes: DOMString) -> Root<HTMLCollection> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
|
|
||||||
HTMLCollection::by_class_name(window.r(), NodeCast::from_ref(self), classes)
|
HTMLCollection::by_class_name(window.r(), NodeCast::from_ref(self), classes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||||
fn GetElementById(self, id: DOMString) -> Option<Root<Element>> {
|
fn GetElementById(&self, id: DOMString) -> Option<Root<Element>> {
|
||||||
let id = Atom::from_slice(&id);
|
let id = Atom::from_slice(&id);
|
||||||
self.idmap.borrow().get(&id).map(|ref elements| (*elements)[0].root())
|
self.idmap.borrow().get(&id).map(|ref elements| (*elements)[0].root())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createelement
|
// https://dom.spec.whatwg.org/#dom-document-createelement
|
||||||
fn CreateElement(self, mut local_name: DOMString) -> Fallible<Root<Element>> {
|
fn CreateElement(&self, mut local_name: DOMString) -> Fallible<Root<Element>> {
|
||||||
if xml_name_type(&local_name) == InvalidXMLName {
|
if xml_name_type(&local_name) == InvalidXMLName {
|
||||||
debug!("Not a valid element name");
|
debug!("Not a valid element name");
|
||||||
return Err(InvalidCharacter);
|
return Err(InvalidCharacter);
|
||||||
|
@ -1254,7 +1254,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createelementns
|
// https://dom.spec.whatwg.org/#dom-document-createelementns
|
||||||
fn CreateElementNS(self,
|
fn CreateElementNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
qualified_name: DOMString) -> Fallible<Root<Element>> {
|
qualified_name: DOMString) -> Fallible<Root<Element>> {
|
||||||
let (namespace, prefix, local_name) =
|
let (namespace, prefix, local_name) =
|
||||||
|
@ -1264,7 +1264,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createattribute
|
// https://dom.spec.whatwg.org/#dom-document-createattribute
|
||||||
fn CreateAttribute(self, local_name: DOMString) -> Fallible<Root<Attr>> {
|
fn CreateAttribute(&self, local_name: DOMString) -> Fallible<Root<Attr>> {
|
||||||
if xml_name_type(&local_name) == InvalidXMLName {
|
if xml_name_type(&local_name) == InvalidXMLName {
|
||||||
debug!("Not a valid element name");
|
debug!("Not a valid element name");
|
||||||
return Err(InvalidCharacter);
|
return Err(InvalidCharacter);
|
||||||
|
@ -1280,7 +1280,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createattributens
|
// https://dom.spec.whatwg.org/#dom-document-createattributens
|
||||||
fn CreateAttributeNS(self, namespace: Option<DOMString>, qualified_name: DOMString)
|
fn CreateAttributeNS(&self, namespace: Option<DOMString>, qualified_name: DOMString)
|
||||||
-> Fallible<Root<Attr>> {
|
-> Fallible<Root<Attr>> {
|
||||||
let (namespace, prefix, local_name) =
|
let (namespace, prefix, local_name) =
|
||||||
try!(validate_and_extract(namespace, &qualified_name));
|
try!(validate_and_extract(namespace, &qualified_name));
|
||||||
|
@ -1292,22 +1292,22 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createdocumentfragment
|
// https://dom.spec.whatwg.org/#dom-document-createdocumentfragment
|
||||||
fn CreateDocumentFragment(self) -> Root<DocumentFragment> {
|
fn CreateDocumentFragment(&self) -> Root<DocumentFragment> {
|
||||||
DocumentFragment::new(self)
|
DocumentFragment::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createtextnode
|
// https://dom.spec.whatwg.org/#dom-document-createtextnode
|
||||||
fn CreateTextNode(self, data: DOMString) -> Root<Text> {
|
fn CreateTextNode(&self, data: DOMString) -> Root<Text> {
|
||||||
Text::new(data, self)
|
Text::new(data, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createcomment
|
// https://dom.spec.whatwg.org/#dom-document-createcomment
|
||||||
fn CreateComment(self, data: DOMString) -> Root<Comment> {
|
fn CreateComment(&self, data: DOMString) -> Root<Comment> {
|
||||||
Comment::new(data, self)
|
Comment::new(data, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
||||||
fn CreateProcessingInstruction(self, target: DOMString, data: DOMString) ->
|
fn CreateProcessingInstruction(&self, target: DOMString, data: DOMString) ->
|
||||||
Fallible<Root<ProcessingInstruction>> {
|
Fallible<Root<ProcessingInstruction>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if xml_name_type(&target) == InvalidXMLName {
|
if xml_name_type(&target) == InvalidXMLName {
|
||||||
|
@ -1324,7 +1324,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-importnode
|
// https://dom.spec.whatwg.org/#dom-document-importnode
|
||||||
fn ImportNode(self, node: &Node, deep: bool) -> Fallible<Root<Node>> {
|
fn ImportNode(&self, node: &Node, deep: bool) -> Fallible<Root<Node>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if node.is_document() {
|
if node.is_document() {
|
||||||
return Err(NotSupported);
|
return Err(NotSupported);
|
||||||
|
@ -1340,7 +1340,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-adoptnode
|
// https://dom.spec.whatwg.org/#dom-document-adoptnode
|
||||||
fn AdoptNode(self, node: &Node) -> Fallible<Root<Node>> {
|
fn AdoptNode(&self, node: &Node) -> Fallible<Root<Node>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if node.is_document() {
|
if node.is_document() {
|
||||||
return Err(NotSupported);
|
return Err(NotSupported);
|
||||||
|
@ -1354,7 +1354,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createevent
|
// https://dom.spec.whatwg.org/#dom-document-createevent
|
||||||
fn CreateEvent(self, interface: DOMString) -> Fallible<Root<Event>> {
|
fn CreateEvent(&self, interface: DOMString) -> Fallible<Root<Event>> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
|
|
||||||
match &*interface.to_ascii_lowercase() {
|
match &*interface.to_ascii_lowercase() {
|
||||||
|
@ -1375,7 +1375,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#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(),
|
||||||
None => time::now().strftime("%m/%d/%Y %H:%M:%S").unwrap().to_string(),
|
None => time::now().strftime("%m/%d/%Y %H:%M:%S").unwrap().to_string(),
|
||||||
|
@ -1383,24 +1383,24 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createrange
|
// https://dom.spec.whatwg.org/#dom-document-createrange
|
||||||
fn CreateRange(self) -> Root<Range> {
|
fn CreateRange(&self) -> Root<Range> {
|
||||||
Range::new_with_doc(self)
|
Range::new_with_doc(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createnodeiteratorroot-whattoshow-filter
|
// https://dom.spec.whatwg.org/#dom-document-createnodeiteratorroot-whattoshow-filter
|
||||||
fn CreateNodeIterator(self, root: &Node, whatToShow: u32, filter: Option<Rc<NodeFilter>>)
|
fn CreateNodeIterator(&self, root: &Node, whatToShow: u32, filter: Option<Rc<NodeFilter>>)
|
||||||
-> Root<NodeIterator> {
|
-> Root<NodeIterator> {
|
||||||
NodeIterator::new(self, root, whatToShow, filter)
|
NodeIterator::new(self, root, whatToShow, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
||||||
fn CreateTreeWalker(self, root: &Node, whatToShow: u32, filter: Option<Rc<NodeFilter>>)
|
fn CreateTreeWalker(&self, root: &Node, whatToShow: u32, filter: Option<Rc<NodeFilter>>)
|
||||||
-> Root<TreeWalker> {
|
-> Root<TreeWalker> {
|
||||||
TreeWalker::new(self, root, whatToShow, filter)
|
TreeWalker::new(self, root, whatToShow, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#document.title
|
// https://html.spec.whatwg.org/#document.title
|
||||||
fn Title(self) -> DOMString {
|
fn Title(&self) -> DOMString {
|
||||||
let title = self.GetDocumentElement().and_then(|root| {
|
let title = self.GetDocumentElement().and_then(|root| {
|
||||||
if root.r().namespace() == &ns!(SVG) && root.r().local_name() == &atom!("svg") {
|
if root.r().namespace() == &ns!(SVG) && root.r().local_name() == &atom!("svg") {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -1427,7 +1427,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#document.title
|
// https://html.spec.whatwg.org/#document.title
|
||||||
fn SetTitle(self, title: DOMString) {
|
fn SetTitle(&self, title: DOMString) {
|
||||||
let root = match self.GetDocumentElement() {
|
let root = match self.GetDocumentElement() {
|
||||||
Some(root) => root,
|
Some(root) => root,
|
||||||
None => return,
|
None => return,
|
||||||
|
@ -1478,7 +1478,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-head
|
// https://html.spec.whatwg.org/#dom-document-head
|
||||||
fn GetHead(self) -> Option<Root<HTMLHeadElement>> {
|
fn GetHead(&self) -> Option<Root<HTMLHeadElement>> {
|
||||||
self.get_html_element().and_then(|root| {
|
self.get_html_element().and_then(|root| {
|
||||||
let node = NodeCast::from_ref(root.r());
|
let node = NodeCast::from_ref(root.r());
|
||||||
node.children()
|
node.children()
|
||||||
|
@ -1488,12 +1488,12 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-currentscript
|
// https://html.spec.whatwg.org/#dom-document-currentscript
|
||||||
fn GetCurrentScript(self) -> Option<Root<HTMLScriptElement>> {
|
fn GetCurrentScript(&self) -> Option<Root<HTMLScriptElement>> {
|
||||||
self.current_script.get().map(Root::from_rooted)
|
self.current_script.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-body
|
// https://html.spec.whatwg.org/#dom-document-body
|
||||||
fn GetBody(self) -> Option<Root<HTMLElement>> {
|
fn GetBody(&self) -> Option<Root<HTMLElement>> {
|
||||||
self.get_html_element().and_then(|root| {
|
self.get_html_element().and_then(|root| {
|
||||||
let node = NodeCast::from_ref(root.r());
|
let node = NodeCast::from_ref(root.r());
|
||||||
node.children().find(|child| {
|
node.children().find(|child| {
|
||||||
|
@ -1509,7 +1509,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-body
|
// https://html.spec.whatwg.org/#dom-document-body
|
||||||
fn SetBody(self, new_body: Option<&HTMLElement>) -> ErrorResult {
|
fn SetBody(&self, new_body: Option<&HTMLElement>) -> ErrorResult {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let new_body = match new_body {
|
let new_body = match new_body {
|
||||||
Some(new_body) => new_body,
|
Some(new_body) => new_body,
|
||||||
|
@ -1552,7 +1552,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-getelementsbyname
|
// https://html.spec.whatwg.org/#dom-document-getelementsbyname
|
||||||
fn GetElementsByName(self, name: DOMString) -> Root<NodeList> {
|
fn GetElementsByName(&self, name: DOMString) -> Root<NodeList> {
|
||||||
self.create_node_list(|node| {
|
self.create_node_list(|node| {
|
||||||
let element = match ElementCast::to_ref(node) {
|
let element = match ElementCast::to_ref(node) {
|
||||||
Some(element) => element,
|
Some(element) => element,
|
||||||
|
@ -1568,7 +1568,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-images
|
// https://html.spec.whatwg.org/#dom-document-images
|
||||||
fn Images(self) -> Root<HTMLCollection> {
|
fn Images(&self) -> Root<HTMLCollection> {
|
||||||
self.images.or_init(|| {
|
self.images.or_init(|| {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
|
@ -1578,7 +1578,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-embeds
|
// https://html.spec.whatwg.org/#dom-document-embeds
|
||||||
fn Embeds(self) -> Root<HTMLCollection> {
|
fn Embeds(&self) -> Root<HTMLCollection> {
|
||||||
self.embeds.or_init(|| {
|
self.embeds.or_init(|| {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
|
@ -1588,12 +1588,12 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-plugins
|
// https://html.spec.whatwg.org/#dom-document-plugins
|
||||||
fn Plugins(self) -> Root<HTMLCollection> {
|
fn Plugins(&self) -> Root<HTMLCollection> {
|
||||||
self.Embeds()
|
self.Embeds()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-links
|
// https://html.spec.whatwg.org/#dom-document-links
|
||||||
fn Links(self) -> Root<HTMLCollection> {
|
fn Links(&self) -> Root<HTMLCollection> {
|
||||||
self.links.or_init(|| {
|
self.links.or_init(|| {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
|
@ -1603,7 +1603,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-forms
|
// https://html.spec.whatwg.org/#dom-document-forms
|
||||||
fn Forms(self) -> Root<HTMLCollection> {
|
fn Forms(&self) -> Root<HTMLCollection> {
|
||||||
self.forms.or_init(|| {
|
self.forms.or_init(|| {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
|
@ -1613,7 +1613,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-scripts
|
// https://html.spec.whatwg.org/#dom-document-scripts
|
||||||
fn Scripts(self) -> Root<HTMLCollection> {
|
fn Scripts(&self) -> Root<HTMLCollection> {
|
||||||
self.scripts.or_init(|| {
|
self.scripts.or_init(|| {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
|
@ -1623,7 +1623,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-anchors
|
// https://html.spec.whatwg.org/#dom-document-anchors
|
||||||
fn Anchors(self) -> Root<HTMLCollection> {
|
fn Anchors(&self) -> Root<HTMLCollection> {
|
||||||
self.anchors.or_init(|| {
|
self.anchors.or_init(|| {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
|
@ -1633,7 +1633,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-applets
|
// https://html.spec.whatwg.org/#dom-document-applets
|
||||||
fn Applets(self) -> Root<HTMLCollection> {
|
fn Applets(&self) -> Root<HTMLCollection> {
|
||||||
// FIXME: This should be return OBJECT elements containing applets.
|
// FIXME: This should be return OBJECT elements containing applets.
|
||||||
self.applets.or_init(|| {
|
self.applets.or_init(|| {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
|
@ -1644,67 +1644,67 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-location
|
// https://html.spec.whatwg.org/#dom-document-location
|
||||||
fn Location(self) -> Root<Location> {
|
fn Location(&self) -> Root<Location> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
self.location.or_init(|| Location::new(window))
|
self.location.or_init(|| Location::new(window))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||||
fn Children(self) -> Root<HTMLCollection> {
|
fn Children(&self) -> Root<HTMLCollection> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
HTMLCollection::children(window.r(), NodeCast::from_ref(self))
|
HTMLCollection::children(window.r(), NodeCast::from_ref(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
||||||
fn GetFirstElementChild(self) -> Option<Root<Element>> {
|
fn GetFirstElementChild(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).child_elements().next()
|
NodeCast::from_ref(self).child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||||
fn GetLastElementChild(self) -> Option<Root<Element>> {
|
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).rev_children().filter_map(ElementCast::to_root).next()
|
NodeCast::from_ref(self).rev_children().filter_map(ElementCast::to_root).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||||
fn ChildElementCount(self) -> u32 {
|
fn ChildElementCount(&self) -> u32 {
|
||||||
NodeCast::from_ref(self).child_elements().count() as u32
|
NodeCast::from_ref(self).child_elements().count() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
|
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
|
||||||
fn Prepend(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Prepend(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).prepend(nodes)
|
NodeCast::from_ref(self).prepend(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-append
|
// https://dom.spec.whatwg.org/#dom-parentnode-append
|
||||||
fn Append(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Append(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).append(nodes)
|
NodeCast::from_ref(self).append(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||||
fn QuerySelector(self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
root.query_selector(selectors)
|
root.query_selector(selectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||||
fn QuerySelectorAll(self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
root.query_selector_all(selectors)
|
root.query_selector_all(selectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-readystate
|
// https://html.spec.whatwg.org/multipage/#dom-document-readystate
|
||||||
fn ReadyState(self) -> DocumentReadyState {
|
fn ReadyState(&self) -> DocumentReadyState {
|
||||||
self.ready_state.get()
|
self.ready_state.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-defaultview
|
// https://html.spec.whatwg.org/multipage/#dom-document-defaultview
|
||||||
fn DefaultView(self) -> Root<Window> {
|
fn DefaultView(&self) -> Root<Window> {
|
||||||
self.window.root()
|
self.window.root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
||||||
fn GetCookie(self) -> Fallible<DOMString> {
|
fn GetCookie(&self) -> Fallible<DOMString> {
|
||||||
//TODO: return empty string for cookie-averse Document
|
//TODO: return empty string for cookie-averse Document
|
||||||
let url = self.url();
|
let url = self.url();
|
||||||
if !is_scheme_host_port_tuple(&url) {
|
if !is_scheme_host_port_tuple(&url) {
|
||||||
|
@ -1718,7 +1718,7 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
||||||
fn SetCookie(self, cookie: DOMString) -> ErrorResult {
|
fn SetCookie(&self, cookie: DOMString) -> ErrorResult {
|
||||||
//TODO: ignore for cookie-averse Document
|
//TODO: ignore for cookie-averse Document
|
||||||
let url = self.url();
|
let url = self.url();
|
||||||
if !is_scheme_host_port_tuple(&url) {
|
if !is_scheme_host_port_tuple(&url) {
|
||||||
|
@ -1730,17 +1730,17 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-bgcolor
|
// https://html.spec.whatwg.org/multipage/#dom-document-bgcolor
|
||||||
fn BgColor(self) -> DOMString {
|
fn BgColor(&self) -> DOMString {
|
||||||
self.get_body_attribute(&atom!("bgcolor"))
|
self.get_body_attribute(&atom!("bgcolor"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-bgcolor
|
// https://html.spec.whatwg.org/multipage/#dom-document-bgcolor
|
||||||
fn SetBgColor(self, value: DOMString) {
|
fn SetBgColor(&self, value: DOMString) {
|
||||||
self.set_body_attribute(&atom!("bgcolor"), value)
|
self.set_body_attribute(&atom!("bgcolor"), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter
|
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter
|
||||||
fn NamedGetter(self, _cx: *mut JSContext, name: DOMString, found: &mut bool)
|
fn NamedGetter(&self, _cx: *mut JSContext, name: DOMString, found: &mut bool)
|
||||||
-> *mut JSObject {
|
-> *mut JSObject {
|
||||||
#[derive(JSTraceable, HeapSizeOf)]
|
#[derive(JSTraceable, HeapSizeOf)]
|
||||||
struct NamedElementFilter {
|
struct NamedElementFilter {
|
||||||
|
@ -1826,23 +1826,23 @@ impl<'a> DocumentMethods for &'a Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#document
|
// https://html.spec.whatwg.org/multipage/#document
|
||||||
fn SupportedPropertyNames(self) -> Vec<DOMString> {
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||||
// FIXME: unimplemented (https://github.com/servo/servo/issues/7273)
|
// FIXME: unimplemented (https://github.com/servo/servo/issues/7273)
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-clear
|
// https://html.spec.whatwg.org/multipage/#dom-document-clear
|
||||||
fn Clear(self) {
|
fn Clear(&self) {
|
||||||
// This method intentionally does nothing
|
// This method intentionally does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-captureevents
|
// https://html.spec.whatwg.org/multipage/#dom-document-captureevents
|
||||||
fn CaptureEvents(self) {
|
fn CaptureEvents(&self) {
|
||||||
// This method intentionally does nothing
|
// This method intentionally does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-document-releaseevents
|
// https://html.spec.whatwg.org/#dom-document-releaseevents
|
||||||
fn ReleaseEvents(self) {
|
fn ReleaseEvents(&self) {
|
||||||
// This method intentionally does nothing
|
// This method intentionally does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,46 +51,46 @@ impl DocumentFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DocumentFragmentMethods for &'a DocumentFragment {
|
impl DocumentFragmentMethods for DocumentFragment {
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||||
fn Children(self) -> Root<HTMLCollection> {
|
fn Children(&self) -> Root<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::children(window.r(), NodeCast::from_ref(self))
|
HTMLCollection::children(window.r(), NodeCast::from_ref(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
||||||
fn GetFirstElementChild(self) -> Option<Root<Element>> {
|
fn GetFirstElementChild(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).child_elements().next()
|
NodeCast::from_ref(self).child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||||
fn GetLastElementChild(self) -> Option<Root<Element>> {
|
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).rev_children().filter_map(ElementCast::to_root).next()
|
NodeCast::from_ref(self).rev_children().filter_map(ElementCast::to_root).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||||
fn ChildElementCount(self) -> u32 {
|
fn ChildElementCount(&self) -> u32 {
|
||||||
NodeCast::from_ref(self).child_elements().count() as u32
|
NodeCast::from_ref(self).child_elements().count() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
|
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
|
||||||
fn Prepend(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Prepend(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).prepend(nodes)
|
NodeCast::from_ref(self).prepend(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-append
|
// https://dom.spec.whatwg.org/#dom-parentnode-append
|
||||||
fn Append(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Append(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).append(nodes)
|
NodeCast::from_ref(self).append(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||||
fn QuerySelector(self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
root.query_selector(selectors)
|
root.query_selector(selectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||||
fn QuerySelectorAll(self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
root.query_selector_all(selectors)
|
root.query_selector_all(selectors)
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,39 +73,39 @@ impl DocumentType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DocumentTypeMethods for &'a DocumentType {
|
impl DocumentTypeMethods for DocumentType {
|
||||||
// https://dom.spec.whatwg.org/#dom-documenttype-name
|
// 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
|
// 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
|
// https://dom.spec.whatwg.org/#dom-documenttype-systemid
|
||||||
fn SystemId(self) -> DOMString {
|
fn SystemId(&self) -> DOMString {
|
||||||
self.system_id.clone()
|
self.system_id.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-before
|
// https://dom.spec.whatwg.org/#dom-childnode-before
|
||||||
fn Before(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Before(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).before(nodes)
|
NodeCast::from_ref(self).before(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-after
|
// https://dom.spec.whatwg.org/#dom-childnode-after
|
||||||
fn After(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn After(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).after(nodes)
|
NodeCast::from_ref(self).after(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
|
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
|
||||||
fn ReplaceWith(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn ReplaceWith(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).replace_with(nodes)
|
NodeCast::from_ref(self).replace_with(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-remove
|
// https://dom.spec.whatwg.org/#dom-childnode-remove
|
||||||
fn Remove(self) {
|
fn Remove(&self) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.remove_self();
|
node.remove_self();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,9 @@ impl DOMException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DOMExceptionMethods for &'a DOMException {
|
impl DOMExceptionMethods for DOMException {
|
||||||
// https://heycam.github.io/webidl/#dfn-DOMException
|
// https://heycam.github.io/webidl/#dfn-DOMException
|
||||||
fn Code(self) -> u16 {
|
fn Code(&self) -> u16 {
|
||||||
match self.code {
|
match self.code {
|
||||||
// https://heycam.github.io/webidl/#dfn-throw
|
// https://heycam.github.io/webidl/#dfn-throw
|
||||||
DOMErrorName::EncodingError => 0,
|
DOMErrorName::EncodingError => 0,
|
||||||
|
@ -70,12 +70,12 @@ impl<'a> DOMExceptionMethods for &'a DOMException {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://heycam.github.io/webidl/#idl-DOMException-error-names
|
// https://heycam.github.io/webidl/#idl-DOMException-error-names
|
||||||
fn Name(self) -> DOMString {
|
fn Name(&self) -> DOMString {
|
||||||
format!("{:?}", self.code)
|
format!("{:?}", self.code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://heycam.github.io/webidl/#error-names
|
// https://heycam.github.io/webidl/#error-names
|
||||||
fn Message(self) -> DOMString {
|
fn Message(&self) -> DOMString {
|
||||||
let message = match self.code {
|
let message = match self.code {
|
||||||
DOMErrorName::IndexSizeError => "The index is not in the allowed range.",
|
DOMErrorName::IndexSizeError => "The index is not in the allowed range.",
|
||||||
DOMErrorName::HierarchyRequestError => "The operation would yield an incorrect node tree.",
|
DOMErrorName::HierarchyRequestError => "The operation would yield an incorrect node tree.",
|
||||||
|
|
|
@ -49,9 +49,9 @@ impl DOMImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#domimplementation
|
// https://dom.spec.whatwg.org/#domimplementation
|
||||||
impl<'a> DOMImplementationMethods for &'a DOMImplementation {
|
impl DOMImplementationMethods for DOMImplementation {
|
||||||
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
|
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
|
||||||
fn CreateDocumentType(self, qualified_name: DOMString, pubid: DOMString, sysid: DOMString)
|
fn CreateDocumentType(&self, qualified_name: DOMString, pubid: DOMString, sysid: DOMString)
|
||||||
-> Fallible<Root<DocumentType>> {
|
-> Fallible<Root<DocumentType>> {
|
||||||
try!(validate_qualified_name(&qualified_name));
|
try!(validate_qualified_name(&qualified_name));
|
||||||
let document = self.document.root();
|
let document = self.document.root();
|
||||||
|
@ -59,7 +59,7 @@ impl<'a> DOMImplementationMethods for &'a DOMImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
|
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
|
||||||
fn CreateDocument(self, namespace: Option<DOMString>, qname: DOMString,
|
fn CreateDocument(&self, namespace: Option<DOMString>, qname: DOMString,
|
||||||
maybe_doctype: Option<&DocumentType>) -> Fallible<Root<Document>> {
|
maybe_doctype: Option<&DocumentType>) -> Fallible<Root<Document>> {
|
||||||
let doc = self.document.root();
|
let doc = self.document.root();
|
||||||
let doc = doc.r();
|
let doc = doc.r();
|
||||||
|
@ -108,7 +108,7 @@ impl<'a> DOMImplementationMethods for &'a DOMImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
||||||
fn CreateHTMLDocument(self, title: Option<DOMString>) -> Root<Document> {
|
fn CreateHTMLDocument(&self, title: Option<DOMString>) -> Root<Document> {
|
||||||
let document = self.document.root();
|
let document = self.document.root();
|
||||||
let document = document.r();
|
let document = document.r();
|
||||||
let win = document.window();
|
let win = document.window();
|
||||||
|
@ -167,7 +167,7 @@ impl<'a> DOMImplementationMethods for &'a DOMImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
// https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
||||||
fn HasFeature(self) -> bool {
|
fn HasFeature(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,9 @@ impl DOMParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DOMParserMethods for &'a DOMParser {
|
impl DOMParserMethods for DOMParser {
|
||||||
// https://domparsing.spec.whatwg.org/#the-domparser-interface
|
// https://domparsing.spec.whatwg.org/#the-domparser-interface
|
||||||
fn ParseFromString(self,
|
fn ParseFromString(&self,
|
||||||
s: DOMString,
|
s: DOMString,
|
||||||
ty: DOMParserBinding::SupportedType)
|
ty: DOMParserBinding::SupportedType)
|
||||||
-> Fallible<Root<Document>> {
|
-> Fallible<Root<Document>> {
|
||||||
|
|
|
@ -33,44 +33,44 @@ impl DOMPoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DOMPointMethods for &'a DOMPoint {
|
impl DOMPointMethods for DOMPoint {
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
|
||||||
fn X(self) -> f64 {
|
fn X(&self) -> f64 {
|
||||||
self.point.X()
|
self.point.X()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
|
||||||
fn SetX(self, value: f64) {
|
fn SetX(&self, value: f64) {
|
||||||
self.point.SetX(value);
|
self.point.SetX(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
|
||||||
fn Y(self) -> f64 {
|
fn Y(&self) -> f64 {
|
||||||
self.point.Y()
|
self.point.Y()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
|
||||||
fn SetY(self, value: f64) {
|
fn SetY(&self, value: f64) {
|
||||||
self.point.SetY(value);
|
self.point.SetY(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
|
||||||
fn Z(self) -> f64 {
|
fn Z(&self) -> f64 {
|
||||||
self.point.Z()
|
self.point.Z()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
|
||||||
fn SetZ(self, value: f64) {
|
fn SetZ(&self, value: f64) {
|
||||||
self.point.SetZ(value);
|
self.point.SetZ(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
|
||||||
fn W(self) -> f64 {
|
fn W(&self) -> f64 {
|
||||||
self.point.W()
|
self.point.W()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
|
||||||
fn SetW(self, value: f64) {
|
fn SetW(&self, value: f64) {
|
||||||
self.point.SetW(value);
|
self.point.SetW(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,49 +40,49 @@ impl DOMPointReadOnly {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DOMPointReadOnlyMethods for &'a DOMPointReadOnly {
|
impl DOMPointReadOnlyMethods for DOMPointReadOnly {
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
|
||||||
fn X(self) -> f64 {
|
fn X(&self) -> f64 {
|
||||||
self.x.get()
|
self.x.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
|
||||||
fn Y(self) -> f64 {
|
fn Y(&self) -> f64 {
|
||||||
self.y.get()
|
self.y.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
|
||||||
fn Z(self) -> f64 {
|
fn Z(&self) -> f64 {
|
||||||
self.z.get()
|
self.z.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
|
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
|
||||||
fn W(self) -> f64 {
|
fn W(&self) -> f64 {
|
||||||
self.w.get()
|
self.w.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DOMPointWriteMethods {
|
pub trait DOMPointWriteMethods {
|
||||||
fn SetX(self, value: f64);
|
fn SetX(&self, value: f64);
|
||||||
fn SetY(self, value: f64);
|
fn SetY(&self, value: f64);
|
||||||
fn SetZ(self, value: f64);
|
fn SetZ(&self, value: f64);
|
||||||
fn SetW(self, value: f64);
|
fn SetW(&self, value: f64);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DOMPointWriteMethods for &'a DOMPointReadOnly {
|
impl DOMPointWriteMethods for DOMPointReadOnly {
|
||||||
fn SetX(self, value: f64) {
|
fn SetX(&self, value: f64) {
|
||||||
self.x.set(value);
|
self.x.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetY(self, value: f64) {
|
fn SetY(&self, value: f64) {
|
||||||
self.y.set(value);
|
self.y.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetZ(self, value: f64) {
|
fn SetZ(&self, value: f64) {
|
||||||
self.z.set(value);
|
self.z.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetW(self, value: f64) {
|
fn SetW(&self, value: f64) {
|
||||||
self.w.set(value);
|
self.w.set(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,35 +40,35 @@ impl DOMRect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DOMRectMethods for &'a DOMRect {
|
impl DOMRectMethods for DOMRect {
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-top
|
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-top
|
||||||
fn Top(self) -> Finite<f32> {
|
fn Top(&self) -> Finite<f32> {
|
||||||
Finite::wrap(self.top)
|
Finite::wrap(self.top)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-bottom
|
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-bottom
|
||||||
fn Bottom(self) -> Finite<f32> {
|
fn Bottom(&self) -> Finite<f32> {
|
||||||
Finite::wrap(self.bottom)
|
Finite::wrap(self.bottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-left
|
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-left
|
||||||
fn Left(self) -> Finite<f32> {
|
fn Left(&self) -> Finite<f32> {
|
||||||
Finite::wrap(self.left)
|
Finite::wrap(self.left)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-right
|
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-right
|
||||||
fn Right(self) -> Finite<f32> {
|
fn Right(&self) -> Finite<f32> {
|
||||||
Finite::wrap(self.right)
|
Finite::wrap(self.right)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-width
|
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-width
|
||||||
fn Width(self) -> Finite<f32> {
|
fn Width(&self) -> Finite<f32> {
|
||||||
let result = (self.right - self.left).abs();
|
let result = (self.right - self.left).abs();
|
||||||
Finite::wrap(result)
|
Finite::wrap(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-height
|
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-height
|
||||||
fn Height(self) -> Finite<f32> {
|
fn Height(&self) -> Finite<f32> {
|
||||||
let result = (self.bottom - self.top).abs();
|
let result = (self.bottom - self.top).abs();
|
||||||
Finite::wrap(result)
|
Finite::wrap(result)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ impl DOMRectList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DOMRectListMethods for &'a DOMRectList {
|
impl DOMRectListMethods for DOMRectList {
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domrectlist-length
|
// https://drafts.fxtf.org/geometry/#dom-domrectlist-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
self.rects.len() as u32
|
self.rects.len() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-domrectlist-item
|
// https://drafts.fxtf.org/geometry/#dom-domrectlist-item
|
||||||
fn Item(self, index: u32) -> Option<Root<DOMRect>> {
|
fn Item(&self, index: u32) -> Option<Root<DOMRect>> {
|
||||||
let rects = &self.rects;
|
let rects = &self.rects;
|
||||||
if index < rects.len() as u32 {
|
if index < rects.len() as u32 {
|
||||||
Some(rects[index as usize].root())
|
Some(rects[index as usize].root())
|
||||||
|
@ -49,7 +49,7 @@ impl<'a> DOMRectListMethods for &'a DOMRectList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<DOMRect>> {
|
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<DOMRect>> {
|
||||||
*found = index < self.rects.len() as u32;
|
*found = index < self.rects.len() as u32;
|
||||||
self.Item(index)
|
self.Item(index)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,26 +34,26 @@ impl DOMStringMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#domstringmap
|
// https://html.spec.whatwg.org/#domstringmap
|
||||||
impl<'a> DOMStringMapMethods for &'a DOMStringMap {
|
impl DOMStringMapMethods for DOMStringMap {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-additem
|
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-additem
|
||||||
fn NamedCreator(self, name: DOMString, value: DOMString) -> ErrorResult {
|
fn NamedCreator(&self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||||
self.NamedSetter(name, value)
|
self.NamedSetter(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-removeitem
|
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-removeitem
|
||||||
fn NamedDeleter(self, name: DOMString) {
|
fn NamedDeleter(&self, name: DOMString) {
|
||||||
let element = self.element.root();
|
let element = self.element.root();
|
||||||
element.r().delete_custom_attr(name)
|
element.r().delete_custom_attr(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-setitem
|
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-setitem
|
||||||
fn NamedSetter(self, name: DOMString, value: DOMString) -> ErrorResult {
|
fn NamedSetter(&self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||||
let element = self.element.root();
|
let element = self.element.root();
|
||||||
element.r().set_custom_attr(name, value)
|
element.r().set_custom_attr(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-nameditem
|
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-nameditem
|
||||||
fn NamedGetter(self, name: DOMString, found: &mut bool) -> DOMString {
|
fn NamedGetter(&self, name: DOMString, found: &mut bool) -> DOMString {
|
||||||
let element = self.element.root();
|
let element = self.element.root();
|
||||||
match element.r().get_custom_attr(name) {
|
match element.r().get_custom_attr(name) {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
|
@ -68,7 +68,7 @@ impl<'a> DOMStringMapMethods for &'a DOMStringMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#domstringmap
|
// https://html.spec.whatwg.org/multipage/#domstringmap
|
||||||
fn SupportedPropertyNames(self) -> Vec<DOMString> {
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||||
// FIXME: unimplemented (https://github.com/servo/servo/issues/7273)
|
// FIXME: unimplemented (https://github.com/servo/servo/issues/7273)
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,9 @@ impl DOMTokenList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#domtokenlist
|
// https://dom.spec.whatwg.org/#domtokenlist
|
||||||
impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
impl DOMTokenListMethods for DOMTokenList {
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-length
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
self.attribute().map(|attr| {
|
self.attribute().map(|attr| {
|
||||||
let attr = attr.r();
|
let attr = attr.r();
|
||||||
attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0)
|
attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0)
|
||||||
|
@ -69,7 +69,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-item
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-item
|
||||||
fn Item(self, index: u32) -> Option<DOMString> {
|
fn Item(&self, index: u32) -> Option<DOMString> {
|
||||||
self.attribute().and_then(|attr| {
|
self.attribute().and_then(|attr| {
|
||||||
let attr = attr.r();
|
let attr = attr.r();
|
||||||
attr.value().tokens().and_then(|tokens| {
|
attr.value().tokens().and_then(|tokens| {
|
||||||
|
@ -79,7 +79,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-contains
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-contains
|
||||||
fn Contains(self, token: DOMString) -> Fallible<bool> {
|
fn Contains(&self, token: DOMString) -> Fallible<bool> {
|
||||||
self.check_token_exceptions(&token).map(|token| {
|
self.check_token_exceptions(&token).map(|token| {
|
||||||
self.attribute().map(|attr| {
|
self.attribute().map(|attr| {
|
||||||
let attr = attr.r();
|
let attr = attr.r();
|
||||||
|
@ -93,7 +93,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-add
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-add
|
||||||
fn Add(self, tokens: Vec<DOMString>) -> ErrorResult {
|
fn Add(&self, tokens: Vec<DOMString>) -> ErrorResult {
|
||||||
let element = self.element.root();
|
let element = self.element.root();
|
||||||
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
||||||
for token in &tokens {
|
for token in &tokens {
|
||||||
|
@ -107,7 +107,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-remove
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-remove
|
||||||
fn Remove(self, tokens: Vec<DOMString>) -> ErrorResult {
|
fn Remove(&self, tokens: Vec<DOMString>) -> ErrorResult {
|
||||||
let element = self.element.root();
|
let element = self.element.root();
|
||||||
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
||||||
for token in &tokens {
|
for token in &tokens {
|
||||||
|
@ -121,7 +121,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
|
||||||
fn Toggle(self, token: DOMString, force: Option<bool>) -> Fallible<bool> {
|
fn Toggle(&self, token: DOMString, force: Option<bool>) -> Fallible<bool> {
|
||||||
let element = self.element.root();
|
let element = self.element.root();
|
||||||
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
let mut atoms = element.r().get_tokenlist_attribute(&self.local_name);
|
||||||
let token = try!(self.check_token_exceptions(&token));
|
let token = try!(self.check_token_exceptions(&token));
|
||||||
|
@ -146,13 +146,13 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#stringification-behavior
|
// https://dom.spec.whatwg.org/#stringification-behavior
|
||||||
fn Stringifier(self) -> DOMString {
|
fn Stringifier(&self) -> DOMString {
|
||||||
let tokenlist = self.element.root().r().get_tokenlist_attribute(&self.local_name);
|
let tokenlist = self.element.root().r().get_tokenlist_attribute(&self.local_name);
|
||||||
str_join(&tokenlist, "\x20")
|
str_join(&tokenlist, "\x20")
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<DOMString> {
|
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<DOMString> {
|
||||||
let item = self.Item(index);
|
let item = self.Item(index);
|
||||||
*found = item.is_some();
|
*found = item.is_some();
|
||||||
item
|
item
|
||||||
|
|
|
@ -1089,24 +1089,24 @@ impl Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ElementMethods for &'a Element {
|
impl ElementMethods for Element {
|
||||||
// https://dom.spec.whatwg.org/#dom-element-namespaceuri
|
// https://dom.spec.whatwg.org/#dom-element-namespaceuri
|
||||||
fn GetNamespaceURI(self) -> Option<DOMString> {
|
fn GetNamespaceURI(&self) -> Option<DOMString> {
|
||||||
Node::namespace_to_string(self.namespace.clone())
|
Node::namespace_to_string(self.namespace.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-localname
|
// https://dom.spec.whatwg.org/#dom-element-localname
|
||||||
fn LocalName(self) -> DOMString {
|
fn LocalName(&self) -> DOMString {
|
||||||
(*self.local_name).to_owned()
|
(*self.local_name).to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-prefix
|
// https://dom.spec.whatwg.org/#dom-element-prefix
|
||||||
fn GetPrefix(self) -> Option<DOMString> {
|
fn GetPrefix(&self) -> Option<DOMString> {
|
||||||
self.prefix.clone()
|
self.prefix.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-tagname
|
// https://dom.spec.whatwg.org/#dom-element-tagname
|
||||||
fn TagName(self) -> DOMString {
|
fn TagName(&self) -> DOMString {
|
||||||
let qualified_name = match self.prefix {
|
let qualified_name = match self.prefix {
|
||||||
Some(ref prefix) => {
|
Some(ref prefix) => {
|
||||||
Cow::Owned(format!("{}:{}", &**prefix, &*self.local_name))
|
Cow::Owned(format!("{}:{}", &**prefix, &*self.local_name))
|
||||||
|
@ -1121,32 +1121,32 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-id
|
// https://dom.spec.whatwg.org/#dom-element-id
|
||||||
fn Id(self) -> DOMString {
|
fn Id(&self) -> DOMString {
|
||||||
self.get_string_attribute(&atom!("id"))
|
self.get_string_attribute(&atom!("id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-id
|
// https://dom.spec.whatwg.org/#dom-element-id
|
||||||
fn SetId(self, id: DOMString) {
|
fn SetId(&self, id: DOMString) {
|
||||||
self.set_atomic_attribute(&atom!("id"), id);
|
self.set_atomic_attribute(&atom!("id"), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-classname
|
// https://dom.spec.whatwg.org/#dom-element-classname
|
||||||
fn ClassName(self) -> DOMString {
|
fn ClassName(&self) -> DOMString {
|
||||||
self.get_string_attribute(&atom!("class"))
|
self.get_string_attribute(&atom!("class"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-classname
|
// https://dom.spec.whatwg.org/#dom-element-classname
|
||||||
fn SetClassName(self, class: DOMString) {
|
fn SetClassName(&self, class: DOMString) {
|
||||||
self.set_tokenlist_attribute(&atom!("class"), class);
|
self.set_tokenlist_attribute(&atom!("class"), class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-classlist
|
// https://dom.spec.whatwg.org/#dom-element-classlist
|
||||||
fn ClassList(self) -> Root<DOMTokenList> {
|
fn ClassList(&self) -> Root<DOMTokenList> {
|
||||||
self.class_list.or_init(|| DOMTokenList::new(self, &atom!("class")))
|
self.class_list.or_init(|| DOMTokenList::new(self, &atom!("class")))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-attributes
|
// https://dom.spec.whatwg.org/#dom-element-attributes
|
||||||
fn Attributes(self) -> Root<NamedNodeMap> {
|
fn Attributes(&self) -> Root<NamedNodeMap> {
|
||||||
self.attr_list.or_init(|| {
|
self.attr_list.or_init(|| {
|
||||||
let doc = {
|
let doc = {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
|
@ -1158,13 +1158,13 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getattribute
|
// https://dom.spec.whatwg.org/#dom-element-getattribute
|
||||||
fn GetAttribute(self, name: DOMString) -> Option<DOMString> {
|
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
|
||||||
self.get_attribute_by_name(name)
|
self.get_attribute_by_name(name)
|
||||||
.map(|s| s.r().Value())
|
.map(|s| s.r().Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getattributens
|
// https://dom.spec.whatwg.org/#dom-element-getattributens
|
||||||
fn GetAttributeNS(self,
|
fn GetAttributeNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
local_name: DOMString) -> Option<DOMString> {
|
local_name: DOMString) -> Option<DOMString> {
|
||||||
let namespace = &namespace_from_domstring(namespace);
|
let namespace = &namespace_from_domstring(namespace);
|
||||||
|
@ -1173,7 +1173,7 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-setattribute
|
// https://dom.spec.whatwg.org/#dom-element-setattribute
|
||||||
fn SetAttribute(self,
|
fn SetAttribute(&self,
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
value: DOMString) -> ErrorResult {
|
value: DOMString) -> ErrorResult {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -1193,7 +1193,7 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-setattributens
|
// https://dom.spec.whatwg.org/#dom-element-setattributens
|
||||||
fn SetAttributeNS(self,
|
fn SetAttributeNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
qualified_name: DOMString,
|
qualified_name: DOMString,
|
||||||
value: DOMString) -> ErrorResult {
|
value: DOMString) -> ErrorResult {
|
||||||
|
@ -1210,13 +1210,13 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-removeattribute
|
// https://dom.spec.whatwg.org/#dom-element-removeattribute
|
||||||
fn RemoveAttribute(self, name: DOMString) {
|
fn RemoveAttribute(&self, name: DOMString) {
|
||||||
let name = self.parsed_name(name);
|
let name = self.parsed_name(name);
|
||||||
self.remove_attribute_by_name(&name);
|
self.remove_attribute_by_name(&name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-removeattributens
|
// https://dom.spec.whatwg.org/#dom-element-removeattributens
|
||||||
fn RemoveAttributeNS(self,
|
fn RemoveAttributeNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
local_name: DOMString) {
|
local_name: DOMString) {
|
||||||
let namespace = namespace_from_domstring(namespace);
|
let namespace = namespace_from_domstring(namespace);
|
||||||
|
@ -1225,38 +1225,38 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-hasattribute
|
// https://dom.spec.whatwg.org/#dom-element-hasattribute
|
||||||
fn HasAttribute(self, name: DOMString) -> bool {
|
fn HasAttribute(&self, name: DOMString) -> bool {
|
||||||
self.GetAttribute(name).is_some()
|
self.GetAttribute(name).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-hasattributens
|
// https://dom.spec.whatwg.org/#dom-element-hasattributens
|
||||||
fn HasAttributeNS(self,
|
fn HasAttributeNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
local_name: DOMString) -> bool {
|
local_name: DOMString) -> bool {
|
||||||
self.GetAttributeNS(namespace, local_name).is_some()
|
self.GetAttributeNS(namespace, local_name).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagname
|
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagname
|
||||||
fn GetElementsByTagName(self, localname: DOMString) -> Root<HTMLCollection> {
|
fn GetElementsByTagName(&self, localname: DOMString) -> Root<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::by_tag_name(window.r(), NodeCast::from_ref(self), localname)
|
HTMLCollection::by_tag_name(window.r(), NodeCast::from_ref(self), localname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens
|
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens
|
||||||
fn GetElementsByTagNameNS(self, maybe_ns: Option<DOMString>,
|
fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>,
|
||||||
localname: DOMString) -> Root<HTMLCollection> {
|
localname: DOMString) -> Root<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::by_tag_name_ns(window.r(), NodeCast::from_ref(self), localname, maybe_ns)
|
HTMLCollection::by_tag_name_ns(window.r(), NodeCast::from_ref(self), localname, maybe_ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname
|
// https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname
|
||||||
fn GetElementsByClassName(self, classes: DOMString) -> Root<HTMLCollection> {
|
fn GetElementsByClassName(&self, classes: DOMString) -> Root<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::by_class_name(window.r(), NodeCast::from_ref(self), classes)
|
HTMLCollection::by_class_name(window.r(), NodeCast::from_ref(self), classes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
||||||
fn GetClientRects(self) -> Root<DOMRectList> {
|
fn GetClientRects(&self) -> Root<DOMRectList> {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
let raw_rects = node.get_content_boxes();
|
let raw_rects = node.get_content_boxes();
|
||||||
|
@ -1269,7 +1269,7 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
|
// https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
|
||||||
fn GetBoundingClientRect(self) -> Root<DOMRect> {
|
fn GetBoundingClientRect(&self) -> Root<DOMRect> {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
let rect = node.get_bounding_content_box();
|
let rect = node.get_bounding_content_box();
|
||||||
|
@ -1282,37 +1282,37 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-clienttop
|
// https://drafts.csswg.org/cssom-view/#dom-element-clienttop
|
||||||
fn ClientTop(self) -> i32 {
|
fn ClientTop(&self) -> i32 {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.get_client_rect().origin.y
|
node.get_client_rect().origin.y
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-clientleft
|
// https://drafts.csswg.org/cssom-view/#dom-element-clientleft
|
||||||
fn ClientLeft(self) -> i32 {
|
fn ClientLeft(&self) -> i32 {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.get_client_rect().origin.x
|
node.get_client_rect().origin.x
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-clientwidth
|
// https://drafts.csswg.org/cssom-view/#dom-element-clientwidth
|
||||||
fn ClientWidth(self) -> i32 {
|
fn ClientWidth(&self) -> i32 {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.get_client_rect().size.width
|
node.get_client_rect().size.width
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-clientheight
|
// https://drafts.csswg.org/cssom-view/#dom-element-clientheight
|
||||||
fn ClientHeight(self) -> i32 {
|
fn ClientHeight(&self) -> i32 {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.get_client_rect().size.height
|
node.get_client_rect().size.height
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
|
||||||
fn GetInnerHTML(self) -> Fallible<DOMString> {
|
fn GetInnerHTML(&self) -> Fallible<DOMString> {
|
||||||
//XXX TODO: XML case
|
//XXX TODO: XML case
|
||||||
self.serialize(ChildrenOnly)
|
self.serialize(ChildrenOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
|
||||||
fn SetInnerHTML(self, value: DOMString) -> Fallible<()> {
|
fn SetInnerHTML(&self, value: DOMString) -> Fallible<()> {
|
||||||
let context_node = NodeCast::from_ref(self);
|
let context_node = NodeCast::from_ref(self);
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let frag = try!(context_node.parse_fragment(value));
|
let frag = try!(context_node.parse_fragment(value));
|
||||||
|
@ -1322,12 +1322,12 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
||||||
fn GetOuterHTML(self) -> Fallible<DOMString> {
|
fn GetOuterHTML(&self) -> Fallible<DOMString> {
|
||||||
self.serialize(IncludeNode)
|
self.serialize(IncludeNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
||||||
fn SetOuterHTML(self, value: DOMString) -> Fallible<()> {
|
fn SetOuterHTML(&self, value: DOMString) -> Fallible<()> {
|
||||||
let context_document = document_from_node(self);
|
let context_document = document_from_node(self);
|
||||||
let context_node = NodeCast::from_ref(self);
|
let context_node = NodeCast::from_ref(self);
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -1362,83 +1362,83 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling
|
||||||
fn GetPreviousElementSibling(self) -> Option<Root<Element>> {
|
fn GetPreviousElementSibling(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).preceding_siblings()
|
NodeCast::from_ref(self).preceding_siblings()
|
||||||
.filter_map(ElementCast::to_root).next()
|
.filter_map(ElementCast::to_root).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
// https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling
|
||||||
fn GetNextElementSibling(self) -> Option<Root<Element>> {
|
fn GetNextElementSibling(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).following_siblings()
|
NodeCast::from_ref(self).following_siblings()
|
||||||
.filter_map(ElementCast::to_root).next()
|
.filter_map(ElementCast::to_root).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||||
fn Children(self) -> Root<HTMLCollection> {
|
fn Children(&self) -> Root<HTMLCollection> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
HTMLCollection::children(window.r(), NodeCast::from_ref(self))
|
HTMLCollection::children(window.r(), NodeCast::from_ref(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
||||||
fn GetFirstElementChild(self) -> Option<Root<Element>> {
|
fn GetFirstElementChild(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).child_elements().next()
|
NodeCast::from_ref(self).child_elements().next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
// https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild
|
||||||
fn GetLastElementChild(self) -> Option<Root<Element>> {
|
fn GetLastElementChild(&self) -> Option<Root<Element>> {
|
||||||
NodeCast::from_ref(self).rev_children().filter_map(ElementCast::to_root).next()
|
NodeCast::from_ref(self).rev_children().filter_map(ElementCast::to_root).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||||
fn ChildElementCount(self) -> u32 {
|
fn ChildElementCount(&self) -> u32 {
|
||||||
NodeCast::from_ref(self).child_elements().count() as u32
|
NodeCast::from_ref(self).child_elements().count() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
|
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
|
||||||
fn Prepend(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Prepend(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).prepend(nodes)
|
NodeCast::from_ref(self).prepend(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-append
|
// https://dom.spec.whatwg.org/#dom-parentnode-append
|
||||||
fn Append(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Append(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).append(nodes)
|
NodeCast::from_ref(self).append(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||||
fn QuerySelector(self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
root.query_selector(selectors)
|
root.query_selector(selectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||||
fn QuerySelectorAll(self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
||||||
let root = NodeCast::from_ref(self);
|
let root = NodeCast::from_ref(self);
|
||||||
root.query_selector_all(selectors)
|
root.query_selector_all(selectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-before
|
// https://dom.spec.whatwg.org/#dom-childnode-before
|
||||||
fn Before(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn Before(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).before(nodes)
|
NodeCast::from_ref(self).before(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-after
|
// https://dom.spec.whatwg.org/#dom-childnode-after
|
||||||
fn After(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn After(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).after(nodes)
|
NodeCast::from_ref(self).after(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
|
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
|
||||||
fn ReplaceWith(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
fn ReplaceWith(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
NodeCast::from_ref(self).replace_with(nodes)
|
NodeCast::from_ref(self).replace_with(nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-remove
|
// https://dom.spec.whatwg.org/#dom-childnode-remove
|
||||||
fn Remove(self) {
|
fn Remove(&self) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.remove_self();
|
node.remove_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-matches
|
// https://dom.spec.whatwg.org/#dom-element-matches
|
||||||
fn Matches(self, selectors: DOMString) -> Fallible<bool> {
|
fn Matches(&self, selectors: DOMString) -> Fallible<bool> {
|
||||||
match parse_author_origin_selector_list_from_str(&selectors) {
|
match parse_author_origin_selector_list_from_str(&selectors) {
|
||||||
Err(()) => Err(Syntax),
|
Err(()) => Err(Syntax),
|
||||||
Ok(ref selectors) => {
|
Ok(ref selectors) => {
|
||||||
|
@ -1448,7 +1448,7 @@ impl<'a> ElementMethods for &'a Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-closest
|
// https://dom.spec.whatwg.org/#dom-element-closest
|
||||||
fn Closest(self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
fn Closest(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
||||||
match parse_author_origin_selector_list_from_str(&selectors) {
|
match parse_author_origin_selector_list_from_str(&selectors) {
|
||||||
Err(()) => Err(Syntax),
|
Err(()) => Err(Syntax),
|
||||||
Ok(ref selectors) => {
|
Ok(ref selectors) => {
|
||||||
|
|
|
@ -114,29 +114,29 @@ impl ErrorEvent {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ErrorEventMethods for &'a ErrorEvent {
|
impl ErrorEventMethods for ErrorEvent {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-errorevent-lineno
|
// https://html.spec.whatwg.org/multipage/#dom-errorevent-lineno
|
||||||
fn Lineno(self) -> u32 {
|
fn Lineno(&self) -> u32 {
|
||||||
self.lineno.get()
|
self.lineno.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-errorevent-colno
|
// https://html.spec.whatwg.org/multipage/#dom-errorevent-colno
|
||||||
fn Colno(self) -> u32 {
|
fn Colno(&self) -> u32 {
|
||||||
self.colno.get()
|
self.colno.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-errorevent-message
|
// https://html.spec.whatwg.org/multipage/#dom-errorevent-message
|
||||||
fn Message(self) -> DOMString {
|
fn Message(&self) -> DOMString {
|
||||||
self.message.borrow().clone()
|
self.message.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-errorevent-filename
|
// https://html.spec.whatwg.org/multipage/#dom-errorevent-filename
|
||||||
fn Filename(self) -> DOMString {
|
fn Filename(&self) -> DOMString {
|
||||||
self.filename.borrow().clone()
|
self.filename.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-errorevent-error
|
// https://html.spec.whatwg.org/multipage/#dom-errorevent-error
|
||||||
fn Error(self, _cx: *mut JSContext) -> JSVal {
|
fn Error(&self, _cx: *mut JSContext) -> JSVal {
|
||||||
self.error.get()
|
self.error.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,67 +172,67 @@ impl Event {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EventMethods for &'a Event {
|
impl EventMethods for Event {
|
||||||
// https://dom.spec.whatwg.org/#dom-event-eventphase
|
// https://dom.spec.whatwg.org/#dom-event-eventphase
|
||||||
fn EventPhase(self) -> u16 {
|
fn EventPhase(&self) -> u16 {
|
||||||
self.phase.get() as u16
|
self.phase.get() as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-type
|
// https://dom.spec.whatwg.org/#dom-event-type
|
||||||
fn Type(self) -> DOMString {
|
fn Type(&self) -> DOMString {
|
||||||
self.type_.borrow().clone()
|
self.type_.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-target
|
// https://dom.spec.whatwg.org/#dom-event-target
|
||||||
fn GetTarget(self) -> Option<Root<EventTarget>> {
|
fn GetTarget(&self) -> Option<Root<EventTarget>> {
|
||||||
self.target.get().map(Root::from_rooted)
|
self.target.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||||
fn GetCurrentTarget(self) -> Option<Root<EventTarget>> {
|
fn GetCurrentTarget(&self) -> Option<Root<EventTarget>> {
|
||||||
self.current_target.get().map(Root::from_rooted)
|
self.current_target.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
// https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
||||||
fn DefaultPrevented(self) -> bool {
|
fn DefaultPrevented(&self) -> bool {
|
||||||
self.canceled.get()
|
self.canceled.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-preventdefault
|
// https://dom.spec.whatwg.org/#dom-event-preventdefault
|
||||||
fn PreventDefault(self) {
|
fn PreventDefault(&self) {
|
||||||
if self.cancelable.get() {
|
if self.cancelable.get() {
|
||||||
self.canceled.set(true)
|
self.canceled.set(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
// https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
||||||
fn StopPropagation(self) {
|
fn StopPropagation(&self) {
|
||||||
self.stop_propagation.set(true);
|
self.stop_propagation.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
// https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
||||||
fn StopImmediatePropagation(self) {
|
fn StopImmediatePropagation(&self) {
|
||||||
self.stop_immediate.set(true);
|
self.stop_immediate.set(true);
|
||||||
self.stop_propagation.set(true);
|
self.stop_propagation.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-bubbles
|
// https://dom.spec.whatwg.org/#dom-event-bubbles
|
||||||
fn Bubbles(self) -> bool {
|
fn Bubbles(&self) -> bool {
|
||||||
self.bubbles.get()
|
self.bubbles.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-cancelable
|
// https://dom.spec.whatwg.org/#dom-event-cancelable
|
||||||
fn Cancelable(self) -> bool {
|
fn Cancelable(&self) -> bool {
|
||||||
self.cancelable.get()
|
self.cancelable.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-timestamp
|
// https://dom.spec.whatwg.org/#dom-event-timestamp
|
||||||
fn TimeStamp(self) -> u64 {
|
fn TimeStamp(&self) -> u64 {
|
||||||
self.timestamp
|
self.timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-initevent
|
// https://dom.spec.whatwg.org/#dom-event-initevent
|
||||||
fn InitEvent(self,
|
fn InitEvent(&self,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool) {
|
cancelable: bool) {
|
||||||
|
@ -252,7 +252,7 @@ impl<'a> EventMethods for &'a Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-event-istrusted
|
// https://dom.spec.whatwg.org/#dom-event-istrusted
|
||||||
fn IsTrusted(self) -> bool {
|
fn IsTrusted(&self) -> bool {
|
||||||
self.trusted.get()
|
self.trusted.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,9 +284,9 @@ impl EventTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EventTargetMethods for &'a EventTarget {
|
impl EventTargetMethods for EventTarget {
|
||||||
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
||||||
fn AddEventListener(self,
|
fn AddEventListener(&self,
|
||||||
ty: DOMString,
|
ty: DOMString,
|
||||||
listener: Option<Rc<EventListener>>,
|
listener: Option<Rc<EventListener>>,
|
||||||
capture: bool) {
|
capture: bool) {
|
||||||
|
@ -312,7 +312,7 @@ impl<'a> EventTargetMethods for &'a EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
||||||
fn RemoveEventListener(self,
|
fn RemoveEventListener(&self,
|
||||||
ty: DOMString,
|
ty: DOMString,
|
||||||
listener: Option<Rc<EventListener>>,
|
listener: Option<Rc<EventListener>>,
|
||||||
capture: bool) {
|
capture: bool) {
|
||||||
|
@ -336,7 +336,7 @@ impl<'a> EventTargetMethods for &'a EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
||||||
fn DispatchEvent(self, event: &Event) -> Fallible<bool> {
|
fn DispatchEvent(&self, event: &Event) -> Fallible<bool> {
|
||||||
if event.dispatching() || !event.initialized() {
|
if event.dispatching() || !event.initialized() {
|
||||||
return Err(InvalidState);
|
return Err(InvalidState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,9 @@ impl File {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FileMethods for &'a File {
|
impl FileMethods for File {
|
||||||
// https://w3c.github.io/FileAPI/#dfn-name
|
// https://w3c.github.io/FileAPI/#dfn-name
|
||||||
fn Name(self) -> DOMString {
|
fn Name(&self) -> DOMString {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,19 +30,19 @@ impl FileList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FileListMethods for &'a FileList {
|
impl FileListMethods for FileList {
|
||||||
// https://w3c.github.io/FileAPI/#dfn-length
|
// https://w3c.github.io/FileAPI/#dfn-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
self.list.len() as u32
|
self.list.len() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-item
|
// https://w3c.github.io/FileAPI/#dfn-item
|
||||||
fn Item(self, index: u32) -> Option<Root<File>> {
|
fn Item(&self, index: u32) -> Option<Root<File>> {
|
||||||
Some(self.list[index as usize].root())
|
Some(self.list[index as usize].root())
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<File>> {
|
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<File>> {
|
||||||
let item = self.Item(index);
|
let item = self.Item(index);
|
||||||
*found = item.is_some();
|
*found = item.is_some();
|
||||||
item
|
item
|
||||||
|
|
|
@ -251,7 +251,7 @@ impl FileReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FileReaderMethods for &'a FileReader {
|
impl FileReaderMethods for FileReader {
|
||||||
event_handler!(loadstart, GetOnloadstart, SetOnloadstart);
|
event_handler!(loadstart, GetOnloadstart, SetOnloadstart);
|
||||||
event_handler!(progress, GetOnprogress, SetOnprogress);
|
event_handler!(progress, GetOnprogress, SetOnprogress);
|
||||||
event_handler!(load, GetOnload, SetOnload);
|
event_handler!(load, GetOnload, SetOnload);
|
||||||
|
@ -261,17 +261,17 @@ impl<'a> FileReaderMethods for &'a FileReader {
|
||||||
|
|
||||||
//TODO https://w3c.github.io/FileAPI/#dfn-readAsArrayBuffer
|
//TODO https://w3c.github.io/FileAPI/#dfn-readAsArrayBuffer
|
||||||
// https://w3c.github.io/FileAPI/#dfn-readAsDataURL
|
// https://w3c.github.io/FileAPI/#dfn-readAsDataURL
|
||||||
fn ReadAsDataURL(self, blob: &Blob) -> ErrorResult {
|
fn ReadAsDataURL(&self, blob: &Blob) -> ErrorResult {
|
||||||
self.read(FileReaderFunction::ReadAsDataUrl, blob, None)
|
self.read(FileReaderFunction::ReadAsDataUrl, blob, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-readAsText
|
// https://w3c.github.io/FileAPI/#dfn-readAsText
|
||||||
fn ReadAsText(self, blob: &Blob, label: Option<DOMString>) -> ErrorResult {
|
fn ReadAsText(&self, blob: &Blob, label: Option<DOMString>) -> ErrorResult {
|
||||||
self.read(FileReaderFunction::ReadAsText, blob, label)
|
self.read(FileReaderFunction::ReadAsText, blob, label)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-abort
|
// https://w3c.github.io/FileAPI/#dfn-abort
|
||||||
fn Abort(self) {
|
fn Abort(&self) {
|
||||||
// Step 2
|
// Step 2
|
||||||
if self.ready_state.get() == FileReaderReadyState::Loading {
|
if self.ready_state.get() == FileReaderReadyState::Loading {
|
||||||
self.change_ready_state(FileReaderReadyState::Done);
|
self.change_ready_state(FileReaderReadyState::Done);
|
||||||
|
@ -290,17 +290,17 @@ impl<'a> FileReaderMethods for &'a FileReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-error
|
// https://w3c.github.io/FileAPI/#dfn-error
|
||||||
fn GetError(self) -> Option<Root<DOMException>> {
|
fn GetError(&self) -> Option<Root<DOMException>> {
|
||||||
self.error.get().map(|error| error.root())
|
self.error.get().map(|error| error.root())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-result
|
// https://w3c.github.io/FileAPI/#dfn-result
|
||||||
fn GetResult(self) -> Option<DOMString> {
|
fn GetResult(&self) -> Option<DOMString> {
|
||||||
self.result.borrow().clone()
|
self.result.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#dfn-readyState
|
// https://w3c.github.io/FileAPI/#dfn-readyState
|
||||||
fn ReadyState(self) -> u16 {
|
fn ReadyState(&self) -> u16 {
|
||||||
self.ready_state.get() as u16
|
self.ready_state.get() as u16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,10 @@ impl FormData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FormDataMethods for &'a FormData {
|
impl FormDataMethods for FormData {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-append
|
// https://xhr.spec.whatwg.org/#dom-formdata-append
|
||||||
fn Append(self, name: DOMString, value: &Blob, filename: Option<DOMString>) {
|
fn Append(&self, name: DOMString, value: &Blob, filename: Option<DOMString>) {
|
||||||
let file = FormDatum::FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
|
let file = FormDatum::FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
|
||||||
let mut data = self.data.borrow_mut();
|
let mut data = self.data.borrow_mut();
|
||||||
match data.entry(name) {
|
match data.entry(name) {
|
||||||
|
@ -72,7 +72,7 @@ impl<'a> FormDataMethods for &'a FormData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-append
|
// https://xhr.spec.whatwg.org/#dom-formdata-append
|
||||||
fn Append_(self, name: DOMString, value: DOMString) {
|
fn Append_(&self, name: DOMString, value: DOMString) {
|
||||||
let mut data = self.data.borrow_mut();
|
let mut data = self.data.borrow_mut();
|
||||||
match data.entry(name) {
|
match data.entry(name) {
|
||||||
Occupied(entry) => entry.into_mut().push(FormDatum::StringData(value)),
|
Occupied(entry) => entry.into_mut().push(FormDatum::StringData(value)),
|
||||||
|
@ -81,13 +81,13 @@ impl<'a> FormDataMethods for &'a FormData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-delete
|
// https://xhr.spec.whatwg.org/#dom-formdata-delete
|
||||||
fn Delete(self, name: DOMString) {
|
fn Delete(&self, name: DOMString) {
|
||||||
self.data.borrow_mut().remove(&name);
|
self.data.borrow_mut().remove(&name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-get
|
// https://xhr.spec.whatwg.org/#dom-formdata-get
|
||||||
fn Get(self, name: DOMString) -> Option<FileOrString> {
|
fn Get(&self, name: DOMString) -> Option<FileOrString> {
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let data = self.data.borrow();
|
let data = self.data.borrow();
|
||||||
if data.contains_key(&name) {
|
if data.contains_key(&name) {
|
||||||
|
@ -103,18 +103,18 @@ impl<'a> FormDataMethods for &'a FormData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-has
|
// https://xhr.spec.whatwg.org/#dom-formdata-has
|
||||||
fn Has(self, name: DOMString) -> bool {
|
fn Has(&self, name: DOMString) -> bool {
|
||||||
self.data.borrow().contains_key(&name)
|
self.data.borrow().contains_key(&name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-set
|
// https://xhr.spec.whatwg.org/#dom-formdata-set
|
||||||
fn Set_(self, name: DOMString, value: DOMString) {
|
fn Set_(&self, name: DOMString, value: DOMString) {
|
||||||
self.data.borrow_mut().insert(name, vec!(FormDatum::StringData(value)));
|
self.data.borrow_mut().insert(name, vec!(FormDatum::StringData(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-set
|
// https://xhr.spec.whatwg.org/#dom-formdata-set
|
||||||
fn Set(self, name: DOMString, value: &Blob, filename: Option<DOMString>) {
|
fn Set(&self, name: DOMString, value: &Blob, filename: Option<DOMString>) {
|
||||||
let file = FormDatum::FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
|
let file = FormDatum::FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
|
||||||
self.data.borrow_mut().insert(name, vec!(file));
|
self.data.borrow_mut().insert(name, vec!(file));
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,21 +79,21 @@ impl VirtualMethods for HTMLAnchorElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLAnchorElementMethods for &'a HTMLAnchorElement {
|
impl HTMLAnchorElementMethods for HTMLAnchorElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-a-text
|
// https://html.spec.whatwg.org/multipage/#dom-a-text
|
||||||
fn Text(self) -> DOMString {
|
fn Text(&self) -> DOMString {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.GetTextContent().unwrap()
|
node.GetTextContent().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-a-text
|
// https://html.spec.whatwg.org/multipage/#dom-a-text
|
||||||
fn SetText(self, value: DOMString) {
|
fn SetText(&self, value: DOMString) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.SetTextContent(Some(value))
|
node.SetTextContent(Some(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-a-rellist
|
// https://html.spec.whatwg.org/multipage/#dom-a-rellist
|
||||||
fn RelList(self) -> Root<DOMTokenList> {
|
fn RelList(&self) -> Root<DOMTokenList> {
|
||||||
self.rel_list.or_init(|| {
|
self.rel_list.or_init(|| {
|
||||||
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))
|
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))
|
||||||
})
|
})
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl HTMLAppletElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLAppletElementMethods for &'a HTMLAppletElement {
|
impl HTMLAppletElementMethods for HTMLAppletElement {
|
||||||
// https://html.spec.whatwg.org/#the-applet-element:dom-applet-name
|
// https://html.spec.whatwg.org/#the-applet-element:dom-applet-name
|
||||||
make_getter!(Name);
|
make_getter!(Name);
|
||||||
make_atomic_setter!(SetName, "name");
|
make_atomic_setter!(SetName, "name");
|
||||||
|
|
|
@ -66,9 +66,9 @@ impl VirtualMethods for HTMLAreaElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLAreaElementMethods for &'a HTMLAreaElement {
|
impl HTMLAreaElementMethods for HTMLAreaElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-area-rellist
|
// https://html.spec.whatwg.org/multipage/#dom-area-rellist
|
||||||
fn RelList(self) -> Root<DOMTokenList> {
|
fn RelList(&self) -> Root<DOMTokenList> {
|
||||||
self.rel_list.or_init(|| {
|
self.rel_list.or_init(|| {
|
||||||
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))
|
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))
|
||||||
})
|
})
|
||||||
|
|
|
@ -68,19 +68,19 @@ impl HTMLBodyElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLBodyElementMethods for &'a HTMLBodyElement {
|
impl HTMLBodyElementMethods for HTMLBodyElement {
|
||||||
// https://html.spec.whatwg.org/multipage#dom-body-bgcolor
|
// https://html.spec.whatwg.org/multipage#dom-body-bgcolor
|
||||||
make_getter!(BgColor, "bgcolor");
|
make_getter!(BgColor, "bgcolor");
|
||||||
make_setter!(SetBgColor, "bgcolor");
|
make_setter!(SetBgColor, "bgcolor");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-body-element
|
// https://html.spec.whatwg.org/multipage/#the-body-element
|
||||||
fn GetOnunload(self) -> Option<Rc<EventHandlerNonNull>> {
|
fn GetOnunload(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
win.r().GetOnunload()
|
win.r().GetOnunload()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-body-element
|
// https://html.spec.whatwg.org/multipage/#the-body-element
|
||||||
fn SetOnunload(self, listener: Option<Rc<EventHandlerNonNull>>) {
|
fn SetOnunload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
win.r().SetOnunload(listener)
|
win.r().SetOnunload(listener)
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,9 @@ impl HTMLButtonElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLButtonElementMethods for &'a HTMLButtonElement {
|
impl HTMLButtonElementMethods for HTMLButtonElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
||||||
fn Validity(self) -> Root<ValidityState> {
|
fn Validity(&self) -> Root<ValidityState> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
ValidityState::new(window.r())
|
ValidityState::new(window.r())
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ impl<'a> HTMLButtonElementMethods for &'a HTMLButtonElement {
|
||||||
make_bool_setter!(SetDisabled, "disabled");
|
make_bool_setter!(SetDisabled, "disabled");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-button-type
|
// https://html.spec.whatwg.org/multipage/#dom-button-type
|
||||||
fn Type(self) -> DOMString {
|
fn Type(&self) -> DOMString {
|
||||||
let elem = ElementCast::from_ref(self);
|
let elem = ElementCast::from_ref(self);
|
||||||
let mut ty = elem.get_string_attribute(&atom!("type"));
|
let mut ty = elem.get_string_attribute(&atom!("type"));
|
||||||
ty.make_ascii_lowercase();
|
ty.make_ascii_lowercase();
|
||||||
|
|
|
@ -205,31 +205,31 @@ impl HTMLCanvasElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLCanvasElementMethods for &'a HTMLCanvasElement {
|
impl HTMLCanvasElementMethods for HTMLCanvasElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-canvas-width
|
// https://html.spec.whatwg.org/multipage/#dom-canvas-width
|
||||||
fn Width(self) -> u32 {
|
fn Width(&self) -> u32 {
|
||||||
self.width.get()
|
self.width.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-canvas-width
|
// https://html.spec.whatwg.org/multipage/#dom-canvas-width
|
||||||
fn SetWidth(self, width: u32) {
|
fn SetWidth(&self, width: u32) {
|
||||||
let elem = ElementCast::from_ref(self);
|
let elem = ElementCast::from_ref(self);
|
||||||
elem.set_uint_attribute(&atom!("width"), width)
|
elem.set_uint_attribute(&atom!("width"), width)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-canvas-height
|
// https://html.spec.whatwg.org/multipage/#dom-canvas-height
|
||||||
fn Height(self) -> u32 {
|
fn Height(&self) -> u32 {
|
||||||
self.height.get()
|
self.height.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-canvas-height
|
// https://html.spec.whatwg.org/multipage/#dom-canvas-height
|
||||||
fn SetHeight(self, height: u32) {
|
fn SetHeight(&self, height: u32) {
|
||||||
let elem = ElementCast::from_ref(self);
|
let elem = ElementCast::from_ref(self);
|
||||||
elem.set_uint_attribute(&atom!("height"), height)
|
elem.set_uint_attribute(&atom!("height"), height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-canvas-getcontext
|
// https://html.spec.whatwg.org/multipage/#dom-canvas-getcontext
|
||||||
fn GetContext(self,
|
fn GetContext(&self,
|
||||||
cx: *mut JSContext,
|
cx: *mut JSContext,
|
||||||
id: DOMString,
|
id: DOMString,
|
||||||
attributes: Vec<HandleValue>)
|
attributes: Vec<HandleValue>)
|
||||||
|
|
|
@ -192,19 +192,19 @@ impl<'a> Iterator for HTMLCollectionElementsIter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLCollectionMethods for &'a HTMLCollection {
|
impl HTMLCollectionMethods for HTMLCollection {
|
||||||
// https://dom.spec.whatwg.org/#dom-htmlcollection-length
|
// https://dom.spec.whatwg.org/#dom-htmlcollection-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
self.elements_iter().count() as u32
|
self.elements_iter().count() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
|
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
|
||||||
fn Item(self, index: u32) -> Option<Root<Element>> {
|
fn Item(&self, index: u32) -> Option<Root<Element>> {
|
||||||
self.elements_iter().nth(index as usize)
|
self.elements_iter().nth(index as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem
|
// https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem
|
||||||
fn NamedItem(self, key: DOMString) -> Option<Root<Element>> {
|
fn NamedItem(&self, key: DOMString) -> Option<Root<Element>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if key.is_empty() {
|
if key.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
|
@ -218,21 +218,21 @@ impl<'a> HTMLCollectionMethods for &'a HTMLCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
|
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
|
||||||
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<Element>> {
|
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<Element>> {
|
||||||
let maybe_elem = self.Item(index);
|
let maybe_elem = self.Item(index);
|
||||||
*found = maybe_elem.is_some();
|
*found = maybe_elem.is_some();
|
||||||
maybe_elem
|
maybe_elem
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn NamedGetter(self, name: DOMString, found: &mut bool) -> Option<Root<Element>> {
|
fn NamedGetter(&self, name: DOMString, found: &mut bool) -> Option<Root<Element>> {
|
||||||
let maybe_elem = self.NamedItem(name);
|
let maybe_elem = self.NamedItem(name);
|
||||||
*found = maybe_elem.is_some();
|
*found = maybe_elem.is_some();
|
||||||
maybe_elem
|
maybe_elem
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#interface-htmlcollection
|
// https://dom.spec.whatwg.org/#interface-htmlcollection
|
||||||
fn SupportedPropertyNames(self) -> Vec<DOMString> {
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||||
// Step 1
|
// Step 1
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,9 @@ impl HTMLDataListElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLDataListElementMethods for &'a HTMLDataListElement {
|
impl HTMLDataListElementMethods for HTMLDataListElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-datalist-options
|
// https://html.spec.whatwg.org/multipage/#dom-datalist-options
|
||||||
fn Options(self) -> Root<HTMLCollection> {
|
fn Options(&self) -> Root<HTMLCollection> {
|
||||||
#[derive(JSTraceable, HeapSizeOf)]
|
#[derive(JSTraceable, HeapSizeOf)]
|
||||||
struct HTMLDataListOptionsFilter;
|
struct HTMLDataListOptionsFilter;
|
||||||
impl CollectionFilter for HTMLDataListOptionsFilter {
|
impl CollectionFilter for HTMLDataListOptionsFilter {
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl HTMLDialogElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLDialogElementMethods for &'a HTMLDialogElement {
|
impl HTMLDialogElementMethods for HTMLDialogElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-dialog-open
|
// https://html.spec.whatwg.org/multipage/#dom-dialog-open
|
||||||
make_bool_getter!(Open);
|
make_bool_getter!(Open);
|
||||||
|
|
||||||
|
@ -59,13 +59,13 @@ impl<'a> HTMLDialogElementMethods for &'a HTMLDialogElement {
|
||||||
make_bool_setter!(SetOpen, "open");
|
make_bool_setter!(SetOpen, "open");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-dialog-returnvalue
|
// https://html.spec.whatwg.org/multipage/#dom-dialog-returnvalue
|
||||||
fn ReturnValue(self) -> DOMString {
|
fn ReturnValue(&self) -> DOMString {
|
||||||
let return_value = self.return_value.borrow();
|
let return_value = self.return_value.borrow();
|
||||||
return_value.clone()
|
return_value.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-dialog-returnvalue
|
// https://html.spec.whatwg.org/multipage/#dom-dialog-returnvalue
|
||||||
fn SetReturnValue(self, return_value: DOMString) {
|
fn SetReturnValue(&self, return_value: DOMString) {
|
||||||
*self.return_value.borrow_mut() = return_value;
|
*self.return_value.borrow_mut() = return_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,9 +124,9 @@ impl HTMLElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLElementMethods for &'a HTMLElement {
|
impl HTMLElementMethods for HTMLElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#the-style-attribute
|
// https://html.spec.whatwg.org/multipage/#the-style-attribute
|
||||||
fn Style(self) -> Root<CSSStyleDeclaration> {
|
fn Style(&self) -> Root<CSSStyleDeclaration> {
|
||||||
self.style_decl.or_init(|| {
|
self.style_decl.or_init(|| {
|
||||||
let global = window_from_node(self);
|
let global = window_from_node(self);
|
||||||
CSSStyleDeclaration::new(global.r(), ElementCast::from_ref(self), None, CSSModificationAccess::ReadWrite)
|
CSSStyleDeclaration::new(global.r(), ElementCast::from_ref(self), None, CSSModificationAccess::ReadWrite)
|
||||||
|
@ -146,12 +146,12 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
global_event_handlers!(NoOnload);
|
global_event_handlers!(NoOnload);
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-dataset
|
// https://html.spec.whatwg.org/multipage/#dom-dataset
|
||||||
fn Dataset(self) -> Root<DOMStringMap> {
|
fn Dataset(&self) -> Root<DOMStringMap> {
|
||||||
self.dataset.or_init(|| DOMStringMap::new(self))
|
self.dataset.or_init(|| DOMStringMap::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#handler-onload
|
// https://html.spec.whatwg.org/multipage/#handler-onload
|
||||||
fn GetOnload(self) -> Option<Rc<EventHandlerNonNull>> {
|
fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||||
if self.is_body_or_frameset() {
|
if self.is_body_or_frameset() {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
win.r().GetOnload()
|
win.r().GetOnload()
|
||||||
|
@ -162,7 +162,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#handler-onload
|
// https://html.spec.whatwg.org/multipage/#handler-onload
|
||||||
fn SetOnload(self, listener: Option<Rc<EventHandlerNonNull>>) {
|
fn SetOnload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||||
if self.is_body_or_frameset() {
|
if self.is_body_or_frameset() {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
win.r().SetOnload(listener)
|
win.r().SetOnload(listener)
|
||||||
|
@ -173,7 +173,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-click
|
// https://html.spec.whatwg.org/multipage/#dom-click
|
||||||
fn Click(self) {
|
fn Click(&self) {
|
||||||
let maybe_input: Option<&HTMLInputElement> = HTMLInputElementCast::to_ref(self);
|
let maybe_input: Option<&HTMLInputElement> = HTMLInputElementCast::to_ref(self);
|
||||||
if let Some(i) = maybe_input {
|
if let Some(i) = maybe_input {
|
||||||
if i.Disabled() {
|
if i.Disabled() {
|
||||||
|
@ -186,7 +186,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-focus
|
// https://html.spec.whatwg.org/multipage/#dom-focus
|
||||||
fn Focus(self) {
|
fn Focus(&self) {
|
||||||
// TODO: Mark the element as locked for focus and run the focusing steps.
|
// TODO: Mark the element as locked for focus and run the focusing steps.
|
||||||
// https://html.spec.whatwg.org/multipage/#focusing-steps
|
// https://html.spec.whatwg.org/multipage/#focusing-steps
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -198,7 +198,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-blur
|
// https://html.spec.whatwg.org/multipage/#dom-blur
|
||||||
fn Blur(self) {
|
fn Blur(&self) {
|
||||||
// TODO: Run the unfocusing steps.
|
// TODO: Run the unfocusing steps.
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
if !node.get_focus_state() {
|
if !node.get_focus_state() {
|
||||||
|
@ -212,7 +212,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
||||||
fn GetOffsetParent(self) -> Option<Root<Element>> {
|
fn GetOffsetParent(&self) -> Option<Root<Element>> {
|
||||||
if self.is_htmlbodyelement() || self.is_htmlhtmlelement() {
|
if self.is_htmlbodyelement() || self.is_htmlhtmlelement() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
||||||
fn OffsetTop(self) -> i32 {
|
fn OffsetTop(&self) -> i32 {
|
||||||
if self.is_htmlbodyelement() {
|
if self.is_htmlbodyelement() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
||||||
fn OffsetLeft(self) -> i32 {
|
fn OffsetLeft(&self) -> i32 {
|
||||||
if self.is_htmlbodyelement() {
|
if self.is_htmlbodyelement() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
||||||
fn OffsetWidth(self) -> i32 {
|
fn OffsetWidth(&self) -> i32 {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let (_, rect) = window.offset_parent_query(node.to_trusted_node_address());
|
let (_, rect) = window.offset_parent_query(node.to_trusted_node_address());
|
||||||
|
@ -260,7 +260,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
||||||
fn OffsetHeight(self) -> i32 {
|
fn OffsetHeight(&self) -> i32 {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let (_, rect) = window.offset_parent_query(node.to_trusted_node_address());
|
let (_, rect) = window.offset_parent_query(node.to_trusted_node_address());
|
||||||
|
|
|
@ -51,9 +51,9 @@ impl HTMLFieldSetElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLFieldSetElementMethods for &'a HTMLFieldSetElement {
|
impl HTMLFieldSetElementMethods for HTMLFieldSetElement {
|
||||||
// https://www.whatwg.org/html/#dom-fieldset-elements
|
// https://www.whatwg.org/html/#dom-fieldset-elements
|
||||||
fn Elements(self) -> Root<HTMLCollection> {
|
fn Elements(&self) -> Root<HTMLCollection> {
|
||||||
#[derive(JSTraceable, HeapSizeOf)]
|
#[derive(JSTraceable, HeapSizeOf)]
|
||||||
struct ElementsFilter;
|
struct ElementsFilter;
|
||||||
impl CollectionFilter for ElementsFilter {
|
impl CollectionFilter for ElementsFilter {
|
||||||
|
@ -70,7 +70,7 @@ impl<'a> HTMLFieldSetElementMethods for &'a HTMLFieldSetElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
||||||
fn Validity(self) -> Root<ValidityState> {
|
fn Validity(&self) -> Root<ValidityState> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
ValidityState::new(window.r())
|
ValidityState::new(window.r())
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl HTMLFontElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLFontElementMethods for &'a HTMLFontElement {
|
impl HTMLFontElementMethods for HTMLFontElement {
|
||||||
make_getter!(Color, "color");
|
make_getter!(Color, "color");
|
||||||
make_setter!(SetColor, "color");
|
make_setter!(SetColor, "color");
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl HTMLFormElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLFormElementMethods for &'a HTMLFormElement {
|
impl HTMLFormElementMethods for HTMLFormElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-form-acceptcharset
|
// https://html.spec.whatwg.org/multipage/#dom-form-acceptcharset
|
||||||
make_getter!(AcceptCharset, "accept-charset");
|
make_getter!(AcceptCharset, "accept-charset");
|
||||||
|
|
||||||
|
@ -105,12 +105,12 @@ impl<'a> HTMLFormElementMethods for &'a HTMLFormElement {
|
||||||
make_setter!(SetEnctype, "enctype");
|
make_setter!(SetEnctype, "enctype");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-fs-encoding
|
// https://html.spec.whatwg.org/multipage/#dom-fs-encoding
|
||||||
fn Encoding(self) -> DOMString {
|
fn Encoding(&self) -> DOMString {
|
||||||
self.Enctype()
|
self.Enctype()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-fs-encoding
|
// https://html.spec.whatwg.org/multipage/#dom-fs-encoding
|
||||||
fn SetEncoding(self, value: DOMString) {
|
fn SetEncoding(&self, value: DOMString) {
|
||||||
self.SetEnctype(value)
|
self.SetEnctype(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,12 +137,12 @@ impl<'a> HTMLFormElementMethods for &'a HTMLFormElement {
|
||||||
make_setter!(SetTarget, "target");
|
make_setter!(SetTarget, "target");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-form-element:concept-form-submit
|
// https://html.spec.whatwg.org/multipage/#the-form-element:concept-form-submit
|
||||||
fn Submit(self) {
|
fn Submit(&self) {
|
||||||
self.submit(SubmittedFrom::FromFormSubmitMethod, FormSubmitter::FormElement(self));
|
self.submit(SubmittedFrom::FromFormSubmitMethod, FormSubmitter::FormElement(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-form-reset
|
// https://html.spec.whatwg.org/multipage/#dom-form-reset
|
||||||
fn Reset(self) {
|
fn Reset(&self) {
|
||||||
self.reset(ResetFrom::FromFormResetMethod);
|
self.reset(ResetFrom::FromFormResetMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,33 +238,33 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
|
impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
|
||||||
fn Src(self) -> DOMString {
|
fn Src(&self) -> DOMString {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
element.get_string_attribute(&atom!("src"))
|
element.get_string_attribute(&atom!("src"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
|
||||||
fn SetSrc(self, src: DOMString) {
|
fn SetSrc(&self, src: DOMString) {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
element.set_url_attribute(&atom!("src"), src)
|
element.set_url_attribute(&atom!("src"), src)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
|
||||||
fn Sandbox(self) -> DOMString {
|
fn Sandbox(&self) -> DOMString {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
element.get_string_attribute(&atom!("sandbox"))
|
element.get_string_attribute(&atom!("sandbox"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
|
||||||
fn SetSandbox(self, sandbox: DOMString) {
|
fn SetSandbox(&self, sandbox: DOMString) {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
element.set_tokenlist_attribute(&atom!("sandbox"), sandbox);
|
element.set_tokenlist_attribute(&atom!("sandbox"), sandbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow
|
||||||
fn GetContentWindow(self) -> Option<Root<Window>> {
|
fn GetContentWindow(&self) -> Option<Root<Window>> {
|
||||||
self.subpage_id.get().and_then(|subpage_id| {
|
self.subpage_id.get().and_then(|subpage_id| {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
|
@ -277,7 +277,7 @@ impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
|
||||||
fn GetContentDocument(self) -> Option<Root<Document>> {
|
fn GetContentDocument(&self) -> Option<Root<Document>> {
|
||||||
self.GetContentWindow().and_then(|window| {
|
self.GetContentWindow().and_then(|window| {
|
||||||
let self_url = match self.get_url() {
|
let self_url = match self.get_url() {
|
||||||
Some(self_url) => self_url,
|
Some(self_url) => self_url,
|
||||||
|
@ -301,7 +301,7 @@ impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
|
||||||
// exposing these APIs. See https://github.com/servo/servo/issues/5264.
|
// exposing these APIs. See https://github.com/servo/servo/issues/5264.
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
|
||||||
fn Mozbrowser(self) -> bool {
|
fn Mozbrowser(&self) -> bool {
|
||||||
if opts::experimental_enabled() {
|
if opts::experimental_enabled() {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
element.has_attribute(&Atom::from_slice("mozbrowser"))
|
element.has_attribute(&Atom::from_slice("mozbrowser"))
|
||||||
|
@ -311,7 +311,7 @@ impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
|
||||||
fn SetMozbrowser(self, value: bool) -> ErrorResult {
|
fn SetMozbrowser(&self, value: bool) -> ErrorResult {
|
||||||
if opts::experimental_enabled() {
|
if opts::experimental_enabled() {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
element.set_bool_attribute(&Atom::from_slice("mozbrowser"), value);
|
element.set_bool_attribute(&Atom::from_slice("mozbrowser"), value);
|
||||||
|
@ -320,22 +320,22 @@ impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
|
||||||
fn GoBack(self) -> Fallible<()> {
|
fn GoBack(&self) -> Fallible<()> {
|
||||||
Navigate(self, NavigationDirection::Back)
|
Navigate(self, NavigationDirection::Back)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goForward
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goForward
|
||||||
fn GoForward(self) -> Fallible<()> {
|
fn GoForward(&self) -> Fallible<()> {
|
||||||
Navigate(self, NavigationDirection::Forward)
|
Navigate(self, NavigationDirection::Forward)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/reload
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/reload
|
||||||
fn Reload(self, _hardReload: bool) -> Fallible<()> {
|
fn Reload(&self, _hardReload: bool) -> Fallible<()> {
|
||||||
Err(NotSupported)
|
Err(NotSupported)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/stop
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/stop
|
||||||
fn Stop(self) -> Fallible<()> {
|
fn Stop(&self) -> Fallible<()> {
|
||||||
Err(NotSupported)
|
Err(NotSupported)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLImageElementMethods for &'a HTMLImageElement {
|
impl HTMLImageElementMethods for HTMLImageElement {
|
||||||
make_getter!(Alt);
|
make_getter!(Alt);
|
||||||
|
|
||||||
make_setter!(SetAlt, "alt");
|
make_setter!(SetAlt, "alt");
|
||||||
|
@ -213,39 +213,39 @@ impl<'a> HTMLImageElementMethods for &'a HTMLImageElement {
|
||||||
make_bool_getter!(IsMap);
|
make_bool_getter!(IsMap);
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-ismap
|
// https://html.spec.whatwg.org/multipage/#dom-img-ismap
|
||||||
fn SetIsMap(self, is_map: bool) {
|
fn SetIsMap(&self, is_map: bool) {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute(&atom!("ismap"), is_map.to_string())
|
element.set_string_attribute(&atom!("ismap"), is_map.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-width
|
// https://html.spec.whatwg.org/multipage/#dom-img-width
|
||||||
fn Width(self) -> u32 {
|
fn Width(&self) -> u32 {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
let rect = node.get_bounding_content_box();
|
let rect = node.get_bounding_content_box();
|
||||||
rect.size.width.to_px() as u32
|
rect.size.width.to_px() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-width
|
// https://html.spec.whatwg.org/multipage/#dom-img-width
|
||||||
fn SetWidth(self, width: u32) {
|
fn SetWidth(&self, width: u32) {
|
||||||
let elem = ElementCast::from_ref(self);
|
let elem = ElementCast::from_ref(self);
|
||||||
elem.set_uint_attribute(&atom!("width"), width)
|
elem.set_uint_attribute(&atom!("width"), width)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-height
|
// https://html.spec.whatwg.org/multipage/#dom-img-height
|
||||||
fn Height(self) -> u32 {
|
fn Height(&self) -> u32 {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
let rect = node.get_bounding_content_box();
|
let rect = node.get_bounding_content_box();
|
||||||
rect.size.height.to_px() as u32
|
rect.size.height.to_px() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-height
|
// https://html.spec.whatwg.org/multipage/#dom-img-height
|
||||||
fn SetHeight(self, height: u32) {
|
fn SetHeight(&self, height: u32) {
|
||||||
let elem = ElementCast::from_ref(self);
|
let elem = ElementCast::from_ref(self);
|
||||||
elem.set_uint_attribute(&atom!("height"), height)
|
elem.set_uint_attribute(&atom!("height"), height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-naturalwidth
|
// https://html.spec.whatwg.org/multipage/#dom-img-naturalwidth
|
||||||
fn NaturalWidth(self) -> u32 {
|
fn NaturalWidth(&self) -> u32 {
|
||||||
let image = self.image.borrow();
|
let image = self.image.borrow();
|
||||||
|
|
||||||
match *image {
|
match *image {
|
||||||
|
@ -255,7 +255,7 @@ impl<'a> HTMLImageElementMethods for &'a HTMLImageElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-naturalheight
|
// https://html.spec.whatwg.org/multipage/#dom-img-naturalheight
|
||||||
fn NaturalHeight(self) -> u32 {
|
fn NaturalHeight(&self) -> u32 {
|
||||||
let image = self.image.borrow();
|
let image = self.image.borrow();
|
||||||
|
|
||||||
match *image {
|
match *image {
|
||||||
|
@ -265,7 +265,7 @@ impl<'a> HTMLImageElementMethods for &'a HTMLImageElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-complete
|
// https://html.spec.whatwg.org/multipage/#dom-img-complete
|
||||||
fn Complete(self) -> bool {
|
fn Complete(&self) -> bool {
|
||||||
let image = self.image.borrow();
|
let image = self.image.borrow();
|
||||||
image.is_some()
|
image.is_some()
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ impl RawLayoutHTMLInputElementHelpers for HTMLInputElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLInputElementMethods for &'a HTMLInputElement {
|
impl HTMLInputElementMethods for HTMLInputElement {
|
||||||
// https://www.whatwg.org/html/#dom-fe-disabled
|
// https://www.whatwg.org/html/#dom-fe-disabled
|
||||||
make_bool_getter!(Disabled);
|
make_bool_getter!(Disabled);
|
||||||
|
|
||||||
|
@ -230,12 +230,12 @@ impl<'a> HTMLInputElementMethods for &'a HTMLInputElement {
|
||||||
make_bool_setter!(SetDefaultChecked, "checked");
|
make_bool_setter!(SetDefaultChecked, "checked");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-input-checked
|
// https://html.spec.whatwg.org/multipage/#dom-input-checked
|
||||||
fn Checked(self) -> bool {
|
fn Checked(&self) -> bool {
|
||||||
self.checked.get()
|
self.checked.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-input-checked
|
// https://html.spec.whatwg.org/multipage/#dom-input-checked
|
||||||
fn SetChecked(self, checked: bool) {
|
fn SetChecked(&self, checked: bool) {
|
||||||
self.update_checked_state(checked, true);
|
self.update_checked_state(checked, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,12 +262,12 @@ impl<'a> HTMLInputElementMethods for &'a HTMLInputElement {
|
||||||
make_setter!(SetType, "type");
|
make_setter!(SetType, "type");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-input-value
|
// https://html.spec.whatwg.org/multipage/#dom-input-value
|
||||||
fn Value(self) -> DOMString {
|
fn Value(&self) -> DOMString {
|
||||||
self.textinput.borrow().get_content()
|
self.textinput.borrow().get_content()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-input-value
|
// https://html.spec.whatwg.org/multipage/#dom-input-value
|
||||||
fn SetValue(self, value: DOMString) {
|
fn SetValue(&self, value: DOMString) {
|
||||||
self.textinput.borrow_mut().set_content(value);
|
self.textinput.borrow_mut().set_content(value);
|
||||||
self.value_changed.set(true);
|
self.value_changed.set(true);
|
||||||
self.force_relayout();
|
self.force_relayout();
|
||||||
|
@ -317,12 +317,12 @@ impl<'a> HTMLInputElementMethods for &'a HTMLInputElement {
|
||||||
make_setter!(SetFormTarget, "formtarget");
|
make_setter!(SetFormTarget, "formtarget");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-input-indeterminate
|
// https://html.spec.whatwg.org/multipage/#dom-input-indeterminate
|
||||||
fn Indeterminate(self) -> bool {
|
fn Indeterminate(&self) -> bool {
|
||||||
self.indeterminate.get()
|
self.indeterminate.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-input-indeterminate
|
// https://html.spec.whatwg.org/multipage/#dom-input-indeterminate
|
||||||
fn SetIndeterminate(self, val: bool) {
|
fn SetIndeterminate(&self, val: bool) {
|
||||||
self.indeterminate.set(val)
|
self.indeterminate.set(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ impl HTMLLinkElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLLinkElementMethods for &'a HTMLLinkElement {
|
impl HTMLLinkElementMethods for HTMLLinkElement {
|
||||||
make_url_getter!(Href);
|
make_url_getter!(Href);
|
||||||
make_setter!(SetHref, "href");
|
make_setter!(SetHref, "href");
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ impl<'a> HTMLLinkElementMethods for &'a HTMLLinkElement {
|
||||||
make_setter!(SetType, "type");
|
make_setter!(SetType, "type");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-link-rellist
|
// https://html.spec.whatwg.org/multipage/#dom-link-rellist
|
||||||
fn RelList(self) -> Root<DOMTokenList> {
|
fn RelList(&self) -> Root<DOMTokenList> {
|
||||||
self.rel_list.or_init(|| {
|
self.rel_list.or_init(|| {
|
||||||
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))
|
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))
|
||||||
})
|
})
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl HTMLMetaElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLMetaElementMethods for &'a HTMLMetaElement {
|
impl HTMLMetaElementMethods for HTMLMetaElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-meta-name
|
// https://html.spec.whatwg.org/multipage/#dom-meta-name
|
||||||
make_getter!(Name, "name");
|
make_getter!(Name, "name");
|
||||||
|
|
||||||
|
|
|
@ -82,9 +82,9 @@ pub fn is_image_data(uri: &str) -> bool {
|
||||||
TYPES.iter().any(|&type_| uri.starts_with(type_))
|
TYPES.iter().any(|&type_| uri.starts_with(type_))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLObjectElementMethods for &'a HTMLObjectElement {
|
impl HTMLObjectElementMethods for HTMLObjectElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
||||||
fn Validity(self) -> Root<ValidityState> {
|
fn Validity(&self) -> Root<ValidityState> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
ValidityState::new(window.r())
|
ValidityState::new(window.r())
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl HTMLOptGroupElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLOptGroupElementMethods for &'a HTMLOptGroupElement {
|
impl HTMLOptGroupElementMethods for HTMLOptGroupElement {
|
||||||
// https://www.whatwg.org/html#dom-optgroup-disabled
|
// https://www.whatwg.org/html#dom-optgroup-disabled
|
||||||
make_bool_getter!(Disabled);
|
make_bool_getter!(Disabled);
|
||||||
|
|
||||||
|
|
|
@ -70,18 +70,18 @@ fn collect_text(node: &&Node, value: &mut DOMString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLOptionElementMethods for &'a HTMLOptionElement {
|
impl HTMLOptionElementMethods for HTMLOptionElement {
|
||||||
// https://www.whatwg.org/html/#dom-option-disabled
|
// https://www.whatwg.org/html/#dom-option-disabled
|
||||||
make_bool_getter!(Disabled);
|
make_bool_getter!(Disabled);
|
||||||
|
|
||||||
// https://www.whatwg.org/html/#dom-option-disabled
|
// https://www.whatwg.org/html/#dom-option-disabled
|
||||||
fn SetDisabled(self, disabled: bool) {
|
fn SetDisabled(&self, disabled: bool) {
|
||||||
let elem = ElementCast::from_ref(self);
|
let elem = ElementCast::from_ref(self);
|
||||||
elem.set_bool_attribute(&atom!("disabled"), disabled)
|
elem.set_bool_attribute(&atom!("disabled"), disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.whatwg.org/html/#dom-option-text
|
// https://www.whatwg.org/html/#dom-option-text
|
||||||
fn Text(self) -> DOMString {
|
fn Text(&self) -> DOMString {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
let mut content = String::new();
|
let mut content = String::new();
|
||||||
collect_text(&node, &mut content);
|
collect_text(&node, &mut content);
|
||||||
|
@ -90,13 +90,13 @@ impl<'a> HTMLOptionElementMethods for &'a HTMLOptionElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.whatwg.org/html/#dom-option-text
|
// https://www.whatwg.org/html/#dom-option-text
|
||||||
fn SetText(self, value: DOMString) {
|
fn SetText(&self, value: DOMString) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.SetTextContent(Some(value))
|
node.SetTextContent(Some(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#attr-option-value
|
// https://html.spec.whatwg.org/multipage/#attr-option-value
|
||||||
fn Value(self) -> DOMString {
|
fn Value(&self) -> DOMString {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
let attr = &atom!("value");
|
let attr = &atom!("value");
|
||||||
if element.has_attribute(attr) {
|
if element.has_attribute(attr) {
|
||||||
|
@ -110,7 +110,7 @@ impl<'a> HTMLOptionElementMethods for &'a HTMLOptionElement {
|
||||||
make_setter!(SetValue, "value");
|
make_setter!(SetValue, "value");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#attr-option-label
|
// https://html.spec.whatwg.org/multipage/#attr-option-label
|
||||||
fn Label(self) -> DOMString {
|
fn Label(&self) -> DOMString {
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
let attr = &atom!("label");
|
let attr = &atom!("label");
|
||||||
if element.has_attribute(attr) {
|
if element.has_attribute(attr) {
|
||||||
|
|
|
@ -46,9 +46,9 @@ impl HTMLOutputElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLOutputElementMethods for &'a HTMLOutputElement {
|
impl HTMLOutputElementMethods for HTMLOutputElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
||||||
fn Validity(self) -> Root<ValidityState> {
|
fn Validity(&self) -> Root<ValidityState> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
ValidityState::new(window.r())
|
ValidityState::new(window.r())
|
||||||
}
|
}
|
||||||
|
|
|
@ -572,18 +572,18 @@ impl VirtualMethods for HTMLScriptElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLScriptElementMethods for &'a HTMLScriptElement {
|
impl HTMLScriptElementMethods for HTMLScriptElement {
|
||||||
make_url_getter!(Src);
|
make_url_getter!(Src);
|
||||||
|
|
||||||
make_setter!(SetSrc, "src");
|
make_setter!(SetSrc, "src");
|
||||||
|
|
||||||
// https://www.whatwg.org/html/#dom-script-text
|
// https://www.whatwg.org/html/#dom-script-text
|
||||||
fn Text(self) -> DOMString {
|
fn Text(&self) -> DOMString {
|
||||||
Node::collect_text_contents(NodeCast::from_ref(self).children())
|
Node::collect_text_contents(NodeCast::from_ref(self).children())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.whatwg.org/html/#dom-script-text
|
// https://www.whatwg.org/html/#dom-script-text
|
||||||
fn SetText(self, value: DOMString) {
|
fn SetText(&self, value: DOMString) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.SetTextContent(Some(value))
|
node.SetTextContent(Some(value))
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,16 +57,16 @@ impl HTMLSelectElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLSelectElementMethods for &'a HTMLSelectElement {
|
impl HTMLSelectElementMethods for HTMLSelectElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
||||||
fn Validity(self) -> Root<ValidityState> {
|
fn Validity(&self) -> Root<ValidityState> {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
ValidityState::new(window.r())
|
ValidityState::new(window.r())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: this function currently only exists for test_union.html.
|
// Note: this function currently only exists for test_union.html.
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-select-add
|
// https://html.spec.whatwg.org/multipage/#dom-select-add
|
||||||
fn Add(self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) {
|
fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.whatwg.org/html/#dom-fe-disabled
|
// https://www.whatwg.org/html/#dom-fe-disabled
|
||||||
|
@ -94,7 +94,7 @@ impl<'a> HTMLSelectElementMethods for &'a HTMLSelectElement {
|
||||||
make_uint_setter!(SetSize, "size", DEFAULT_SELECT_SIZE);
|
make_uint_setter!(SetSize, "size", DEFAULT_SELECT_SIZE);
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-select-type
|
// https://html.spec.whatwg.org/multipage/#dom-select-type
|
||||||
fn Type(self) -> DOMString {
|
fn Type(&self) -> DOMString {
|
||||||
if self.Multiple() {
|
if self.Multiple() {
|
||||||
"select-multiple".to_owned()
|
"select-multiple".to_owned()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl HTMLTableCellElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLTableCellElementMethods for &'a HTMLTableCellElement {
|
impl HTMLTableCellElementMethods for HTMLTableCellElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-tdth-colspan
|
// https://html.spec.whatwg.org/multipage/#dom-tdth-colspan
|
||||||
make_uint_getter!(ColSpan, "colspan", DEFAULT_COLSPAN);
|
make_uint_getter!(ColSpan, "colspan", DEFAULT_COLSPAN);
|
||||||
make_uint_setter!(SetColSpan, "colspan");
|
make_uint_setter!(SetColSpan, "colspan");
|
||||||
|
|
|
@ -66,9 +66,9 @@ impl HTMLTableElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
|
impl HTMLTableElementMethods for HTMLTableElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-table-caption
|
// https://html.spec.whatwg.org/multipage/#dom-table-caption
|
||||||
fn GetCaption(self) -> Option<Root<HTMLTableCaptionElement>> {
|
fn GetCaption(&self) -> Option<Root<HTMLTableCaptionElement>> {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.children()
|
node.children()
|
||||||
.filter_map(|c| {
|
.filter_map(|c| {
|
||||||
|
@ -78,7 +78,7 @@ impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-table-caption
|
// https://html.spec.whatwg.org/multipage/#dom-table-caption
|
||||||
fn SetCaption(self, new_caption: Option<&HTMLTableCaptionElement>) {
|
fn SetCaption(&self, new_caption: Option<&HTMLTableCaptionElement>) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
|
|
||||||
if let Some(ref caption) = self.GetCaption() {
|
if let Some(ref caption) = self.GetCaption() {
|
||||||
|
@ -92,7 +92,7 @@ impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-table-createcaption
|
// https://html.spec.whatwg.org/multipage/#dom-table-createcaption
|
||||||
fn CreateCaption(self) -> Root<HTMLElement> {
|
fn CreateCaption(&self) -> Root<HTMLElement> {
|
||||||
let caption = match self.GetCaption() {
|
let caption = match self.GetCaption() {
|
||||||
Some(caption) => caption,
|
Some(caption) => caption,
|
||||||
None => {
|
None => {
|
||||||
|
@ -107,14 +107,14 @@ impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-table-deletecaption
|
// https://html.spec.whatwg.org/multipage/#dom-table-deletecaption
|
||||||
fn DeleteCaption(self) {
|
fn DeleteCaption(&self) {
|
||||||
if let Some(caption) = self.GetCaption() {
|
if let Some(caption) = self.GetCaption() {
|
||||||
NodeCast::from_ref(caption.r()).remove_self();
|
NodeCast::from_ref(caption.r()).remove_self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-table-createtbody
|
// https://html.spec.whatwg.org/multipage/#dom-table-createtbody
|
||||||
fn CreateTBody(self) -> Root<HTMLTableSectionElement> {
|
fn CreateTBody(&self) -> Root<HTMLTableSectionElement> {
|
||||||
let tbody = HTMLTableSectionElement::new("tbody".to_owned(),
|
let tbody = HTMLTableSectionElement::new("tbody".to_owned(),
|
||||||
None,
|
None,
|
||||||
document_from_node(self).r());
|
document_from_node(self).r());
|
||||||
|
|
|
@ -114,7 +114,7 @@ impl HTMLTextAreaElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLTextAreaElementMethods for &'a HTMLTextAreaElement {
|
impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
|
||||||
// TODO A few of these attributes have default values and additional
|
// TODO A few of these attributes have default values and additional
|
||||||
// constraints
|
// constraints
|
||||||
|
|
||||||
|
@ -163,18 +163,18 @@ impl<'a> HTMLTextAreaElementMethods for &'a HTMLTextAreaElement {
|
||||||
make_setter!(SetWrap, "wrap");
|
make_setter!(SetWrap, "wrap");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-textarea-type
|
// https://html.spec.whatwg.org/multipage/#dom-textarea-type
|
||||||
fn Type(self) -> DOMString {
|
fn Type(&self) -> DOMString {
|
||||||
"textarea".to_owned()
|
"textarea".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-textarea-defaultvalue
|
// https://html.spec.whatwg.org/multipage/#dom-textarea-defaultvalue
|
||||||
fn DefaultValue(self) -> DOMString {
|
fn DefaultValue(&self) -> DOMString {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.GetTextContent().unwrap()
|
node.GetTextContent().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-textarea-defaultvalue
|
// https://html.spec.whatwg.org/multipage/#dom-textarea-defaultvalue
|
||||||
fn SetDefaultValue(self, value: DOMString) {
|
fn SetDefaultValue(&self, value: DOMString) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.SetTextContent(Some(value));
|
node.SetTextContent(Some(value));
|
||||||
|
|
||||||
|
@ -186,12 +186,12 @@ impl<'a> HTMLTextAreaElementMethods for &'a HTMLTextAreaElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
|
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
|
||||||
fn Value(self) -> DOMString {
|
fn Value(&self) -> DOMString {
|
||||||
self.textinput.borrow().get_content()
|
self.textinput.borrow().get_content()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
|
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
|
||||||
fn SetValue(self, value: DOMString) {
|
fn SetValue(&self, value: DOMString) {
|
||||||
// TODO move the cursor to the end of the field
|
// TODO move the cursor to the end of the field
|
||||||
self.textinput.borrow_mut().set_content(value);
|
self.textinput.borrow_mut().set_content(value);
|
||||||
self.value_changed.set(true);
|
self.value_changed.set(true);
|
||||||
|
|
|
@ -46,9 +46,9 @@ impl HTMLTitleElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLTitleElementMethods for &'a HTMLTitleElement {
|
impl HTMLTitleElementMethods for HTMLTitleElement {
|
||||||
// https://www.whatwg.org/html/#dom-title-text
|
// https://www.whatwg.org/html/#dom-title-text
|
||||||
fn Text(self) -> DOMString {
|
fn Text(&self) -> DOMString {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
let mut content = String::new();
|
let mut content = String::new();
|
||||||
for child in node.children() {
|
for child in node.children() {
|
||||||
|
@ -62,7 +62,7 @@ impl<'a> HTMLTitleElementMethods for &'a HTMLTitleElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.whatwg.org/html/#dom-title-text
|
// https://www.whatwg.org/html/#dom-title-text
|
||||||
fn SetText(self, value: DOMString) {
|
fn SetText(&self, value: DOMString) {
|
||||||
let node = NodeCast::from_ref(self);
|
let node = NodeCast::from_ref(self);
|
||||||
node.SetTextContent(Some(value))
|
node.SetTextContent(Some(value))
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,19 +68,19 @@ impl ImageData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ImageDataMethods for &'a ImageData {
|
impl ImageDataMethods for ImageData {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-imagedata-width
|
// 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
|
// 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
|
// 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.get()
|
self.data.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -757,9 +757,9 @@ impl KeyEventProperties {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
|
impl KeyboardEventMethods for KeyboardEvent {
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-initKeyboardEvent
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-initKeyboardEvent
|
||||||
fn InitKeyboardEvent(self,
|
fn InitKeyboardEvent(&self,
|
||||||
typeArg: DOMString,
|
typeArg: DOMString,
|
||||||
canBubbleArg: bool,
|
canBubbleArg: bool,
|
||||||
cancelableArg: bool,
|
cancelableArg: bool,
|
||||||
|
@ -782,52 +782,52 @@ impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-key
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-key
|
||||||
fn Key(self) -> DOMString {
|
fn Key(&self) -> DOMString {
|
||||||
self.key_string.borrow().clone()
|
self.key_string.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-code
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-code
|
||||||
fn Code(self) -> DOMString {
|
fn Code(&self) -> DOMString {
|
||||||
self.code.borrow().clone()
|
self.code.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-location
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-location
|
||||||
fn Location(self) -> u32 {
|
fn Location(&self) -> u32 {
|
||||||
self.location.get()
|
self.location.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-ctrlKey
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-ctrlKey
|
||||||
fn CtrlKey(self) -> bool {
|
fn CtrlKey(&self) -> bool {
|
||||||
self.ctrl.get()
|
self.ctrl.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-shiftKey
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-shiftKey
|
||||||
fn ShiftKey(self) -> bool {
|
fn ShiftKey(&self) -> bool {
|
||||||
self.shift.get()
|
self.shift.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-altKey
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-altKey
|
||||||
fn AltKey(self) -> bool {
|
fn AltKey(&self) -> bool {
|
||||||
self.alt.get()
|
self.alt.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-metaKey
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-metaKey
|
||||||
fn MetaKey(self) -> bool {
|
fn MetaKey(&self) -> bool {
|
||||||
self.meta.get()
|
self.meta.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-repeat
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-repeat
|
||||||
fn Repeat(self) -> bool {
|
fn Repeat(&self) -> bool {
|
||||||
self.repeat.get()
|
self.repeat.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-isComposing
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-isComposing
|
||||||
fn IsComposing(self) -> bool {
|
fn IsComposing(&self) -> bool {
|
||||||
self.is_composing.get()
|
self.is_composing.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-KeyboardEvent-getModifierState
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-KeyboardEvent-getModifierState
|
||||||
fn GetModifierState(self, keyArg: DOMString) -> bool {
|
fn GetModifierState(&self, keyArg: DOMString) -> bool {
|
||||||
match &*keyArg {
|
match &*keyArg {
|
||||||
"Ctrl" => self.CtrlKey(),
|
"Ctrl" => self.CtrlKey(),
|
||||||
"Alt" => self.AltKey(),
|
"Alt" => self.AltKey(),
|
||||||
|
@ -840,17 +840,17 @@ impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-charCode
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-charCode
|
||||||
fn CharCode(self) -> u32 {
|
fn CharCode(&self) -> u32 {
|
||||||
self.char_code.get().unwrap_or(0)
|
self.char_code.get().unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-keyCode
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-keyCode
|
||||||
fn KeyCode(self) -> u32 {
|
fn KeyCode(&self) -> u32 {
|
||||||
self.key_code.get()
|
self.key_code.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-KeyboardEvent-which
|
// https://w3c.github.io/uievents/#widl-KeyboardEvent-which
|
||||||
fn Which(self) -> u32 {
|
fn Which(&self) -> u32 {
|
||||||
self.char_code.get().unwrap_or(self.KeyCode())
|
self.char_code.get().unwrap_or(self.KeyCode())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ impl Location {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LocationMethods for &'a Location {
|
impl LocationMethods for Location {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-location-assign
|
// https://html.spec.whatwg.org/multipage/#dom-location-assign
|
||||||
fn Assign(self, url: DOMString) {
|
fn Assign(&self, url: DOMString) {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
// TODO: per spec, we should use the _API base URL_ specified by the
|
// TODO: per spec, we should use the _API base URL_ specified by the
|
||||||
// _entry settings object_.
|
// _entry settings object_.
|
||||||
|
@ -48,57 +48,57 @@ impl<'a> LocationMethods for &'a Location {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
// 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())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-href
|
// 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-host
|
// https://url.spec.whatwg.org/#dom-urlutils-host
|
||||||
fn Host(self) -> USVString {
|
fn Host(&self) -> USVString {
|
||||||
UrlHelper::Host(&self.get_url())
|
UrlHelper::Host(&self.get_url())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-hostname
|
// https://url.spec.whatwg.org/#dom-urlutils-hostname
|
||||||
fn Hostname(self) -> USVString {
|
fn Hostname(&self) -> USVString {
|
||||||
UrlHelper::Hostname(&self.get_url())
|
UrlHelper::Hostname(&self.get_url())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-password
|
// https://url.spec.whatwg.org/#dom-urlutils-password
|
||||||
fn Password(self) -> USVString {
|
fn Password(&self) -> USVString {
|
||||||
UrlHelper::Password(&self.get_url())
|
UrlHelper::Password(&self.get_url())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-pathname
|
// 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/#dom-urlutils-port
|
// https://url.spec.whatwg.org/#dom-urlutils-port
|
||||||
fn Port(self) -> USVString {
|
fn Port(&self) -> USVString {
|
||||||
UrlHelper::Port(&self.get_url())
|
UrlHelper::Port(&self.get_url())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-protocol
|
// https://url.spec.whatwg.org/#dom-urlutils-protocol
|
||||||
fn Protocol(self) -> USVString {
|
fn Protocol(&self) -> USVString {
|
||||||
UrlHelper::Protocol(&self.get_url())
|
UrlHelper::Protocol(&self.get_url())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
||||||
fn Stringifier(self) -> DOMString {
|
fn Stringifier(&self) -> DOMString {
|
||||||
self.Href().0
|
self.Href().0
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-search
|
// 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-username
|
// https://url.spec.whatwg.org/#dom-urlutils-username
|
||||||
fn Username(self) -> USVString {
|
fn Username(&self) -> USVString {
|
||||||
UrlHelper::Username(&self.get_url())
|
UrlHelper::Username(&self.get_url())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_getter(
|
macro_rules! make_getter(
|
||||||
( $attr:ident, $htmlname:expr ) => (
|
( $attr:ident, $htmlname:expr ) => (
|
||||||
fn $attr(self) -> DOMString {
|
fn $attr(&self) -> DOMString {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -20,7 +20,7 @@ macro_rules! make_getter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_bool_getter(
|
macro_rules! make_bool_getter(
|
||||||
( $attr:ident, $htmlname:expr ) => (
|
( $attr:ident, $htmlname:expr ) => (
|
||||||
fn $attr(self) -> bool {
|
fn $attr(&self) -> bool {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -36,7 +36,7 @@ macro_rules! make_bool_getter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_uint_getter(
|
macro_rules! make_uint_getter(
|
||||||
($attr:ident, $htmlname:expr, $default:expr) => (
|
($attr:ident, $htmlname:expr, $default:expr) => (
|
||||||
fn $attr(self) -> u32 {
|
fn $attr(&self) -> u32 {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -55,7 +55,7 @@ macro_rules! make_uint_getter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_url_getter(
|
macro_rules! make_url_getter(
|
||||||
( $attr:ident, $htmlname:expr ) => (
|
( $attr:ident, $htmlname:expr ) => (
|
||||||
fn $attr(self) -> DOMString {
|
fn $attr(&self) -> DOMString {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -72,7 +72,7 @@ macro_rules! make_url_getter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_url_or_base_getter(
|
macro_rules! make_url_or_base_getter(
|
||||||
( $attr:ident, $htmlname:expr ) => (
|
( $attr:ident, $htmlname:expr ) => (
|
||||||
fn $attr(self) -> DOMString {
|
fn $attr(&self) -> DOMString {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -93,7 +93,7 @@ macro_rules! make_url_or_base_getter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_enumerated_getter(
|
macro_rules! make_enumerated_getter(
|
||||||
( $attr:ident, $htmlname:expr, $default:expr, $(($choices: pat))|+) => (
|
( $attr:ident, $htmlname:expr, $default:expr, $(($choices: pat))|+) => (
|
||||||
fn $attr(self) -> DOMString {
|
fn $attr(&self) -> DOMString {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
|
@ -118,7 +118,7 @@ macro_rules! make_enumerated_getter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_setter(
|
macro_rules! make_setter(
|
||||||
( $attr:ident, $htmlname:expr ) => (
|
( $attr:ident, $htmlname:expr ) => (
|
||||||
fn $attr(self, value: DOMString) {
|
fn $attr(&self, value: DOMString) {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -131,7 +131,7 @@ macro_rules! make_setter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_bool_setter(
|
macro_rules! make_bool_setter(
|
||||||
( $attr:ident, $htmlname:expr ) => (
|
( $attr:ident, $htmlname:expr ) => (
|
||||||
fn $attr(self, value: bool) {
|
fn $attr(&self, value: bool) {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -144,7 +144,7 @@ macro_rules! make_bool_setter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_uint_setter(
|
macro_rules! make_uint_setter(
|
||||||
($attr:ident, $htmlname:expr, $default:expr) => (
|
($attr:ident, $htmlname:expr, $default:expr) => (
|
||||||
fn $attr(self, value: u32) {
|
fn $attr(&self, value: u32) {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let value = if value > 2147483647 {
|
let value = if value > 2147483647 {
|
||||||
|
@ -165,7 +165,7 @@ macro_rules! make_uint_setter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_limited_uint_setter(
|
macro_rules! make_limited_uint_setter(
|
||||||
($attr:ident, $htmlname:expr, $default:expr) => (
|
($attr:ident, $htmlname:expr, $default:expr) => (
|
||||||
fn $attr(self, value: u32) -> $crate::dom::bindings::error::ErrorResult {
|
fn $attr(&self, value: u32) -> $crate::dom::bindings::error::ErrorResult {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let value = if value == 0 {
|
let value = if value == 0 {
|
||||||
|
@ -192,7 +192,7 @@ macro_rules! make_limited_uint_setter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_atomic_setter(
|
macro_rules! make_atomic_setter(
|
||||||
( $attr:ident, $htmlname:expr ) => (
|
( $attr:ident, $htmlname:expr ) => (
|
||||||
fn $attr(self, value: DOMString) {
|
fn $attr(&self, value: DOMString) {
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
let element = ElementCast::from_ref(self);
|
let element = ElementCast::from_ref(self);
|
||||||
|
@ -228,12 +228,12 @@ macro_rules! no_jsmanaged_fields(
|
||||||
/// These are used to generate a event handler which has no special case.
|
/// These are used to generate a event handler which has no special case.
|
||||||
macro_rules! define_event_handler(
|
macro_rules! define_event_handler(
|
||||||
($handler: ident, $event_type: ident, $getter: ident, $setter: ident) => (
|
($handler: ident, $event_type: ident, $getter: ident, $setter: ident) => (
|
||||||
fn $getter(self) -> Option<::std::rc::Rc<$handler>> {
|
fn $getter(&self) -> Option<::std::rc::Rc<$handler>> {
|
||||||
let eventtarget = EventTargetCast::from_ref(self);
|
let eventtarget = EventTargetCast::from_ref(self);
|
||||||
eventtarget.get_event_handler_common(stringify!($event_type))
|
eventtarget.get_event_handler_common(stringify!($event_type))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn $setter(self, listener: Option<::std::rc::Rc<$handler>>) {
|
fn $setter(&self, listener: Option<::std::rc::Rc<$handler>>) {
|
||||||
let eventtarget = EventTargetCast::from_ref(self);
|
let eventtarget = EventTargetCast::from_ref(self);
|
||||||
eventtarget.set_event_handler_common(stringify!($event_type), listener)
|
eventtarget.set_event_handler_common(stringify!($event_type), listener)
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,19 +89,19 @@ impl MessageEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> MessageEventMethods for &'a MessageEvent {
|
impl MessageEventMethods for MessageEvent {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-messageevent-data
|
// https://html.spec.whatwg.org/multipage/#dom-messageevent-data
|
||||||
fn Data(self, _cx: *mut JSContext) -> JSVal {
|
fn Data(&self, _cx: *mut JSContext) -> JSVal {
|
||||||
self.data.get()
|
self.data.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-messageevent-origin
|
// https://html.spec.whatwg.org/multipage/#dom-messageevent-origin
|
||||||
fn Origin(self) -> DOMString {
|
fn Origin(&self) -> DOMString {
|
||||||
self.origin.clone()
|
self.origin.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-messageevent-lasteventid
|
// https://html.spec.whatwg.org/multipage/#dom-messageevent-lasteventid
|
||||||
fn LastEventId(self) -> DOMString {
|
fn LastEventId(&self) -> DOMString {
|
||||||
self.lastEventId.clone()
|
self.lastEventId.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,54 +114,54 @@ impl MouseEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> MouseEventMethods for &'a MouseEvent {
|
impl MouseEventMethods for MouseEvent {
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-screenX
|
// https://w3c.github.io/uievents/#widl-MouseEvent-screenX
|
||||||
fn ScreenX(self) -> i32 {
|
fn ScreenX(&self) -> i32 {
|
||||||
self.screen_x.get()
|
self.screen_x.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-screenY
|
// https://w3c.github.io/uievents/#widl-MouseEvent-screenY
|
||||||
fn ScreenY(self) -> i32 {
|
fn ScreenY(&self) -> i32 {
|
||||||
self.screen_y.get()
|
self.screen_y.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-clientX
|
// https://w3c.github.io/uievents/#widl-MouseEvent-clientX
|
||||||
fn ClientX(self) -> i32 {
|
fn ClientX(&self) -> i32 {
|
||||||
self.client_x.get()
|
self.client_x.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-clientY
|
// https://w3c.github.io/uievents/#widl-MouseEvent-clientY
|
||||||
fn ClientY(self) -> i32 {
|
fn ClientY(&self) -> i32 {
|
||||||
self.client_y.get()
|
self.client_y.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-ctrlKey
|
// https://w3c.github.io/uievents/#widl-MouseEvent-ctrlKey
|
||||||
fn CtrlKey(self) -> bool {
|
fn CtrlKey(&self) -> bool {
|
||||||
self.ctrl_key.get()
|
self.ctrl_key.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-shiftKey
|
// https://w3c.github.io/uievents/#widl-MouseEvent-shiftKey
|
||||||
fn ShiftKey(self) -> bool {
|
fn ShiftKey(&self) -> bool {
|
||||||
self.shift_key.get()
|
self.shift_key.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-altKey
|
// https://w3c.github.io/uievents/#widl-MouseEvent-altKey
|
||||||
fn AltKey(self) -> bool {
|
fn AltKey(&self) -> bool {
|
||||||
self.alt_key.get()
|
self.alt_key.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-metaKey
|
// https://w3c.github.io/uievents/#widl-MouseEvent-metaKey
|
||||||
fn MetaKey(self) -> bool {
|
fn MetaKey(&self) -> bool {
|
||||||
self.meta_key.get()
|
self.meta_key.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-button
|
// https://w3c.github.io/uievents/#widl-MouseEvent-button
|
||||||
fn Button(self) -> i16 {
|
fn Button(&self) -> i16 {
|
||||||
self.button.get()
|
self.button.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-relatedTarget
|
// https://w3c.github.io/uievents/#widl-MouseEvent-relatedTarget
|
||||||
fn GetRelatedTarget(self) -> Option<Root<EventTarget>> {
|
fn GetRelatedTarget(&self) -> Option<Root<EventTarget>> {
|
||||||
self.related_target.get().map(Root::from_rooted)
|
self.related_target.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ impl<'a> MouseEventMethods for &'a MouseEvent {
|
||||||
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1186125
|
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1186125
|
||||||
// This returns the same result as current gecko.
|
// This returns the same result as current gecko.
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
|
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
|
||||||
fn Which(self) -> i32 {
|
fn Which(&self) -> i32 {
|
||||||
if opts::experimental_enabled() {
|
if opts::experimental_enabled() {
|
||||||
(self.button.get() + 1) as i32
|
(self.button.get() + 1) as i32
|
||||||
} else {
|
} else {
|
||||||
|
@ -179,7 +179,7 @@ impl<'a> MouseEventMethods for &'a MouseEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-MouseEvent-initMouseEvent
|
// https://w3c.github.io/uievents/#widl-MouseEvent-initMouseEvent
|
||||||
fn InitMouseEvent(self,
|
fn InitMouseEvent(&self,
|
||||||
typeArg: DOMString,
|
typeArg: DOMString,
|
||||||
canBubbleArg: bool,
|
canBubbleArg: bool,
|
||||||
cancelableArg: bool,
|
cancelableArg: bool,
|
||||||
|
|
|
@ -35,9 +35,9 @@ impl NamedNodeMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
impl NamedNodeMapMethods for NamedNodeMap {
|
||||||
// https://dom.spec.whatwg.org/#dom-namednodemap-length
|
// https://dom.spec.whatwg.org/#dom-namednodemap-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let owner = owner.r();
|
let owner = owner.r();
|
||||||
|
@ -46,7 +46,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-namednodemap-item
|
// https://dom.spec.whatwg.org/#dom-namednodemap-item
|
||||||
fn Item(self, index: u32) -> Option<Root<Attr>> {
|
fn Item(&self, index: u32) -> Option<Root<Attr>> {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let owner = owner.r();
|
let owner = owner.r();
|
||||||
|
@ -55,7 +55,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-namednodemap-getnameditem
|
// https://dom.spec.whatwg.org/#dom-namednodemap-getnameditem
|
||||||
fn GetNamedItem(self, name: DOMString) -> Option<Root<Attr>> {
|
fn GetNamedItem(&self, name: DOMString) -> Option<Root<Attr>> {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let owner = owner.r();
|
let owner = owner.r();
|
||||||
|
@ -63,7 +63,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-namednodemap-getnameditemns
|
// https://dom.spec.whatwg.org/#dom-namednodemap-getnameditemns
|
||||||
fn GetNamedItemNS(self, namespace: Option<DOMString>, local_name: DOMString)
|
fn GetNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString)
|
||||||
-> Option<Root<Attr>> {
|
-> Option<Root<Attr>> {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
|
@ -73,7 +73,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
|
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
|
||||||
fn RemoveNamedItem(self, name: DOMString) -> Fallible<Root<Attr>> {
|
fn RemoveNamedItem(&self, name: DOMString) -> Fallible<Root<Attr>> {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let owner = owner.r();
|
let owner = owner.r();
|
||||||
|
@ -82,7 +82,7 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns
|
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns
|
||||||
fn RemoveNamedItemNS(self, namespace: Option<DOMString>, local_name: DOMString)
|
fn RemoveNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString)
|
||||||
-> Fallible<Root<Attr>> {
|
-> Fallible<Root<Attr>> {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
|
@ -92,20 +92,20 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-namednodemap-item
|
// https://dom.spec.whatwg.org/#dom-namednodemap-item
|
||||||
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<Attr>> {
|
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<Attr>> {
|
||||||
let item = self.Item(index);
|
let item = self.Item(index);
|
||||||
*found = item.is_some();
|
*found = item.is_some();
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn NamedGetter(self, name: DOMString, found: &mut bool) -> Option<Root<Attr>> {
|
fn NamedGetter(&self, name: DOMString, found: &mut bool) -> Option<Root<Attr>> {
|
||||||
let item = self.GetNamedItem(name);
|
let item = self.GetNamedItem(name);
|
||||||
*found = item.is_some();
|
*found = item.is_some();
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SupportedPropertyNames(self) -> Vec<DOMString> {
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||||
// FIXME: unimplemented (https://github.com/servo/servo/issues/7273)
|
// FIXME: unimplemented (https://github.com/servo/servo/issues/7273)
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,39 +30,39 @@ impl Navigator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NavigatorMethods for &'a Navigator {
|
impl NavigatorMethods for Navigator {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-product
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-product
|
||||||
fn Product(self) -> DOMString {
|
fn Product(&self) -> DOMString {
|
||||||
navigatorinfo::Product()
|
navigatorinfo::Product()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-taintenabled
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-taintenabled
|
||||||
fn TaintEnabled(self) -> bool {
|
fn TaintEnabled(&self) -> bool {
|
||||||
navigatorinfo::TaintEnabled()
|
navigatorinfo::TaintEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-appname
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-appname
|
||||||
fn AppName(self) -> DOMString {
|
fn AppName(&self) -> DOMString {
|
||||||
navigatorinfo::AppName()
|
navigatorinfo::AppName()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-appcodename
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-appcodename
|
||||||
fn AppCodeName(self) -> DOMString {
|
fn AppCodeName(&self) -> DOMString {
|
||||||
navigatorinfo::AppCodeName()
|
navigatorinfo::AppCodeName()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-platform
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-platform
|
||||||
fn Platform(self) -> DOMString {
|
fn Platform(&self) -> DOMString {
|
||||||
navigatorinfo::Platform()
|
navigatorinfo::Platform()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-useragent
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-useragent
|
||||||
fn UserAgent(self) -> DOMString {
|
fn UserAgent(&self) -> DOMString {
|
||||||
navigatorinfo::UserAgent()
|
navigatorinfo::UserAgent()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-appversion
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-appversion
|
||||||
fn AppVersion(self) -> DOMString {
|
fn AppVersion(&self) -> DOMString {
|
||||||
navigatorinfo::AppVersion()
|
navigatorinfo::AppVersion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1892,9 +1892,9 @@ impl Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NodeMethods for &'a Node {
|
impl NodeMethods for Node {
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodetype
|
// https://dom.spec.whatwg.org/#dom-node-nodetype
|
||||||
fn NodeType(self) -> u16 {
|
fn NodeType(&self) -> u16 {
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) =>
|
NodeTypeId::CharacterData(CharacterDataTypeId::Text) =>
|
||||||
NodeConstants::TEXT_NODE,
|
NodeConstants::TEXT_NODE,
|
||||||
|
@ -1914,7 +1914,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodename
|
// https://dom.spec.whatwg.org/#dom-node-nodename
|
||||||
fn NodeName(self) -> DOMString {
|
fn NodeName(&self) -> DOMString {
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
NodeTypeId::Element(..) => {
|
NodeTypeId::Element(..) => {
|
||||||
let elem: &Element = ElementCast::to_ref(self).unwrap();
|
let elem: &Element = ElementCast::to_ref(self).unwrap();
|
||||||
|
@ -1937,12 +1937,12 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-baseuri
|
// https://dom.spec.whatwg.org/#dom-node-baseuri
|
||||||
fn BaseURI(self) -> DOMString {
|
fn BaseURI(&self) -> DOMString {
|
||||||
self.owner_doc().URL()
|
self.owner_doc().URL()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
// https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
||||||
fn GetOwnerDocument(self) -> Option<Root<Document>> {
|
fn GetOwnerDocument(&self) -> Option<Root<Document>> {
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
NodeTypeId::CharacterData(..) |
|
NodeTypeId::CharacterData(..) |
|
||||||
NodeTypeId::Element(..) |
|
NodeTypeId::Element(..) |
|
||||||
|
@ -1953,22 +1953,22 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-parentnode
|
// https://dom.spec.whatwg.org/#dom-node-parentnode
|
||||||
fn GetParentNode(self) -> Option<Root<Node>> {
|
fn GetParentNode(&self) -> Option<Root<Node>> {
|
||||||
self.parent_node.get().map(Root::from_rooted)
|
self.parent_node.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-parentelement
|
// https://dom.spec.whatwg.org/#dom-node-parentelement
|
||||||
fn GetParentElement(self) -> Option<Root<Element>> {
|
fn GetParentElement(&self) -> Option<Root<Element>> {
|
||||||
self.GetParentNode().and_then(ElementCast::to_root)
|
self.GetParentNode().and_then(ElementCast::to_root)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-haschildnodes
|
// https://dom.spec.whatwg.org/#dom-node-haschildnodes
|
||||||
fn HasChildNodes(self) -> bool {
|
fn HasChildNodes(&self) -> bool {
|
||||||
self.first_child.get().is_some()
|
self.first_child.get().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-childnodes
|
// https://dom.spec.whatwg.org/#dom-node-childnodes
|
||||||
fn ChildNodes(self) -> Root<NodeList> {
|
fn ChildNodes(&self) -> Root<NodeList> {
|
||||||
self.child_list.or_init(|| {
|
self.child_list.or_init(|| {
|
||||||
let doc = self.owner_doc();
|
let doc = self.owner_doc();
|
||||||
let window = doc.r().window();
|
let window = doc.r().window();
|
||||||
|
@ -1977,39 +1977,39 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-firstchild
|
// https://dom.spec.whatwg.org/#dom-node-firstchild
|
||||||
fn GetFirstChild(self) -> Option<Root<Node>> {
|
fn GetFirstChild(&self) -> Option<Root<Node>> {
|
||||||
self.first_child.get().map(Root::from_rooted)
|
self.first_child.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-lastchild
|
// https://dom.spec.whatwg.org/#dom-node-lastchild
|
||||||
fn GetLastChild(self) -> Option<Root<Node>> {
|
fn GetLastChild(&self) -> Option<Root<Node>> {
|
||||||
self.last_child.get().map(Root::from_rooted)
|
self.last_child.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-previoussibling
|
// https://dom.spec.whatwg.org/#dom-node-previoussibling
|
||||||
fn GetPreviousSibling(self) -> Option<Root<Node>> {
|
fn GetPreviousSibling(&self) -> Option<Root<Node>> {
|
||||||
self.prev_sibling.get().map(Root::from_rooted)
|
self.prev_sibling.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nextsibling
|
// https://dom.spec.whatwg.org/#dom-node-nextsibling
|
||||||
fn GetNextSibling(self) -> Option<Root<Node>> {
|
fn GetNextSibling(&self) -> Option<Root<Node>> {
|
||||||
self.next_sibling.get().map(Root::from_rooted)
|
self.next_sibling.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||||
fn GetNodeValue(self) -> Option<DOMString> {
|
fn GetNodeValue(&self) -> Option<DOMString> {
|
||||||
CharacterDataCast::to_ref(self).map(|c| c.Data())
|
CharacterDataCast::to_ref(self).map(|c| c.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||||
fn SetNodeValue(self, val: Option<DOMString>) {
|
fn SetNodeValue(&self, val: Option<DOMString>) {
|
||||||
if let NodeTypeId::CharacterData(..) = self.type_id {
|
if let NodeTypeId::CharacterData(..) = self.type_id {
|
||||||
self.SetTextContent(val)
|
self.SetTextContent(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
||||||
fn GetTextContent(self) -> Option<DOMString> {
|
fn GetTextContent(&self) -> Option<DOMString> {
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
NodeTypeId::DocumentFragment |
|
NodeTypeId::DocumentFragment |
|
||||||
NodeTypeId::Element(..) => {
|
NodeTypeId::Element(..) => {
|
||||||
|
@ -2028,7 +2028,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
||||||
fn SetTextContent(self, value: Option<DOMString>) {
|
fn SetTextContent(&self, value: Option<DOMString>) {
|
||||||
let value = value.unwrap_or(String::new());
|
let value = value.unwrap_or(String::new());
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
NodeTypeId::DocumentFragment |
|
NodeTypeId::DocumentFragment |
|
||||||
|
@ -2058,17 +2058,17 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-insertbefore
|
// https://dom.spec.whatwg.org/#dom-node-insertbefore
|
||||||
fn InsertBefore(self, node: &Node, child: Option<&Node>) -> Fallible<Root<Node>> {
|
fn InsertBefore(&self, node: &Node, child: Option<&Node>) -> Fallible<Root<Node>> {
|
||||||
Node::pre_insert(node, self, child)
|
Node::pre_insert(node, self, child)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-appendchild
|
// https://dom.spec.whatwg.org/#dom-node-appendchild
|
||||||
fn AppendChild(self, node: &Node) -> Fallible<Root<Node>> {
|
fn AppendChild(&self, node: &Node) -> Fallible<Root<Node>> {
|
||||||
Node::pre_insert(node, self, None)
|
Node::pre_insert(node, self, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-node-replace
|
// https://dom.spec.whatwg.org/#concept-node-replace
|
||||||
fn ReplaceChild(self, node: &Node, child: &Node) -> Fallible<Root<Node>> {
|
fn ReplaceChild(&self, node: &Node, child: &Node) -> Fallible<Root<Node>> {
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
|
@ -2204,13 +2204,13 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-removechild
|
// https://dom.spec.whatwg.org/#dom-node-removechild
|
||||||
fn RemoveChild(self, node: &Node)
|
fn RemoveChild(&self, node: &Node)
|
||||||
-> Fallible<Root<Node>> {
|
-> Fallible<Root<Node>> {
|
||||||
Node::pre_remove(node, self)
|
Node::pre_remove(node, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-normalize
|
// https://dom.spec.whatwg.org/#dom-node-normalize
|
||||||
fn Normalize(self) {
|
fn Normalize(&self) {
|
||||||
let mut prev_text: Option<Root<Text>> = None;
|
let mut prev_text: Option<Root<Text>> = None;
|
||||||
for child in self.children() {
|
for child in self.children() {
|
||||||
match TextCast::to_ref(child.r()) {
|
match TextCast::to_ref(child.r()) {
|
||||||
|
@ -2239,7 +2239,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-clonenode
|
// https://dom.spec.whatwg.org/#dom-node-clonenode
|
||||||
fn CloneNode(self, deep: bool) -> Root<Node> {
|
fn CloneNode(&self, deep: bool) -> Root<Node> {
|
||||||
Node::clone(self, None, if deep {
|
Node::clone(self, None, if deep {
|
||||||
CloneChildrenFlag::CloneChildren
|
CloneChildrenFlag::CloneChildren
|
||||||
} else {
|
} else {
|
||||||
|
@ -2248,7 +2248,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-isequalnode
|
// https://dom.spec.whatwg.org/#dom-node-isequalnode
|
||||||
fn IsEqualNode(self, maybe_node: Option<&Node>) -> bool {
|
fn IsEqualNode(&self, maybe_node: Option<&Node>) -> bool {
|
||||||
fn is_equal_doctype(node: &Node, other: &Node) -> bool {
|
fn is_equal_doctype(node: &Node, other: &Node) -> bool {
|
||||||
let doctype: &DocumentType = DocumentTypeCast::to_ref(node).unwrap();
|
let doctype: &DocumentType = DocumentTypeCast::to_ref(node).unwrap();
|
||||||
let other_doctype: &DocumentType = DocumentTypeCast::to_ref(other).unwrap();
|
let other_doctype: &DocumentType = DocumentTypeCast::to_ref(other).unwrap();
|
||||||
|
@ -2333,7 +2333,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-comparedocumentposition
|
// https://dom.spec.whatwg.org/#dom-node-comparedocumentposition
|
||||||
fn CompareDocumentPosition(self, other: &Node) -> u16 {
|
fn CompareDocumentPosition(&self, other: &Node) -> u16 {
|
||||||
if self == other {
|
if self == other {
|
||||||
// step 2.
|
// step 2.
|
||||||
0
|
0
|
||||||
|
@ -2387,7 +2387,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-contains
|
// https://dom.spec.whatwg.org/#dom-node-contains
|
||||||
fn Contains(self, maybe_other: Option<&Node>) -> bool {
|
fn Contains(&self, maybe_other: Option<&Node>) -> bool {
|
||||||
match maybe_other {
|
match maybe_other {
|
||||||
None => false,
|
None => false,
|
||||||
Some(other) => self.is_inclusive_ancestor_of(other)
|
Some(other) => self.is_inclusive_ancestor_of(other)
|
||||||
|
@ -2395,7 +2395,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-lookupprefix
|
// https://dom.spec.whatwg.org/#dom-node-lookupprefix
|
||||||
fn LookupPrefix(self, namespace: Option<DOMString>) -> Option<DOMString> {
|
fn LookupPrefix(&self, namespace: Option<DOMString>) -> Option<DOMString> {
|
||||||
let namespace = namespace_from_domstring(namespace);
|
let namespace = namespace_from_domstring(namespace);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -2421,7 +2421,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
|
// https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
|
||||||
fn LookupNamespaceURI(self, prefix: Option<DOMString>) -> Option<DOMString> {
|
fn LookupNamespaceURI(&self, prefix: Option<DOMString>) -> Option<DOMString> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let prefix = match prefix {
|
let prefix = match prefix {
|
||||||
Some(ref p) if p.is_empty() => None,
|
Some(ref p) if p.is_empty() => None,
|
||||||
|
@ -2433,7 +2433,7 @@ impl<'a> NodeMethods for &'a Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace
|
// https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace
|
||||||
fn IsDefaultNamespace(self, namespace: Option<DOMString>) -> bool {
|
fn IsDefaultNamespace(&self, namespace: Option<DOMString>) -> bool {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let namespace = namespace_from_domstring(namespace);
|
let namespace = namespace_from_domstring(namespace);
|
||||||
// Steps 2 and 3.
|
// Steps 2 and 3.
|
||||||
|
|
|
@ -66,19 +66,19 @@ impl NodeIterator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NodeIteratorMethods for &'a NodeIterator {
|
impl NodeIteratorMethods for NodeIterator {
|
||||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-root
|
// https://dom.spec.whatwg.org/#dom-nodeiterator-root
|
||||||
fn Root(self) -> Root<Node> {
|
fn Root(&self) -> Root<Node> {
|
||||||
self.root_node.root()
|
self.root_node.root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-whattoshow
|
// https://dom.spec.whatwg.org/#dom-nodeiterator-whattoshow
|
||||||
fn WhatToShow(self) -> u32 {
|
fn WhatToShow(&self) -> u32 {
|
||||||
self.what_to_show
|
self.what_to_show
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-filter
|
// https://dom.spec.whatwg.org/#dom-nodeiterator-filter
|
||||||
fn GetFilter(self) -> Option<Rc<NodeFilter>> {
|
fn GetFilter(&self) -> Option<Rc<NodeFilter>> {
|
||||||
match self.filter {
|
match self.filter {
|
||||||
Filter::None => None,
|
Filter::None => None,
|
||||||
Filter::Callback(ref nf) => Some((*nf).clone()),
|
Filter::Callback(ref nf) => Some((*nf).clone()),
|
||||||
|
@ -87,17 +87,17 @@ impl<'a> NodeIteratorMethods for &'a NodeIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-referencenode
|
// https://dom.spec.whatwg.org/#dom-nodeiterator-referencenode
|
||||||
fn ReferenceNode(self) -> Root<Node> {
|
fn ReferenceNode(&self) -> Root<Node> {
|
||||||
self.reference_node.get().root()
|
self.reference_node.get().root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-pointerbeforereferencenode
|
// https://dom.spec.whatwg.org/#dom-nodeiterator-pointerbeforereferencenode
|
||||||
fn PointerBeforeReferenceNode(self) -> bool {
|
fn PointerBeforeReferenceNode(&self) -> bool {
|
||||||
self.pointer_before_reference_node.get()
|
self.pointer_before_reference_node.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-nextnode
|
// https://dom.spec.whatwg.org/#dom-nodeiterator-nextnode
|
||||||
fn NextNode(self) -> Fallible<Option<Root<Node>>> {
|
fn NextNode(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// https://dom.spec.whatwg.org/#concept-NodeIterator-traverse
|
// https://dom.spec.whatwg.org/#concept-NodeIterator-traverse
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let node = self.reference_node.get().root();
|
let node = self.reference_node.get().root();
|
||||||
|
@ -141,7 +141,7 @@ impl<'a> NodeIteratorMethods for &'a NodeIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-previousnode
|
// https://dom.spec.whatwg.org/#dom-nodeiterator-previousnode
|
||||||
fn PreviousNode(self) -> Fallible<Option<Root<Node>>> {
|
fn PreviousNode(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// https://dom.spec.whatwg.org/#concept-NodeIterator-traverse
|
// https://dom.spec.whatwg.org/#concept-NodeIterator-traverse
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let node = self.reference_node.get().root();
|
let node = self.reference_node.get().root();
|
||||||
|
@ -186,7 +186,7 @@ impl<'a> NodeIteratorMethods for &'a NodeIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-detach
|
// https://dom.spec.whatwg.org/#dom-nodeiterator-detach
|
||||||
fn Detach(self) {
|
fn Detach(&self) {
|
||||||
// This method intentionally left blank.
|
// This method intentionally left blank.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,9 @@ impl NodeList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NodeListMethods for &'a NodeList {
|
impl NodeListMethods for NodeList {
|
||||||
// https://dom.spec.whatwg.org/#dom-nodelist-length
|
// https://dom.spec.whatwg.org/#dom-nodelist-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
match self.list_type {
|
match self.list_type {
|
||||||
NodeListType::Simple(ref elems) => elems.len() as u32,
|
NodeListType::Simple(ref elems) => elems.len() as u32,
|
||||||
NodeListType::Children(ref list) => list.len(),
|
NodeListType::Children(ref list) => list.len(),
|
||||||
|
@ -62,7 +62,7 @@ impl<'a> NodeListMethods for &'a NodeList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodelist-item
|
// https://dom.spec.whatwg.org/#dom-nodelist-item
|
||||||
fn Item(self, index: u32) -> Option<Root<Node>> {
|
fn Item(&self, index: u32) -> Option<Root<Node>> {
|
||||||
match self.list_type {
|
match self.list_type {
|
||||||
NodeListType::Simple(ref elems) => {
|
NodeListType::Simple(ref elems) => {
|
||||||
elems.get(index as usize).map(|node| Root::from_rooted(*node))
|
elems.get(index as usize).map(|node| Root::from_rooted(*node))
|
||||||
|
@ -72,7 +72,7 @@ impl<'a> NodeListMethods for &'a NodeList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-nodelist-item
|
// https://dom.spec.whatwg.org/#dom-nodelist-item
|
||||||
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<Node>> {
|
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<Node>> {
|
||||||
let item = self.Item(index);
|
let item = self.Item(index);
|
||||||
*found = item.is_some();
|
*found = item.is_some();
|
||||||
item
|
item
|
||||||
|
|
|
@ -43,14 +43,14 @@ impl Performance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PerformanceMethods for &'a Performance {
|
impl PerformanceMethods for Performance {
|
||||||
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#performance-timing-attribute
|
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#performance-timing-attribute
|
||||||
fn Timing(self) -> Root<PerformanceTiming> {
|
fn Timing(&self) -> Root<PerformanceTiming> {
|
||||||
self.timing.root()
|
self.timing.root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html#dom-performance-now
|
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html#dom-performance-now
|
||||||
fn Now(self) -> DOMHighResTimeStamp {
|
fn Now(&self) -> DOMHighResTimeStamp {
|
||||||
let navStart = self.timing.root().r().NavigationStartPrecise();
|
let navStart = self.timing.root().r().NavigationStartPrecise();
|
||||||
let now = (time::precise_time_ns() as f64 - navStart) / 1000000 as f64;
|
let now = (time::precise_time_ns() as f64 - navStart) / 1000000 as f64;
|
||||||
Finite::wrap(now)
|
Finite::wrap(now)
|
||||||
|
|
|
@ -38,10 +38,10 @@ impl PerformanceTiming {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PerformanceTimingMethods for &'a PerformanceTiming {
|
impl PerformanceTimingMethods for PerformanceTiming {
|
||||||
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/
|
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/
|
||||||
// NavigationTiming/Overview.html#dom-performancetiming-navigationstart
|
// NavigationTiming/Overview.html#dom-performancetiming-navigationstart
|
||||||
fn NavigationStart(self) -> u64 {
|
fn NavigationStart(&self) -> u64 {
|
||||||
self.navigationStart
|
self.navigationStart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,9 @@ impl ProcessingInstruction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ProcessingInstructionMethods for &'a ProcessingInstruction {
|
impl ProcessingInstructionMethods for ProcessingInstruction {
|
||||||
// https://dom.spec.whatwg.org/#dom-processinginstruction-target
|
// https://dom.spec.whatwg.org/#dom-processinginstruction-target
|
||||||
fn Target(self) -> DOMString {
|
fn Target(&self) -> DOMString {
|
||||||
self.target.clone()
|
self.target.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,19 +61,19 @@ impl ProgressEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ProgressEventMethods for &'a ProgressEvent {
|
impl ProgressEventMethods for ProgressEvent {
|
||||||
// https://xhr.spec.whatwg.org/#dom-progressevent-lengthcomputable
|
// https://xhr.spec.whatwg.org/#dom-progressevent-lengthcomputable
|
||||||
fn LengthComputable(self) -> bool {
|
fn LengthComputable(&self) -> bool {
|
||||||
self.length_computable
|
self.length_computable
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-progressevent-loaded
|
// https://xhr.spec.whatwg.org/#dom-progressevent-loaded
|
||||||
fn Loaded(self) -> u64 {
|
fn Loaded(&self) -> u64 {
|
||||||
self.loaded
|
self.loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-progressevent-total
|
// https://xhr.spec.whatwg.org/#dom-progressevent-total
|
||||||
fn Total(self) -> u64 {
|
fn Total(&self) -> u64 {
|
||||||
self.total
|
self.total
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,40 +132,40 @@ impl Range {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> RangeMethods for &'a Range {
|
impl RangeMethods for Range {
|
||||||
// https://dom.spec.whatwg.org/#dom-range-startcontainer
|
// https://dom.spec.whatwg.org/#dom-range-startcontainer
|
||||||
fn StartContainer(self) -> Root<Node> {
|
fn StartContainer(&self) -> Root<Node> {
|
||||||
self.inner().borrow().start.node()
|
self.inner().borrow().start.node()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-startoffset
|
// https://dom.spec.whatwg.org/#dom-range-startoffset
|
||||||
fn StartOffset(self) -> u32 {
|
fn StartOffset(&self) -> u32 {
|
||||||
self.inner().borrow().start.offset
|
self.inner().borrow().start.offset
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-endcontainer
|
// https://dom.spec.whatwg.org/#dom-range-endcontainer
|
||||||
fn EndContainer(self) -> Root<Node> {
|
fn EndContainer(&self) -> Root<Node> {
|
||||||
self.inner().borrow().end.node()
|
self.inner().borrow().end.node()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-endoffset
|
// https://dom.spec.whatwg.org/#dom-range-endoffset
|
||||||
fn EndOffset(self) -> u32 {
|
fn EndOffset(&self) -> u32 {
|
||||||
self.inner().borrow().end.offset
|
self.inner().borrow().end.offset
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-collapsed
|
// https://dom.spec.whatwg.org/#dom-range-collapsed
|
||||||
fn Collapsed(self) -> bool {
|
fn Collapsed(&self) -> bool {
|
||||||
let inner = self.inner().borrow();
|
let inner = self.inner().borrow();
|
||||||
inner.start == inner.end
|
inner.start == inner.end
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-commonancestorcontainer
|
// https://dom.spec.whatwg.org/#dom-range-commonancestorcontainer
|
||||||
fn CommonAncestorContainer(self) -> Root<Node> {
|
fn CommonAncestorContainer(&self) -> Root<Node> {
|
||||||
self.inner().borrow().common_ancestor_container()
|
self.inner().borrow().common_ancestor_container()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-setstartnode-offset
|
// https://dom.spec.whatwg.org/#dom-range-setstartnode-offset
|
||||||
fn SetStart(self, node: &Node, offset: u32) -> ErrorResult {
|
fn SetStart(&self, node: &Node, offset: u32) -> ErrorResult {
|
||||||
if node.is_doctype() {
|
if node.is_doctype() {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
Err(Error::InvalidNodeType)
|
Err(Error::InvalidNodeType)
|
||||||
|
@ -180,7 +180,7 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-setendnode-offset
|
// https://dom.spec.whatwg.org/#dom-range-setendnode-offset
|
||||||
fn SetEnd(self, node: &Node, offset: u32) -> ErrorResult {
|
fn SetEnd(&self, node: &Node, offset: u32) -> ErrorResult {
|
||||||
if node.is_doctype() {
|
if node.is_doctype() {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
Err(Error::InvalidNodeType)
|
Err(Error::InvalidNodeType)
|
||||||
|
@ -195,46 +195,46 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-setstartbeforenode
|
// https://dom.spec.whatwg.org/#dom-range-setstartbeforenode
|
||||||
fn SetStartBefore(self, node: &Node) -> ErrorResult {
|
fn SetStartBefore(&self, node: &Node) -> ErrorResult {
|
||||||
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
|
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
|
||||||
self.SetStart(parent.r(), node.index())
|
self.SetStart(parent.r(), node.index())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-setstartafternode
|
// https://dom.spec.whatwg.org/#dom-range-setstartafternode
|
||||||
fn SetStartAfter(self, node: &Node) -> ErrorResult {
|
fn SetStartAfter(&self, node: &Node) -> ErrorResult {
|
||||||
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
|
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
|
||||||
self.SetStart(parent.r(), node.index() + 1)
|
self.SetStart(parent.r(), node.index() + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-setendbeforenode
|
// https://dom.spec.whatwg.org/#dom-range-setendbeforenode
|
||||||
fn SetEndBefore(self, node: &Node) -> ErrorResult {
|
fn SetEndBefore(&self, node: &Node) -> ErrorResult {
|
||||||
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
|
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
|
||||||
self.SetEnd(parent.r(), node.index())
|
self.SetEnd(parent.r(), node.index())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-setendafternode
|
// https://dom.spec.whatwg.org/#dom-range-setendafternode
|
||||||
fn SetEndAfter(self, node: &Node) -> ErrorResult {
|
fn SetEndAfter(&self, node: &Node) -> ErrorResult {
|
||||||
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
|
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
|
||||||
self.SetEnd(parent.r(), node.index() + 1)
|
self.SetEnd(parent.r(), node.index() + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-collapsetostart
|
// https://dom.spec.whatwg.org/#dom-range-collapsetostart
|
||||||
fn Collapse(self, to_start: bool) {
|
fn Collapse(&self, to_start: bool) {
|
||||||
self.inner().borrow_mut().collapse(to_start);
|
self.inner().borrow_mut().collapse(to_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-selectnodenode
|
// https://dom.spec.whatwg.org/#dom-range-selectnodenode
|
||||||
fn SelectNode(self, node: &Node) -> ErrorResult {
|
fn SelectNode(&self, node: &Node) -> ErrorResult {
|
||||||
self.inner().borrow_mut().select_node(node)
|
self.inner().borrow_mut().select_node(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-selectnodecontentsnode
|
// https://dom.spec.whatwg.org/#dom-range-selectnodecontentsnode
|
||||||
fn SelectNodeContents(self, node: &Node) -> ErrorResult {
|
fn SelectNodeContents(&self, node: &Node) -> ErrorResult {
|
||||||
self.inner().borrow_mut().select_node_contents(node)
|
self.inner().borrow_mut().select_node_contents(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-compareboundarypointshow-sourcerange
|
// https://dom.spec.whatwg.org/#dom-range-compareboundarypointshow-sourcerange
|
||||||
fn CompareBoundaryPoints(self, how: u16, source_range: &Range)
|
fn CompareBoundaryPoints(&self, how: u16, source_range: &Range)
|
||||||
-> Fallible<i16> {
|
-> Fallible<i16> {
|
||||||
if how > RangeConstants::END_TO_START {
|
if how > RangeConstants::END_TO_START {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -275,7 +275,7 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-clonerange
|
// https://dom.spec.whatwg.org/#dom-range-clonerange
|
||||||
fn CloneRange(self) -> Root<Range> {
|
fn CloneRange(&self) -> Root<Range> {
|
||||||
let inner = self.inner().borrow();
|
let inner = self.inner().borrow();
|
||||||
let start = &inner.start;
|
let start = &inner.start;
|
||||||
let end = &inner.end;
|
let end = &inner.end;
|
||||||
|
@ -286,7 +286,7 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-ispointinrangenode-offset
|
// https://dom.spec.whatwg.org/#dom-range-ispointinrangenode-offset
|
||||||
fn IsPointInRange(self, node: &Node, offset: u32) -> Fallible<bool> {
|
fn IsPointInRange(&self, node: &Node, offset: u32) -> Fallible<bool> {
|
||||||
match self.inner().borrow().compare_point(node, offset) {
|
match self.inner().borrow().compare_point(node, offset) {
|
||||||
Ok(Ordering::Less) => Ok(false),
|
Ok(Ordering::Less) => Ok(false),
|
||||||
Ok(Ordering::Equal) => Ok(true),
|
Ok(Ordering::Equal) => Ok(true),
|
||||||
|
@ -300,7 +300,7 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-comparepointnode-offset
|
// https://dom.spec.whatwg.org/#dom-range-comparepointnode-offset
|
||||||
fn ComparePoint(self, node: &Node, offset: u32) -> Fallible<i16> {
|
fn ComparePoint(&self, node: &Node, offset: u32) -> Fallible<i16> {
|
||||||
self.inner().borrow().compare_point(node, offset).map(|order| {
|
self.inner().borrow().compare_point(node, offset).map(|order| {
|
||||||
match order {
|
match order {
|
||||||
Ordering::Less => -1,
|
Ordering::Less => -1,
|
||||||
|
@ -311,7 +311,7 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-intersectsnode
|
// https://dom.spec.whatwg.org/#dom-range-intersectsnode
|
||||||
fn IntersectsNode(self, node: &Node) -> bool {
|
fn IntersectsNode(&self, node: &Node) -> bool {
|
||||||
let inner = self.inner().borrow();
|
let inner = self.inner().borrow();
|
||||||
let start = &inner.start;
|
let start = &inner.start;
|
||||||
let start_node = start.node();
|
let start_node = start.node();
|
||||||
|
@ -343,7 +343,7 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-clonecontents
|
// https://dom.spec.whatwg.org/#dom-range-clonecontents
|
||||||
// https://dom.spec.whatwg.org/#concept-range-clone
|
// https://dom.spec.whatwg.org/#concept-range-clone
|
||||||
fn CloneContents(self) -> Fallible<Root<DocumentFragment>> {
|
fn CloneContents(&self) -> Fallible<Root<DocumentFragment>> {
|
||||||
let inner = self.inner.borrow();
|
let inner = self.inner.borrow();
|
||||||
let start = &inner.start;
|
let start = &inner.start;
|
||||||
let end = &inner.end;
|
let end = &inner.end;
|
||||||
|
@ -452,7 +452,7 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-extractcontents
|
// https://dom.spec.whatwg.org/#dom-range-extractcontents
|
||||||
// https://dom.spec.whatwg.org/#concept-range-extract
|
// https://dom.spec.whatwg.org/#concept-range-extract
|
||||||
fn ExtractContents(self) -> Fallible<Root<DocumentFragment>> {
|
fn ExtractContents(&self) -> Fallible<Root<DocumentFragment>> {
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
let (start_node, start_offset, end_node, end_offset) = {
|
let (start_node, start_offset, end_node, end_offset) = {
|
||||||
|
@ -581,13 +581,13 @@ impl<'a> RangeMethods for &'a Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-detach
|
// https://dom.spec.whatwg.org/#dom-range-detach
|
||||||
fn Detach(self) {
|
fn Detach(&self) {
|
||||||
// This method intentionally left blank.
|
// This method intentionally left blank.
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-insertnode
|
// https://dom.spec.whatwg.org/#dom-range-insertnode
|
||||||
// https://dom.spec.whatwg.org/#concept-range-insert
|
// https://dom.spec.whatwg.org/#concept-range-insert
|
||||||
fn InsertNode(self, node: &Node) -> ErrorResult {
|
fn InsertNode(&self, node: &Node) -> ErrorResult {
|
||||||
let (start_node, start_offset) = {
|
let (start_node, start_offset) = {
|
||||||
let inner = self.inner().borrow();
|
let inner = self.inner().borrow();
|
||||||
let start = &inner.start;
|
let start = &inner.start;
|
||||||
|
|
|
@ -28,14 +28,14 @@ impl Screen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ScreenMethods for &'a Screen {
|
impl ScreenMethods for Screen {
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-screen-colordepth
|
// https://drafts.csswg.org/cssom-view/#dom-screen-colordepth
|
||||||
fn ColorDepth(self) -> u32 {
|
fn ColorDepth(&self) -> u32 {
|
||||||
24
|
24
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-screen-pixeldepth
|
// https://drafts.csswg.org/cssom-view/#dom-screen-pixeldepth
|
||||||
fn PixelDepth(self) -> u32 {
|
fn PixelDepth(&self) -> u32 {
|
||||||
24
|
24
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,9 @@ impl Storage {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StorageMethods for &'a Storage {
|
impl StorageMethods for Storage {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storage-length
|
// https://html.spec.whatwg.org/multipage/#dom-storage-length
|
||||||
fn Length(self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
self.get_storage_task().send(StorageTaskMsg::Length(sender, self.get_url(), self.storage_type)).unwrap();
|
self.get_storage_task().send(StorageTaskMsg::Length(sender, self.get_url(), self.storage_type)).unwrap();
|
||||||
|
@ -65,7 +65,7 @@ impl<'a> StorageMethods for &'a Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storage-key
|
// https://html.spec.whatwg.org/multipage/#dom-storage-key
|
||||||
fn Key(self, index: u32) -> Option<DOMString> {
|
fn Key(&self, index: u32) -> Option<DOMString> {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
self.get_storage_task().send(StorageTaskMsg::Key(sender, self.get_url(), self.storage_type, index)).unwrap();
|
self.get_storage_task().send(StorageTaskMsg::Key(sender, self.get_url(), self.storage_type, index)).unwrap();
|
||||||
|
@ -73,7 +73,7 @@ impl<'a> StorageMethods for &'a Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storage-getitem
|
// https://html.spec.whatwg.org/multipage/#dom-storage-getitem
|
||||||
fn GetItem(self, name: DOMString) -> Option<DOMString> {
|
fn GetItem(&self, name: DOMString) -> Option<DOMString> {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
let msg = StorageTaskMsg::GetItem(sender, self.get_url(), self.storage_type, name);
|
let msg = StorageTaskMsg::GetItem(sender, self.get_url(), self.storage_type, name);
|
||||||
|
@ -82,7 +82,7 @@ impl<'a> StorageMethods for &'a Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storage-setitem
|
// https://html.spec.whatwg.org/multipage/#dom-storage-setitem
|
||||||
fn SetItem(self, name: DOMString, value: DOMString) {
|
fn SetItem(&self, name: DOMString, value: DOMString) {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
let msg = StorageTaskMsg::SetItem(sender, self.get_url(), self.storage_type, name.clone(), value.clone());
|
let msg = StorageTaskMsg::SetItem(sender, self.get_url(), self.storage_type, name.clone(), value.clone());
|
||||||
|
@ -94,7 +94,7 @@ impl<'a> StorageMethods for &'a Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storage-removeitem
|
// https://html.spec.whatwg.org/multipage/#dom-storage-removeitem
|
||||||
fn RemoveItem(self, name: DOMString) {
|
fn RemoveItem(&self, name: DOMString) {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
let msg = StorageTaskMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone());
|
let msg = StorageTaskMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone());
|
||||||
|
@ -105,7 +105,7 @@ impl<'a> StorageMethods for &'a Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storage-clear
|
// https://html.spec.whatwg.org/multipage/#dom-storage-clear
|
||||||
fn Clear(self) {
|
fn Clear(&self) {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap();
|
self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap();
|
||||||
|
@ -115,25 +115,25 @@ impl<'a> StorageMethods for &'a Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn NamedGetter(self, name: DOMString, found: &mut bool) -> Option<DOMString> {
|
fn NamedGetter(&self, name: DOMString, found: &mut bool) -> Option<DOMString> {
|
||||||
let item = self.GetItem(name);
|
let item = self.GetItem(name);
|
||||||
*found = item.is_some();
|
*found = item.is_some();
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NamedSetter(self, name: DOMString, value: DOMString) {
|
fn NamedSetter(&self, name: DOMString, value: DOMString) {
|
||||||
self.SetItem(name, value);
|
self.SetItem(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NamedCreator(self, name: DOMString, value: DOMString) {
|
fn NamedCreator(&self, name: DOMString, value: DOMString) {
|
||||||
self.SetItem(name, value);
|
self.SetItem(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NamedDeleter(self, name: DOMString) {
|
fn NamedDeleter(&self, name: DOMString) {
|
||||||
self.RemoveItem(name);
|
self.RemoveItem(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SupportedPropertyNames(self) -> Vec<DOMString> {
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||||
// FIXME: unimplemented (https://github.com/servo/servo/issues/7273)
|
// FIXME: unimplemented (https://github.com/servo/servo/issues/7273)
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,29 +87,29 @@ impl StorageEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StorageEventMethods for &'a StorageEvent {
|
impl StorageEventMethods for StorageEvent {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storageevent-key
|
// https://html.spec.whatwg.org/multipage/#dom-storageevent-key
|
||||||
fn GetKey(self) -> Option<DOMString> {
|
fn GetKey(&self) -> Option<DOMString> {
|
||||||
self.key.borrow().clone()
|
self.key.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storageevent-oldvalue
|
// https://html.spec.whatwg.org/multipage/#dom-storageevent-oldvalue
|
||||||
fn GetOldValue(self) -> Option<DOMString> {
|
fn GetOldValue(&self) -> Option<DOMString> {
|
||||||
self.oldValue.borrow().clone()
|
self.oldValue.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storageevent-newvalue
|
// https://html.spec.whatwg.org/multipage/#dom-storageevent-newvalue
|
||||||
fn GetNewValue(self) -> Option<DOMString> {
|
fn GetNewValue(&self) -> Option<DOMString> {
|
||||||
self.newValue.borrow().clone()
|
self.newValue.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storageevent-url
|
// https://html.spec.whatwg.org/multipage/#dom-storageevent-url
|
||||||
fn Url(self) -> DOMString {
|
fn Url(&self) -> DOMString {
|
||||||
self.url.borrow().clone()
|
self.url.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-storageevent-storagearea
|
// https://html.spec.whatwg.org/multipage/#dom-storageevent-storagearea
|
||||||
fn GetStorageArea(self) -> Option<Root<Storage>> {
|
fn GetStorageArea(&self) -> Option<Root<Storage>> {
|
||||||
self.storageArea.get().map(Root::from_rooted)
|
self.storageArea.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,333 +35,333 @@ pub struct TestBinding {
|
||||||
global: GlobalField,
|
global: GlobalField,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TestBindingMethods for &'a TestBinding {
|
impl TestBindingMethods for TestBinding {
|
||||||
fn BooleanAttribute(self) -> bool { false }
|
fn BooleanAttribute(&self) -> bool { false }
|
||||||
fn SetBooleanAttribute(self, _: bool) {}
|
fn SetBooleanAttribute(&self, _: bool) {}
|
||||||
fn ByteAttribute(self) -> i8 { 0 }
|
fn ByteAttribute(&self) -> i8 { 0 }
|
||||||
fn SetByteAttribute(self, _: i8) {}
|
fn SetByteAttribute(&self, _: i8) {}
|
||||||
fn OctetAttribute(self) -> u8 { 0 }
|
fn OctetAttribute(&self) -> u8 { 0 }
|
||||||
fn SetOctetAttribute(self, _: u8) {}
|
fn SetOctetAttribute(&self, _: u8) {}
|
||||||
fn ShortAttribute(self) -> i16 { 0 }
|
fn ShortAttribute(&self) -> i16 { 0 }
|
||||||
fn SetShortAttribute(self, _: i16) {}
|
fn SetShortAttribute(&self, _: i16) {}
|
||||||
fn UnsignedShortAttribute(self) -> u16 { 0 }
|
fn UnsignedShortAttribute(&self) -> u16 { 0 }
|
||||||
fn SetUnsignedShortAttribute(self, _: u16) {}
|
fn SetUnsignedShortAttribute(&self, _: u16) {}
|
||||||
fn LongAttribute(self) -> i32 { 0 }
|
fn LongAttribute(&self) -> i32 { 0 }
|
||||||
fn SetLongAttribute(self, _: i32) {}
|
fn SetLongAttribute(&self, _: i32) {}
|
||||||
fn UnsignedLongAttribute(self) -> u32 { 0 }
|
fn UnsignedLongAttribute(&self) -> u32 { 0 }
|
||||||
fn SetUnsignedLongAttribute(self, _: u32) {}
|
fn SetUnsignedLongAttribute(&self, _: u32) {}
|
||||||
fn LongLongAttribute(self) -> i64 { 0 }
|
fn LongLongAttribute(&self) -> i64 { 0 }
|
||||||
fn SetLongLongAttribute(self, _: i64) {}
|
fn SetLongLongAttribute(&self, _: i64) {}
|
||||||
fn UnsignedLongLongAttribute(self) -> u64 { 0 }
|
fn UnsignedLongLongAttribute(&self) -> u64 { 0 }
|
||||||
fn SetUnsignedLongLongAttribute(self, _: u64) {}
|
fn SetUnsignedLongLongAttribute(&self, _: u64) {}
|
||||||
fn UnrestrictedFloatAttribute(self) -> f32 { 0. }
|
fn UnrestrictedFloatAttribute(&self) -> f32 { 0. }
|
||||||
fn SetUnrestrictedFloatAttribute(self, _: f32) {}
|
fn SetUnrestrictedFloatAttribute(&self, _: f32) {}
|
||||||
fn FloatAttribute(self) -> Finite<f32> { Finite::wrap(0.) }
|
fn FloatAttribute(&self) -> Finite<f32> { Finite::wrap(0.) }
|
||||||
fn SetFloatAttribute(self, _: Finite<f32>) {}
|
fn SetFloatAttribute(&self, _: Finite<f32>) {}
|
||||||
fn UnrestrictedDoubleAttribute(self) -> f64 { 0. }
|
fn UnrestrictedDoubleAttribute(&self) -> f64 { 0. }
|
||||||
fn SetUnrestrictedDoubleAttribute(self, _: f64) {}
|
fn SetUnrestrictedDoubleAttribute(&self, _: f64) {}
|
||||||
fn DoubleAttribute(self) -> Finite<f64> { Finite::wrap(0.) }
|
fn DoubleAttribute(&self) -> Finite<f64> { Finite::wrap(0.) }
|
||||||
fn SetDoubleAttribute(self, _: Finite<f64>) {}
|
fn SetDoubleAttribute(&self, _: Finite<f64>) {}
|
||||||
fn StringAttribute(self) -> DOMString { "".to_owned() }
|
fn StringAttribute(&self) -> DOMString { "".to_owned() }
|
||||||
fn SetStringAttribute(self, _: DOMString) {}
|
fn SetStringAttribute(&self, _: DOMString) {}
|
||||||
fn UsvstringAttribute(self) -> USVString { USVString("".to_owned()) }
|
fn UsvstringAttribute(&self) -> USVString { USVString("".to_owned()) }
|
||||||
fn SetUsvstringAttribute(self, _: USVString) {}
|
fn SetUsvstringAttribute(&self, _: USVString) {}
|
||||||
fn ByteStringAttribute(self) -> ByteString { ByteString::new(vec!()) }
|
fn ByteStringAttribute(&self) -> ByteString { ByteString::new(vec!()) }
|
||||||
fn SetByteStringAttribute(self, _: ByteString) {}
|
fn SetByteStringAttribute(&self, _: ByteString) {}
|
||||||
fn EnumAttribute(self) -> TestEnum { _empty }
|
fn EnumAttribute(&self) -> TestEnum { _empty }
|
||||||
fn SetEnumAttribute(self, _: TestEnum) {}
|
fn SetEnumAttribute(&self, _: TestEnum) {}
|
||||||
fn InterfaceAttribute(self) -> Root<Blob> {
|
fn InterfaceAttribute(&self) -> Root<Blob> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
Blob::new(global.r(), None, "")
|
Blob::new(global.r(), None, "")
|
||||||
}
|
}
|
||||||
fn SetInterfaceAttribute(self, _: &Blob) {}
|
fn SetInterfaceAttribute(&self, _: &Blob) {}
|
||||||
fn UnionAttribute(self) -> HTMLElementOrLong { eLong(0) }
|
fn UnionAttribute(&self) -> HTMLElementOrLong { eLong(0) }
|
||||||
fn SetUnionAttribute(self, _: HTMLElementOrLong) {}
|
fn SetUnionAttribute(&self, _: HTMLElementOrLong) {}
|
||||||
fn Union2Attribute(self) -> EventOrString { eString("".to_owned()) }
|
fn Union2Attribute(&self) -> EventOrString { eString("".to_owned()) }
|
||||||
fn SetUnion2Attribute(self, _: EventOrString) {}
|
fn SetUnion2Attribute(&self, _: EventOrString) {}
|
||||||
fn ArrayAttribute(self, _: *mut JSContext) -> *mut JSObject { NullValue().to_object_or_null() }
|
fn ArrayAttribute(&self, _: *mut JSContext) -> *mut JSObject { NullValue().to_object_or_null() }
|
||||||
fn AnyAttribute(self, _: *mut JSContext) -> JSVal { NullValue() }
|
fn AnyAttribute(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||||
fn SetAnyAttribute(self, _: *mut JSContext, _: HandleValue) {}
|
fn SetAnyAttribute(&self, _: *mut JSContext, _: HandleValue) {}
|
||||||
fn ObjectAttribute(self, _: *mut JSContext) -> *mut JSObject { panic!() }
|
fn ObjectAttribute(&self, _: *mut JSContext) -> *mut JSObject { panic!() }
|
||||||
fn SetObjectAttribute(self, _: *mut JSContext, _: *mut JSObject) {}
|
fn SetObjectAttribute(&self, _: *mut JSContext, _: *mut JSObject) {}
|
||||||
|
|
||||||
fn GetBooleanAttributeNullable(self) -> Option<bool> { Some(false) }
|
fn GetBooleanAttributeNullable(&self) -> Option<bool> { Some(false) }
|
||||||
fn SetBooleanAttributeNullable(self, _: Option<bool>) {}
|
fn SetBooleanAttributeNullable(&self, _: Option<bool>) {}
|
||||||
fn GetByteAttributeNullable(self) -> Option<i8> { Some(0) }
|
fn GetByteAttributeNullable(&self) -> Option<i8> { Some(0) }
|
||||||
fn SetByteAttributeNullable(self, _: Option<i8>) {}
|
fn SetByteAttributeNullable(&self, _: Option<i8>) {}
|
||||||
fn GetOctetAttributeNullable(self) -> Option<u8> { Some(0) }
|
fn GetOctetAttributeNullable(&self) -> Option<u8> { Some(0) }
|
||||||
fn SetOctetAttributeNullable(self, _: Option<u8>) {}
|
fn SetOctetAttributeNullable(&self, _: Option<u8>) {}
|
||||||
fn GetShortAttributeNullable(self) -> Option<i16> { Some(0) }
|
fn GetShortAttributeNullable(&self) -> Option<i16> { Some(0) }
|
||||||
fn SetShortAttributeNullable(self, _: Option<i16>) {}
|
fn SetShortAttributeNullable(&self, _: Option<i16>) {}
|
||||||
fn GetUnsignedShortAttributeNullable(self) -> Option<u16> { Some(0) }
|
fn GetUnsignedShortAttributeNullable(&self) -> Option<u16> { Some(0) }
|
||||||
fn SetUnsignedShortAttributeNullable(self, _: Option<u16>) {}
|
fn SetUnsignedShortAttributeNullable(&self, _: Option<u16>) {}
|
||||||
fn GetLongAttributeNullable(self) -> Option<i32> { Some(0) }
|
fn GetLongAttributeNullable(&self) -> Option<i32> { Some(0) }
|
||||||
fn SetLongAttributeNullable(self, _: Option<i32>) {}
|
fn SetLongAttributeNullable(&self, _: Option<i32>) {}
|
||||||
fn GetUnsignedLongAttributeNullable(self) -> Option<u32> { Some(0) }
|
fn GetUnsignedLongAttributeNullable(&self) -> Option<u32> { Some(0) }
|
||||||
fn SetUnsignedLongAttributeNullable(self, _: Option<u32>) {}
|
fn SetUnsignedLongAttributeNullable(&self, _: Option<u32>) {}
|
||||||
fn GetLongLongAttributeNullable(self) -> Option<i64> { Some(0) }
|
fn GetLongLongAttributeNullable(&self) -> Option<i64> { Some(0) }
|
||||||
fn SetLongLongAttributeNullable(self, _: Option<i64>) {}
|
fn SetLongLongAttributeNullable(&self, _: Option<i64>) {}
|
||||||
fn GetUnsignedLongLongAttributeNullable(self) -> Option<u64> { Some(0) }
|
fn GetUnsignedLongLongAttributeNullable(&self) -> Option<u64> { Some(0) }
|
||||||
fn SetUnsignedLongLongAttributeNullable(self, _: Option<u64>) {}
|
fn SetUnsignedLongLongAttributeNullable(&self, _: Option<u64>) {}
|
||||||
fn GetUnrestrictedFloatAttributeNullable(self) -> Option<f32> { Some(0.) }
|
fn GetUnrestrictedFloatAttributeNullable(&self) -> Option<f32> { Some(0.) }
|
||||||
fn SetUnrestrictedFloatAttributeNullable(self, _: Option<f32>) {}
|
fn SetUnrestrictedFloatAttributeNullable(&self, _: Option<f32>) {}
|
||||||
fn GetFloatAttributeNullable(self) -> Option<Finite<f32>> { Some(Finite::wrap(0.)) }
|
fn GetFloatAttributeNullable(&self) -> Option<Finite<f32>> { Some(Finite::wrap(0.)) }
|
||||||
fn SetFloatAttributeNullable(self, _: Option<Finite<f32>>) {}
|
fn SetFloatAttributeNullable(&self, _: Option<Finite<f32>>) {}
|
||||||
fn GetUnrestrictedDoubleAttributeNullable(self) -> Option<f64> { Some(0.) }
|
fn GetUnrestrictedDoubleAttributeNullable(&self) -> Option<f64> { Some(0.) }
|
||||||
fn SetUnrestrictedDoubleAttributeNullable(self, _: Option<f64>) {}
|
fn SetUnrestrictedDoubleAttributeNullable(&self, _: Option<f64>) {}
|
||||||
fn GetDoubleAttributeNullable(self) -> Option<Finite<f64>> { Some(Finite::wrap(0.)) }
|
fn GetDoubleAttributeNullable(&self) -> Option<Finite<f64>> { Some(Finite::wrap(0.)) }
|
||||||
fn SetDoubleAttributeNullable(self, _: Option<Finite<f64>>) {}
|
fn SetDoubleAttributeNullable(&self, _: Option<Finite<f64>>) {}
|
||||||
fn GetByteStringAttributeNullable(self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
fn GetByteStringAttributeNullable(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
||||||
fn SetByteStringAttributeNullable(self, _: Option<ByteString>) {}
|
fn SetByteStringAttributeNullable(&self, _: Option<ByteString>) {}
|
||||||
fn GetStringAttributeNullable(self) -> Option<DOMString> { Some("".to_owned()) }
|
fn GetStringAttributeNullable(&self) -> Option<DOMString> { Some("".to_owned()) }
|
||||||
fn SetStringAttributeNullable(self, _: Option<DOMString>) {}
|
fn SetStringAttributeNullable(&self, _: Option<DOMString>) {}
|
||||||
fn GetUsvstringAttributeNullable(self) -> Option<USVString> { Some(USVString("".to_owned())) }
|
fn GetUsvstringAttributeNullable(&self) -> Option<USVString> { Some(USVString("".to_owned())) }
|
||||||
fn SetUsvstringAttributeNullable(self, _: Option<USVString>) {}
|
fn SetUsvstringAttributeNullable(&self, _: Option<USVString>) {}
|
||||||
fn SetBinaryRenamedAttribute(self, _: DOMString) {}
|
fn SetBinaryRenamedAttribute(&self, _: DOMString) {}
|
||||||
fn ForwardedAttribute(self) -> Root<TestBinding> { Root::from_ref(self) }
|
fn ForwardedAttribute(&self) -> Root<TestBinding> { Root::from_ref(self) }
|
||||||
fn BinaryRenamedAttribute(self) -> DOMString { "".to_owned() }
|
fn BinaryRenamedAttribute(&self) -> DOMString { "".to_owned() }
|
||||||
fn GetEnumAttributeNullable(self) -> Option<TestEnum> { Some(_empty) }
|
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(_empty) }
|
||||||
fn GetInterfaceAttributeNullable(self) -> Option<Root<Blob>> {
|
fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
Some(Blob::new(global.r(), None, ""))
|
Some(Blob::new(global.r(), None, ""))
|
||||||
}
|
}
|
||||||
fn SetInterfaceAttributeNullable(self, _: Option<&Blob>) {}
|
fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {}
|
||||||
fn GetObjectAttributeNullable(self, _: *mut JSContext) -> *mut JSObject { ptr::null_mut() }
|
fn GetObjectAttributeNullable(&self, _: *mut JSContext) -> *mut JSObject { ptr::null_mut() }
|
||||||
fn SetObjectAttributeNullable(self, _: *mut JSContext, _: *mut JSObject) {}
|
fn SetObjectAttributeNullable(&self, _: *mut JSContext, _: *mut JSObject) {}
|
||||||
fn GetUnionAttributeNullable(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
fn GetUnionAttributeNullable(&self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
||||||
fn SetUnionAttributeNullable(self, _: Option<HTMLElementOrLong>) {}
|
fn SetUnionAttributeNullable(&self, _: Option<HTMLElementOrLong>) {}
|
||||||
fn GetUnion2AttributeNullable(self) -> Option<EventOrString> { Some(eString("".to_owned())) }
|
fn GetUnion2AttributeNullable(&self) -> Option<EventOrString> { Some(eString("".to_owned())) }
|
||||||
fn SetUnion2AttributeNullable(self, _: Option<EventOrString>) {}
|
fn SetUnion2AttributeNullable(&self, _: Option<EventOrString>) {}
|
||||||
fn BinaryRenamedMethod(self) -> () {}
|
fn BinaryRenamedMethod(&self) -> () {}
|
||||||
fn ReceiveVoid(self) -> () {}
|
fn ReceiveVoid(&self) -> () {}
|
||||||
fn ReceiveBoolean(self) -> bool { false }
|
fn ReceiveBoolean(&self) -> bool { false }
|
||||||
fn ReceiveByte(self) -> i8 { 0 }
|
fn ReceiveByte(&self) -> i8 { 0 }
|
||||||
fn ReceiveOctet(self) -> u8 { 0 }
|
fn ReceiveOctet(&self) -> u8 { 0 }
|
||||||
fn ReceiveShort(self) -> i16 { 0 }
|
fn ReceiveShort(&self) -> i16 { 0 }
|
||||||
fn ReceiveUnsignedShort(self) -> u16 { 0 }
|
fn ReceiveUnsignedShort(&self) -> u16 { 0 }
|
||||||
fn ReceiveLong(self) -> i32 { 0 }
|
fn ReceiveLong(&self) -> i32 { 0 }
|
||||||
fn ReceiveUnsignedLong(self) -> u32 { 0 }
|
fn ReceiveUnsignedLong(&self) -> u32 { 0 }
|
||||||
fn ReceiveLongLong(self) -> i64 { 0 }
|
fn ReceiveLongLong(&self) -> i64 { 0 }
|
||||||
fn ReceiveUnsignedLongLong(self) -> u64 { 0 }
|
fn ReceiveUnsignedLongLong(&self) -> u64 { 0 }
|
||||||
fn ReceiveUnrestrictedFloat(self) -> f32 { 0. }
|
fn ReceiveUnrestrictedFloat(&self) -> f32 { 0. }
|
||||||
fn ReceiveFloat(self) -> Finite<f32> { Finite::wrap(0.) }
|
fn ReceiveFloat(&self) -> Finite<f32> { Finite::wrap(0.) }
|
||||||
fn ReceiveUnrestrictedDouble(self) -> f64 { 0. }
|
fn ReceiveUnrestrictedDouble(&self) -> f64 { 0. }
|
||||||
fn ReceiveDouble(self) -> Finite<f64> { Finite::wrap(0.) }
|
fn ReceiveDouble(&self) -> Finite<f64> { Finite::wrap(0.) }
|
||||||
fn ReceiveString(self) -> DOMString { "".to_owned() }
|
fn ReceiveString(&self) -> DOMString { "".to_owned() }
|
||||||
fn ReceiveUsvstring(self) -> USVString { USVString("".to_owned()) }
|
fn ReceiveUsvstring(&self) -> USVString { USVString("".to_owned()) }
|
||||||
fn ReceiveByteString(self) -> ByteString { ByteString::new(vec!()) }
|
fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) }
|
||||||
fn ReceiveEnum(self) -> TestEnum { _empty }
|
fn ReceiveEnum(&self) -> TestEnum { _empty }
|
||||||
fn ReceiveInterface(self) -> Root<Blob> {
|
fn ReceiveInterface(&self) -> Root<Blob> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
Blob::new(global.r(), None, "")
|
Blob::new(global.r(), None, "")
|
||||||
}
|
}
|
||||||
fn ReceiveAny(self, _: *mut JSContext) -> JSVal { NullValue() }
|
fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||||
fn ReceiveObject(self, _: *mut JSContext) -> *mut JSObject { panic!() }
|
fn ReceiveObject(&self, _: *mut JSContext) -> *mut JSObject { panic!() }
|
||||||
fn ReceiveUnion(self) -> HTMLElementOrLong { eLong(0) }
|
fn ReceiveUnion(&self) -> HTMLElementOrLong { eLong(0) }
|
||||||
fn ReceiveUnion2(self) -> EventOrString { eString("".to_owned()) }
|
fn ReceiveUnion2(&self) -> EventOrString { eString("".to_owned()) }
|
||||||
|
|
||||||
fn ReceiveNullableBoolean(self) -> Option<bool> { Some(false) }
|
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
|
||||||
fn ReceiveNullableByte(self) -> Option<i8> { Some(0) }
|
fn ReceiveNullableByte(&self) -> Option<i8> { Some(0) }
|
||||||
fn ReceiveNullableOctet(self) -> Option<u8> { Some(0) }
|
fn ReceiveNullableOctet(&self) -> Option<u8> { Some(0) }
|
||||||
fn ReceiveNullableShort(self) -> Option<i16> { Some(0) }
|
fn ReceiveNullableShort(&self) -> Option<i16> { Some(0) }
|
||||||
fn ReceiveNullableUnsignedShort(self) -> Option<u16> { Some(0) }
|
fn ReceiveNullableUnsignedShort(&self) -> Option<u16> { Some(0) }
|
||||||
fn ReceiveNullableLong(self) -> Option<i32> { Some(0) }
|
fn ReceiveNullableLong(&self) -> Option<i32> { Some(0) }
|
||||||
fn ReceiveNullableUnsignedLong(self) -> Option<u32> { Some(0) }
|
fn ReceiveNullableUnsignedLong(&self) -> Option<u32> { Some(0) }
|
||||||
fn ReceiveNullableLongLong(self) -> Option<i64> { Some(0) }
|
fn ReceiveNullableLongLong(&self) -> Option<i64> { Some(0) }
|
||||||
fn ReceiveNullableUnsignedLongLong(self) -> Option<u64> { Some(0) }
|
fn ReceiveNullableUnsignedLongLong(&self) -> Option<u64> { Some(0) }
|
||||||
fn ReceiveNullableUnrestrictedFloat(self) -> Option<f32> { Some(0.) }
|
fn ReceiveNullableUnrestrictedFloat(&self) -> Option<f32> { Some(0.) }
|
||||||
fn ReceiveNullableFloat(self) -> Option<Finite<f32>> { Some(Finite::wrap(0.)) }
|
fn ReceiveNullableFloat(&self) -> Option<Finite<f32>> { Some(Finite::wrap(0.)) }
|
||||||
fn ReceiveNullableUnrestrictedDouble(self) -> Option<f64> { Some(0.) }
|
fn ReceiveNullableUnrestrictedDouble(&self) -> Option<f64> { Some(0.) }
|
||||||
fn ReceiveNullableDouble(self) -> Option<Finite<f64>> { Some(Finite::wrap(0.)) }
|
fn ReceiveNullableDouble(&self) -> Option<Finite<f64>> { Some(Finite::wrap(0.)) }
|
||||||
fn ReceiveNullableString(self) -> Option<DOMString> { Some("".to_owned()) }
|
fn ReceiveNullableString(&self) -> Option<DOMString> { Some("".to_owned()) }
|
||||||
fn ReceiveNullableUsvstring(self) -> Option<USVString> { Some(USVString("".to_owned())) }
|
fn ReceiveNullableUsvstring(&self) -> Option<USVString> { Some(USVString("".to_owned())) }
|
||||||
fn ReceiveNullableByteString(self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
||||||
fn ReceiveNullableEnum(self) -> Option<TestEnum> { Some(_empty) }
|
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(_empty) }
|
||||||
fn ReceiveNullableInterface(self) -> Option<Root<Blob>> {
|
fn ReceiveNullableInterface(&self) -> Option<Root<Blob>> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
Some(Blob::new(global.r(), None, ""))
|
Some(Blob::new(global.r(), None, ""))
|
||||||
}
|
}
|
||||||
fn ReceiveNullableObject(self, _: *mut JSContext) -> *mut JSObject { ptr::null_mut() }
|
fn ReceiveNullableObject(&self, _: *mut JSContext) -> *mut JSObject { ptr::null_mut() }
|
||||||
fn ReceiveNullableUnion(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
fn ReceiveNullableUnion(&self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
||||||
fn ReceiveNullableUnion2(self) -> Option<EventOrString> { Some(eString("".to_owned())) }
|
fn ReceiveNullableUnion2(&self) -> Option<EventOrString> { Some(eString("".to_owned())) }
|
||||||
|
|
||||||
fn PassBoolean(self, _: bool) {}
|
fn PassBoolean(&self, _: bool) {}
|
||||||
fn PassByte(self, _: i8) {}
|
fn PassByte(&self, _: i8) {}
|
||||||
fn PassOctet(self, _: u8) {}
|
fn PassOctet(&self, _: u8) {}
|
||||||
fn PassShort(self, _: i16) {}
|
fn PassShort(&self, _: i16) {}
|
||||||
fn PassUnsignedShort(self, _: u16) {}
|
fn PassUnsignedShort(&self, _: u16) {}
|
||||||
fn PassLong(self, _: i32) {}
|
fn PassLong(&self, _: i32) {}
|
||||||
fn PassUnsignedLong(self, _: u32) {}
|
fn PassUnsignedLong(&self, _: u32) {}
|
||||||
fn PassLongLong(self, _: i64) {}
|
fn PassLongLong(&self, _: i64) {}
|
||||||
fn PassUnsignedLongLong(self, _: u64) {}
|
fn PassUnsignedLongLong(&self, _: u64) {}
|
||||||
fn PassUnrestrictedFloat(self, _: f32) {}
|
fn PassUnrestrictedFloat(&self, _: f32) {}
|
||||||
fn PassFloat(self, _: Finite<f32>) {}
|
fn PassFloat(&self, _: Finite<f32>) {}
|
||||||
fn PassUnrestrictedDouble(self, _: f64) {}
|
fn PassUnrestrictedDouble(&self, _: f64) {}
|
||||||
fn PassDouble(self, _: Finite<f64>) {}
|
fn PassDouble(&self, _: Finite<f64>) {}
|
||||||
fn PassString(self, _: DOMString) {}
|
fn PassString(&self, _: DOMString) {}
|
||||||
fn PassUsvstring(self, _: USVString) {}
|
fn PassUsvstring(&self, _: USVString) {}
|
||||||
fn PassByteString(self, _: ByteString) {}
|
fn PassByteString(&self, _: ByteString) {}
|
||||||
fn PassEnum(self, _: TestEnum) {}
|
fn PassEnum(&self, _: TestEnum) {}
|
||||||
fn PassInterface(self, _: &Blob) {}
|
fn PassInterface(&self, _: &Blob) {}
|
||||||
fn PassUnion(self, _: HTMLElementOrLong) {}
|
fn PassUnion(&self, _: HTMLElementOrLong) {}
|
||||||
fn PassUnion2(self, _: EventOrString) {}
|
fn PassUnion2(&self, _: EventOrString) {}
|
||||||
fn PassUnion3(self, _: BlobOrString) {}
|
fn PassUnion3(&self, _: BlobOrString) {}
|
||||||
fn PassAny(self, _: *mut JSContext, _: HandleValue) {}
|
fn PassAny(&self, _: *mut JSContext, _: HandleValue) {}
|
||||||
fn PassObject(self, _: *mut JSContext, _: *mut JSObject) {}
|
fn PassObject(&self, _: *mut JSContext, _: *mut JSObject) {}
|
||||||
fn PassCallbackFunction(self, _: Rc<Function>) {}
|
fn PassCallbackFunction(&self, _: Rc<Function>) {}
|
||||||
fn PassCallbackInterface(self, _: Rc<EventListener>) {}
|
fn PassCallbackInterface(&self, _: Rc<EventListener>) {}
|
||||||
|
|
||||||
fn PassNullableBoolean(self, _: Option<bool>) {}
|
fn PassNullableBoolean(&self, _: Option<bool>) {}
|
||||||
fn PassNullableByte(self, _: Option<i8>) {}
|
fn PassNullableByte(&self, _: Option<i8>) {}
|
||||||
fn PassNullableOctet(self, _: Option<u8>) {}
|
fn PassNullableOctet(&self, _: Option<u8>) {}
|
||||||
fn PassNullableShort(self, _: Option<i16>) {}
|
fn PassNullableShort(&self, _: Option<i16>) {}
|
||||||
fn PassNullableUnsignedShort(self, _: Option<u16>) {}
|
fn PassNullableUnsignedShort(&self, _: Option<u16>) {}
|
||||||
fn PassNullableLong(self, _: Option<i32>) {}
|
fn PassNullableLong(&self, _: Option<i32>) {}
|
||||||
fn PassNullableUnsignedLong(self, _: Option<u32>) {}
|
fn PassNullableUnsignedLong(&self, _: Option<u32>) {}
|
||||||
fn PassNullableLongLong(self, _: Option<i64>) {}
|
fn PassNullableLongLong(&self, _: Option<i64>) {}
|
||||||
fn PassNullableUnsignedLongLong(self, _: Option<u64>) {}
|
fn PassNullableUnsignedLongLong(&self, _: Option<u64>) {}
|
||||||
fn PassNullableUnrestrictedFloat(self, _: Option<f32>) {}
|
fn PassNullableUnrestrictedFloat(&self, _: Option<f32>) {}
|
||||||
fn PassNullableFloat(self, _: Option<Finite<f32>>) {}
|
fn PassNullableFloat(&self, _: Option<Finite<f32>>) {}
|
||||||
fn PassNullableUnrestrictedDouble(self, _: Option<f64>) {}
|
fn PassNullableUnrestrictedDouble(&self, _: Option<f64>) {}
|
||||||
fn PassNullableDouble(self, _: Option<Finite<f64>>) {}
|
fn PassNullableDouble(&self, _: Option<Finite<f64>>) {}
|
||||||
fn PassNullableString(self, _: Option<DOMString>) {}
|
fn PassNullableString(&self, _: Option<DOMString>) {}
|
||||||
fn PassNullableUsvstring(self, _: Option<USVString>) {}
|
fn PassNullableUsvstring(&self, _: Option<USVString>) {}
|
||||||
fn PassNullableByteString(self, _: Option<ByteString>) {}
|
fn PassNullableByteString(&self, _: Option<ByteString>) {}
|
||||||
// fn PassNullableEnum(self, _: Option<TestEnum>) {}
|
// fn PassNullableEnum(self, _: Option<TestEnum>) {}
|
||||||
fn PassNullableInterface(self, _: Option<&Blob>) {}
|
fn PassNullableInterface(&self, _: Option<&Blob>) {}
|
||||||
fn PassNullableObject(self, _: *mut JSContext, _: *mut JSObject) {}
|
fn PassNullableObject(&self, _: *mut JSContext, _: *mut JSObject) {}
|
||||||
fn PassNullableUnion(self, _: Option<HTMLElementOrLong>) {}
|
fn PassNullableUnion(&self, _: Option<HTMLElementOrLong>) {}
|
||||||
fn PassNullableUnion2(self, _: Option<EventOrString>) {}
|
fn PassNullableUnion2(&self, _: Option<EventOrString>) {}
|
||||||
fn PassNullableCallbackFunction(self, _: Option<Rc<Function>>) {}
|
fn PassNullableCallbackFunction(&self, _: Option<Rc<Function>>) {}
|
||||||
fn PassNullableCallbackInterface(self, _: Option<Rc<EventListener>>) {}
|
fn PassNullableCallbackInterface(&self, _: Option<Rc<EventListener>>) {}
|
||||||
|
|
||||||
fn PassOptionalBoolean(self, _: Option<bool>) {}
|
fn PassOptionalBoolean(&self, _: Option<bool>) {}
|
||||||
fn PassOptionalByte(self, _: Option<i8>) {}
|
fn PassOptionalByte(&self, _: Option<i8>) {}
|
||||||
fn PassOptionalOctet(self, _: Option<u8>) {}
|
fn PassOptionalOctet(&self, _: Option<u8>) {}
|
||||||
fn PassOptionalShort(self, _: Option<i16>) {}
|
fn PassOptionalShort(&self, _: Option<i16>) {}
|
||||||
fn PassOptionalUnsignedShort(self, _: Option<u16>) {}
|
fn PassOptionalUnsignedShort(&self, _: Option<u16>) {}
|
||||||
fn PassOptionalLong(self, _: Option<i32>) {}
|
fn PassOptionalLong(&self, _: Option<i32>) {}
|
||||||
fn PassOptionalUnsignedLong(self, _: Option<u32>) {}
|
fn PassOptionalUnsignedLong(&self, _: Option<u32>) {}
|
||||||
fn PassOptionalLongLong(self, _: Option<i64>) {}
|
fn PassOptionalLongLong(&self, _: Option<i64>) {}
|
||||||
fn PassOptionalUnsignedLongLong(self, _: Option<u64>) {}
|
fn PassOptionalUnsignedLongLong(&self, _: Option<u64>) {}
|
||||||
fn PassOptionalUnrestrictedFloat(self, _: Option<f32>) {}
|
fn PassOptionalUnrestrictedFloat(&self, _: Option<f32>) {}
|
||||||
fn PassOptionalFloat(self, _: Option<Finite<f32>>) {}
|
fn PassOptionalFloat(&self, _: Option<Finite<f32>>) {}
|
||||||
fn PassOptionalUnrestrictedDouble(self, _: Option<f64>) {}
|
fn PassOptionalUnrestrictedDouble(&self, _: Option<f64>) {}
|
||||||
fn PassOptionalDouble(self, _: Option<Finite<f64>>) {}
|
fn PassOptionalDouble(&self, _: Option<Finite<f64>>) {}
|
||||||
fn PassOptionalString(self, _: Option<DOMString>) {}
|
fn PassOptionalString(&self, _: Option<DOMString>) {}
|
||||||
fn PassOptionalUsvstring(self, _: Option<USVString>) {}
|
fn PassOptionalUsvstring(&self, _: Option<USVString>) {}
|
||||||
fn PassOptionalByteString(self, _: Option<ByteString>) {}
|
fn PassOptionalByteString(&self, _: Option<ByteString>) {}
|
||||||
fn PassOptionalEnum(self, _: Option<TestEnum>) {}
|
fn PassOptionalEnum(&self, _: Option<TestEnum>) {}
|
||||||
fn PassOptionalInterface(self, _: Option<&Blob>) {}
|
fn PassOptionalInterface(&self, _: Option<&Blob>) {}
|
||||||
fn PassOptionalUnion(self, _: Option<HTMLElementOrLong>) {}
|
fn PassOptionalUnion(&self, _: Option<HTMLElementOrLong>) {}
|
||||||
fn PassOptionalUnion2(self, _: Option<EventOrString>) {}
|
fn PassOptionalUnion2(&self, _: Option<EventOrString>) {}
|
||||||
fn PassOptionalAny(self, _: *mut JSContext, _: HandleValue) {}
|
fn PassOptionalAny(&self, _: *mut JSContext, _: HandleValue) {}
|
||||||
fn PassOptionalObject(self, _: *mut JSContext, _: Option<*mut JSObject>) {}
|
fn PassOptionalObject(&self, _: *mut JSContext, _: Option<*mut JSObject>) {}
|
||||||
fn PassOptionalCallbackFunction(self, _: Option<Rc<Function>>) {}
|
fn PassOptionalCallbackFunction(&self, _: Option<Rc<Function>>) {}
|
||||||
fn PassOptionalCallbackInterface(self, _: Option<Rc<EventListener>>) {}
|
fn PassOptionalCallbackInterface(&self, _: Option<Rc<EventListener>>) {}
|
||||||
|
|
||||||
fn PassOptionalNullableBoolean(self, _: Option<Option<bool>>) {}
|
fn PassOptionalNullableBoolean(&self, _: Option<Option<bool>>) {}
|
||||||
fn PassOptionalNullableByte(self, _: Option<Option<i8>>) {}
|
fn PassOptionalNullableByte(&self, _: Option<Option<i8>>) {}
|
||||||
fn PassOptionalNullableOctet(self, _: Option<Option<u8>>) {}
|
fn PassOptionalNullableOctet(&self, _: Option<Option<u8>>) {}
|
||||||
fn PassOptionalNullableShort(self, _: Option<Option<i16>>) {}
|
fn PassOptionalNullableShort(&self, _: Option<Option<i16>>) {}
|
||||||
fn PassOptionalNullableUnsignedShort(self, _: Option<Option<u16>>) {}
|
fn PassOptionalNullableUnsignedShort(&self, _: Option<Option<u16>>) {}
|
||||||
fn PassOptionalNullableLong(self, _: Option<Option<i32>>) {}
|
fn PassOptionalNullableLong(&self, _: Option<Option<i32>>) {}
|
||||||
fn PassOptionalNullableUnsignedLong(self, _: Option<Option<u32>>) {}
|
fn PassOptionalNullableUnsignedLong(&self, _: Option<Option<u32>>) {}
|
||||||
fn PassOptionalNullableLongLong(self, _: Option<Option<i64>>) {}
|
fn PassOptionalNullableLongLong(&self, _: Option<Option<i64>>) {}
|
||||||
fn PassOptionalNullableUnsignedLongLong(self, _: Option<Option<u64>>) {}
|
fn PassOptionalNullableUnsignedLongLong(&self, _: Option<Option<u64>>) {}
|
||||||
fn PassOptionalNullableUnrestrictedFloat(self, _: Option<Option<f32>>) {}
|
fn PassOptionalNullableUnrestrictedFloat(&self, _: Option<Option<f32>>) {}
|
||||||
fn PassOptionalNullableFloat(self, _: Option<Option<Finite<f32>>>) {}
|
fn PassOptionalNullableFloat(&self, _: Option<Option<Finite<f32>>>) {}
|
||||||
fn PassOptionalNullableUnrestrictedDouble(self, _: Option<Option<f64>>) {}
|
fn PassOptionalNullableUnrestrictedDouble(&self, _: Option<Option<f64>>) {}
|
||||||
fn PassOptionalNullableDouble(self, _: Option<Option<Finite<f64>>>) {}
|
fn PassOptionalNullableDouble(&self, _: Option<Option<Finite<f64>>>) {}
|
||||||
fn PassOptionalNullableString(self, _: Option<Option<DOMString>>) {}
|
fn PassOptionalNullableString(&self, _: Option<Option<DOMString>>) {}
|
||||||
fn PassOptionalNullableUsvstring(self, _: Option<Option<USVString>>) {}
|
fn PassOptionalNullableUsvstring(&self, _: Option<Option<USVString>>) {}
|
||||||
fn PassOptionalNullableByteString(self, _: Option<Option<ByteString>>) {}
|
fn PassOptionalNullableByteString(&self, _: Option<Option<ByteString>>) {}
|
||||||
// fn PassOptionalNullableEnum(self, _: Option<Option<TestEnum>>) {}
|
// fn PassOptionalNullableEnum(self, _: Option<Option<TestEnum>>) {}
|
||||||
fn PassOptionalNullableInterface(self, _: Option<Option<&Blob>>) {}
|
fn PassOptionalNullableInterface(&self, _: Option<Option<&Blob>>) {}
|
||||||
fn PassOptionalNullableObject(self, _: *mut JSContext, _: Option<*mut JSObject>) {}
|
fn PassOptionalNullableObject(&self, _: *mut JSContext, _: Option<*mut JSObject>) {}
|
||||||
fn PassOptionalNullableUnion(self, _: Option<Option<HTMLElementOrLong>>) {}
|
fn PassOptionalNullableUnion(&self, _: Option<Option<HTMLElementOrLong>>) {}
|
||||||
fn PassOptionalNullableUnion2(self, _: Option<Option<EventOrString>>) {}
|
fn PassOptionalNullableUnion2(&self, _: Option<Option<EventOrString>>) {}
|
||||||
fn PassOptionalNullableCallbackFunction(self, _: Option<Option<Rc<Function>>>) {}
|
fn PassOptionalNullableCallbackFunction(&self, _: Option<Option<Rc<Function>>>) {}
|
||||||
fn PassOptionalNullableCallbackInterface(self, _: Option<Option<Rc<EventListener>>>) {}
|
fn PassOptionalNullableCallbackInterface(&self, _: Option<Option<Rc<EventListener>>>) {}
|
||||||
|
|
||||||
fn PassOptionalBooleanWithDefault(self, _: bool) {}
|
fn PassOptionalBooleanWithDefault(&self, _: bool) {}
|
||||||
fn PassOptionalByteWithDefault(self, _: i8) {}
|
fn PassOptionalByteWithDefault(&self, _: i8) {}
|
||||||
fn PassOptionalOctetWithDefault(self, _: u8) {}
|
fn PassOptionalOctetWithDefault(&self, _: u8) {}
|
||||||
fn PassOptionalShortWithDefault(self, _: i16) {}
|
fn PassOptionalShortWithDefault(&self, _: i16) {}
|
||||||
fn PassOptionalUnsignedShortWithDefault(self, _: u16) {}
|
fn PassOptionalUnsignedShortWithDefault(&self, _: u16) {}
|
||||||
fn PassOptionalLongWithDefault(self, _: i32) {}
|
fn PassOptionalLongWithDefault(&self, _: i32) {}
|
||||||
fn PassOptionalUnsignedLongWithDefault(self, _: u32) {}
|
fn PassOptionalUnsignedLongWithDefault(&self, _: u32) {}
|
||||||
fn PassOptionalLongLongWithDefault(self, _: i64) {}
|
fn PassOptionalLongLongWithDefault(&self, _: i64) {}
|
||||||
fn PassOptionalUnsignedLongLongWithDefault(self, _: u64) {}
|
fn PassOptionalUnsignedLongLongWithDefault(&self, _: u64) {}
|
||||||
fn PassOptionalStringWithDefault(self, _: DOMString) {}
|
fn PassOptionalStringWithDefault(&self, _: DOMString) {}
|
||||||
fn PassOptionalUsvstringWithDefault(self, _: USVString) {}
|
fn PassOptionalUsvstringWithDefault(&self, _: USVString) {}
|
||||||
fn PassOptionalEnumWithDefault(self, _: TestEnum) {}
|
fn PassOptionalEnumWithDefault(&self, _: TestEnum) {}
|
||||||
|
|
||||||
fn PassOptionalNullableBooleanWithDefault(self, _: Option<bool>) {}
|
fn PassOptionalNullableBooleanWithDefault(&self, _: Option<bool>) {}
|
||||||
fn PassOptionalNullableByteWithDefault(self, _: Option<i8>) {}
|
fn PassOptionalNullableByteWithDefault(&self, _: Option<i8>) {}
|
||||||
fn PassOptionalNullableOctetWithDefault(self, _: Option<u8>) {}
|
fn PassOptionalNullableOctetWithDefault(&self, _: Option<u8>) {}
|
||||||
fn PassOptionalNullableShortWithDefault(self, _: Option<i16>) {}
|
fn PassOptionalNullableShortWithDefault(&self, _: Option<i16>) {}
|
||||||
fn PassOptionalNullableUnsignedShortWithDefault(self, _: Option<u16>) {}
|
fn PassOptionalNullableUnsignedShortWithDefault(&self, _: Option<u16>) {}
|
||||||
fn PassOptionalNullableLongWithDefault(self, _: Option<i32>) {}
|
fn PassOptionalNullableLongWithDefault(&self, _: Option<i32>) {}
|
||||||
fn PassOptionalNullableUnsignedLongWithDefault(self, _: Option<u32>) {}
|
fn PassOptionalNullableUnsignedLongWithDefault(&self, _: Option<u32>) {}
|
||||||
fn PassOptionalNullableLongLongWithDefault(self, _: Option<i64>) {}
|
fn PassOptionalNullableLongLongWithDefault(&self, _: Option<i64>) {}
|
||||||
fn PassOptionalNullableUnsignedLongLongWithDefault(self, _: Option<u64>) {}
|
fn PassOptionalNullableUnsignedLongLongWithDefault(&self, _: Option<u64>) {}
|
||||||
// fn PassOptionalNullableUnrestrictedFloatWithDefault(self, _: Option<f32>) {}
|
// fn PassOptionalNullableUnrestrictedFloatWithDefault(self, _: Option<f32>) {}
|
||||||
// fn PassOptionalNullableFloatWithDefault(self, _: Option<Finite<f32>>) {}
|
// fn PassOptionalNullableFloatWithDefault(self, _: Option<Finite<f32>>) {}
|
||||||
// fn PassOptionalNullableUnrestrictedDoubleWithDefault(self, _: Option<f64>) {}
|
// fn PassOptionalNullableUnrestrictedDoubleWithDefault(self, _: Option<f64>) {}
|
||||||
// fn PassOptionalNullableDoubleWithDefault(self, _: Option<Finite<f64>>) {}
|
// fn PassOptionalNullableDoubleWithDefault(self, _: Option<Finite<f64>>) {}
|
||||||
fn PassOptionalNullableStringWithDefault(self, _: Option<DOMString>) {}
|
fn PassOptionalNullableStringWithDefault(&self, _: Option<DOMString>) {}
|
||||||
fn PassOptionalNullableUsvstringWithDefault(self, _: Option<USVString>) {}
|
fn PassOptionalNullableUsvstringWithDefault(&self, _: Option<USVString>) {}
|
||||||
fn PassOptionalNullableByteStringWithDefault(self, _: Option<ByteString>) {}
|
fn PassOptionalNullableByteStringWithDefault(&self, _: Option<ByteString>) {}
|
||||||
// fn PassOptionalNullableEnumWithDefault(self, _: Option<TestEnum>) {}
|
// fn PassOptionalNullableEnumWithDefault(self, _: Option<TestEnum>) {}
|
||||||
fn PassOptionalNullableInterfaceWithDefault(self, _: Option<&Blob>) {}
|
fn PassOptionalNullableInterfaceWithDefault(&self, _: Option<&Blob>) {}
|
||||||
fn PassOptionalNullableObjectWithDefault(self, _: *mut JSContext, _: *mut JSObject) {}
|
fn PassOptionalNullableObjectWithDefault(&self, _: *mut JSContext, _: *mut JSObject) {}
|
||||||
fn PassOptionalNullableUnionWithDefault(self, _: Option<HTMLElementOrLong>) {}
|
fn PassOptionalNullableUnionWithDefault(&self, _: Option<HTMLElementOrLong>) {}
|
||||||
fn PassOptionalNullableUnion2WithDefault(self, _: Option<EventOrString>) {}
|
fn PassOptionalNullableUnion2WithDefault(&self, _: Option<EventOrString>) {}
|
||||||
// fn PassOptionalNullableCallbackFunctionWithDefault(self, _: Option<Function>) {}
|
// fn PassOptionalNullableCallbackFunctionWithDefault(self, _: Option<Function>) {}
|
||||||
fn PassOptionalNullableCallbackInterfaceWithDefault(self, _: Option<Rc<EventListener>>) {}
|
fn PassOptionalNullableCallbackInterfaceWithDefault(&self, _: Option<Rc<EventListener>>) {}
|
||||||
fn PassOptionalAnyWithDefault(self, _: *mut JSContext, _: HandleValue) {}
|
fn PassOptionalAnyWithDefault(&self, _: *mut JSContext, _: HandleValue) {}
|
||||||
|
|
||||||
fn PassOptionalNullableBooleanWithNonNullDefault(self, _: Option<bool>) {}
|
fn PassOptionalNullableBooleanWithNonNullDefault(&self, _: Option<bool>) {}
|
||||||
fn PassOptionalNullableByteWithNonNullDefault(self, _: Option<i8>) {}
|
fn PassOptionalNullableByteWithNonNullDefault(&self, _: Option<i8>) {}
|
||||||
fn PassOptionalNullableOctetWithNonNullDefault(self, _: Option<u8>) {}
|
fn PassOptionalNullableOctetWithNonNullDefault(&self, _: Option<u8>) {}
|
||||||
fn PassOptionalNullableShortWithNonNullDefault(self, _: Option<i16>) {}
|
fn PassOptionalNullableShortWithNonNullDefault(&self, _: Option<i16>) {}
|
||||||
fn PassOptionalNullableUnsignedShortWithNonNullDefault(self, _: Option<u16>) {}
|
fn PassOptionalNullableUnsignedShortWithNonNullDefault(&self, _: Option<u16>) {}
|
||||||
fn PassOptionalNullableLongWithNonNullDefault(self, _: Option<i32>) {}
|
fn PassOptionalNullableLongWithNonNullDefault(&self, _: Option<i32>) {}
|
||||||
fn PassOptionalNullableUnsignedLongWithNonNullDefault(self, _: Option<u32>) {}
|
fn PassOptionalNullableUnsignedLongWithNonNullDefault(&self, _: Option<u32>) {}
|
||||||
fn PassOptionalNullableLongLongWithNonNullDefault(self, _: Option<i64>) {}
|
fn PassOptionalNullableLongLongWithNonNullDefault(&self, _: Option<i64>) {}
|
||||||
fn PassOptionalNullableUnsignedLongLongWithNonNullDefault(self, _: Option<u64>) {}
|
fn PassOptionalNullableUnsignedLongLongWithNonNullDefault(&self, _: Option<u64>) {}
|
||||||
// fn PassOptionalNullableUnrestrictedFloatWithNonNullDefault(self, _: Option<f32>) {}
|
// fn PassOptionalNullableUnrestrictedFloatWithNonNullDefault(self, _: Option<f32>) {}
|
||||||
// fn PassOptionalNullableFloatWithNonNullDefault(self, _: Option<Finite<f32>>) {}
|
// fn PassOptionalNullableFloatWithNonNullDefault(self, _: Option<Finite<f32>>) {}
|
||||||
// fn PassOptionalNullableUnrestrictedDoubleWithNonNullDefault(self, _: Option<f64>) {}
|
// fn PassOptionalNullableUnrestrictedDoubleWithNonNullDefault(self, _: Option<f64>) {}
|
||||||
// fn PassOptionalNullableDoubleWithNonNullDefault(self, _: Option<Finite<f64>>) {}
|
// fn PassOptionalNullableDoubleWithNonNullDefault(self, _: Option<Finite<f64>>) {}
|
||||||
fn PassOptionalNullableStringWithNonNullDefault(self, _: Option<DOMString>) {}
|
fn PassOptionalNullableStringWithNonNullDefault(&self, _: Option<DOMString>) {}
|
||||||
fn PassOptionalNullableUsvstringWithNonNullDefault(self, _: Option<USVString>) {}
|
fn PassOptionalNullableUsvstringWithNonNullDefault(&self, _: Option<USVString>) {}
|
||||||
// fn PassOptionalNullableEnumWithNonNullDefault(self, _: Option<TestEnum>) {}
|
// fn PassOptionalNullableEnumWithNonNullDefault(self, _: Option<TestEnum>) {}
|
||||||
|
|
||||||
fn PassVariadicBoolean(self, _: Vec<bool>) {}
|
fn PassVariadicBoolean(&self, _: Vec<bool>) {}
|
||||||
fn PassVariadicByte(self, _: Vec<i8>) {}
|
fn PassVariadicByte(&self, _: Vec<i8>) {}
|
||||||
fn PassVariadicOctet(self, _: Vec<u8>) {}
|
fn PassVariadicOctet(&self, _: Vec<u8>) {}
|
||||||
fn PassVariadicShort(self, _: Vec<i16>) {}
|
fn PassVariadicShort(&self, _: Vec<i16>) {}
|
||||||
fn PassVariadicUnsignedShort(self, _: Vec<u16>) {}
|
fn PassVariadicUnsignedShort(&self, _: Vec<u16>) {}
|
||||||
fn PassVariadicLong(self, _: Vec<i32>) {}
|
fn PassVariadicLong(&self, _: Vec<i32>) {}
|
||||||
fn PassVariadicUnsignedLong(self, _: Vec<u32>) {}
|
fn PassVariadicUnsignedLong(&self, _: Vec<u32>) {}
|
||||||
fn PassVariadicLongLong(self, _: Vec<i64>) {}
|
fn PassVariadicLongLong(&self, _: Vec<i64>) {}
|
||||||
fn PassVariadicUnsignedLongLong(self, _: Vec<u64>) {}
|
fn PassVariadicUnsignedLongLong(&self, _: Vec<u64>) {}
|
||||||
fn PassVariadicUnrestrictedFloat(self, _: Vec<f32>) {}
|
fn PassVariadicUnrestrictedFloat(&self, _: Vec<f32>) {}
|
||||||
fn PassVariadicFloat(self, _: Vec<Finite<f32>>) {}
|
fn PassVariadicFloat(&self, _: Vec<Finite<f32>>) {}
|
||||||
fn PassVariadicUnrestrictedDouble(self, _: Vec<f64>) {}
|
fn PassVariadicUnrestrictedDouble(&self, _: Vec<f64>) {}
|
||||||
fn PassVariadicDouble(self, _: Vec<Finite<f64>>) {}
|
fn PassVariadicDouble(&self, _: Vec<Finite<f64>>) {}
|
||||||
fn PassVariadicString(self, _: Vec<DOMString>) {}
|
fn PassVariadicString(&self, _: Vec<DOMString>) {}
|
||||||
fn PassVariadicUsvstring(self, _: Vec<USVString>) {}
|
fn PassVariadicUsvstring(&self, _: Vec<USVString>) {}
|
||||||
fn PassVariadicByteString(self, _: Vec<ByteString>) {}
|
fn PassVariadicByteString(&self, _: Vec<ByteString>) {}
|
||||||
fn PassVariadicEnum(self, _: Vec<TestEnum>) {}
|
fn PassVariadicEnum(&self, _: Vec<TestEnum>) {}
|
||||||
// fn PassVariadicInterface(self, _: Vec<&Blob>) {}
|
// fn PassVariadicInterface(self, _: Vec<&Blob>) {}
|
||||||
fn PassVariadicUnion(self, _: Vec<HTMLElementOrLong>) {}
|
fn PassVariadicUnion(&self, _: Vec<HTMLElementOrLong>) {}
|
||||||
fn PassVariadicUnion2(self, _: Vec<EventOrString>) {}
|
fn PassVariadicUnion2(&self, _: Vec<EventOrString>) {}
|
||||||
fn PassVariadicUnion3(self, _: Vec<BlobOrString>) {}
|
fn PassVariadicUnion3(&self, _: Vec<BlobOrString>) {}
|
||||||
fn PassVariadicAny(self, _: *mut JSContext, _: Vec<HandleValue>) {}
|
fn PassVariadicAny(&self, _: *mut JSContext, _: Vec<HandleValue>) {}
|
||||||
fn PassVariadicObject(self, _: *mut JSContext, _: Vec<*mut JSObject>) {}
|
fn PassVariadicObject(&self, _: *mut JSContext, _: Vec<*mut JSObject>) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestBinding {
|
impl TestBinding {
|
||||||
|
|
|
@ -14,21 +14,21 @@ pub struct TestBindingProxy {
|
||||||
reflector_: Reflector
|
reflector_: Reflector
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TestBindingProxyMethods for &'a TestBindingProxy {
|
impl TestBindingProxyMethods for TestBindingProxy {
|
||||||
fn Length(self) -> u32 {0}
|
fn Length(&self) -> u32 {0}
|
||||||
fn SupportedPropertyNames(self) -> Vec<DOMString> {vec![]}
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {vec![]}
|
||||||
fn GetNamedItem(self, _: DOMString) -> DOMString {"".to_owned()}
|
fn GetNamedItem(&self, _: DOMString) -> DOMString {"".to_owned()}
|
||||||
fn SetNamedItem(self, _: DOMString, _: DOMString) -> () {}
|
fn SetNamedItem(&self, _: DOMString, _: DOMString) -> () {}
|
||||||
fn GetItem(self, _: u32) -> DOMString {"".to_owned()}
|
fn GetItem(&self, _: u32) -> DOMString {"".to_owned()}
|
||||||
fn SetItem(self, _: u32, _: DOMString) -> () {}
|
fn SetItem(&self, _: u32, _: DOMString) -> () {}
|
||||||
fn RemoveItem(self, _: DOMString) -> () {}
|
fn RemoveItem(&self, _: DOMString) -> () {}
|
||||||
fn Stringifier(self) -> DOMString {"".to_owned()}
|
fn Stringifier(&self) -> DOMString {"".to_owned()}
|
||||||
fn NamedCreator(self, _: DOMString, _: DOMString) -> () {}
|
fn NamedCreator(&self, _: DOMString, _: DOMString) -> () {}
|
||||||
fn IndexedGetter(self, _: u32, _: &mut bool) -> DOMString {"".to_owned()}
|
fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString {"".to_owned()}
|
||||||
fn NamedDeleter(self, _: DOMString) -> () {}
|
fn NamedDeleter(&self, _: DOMString) -> () {}
|
||||||
fn IndexedSetter(self, _: u32, _: DOMString) -> () {}
|
fn IndexedSetter(&self, _: u32, _: DOMString) -> () {}
|
||||||
fn NamedSetter(self, _: DOMString, _: DOMString) -> () {}
|
fn NamedSetter(&self, _: DOMString, _: DOMString) -> () {}
|
||||||
fn IndexedCreator(self, _: u32, _: DOMString) -> () {}
|
fn IndexedCreator(&self, _: u32, _: DOMString) -> () {}
|
||||||
fn NamedGetter(self, _: DOMString, _: &mut bool) -> DOMString {"".to_owned()}
|
fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString {"".to_owned()}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,9 @@ impl Text {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TextMethods for &'a Text {
|
impl TextMethods for Text {
|
||||||
// https://dom.spec.whatwg.org/#dom-text-splittextoffset
|
// https://dom.spec.whatwg.org/#dom-text-splittextoffset
|
||||||
fn SplitText(self, offset: u32) -> Fallible<Root<Text>> {
|
fn SplitText(&self, offset: u32) -> Fallible<Root<Text>> {
|
||||||
let cdata = CharacterDataCast::from_ref(self);
|
let cdata = CharacterDataCast::from_ref(self);
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let length = cdata.Length();
|
let length = cdata.Length();
|
||||||
|
@ -87,7 +87,7 @@ impl<'a> TextMethods for &'a Text {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-text-wholetext
|
// https://dom.spec.whatwg.org/#dom-text-wholetext
|
||||||
fn WholeText(self) -> DOMString {
|
fn WholeText(&self) -> DOMString {
|
||||||
let first = NodeCast::from_ref(self).inclusively_preceding_siblings()
|
let first = NodeCast::from_ref(self).inclusively_preceding_siblings()
|
||||||
.take_while(|node| node.r().is_text())
|
.take_while(|node| node.r().is_text())
|
||||||
.last().unwrap();
|
.last().unwrap();
|
||||||
|
|
|
@ -73,20 +73,20 @@ impl TextDecoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a> TextDecoderMethods for &'a TextDecoder {
|
impl TextDecoderMethods for TextDecoder {
|
||||||
// https://encoding.spec.whatwg.org/#dom-textdecoder-encoding
|
// https://encoding.spec.whatwg.org/#dom-textdecoder-encoding
|
||||||
fn Encoding(self) -> DOMString {
|
fn Encoding(&self) -> DOMString {
|
||||||
self.encoding.whatwg_name().unwrap().to_owned()
|
self.encoding.whatwg_name().unwrap().to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://encoding.spec.whatwg.org/#dom-textdecoder-fatal
|
// https://encoding.spec.whatwg.org/#dom-textdecoder-fatal
|
||||||
fn Fatal(self) -> bool {
|
fn Fatal(&self) -> bool {
|
||||||
self.fatal
|
self.fatal
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode
|
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode
|
||||||
fn Decode(self, _cx: *mut JSContext, input: Option<*mut JSObject>)
|
fn Decode(&self, _cx: *mut JSContext, input: Option<*mut JSObject>)
|
||||||
-> Fallible<USVString> {
|
-> Fallible<USVString> {
|
||||||
let input = match input {
|
let input = match input {
|
||||||
Some(input) => input,
|
Some(input) => input,
|
||||||
|
|
|
@ -70,15 +70,15 @@ impl TextEncoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TextEncoderMethods for &'a TextEncoder {
|
impl TextEncoderMethods for TextEncoder {
|
||||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encoding
|
// https://encoding.spec.whatwg.org/#dom-textencoder-encoding
|
||||||
fn Encoding(self) -> DOMString {
|
fn Encoding(&self) -> DOMString {
|
||||||
self.encoding.clone()
|
self.encoding.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encode
|
// https://encoding.spec.whatwg.org/#dom-textencoder-encode
|
||||||
fn Encode(self, cx: *mut JSContext, input: USVString) -> *mut JSObject {
|
fn Encode(&self, cx: *mut JSContext, input: USVString) -> *mut JSObject {
|
||||||
unsafe {
|
unsafe {
|
||||||
let encoded = self.encoder.encode(&input.0, EncoderTrap::Strict).unwrap();
|
let encoded = self.encoder.encode(&input.0, EncoderTrap::Strict).unwrap();
|
||||||
let length = encoded.len() as u32;
|
let length = encoded.len() as u32;
|
||||||
|
|
|
@ -63,19 +63,19 @@ impl TreeWalker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TreeWalkerMethods for &'a TreeWalker {
|
impl TreeWalkerMethods for TreeWalker {
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-root
|
// https://dom.spec.whatwg.org/#dom-treewalker-root
|
||||||
fn Root(self) -> Root<Node> {
|
fn Root(&self) -> Root<Node> {
|
||||||
self.root_node.root()
|
self.root_node.root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-whattoshow
|
// https://dom.spec.whatwg.org/#dom-treewalker-whattoshow
|
||||||
fn WhatToShow(self) -> u32 {
|
fn WhatToShow(&self) -> u32 {
|
||||||
self.what_to_show
|
self.what_to_show
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-filter
|
// https://dom.spec.whatwg.org/#dom-treewalker-filter
|
||||||
fn GetFilter(self) -> Option<Rc<NodeFilter>> {
|
fn GetFilter(&self) -> Option<Rc<NodeFilter>> {
|
||||||
match self.filter {
|
match self.filter {
|
||||||
Filter::None => None,
|
Filter::None => None,
|
||||||
Filter::JS(ref nf) => Some(nf.clone()),
|
Filter::JS(ref nf) => Some(nf.clone()),
|
||||||
|
@ -84,17 +84,17 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
||||||
fn CurrentNode(self) -> Root<Node> {
|
fn CurrentNode(&self) -> Root<Node> {
|
||||||
self.current_node.get().root()
|
self.current_node.get().root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
||||||
fn SetCurrentNode(self, node: &Node) {
|
fn SetCurrentNode(&self, node: &Node) {
|
||||||
self.current_node.set(JS::from_ref(node));
|
self.current_node.set(JS::from_ref(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-parentnode
|
// https://dom.spec.whatwg.org/#dom-treewalker-parentnode
|
||||||
fn ParentNode(self) -> Fallible<Option<Root<Node>>> {
|
fn ParentNode(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// "1. Let node be the value of the currentNode attribute."
|
// "1. Let node be the value of the currentNode attribute."
|
||||||
let mut node = self.current_node.get().root();
|
let mut node = self.current_node.get().root();
|
||||||
// "2. While node is not null and is not root, run these substeps:"
|
// "2. While node is not null and is not root, run these substeps:"
|
||||||
|
@ -118,35 +118,35 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-firstchild
|
// https://dom.spec.whatwg.org/#dom-treewalker-firstchild
|
||||||
fn FirstChild(self) -> Fallible<Option<Root<Node>>> {
|
fn FirstChild(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// "The firstChild() method must traverse children of type first."
|
// "The firstChild() method must traverse children of type first."
|
||||||
self.traverse_children(|node| node.GetFirstChild(),
|
self.traverse_children(|node| node.GetFirstChild(),
|
||||||
|node| node.GetNextSibling())
|
|node| node.GetNextSibling())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-lastchild
|
// https://dom.spec.whatwg.org/#dom-treewalker-lastchild
|
||||||
fn LastChild(self) -> Fallible<Option<Root<Node>>> {
|
fn LastChild(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// "The lastChild() method must traverse children of type last."
|
// "The lastChild() method must traverse children of type last."
|
||||||
self.traverse_children(|node| node.GetLastChild(),
|
self.traverse_children(|node| node.GetLastChild(),
|
||||||
|node| node.GetPreviousSibling())
|
|node| node.GetPreviousSibling())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-previoussibling
|
// https://dom.spec.whatwg.org/#dom-treewalker-previoussibling
|
||||||
fn PreviousSibling(self) -> Fallible<Option<Root<Node>>> {
|
fn PreviousSibling(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// "The nextSibling() method must traverse siblings of type next."
|
// "The nextSibling() method must traverse siblings of type next."
|
||||||
self.traverse_siblings(|node| node.GetLastChild(),
|
self.traverse_siblings(|node| node.GetLastChild(),
|
||||||
|node| node.GetPreviousSibling())
|
|node| node.GetPreviousSibling())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-nextsibling
|
// https://dom.spec.whatwg.org/#dom-treewalker-nextsibling
|
||||||
fn NextSibling(self) -> Fallible<Option<Root<Node>>> {
|
fn NextSibling(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// "The previousSibling() method must traverse siblings of type previous."
|
// "The previousSibling() method must traverse siblings of type previous."
|
||||||
self.traverse_siblings(|node| node.GetFirstChild(),
|
self.traverse_siblings(|node| node.GetFirstChild(),
|
||||||
|node| node.GetNextSibling())
|
|node| node.GetNextSibling())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-previousnode
|
// https://dom.spec.whatwg.org/#dom-treewalker-previousnode
|
||||||
fn PreviousNode(self) -> Fallible<Option<Root<Node>>> {
|
fn PreviousNode(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// "1. Let node be the value of the currentNode attribute."
|
// "1. Let node be the value of the currentNode attribute."
|
||||||
let mut node = self.current_node.get().root();
|
let mut node = self.current_node.get().root();
|
||||||
// "2. While node is not root, run these substeps:"
|
// "2. While node is not root, run these substeps:"
|
||||||
|
@ -203,7 +203,7 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-treewalker-nextnode
|
// https://dom.spec.whatwg.org/#dom-treewalker-nextnode
|
||||||
fn NextNode(self) -> Fallible<Option<Root<Node>>> {
|
fn NextNode(&self) -> Fallible<Option<Root<Node>>> {
|
||||||
// "1. Let node be the value of the currentNode attribute."
|
// "1. Let node be the value of the currentNode attribute."
|
||||||
let mut node = self.current_node.get().root();
|
let mut node = self.current_node.get().root();
|
||||||
// "2. Let result be FILTER_ACCEPT."
|
// "2. Let result be FILTER_ACCEPT."
|
||||||
|
|
|
@ -86,19 +86,19 @@ impl UIEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> UIEventMethods for &'a UIEvent {
|
impl UIEventMethods for UIEvent {
|
||||||
// https://w3c.github.io/uievents/#widl-UIEvent-view
|
// https://w3c.github.io/uievents/#widl-UIEvent-view
|
||||||
fn GetView(self) -> Option<Root<Window>> {
|
fn GetView(&self) -> Option<Root<Window>> {
|
||||||
self.view.get().map(Root::from_rooted)
|
self.view.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-UIEvent-detail
|
// https://w3c.github.io/uievents/#widl-UIEvent-detail
|
||||||
fn Detail(self) -> i32 {
|
fn Detail(&self) -> i32 {
|
||||||
self.detail.get()
|
self.detail.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#widl-UIEvent-initUIEvent
|
// https://w3c.github.io/uievents/#widl-UIEvent-initUIEvent
|
||||||
fn InitUIEvent(self,
|
fn InitUIEvent(&self,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
can_bubble: bool,
|
can_bubble: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
|
|
|
@ -84,59 +84,59 @@ impl URL {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> URLMethods for &'a URL {
|
impl URLMethods for URL {
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
||||||
fn Hash(self) -> USVString {
|
fn Hash(&self) -> USVString {
|
||||||
UrlHelper::Hash(&self.url)
|
UrlHelper::Hash(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-host
|
// https://url.spec.whatwg.org/#dom-urlutils-host
|
||||||
fn Host(self) -> USVString {
|
fn Host(&self) -> USVString {
|
||||||
UrlHelper::Host(&self.url)
|
UrlHelper::Host(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-hostname
|
// https://url.spec.whatwg.org/#dom-urlutils-hostname
|
||||||
fn Hostname(self) -> USVString {
|
fn Hostname(&self) -> USVString {
|
||||||
UrlHelper::Hostname(&self.url)
|
UrlHelper::Hostname(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-href
|
// https://url.spec.whatwg.org/#dom-urlutils-href
|
||||||
fn Href(self) -> USVString {
|
fn Href(&self) -> USVString {
|
||||||
UrlHelper::Href(&self.url)
|
UrlHelper::Href(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-password
|
// https://url.spec.whatwg.org/#dom-urlutils-password
|
||||||
fn Password(self) -> USVString {
|
fn Password(&self) -> USVString {
|
||||||
UrlHelper::Password(&self.url)
|
UrlHelper::Password(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-pathname
|
// https://url.spec.whatwg.org/#dom-urlutils-pathname
|
||||||
fn Pathname(self) -> USVString {
|
fn Pathname(&self) -> USVString {
|
||||||
UrlHelper::Pathname(&self.url)
|
UrlHelper::Pathname(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-port
|
// https://url.spec.whatwg.org/#dom-urlutils-port
|
||||||
fn Port(self) -> USVString {
|
fn Port(&self) -> USVString {
|
||||||
UrlHelper::Port(&self.url)
|
UrlHelper::Port(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-protocol
|
// https://url.spec.whatwg.org/#dom-urlutils-protocol
|
||||||
fn Protocol(self) -> USVString {
|
fn Protocol(&self) -> USVString {
|
||||||
UrlHelper::Protocol(&self.url)
|
UrlHelper::Protocol(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-search
|
// https://url.spec.whatwg.org/#dom-urlutils-search
|
||||||
fn Search(self) -> USVString {
|
fn Search(&self) -> USVString {
|
||||||
UrlHelper::Search(&self.url)
|
UrlHelper::Search(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
||||||
fn Stringifier(self) -> DOMString {
|
fn Stringifier(&self) -> DOMString {
|
||||||
self.Href().0
|
self.Href().0
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-username
|
// https://url.spec.whatwg.org/#dom-urlutils-username
|
||||||
fn Username(self) -> USVString {
|
fn Username(&self) -> USVString {
|
||||||
UrlHelper::Username(&self.url)
|
UrlHelper::Username(&self.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,9 @@ impl URLSearchParams {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> URLSearchParamsMethods for &'a URLSearchParams {
|
impl URLSearchParamsMethods for URLSearchParams {
|
||||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-append
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-append
|
||||||
fn Append(self, name: DOMString, value: DOMString) {
|
fn Append(&self, name: DOMString, value: DOMString) {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
self.list.borrow_mut().push((name, value));
|
self.list.borrow_mut().push((name, value));
|
||||||
// Step 2.
|
// Step 2.
|
||||||
|
@ -68,7 +68,7 @@ impl<'a> URLSearchParamsMethods for &'a URLSearchParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
|
||||||
fn Delete(self, name: DOMString) {
|
fn Delete(&self, name: DOMString) {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
self.list.borrow_mut().retain(|&(ref k, _)| k != &name);
|
self.list.borrow_mut().retain(|&(ref k, _)| k != &name);
|
||||||
// Step 2.
|
// Step 2.
|
||||||
|
@ -76,7 +76,7 @@ impl<'a> URLSearchParamsMethods for &'a URLSearchParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-get
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-get
|
||||||
fn Get(self, name: DOMString) -> Option<DOMString> {
|
fn Get(&self, name: DOMString) -> Option<DOMString> {
|
||||||
let list = self.list.borrow();
|
let list = self.list.borrow();
|
||||||
list.iter().filter_map(|&(ref k, ref v)| {
|
list.iter().filter_map(|&(ref k, ref v)| {
|
||||||
if k == &name {
|
if k == &name {
|
||||||
|
@ -88,13 +88,13 @@ impl<'a> URLSearchParamsMethods for &'a URLSearchParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
|
||||||
fn Has(self, name: DOMString) -> bool {
|
fn Has(&self, name: DOMString) -> bool {
|
||||||
let list = self.list.borrow();
|
let list = self.list.borrow();
|
||||||
list.iter().find(|&&(ref k, _)| k == &name).is_some()
|
list.iter().find(|&&(ref k, _)| k == &name).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-set
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-set
|
||||||
fn Set(self, name: DOMString, value: DOMString) {
|
fn Set(&self, name: DOMString, value: DOMString) {
|
||||||
let mut list = self.list.borrow_mut();
|
let mut list = self.list.borrow_mut();
|
||||||
let mut index = None;
|
let mut index = None;
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
|
@ -118,7 +118,7 @@ impl<'a> URLSearchParamsMethods for &'a URLSearchParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#stringification-behavior
|
// https://url.spec.whatwg.org/#stringification-behavior
|
||||||
fn Stringifier(self) -> DOMString {
|
fn Stringifier(&self) -> DOMString {
|
||||||
self.serialize(None)
|
self.serialize(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,19 +34,19 @@ impl WebGLActiveInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WebGLActiveInfoMethods for &'a WebGLActiveInfo {
|
impl WebGLActiveInfoMethods for WebGLActiveInfo {
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
|
||||||
fn Size(self) -> i32 {
|
fn Size(&self) -> i32 {
|
||||||
self.size
|
self.size
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
|
||||||
fn Type(self) -> u32 {
|
fn Type(&self) -> u32 {
|
||||||
self.ty
|
self.ty
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
|
||||||
fn Name(self) -> DOMString {
|
fn Name(&self) -> DOMString {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,14 +143,14 @@ impl Drop for WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1
|
||||||
fn Canvas(self) -> Root<HTMLCanvasElement> {
|
fn Canvas(&self) -> Root<HTMLCanvasElement> {
|
||||||
self.canvas.root()
|
self.canvas.root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1
|
||||||
fn DrawingBufferWidth(self) -> i32 {
|
fn DrawingBufferWidth(&self) -> i32 {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::DrawingBufferWidth(sender)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::DrawingBufferWidth(sender)))
|
||||||
|
@ -159,7 +159,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1
|
||||||
fn DrawingBufferHeight(self) -> i32 {
|
fn DrawingBufferHeight(&self) -> i32 {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::DrawingBufferHeight(sender)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::DrawingBufferHeight(sender)))
|
||||||
|
@ -168,7 +168,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn GetParameter(self, cx: *mut JSContext, parameter: u32) -> JSVal {
|
fn GetParameter(&self, cx: *mut JSContext, parameter: u32) -> JSVal {
|
||||||
// TODO(ecoal95): Implement the missing parameters from the spec
|
// TODO(ecoal95): Implement the missing parameters from the spec
|
||||||
let mut rval = RootedValue::new(cx, UndefinedValue());
|
let mut rval = RootedValue::new(cx, UndefinedValue());
|
||||||
match parameter {
|
match parameter {
|
||||||
|
@ -183,7 +183,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn GetError(self) -> u32 {
|
fn GetError(&self) -> u32 {
|
||||||
let error_code = if let Some(error) = self.last_error.get() {
|
let error_code = if let Some(error) = self.last_error.get() {
|
||||||
match error {
|
match error {
|
||||||
WebGLError::InvalidEnum => constants::INVALID_ENUM,
|
WebGLError::InvalidEnum => constants::INVALID_ENUM,
|
||||||
|
@ -200,7 +200,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.2
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.2
|
||||||
fn GetContextAttributes(self) -> Option<WebGLContextAttributes> {
|
fn GetContextAttributes(&self) -> Option<WebGLContextAttributes> {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
// If the send does not succeed, assume context lost
|
// If the send does not succeed, assume context lost
|
||||||
|
@ -223,49 +223,49 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.14
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.14
|
||||||
fn GetExtension(self, _cx: *mut JSContext, _name: DOMString) -> *mut JSObject {
|
fn GetExtension(&self, _cx: *mut JSContext, _name: DOMString) -> *mut JSObject {
|
||||||
// TODO(ecoal95) we actually do not support extensions.
|
// TODO(ecoal95) we actually do not support extensions.
|
||||||
// `getSupportedExtensions` cannot be implemented as of right now (see #544)
|
// `getSupportedExtensions` cannot be implemented as of right now (see #544)
|
||||||
0 as *mut JSObject
|
0 as *mut JSObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn ActiveTexture(self, texture: u32) {
|
fn ActiveTexture(&self, texture: u32) {
|
||||||
self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::ActiveTexture(texture))).unwrap();
|
self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::ActiveTexture(texture))).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn BlendColor(self, r: f32, g: f32, b: f32, a: f32) {
|
fn BlendColor(&self, r: f32, g: f32, b: f32, a: f32) {
|
||||||
self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendColor(r, g, b, a))).unwrap();
|
self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendColor(r, g, b, a))).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn BlendEquation(self, mode: u32) {
|
fn BlendEquation(&self, mode: u32) {
|
||||||
self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendEquation(mode))).unwrap();
|
self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendEquation(mode))).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn BlendEquationSeparate(self, mode_rgb: u32, mode_alpha: u32) {
|
fn BlendEquationSeparate(&self, mode_rgb: u32, mode_alpha: u32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendEquationSeparate(mode_rgb, mode_alpha)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendEquationSeparate(mode_rgb, mode_alpha)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn BlendFunc(self, src_factor: u32, dest_factor: u32) {
|
fn BlendFunc(&self, src_factor: u32, dest_factor: u32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendFunc(src_factor, dest_factor)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendFunc(src_factor, dest_factor)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn BlendFuncSeparate(self, src_rgb: u32, dest_rgb: u32, src_alpha: u32, dest_alpha: u32) {
|
fn BlendFuncSeparate(&self, src_rgb: u32, dest_rgb: u32, src_alpha: u32, dest_alpha: u32) {
|
||||||
self.ipc_renderer.send(
|
self.ipc_renderer.send(
|
||||||
CanvasMsg::WebGL(CanvasWebGLMsg::BlendFuncSeparate(src_rgb, dest_rgb, src_alpha, dest_alpha))).unwrap();
|
CanvasMsg::WebGL(CanvasWebGLMsg::BlendFuncSeparate(src_rgb, dest_rgb, src_alpha, dest_alpha))).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn AttachShader(self, program: Option<&WebGLProgram>, shader: Option<&WebGLShader>) {
|
fn AttachShader(&self, program: Option<&WebGLProgram>, shader: Option<&WebGLShader>) {
|
||||||
if let Some(program) = program {
|
if let Some(program) = program {
|
||||||
if let Some(shader) = shader {
|
if let Some(shader) = shader {
|
||||||
handle_potential_webgl_error!(self, program.attach_shader(shader));
|
handle_potential_webgl_error!(self, program.attach_shader(shader));
|
||||||
|
@ -274,7 +274,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||||
fn BindBuffer(self, target: u32, buffer: Option<&WebGLBuffer>) {
|
fn BindBuffer(&self, target: u32, buffer: Option<&WebGLBuffer>) {
|
||||||
match target {
|
match target {
|
||||||
constants::ARRAY_BUFFER |
|
constants::ARRAY_BUFFER |
|
||||||
constants::ELEMENT_ARRAY_BUFFER => (),
|
constants::ELEMENT_ARRAY_BUFFER => (),
|
||||||
|
@ -293,7 +293,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||||
fn BindFramebuffer(self, target: u32, framebuffer: Option<&WebGLFramebuffer>) {
|
fn BindFramebuffer(&self, target: u32, framebuffer: Option<&WebGLFramebuffer>) {
|
||||||
if target != constants::FRAMEBUFFER {
|
if target != constants::FRAMEBUFFER {
|
||||||
return self.webgl_error(InvalidOperation);
|
return self.webgl_error(InvalidOperation);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||||
fn BindRenderbuffer(self, target: u32, renderbuffer: Option<&WebGLRenderbuffer>) {
|
fn BindRenderbuffer(&self, target: u32, renderbuffer: Option<&WebGLRenderbuffer>) {
|
||||||
if target != constants::RENDERBUFFER {
|
if target != constants::RENDERBUFFER {
|
||||||
return self.webgl_error(InvalidEnum);
|
return self.webgl_error(InvalidEnum);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||||
fn BindTexture(self, target: u32, texture: Option<&WebGLTexture>) {
|
fn BindTexture(&self, target: u32, texture: Option<&WebGLTexture>) {
|
||||||
let slot = match target {
|
let slot = match target {
|
||||||
constants::TEXTURE_2D => &self.bound_texture_2d,
|
constants::TEXTURE_2D => &self.bound_texture_2d,
|
||||||
constants::TEXTURE_CUBE_MAP => &self.bound_texture_cube_map,
|
constants::TEXTURE_CUBE_MAP => &self.bound_texture_cube_map,
|
||||||
|
@ -347,7 +347,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||||
fn BufferData(self, _cx: *mut JSContext, target: u32, data: Option<*mut JSObject>, usage: u32) {
|
fn BufferData(&self, _cx: *mut JSContext, target: u32, data: Option<*mut JSObject>, usage: u32) {
|
||||||
let data = match data {
|
let data = match data {
|
||||||
Some(data) => data,
|
Some(data) => data,
|
||||||
None => return,
|
None => return,
|
||||||
|
@ -369,41 +369,41 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11
|
||||||
fn Clear(self, mask: u32) {
|
fn Clear(&self, mask: u32) {
|
||||||
self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::Clear(mask))).unwrap();
|
self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::Clear(mask))).unwrap();
|
||||||
self.mark_as_dirty();
|
self.mark_as_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn ClearColor(self, red: f32, green: f32, blue: f32, alpha: f32) {
|
fn ClearColor(&self, red: f32, green: f32, blue: f32, alpha: f32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearColor(red, green, blue, alpha)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearColor(red, green, blue, alpha)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn ClearDepth(self, depth: f32) {
|
fn ClearDepth(&self, depth: f32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearDepth(depth as f64)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearDepth(depth as f64)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn ClearStencil(self, stencil: i32) {
|
fn ClearStencil(&self, stencil: i32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearStencil(stencil)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearStencil(stencil)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn ColorMask(self, r: bool, g: bool, b: bool, a: bool) {
|
fn ColorMask(&self, r: bool, g: bool, b: bool, a: bool) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::ColorMask(r, g, b, a)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::ColorMask(r, g, b, a)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn CullFace(self, mode: u32) {
|
fn CullFace(&self, mode: u32) {
|
||||||
match mode {
|
match mode {
|
||||||
constants::FRONT | constants::BACK | constants::FRONT_AND_BACK =>
|
constants::FRONT | constants::BACK | constants::FRONT_AND_BACK =>
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
|
@ -414,7 +414,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn FrontFace(self, mode: u32) {
|
fn FrontFace(&self, mode: u32) {
|
||||||
match mode {
|
match mode {
|
||||||
constants::CW | constants::CCW =>
|
constants::CW | constants::CCW =>
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
|
@ -424,7 +424,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn DepthFunc(self, func: u32) {
|
fn DepthFunc(&self, func: u32) {
|
||||||
match func {
|
match func {
|
||||||
constants::NEVER | constants::LESS |
|
constants::NEVER | constants::LESS |
|
||||||
constants::EQUAL | constants::LEQUAL |
|
constants::EQUAL | constants::LEQUAL |
|
||||||
|
@ -438,21 +438,21 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn DepthMask(self, flag: bool) {
|
fn DepthMask(&self, flag: bool) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::DepthMask(flag)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::DepthMask(flag)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn DepthRange(self, near: f32, far: f32) {
|
fn DepthRange(&self, near: f32, far: f32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::DepthRange(near as f64, far as f64)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::DepthRange(near as f64, far as f64)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn Enable(self, cap: u32) {
|
fn Enable(&self, cap: u32) {
|
||||||
match cap {
|
match cap {
|
||||||
constants::BLEND | constants::CULL_FACE | constants::DEPTH_TEST | constants::DITHER |
|
constants::BLEND | constants::CULL_FACE | constants::DEPTH_TEST | constants::DITHER |
|
||||||
constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE |
|
constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE |
|
||||||
|
@ -465,7 +465,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn Disable(self, cap: u32) {
|
fn Disable(&self, cap: u32) {
|
||||||
match cap {
|
match cap {
|
||||||
constants::BLEND | constants::CULL_FACE | constants::DEPTH_TEST | constants::DITHER |
|
constants::BLEND | constants::CULL_FACE | constants::DEPTH_TEST | constants::DITHER |
|
||||||
constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE |
|
constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE |
|
||||||
|
@ -478,7 +478,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn CompileShader(self, shader: Option<&WebGLShader>) {
|
fn CompileShader(&self, shader: Option<&WebGLShader>) {
|
||||||
if let Some(shader) = shader {
|
if let Some(shader) = shader {
|
||||||
shader.compile()
|
shader.compile()
|
||||||
}
|
}
|
||||||
|
@ -487,81 +487,81 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
// TODO(ecoal95): Probably in the future we should keep track of the
|
// TODO(ecoal95): Probably in the future we should keep track of the
|
||||||
// generated objects, either here or in the webgl task
|
// generated objects, either here or in the webgl task
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||||
fn CreateBuffer(self) -> Option<Root<WebGLBuffer>> {
|
fn CreateBuffer(&self) -> Option<Root<WebGLBuffer>> {
|
||||||
WebGLBuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
WebGLBuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||||
fn CreateFramebuffer(self) -> Option<Root<WebGLFramebuffer>> {
|
fn CreateFramebuffer(&self) -> Option<Root<WebGLFramebuffer>> {
|
||||||
WebGLFramebuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
WebGLFramebuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||||
fn CreateRenderbuffer(self) -> Option<Root<WebGLRenderbuffer>> {
|
fn CreateRenderbuffer(&self) -> Option<Root<WebGLRenderbuffer>> {
|
||||||
WebGLRenderbuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
WebGLRenderbuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||||
fn CreateTexture(self) -> Option<Root<WebGLTexture>> {
|
fn CreateTexture(&self) -> Option<Root<WebGLTexture>> {
|
||||||
WebGLTexture::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
WebGLTexture::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn CreateProgram(self) -> Option<Root<WebGLProgram>> {
|
fn CreateProgram(&self) -> Option<Root<WebGLProgram>> {
|
||||||
WebGLProgram::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
WebGLProgram::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ecoal95): Check if constants are cross-platform or if we must make a translation
|
// TODO(ecoal95): Check if constants are cross-platform or if we must make a translation
|
||||||
// between WebGL constants and native ones.
|
// between WebGL constants and native ones.
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn CreateShader(self, shader_type: u32) -> Option<Root<WebGLShader>> {
|
fn CreateShader(&self, shader_type: u32) -> Option<Root<WebGLShader>> {
|
||||||
WebGLShader::maybe_new(self.global.root().r(), self.ipc_renderer.clone(), shader_type)
|
WebGLShader::maybe_new(self.global.root().r(), self.ipc_renderer.clone(), shader_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||||
fn DeleteBuffer(self, buffer: Option<&WebGLBuffer>) {
|
fn DeleteBuffer(&self, buffer: Option<&WebGLBuffer>) {
|
||||||
if let Some(buffer) = buffer {
|
if let Some(buffer) = buffer {
|
||||||
buffer.delete()
|
buffer.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||||
fn DeleteFramebuffer(self, framebuffer: Option<&WebGLFramebuffer>) {
|
fn DeleteFramebuffer(&self, framebuffer: Option<&WebGLFramebuffer>) {
|
||||||
if let Some(framebuffer) = framebuffer {
|
if let Some(framebuffer) = framebuffer {
|
||||||
framebuffer.delete()
|
framebuffer.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||||
fn DeleteRenderbuffer(self, renderbuffer: Option<&WebGLRenderbuffer>) {
|
fn DeleteRenderbuffer(&self, renderbuffer: Option<&WebGLRenderbuffer>) {
|
||||||
if let Some(renderbuffer) = renderbuffer {
|
if let Some(renderbuffer) = renderbuffer {
|
||||||
renderbuffer.delete()
|
renderbuffer.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||||
fn DeleteTexture(self, texture: Option<&WebGLTexture>) {
|
fn DeleteTexture(&self, texture: Option<&WebGLTexture>) {
|
||||||
if let Some(texture) = texture {
|
if let Some(texture) = texture {
|
||||||
texture.delete()
|
texture.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn DeleteProgram(self, program: Option<&WebGLProgram>) {
|
fn DeleteProgram(&self, program: Option<&WebGLProgram>) {
|
||||||
if let Some(program) = program {
|
if let Some(program) = program {
|
||||||
program.delete()
|
program.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn DeleteShader(self, shader: Option<&WebGLShader>) {
|
fn DeleteShader(&self, shader: Option<&WebGLShader>) {
|
||||||
if let Some(shader) = shader {
|
if let Some(shader) = shader {
|
||||||
shader.delete()
|
shader.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11
|
||||||
fn DrawArrays(self, mode: u32, first: i32, count: i32) {
|
fn DrawArrays(&self, mode: u32, first: i32, count: i32) {
|
||||||
match mode {
|
match mode {
|
||||||
constants::POINTS | constants::LINE_STRIP |
|
constants::POINTS | constants::LINE_STRIP |
|
||||||
constants::LINE_LOOP | constants::LINES |
|
constants::LINE_LOOP | constants::LINES |
|
||||||
|
@ -583,14 +583,14 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
||||||
fn EnableVertexAttribArray(self, attrib_id: u32) {
|
fn EnableVertexAttribArray(&self, attrib_id: u32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::EnableVertexAttribArray(attrib_id)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::EnableVertexAttribArray(attrib_id)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
||||||
fn GetAttribLocation(self, program: Option<&WebGLProgram>, name: DOMString) -> i32 {
|
fn GetAttribLocation(&self, program: Option<&WebGLProgram>, name: DOMString) -> i32 {
|
||||||
if let Some(program) = program {
|
if let Some(program) = program {
|
||||||
handle_potential_webgl_error!(self, program.get_attrib_location(name), None).unwrap_or(-1)
|
handle_potential_webgl_error!(self, program.get_attrib_location(name), None).unwrap_or(-1)
|
||||||
} else {
|
} else {
|
||||||
|
@ -599,7 +599,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn GetShaderInfoLog(self, shader: Option<&WebGLShader>) -> Option<DOMString> {
|
fn GetShaderInfoLog(&self, shader: Option<&WebGLShader>) -> Option<DOMString> {
|
||||||
if let Some(shader) = shader {
|
if let Some(shader) = shader {
|
||||||
shader.info_log()
|
shader.info_log()
|
||||||
} else {
|
} else {
|
||||||
|
@ -608,7 +608,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn GetShaderParameter(self, _: *mut JSContext, shader: Option<&WebGLShader>, param_id: u32) -> JSVal {
|
fn GetShaderParameter(&self, _: *mut JSContext, shader: Option<&WebGLShader>, param_id: u32) -> JSVal {
|
||||||
if let Some(shader) = shader {
|
if let Some(shader) = shader {
|
||||||
match handle_potential_webgl_error!(self, shader.parameter(param_id), WebGLShaderParameter::Invalid) {
|
match handle_potential_webgl_error!(self, shader.parameter(param_id), WebGLShaderParameter::Invalid) {
|
||||||
WebGLShaderParameter::Int(val) => Int32Value(val),
|
WebGLShaderParameter::Int(val) => Int32Value(val),
|
||||||
|
@ -621,7 +621,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
||||||
fn GetUniformLocation(self,
|
fn GetUniformLocation(&self,
|
||||||
program: Option<&WebGLProgram>,
|
program: Option<&WebGLProgram>,
|
||||||
name: DOMString) -> Option<Root<WebGLUniformLocation>> {
|
name: DOMString) -> Option<Root<WebGLUniformLocation>> {
|
||||||
if let Some(program) = program {
|
if let Some(program) = program {
|
||||||
|
@ -633,7 +633,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn Hint(self, target: u32, mode: u32) {
|
fn Hint(&self, target: u32, mode: u32) {
|
||||||
if target != constants::GENERATE_MIPMAP_HINT {
|
if target != constants::GENERATE_MIPMAP_HINT {
|
||||||
return self.webgl_error(InvalidEnum);
|
return self.webgl_error(InvalidEnum);
|
||||||
}
|
}
|
||||||
|
@ -652,7 +652,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn LineWidth(self, width: f32) {
|
fn LineWidth(&self, width: f32) {
|
||||||
if width.is_nan() || width <= 0f32 {
|
if width.is_nan() || width <= 0f32 {
|
||||||
return self.webgl_error(InvalidValue);
|
return self.webgl_error(InvalidValue);
|
||||||
}
|
}
|
||||||
|
@ -665,7 +665,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
// NOTE: Usage of this function could affect rendering while we keep using
|
// NOTE: Usage of this function could affect rendering while we keep using
|
||||||
// readback to render to the page.
|
// readback to render to the page.
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn PixelStorei(self, param_name: u32, param_value: i32) {
|
fn PixelStorei(&self, param_name: u32, param_value: i32) {
|
||||||
let mut texture_settings = self.texture_unpacking_settings.get();
|
let mut texture_settings = self.texture_unpacking_settings.get();
|
||||||
match param_name {
|
match param_name {
|
||||||
constants::UNPACK_FLIP_Y_WEBGL => {
|
constants::UNPACK_FLIP_Y_WEBGL => {
|
||||||
|
@ -716,28 +716,28 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||||
fn PolygonOffset(self, factor: f32, units: f32) {
|
fn PolygonOffset(&self, factor: f32, units: f32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::PolygonOffset(factor, units)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::PolygonOffset(factor, units)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn LinkProgram(self, program: Option<&WebGLProgram>) {
|
fn LinkProgram(&self, program: Option<&WebGLProgram>) {
|
||||||
if let Some(program) = program {
|
if let Some(program) = program {
|
||||||
program.link()
|
program.link()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn ShaderSource(self, shader: Option<&WebGLShader>, source: DOMString) {
|
fn ShaderSource(&self, shader: Option<&WebGLShader>, source: DOMString) {
|
||||||
if let Some(shader) = shader {
|
if let Some(shader) = shader {
|
||||||
shader.set_source(source)
|
shader.set_source(source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn GetShaderSource(self, shader: Option<&WebGLShader>) -> Option<DOMString> {
|
fn GetShaderSource(&self, shader: Option<&WebGLShader>) -> Option<DOMString> {
|
||||||
if let Some(shader) = shader {
|
if let Some(shader) = shader {
|
||||||
shader.source()
|
shader.source()
|
||||||
} else {
|
} else {
|
||||||
|
@ -747,7 +747,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
||||||
fn Uniform4fv(self,
|
fn Uniform4fv(&self,
|
||||||
_cx: *mut JSContext,
|
_cx: *mut JSContext,
|
||||||
uniform: Option<&WebGLUniformLocation>,
|
uniform: Option<&WebGLUniformLocation>,
|
||||||
data: Option<*mut JSObject>) {
|
data: Option<*mut JSObject>) {
|
||||||
|
@ -771,14 +771,14 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn UseProgram(self, program: Option<&WebGLProgram>) {
|
fn UseProgram(&self, program: Option<&WebGLProgram>) {
|
||||||
if let Some(program) = program {
|
if let Some(program) = program {
|
||||||
program.use_program()
|
program.use_program()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
|
||||||
fn VertexAttribPointer(self, attrib_id: u32, size: i32, data_type: u32,
|
fn VertexAttribPointer(&self, attrib_id: u32, size: i32, data_type: u32,
|
||||||
normalized: bool, stride: i32, offset: i64) {
|
normalized: bool, stride: i32, offset: i64) {
|
||||||
if let constants::FLOAT = data_type {
|
if let constants::FLOAT = data_type {
|
||||||
let msg = CanvasMsg::WebGL(
|
let msg = CanvasMsg::WebGL(
|
||||||
|
@ -790,14 +790,14 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4
|
||||||
fn Viewport(self, x: i32, y: i32, width: i32, height: i32) {
|
fn Viewport(&self, x: i32, y: i32, width: i32, height: i32) {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::Viewport(x, y, width, height)))
|
.send(CanvasMsg::WebGL(CanvasWebGLMsg::Viewport(x, y, width, height)))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||||
fn TexImage2D(self,
|
fn TexImage2D(&self,
|
||||||
target: u32,
|
target: u32,
|
||||||
level: i32,
|
level: i32,
|
||||||
internal_format: u32,
|
internal_format: u32,
|
||||||
|
@ -868,7 +868,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||||
fn TexParameterf(self, target: u32, name: u32, value: f32) {
|
fn TexParameterf(&self, target: u32, name: u32, value: f32) {
|
||||||
match target {
|
match target {
|
||||||
constants::TEXTURE_2D |
|
constants::TEXTURE_2D |
|
||||||
constants::TEXTURE_CUBE_MAP => {
|
constants::TEXTURE_CUBE_MAP => {
|
||||||
|
@ -886,7 +886,7 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||||
fn TexParameteri(self, target: u32, name: u32, value: i32) {
|
fn TexParameteri(&self, target: u32, name: u32, value: i32) {
|
||||||
match target {
|
match target {
|
||||||
constants::TEXTURE_2D |
|
constants::TEXTURE_2D |
|
||||||
constants::TEXTURE_CUBE_MAP => {
|
constants::TEXTURE_CUBE_MAP => {
|
||||||
|
|
|
@ -38,19 +38,19 @@ impl WebGLShaderPrecisionFormat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WebGLShaderPrecisionFormatMethods for &'a WebGLShaderPrecisionFormat {
|
impl WebGLShaderPrecisionFormatMethods for WebGLShaderPrecisionFormat {
|
||||||
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
|
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
|
||||||
fn RangeMin(self) -> i32 {
|
fn RangeMin(&self) -> i32 {
|
||||||
self.range_min
|
self.range_min
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
|
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
|
||||||
fn RangeMax(self) -> i32 {
|
fn RangeMax(&self) -> i32 {
|
||||||
self.range_max
|
self.range_max
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
|
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
|
||||||
fn Precision(self) -> i32 {
|
fn Precision(&self) -> i32 {
|
||||||
self.precision
|
self.precision
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,34 +226,34 @@ impl WebSocket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WebSocketMethods for &'a WebSocket {
|
impl WebSocketMethods for WebSocket {
|
||||||
event_handler!(open, GetOnopen, SetOnopen);
|
event_handler!(open, GetOnopen, SetOnopen);
|
||||||
event_handler!(close, GetOnclose, SetOnclose);
|
event_handler!(close, GetOnclose, SetOnclose);
|
||||||
event_handler!(error, GetOnerror, SetOnerror);
|
event_handler!(error, GetOnerror, SetOnerror);
|
||||||
event_handler!(message, GetOnmessage, SetOnmessage);
|
event_handler!(message, GetOnmessage, SetOnmessage);
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-url
|
// https://html.spec.whatwg.org/multipage/#dom-websocket-url
|
||||||
fn Url(self) -> DOMString {
|
fn Url(&self) -> DOMString {
|
||||||
self.url.serialize()
|
self.url.serialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-readystate
|
// https://html.spec.whatwg.org/multipage/#dom-websocket-readystate
|
||||||
fn ReadyState(self) -> u16 {
|
fn ReadyState(&self) -> u16 {
|
||||||
self.ready_state.get() as u16
|
self.ready_state.get() as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-binarytype
|
// https://html.spec.whatwg.org/multipage/#dom-websocket-binarytype
|
||||||
fn BinaryType(self) -> BinaryType {
|
fn BinaryType(&self) -> BinaryType {
|
||||||
self.binary_type.get()
|
self.binary_type.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-binarytype
|
// https://html.spec.whatwg.org/multipage/#dom-websocket-binarytype
|
||||||
fn SetBinaryType(self, btype: BinaryType) {
|
fn SetBinaryType(&self, btype: BinaryType) {
|
||||||
self.binary_type.set(btype)
|
self.binary_type.set(btype)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-send
|
// https://html.spec.whatwg.org/multipage/#dom-websocket-send
|
||||||
fn Send(self, data: Option<USVString>) -> Fallible<()> {
|
fn Send(&self, data: Option<USVString>) -> Fallible<()> {
|
||||||
match self.ready_state.get() {
|
match self.ready_state.get() {
|
||||||
WebSocketRequestState::Connecting => {
|
WebSocketRequestState::Connecting => {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState);
|
||||||
|
@ -280,7 +280,7 @@ impl<'a> WebSocketMethods for &'a WebSocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-close
|
// https://html.spec.whatwg.org/multipage/#dom-websocket-close
|
||||||
fn Close(self, code: Option<u16>, reason: Option<USVString>) -> Fallible<()>{
|
fn Close(&self, code: Option<u16>, reason: Option<USVString>) -> Fallible<()>{
|
||||||
fn send_close(this: &WebSocket) {
|
fn send_close(this: &WebSocket) {
|
||||||
this.ready_state.set(WebSocketRequestState::Closing);
|
this.ready_state.set(WebSocketRequestState::Closing);
|
||||||
|
|
||||||
|
|
|
@ -356,9 +356,9 @@ pub fn base64_atob(input: DOMString) -> Fallible<DOMString> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WindowMethods for &'a Window {
|
impl WindowMethods for Window {
|
||||||
// https://html.spec.whatwg.org/#dom-alert
|
// https://html.spec.whatwg.org/#dom-alert
|
||||||
fn Alert(self, s: DOMString) {
|
fn Alert(&self, s: DOMString) {
|
||||||
// Right now, just print to the console
|
// Right now, just print to the console
|
||||||
// Ensure that stderr doesn't trample through the alert() we use to
|
// Ensure that stderr doesn't trample through the alert() we use to
|
||||||
// communicate test results.
|
// communicate test results.
|
||||||
|
@ -372,52 +372,52 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-window-close
|
// https://html.spec.whatwg.org/multipage/#dom-window-close
|
||||||
fn Close(self) {
|
fn Close(&self) {
|
||||||
self.main_thread_script_chan().send(MainThreadScriptMsg::ExitWindow(self.id.clone())).unwrap();
|
self.main_thread_script_chan().send(MainThreadScriptMsg::ExitWindow(self.id.clone())).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-0
|
// https://html.spec.whatwg.org/multipage/#dom-document-0
|
||||||
fn Document(self) -> Root<Document> {
|
fn Document(&self) -> Root<Document> {
|
||||||
self.browsing_context().as_ref().unwrap().active_document()
|
self.browsing_context().as_ref().unwrap().active_document()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-location
|
// https://html.spec.whatwg.org/#dom-location
|
||||||
fn Location(self) -> Root<Location> {
|
fn Location(&self) -> Root<Location> {
|
||||||
self.Document().r().Location()
|
self.Document().r().Location()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-sessionstorage
|
// https://html.spec.whatwg.org/#dom-sessionstorage
|
||||||
fn SessionStorage(self) -> Root<Storage> {
|
fn SessionStorage(&self) -> Root<Storage> {
|
||||||
self.session_storage.or_init(|| Storage::new(&GlobalRef::Window(self), StorageType::Session))
|
self.session_storage.or_init(|| Storage::new(&GlobalRef::Window(self), StorageType::Session))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-localstorage
|
// https://html.spec.whatwg.org/#dom-localstorage
|
||||||
fn LocalStorage(self) -> Root<Storage> {
|
fn LocalStorage(&self) -> Root<Storage> {
|
||||||
self.local_storage.or_init(|| Storage::new(&GlobalRef::Window(self), StorageType::Local))
|
self.local_storage.or_init(|| Storage::new(&GlobalRef::Window(self), StorageType::Local))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
||||||
fn Console(self) -> Root<Console> {
|
fn Console(&self) -> Root<Console> {
|
||||||
self.console.or_init(|| Console::new(GlobalRef::Window(self)))
|
self.console.or_init(|| Console::new(GlobalRef::Window(self)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-GlobalCrypto
|
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-GlobalCrypto
|
||||||
fn Crypto(self) -> Root<Crypto> {
|
fn Crypto(&self) -> Root<Crypto> {
|
||||||
self.crypto.or_init(|| Crypto::new(GlobalRef::Window(self)))
|
self.crypto.or_init(|| Crypto::new(GlobalRef::Window(self)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-frameelement
|
// https://html.spec.whatwg.org/#dom-frameelement
|
||||||
fn GetFrameElement(self) -> Option<Root<Element>> {
|
fn GetFrameElement(&self) -> Option<Root<Element>> {
|
||||||
self.browsing_context().as_ref().unwrap().frame_element()
|
self.browsing_context().as_ref().unwrap().frame_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-navigator
|
// https://html.spec.whatwg.org/#dom-navigator
|
||||||
fn Navigator(self) -> Root<Navigator> {
|
fn Navigator(&self) -> Root<Navigator> {
|
||||||
self.navigator.or_init(|| Navigator::new(self))
|
self.navigator.or_init(|| Navigator::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-windowtimers-settimeout
|
// https://html.spec.whatwg.org/#dom-windowtimers-settimeout
|
||||||
fn SetTimeout(self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
fn SetTimeout(&self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
||||||
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
|
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -427,7 +427,7 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-windowtimers-settimeout
|
// https://html.spec.whatwg.org/#dom-windowtimers-settimeout
|
||||||
fn SetTimeout_(self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
fn SetTimeout_(&self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
||||||
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
|
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -437,12 +437,12 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-windowtimers-cleartimeout
|
// https://html.spec.whatwg.org/#dom-windowtimers-cleartimeout
|
||||||
fn ClearTimeout(self, handle: i32) {
|
fn ClearTimeout(&self, handle: i32) {
|
||||||
self.timers.clear_timeout_or_interval(handle);
|
self.timers.clear_timeout_or_interval(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-windowtimers-setinterval
|
// https://html.spec.whatwg.org/#dom-windowtimers-setinterval
|
||||||
fn SetInterval(self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
fn SetInterval(&self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
||||||
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
|
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -452,7 +452,7 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-windowtimers-setinterval
|
// https://html.spec.whatwg.org/#dom-windowtimers-setinterval
|
||||||
fn SetInterval_(self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
fn SetInterval_(&self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
||||||
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
|
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -462,32 +462,32 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/#dom-windowtimers-clearinterval
|
// https://html.spec.whatwg.org/#dom-windowtimers-clearinterval
|
||||||
fn ClearInterval(self, handle: i32) {
|
fn ClearInterval(&self, handle: i32) {
|
||||||
self.ClearTimeout(handle);
|
self.ClearTimeout(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-window
|
// https://html.spec.whatwg.org/multipage/#dom-window
|
||||||
fn Window(self) -> Root<Window> {
|
fn Window(&self) -> Root<Window> {
|
||||||
Root::from_ref(self)
|
Root::from_ref(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-self
|
// https://html.spec.whatwg.org/multipage/#dom-self
|
||||||
fn Self_(self) -> Root<Window> {
|
fn Self_(&self) -> Root<Window> {
|
||||||
self.Window()
|
self.Window()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.whatwg.org/html/#dom-frames
|
// https://www.whatwg.org/html/#dom-frames
|
||||||
fn Frames(self) -> Root<Window> {
|
fn Frames(&self) -> Root<Window> {
|
||||||
self.Window()
|
self.Window()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-parent
|
// https://html.spec.whatwg.org/multipage/#dom-parent
|
||||||
fn Parent(self) -> Root<Window> {
|
fn Parent(&self) -> Root<Window> {
|
||||||
self.parent().unwrap_or(self.Window())
|
self.parent().unwrap_or(self.Window())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-top
|
// https://html.spec.whatwg.org/multipage/#dom-top
|
||||||
fn Top(self) -> Root<Window> {
|
fn Top(&self) -> Root<Window> {
|
||||||
let mut window = self.Window();
|
let mut window = self.Window();
|
||||||
while let Some(parent) = window.parent() {
|
while let Some(parent) = window.parent() {
|
||||||
window = parent;
|
window = parent;
|
||||||
|
@ -497,7 +497,7 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/
|
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/
|
||||||
// NavigationTiming/Overview.html#sec-window.performance-attribute
|
// NavigationTiming/Overview.html#sec-window.performance-attribute
|
||||||
fn Performance(self) -> Root<Performance> {
|
fn Performance(&self) -> Root<Performance> {
|
||||||
self.performance.or_init(|| {
|
self.performance.or_init(|| {
|
||||||
Performance::new(self, self.navigation_start,
|
Performance::new(self, self.navigation_start,
|
||||||
self.navigation_start_precise)
|
self.navigation_start_precise)
|
||||||
|
@ -509,22 +509,22 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
error_event_handler!(error, GetOnerror, SetOnerror);
|
error_event_handler!(error, GetOnerror, SetOnerror);
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Window/screen
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/screen
|
||||||
fn Screen(self) -> Root<Screen> {
|
fn Screen(&self) -> Root<Screen> {
|
||||||
self.screen.or_init(|| Screen::new(self))
|
self.screen.or_init(|| Screen::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa
|
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa
|
||||||
fn Btoa(self, btoa: DOMString) -> Fallible<DOMString> {
|
fn Btoa(&self, btoa: DOMString) -> Fallible<DOMString> {
|
||||||
base64_btoa(btoa)
|
base64_btoa(btoa)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-atob
|
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-atob
|
||||||
fn Atob(self, atob: DOMString) -> Fallible<DOMString> {
|
fn Atob(&self, atob: DOMString) -> Fallible<DOMString> {
|
||||||
base64_atob(atob)
|
base64_atob(atob)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
||||||
fn RequestAnimationFrame(self, callback: Rc<FrameRequestCallback>) -> i32 {
|
fn RequestAnimationFrame(&self, callback: Rc<FrameRequestCallback>) -> i32 {
|
||||||
let doc = self.Document();
|
let doc = self.Document();
|
||||||
|
|
||||||
let callback = move |now: f64| {
|
let callback = move |now: f64| {
|
||||||
|
@ -537,38 +537,38 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
||||||
fn CancelAnimationFrame(self, ident: i32) {
|
fn CancelAnimationFrame(&self, ident: i32) {
|
||||||
let doc = self.Document();
|
let doc = self.Document();
|
||||||
doc.r().cancel_animation_frame(ident);
|
doc.r().cancel_animation_frame(ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-window-captureevents
|
// https://html.spec.whatwg.org/multipage/#dom-window-captureevents
|
||||||
fn CaptureEvents(self) {
|
fn CaptureEvents(&self) {
|
||||||
// This method intentionally does nothing
|
// This method intentionally does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-window-releaseevents
|
// https://html.spec.whatwg.org/multipage/#dom-window-releaseevents
|
||||||
fn ReleaseEvents(self) {
|
fn ReleaseEvents(&self) {
|
||||||
// This method intentionally does nothing
|
// This method intentionally does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
fn Debug(self, message: DOMString) {
|
fn Debug(&self, message: DOMString) {
|
||||||
debug!("{}", message);
|
debug!("{}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn Gc(self) {
|
fn Gc(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_GC(JS_GetRuntime(self.get_cx()));
|
JS_GC(JS_GetRuntime(self.get_cx()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Trap(self) {
|
fn Trap(&self) {
|
||||||
breakpoint();
|
breakpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn WebdriverCallback(self, cx: *mut JSContext, val: HandleValue) {
|
fn WebdriverCallback(&self, cx: *mut JSContext, val: HandleValue) {
|
||||||
let rv = jsval_to_webdriver(cx, val);
|
let rv = jsval_to_webdriver(cx, val);
|
||||||
let opt_chan = self.webdriver_script_chan.borrow_mut().take();
|
let opt_chan = self.webdriver_script_chan.borrow_mut().take();
|
||||||
if let Some(chan) = opt_chan {
|
if let Some(chan) = opt_chan {
|
||||||
|
@ -576,7 +576,7 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn WebdriverTimeout(self) {
|
fn WebdriverTimeout(&self) {
|
||||||
let opt_chan = self.webdriver_script_chan.borrow_mut().take();
|
let opt_chan = self.webdriver_script_chan.borrow_mut().take();
|
||||||
if let Some(chan) = opt_chan {
|
if let Some(chan) = opt_chan {
|
||||||
chan.send(Err(WebDriverJSError::Timeout)).unwrap();
|
chan.send(Err(WebDriverJSError::Timeout)).unwrap();
|
||||||
|
@ -584,7 +584,7 @@ impl<'a> WindowMethods for &'a Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle
|
// https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle
|
||||||
fn GetComputedStyle(self,
|
fn GetComputedStyle(&self,
|
||||||
element: &Element,
|
element: &Element,
|
||||||
pseudo: Option<DOMString>) -> Root<CSSStyleDeclaration> {
|
pseudo: Option<DOMString>) -> Root<CSSStyleDeclaration> {
|
||||||
// Steps 1-4.
|
// Steps 1-4.
|
||||||
|
|
|
@ -153,9 +153,9 @@ impl Worker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WorkerMethods for &'a Worker {
|
impl WorkerMethods for Worker {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage
|
// https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage
|
||||||
fn PostMessage(self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
|
fn PostMessage(&self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
|
||||||
let data = try!(StructuredCloneData::write(cx, message));
|
let data = try!(StructuredCloneData::write(cx, message));
|
||||||
let address = Trusted::new(cx, self, self.global.root().r().script_chan().clone());
|
let address = Trusted::new(cx, self, self.global.root().r().script_chan().clone());
|
||||||
self.sender.send((address, WorkerScriptMsg::DOMMessage(data))).unwrap();
|
self.sender.send((address, WorkerScriptMsg::DOMMessage(data))).unwrap();
|
||||||
|
|
|
@ -161,21 +161,21 @@ impl WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
|
impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-self
|
// https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-self
|
||||||
fn Self_(self) -> Root<WorkerGlobalScope> {
|
fn Self_(&self) -> Root<WorkerGlobalScope> {
|
||||||
Root::from_ref(self)
|
Root::from_ref(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-location
|
// https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-location
|
||||||
fn Location(self) -> Root<WorkerLocation> {
|
fn Location(&self) -> Root<WorkerLocation> {
|
||||||
self.location.or_init(|| {
|
self.location.or_init(|| {
|
||||||
WorkerLocation::new(self, self.worker_url.clone())
|
WorkerLocation::new(self, self.worker_url.clone())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-importscripts
|
// https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-importscripts
|
||||||
fn ImportScripts(self, url_strings: Vec<DOMString>) -> ErrorResult {
|
fn ImportScripts(&self, url_strings: Vec<DOMString>) -> ErrorResult {
|
||||||
let mut urls = Vec::with_capacity(url_strings.len());
|
let mut urls = Vec::with_capacity(url_strings.len());
|
||||||
for url in url_strings {
|
for url in url_strings {
|
||||||
let url = UrlParser::new().base_url(&self.worker_url)
|
let url = UrlParser::new().base_url(&self.worker_url)
|
||||||
|
@ -208,32 +208,32 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-worker-navigator
|
// https://html.spec.whatwg.org/multipage/#dom-worker-navigator
|
||||||
fn Navigator(self) -> Root<WorkerNavigator> {
|
fn Navigator(&self) -> Root<WorkerNavigator> {
|
||||||
self.navigator.or_init(|| WorkerNavigator::new(self))
|
self.navigator.or_init(|| WorkerNavigator::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/console
|
// https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/console
|
||||||
fn Console(self) -> Root<Console> {
|
fn Console(&self) -> Root<Console> {
|
||||||
self.console.or_init(|| Console::new(GlobalRef::Worker(self)))
|
self.console.or_init(|| Console::new(GlobalRef::Worker(self)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dfn-Crypto
|
// https://html.spec.whatwg.org/multipage/#dfn-Crypto
|
||||||
fn Crypto(self) -> Root<Crypto> {
|
fn Crypto(&self) -> Root<Crypto> {
|
||||||
self.crypto.or_init(|| Crypto::new(GlobalRef::Worker(self)))
|
self.crypto.or_init(|| Crypto::new(GlobalRef::Worker(self)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa
|
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa
|
||||||
fn Btoa(self, btoa: DOMString) -> Fallible<DOMString> {
|
fn Btoa(&self, btoa: DOMString) -> Fallible<DOMString> {
|
||||||
base64_btoa(btoa)
|
base64_btoa(btoa)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-atob
|
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-atob
|
||||||
fn Atob(self, atob: DOMString) -> Fallible<DOMString> {
|
fn Atob(&self, atob: DOMString) -> Fallible<DOMString> {
|
||||||
base64_atob(atob)
|
base64_atob(atob)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
|
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
|
||||||
fn SetTimeout(self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
fn SetTimeout(&self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
||||||
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
|
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -243,7 +243,7 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
|
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
|
||||||
fn SetTimeout_(self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
fn SetTimeout_(&self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
||||||
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
|
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -253,12 +253,12 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-clearinterval
|
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-clearinterval
|
||||||
fn ClearTimeout(self, handle: i32) {
|
fn ClearTimeout(&self, handle: i32) {
|
||||||
self.timers.clear_timeout_or_interval(handle);
|
self.timers.clear_timeout_or_interval(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
|
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
|
||||||
fn SetInterval(self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
fn SetInterval(&self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
||||||
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
|
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -268,7 +268,7 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
|
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
|
||||||
fn SetInterval_(self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
fn SetInterval_(&self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
|
||||||
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
|
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -278,7 +278,7 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-clearinterval
|
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-clearinterval
|
||||||
fn ClearInterval(self, handle: i32) {
|
fn ClearInterval(&self, handle: i32) {
|
||||||
self.ClearTimeout(handle);
|
self.ClearTimeout(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,49 +36,49 @@ impl WorkerLocation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WorkerLocationMethods for &'a WorkerLocation {
|
impl WorkerLocationMethods for WorkerLocation {
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
||||||
fn Hash(self) -> USVString {
|
fn Hash(&self) -> USVString {
|
||||||
UrlHelper::Hash(&self.url)
|
UrlHelper::Hash(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-host
|
// https://url.spec.whatwg.org/#dom-urlutils-host
|
||||||
fn Host(self) -> USVString {
|
fn Host(&self) -> USVString {
|
||||||
UrlHelper::Host(&self.url)
|
UrlHelper::Host(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-hostname
|
// https://url.spec.whatwg.org/#dom-urlutils-hostname
|
||||||
fn Hostname(self) -> USVString {
|
fn Hostname(&self) -> USVString {
|
||||||
UrlHelper::Hostname(&self.url)
|
UrlHelper::Hostname(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-href
|
// https://url.spec.whatwg.org/#dom-urlutils-href
|
||||||
fn Href(self) -> USVString {
|
fn Href(&self) -> USVString {
|
||||||
UrlHelper::Href(&self.url)
|
UrlHelper::Href(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-pathname
|
// https://url.spec.whatwg.org/#dom-urlutils-pathname
|
||||||
fn Pathname(self) -> USVString {
|
fn Pathname(&self) -> USVString {
|
||||||
UrlHelper::Pathname(&self.url)
|
UrlHelper::Pathname(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-port
|
// https://url.spec.whatwg.org/#dom-urlutils-port
|
||||||
fn Port(self) -> USVString {
|
fn Port(&self) -> USVString {
|
||||||
UrlHelper::Port(&self.url)
|
UrlHelper::Port(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-protocol
|
// https://url.spec.whatwg.org/#dom-urlutils-protocol
|
||||||
fn Protocol(self) -> USVString {
|
fn Protocol(&self) -> USVString {
|
||||||
UrlHelper::Protocol(&self.url)
|
UrlHelper::Protocol(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-search
|
// https://url.spec.whatwg.org/#dom-urlutils-search
|
||||||
fn Search(self) -> USVString {
|
fn Search(&self) -> USVString {
|
||||||
UrlHelper::Search(&self.url)
|
UrlHelper::Search(&self.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
||||||
fn Stringifier(self) -> DOMString {
|
fn Stringifier(&self) -> DOMString {
|
||||||
self.Href().0
|
self.Href().0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,39 +31,39 @@ impl WorkerNavigator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WorkerNavigatorMethods for &'a WorkerNavigator {
|
impl WorkerNavigatorMethods for WorkerNavigator {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-product
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-product
|
||||||
fn Product(self) -> DOMString {
|
fn Product(&self) -> DOMString {
|
||||||
navigatorinfo::Product()
|
navigatorinfo::Product()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-taintenabled
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-taintenabled
|
||||||
fn TaintEnabled(self) -> bool {
|
fn TaintEnabled(&self) -> bool {
|
||||||
navigatorinfo::TaintEnabled()
|
navigatorinfo::TaintEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-appname
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-appname
|
||||||
fn AppName(self) -> DOMString {
|
fn AppName(&self) -> DOMString {
|
||||||
navigatorinfo::AppName()
|
navigatorinfo::AppName()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-appcodename
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-appcodename
|
||||||
fn AppCodeName(self) -> DOMString {
|
fn AppCodeName(&self) -> DOMString {
|
||||||
navigatorinfo::AppCodeName()
|
navigatorinfo::AppCodeName()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-platform
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-platform
|
||||||
fn Platform(self) -> DOMString {
|
fn Platform(&self) -> DOMString {
|
||||||
navigatorinfo::Platform()
|
navigatorinfo::Platform()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-useragent
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-useragent
|
||||||
fn UserAgent(self) -> DOMString {
|
fn UserAgent(&self) -> DOMString {
|
||||||
navigatorinfo::UserAgent()
|
navigatorinfo::UserAgent()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-appversion
|
// https://html.spec.whatwg.org/multipage/#dom-navigator-appversion
|
||||||
fn AppVersion(self) -> DOMString {
|
fn AppVersion(&self) -> DOMString {
|
||||||
navigatorinfo::AppVersion()
|
navigatorinfo::AppVersion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,16 +291,16 @@ impl XMLHttpRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange);
|
event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange);
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-readystate
|
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-readystate
|
||||||
fn ReadyState(self) -> u16 {
|
fn ReadyState(&self) -> u16 {
|
||||||
self.ready_state.get() as u16
|
self.ready_state.get() as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-open()-method
|
// https://xhr.spec.whatwg.org/#the-open()-method
|
||||||
fn Open(self, method: ByteString, url: DOMString) -> ErrorResult {
|
fn Open(&self, method: ByteString, url: DOMString) -> ErrorResult {
|
||||||
//FIXME(seanmonstar): use a Trie instead?
|
//FIXME(seanmonstar): use a Trie instead?
|
||||||
let maybe_method = method.as_str().and_then(|s| {
|
let maybe_method = method.as_str().and_then(|s| {
|
||||||
// Note: hyper tests against the uppercase versions
|
// Note: hyper tests against the uppercase versions
|
||||||
|
@ -365,14 +365,14 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-open()-method
|
// https://xhr.spec.whatwg.org/#the-open()-method
|
||||||
fn Open_(self, method: ByteString, url: DOMString, async: bool,
|
fn Open_(&self, method: ByteString, url: DOMString, async: bool,
|
||||||
_username: Option<DOMString>, _password: Option<DOMString>) -> ErrorResult {
|
_username: Option<DOMString>, _password: Option<DOMString>) -> ErrorResult {
|
||||||
self.sync.set(!async);
|
self.sync.set(!async);
|
||||||
self.Open(method, url)
|
self.Open(method, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-setrequestheader()-method
|
// https://xhr.spec.whatwg.org/#the-setrequestheader()-method
|
||||||
fn SetRequestHeader(self, name: ByteString, mut value: ByteString) -> ErrorResult {
|
fn SetRequestHeader(&self, name: ByteString, mut value: ByteString) -> ErrorResult {
|
||||||
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
|
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
|
||||||
return Err(InvalidState); // Step 1, 2
|
return Err(InvalidState); // Step 1, 2
|
||||||
}
|
}
|
||||||
|
@ -422,12 +422,12 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-timeout-attribute
|
// https://xhr.spec.whatwg.org/#the-timeout-attribute
|
||||||
fn Timeout(self) -> u32 {
|
fn Timeout(&self) -> u32 {
|
||||||
self.timeout.get()
|
self.timeout.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-timeout-attribute
|
// https://xhr.spec.whatwg.org/#the-timeout-attribute
|
||||||
fn SetTimeout(self, timeout: u32) -> ErrorResult {
|
fn SetTimeout(&self, timeout: u32) -> ErrorResult {
|
||||||
if self.sync.get() {
|
if self.sync.get() {
|
||||||
// FIXME: Not valid for a worker environment
|
// FIXME: Not valid for a worker environment
|
||||||
Err(InvalidAccess)
|
Err(InvalidAccess)
|
||||||
|
@ -451,12 +451,12 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-withcredentials-attribute
|
// https://xhr.spec.whatwg.org/#the-withcredentials-attribute
|
||||||
fn WithCredentials(self) -> bool {
|
fn WithCredentials(&self) -> bool {
|
||||||
self.with_credentials.get()
|
self.with_credentials.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-withcredentials
|
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-withcredentials
|
||||||
fn SetWithCredentials(self, with_credentials: bool) -> ErrorResult {
|
fn SetWithCredentials(&self, with_credentials: bool) -> ErrorResult {
|
||||||
match self.ready_state.get() {
|
match self.ready_state.get() {
|
||||||
XMLHttpRequestState::HeadersReceived |
|
XMLHttpRequestState::HeadersReceived |
|
||||||
XMLHttpRequestState::Loading |
|
XMLHttpRequestState::Loading |
|
||||||
|
@ -473,12 +473,12 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-upload-attribute
|
// https://xhr.spec.whatwg.org/#the-upload-attribute
|
||||||
fn Upload(self) -> Root<XMLHttpRequestUpload> {
|
fn Upload(&self) -> Root<XMLHttpRequestUpload> {
|
||||||
self.upload.root()
|
self.upload.root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-send()-method
|
// https://xhr.spec.whatwg.org/#the-send()-method
|
||||||
fn Send(self, data: Option<SendParam>) -> ErrorResult {
|
fn Send(&self, data: Option<SendParam>) -> ErrorResult {
|
||||||
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
|
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
|
||||||
return Err(InvalidState); // Step 1, 2
|
return Err(InvalidState); // Step 1, 2
|
||||||
}
|
}
|
||||||
|
@ -610,7 +610,7 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-abort()-method
|
// https://xhr.spec.whatwg.org/#the-abort()-method
|
||||||
fn Abort(self) {
|
fn Abort(&self) {
|
||||||
self.terminate_ongoing_fetch();
|
self.terminate_ongoing_fetch();
|
||||||
let state = self.ready_state.get();
|
let state = self.ready_state.get();
|
||||||
if (state == XMLHttpRequestState::Opened && self.send_flag.get()) ||
|
if (state == XMLHttpRequestState::Opened && self.send_flag.get()) ||
|
||||||
|
@ -628,22 +628,22 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-responseurl-attribute
|
// https://xhr.spec.whatwg.org/#the-responseurl-attribute
|
||||||
fn ResponseURL(self) -> DOMString {
|
fn ResponseURL(&self) -> DOMString {
|
||||||
self.response_url.clone()
|
self.response_url.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-status-attribute
|
// https://xhr.spec.whatwg.org/#the-status-attribute
|
||||||
fn Status(self) -> u16 {
|
fn Status(&self) -> u16 {
|
||||||
self.status.get()
|
self.status.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-statustext-attribute
|
// https://xhr.spec.whatwg.org/#the-statustext-attribute
|
||||||
fn StatusText(self) -> ByteString {
|
fn StatusText(&self) -> ByteString {
|
||||||
self.status_text.borrow().clone()
|
self.status_text.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-getresponseheader()-method
|
// https://xhr.spec.whatwg.org/#the-getresponseheader()-method
|
||||||
fn GetResponseHeader(self, name: ByteString) -> Option<ByteString> {
|
fn GetResponseHeader(&self, name: ByteString) -> Option<ByteString> {
|
||||||
self.filter_response_headers().iter().find(|h| {
|
self.filter_response_headers().iter().find(|h| {
|
||||||
name.eq_ignore_case(&h.name().parse().unwrap())
|
name.eq_ignore_case(&h.name().parse().unwrap())
|
||||||
}).map(|h| {
|
}).map(|h| {
|
||||||
|
@ -652,17 +652,17 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method
|
// https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method
|
||||||
fn GetAllResponseHeaders(self) -> ByteString {
|
fn GetAllResponseHeaders(&self) -> ByteString {
|
||||||
ByteString::new(self.filter_response_headers().to_string().into_bytes())
|
ByteString::new(self.filter_response_headers().to_string().into_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-responsetype-attribute
|
// https://xhr.spec.whatwg.org/#the-responsetype-attribute
|
||||||
fn ResponseType(self) -> XMLHttpRequestResponseType {
|
fn ResponseType(&self) -> XMLHttpRequestResponseType {
|
||||||
self.response_type.get()
|
self.response_type.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-responsetype-attribute
|
// https://xhr.spec.whatwg.org/#the-responsetype-attribute
|
||||||
fn SetResponseType(self, response_type: XMLHttpRequestResponseType) -> ErrorResult {
|
fn SetResponseType(&self, response_type: XMLHttpRequestResponseType) -> ErrorResult {
|
||||||
match self.global.root() {
|
match self.global.root() {
|
||||||
GlobalRoot::Worker(_) if response_type == XMLHttpRequestResponseType::Document
|
GlobalRoot::Worker(_) if response_type == XMLHttpRequestResponseType::Document
|
||||||
=> return Ok(()),
|
=> return Ok(()),
|
||||||
|
@ -680,7 +680,7 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://xhr.spec.whatwg.org/#the-response-attribute
|
// https://xhr.spec.whatwg.org/#the-response-attribute
|
||||||
fn Response(self, cx: *mut JSContext) -> JSVal {
|
fn Response(&self, cx: *mut JSContext) -> JSVal {
|
||||||
let mut rval = RootedValue::new(cx, UndefinedValue());
|
let mut rval = RootedValue::new(cx, UndefinedValue());
|
||||||
match self.response_type.get() {
|
match self.response_type.get() {
|
||||||
_empty | Text => {
|
_empty | Text => {
|
||||||
|
@ -716,7 +716,7 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-responsetext-attribute
|
// https://xhr.spec.whatwg.org/#the-responsetext-attribute
|
||||||
fn GetResponseText(self) -> Fallible<DOMString> {
|
fn GetResponseText(&self) -> Fallible<DOMString> {
|
||||||
match self.response_type.get() {
|
match self.response_type.get() {
|
||||||
_empty | Text => {
|
_empty | Text => {
|
||||||
match self.ready_state.get() {
|
match self.ready_state.get() {
|
||||||
|
@ -729,7 +729,7 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-responsexml-attribute
|
// https://xhr.spec.whatwg.org/#the-responsexml-attribute
|
||||||
fn GetResponseXML(self) -> Option<Root<Document>> {
|
fn GetResponseXML(&self) -> Option<Root<Document>> {
|
||||||
self.response_xml.get().map(Root::from_rooted)
|
self.response_xml.get().map(Root::from_rooted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl XMLHttpRequestEventTargetDerived for EventTarget {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> XMLHttpRequestEventTargetMethods for &'a XMLHttpRequestEventTarget {
|
impl XMLHttpRequestEventTargetMethods for XMLHttpRequestEventTarget {
|
||||||
event_handler!(loadstart, GetOnloadstart, SetOnloadstart);
|
event_handler!(loadstart, GetOnloadstart, SetOnloadstart);
|
||||||
event_handler!(progress, GetOnprogress, SetOnprogress);
|
event_handler!(progress, GetOnprogress, SetOnprogress);
|
||||||
event_handler!(abort, GetOnabort, SetOnabort);
|
event_handler!(abort, GetOnabort, SetOnabort);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue