mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Bump euclid to 0.14.
This commit is contained in:
parent
5dce166266
commit
8617320500
88 changed files with 349 additions and 381 deletions
|
@ -10,7 +10,7 @@ use StyleArc;
|
|||
use app_units::Au;
|
||||
use canvas_traits::CanvasMsg;
|
||||
use context::{LayoutContext, with_thread_local_font_context};
|
||||
use euclid::{Matrix4D, Point2D, Radians, Rect, Size2D};
|
||||
use euclid::{Transform3D, Point2D, Vector2D, Radians, Rect, Size2D};
|
||||
use floats::ClearType;
|
||||
use flow::{self, ImmutableFlowUtils};
|
||||
use flow_ref::FlowRef;
|
||||
|
@ -2440,7 +2440,7 @@ impl Fragment {
|
|||
// this.
|
||||
let relative_position = self.relative_position(relative_containing_block_size);
|
||||
border_box.translate_by_size(&relative_position.to_physical(self.style.writing_mode))
|
||||
.translate(stacking_relative_flow_origin)
|
||||
.translate(&stacking_relative_flow_origin.to_vector())
|
||||
}
|
||||
|
||||
/// Given the stacking-context-relative border box, returns the stacking-context-relative
|
||||
|
@ -2551,7 +2551,7 @@ impl Fragment {
|
|||
|
||||
// Box shadows cause us to draw outside our border box.
|
||||
for box_shadow in &self.style().get_effects().box_shadow.0 {
|
||||
let offset = Point2D::new(box_shadow.offset_x, box_shadow.offset_y);
|
||||
let offset = Vector2D::new(box_shadow.offset_x, box_shadow.offset_y);
|
||||
let inflation = box_shadow.spread_radius + box_shadow.blur_radius *
|
||||
BLUR_INFLATION_FACTOR;
|
||||
overflow.paint = overflow.paint.union(&border_box.translate(&offset)
|
||||
|
@ -2842,13 +2842,13 @@ impl Fragment {
|
|||
}
|
||||
|
||||
/// Returns the 4D matrix representing this fragment's transform.
|
||||
pub fn transform_matrix(&self, stacking_relative_border_box: &Rect<Au>) -> Option<Matrix4D<f32>> {
|
||||
pub fn transform_matrix(&self, stacking_relative_border_box: &Rect<Au>) -> Option<Transform3D<f32>> {
|
||||
let operations = match self.style.get_box().transform.0 {
|
||||
None => return None,
|
||||
Some(ref operations) => operations,
|
||||
};
|
||||
|
||||
let mut transform = Matrix4D::identity();
|
||||
let mut transform = Transform3D::identity();
|
||||
let transform_origin = &self.style.get_box().transform_origin;
|
||||
let transform_origin_x =
|
||||
transform_origin.horizontal
|
||||
|
@ -2860,30 +2860,30 @@ impl Fragment {
|
|||
.to_f32_px();
|
||||
let transform_origin_z = transform_origin.depth.to_f32_px();
|
||||
|
||||
let pre_transform = Matrix4D::create_translation(transform_origin_x,
|
||||
transform_origin_y,
|
||||
transform_origin_z);
|
||||
let post_transform = Matrix4D::create_translation(-transform_origin_x,
|
||||
-transform_origin_y,
|
||||
-transform_origin_z);
|
||||
let pre_transform = Transform3D::create_translation(transform_origin_x,
|
||||
transform_origin_y,
|
||||
transform_origin_z);
|
||||
let post_transform = Transform3D::create_translation(-transform_origin_x,
|
||||
-transform_origin_y,
|
||||
-transform_origin_z);
|
||||
|
||||
for operation in operations {
|
||||
let matrix = match *operation {
|
||||
transform::ComputedOperation::Rotate(ax, ay, az, theta) => {
|
||||
let theta = 2.0f32 * f32::consts::PI - theta.radians();
|
||||
Matrix4D::create_rotation(ax, ay, az, Radians::new(theta))
|
||||
Transform3D::create_rotation(ax, ay, az, Radians::new(theta))
|
||||
}
|
||||
transform::ComputedOperation::Perspective(d) => {
|
||||
create_perspective_matrix(d)
|
||||
}
|
||||
transform::ComputedOperation::Scale(sx, sy, sz) => {
|
||||
Matrix4D::create_scale(sx, sy, sz)
|
||||
Transform3D::create_scale(sx, sy, sz)
|
||||
}
|
||||
transform::ComputedOperation::Translate(tx, ty, tz) => {
|
||||
let tx = tx.to_used_value(stacking_relative_border_box.size.width).to_f32_px();
|
||||
let ty = ty.to_used_value(stacking_relative_border_box.size.height).to_f32_px();
|
||||
let tz = tz.to_f32_px();
|
||||
Matrix4D::create_translation(tx, ty, tz)
|
||||
Transform3D::create_translation(tx, ty, tz)
|
||||
}
|
||||
transform::ComputedOperation::Matrix(m) => {
|
||||
m.to_gfx_matrix()
|
||||
|
@ -2893,14 +2893,14 @@ impl Fragment {
|
|||
unreachable!()
|
||||
}
|
||||
transform::ComputedOperation::Skew(theta_x, theta_y) => {
|
||||
Matrix4D::create_skew(Radians::new(theta_x.radians()),
|
||||
Transform3D::create_skew(Radians::new(theta_x.radians()),
|
||||
Radians::new(theta_y.radians()))
|
||||
}
|
||||
transform::ComputedOperation::InterpolateMatrix { .. } |
|
||||
transform::ComputedOperation::AccumulateMatrix { .. } => {
|
||||
// TODO: Convert InterpolateMatrix/AccmulateMatrix into a valid Matrix4D by
|
||||
// TODO: Convert InterpolateMatrix/AccmulateMatrix into a valid Transform3D by
|
||||
// the reference box.
|
||||
Matrix4D::identity()
|
||||
Transform3D::identity()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2911,7 +2911,7 @@ impl Fragment {
|
|||
}
|
||||
|
||||
/// Returns the 4D matrix representing this fragment's perspective.
|
||||
pub fn perspective_matrix(&self, stacking_relative_border_box: &Rect<Au>) -> Option<Matrix4D<f32>> {
|
||||
pub fn perspective_matrix(&self, stacking_relative_border_box: &Rect<Au>) -> Option<Transform3D<f32>> {
|
||||
match self.style().get_box().perspective {
|
||||
Either::First(length) => {
|
||||
let perspective_origin = self.style().get_box().perspective_origin;
|
||||
|
@ -2924,12 +2924,12 @@ impl Fragment {
|
|||
.to_used_value(stacking_relative_border_box.size.height)
|
||||
.to_f32_px());
|
||||
|
||||
let pre_transform = Matrix4D::create_translation(perspective_origin.x,
|
||||
perspective_origin.y,
|
||||
0.0);
|
||||
let post_transform = Matrix4D::create_translation(-perspective_origin.x,
|
||||
-perspective_origin.y,
|
||||
0.0);
|
||||
let pre_transform = Transform3D::create_translation(perspective_origin.x,
|
||||
perspective_origin.y,
|
||||
0.0);
|
||||
let post_transform = Transform3D::create_translation(-perspective_origin.x,
|
||||
-perspective_origin.y,
|
||||
0.0);
|
||||
|
||||
let perspective_matrix = create_perspective_matrix(length);
|
||||
|
||||
|
@ -3099,9 +3099,9 @@ impl Overflow {
|
|||
self.paint = self.paint.union(&other.paint);
|
||||
}
|
||||
|
||||
pub fn translate(&mut self, point: &Point2D<Au>) {
|
||||
self.scroll = self.scroll.translate(point);
|
||||
self.paint = self.paint.translate(point);
|
||||
pub fn translate(&mut self, by: &Vector2D<Au>) {
|
||||
self.scroll = self.scroll.translate(by);
|
||||
self.paint = self.paint.translate(by);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3184,11 +3184,11 @@ impl Serialize for DebugId {
|
|||
// and behaves as it does in other browsers.
|
||||
// See https://lists.w3.org/Archives/Public/www-style/2016Jan/0020.html for more details.
|
||||
#[inline]
|
||||
fn create_perspective_matrix(d: Au) -> Matrix4D<f32> {
|
||||
fn create_perspective_matrix(d: Au) -> Transform3D<f32> {
|
||||
let d = d.to_f32_px();
|
||||
if d <= 0.0 {
|
||||
Matrix4D::identity()
|
||||
Transform3D::identity()
|
||||
} else {
|
||||
Matrix4D::create_perspective(d)
|
||||
Transform3D::create_perspective(d)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue