aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/canvas_state.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2020-02-13 12:03:42 -0500
committerGitHub <noreply@github.com>2020-02-13 12:03:42 -0500
commit2c70db5f5b3f418807bc13d503ffb9d1d7fe425b (patch)
tree2799eb43f3819c1175f0dbbb725a7feeb494fffc /components/script/canvas_state.rs
parente3a2301efe911dfa232803a293f62c16ffdd3925 (diff)
parent588c09b5807bd9534aa63cbb11cff5c0227efdab (diff)
downloadservo-2c70db5f5b3f418807bc13d503ffb9d1d7fe425b.tar.gz
servo-2c70db5f5b3f418807bc13d503ffb9d1d7fe425b.zip
Auto merge of #25734 - pylbrecht:get.transform, r=jdm
Implement CanvasRenderingContext2D.getTransform() <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #25331 <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/canvas_state.rs')
-rw-r--r--components/script/canvas_state.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/canvas_state.rs b/components/script/canvas_state.rs
index d596ff826fa..41c92fc0799 100644
--- a/components/script/canvas_state.rs
+++ b/components/script/canvas_state.rs
@@ -16,6 +16,7 @@ use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::DOMString;
use crate::dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
use crate::dom::canvaspattern::CanvasPattern;
+use crate::dom::dommatrix::DOMMatrix;
use crate::dom::element::cors_setting_for_element;
use crate::dom::element::Element;
use crate::dom::globalscope::GlobalScope;
@@ -1415,6 +1416,15 @@ impl CanvasState {
self.update_transform()
}
+ // https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
+ pub fn get_transform(&self, global: &GlobalScope) -> DomRoot<DOMMatrix> {
+ let (sender, receiver) = ipc::channel::<Transform2D<f32>>().unwrap();
+ self.send_canvas_2d_msg(Canvas2dMsg::GetTransform(sender));
+ let transform = receiver.recv().unwrap();
+
+ DOMMatrix::new(global, true, transform.cast::<f64>().to_3d())
+ }
+
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
pub fn set_transform(&self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) {
if !(a.is_finite() &&