Bump euclid to 0.14.

This commit is contained in:
Nicolas Silva 2017-06-02 14:50:26 +02:00
parent 5dce166266
commit 8617320500
88 changed files with 349 additions and 381 deletions

View file

@ -41,7 +41,7 @@ devtools_traits = {path = "../devtools_traits"}
dom_struct = {path = "../dom_struct"}
domobject_derive = {path = "../domobject_derive"}
encoding = "0.2"
euclid = "0.13"
euclid = "0.14.4"
fnv = "1.0"
gleam = "0.4"
gfx_traits = {path = "../gfx_traits"}
@ -63,7 +63,7 @@ mime_guess = "1.8.0"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
num-traits = "0.1.32"
offscreen_gl_context = "0.8"
offscreen_gl_context = { version = "0.9", features = ["serde"] }
open = "1.1.1"
parking_lot = "0.3"
phf = "0.7.18"

View file

@ -43,10 +43,8 @@ use dom::bindings::str::{DOMString, USVString};
use dom::bindings::utils::WindowProxyHandler;
use dom::document::PendingRestyle;
use encoding::types::EncodingRef;
use euclid::{Matrix2D, Matrix4D, Point2D};
use euclid::length::Length as EuclidLength;
use euclid::rect::Rect;
use euclid::size::Size2D;
use euclid::{Transform2D, Transform3D, Point2D, Vector2D, Rect, Size2D};
use euclid::Length as EuclidLength;
use html5ever::{Prefix, LocalName, Namespace, QualName};
use html5ever::buffer_queue::BufferQueue;
use html5ever::tendril::IncompleteUtf8;
@ -457,14 +455,14 @@ unsafe impl<T: Send> JSTraceable for Sender<T> {
}
}
unsafe impl JSTraceable for Matrix2D<f32> {
unsafe impl JSTraceable for Transform2D<f32> {
#[inline]
unsafe fn trace(&self, _trc: *mut JSTracer) {
// Do nothing
}
}
unsafe impl JSTraceable for Matrix4D<f64> {
unsafe impl JSTraceable for Transform3D<f64> {
#[inline]
unsafe fn trace(&self, _trc: *mut JSTracer) {
// Do nothing
@ -478,6 +476,13 @@ unsafe impl JSTraceable for Point2D<f32> {
}
}
unsafe impl JSTraceable for Vector2D<f32> {
#[inline]
unsafe fn trace(&self, _trc: *mut JSTracer) {
// Do nothing
}
}
unsafe impl<T> JSTraceable for EuclidLength<u64, T> {
#[inline]
unsafe fn trace(&self, _trc: *mut JSTracer) {

View file

@ -9,7 +9,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::canvasgradient::ToFillOrStrokeStyle;
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use euclid::size::Size2D;
use euclid::Size2D;
// https://html.spec.whatwg.org/multipage/#canvaspattern
#[dom_struct]

View file

@ -34,10 +34,7 @@ use dom::htmlimageelement::HTMLImageElement;
use dom::imagedata::ImageData;
use dom::node::{document_from_node, Node, NodeDamage, window_from_node};
use dom_struct::dom_struct;
use euclid::matrix2d::Matrix2D;
use euclid::point::Point2D;
use euclid::rect::Rect;
use euclid::size::Size2D;
use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D, vec2};
use ipc_channel::ipc::{self, IpcSender};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::ImageResponse;
@ -82,7 +79,7 @@ struct CanvasContextState {
line_cap: LineCapStyle,
line_join: LineJoinStyle,
miter_limit: f64,
transform: Matrix2D<f32>,
transform: Transform2D<f32>,
shadow_offset_x: f64,
shadow_offset_y: f64,
shadow_blur: f64,
@ -102,7 +99,7 @@ impl CanvasContextState {
line_cap: LineCapStyle::Butt,
line_join: LineJoinStyle::Miter,
miter_limit: 10.0,
transform: Matrix2D::identity(),
transform: Transform2D::identity(),
shadow_offset_x: 0.0,
shadow_offset_y: 0.0,
shadow_blur: 0.0,
@ -559,7 +556,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
}
let transform = self.state.borrow().transform;
self.state.borrow_mut().transform = transform.pre_scaled(x as f32, y as f32);
self.state.borrow_mut().transform = transform.pre_scale(x as f32, y as f32);
self.update_transform()
}
@ -572,7 +569,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
let (sin, cos) = (angle.sin(), angle.cos());
let transform = self.state.borrow().transform;
self.state.borrow_mut().transform = transform.pre_mul(
&Matrix2D::row_major(cos as f32, sin as f32,
&Transform2D::row_major(cos as f32, sin as f32,
-sin as f32, cos as f32,
0.0, 0.0));
self.update_transform()
@ -585,7 +582,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
}
let transform = self.state.borrow().transform;
self.state.borrow_mut().transform = transform.pre_translated(x as f32, y as f32);
self.state.borrow_mut().transform = transform.pre_translate(vec2(x as f32, y as f32));
self.update_transform()
}
@ -598,7 +595,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
let transform = self.state.borrow().transform;
self.state.borrow_mut().transform = transform.pre_mul(
&Matrix2D::row_major(a as f32, b as f32, c as f32, d as f32, e as f32, f as f32));
&Transform2D::row_major(a as f32, b as f32, c as f32, d as f32, e as f32, f as f32));
self.update_transform()
}
@ -610,13 +607,13 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
}
self.state.borrow_mut().transform =
Matrix2D::row_major(a as f32, b as f32, c as f32, d as f32, e as f32, f as f32);
Transform2D::row_major(a as f32, b as f32, c as f32, d as f32, e as f32, f as f32);
self.update_transform()
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-resettransform
fn ResetTransform(&self) {
self.state.borrow_mut().transform = Matrix2D::identity();
self.state.borrow_mut().transform = Transform2D::identity();
self.update_transform()
}
@ -1079,7 +1076,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
dirty_width: Finite<f64>,
dirty_height: Finite<f64>) {
let data = imagedata.get_data_array();
let offset = Point2D::new(*dx, *dy);
let offset = Vector2D::new(*dx, *dy);
let image_data_size = Size2D::new(imagedata.Width() as f64, imagedata.Height() as f64);
let dirty_rect = Rect::new(Point2D::new(*dirty_x, *dirty_y),

View file

@ -92,7 +92,7 @@ use dom::windowproxy::WindowProxy;
use dom_struct::dom_struct;
use encoding::EncodingRef;
use encoding::all::UTF_8;
use euclid::point::Point2D;
use euclid::{Point2D, Vector2D};
use html5ever::{LocalName, QualName};
use hyper::header::{Header, SetCookie};
use hyper_serde::Serde;
@ -865,7 +865,7 @@ impl Document {
if let Some(iframe) = el.downcast::<HTMLIFrameElement>() {
if let Some(pipeline_id) = iframe.pipeline_id() {
let rect = iframe.upcast::<Element>().GetBoundingClientRect();
let child_origin = Point2D::new(rect.X() as f32, rect.Y() as f32);
let child_origin = Vector2D::new(rect.X() as f32, rect.Y() as f32);
let child_point = client_point - child_origin;
let event = CompositorEvent::MouseButtonEvent(mouse_event_type, button, child_point);
@ -1020,7 +1020,7 @@ impl Document {
if let Some(iframe) = el.downcast::<HTMLIFrameElement>() {
if let Some(pipeline_id) = iframe.pipeline_id() {
let rect = iframe.upcast::<Element>().GetBoundingClientRect();
let child_origin = Point2D::new(rect.X() as f32, rect.Y() as f32);
let child_origin = Vector2D::new(rect.X() as f32, rect.Y() as f32);
let child_point = client_point - child_origin;
let event = CompositorEvent::TouchpadPressureEvent(child_point,
@ -1124,7 +1124,7 @@ impl Document {
if let Some(iframe) = new_target.downcast::<HTMLIFrameElement>() {
if let Some(pipeline_id) = iframe.pipeline_id() {
let rect = iframe.upcast::<Element>().GetBoundingClientRect();
let child_origin = Point2D::new(rect.X() as f32, rect.Y() as f32);
let child_origin = Vector2D::new(rect.X() as f32, rect.Y() as f32);
let child_point = client_point - child_origin;
let event = CompositorEvent::MouseMoveEvent(Some(child_point));
@ -1231,7 +1231,7 @@ impl Document {
if let Some(iframe) = el.downcast::<HTMLIFrameElement>() {
if let Some(pipeline_id) = iframe.pipeline_id() {
let rect = iframe.upcast::<Element>().GetBoundingClientRect();
let child_origin = Point2D::new(rect.X() as f32, rect.Y() as f32);
let child_origin = Vector2D::new(rect.X() as f32, rect.Y() as f32);
let child_point = point - child_origin;
let event = CompositorEvent::TouchEvent(event_type, touch_id, child_point);

View file

@ -11,7 +11,7 @@ use dom::bindings::reflector::reflect_dom_object;
use dom::dommatrixreadonly::{dommatrixinit_to_matrix, DOMMatrixReadOnly, entries_to_matrix};
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use euclid::Matrix4D;
use euclid::Transform3D;
#[dom_struct]
@ -21,12 +21,12 @@ pub struct DOMMatrix {
impl DOMMatrix {
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope, is2D: bool, matrix: Matrix4D<f64>) -> Root<Self> {
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> Root<Self> {
let dommatrix = Self::new_inherited(is2D, matrix);
reflect_dom_object(box dommatrix, global, Wrap)
}
pub fn new_inherited(is2D: bool, matrix: Matrix4D<f64>) -> Self {
pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self {
DOMMatrix {
parent: DOMMatrixReadOnly::new_inherited(is2D, matrix)
}

View file

@ -14,25 +14,25 @@ use dom::dommatrix::DOMMatrix;
use dom::dompoint::DOMPoint;
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use euclid::{Matrix4D, Point4D, Radians};
use euclid::{Transform3D, Radians};
use std::cell::{Cell, Ref};
use std::f64;
#[dom_struct]
pub struct DOMMatrixReadOnly {
reflector_: Reflector,
matrix: DOMRefCell<Matrix4D<f64>>,
matrix: DOMRefCell<Transform3D<f64>>,
is2D: Cell<bool>,
}
impl DOMMatrixReadOnly {
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope, is2D: bool, matrix: Matrix4D<f64>) -> Root<Self> {
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> Root<Self> {
let dommatrix = Self::new_inherited(is2D, matrix);
reflect_dom_object(box dommatrix, global, Wrap)
}
pub fn new_inherited(is2D: bool, matrix: Matrix4D<f64>) -> Self {
pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self {
DOMMatrixReadOnly {
reflector_: Reflector::new(),
matrix: DOMRefCell::new(matrix),
@ -42,7 +42,7 @@ impl DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Self>> {
Ok(Self::new(global, true, Matrix4D::identity()))
Ok(Self::new(global, true, Transform3D::identity()))
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
@ -61,7 +61,7 @@ impl DOMMatrixReadOnly {
})
}
pub fn matrix(&self) -> Ref<Matrix4D<f64>> {
pub fn matrix(&self) -> Ref<Transform3D<f64>> {
self.matrix.borrow()
}
@ -183,7 +183,7 @@ impl DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself
pub fn translate_self(&self, tx: f64, ty: f64, tz: f64) {
// Step 1.
let translation = Matrix4D::create_translation(tx, ty, tz);
let translation = Transform3D::create_translation(tx, ty, tz);
let mut matrix = self.matrix.borrow_mut();
*matrix = translation.post_mul(&matrix);
// Step 2.
@ -202,7 +202,7 @@ impl DOMMatrixReadOnly {
let scaleY = scaleY.unwrap_or(scaleX);
// Step 3.
{
let scale3D = Matrix4D::create_scale(scaleX, scaleY, scaleZ);
let scale3D = Transform3D::create_scale(scaleX, scaleY, scaleZ);
let mut matrix = self.matrix.borrow_mut();
*matrix = scale3D.post_mul(&matrix);
}
@ -225,7 +225,7 @@ impl DOMMatrixReadOnly {
self.translate_self(originX, originY, originZ);
// Step 2.
{
let scale3D = Matrix4D::create_scale(scale, scale, scale);
let scale3D = Transform3D::create_scale(scale, scale, scale);
let mut matrix = self.matrix.borrow_mut();
*matrix = scale3D.post_mul(&matrix);
}
@ -256,19 +256,19 @@ impl DOMMatrixReadOnly {
}
if rotZ != 0.0 {
// Step 5.
let rotation = Matrix4D::create_rotation(0.0, 0.0, 1.0, Radians::new(rotZ.to_radians()));
let rotation = Transform3D::create_rotation(0.0, 0.0, 1.0, Radians::new(rotZ.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
}
if rotY != 0.0 {
// Step 6.
let rotation = Matrix4D::create_rotation(0.0, 1.0, 0.0, Radians::new(rotY.to_radians()));
let rotation = Transform3D::create_rotation(0.0, 1.0, 0.0, Radians::new(rotY.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
}
if rotX != 0.0 {
// Step 7.
let rotation = Matrix4D::create_rotation(1.0, 0.0, 0.0, Radians::new(rotX.to_radians()));
let rotation = Transform3D::create_rotation(1.0, 0.0, 0.0, Radians::new(rotX.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
}
@ -281,7 +281,7 @@ impl DOMMatrixReadOnly {
if y != 0.0 || x < 0.0 {
// Step 1.
let rotZ = Radians::new(f64::atan2(y, x));
let rotation = Matrix4D::create_rotation(0.0, 0.0, 1.0, rotZ);
let rotation = Transform3D::create_rotation(0.0, 0.0, 1.0, rotZ);
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
}
@ -292,7 +292,7 @@ impl DOMMatrixReadOnly {
pub fn rotate_axis_angle_self(&self, x: f64, y: f64, z: f64, angle: f64) {
// Step 1.
let (norm_x, norm_y, norm_z) = normalize_point(x, y, z);
let rotation = Matrix4D::create_rotation(norm_x, norm_y, norm_z, Radians::new(angle.to_radians()));
let rotation = Transform3D::create_rotation(norm_x, norm_y, norm_z, Radians::new(angle.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = rotation.post_mul(&matrix);
// Step 2.
@ -305,7 +305,7 @@ impl DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself
pub fn skew_x_self(&self, sx: f64) {
// Step 1.
let skew = Matrix4D::create_skew(Radians::new(sx.to_radians()), Radians::new(0.0));
let skew = Transform3D::create_skew(Radians::new(sx.to_radians()), Radians::new(0.0));
let mut matrix = self.matrix.borrow_mut();
*matrix = skew.post_mul(&matrix);
// Step 2 in DOMMatrix.SkewXSelf
@ -314,7 +314,7 @@ impl DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself
pub fn skew_y_self(&self, sy: f64) {
// Step 1.
let skew = Matrix4D::create_skew(Radians::new(0.0), Radians::new(sy.to_radians()));
let skew = Transform3D::create_skew(Radians::new(0.0), Radians::new(sy.to_radians()));
let mut matrix = self.matrix.borrow_mut();
*matrix = skew.post_mul(&matrix);
// Step 2 in DOMMatrix.SkewYSelf
@ -327,7 +327,7 @@ impl DOMMatrixReadOnly {
*matrix = matrix.inverse().unwrap_or_else(|| {
// Step 2.
self.is2D.set(false);
Matrix4D::row_major(f64::NAN, f64::NAN, f64::NAN, f64::NAN,
Transform3D::row_major(f64::NAN, f64::NAN, f64::NAN, f64::NAN,
f64::NAN, f64::NAN, f64::NAN, f64::NAN,
f64::NAN, f64::NAN, f64::NAN, f64::NAN,
f64::NAN, f64::NAN, f64::NAN, f64::NAN)
@ -513,7 +513,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
fn FlipX(&self) -> Root<DOMMatrix> {
let is2D = self.is2D.get();
let flip = Matrix4D::row_major(-1.0, 0.0, 0.0, 0.0,
let flip = Transform3D::row_major(-1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
@ -524,7 +524,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
fn FlipY(&self) -> Root<DOMMatrix> {
let is2D = self.is2D.get();
let flip = Matrix4D::row_major(1.0, 0.0, 0.0, 0.0,
let flip = Transform3D::row_major(1.0, 0.0, 0.0, 0.0,
0.0, -1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
@ -539,21 +539,26 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
fn TransformPoint(&self, point: &DOMPointInit) -> Root<DOMPoint> {
let matrix = self.matrix.borrow();
let result = matrix.transform_point4d(&Point4D::new(point.x, point.y, point.z, point.w));
DOMPoint::new(
&self.global(),
result.x as f64,
result.y as f64,
result.z as f64,
result.w as f64)
// Euclid always normalizes the homogeneous coordinate which is usually the right
// thing but may (?) not be compliant with the CSS matrix spec (or at least is
// probably not the behavior web authors will expect even if it is mathematically
// correct in the context of geometry computations).
// Since this is the only place where this is needed, better implement it here
// than in euclid (which does not have a notion of 4d points).
let mat = self.matrix.borrow();
let x = point.x * mat.m11 + point.y * mat.m21 + point.z * mat.m31 + point.w * mat.m41;
let y = point.x * mat.m12 + point.y * mat.m22 + point.z * mat.m32 + point.w * mat.m42;
let z = point.x * mat.m13 + point.y * mat.m23 + point.z * mat.m33 + point.w * mat.m43;
let w = point.x * mat.m14 + point.y * mat.m24 + point.z * mat.m34 + point.w * mat.m44;
DOMPoint::new(&self.global(), x, y, z, w)
}
}
// https://drafts.fxtf.org/geometry-1/#create-a-2d-matrix
fn create_2d_matrix(entries: &[f64]) -> Matrix4D<f64> {
Matrix4D::row_major(entries[0], entries[1], 0.0, 0.0,
fn create_2d_matrix(entries: &[f64]) -> Transform3D<f64> {
Transform3D::row_major(entries[0], entries[1], 0.0, 0.0,
entries[2], entries[3], 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
entries[4], entries[5], 0.0, 1.0)
@ -561,15 +566,15 @@ fn create_2d_matrix(entries: &[f64]) -> Matrix4D<f64> {
// https://drafts.fxtf.org/geometry-1/#create-a-3d-matrix
fn create_3d_matrix(entries: &[f64]) -> Matrix4D<f64> {
Matrix4D::row_major(entries[0], entries[1], entries[2], entries[3],
fn create_3d_matrix(entries: &[f64]) -> Transform3D<f64> {
Transform3D::row_major(entries[0], entries[1], entries[2], entries[3],
entries[4], entries[5], entries[6], entries[7],
entries[8], entries[9], entries[10], entries[11],
entries[12], entries[13], entries[14], entries[15])
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Matrix4D<f64>)> {
pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Transform3D<f64>)> {
if entries.len() == 6 {
Ok((true, create_2d_matrix(&entries)))
} else if entries.len() == 16 {
@ -582,7 +587,7 @@ pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Matrix4D<f64>)> {
// https://drafts.fxtf.org/geometry-1/#validate-and-fixup
pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Matrix4D<f64>)> {
pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transform3D<f64>)> {
// Step 1.
if dict.a.is_some() && dict.m11.is_some() && dict.a.unwrap() != dict.m11.unwrap() ||
dict.b.is_some() && dict.m12.is_some() && dict.b.unwrap() != dict.m12.unwrap() ||
@ -621,7 +626,7 @@ pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Matrix4D
if is2D.is_none() {
is2D = Some(true);
}
let matrix = Matrix4D::row_major(m11, m12, dict.m13, dict.m14,
let matrix = Transform3D::row_major(m11, m12, dict.m13, dict.m14,
m21, m22, dict.m23, dict.m24,
dict.m31, dict.m32, dict.m33, dict.m34,
m41, m42, dict.m43, dict.m44);

View file

@ -16,7 +16,7 @@ use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
use dom::messageevent::MessageEvent;
use dom_struct::dom_struct;
use euclid::length::Length;
use euclid::Length;
use hyper::header::{Accept, qitem};
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;

View file

@ -19,7 +19,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, document_from_node};
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use euclid::point::Point2D;
use euclid::Point2D;
use html5ever::{LocalName, Prefix};
use net_traits::ReferrerPolicy;
use std::default::Default;

View file

@ -26,7 +26,7 @@ use dom::node::{Node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use dom::webglrenderingcontext::{LayoutCanvasWebGLRenderingContextHelpers, WebGLRenderingContext};
use dom_struct::dom_struct;
use euclid::size::Size2D;
use euclid::Size2D;
use html5ever::{LocalName, Prefix};
use image::ColorType;
use image::png::PNGEncoder;

View file

@ -35,7 +35,7 @@ use dom::values::UNSIGNED_LONG_MAX;
use dom::virtualmethods::VirtualMethods;
use dom::window::Window;
use dom_struct::dom_struct;
use euclid::point::Point2D;
use euclid::Point2D;
use html5ever::{LocalName, Prefix};
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;

View file

@ -10,7 +10,7 @@ use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use euclid::size::Size2D;
use euclid::Size2D;
use js::jsapi::{Heap, JSContext, JSObject};
use js::rust::Runtime;
use js::typedarray::{Uint8ClampedArray, CreateWith};

View file

@ -56,9 +56,7 @@ use dom::text::Text;
use dom::virtualmethods::{VirtualMethods, vtable_for};
use dom::window::Window;
use dom_struct::dom_struct;
use euclid::point::Point2D;
use euclid::rect::Rect;
use euclid::size::Size2D;
use euclid::{Point2D, Vector2D, Rect, Size2D};
use heapsize::{HeapSizeOf, heap_size_of};
use html5ever::{Prefix, Namespace, QualName};
use js::jsapi::{JSContext, JSObject, JSRuntime};
@ -612,7 +610,7 @@ impl Node {
}
}
pub fn scroll_offset(&self) -> Point2D<f32> {
pub fn scroll_offset(&self) -> Vector2D<f32> {
let document = self.owner_doc();
let window = document.window();
window.scroll_offset_query(self)

View file

@ -40,7 +40,7 @@ use dom::webgltexture::{TexParameterValue, WebGLTexture};
use dom::webgluniformlocation::WebGLUniformLocation;
use dom::window::Window;
use dom_struct::dom_struct;
use euclid::size::Size2D;
use euclid::Size2D;
use half::f16;
use ipc_channel::ipc::{self, IpcSender};
use js::conversions::ConversionBehavior;

View file

@ -53,7 +53,7 @@ use dom::windowproxy::WindowProxy;
use dom::worklet::Worklet;
use dom::workletglobalscope::WorkletGlobalScopeType;
use dom_struct::dom_struct;
use euclid::{Point2D, Rect, Size2D};
use euclid::{Point2D, Vector2D, Rect, Size2D};
use fetch;
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
@ -255,7 +255,7 @@ pub struct Window {
error_reporter: CSSErrorReporter,
/// A list of scroll offsets for each scrollable element.
scroll_offsets: DOMRefCell<HashMap<UntrustedNodeAddress, Point2D<f32>>>,
scroll_offsets: DOMRefCell<HashMap<UntrustedNodeAddress, Vector2D<f32>>>,
/// All the MediaQueryLists we need to update
media_query_lists: WeakMediaQueryListVec,
@ -365,7 +365,7 @@ impl Window {
/// Sets a new list of scroll offsets.
///
/// This is called when layout gives us new ones and WebRender is in use.
pub fn set_scroll_offsets(&self, offsets: HashMap<UntrustedNodeAddress, Point2D<f32>>) {
pub fn set_scroll_offsets(&self, offsets: HashMap<UntrustedNodeAddress, Vector2D<f32>>) {
*self.scroll_offsets.borrow_mut() = offsets
}
@ -1155,7 +1155,7 @@ impl Window {
self.layout_chan.send(Msg::UpdateScrollStateFromScript(ScrollState {
scroll_root_id: scroll_root_id,
scroll_offset: Point2D::new(-x, -y),
scroll_offset: Vector2D::new(-x, -y),
})).unwrap();
// TODO (farodin91): Raise an event to stop the current_viewport
@ -1449,7 +1449,7 @@ impl Window {
self.layout_rpc.node_overflow().0.unwrap()
}
pub fn scroll_offset_query(&self, node: &Node) -> Point2D<f32> {
pub fn scroll_offset_query(&self, node: &Node) -> Vector2D<f32> {
let mut node = Root::from_ref(node);
loop {
if let Some(scroll_offset) = self.scroll_offsets
@ -1462,8 +1462,8 @@ impl Window {
None => break,
}
}
let offset = self.current_viewport.get().origin;
Point2D::new(offset.x.to_f32_px(), offset.y.to_f32_px())
let vp_origin = self.current_viewport.get().origin;
Vector2D::new(vp_origin.x.to_f32_px(), vp_origin.y.to_f32_px())
}
// https://drafts.csswg.org/cssom-view/#dom-element-scroll

View file

@ -40,7 +40,7 @@ use dom_struct::dom_struct;
use encoding::all::UTF_8;
use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecoderTrap, EncoderTrap, Encoding, EncodingRef};
use euclid::length::Length;
use euclid::Length;
use html5ever::serialize;
use html5ever::serialize::SerializeOpts;
use hyper::header::{ContentLength, ContentType, ContentEncoding};

View file

@ -58,8 +58,7 @@ use dom::windowproxy::WindowProxy;
use dom::worker::TrustedWorkerAddress;
use dom::worklet::WorkletThreadPool;
use dom::workletglobalscope::WorkletGlobalScopeInit;
use euclid::Rect;
use euclid::point::Point2D;
use euclid::{Point2D, Vector2D, Rect};
use hyper::header::{ContentType, HttpDate, Headers, LastModified};
use hyper::header::ReferrerPolicy as ReferrerPolicyHeader;
use hyper::mime::{Mime, SubLevel, TopLevel};
@ -1339,7 +1338,7 @@ impl ScriptThread {
fn handle_set_scroll_state(&self,
id: PipelineId,
scroll_states: &[(UntrustedNodeAddress, Point2D<f32>)]) {
scroll_states: &[(UntrustedNodeAddress, Vector2D<f32>)]) {
let window = match { self.documents.borrow().find_window(id) } {
Some(window) => window,
None => return warn!("Set scroll state message sent to nonexistent pipeline: {:?}", id),
@ -1350,8 +1349,7 @@ impl ScriptThread {
if node_address == UntrustedNodeAddress(ptr::null()) {
window.update_viewport_for_scroll(-scroll_offset.x, -scroll_offset.y);
} else {
scroll_offsets.insert(node_address,
Point2D::new(-scroll_offset.x, -scroll_offset.y));
scroll_offsets.insert(node_address, -*scroll_offset);
}
}
window.set_scroll_offsets(scroll_offsets)

View file

@ -12,7 +12,7 @@ use dom::eventsource::EventSourceTimeoutCallback;
use dom::globalscope::GlobalScope;
use dom::testbinding::TestBindingCallback;
use dom::xmlhttprequest::XHRTimeoutCallback;
use euclid::length::Length;
use euclid::Length;
use heapsize::HeapSizeOf;
use ipc_channel::ipc::IpcSender;
use js::jsapi::{HandleValue, Heap};

View file

@ -22,9 +22,7 @@ use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlinputelement::HTMLInputElement;
use dom::htmloptionelement::HTMLOptionElement;
use dom::node::{Node, window_from_node};
use euclid::point::Point2D;
use euclid::rect::Rect;
use euclid::size::Size2D;
use euclid::{Point2D, Rect, Size2D};
use hyper_serde::Serde;
use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{HandleValue, JSContext};