aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/properties/gecko.mako.rs1
-rw-r--r--components/style/properties/longhand/font.mako.rs59
-rw-r--r--components/style/values/computed/font.rs29
-rw-r--r--components/style/values/computed/mod.rs2
-rw-r--r--components/style/values/specified/font.rs27
-rw-r--r--components/style/values/specified/mod.rs2
6 files changed, 64 insertions, 56 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index c4c059ce95b..f66eaf21241 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -1119,6 +1119,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
"LengthOrNormal": impl_style_coord,
"MaxLength": impl_style_coord,
"MozLength": impl_style_coord,
+ "MozScriptMinSize": impl_absolute_length,
"NonNegativeLengthOrPercentage": impl_style_coord,
"NonNegativeNumber": impl_simple,
"Number": impl_simple,
diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs
index 20c0097a685..41ff54cee18 100644
--- a/components/style/properties/longhand/font.mako.rs
+++ b/components/style/properties/longhand/font.mako.rs
@@ -2187,57 +2187,14 @@ ${helpers.single_keyword("-moz-math-variant",
animation_value_type="none",
needs_conversion=True)}
-<%helpers:longhand name="-moz-script-min-size" products="gecko" animation_value_type="none"
- predefined_type="Length" gecko_ffi_name="mScriptMinSize"
- spec="Internal (not web-exposed)"
- internal="True">
- use gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT;
- use values::computed::Length;
- use values::specified::length::{AU_PER_PT, AU_PER_PX, FontBaseSize, NoCalcLength};
-
- #[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
- #[derive(Clone, Debug, PartialEq, ToCss)]
- pub struct SpecifiedValue(pub NoCalcLength);
-
- pub mod computed_value {
- pub type T = ::values::computed::Length;
- }
-
- impl ToComputedValue for SpecifiedValue {
- type ComputedValue = computed_value::T;
-
- fn to_computed_value(&self, cx: &Context) -> Length {
- // this value is used in the computation of font-size, so
- // we use the parent size
- let base_size = FontBaseSize::InheritedStyle;
- match self.0 {
- NoCalcLength::FontRelative(value) => {
- value.to_computed_value(cx, base_size)
- }
- NoCalcLength::ServoCharacterWidth(value) => {
- value.to_computed_value(base_size.resolve(cx))
- }
- ref l => {
- l.to_computed_value(cx)
- }
- }
- }
- fn from_computed_value(other: &computed_value::T) -> Self {
- SpecifiedValue(ToComputedValue::from_computed_value(other))
- }
- }
-
- #[inline]
- pub fn get_initial_value() -> computed_value::T {
- Length::new(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT as f32 * (AU_PER_PT / AU_PER_PX))
- }
-
- pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
- -> Result<SpecifiedValue, ParseError<'i>> {
- debug_assert!(false, "Should be set directly by presentation attributes only.");
- Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
- }
-</%helpers:longhand>
+${helpers.predefined_type("-moz-script-min-size",
+ "MozScriptMinSize",
+ "specified::MozScriptMinSize::get_initial_value()",
+ animation_value_type="none",
+ products="gecko",
+ internal=True,
+ gecko_ffi_name="mScriptMinSize",
+ spec="Internal (not web-exposed)")}
${helpers.predefined_type("-x-text-zoom",
"XTextZoom",
diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs
index 8114a98d790..03427594331 100644
--- a/components/style/values/computed/font.rs
+++ b/components/style/values/computed/font.rs
@@ -8,9 +8,11 @@ use app_units::Au;
use std::fmt;
use style_traits::ToCss;
use values::animated::ToAnimatedValue;
-use values::computed::NonNegativeLength;
+use values::computed::{Context, NonNegativeLength, ToComputedValue};
use values::specified::font as specified;
+use values::specified::length::{FontBaseSize, NoCalcLength};
+pub use values::computed::Length as MozScriptMinSize;
pub use values::specified::font::XTextZoom;
#[derive(Animate, ComputeSquaredDistance, MallocSizeOf, ToAnimatedZero)]
@@ -94,3 +96,28 @@ impl ToAnimatedValue for FontSize {
}
}
}
+
+impl ToComputedValue for specified::MozScriptMinSize {
+ type ComputedValue = MozScriptMinSize;
+
+ fn to_computed_value(&self, cx: &Context) -> MozScriptMinSize {
+ // this value is used in the computation of font-size, so
+ // we use the parent size
+ let base_size = FontBaseSize::InheritedStyle;
+ match self.0 {
+ NoCalcLength::FontRelative(value) => {
+ value.to_computed_value(cx, base_size)
+ }
+ NoCalcLength::ServoCharacterWidth(value) => {
+ value.to_computed_value(base_size.resolve(cx))
+ }
+ ref l => {
+ l.to_computed_value(cx)
+ }
+ }
+ }
+
+ fn from_computed_value(other: &MozScriptMinSize) -> Self {
+ specified::MozScriptMinSize(ToComputedValue::from_computed_value(other))
+ }
+}
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index 94f9c4f4135..558c084b64f 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -36,7 +36,7 @@ pub use self::angle::Angle;
pub use self::background::{BackgroundSize, BackgroundRepeat};
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageSideWidth};
pub use self::border::{BorderRadius, BorderCornerRadius, BorderSpacing};
-pub use self::font::XTextZoom;
+pub use self::font::{XTextZoom, MozScriptMinSize};
pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs
index a04dcd80c5e..e4d007fcafa 100644
--- a/components/style/values/specified/font.rs
+++ b/components/style/values/specified/font.rs
@@ -12,9 +12,11 @@ use parser::{Parse, ParserContext};
use properties::longhands::system_font::SystemFont;
use std::fmt;
use style_traits::{ToCss, StyleParseErrorKind, ParseError};
-use values::computed::{font as computed, Context, NonNegativeLength, ToComputedValue};
+use values::computed::{font as computed, Context, Length, NonNegativeLength, ToComputedValue};
use values::specified::{LengthOrPercentage, NoCalcLength};
-use values::specified::length::FontBaseSize;
+use values::specified::length::{AU_PER_PT, AU_PER_PX, FontBaseSize};
+
+const DEFAULT_SCRIPT_MIN_SIZE_PT: u32 = 8;
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
/// A specified font-size value
@@ -391,3 +393,24 @@ impl ToCss for XTextZoom {
Ok(())
}
}
+
+#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
+#[derive(Clone, Debug, PartialEq, ToCss)]
+/// Specifies the minimum font size allowed due to changes in scriptlevel.
+/// Ref: https://wiki.mozilla.org/MathML:mstyle
+pub struct MozScriptMinSize(pub NoCalcLength);
+
+impl MozScriptMinSize {
+ #[inline]
+ /// Calculate initial value of -moz-script-min-size.
+ pub fn get_initial_value() -> Length {
+ Length::new(DEFAULT_SCRIPT_MIN_SIZE_PT as f32 * (AU_PER_PT / AU_PER_PX))
+ }
+}
+
+impl Parse for MozScriptMinSize {
+ fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<MozScriptMinSize, ParseError<'i>> {
+ debug_assert!(false, "Should be set directly by presentation attributes only.");
+ Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
+ }
+}
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index 7e12767db77..1c9bc6122a6 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -30,7 +30,7 @@ pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, Justify
pub use self::background::{BackgroundRepeat, BackgroundSize};
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
-pub use self::font::XTextZoom;
+pub use self::font::{XTextZoom, MozScriptMinSize};
pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
pub use self::effects::{BoxShadow, Filter, SimpleShadow};