Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7400219
commit f564b24
Showing
1,437 changed files
with
6,113 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use crate::dom::bindings::cell::DomRefCell; | ||
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasBinding::{ | ||
OffscreenCanvasMethods, OffscreenRenderingContext, Wrap as OffscreenCanvasWrap, | ||
}; | ||
use crate::dom::bindings::error::Fallible; | ||
use crate::dom::bindings::reflector::reflect_dom_object; | ||
use crate::dom::bindings::reflector::DomObject; | ||
use crate::dom::bindings::root::{Dom, DomRoot}; | ||
use crate::dom::bindings::str::DOMString; | ||
use crate::dom::eventtarget::EventTarget; | ||
use crate::dom::globalscope::GlobalScope; | ||
use crate::dom::htmlcanvaselement::HTMLCanvasElement; | ||
use crate::dom::offscreencanvasrenderingcontext2d::OffscreenCanvasRenderingContext2D; | ||
use dom_struct::dom_struct; | ||
use euclid::Size2D; | ||
use js::jsapi::JSContext; | ||
use js::rust::HandleValue; | ||
use ref_filter_map; | ||
use std::cell::Cell; | ||
use std::cell::Ref; | ||
|
||
#[must_root] | ||
#[derive(Clone, JSTraceable, MallocSizeOf)] | ||
pub enum OffscreenCanvasContext { | ||
OffscreenContext2d(Dom<OffscreenCanvasRenderingContext2D>), | ||
//WebGL(Dom<WebGLRenderingContext>), | ||
//WebGL2(Dom<WebGL2RenderingContext>), | ||
} | ||
|
||
#[dom_struct] | ||
pub struct OffscreenCanvas { | ||
eventtarget: EventTarget, | ||
height: Cell<u64>, | ||
width: Cell<u64>, | ||
context: DomRefCell<Option<OffscreenCanvasContext>>, | ||
placeholder: Option<Dom<HTMLCanvasElement>>, | ||
} | ||
|
||
impl OffscreenCanvas { | ||
pub fn new_inherited( | ||
height: u64, | ||
width: u64, | ||
placeholder: Option<&HTMLCanvasElement>, | ||
) -> OffscreenCanvas { | ||
OffscreenCanvas { | ||
eventtarget: EventTarget::new_inherited(), | ||
height: Cell::new(height), | ||
width: Cell::new(width), | ||
context: DomRefCell::new(None), | ||
placeholder: placeholder.map(Dom::from_ref), | ||
} | ||
} | ||
|
||
pub fn new( | ||
global: &GlobalScope, | ||
height: u64, | ||
width: u64, | ||
placeholder: Option<&HTMLCanvasElement>, | ||
) -> DomRoot<OffscreenCanvas> { | ||
reflect_dom_object( | ||
Box::new(OffscreenCanvas::new_inherited(height, width, placeholder)), | ||
global, | ||
OffscreenCanvasWrap, | ||
) | ||
} | ||
|
||
pub fn Constructor( | ||
global: &GlobalScope, | ||
height: u64, | ||
width: u64, | ||
) -> Fallible<DomRoot<OffscreenCanvas>> { | ||
let offscreencanvas = OffscreenCanvas::new(global, height, width, None); | ||
Ok(offscreencanvas) | ||
} | ||
|
||
pub fn get_size(&self) -> Size2D<u64> { | ||
Size2D::new(self.Width(), self.Height()) | ||
} | ||
|
||
pub fn context(&self) -> Option<Ref<OffscreenCanvasContext>> { | ||
ref_filter_map::ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref()) | ||
} | ||
|
||
#[allow(unsafe_code)] | ||
fn get_or_init_2d_context(&self) -> Option<DomRoot<OffscreenCanvasRenderingContext2D>> { | ||
if let Some(ctx) = self.context() { | ||
return match *ctx { | ||
OffscreenCanvasContext::OffscreenContext2d(ref ctx) => Some(DomRoot::from_ref(ctx)), | ||
}; | ||
} | ||
let size = self.get_size(); | ||
let context = OffscreenCanvasRenderingContext2D::new(&self.global(), self, size); | ||
*self.context.borrow_mut() = Some(OffscreenCanvasContext::OffscreenContext2d( | ||
Dom::from_ref(&*context), | ||
)); | ||
Some(context) | ||
} | ||
} | ||
|
||
impl OffscreenCanvasMethods for OffscreenCanvas { | ||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-getcontext | ||
#[allow(unsafe_code)] | ||
unsafe fn GetContext( | ||
&self, | ||
_cx: *mut JSContext, | ||
id: DOMString, | ||
_options: HandleValue, | ||
) -> Option<OffscreenRenderingContext> { | ||
match &*id { | ||
"2d" => self | ||
.get_or_init_2d_context() | ||
.map(OffscreenRenderingContext::OffscreenCanvasRenderingContext2D), | ||
/*"webgl" | "experimental-webgl" => self | ||
.get_or_init_webgl_context(cx, options) | ||
.map(OffscreenRenderingContext::WebGLRenderingContext), | ||
"webgl2" | "experimental-webgl2" => self | ||
.get_or_init_webgl2_context(cx, options) | ||
.map(OffscreenRenderingContext::WebGL2RenderingContext),*/ | ||
_ => None, | ||
} | ||
} | ||
|
||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width | ||
fn Width(&self) -> u64 { | ||
return self.width.get(); | ||
} | ||
|
||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width | ||
fn SetWidth(&self, value: u64) { | ||
self.width.set(value); | ||
} | ||
|
||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height | ||
fn Height(&self) -> u64 { | ||
return self.height.get(); | ||
} | ||
|
||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height | ||
fn SetHeight(&self, value: u64) { | ||
self.height.set(value); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
components/script/dom/offscreencanvasrenderingcontext2d.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding; | ||
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding::OffscreenCanvasRenderingContext2DMethods; | ||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; | ||
use crate::dom::bindings::root::{Dom, DomRoot}; | ||
use crate::dom::globalscope::GlobalScope; | ||
use crate::dom::offscreencanvas::OffscreenCanvas; | ||
use dom_struct::dom_struct; | ||
use euclid::Size2D; | ||
|
||
#[dom_struct] | ||
pub struct OffscreenCanvasRenderingContext2D { | ||
reflector_: Reflector, | ||
canvas: Option<Dom<OffscreenCanvas>>, | ||
} | ||
|
||
impl OffscreenCanvasRenderingContext2D { | ||
pub fn new_inherited( | ||
_global: &GlobalScope, | ||
canvas: Option<&OffscreenCanvas>, | ||
_size: Size2D<u64>, | ||
) -> OffscreenCanvasRenderingContext2D { | ||
OffscreenCanvasRenderingContext2D { | ||
reflector_: Reflector::new(), | ||
canvas: canvas.map(Dom::from_ref), | ||
} | ||
} | ||
|
||
pub fn new( | ||
_global: &GlobalScope, | ||
canvas: &OffscreenCanvas, | ||
_size: Size2D<u64>, | ||
) -> DomRoot<OffscreenCanvasRenderingContext2D> { | ||
let boxed = Box::new(OffscreenCanvasRenderingContext2D::new_inherited( | ||
_global, | ||
Some(canvas), | ||
_size, | ||
)); | ||
reflect_dom_object( | ||
boxed, | ||
_global, | ||
OffscreenCanvasRenderingContext2DBinding::Wrap, | ||
) | ||
} | ||
} | ||
|
||
impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContext2D { | ||
// https://html.spec.whatwg.org/multipage/offscreencontext2d-canvas | ||
fn Canvas(&self) -> DomRoot<OffscreenCanvas> { | ||
DomRoot::from_ref(self.canvas.as_ref().expect("No canvas.")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
// https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface | ||
typedef (OffscreenCanvasRenderingContext2D or WebGLRenderingContext or WebGL2RenderingContext) | ||
OffscreenRenderingContext; | ||
|
||
dictionary ImageEncodeOptions { | ||
DOMString type = "image/png"; | ||
unrestricted double quality = 1.0; | ||
}; | ||
|
||
//enum OffscreenRenderingContextId { "2d", "webgl", "webgl2" }; | ||
|
||
[Constructor([EnforceRange] unsigned long long width, [EnforceRange] unsigned long long height), | ||
Exposed=(Window,Worker)/*, Transferable*/, Pref="dom.offscreen_canvas.enabled"] | ||
interface OffscreenCanvas : EventTarget { | ||
attribute /*[EnforceRange]*/ unsigned long long width; | ||
attribute /*[EnforceRange]*/ unsigned long long height; | ||
|
||
OffscreenRenderingContext? getContext(DOMString contextId, optional any options = null); | ||
//ImageBitmap transferToImageBitmap(); | ||
//Promise<Blob> convertToBlob(optional ImageEncodeOptions options); | ||
}; |
26 changes: 26 additions & 0 deletions
26
components/script/dom/webidls/OffscreenCanvasRenderingContext2D.webidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
// https://html.spec.whatwg.org/multipage/#the-offscreen-2d-rendering-context | ||
[Exposed=(Window,Worker), Pref="dom.offscreen_canvas.enabled"] | ||
interface OffscreenCanvasRenderingContext2D { | ||
//void commit(); | ||
readonly attribute OffscreenCanvas canvas; | ||
}; | ||
|
||
//OffscreenCanvasRenderingContext2D includes CanvasState; | ||
//OffscreenCanvasRenderingContext2D includes CanvasTransform; | ||
//OffscreenCanvasRenderingContext2D includes CanvasCompositing; | ||
//OffscreenCanvasRenderingContext2D includes CanvasImageSmoothing; | ||
//OffscreenCanvasRenderingContext2D includes CanvasFillStrokeStyles; | ||
//OffscreenCanvasRenderingContext2D includes CanvasShadowStyles; | ||
//OffscreenCanvasRenderingContext2D includes CanvasFilters; | ||
//OffscreenCanvasRenderingContext2D includes CanvasRect; | ||
//OffscreenCanvasRenderingContext2D includes CanvasDrawPath; | ||
//OffscreenCanvasRenderingContext2D includes CanvasText; | ||
//OffscreenCanvasRenderingContext2D includes CanvasDrawImage; | ||
//OffscreenCanvasRenderingContext2D includes CanvasImageData; | ||
//OffscreenCanvasRenderingContext2D includes CanvasPathDrawingStyles; | ||
//OffscreenCanvasRenderingContext2D includes CanvasTextDrawingStyles; | ||
//OffscreenCanvasRenderingContext2D includes CanvasPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
tests/wpt/metadata/css/CSS2/floats/floats-in-table-caption-001.html.ini
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
tests/wpt/metadata/css/CSS2/positioning/abspos-float-with-inline-container.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[abspos-float-with-inline-container.html] | ||
expected: FAIL | ||
expected: TIMEOUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[white-space-002.xht] | ||
expected: FAIL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[line-height-204.html] | ||
expected: FAIL |
2 changes: 2 additions & 0 deletions
2
tests/wpt/metadata/css/compositing/mix-blend-mode/mix-blend-mode-paragraph.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[mix-blend-mode-paragraph.html] | ||
expected: FAIL |
2 changes: 2 additions & 0 deletions
2
...pt/metadata/css/css-backgrounds/background-repeat/background-repeat-round-roundup.xht.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[background-repeat-round-roundup.xht] | ||
expected: FAIL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
tests/wpt/metadata/css/css-text/line-break/line-break-normal-018.xht.ini
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
tests/wpt/metadata/css/css-text/line-break/line-break-strict-018.xht.ini
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
tests/wpt/metadata/css/css-text/text-transform/text-transform-full-size-kana-001.html.ini
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
tests/wpt/metadata/css/css-text/text-transform/text-transform-full-size-kana-002.html.ini
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
tests/wpt/metadata/css/css-text/text-transform/text-transform-full-size-kana-003.html.ini
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
tests/wpt/metadata/css/css-text/text-transform/text-transform-full-size-kana-004.html.ini
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
tests/wpt/metadata/css/css-text/white-space/trailing-ideographic-space-004.html.ini
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
tests/wpt/metadata/css/css-text/word-break/word-break-keep-all-006.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[word-break-keep-all-006.html] | ||
expected: FAIL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,6 @@ | |
[opacity end] | ||
expected: FAIL | ||
|
||
[border-top-width end] | ||
expected: FAIL | ||
|
2 changes: 1 addition & 1 deletion
2
tests/wpt/metadata/custom-elements/parser/parser-sets-attributes-and-children.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[parser-sets-attributes-and-children.html] | ||
expected: TIMEOUT | ||
expected: CRASH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.