mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
Auto merge of #8170 - Ms2ger:cleanup-canvas, r=frewsxcv
Cleanup some code in htmlcanvaselement.rs. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8170) <!-- Reviewable:end -->
This commit is contained in:
commit
ac8097b5d2
1 changed files with 8 additions and 13 deletions
|
@ -78,8 +78,8 @@ impl HTMLCanvasElement {
|
||||||
let size = self.get_size();
|
let size = self.get_size();
|
||||||
if let Some(ref context) = *self.context.borrow() {
|
if let Some(ref context) = *self.context.borrow() {
|
||||||
match *context {
|
match *context {
|
||||||
CanvasContext::Context2d(ref context) => context.root().r().recreate(size),
|
CanvasContext::Context2d(ref context) => context.recreate(size),
|
||||||
CanvasContext::WebGL(ref context) => context.root().r().recreate(size),
|
CanvasContext::WebGL(ref context) => context.recreate(size),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,8 +139,8 @@ impl HTMLCanvasElement {
|
||||||
pub fn ipc_renderer(&self) -> Option<IpcSender<CanvasMsg>> {
|
pub fn ipc_renderer(&self) -> Option<IpcSender<CanvasMsg>> {
|
||||||
self.context.borrow().as_ref().map(|context| {
|
self.context.borrow().as_ref().map(|context| {
|
||||||
match *context {
|
match *context {
|
||||||
CanvasContext::Context2d(ref context) => context.root().r().ipc_renderer(),
|
CanvasContext::Context2d(ref context) => context.ipc_renderer(),
|
||||||
CanvasContext::WebGL(ref context) => context.root().r().ipc_renderer(),
|
CanvasContext::WebGL(ref context) => context.ipc_renderer(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -182,11 +182,8 @@ impl HTMLCanvasElement {
|
||||||
*self.context.borrow_mut() = maybe_ctx.map( |ctx| CanvasContext::WebGL(JS::from_rooted(&ctx)));
|
*self.context.borrow_mut() = maybe_ctx.map( |ctx| CanvasContext::WebGL(JS::from_rooted(&ctx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref context) = *self.context.borrow() {
|
if let Some(CanvasContext::WebGL(ref context)) = *self.context.borrow() {
|
||||||
match *context {
|
Some(context.root())
|
||||||
CanvasContext::WebGL(ref context) => Some(context.root()),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -247,13 +244,11 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement {
|
||||||
match &*id {
|
match &*id {
|
||||||
"2d" => {
|
"2d" => {
|
||||||
self.get_or_init_2d_context()
|
self.get_or_init_2d_context()
|
||||||
.map(|ctx| CanvasRenderingContext2DOrWebGLRenderingContext::eCanvasRenderingContext2D(
|
.map(CanvasRenderingContext2DOrWebGLRenderingContext::eCanvasRenderingContext2D)
|
||||||
ctx))
|
|
||||||
}
|
}
|
||||||
"webgl" | "experimental-webgl" => {
|
"webgl" | "experimental-webgl" => {
|
||||||
self.get_or_init_webgl_context(cx, attributes.get(0).map(|p| *p))
|
self.get_or_init_webgl_context(cx, attributes.get(0).map(|p| *p))
|
||||||
.map(|ctx| CanvasRenderingContext2DOrWebGLRenderingContext::eWebGLRenderingContext(
|
.map(CanvasRenderingContext2DOrWebGLRenderingContext::eWebGLRenderingContext)
|
||||||
ctx))
|
|
||||||
}
|
}
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue