mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Introduce CSSPixelLength and update NonNegativeLength.
First, we define computed::CSSPixelLength which contains a CSSFloat, a pixel value, and then we replace computed::Length with CSSPixelLength. Therefore, the |ComputedValue| of NoCalcLength, AbsoluteLength, FontRelativeLength, ViewportPercentageLength, CharacterWidth, and PhysicalLength is CSSPixelLength. Besides, we drop NonNegativeAu, and replace computed::NonNegativeLength with NonNegative<computed::Length>. (i.e. NonNegative<CSSPixelLength>)
This commit is contained in:
parent
cad3aff508
commit
a949e2a057
40 changed files with 502 additions and 406 deletions
|
@ -328,8 +328,9 @@ impl nsStyleImage {
|
|||
match shape {
|
||||
EndingShape::Circle(Circle::Radius(length)) => {
|
||||
unsafe {
|
||||
(*gecko_gradient).mRadiusX.set_value(CoordDataValue::Coord(length.0));
|
||||
(*gecko_gradient).mRadiusY.set_value(CoordDataValue::Coord(length.0));
|
||||
let au = length.to_i32_au();
|
||||
(*gecko_gradient).mRadiusX.set_value(CoordDataValue::Coord(au));
|
||||
(*gecko_gradient).mRadiusY.set_value(CoordDataValue::Coord(au));
|
||||
}
|
||||
},
|
||||
EndingShape::Ellipse(Ellipse::Radii(x, y)) => {
|
||||
|
|
|
@ -1376,6 +1376,10 @@ extern "C" {
|
|||
pub fn Gecko_CSSValue_SetPercentage(css_value: nsCSSValueBorrowedMut,
|
||||
percent: f32);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CSSValue_SetPixelLength(aCSSValue: nsCSSValueBorrowedMut,
|
||||
aLen: f32);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CSSValue_SetCalc(css_value: nsCSSValueBorrowedMut,
|
||||
calc: nsStyleCoord_CalcValue);
|
||||
|
|
|
@ -71,7 +71,7 @@ impl Device {
|
|||
pres_context: pres_context,
|
||||
default_values: ComputedValues::default_values(unsafe { &*pres_context }),
|
||||
// FIXME(bz): Seems dubious?
|
||||
root_font_size: AtomicIsize::new(font_size::get_initial_value().value() as isize),
|
||||
root_font_size: AtomicIsize::new(font_size::get_initial_value().0.to_i32_au() as isize),
|
||||
used_root_font_size: AtomicBool::new(false),
|
||||
used_viewport_size: AtomicBool::new(false),
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ impl Expression {
|
|||
return match *actual_value {
|
||||
BoolInteger(v) => v,
|
||||
Integer(v) => v != 0,
|
||||
Length(ref l) => l.to_computed_value(&context) != Au(0),
|
||||
Length(ref l) => l.to_computed_value(&context).px() != 0.,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
@ -722,8 +722,8 @@ impl Expression {
|
|||
// FIXME(emilio): Handle the possible floating point errors?
|
||||
let cmp = match (required_value, actual_value) {
|
||||
(&Length(ref one), &Length(ref other)) => {
|
||||
one.to_computed_value(&context)
|
||||
.cmp(&other.to_computed_value(&context))
|
||||
one.to_computed_value(&context).to_i32_au()
|
||||
.cmp(&other.to_computed_value(&context).to_i32_au())
|
||||
}
|
||||
(&Integer(one), &Integer(ref other)) => one.cmp(other),
|
||||
(&BoolInteger(one), &BoolInteger(ref other)) => one.cmp(other),
|
||||
|
|
|
@ -17,10 +17,10 @@ use media_queries::Device;
|
|||
use nsstring::{nsACString, nsCString};
|
||||
use std::cmp::max;
|
||||
use values::{Auto, Either, ExtremumLength, None_, Normal};
|
||||
use values::computed::{Angle, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::{Angle, Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
|
||||
use values::computed::{MaxLength, MozLength, Percentage};
|
||||
use values::computed::{NonNegativeAu, NonNegativeLengthOrPercentage, NonNegativeNumber};
|
||||
use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber};
|
||||
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
|
||||
use values::generics::{CounterStyleOrNone, NonNegative};
|
||||
use values::generics::basic_shape::ShapeRadius;
|
||||
|
@ -133,26 +133,26 @@ impl GeckoStyleCoordConvertible for NonNegativeLengthOrPercentage {
|
|||
}
|
||||
}
|
||||
|
||||
impl GeckoStyleCoordConvertible for Au {
|
||||
impl GeckoStyleCoordConvertible for Length {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
coord.set_value(CoordDataValue::Coord(self.0));
|
||||
coord.set_value(CoordDataValue::Coord(self.to_i32_au()));
|
||||
}
|
||||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
match coord.as_value() {
|
||||
CoordDataValue::Coord(coord) => Some(Au(coord)),
|
||||
CoordDataValue::Coord(coord) => Some(Au(coord).into()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GeckoStyleCoordConvertible for NonNegativeAu {
|
||||
impl GeckoStyleCoordConvertible for NonNegativeLength {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
self.0.to_gecko_style_coord(coord);
|
||||
}
|
||||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
Au::from_gecko_style_coord(coord).map(NonNegative::<Au>)
|
||||
Length::from_gecko_style_coord(coord).map(NonNegative::<Length>)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue