[librsvg/wip/dimensions-api: 2/11] Rename LengthUnit::Default to LengthUnit::Px
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/wip/dimensions-api: 2/11] Rename LengthUnit::Default to LengthUnit::Px
- Date: Fri, 8 Feb 2019 01:38:06 +0000 (UTC)
commit 6e3246d7ab3c355cfd4c27b9f594b6437fdd8434
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Feb 6 16:34:59 2019 -0600
Rename LengthUnit::Default to LengthUnit::Px
Per CSS's terminology
rsvg_internals/src/filters/mod.rs | 4 ++--
rsvg_internals/src/filters/node.rs | 4 ++--
rsvg_internals/src/font_props.rs | 4 ++--
rsvg_internals/src/length.rs | 24 ++++++++++++------------
rsvg_internals/src/stop.rs | 2 +-
5 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/rsvg_internals/src/filters/mod.rs b/rsvg_internals/src/filters/mod.rs
index a12eee1e..e34f88b2 100644
--- a/rsvg_internals/src/filters/mod.rs
+++ b/rsvg_internals/src/filters/mod.rs
@@ -131,7 +131,7 @@ impl NodeTrait for Primitive {
}
match length.unit() {
- LengthUnit::Default | LengthUnit::Percent => Ok(length),
+ LengthUnit::Px | LengthUnit::Percent => Ok(length),
_ => Err(ValueErrorKind::Parse(ParseError::new(
"unit identifiers are not allowed with primitiveUnits set to objectBoundingBox",
))),
@@ -144,7 +144,7 @@ impl NodeTrait for Primitive {
}
match length.unit() {
- LengthUnit::Default | LengthUnit::Percent => Ok(length),
+ LengthUnit::Px | LengthUnit::Percent => Ok(length),
_ => Err(ValueErrorKind::Parse(ParseError::new(
"unit identifiers are not allowed with primitiveUnits set to objectBoundingBox",
))),
diff --git a/rsvg_internals/src/filters/node.rs b/rsvg_internals/src/filters/node.rs
index b30e710a..f8d46bad 100644
--- a/rsvg_internals/src/filters/node.rs
+++ b/rsvg_internals/src/filters/node.rs
@@ -53,7 +53,7 @@ impl NodeTrait for NodeFilter {
}
match length.unit() {
- LengthUnit::Default | LengthUnit::Percent => Ok(length),
+ LengthUnit::Px | LengthUnit::Percent => Ok(length),
_ => Err(ValueErrorKind::Parse(ParseError::new(
"unit identifiers are not allowed with filterUnits set to objectBoundingBox",
))),
@@ -66,7 +66,7 @@ impl NodeTrait for NodeFilter {
}
match length.unit() {
- LengthUnit::Default | LengthUnit::Percent => Ok(length),
+ LengthUnit::Px | LengthUnit::Percent => Ok(length),
_ => Err(ValueErrorKind::Parse(ParseError::new(
"unit identifiers are not allowed with filterUnits set to objectBoundingBox",
))),
diff --git a/rsvg_internals/src/font_props.rs b/rsvg_internals/src/font_props.rs
index b663fd45..042609b9 100644
--- a/rsvg_internals/src/font_props.rs
+++ b/rsvg_internals/src/font_props.rs
@@ -175,7 +175,7 @@ impl LetterSpacingSpec {
pub fn compute(&self) -> Self {
let spacing = match self {
- LetterSpacingSpec::Normal => LengthHorizontal::new(0.0, LengthUnit::Default),
+ LetterSpacingSpec::Normal => LengthHorizontal::new(0.0, LengthUnit::Px),
LetterSpacingSpec::Value(s) => s.clone(),
};
@@ -304,7 +304,7 @@ mod tests {
<LetterSpacingSpec as Parse>::parse_str("normal").map(|s| s.compute()),
Ok(LetterSpacingSpec::Value(LengthHorizontal::new(
0.0,
- LengthUnit::Default,
+ LengthUnit::Px,
)))
);
assert_eq!(
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index 5b0cabc7..8b1602cf 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -10,7 +10,7 @@ use properties::ComputedValues;
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum LengthUnit {
Percent,
- Default,
+ Px,
FontEm,
FontEx,
Inch,
@@ -67,7 +67,7 @@ macro_rules! define_length_type {
pub fn normalize(&self, values: &ComputedValues, params: &ViewParams) -> f64 {
match self.unit() {
- LengthUnit::Default => self.length(),
+ LengthUnit::Px => self.length(),
LengthUnit::Percent => {
self.length()
@@ -103,7 +103,7 @@ macro_rules! define_length_type {
impl Default for $name {
fn default() -> Self {
- $name(Length::new(0.0, LengthUnit::Default))
+ $name(Length::new(0.0, LengthUnit::Px))
}
}
@@ -183,7 +183,7 @@ impl Length {
/// Returns the raw length after asserting units are either default or percent.
#[inline]
pub fn get_unitless(&self) -> f64 {
- assert!(self.unit == LengthUnit::Default || self.unit == LengthUnit::Percent);
+ assert!(self.unit == LengthUnit::Px || self.unit == LengthUnit::Percent);
self.length
}
@@ -194,7 +194,7 @@ impl Length {
font_size: f64,
) -> f64 {
match self.unit {
- LengthUnit::Default => self.length,
+ LengthUnit::Px => self.length,
LengthUnit::Percent => self.length * width_or_height,
LengthUnit::FontEm => self.length * font_size,
LengthUnit::FontEx => self.length * font_size / 2.0,
@@ -213,7 +213,7 @@ impl Length {
match *token {
Token::Number { value, .. } => Length {
length: f64::from(value),
- unit: LengthUnit::Default,
+ unit: LengthUnit::Px,
},
Token::Percentage { unit_value, .. } => Length {
@@ -264,7 +264,7 @@ impl Length {
"px" => Length {
length: value,
- unit: LengthUnit::Default,
+ unit: LengthUnit::Px,
},
_ => return Err(make_err()),
@@ -283,7 +283,7 @@ fn font_size_from_values(values: &ComputedValues, params: &ViewParams) -> f64 {
let v = &values.font_size.0.value().0;
match v.unit {
- LengthUnit::Default => v.length,
+ LengthUnit::Px => v.length,
// FontSize always is a LengthDir::Both, per properties.rs
LengthUnit::Inch => v.length * LengthDir::Both.scaling_factor(params.dpi_x, params.dpi_y),
@@ -356,12 +356,12 @@ mod tests {
fn parses_default() {
assert_eq!(
LengthHorizontal::parse_str("42"),
- Ok(LengthHorizontal(Length::new(42.0, LengthUnit::Default,)))
+ Ok(LengthHorizontal(Length::new(42.0, LengthUnit::Px)))
);
assert_eq!(
LengthHorizontal::parse_str("-42px"),
- Ok(LengthHorizontal(Length::new(-42.0, LengthUnit::Default,)))
+ Ok(LengthHorizontal(Length::new(-42.0, LengthUnit::Px)))
);
}
@@ -369,7 +369,7 @@ mod tests {
fn parses_percent() {
assert_eq!(
LengthHorizontal::parse_str("50.0%"),
- Ok(LengthHorizontal(Length::new(0.5, LengthUnit::Percent,)))
+ Ok(LengthHorizontal(Length::new(0.5, LengthUnit::Percent)))
);
}
@@ -444,7 +444,7 @@ mod tests {
let values = ComputedValues::default();
assert_approx_eq_cairo!(
- LengthBoth::new(10.0, LengthUnit::Default).normalize(&values, ¶ms),
+ LengthBoth::new(10.0, LengthUnit::Px).normalize(&values, ¶ms),
10.0
);
}
diff --git a/rsvg_internals/src/stop.rs b/rsvg_internals/src/stop.rs
index af9d3398..172f0f0b 100644
--- a/rsvg_internals/src/stop.rs
+++ b/rsvg_internals/src/stop.rs
@@ -26,7 +26,7 @@ impl NodeStop {
fn validate_offset(length: LengthBoth) -> Result<LengthBoth, ValueErrorKind> {
match length.unit() {
- LengthUnit::Default | LengthUnit::Percent => Ok(length),
+ LengthUnit::Px | LengthUnit::Percent => Ok(length),
_ => Err(ValueErrorKind::Value(
"stop offset must be in default or percent units".to_string(),
)),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]