mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Update to euclid 0.8
This commit is contained in:
parent
b7facf41cb
commit
6259df5e2d
56 changed files with 538 additions and 558 deletions
|
@ -25,7 +25,7 @@ bitflags = "0.7"
|
|||
cssparser = "0.5.5"
|
||||
deque = "0.3.1"
|
||||
encoding = "0.2"
|
||||
euclid = "0.7.1"
|
||||
euclid = "0.8.2"
|
||||
fnv = "1.0"
|
||||
gecko_bindings = {path = "../../ports/geckolib/gecko_bindings", optional = true}
|
||||
gecko_string_cache = {path = "../../ports/geckolib/string_cache", optional = true}
|
||||
|
|
|
@ -301,9 +301,9 @@ impl<T: Copy> LogicalSize<T> {
|
|||
pub fn to_physical(&self, mode: WritingMode) -> Size2D<T> {
|
||||
self.debug_writing_mode.check(mode);
|
||||
if mode.is_vertical() {
|
||||
Size2D { width: self.block, height: self.inline }
|
||||
Size2D::new(self.block, self.inline)
|
||||
} else {
|
||||
Size2D { width: self.inline, height: self.block }
|
||||
Size2D::new(self.inline, self.block)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,15 +450,13 @@ impl<T: Copy + Sub<T, Output=T>> LogicalPoint<T> {
|
|||
pub fn to_physical(&self, mode: WritingMode, container_size: Size2D<T>) -> Point2D<T> {
|
||||
self.debug_writing_mode.check(mode);
|
||||
if mode.is_vertical() {
|
||||
Point2D {
|
||||
x: if mode.is_vertical_lr() { self.b } else { container_size.width - self.b },
|
||||
y: if mode.is_inline_tb() { self.i } else { container_size.height - self.i }
|
||||
}
|
||||
Point2D::new(
|
||||
if mode.is_vertical_lr() { self.b } else { container_size.width - self.b },
|
||||
if mode.is_inline_tb() { self.i } else { container_size.height - self.i })
|
||||
} else {
|
||||
Point2D {
|
||||
x: if mode.is_bidi_ltr() { self.i } else { container_size.width - self.i },
|
||||
y: self.b
|
||||
}
|
||||
Point2D::new(
|
||||
if mode.is_bidi_ltr() { self.i } else { container_size.width - self.i },
|
||||
self.b)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -953,8 +951,8 @@ impl<T: Copy + Add<T, Output=T> + Sub<T, Output=T>> LogicalRect<T> {
|
|||
}
|
||||
}
|
||||
Rect {
|
||||
origin: Point2D { x: x, y: y },
|
||||
size: Size2D { width: width, height: height },
|
||||
origin: Point2D::new(x, y),
|
||||
size: Size2D::new(width, height),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,11 +118,11 @@ pub enum MediaType {
|
|||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct Device {
|
||||
pub media_type: MediaType,
|
||||
pub viewport_size: TypedSize2D<ViewportPx, f32>,
|
||||
pub viewport_size: TypedSize2D<f32, ViewportPx>,
|
||||
}
|
||||
|
||||
impl Device {
|
||||
pub fn new(media_type: MediaType, viewport_size: TypedSize2D<ViewportPx, f32>) -> Device {
|
||||
pub fn new(media_type: MediaType, viewport_size: TypedSize2D<f32, ViewportPx>) -> Device {
|
||||
Device {
|
||||
media_type: media_type,
|
||||
viewport_size: viewport_size,
|
||||
|
@ -131,8 +131,8 @@ impl Device {
|
|||
|
||||
#[inline]
|
||||
pub fn au_viewport_size(&self) -> Size2D<Au> {
|
||||
Size2D::new(Au::from_f32_px(self.viewport_size.width.get()),
|
||||
Au::from_f32_px(self.viewport_size.height.get()))
|
||||
Size2D::new(Au::from_f32_px(self.viewport_size.width),
|
||||
Au::from_f32_px(self.viewport_size.height))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -369,47 +369,43 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
animatable="False">
|
||||
use self::computed_value::{StartEnd, TransitionTimingFunction};
|
||||
|
||||
use euclid::point::Point2D;
|
||||
use euclid::point::{Point2D, TypedPoint2D};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue;
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
|
||||
static EASE: TransitionTimingFunction = TransitionTimingFunction::CubicBezier(Point2D {
|
||||
x: 0.25,
|
||||
y: 0.1,
|
||||
}, Point2D {
|
||||
x: 0.25,
|
||||
y: 1.0,
|
||||
});
|
||||
static LINEAR: TransitionTimingFunction = TransitionTimingFunction::CubicBezier(Point2D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
}, Point2D {
|
||||
x: 1.0,
|
||||
y: 1.0,
|
||||
});
|
||||
static EASE_IN: TransitionTimingFunction = TransitionTimingFunction::CubicBezier(Point2D {
|
||||
x: 0.42,
|
||||
y: 0.0,
|
||||
}, Point2D {
|
||||
x: 1.0,
|
||||
y: 1.0,
|
||||
});
|
||||
static EASE_OUT: TransitionTimingFunction = TransitionTimingFunction::CubicBezier(Point2D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
}, Point2D {
|
||||
x: 0.58,
|
||||
y: 1.0,
|
||||
});
|
||||
static EASE_IN_OUT: TransitionTimingFunction =
|
||||
TransitionTimingFunction::CubicBezier(Point2D {
|
||||
x: 0.42,
|
||||
y: 0.0,
|
||||
}, Point2D {
|
||||
x: 0.58,
|
||||
y: 1.0,
|
||||
});
|
||||
// FIXME: This could use static variables and const functions when they are available.
|
||||
#[inline(always)]
|
||||
fn ease() -> TransitionTimingFunction {
|
||||
TransitionTimingFunction::CubicBezier(TypedPoint2D::new(0.25, 0.1),
|
||||
TypedPoint2D::new(0.25, 1.0))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn linear() -> TransitionTimingFunction {
|
||||
TransitionTimingFunction::CubicBezier(TypedPoint2D::new(0.0, 0.0),
|
||||
TypedPoint2D::new(1.0, 1.0))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn ease_in() -> TransitionTimingFunction {
|
||||
TransitionTimingFunction::CubicBezier(TypedPoint2D::new(0.42, 0.0),
|
||||
TypedPoint2D::new(1.0, 1.0))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn ease_out() -> TransitionTimingFunction {
|
||||
TransitionTimingFunction::CubicBezier(TypedPoint2D::new(0.0, 0.0),
|
||||
TypedPoint2D::new(0.58, 1.0))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn ease_in_out() -> TransitionTimingFunction {
|
||||
TransitionTimingFunction::CubicBezier(TypedPoint2D::new(0.42, 0.0),
|
||||
TypedPoint2D::new(0.58, 1.0))
|
||||
}
|
||||
|
||||
static STEP_START: TransitionTimingFunction =
|
||||
TransitionTimingFunction::Steps(1, StartEnd::Start);
|
||||
static STEP_END: TransitionTimingFunction =
|
||||
|
@ -509,7 +505,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
|
||||
#[inline]
|
||||
pub fn get_initial_single_value() -> TransitionTimingFunction {
|
||||
EASE
|
||||
ease()
|
||||
}
|
||||
|
||||
pub fn parse_one(input: &mut Parser) -> Result<SingleSpecifiedValue,()> {
|
||||
|
@ -551,11 +547,11 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
}
|
||||
match_ignore_ascii_case! {
|
||||
try!(input.expect_ident()),
|
||||
"ease" => Ok(EASE),
|
||||
"linear" => Ok(LINEAR),
|
||||
"ease-in" => Ok(EASE_IN),
|
||||
"ease-out" => Ok(EASE_OUT),
|
||||
"ease-in-out" => Ok(EASE_IN_OUT),
|
||||
"ease" => Ok(ease()),
|
||||
"linear" => Ok(linear()),
|
||||
"ease-in" => Ok(ease_in()),
|
||||
"ease-out" => Ok(ease_out()),
|
||||
"ease-in-out" => Ok(ease_in_out()),
|
||||
"step-start" => Ok(STEP_START),
|
||||
"step-end" => Ok(STEP_END),
|
||||
_ => Err(())
|
||||
|
|
|
@ -555,13 +555,13 @@ impl<'a, I> ViewportDescriptorDeclarationCascade for I
|
|||
}
|
||||
|
||||
pub trait MaybeNew {
|
||||
fn maybe_new(initial_viewport: TypedSize2D<ViewportPx, f32>,
|
||||
fn maybe_new(initial_viewport: TypedSize2D<f32, ViewportPx>,
|
||||
rule: &ViewportRule)
|
||||
-> Option<ViewportConstraints>;
|
||||
}
|
||||
|
||||
impl MaybeNew for ViewportConstraints {
|
||||
fn maybe_new(initial_viewport: TypedSize2D<ViewportPx, f32>,
|
||||
fn maybe_new(initial_viewport: TypedSize2D<f32, ViewportPx>,
|
||||
rule: &ViewportRule)
|
||||
-> Option<ViewportConstraints>
|
||||
{
|
||||
|
@ -639,8 +639,8 @@ impl MaybeNew for ViewportConstraints {
|
|||
//
|
||||
// Note: DEVICE-ADAPT § 5. states that relative length values are
|
||||
// resolved against initial values
|
||||
let initial_viewport = Size2D::new(Au::from_f32_px(initial_viewport.width.get()),
|
||||
Au::from_f32_px(initial_viewport.height.get()));
|
||||
let initial_viewport = Size2D::new(Au::from_f32_px(initial_viewport.width),
|
||||
Au::from_f32_px(initial_viewport.height));
|
||||
|
||||
|
||||
let context = Context {
|
||||
|
@ -749,7 +749,7 @@ impl MaybeNew for ViewportConstraints {
|
|||
});
|
||||
|
||||
Some(ViewportConstraints {
|
||||
size: Size2D::typed(width.to_f32_px(), height.to_f32_px()),
|
||||
size: TypedSize2D::new(width.to_f32_px(), height.to_f32_px()),
|
||||
|
||||
// TODO: compute a zoom factor for 'auto' as suggested by DEVICE-ADAPT § 10.
|
||||
initial_zoom: ScaleFactor::new(initial_zoom.unwrap_or(1.)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue