stylo: Support mathsize, width, and scriptminsize presentation attributes in MathML

This commit is contained in:
Manish Goregaokar 2017-04-10 15:28:48 +08:00 committed by Manish Goregaokar
parent 1ea8175163
commit 6e842c373c
4 changed files with 91 additions and 8 deletions

View file

@ -1871,6 +1871,12 @@ extern "C" {
property: nsCSSPropertyID,
value: f32);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetLengthValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value: f32, unit: nsCSSUnit);
}
extern "C" {
pub fn Servo_DeclarationBlock_SetNumberValue(declarations:
RawServoDeclarationBlockBorrowed,

View file

@ -459,6 +459,12 @@ ${helpers.single_keyword("font-variant-caps",
Larger,
}
impl From<specified::LengthOrPercentage> for SpecifiedValue {
fn from(other: specified::LengthOrPercentage) -> Self {
SpecifiedValue::Length(other)
}
}
pub mod computed_value {
use app_units::Au;
pub type T = Au;
@ -1283,3 +1289,31 @@ ${helpers.single_keyword("-moz-math-variant",
spec="Internal (not web-exposed)",
animation_type="none",
needs_conversion=True)}
<%helpers:longhand name="-moz-script-min-size" products="gecko" animation_type="none"
predefined_type="Length" gecko_ffi_name="mScriptMinSize"
spec="Internal (not web-exposed)"
internal="True" disable_when_testing="True">
use app_units::Au;
use gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified;
use values::specified::length::{AU_PER_PT, Length};
pub type SpecifiedValue = Length;
pub mod computed_value {
pub type T = super::Au;
}
#[inline]
pub fn get_initial_value() -> computed_value::T {
Au((NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT as f32 * AU_PER_PT) as i32)
}
pub fn parse(_context: &ParserContext, _input: &mut Parser) -> Result<SpecifiedValue, ()> {
debug_assert!(false, "Should be set directly by presentation attributes only.");
Err(())
}
</%helpers:longhand>

View file

@ -26,13 +26,20 @@ pub use super::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingSh
pub use super::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
pub use super::image::{SizeKeyword, VerticalDirection};
const AU_PER_PX: CSSFloat = 60.;
const AU_PER_IN: CSSFloat = AU_PER_PX * 96.;
const AU_PER_CM: CSSFloat = AU_PER_IN / 2.54;
const AU_PER_MM: CSSFloat = AU_PER_IN / 25.4;
const AU_PER_Q: CSSFloat = AU_PER_MM / 4.;
const AU_PER_PT: CSSFloat = AU_PER_IN / 72.;
const AU_PER_PC: CSSFloat = AU_PER_PT * 12.;
/// Number of app units per pixel
pub const AU_PER_PX: CSSFloat = 60.;
/// Number of app units per inch
pub const AU_PER_IN: CSSFloat = AU_PER_PX * 96.;
/// Number of app units per centimeter
pub const AU_PER_CM: CSSFloat = AU_PER_IN / 2.54;
/// Number of app units per millimeter
pub const AU_PER_MM: CSSFloat = AU_PER_IN / 25.4;
/// Number of app units per quarter
pub const AU_PER_Q: CSSFloat = AU_PER_MM / 4.;
/// Number of app units per point
pub const AU_PER_PT: CSSFloat = AU_PER_IN / 72.;
/// Number of app units per pica
pub const AU_PER_PC: CSSFloat = AU_PER_PT * 12.;
/// Same as Gecko's AppUnitsToIntCSSPixels
///