Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicts resolved in conflicting files. OffscreenCanvas ready to be merged. #19067

Closed
wants to merge 11 commits into from

Sanitized code to add link and missing functions in offscreeen

  • Loading branch information
gauraangkhurana committed Nov 22, 2017
commit 8c1f2bdc11788a8f8243987b64e2e55228a52303
@@ -15,7 +15,8 @@ use dom::element::{Element, RawLayoutElementHelpers};
use dom::globalscope::GlobalScope;
use dom::htmlelement::HTMLElement;
use dom::node::{Node, window_from_node};
use dom::offscreencanvasrenderingcontext2d::{OffscreenCanvasRenderingContext2D, LayoutOffscreenCanvasRenderingContext2DHelpers};
use dom::offscreencanvasrenderingcontext2d::{OffscreenCanvasRenderingContext2D,
LayoutOffscreenCanvasRenderingContext2DHelpers};
use dom::webglrenderingcontext::{LayoutCanvasWebGLRenderingContextHelpers, WebGLRenderingContext};
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
@@ -15,7 +15,8 @@ use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLin
use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineJoin;
use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods;
use dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding;
use dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding::OffscreenCanvasRenderingContext2DMethods;
use dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding::
OffscreenCanvasRenderingContext2DMethods;
use dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::num::Finite;
@@ -457,6 +458,12 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
self.draw_image(image, 0f64, 0f64, None, None, dx, dy, None, None)
}

/// Reassign the focus context to the element that last requested focus during this
/// transaction, or none if no elements requested it.
fn Commit(&self) {

}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
fn DrawImage_(&self,
image: CanvasImageSource,
@@ -719,30 +726,32 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
// https://html.spec.whatwg.org/multipage/#dom-context-2d-lineto
fn LineTo(&self, x: f64, y: f64) {
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-quadraticcurveto
fn QuadraticCurveTo(&self, cpx: f64, cpy: f64, x: f64, y: f64) {
}
// 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) {
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-arc
fn Arc(&self, x: f64, y: f64, r: f64, start: f64, end: f64, ccw: bool) -> ErrorResult {
if !([x, y, r, start, end].iter().all(|x| x.is_finite())) {
return Ok(());
}
if !([x, y, r, start, end].iter().all(|x| x.is_finite())) {
return Ok(());
}

if r < 0.0 {
return Err(Error::IndexSize);
}
if r < 0.0 {
return Err(Error::IndexSize);
}

let msg = CanvasMsg::Canvas2d(Canvas2dMsg::Arc(Point2D::new(x as f32, y as f32),
r as f32,
start as f32,
end as f32,
ccw));
let msg = CanvasMsg::Canvas2d(Canvas2dMsg::Arc(Point2D::new(x as f32, y as f32),
r as f32,
start as f32,
end as f32,
ccw));

self.ipc_renderer.send(msg).unwrap();
Ok(())
self.ipc_renderer.send(msg).unwrap();
Ok(())
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-arcto
@@ -877,6 +886,8 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor
fn SetShadowColor(&self, value: DOMString) {
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-save
fn Save(&self) {
}

@@ -909,6 +920,24 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
fn ResetTransform(&self) {
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha
fn GlobalAlpha(&self) -> f64 {
let state = self.state.borrow();
state.global_alpha
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha
fn SetGlobalAlpha(&self, alpha: f64) {
if !alpha.is_finite() || alpha > 1.0 || alpha < 0.0 {
return;
}

self.state.borrow_mut().global_alpha = alpha;
self.ipc_renderer
.send(CanvasMsg::Canvas2d(Canvas2dMsg::SetGlobalAlpha(alpha as f32)))
.unwrap()
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
fn SetFillStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
}
@@ -2,7 +2,7 @@
* 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/canvas.html#the-offscreencanvas-interface
// https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface
//[Pref="dom.offscreen_canvas.enabled"]

typedef (OffscreenCanvasRenderingContext2D or
@@ -15,7 +15,8 @@ dictionary ImageEncodeOptions {

//enum OffscreenRenderingContextType { "2d", "webgl" };

[Pref="dom.offscreen_canvas.enabled", Constructor([EnforceRange] unsigned long long width, [EnforceRange] unsigned long long height), Exposed=(Window,Worker)]
[Pref="dom.offscreen_canvas.enabled", Constructor([EnforceRange] unsigned long long width,
[EnforceRange] unsigned long long height), Exposed=(Window,Worker)]
interface OffscreenCanvas : EventTarget {
attribute unsigned long long width;
attribute unsigned long long height;
@@ -2,7 +2,7 @@
* 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/canvas.html#the-offscreen-2d-rendering-context
// https://html.spec.whatwg.org/multipage/#the-offscreen-2d-rendering-context
//[Exposed=(Window,Worker)]
[Pref="dom.offscreen_canvas.enabled"]
interface OffscreenCanvasRenderingContext2D {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.