mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
stylo: Support mathsize, width, and scriptminsize presentation attributes in MathML
This commit is contained in:
parent
1ea8175163
commit
6e842c373c
4 changed files with 91 additions and 8 deletions
|
@ -1871,6 +1871,12 @@ extern "C" {
|
||||||
property: nsCSSPropertyID,
|
property: nsCSSPropertyID,
|
||||||
value: f32);
|
value: f32);
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_DeclarationBlock_SetLengthValue(declarations:
|
||||||
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
property: nsCSSPropertyID,
|
||||||
|
value: f32, unit: nsCSSUnit);
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_DeclarationBlock_SetNumberValue(declarations:
|
pub fn Servo_DeclarationBlock_SetNumberValue(declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
|
|
@ -459,6 +459,12 @@ ${helpers.single_keyword("font-variant-caps",
|
||||||
Larger,
|
Larger,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<specified::LengthOrPercentage> for SpecifiedValue {
|
||||||
|
fn from(other: specified::LengthOrPercentage) -> Self {
|
||||||
|
SpecifiedValue::Length(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
pub type T = Au;
|
pub type T = Au;
|
||||||
|
@ -1283,3 +1289,31 @@ ${helpers.single_keyword("-moz-math-variant",
|
||||||
spec="Internal (not web-exposed)",
|
spec="Internal (not web-exposed)",
|
||||||
animation_type="none",
|
animation_type="none",
|
||||||
needs_conversion=True)}
|
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>
|
||||||
|
|
||||||
|
|
|
@ -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::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
|
||||||
pub use super::image::{SizeKeyword, VerticalDirection};
|
pub use super::image::{SizeKeyword, VerticalDirection};
|
||||||
|
|
||||||
const AU_PER_PX: CSSFloat = 60.;
|
/// Number of app units per pixel
|
||||||
const AU_PER_IN: CSSFloat = AU_PER_PX * 96.;
|
pub const AU_PER_PX: CSSFloat = 60.;
|
||||||
const AU_PER_CM: CSSFloat = AU_PER_IN / 2.54;
|
/// Number of app units per inch
|
||||||
const AU_PER_MM: CSSFloat = AU_PER_IN / 25.4;
|
pub const AU_PER_IN: CSSFloat = AU_PER_PX * 96.;
|
||||||
const AU_PER_Q: CSSFloat = AU_PER_MM / 4.;
|
/// Number of app units per centimeter
|
||||||
const AU_PER_PT: CSSFloat = AU_PER_IN / 72.;
|
pub const AU_PER_CM: CSSFloat = AU_PER_IN / 2.54;
|
||||||
const AU_PER_PC: CSSFloat = AU_PER_PT * 12.;
|
/// 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
|
/// Same as Gecko's AppUnitsToIntCSSPixels
|
||||||
///
|
///
|
||||||
|
|
|
@ -1413,6 +1413,41 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations:
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(declarations:
|
||||||
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
property: nsCSSPropertyID,
|
||||||
|
value: f32,
|
||||||
|
unit: structs::nsCSSUnit) {
|
||||||
|
use style::properties::{PropertyDeclaration, LonghandId};
|
||||||
|
use style::values::specified::length::{AbsoluteLength, FontRelativeLength};
|
||||||
|
use style::values::specified::length::{LengthOrPercentage, NoCalcLength};
|
||||||
|
|
||||||
|
let long = get_longhand_from_id!(property);
|
||||||
|
let nocalc = match unit {
|
||||||
|
structs::nsCSSUnit::eCSSUnit_EM => NoCalcLength::FontRelative(FontRelativeLength::Em(value)),
|
||||||
|
structs::nsCSSUnit::eCSSUnit_XHeight => NoCalcLength::FontRelative(FontRelativeLength::Ex(value)),
|
||||||
|
structs::nsCSSUnit::eCSSUnit_Pixel => NoCalcLength::Absolute(AbsoluteLength::Px(value)),
|
||||||
|
structs::nsCSSUnit::eCSSUnit_Inch => NoCalcLength::Absolute(AbsoluteLength::In(value)),
|
||||||
|
structs::nsCSSUnit::eCSSUnit_Centimeter => NoCalcLength::Absolute(AbsoluteLength::Cm(value)),
|
||||||
|
structs::nsCSSUnit::eCSSUnit_Millimeter => NoCalcLength::Absolute(AbsoluteLength::Mm(value)),
|
||||||
|
structs::nsCSSUnit::eCSSUnit_Point => NoCalcLength::Absolute(AbsoluteLength::Pt(value)),
|
||||||
|
structs::nsCSSUnit::eCSSUnit_Pica => NoCalcLength::Absolute(AbsoluteLength::Pc(value)),
|
||||||
|
structs::nsCSSUnit::eCSSUnit_Quarter => NoCalcLength::Absolute(AbsoluteLength::Q(value)),
|
||||||
|
_ => unreachable!("Unknown unit {:?} passed to SetLengthValue", unit)
|
||||||
|
};
|
||||||
|
|
||||||
|
let prop = match_wrap_declared! { long,
|
||||||
|
Width => nocalc.into(),
|
||||||
|
FontSize => LengthOrPercentage::from(nocalc).into(),
|
||||||
|
MozScriptMinSize => nocalc.into(),
|
||||||
|
};
|
||||||
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
|
decls.push(prop, Importance::Normal);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_DeclarationBlock_SetNumberValue(declarations:
|
pub extern "C" fn Servo_DeclarationBlock_SetNumberValue(declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
@ -1439,7 +1474,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations:
|
||||||
property: nsCSSPropertyID,
|
property: nsCSSPropertyID,
|
||||||
value: f32) {
|
value: f32) {
|
||||||
use style::properties::{PropertyDeclaration, LonghandId};
|
use style::properties::{PropertyDeclaration, LonghandId};
|
||||||
use style::values::specified::length::Percentage;
|
use style::values::specified::length::{LengthOrPercentage, Percentage};
|
||||||
|
|
||||||
let long = get_longhand_from_id!(property);
|
let long = get_longhand_from_id!(property);
|
||||||
let pc = Percentage(value);
|
let pc = Percentage(value);
|
||||||
|
@ -1451,6 +1486,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations:
|
||||||
MarginRight => pc.into(),
|
MarginRight => pc.into(),
|
||||||
MarginBottom => pc.into(),
|
MarginBottom => pc.into(),
|
||||||
MarginLeft => pc.into(),
|
MarginLeft => pc.into(),
|
||||||
|
FontSize => LengthOrPercentage::from(pc).into(),
|
||||||
};
|
};
|
||||||
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