mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Compute scriptminsize against the parent font base size
MozReview-Commit-ID: Jf35S4GzkpN
This commit is contained in:
parent
bbf292b120
commit
275e94d718
2 changed files with 44 additions and 3 deletions
|
@ -2157,16 +2157,56 @@ ${helpers.single_keyword("-moz-math-variant",
|
||||||
internal="True" disable_when_testing="True">
|
internal="True" disable_when_testing="True">
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT;
|
use gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT;
|
||||||
|
use std::fmt;
|
||||||
|
use style_traits::ToCss;
|
||||||
use values::HasViewportPercentage;
|
use values::HasViewportPercentage;
|
||||||
use values::computed::ComputedValueAsSpecified;
|
use values::computed::ComputedValueAsSpecified;
|
||||||
use values::specified::length::{AU_PER_PT, Length};
|
use values::specified::length::{AU_PER_PT, FontBaseSize, NoCalcLength};
|
||||||
|
|
||||||
pub type SpecifiedValue = Length;
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
|
pub struct SpecifiedValue(pub NoCalcLength);
|
||||||
|
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
pub type T = super::Au;
|
pub type T = super::Au;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl ToComputedValue for SpecifiedValue {
|
||||||
|
type ComputedValue = computed_value::T;
|
||||||
|
|
||||||
|
fn to_computed_value(&self, cx: &Context) -> Au {
|
||||||
|
// 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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for SpecifiedValue {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
self.0.to_css(dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasViewportPercentage for SpecifiedValue {
|
||||||
|
fn has_viewport_percentage(&self) -> bool {
|
||||||
|
self.0.has_viewport_percentage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
Au((NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT as f32 * AU_PER_PT) as i32)
|
Au((NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT as f32 * AU_PER_PT) as i32)
|
||||||
|
|
|
@ -1476,6 +1476,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(declarations:
|
||||||
value: f32,
|
value: f32,
|
||||||
unit: structs::nsCSSUnit) {
|
unit: structs::nsCSSUnit) {
|
||||||
use style::properties::{PropertyDeclaration, LonghandId};
|
use style::properties::{PropertyDeclaration, LonghandId};
|
||||||
|
use style::properties::longhands::_moz_script_min_size::SpecifiedValue as MozScriptMinSize;
|
||||||
use style::values::specified::length::{AbsoluteLength, FontRelativeLength};
|
use style::values::specified::length::{AbsoluteLength, FontRelativeLength};
|
||||||
use style::values::specified::length::{LengthOrPercentage, NoCalcLength};
|
use style::values::specified::length::{LengthOrPercentage, NoCalcLength};
|
||||||
|
|
||||||
|
@ -1496,7 +1497,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(declarations:
|
||||||
let prop = match_wrap_declared! { long,
|
let prop = match_wrap_declared! { long,
|
||||||
Width => nocalc.into(),
|
Width => nocalc.into(),
|
||||||
FontSize => LengthOrPercentage::from(nocalc).into(),
|
FontSize => LengthOrPercentage::from(nocalc).into(),
|
||||||
MozScriptMinSize => nocalc.into(),
|
MozScriptMinSize => MozScriptMinSize(nocalc),
|
||||||
};
|
};
|
||||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
decls.push(prop, Importance::Normal);
|
decls.push(prop, Importance::Normal);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue