mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #8728 - dzbarsky:reset_bitmpa, r=dzbarsky
Reset canvas state when changing bitmap dimensions Ran http://mxr.mozilla.org/servo/source/tests/wpt/web-platform-tests/html/semantics/embedded-content/the-canvas-element/initial.reset.2dstate.html?force=1#88 to confirm that this code is being executed, but the test still fails because the font isn't implemented and the expando doesn't get reset. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8728) <!-- Reviewable:end -->
This commit is contained in:
commit
2bb34feb3e
4 changed files with 103 additions and 2 deletions
|
@ -143,12 +143,20 @@ impl CanvasRenderingContext2D {
|
|||
CanvasRenderingContext2DBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn recreate(&self, size: Size2D<i32>) {
|
||||
// https://html.spec.whatwg.org/multipage/#concept-canvas-set-bitmap-dimensions
|
||||
pub fn set_bitmap_dimensions(&self, size: Size2D<i32>) {
|
||||
self.reset_to_initial_state();
|
||||
self.ipc_renderer
|
||||
.send(CanvasMsg::Common(CanvasCommonMsg::Recreate(size)))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#reset-the-rendering-context-to-its-default-state
|
||||
fn reset_to_initial_state(&self) {
|
||||
self.saved_states.borrow_mut().clear();
|
||||
*self.state.borrow_mut() = CanvasContextState::new();
|
||||
}
|
||||
|
||||
pub fn ipc_renderer(&self) -> IpcSender<CanvasMsg> {
|
||||
self.ipc_renderer.clone()
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ impl HTMLCanvasElement {
|
|||
let size = self.get_size();
|
||||
if let Some(ref context) = *self.context.borrow() {
|
||||
match *context {
|
||||
CanvasContext::Context2d(ref context) => context.recreate(size),
|
||||
CanvasContext::Context2d(ref context) => context.set_bitmap_dimensions(size),
|
||||
CanvasContext::WebGL(ref context) => context.recreate(size),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue