mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #16376 - Manishearth:stylo-mathml, r=emilio
stylo: Support mathml and background preshints r=emilio https://bugzilla.mozilla.org/show_bug.cgi?id=1339711 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16376) <!-- Reviewable:end -->
This commit is contained in:
commit
8298ee75c7
9 changed files with 362 additions and 24 deletions
|
@ -302,6 +302,7 @@ mod bindings {
|
||||||
"NODE_.*",
|
"NODE_.*",
|
||||||
"NS_FONT_.*",
|
"NS_FONT_.*",
|
||||||
"NS_STYLE_.*",
|
"NS_STYLE_.*",
|
||||||
|
"NS_MATHML_.*",
|
||||||
"NS_RADIUS_.*",
|
"NS_RADIUS_.*",
|
||||||
"BORDER_COLOR_.*",
|
"BORDER_COLOR_.*",
|
||||||
"BORDER_STYLE_.*",
|
"BORDER_STYLE_.*",
|
||||||
|
|
|
@ -1871,6 +1871,18 @@ 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" {
|
||||||
|
pub fn Servo_DeclarationBlock_SetNumberValue(declarations:
|
||||||
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
property: nsCSSPropertyID,
|
||||||
|
value: f32);
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_DeclarationBlock_SetPercentValue(declarations:
|
pub fn Servo_DeclarationBlock_SetPercentValue(declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
|
|
@ -540,6 +540,35 @@ pub mod root {
|
||||||
pub const NS_STYLE_GRID_TEMPLATE_SUBGRID: ::std::os::raw::c_uint = 0;
|
pub const NS_STYLE_GRID_TEMPLATE_SUBGRID: ::std::os::raw::c_uint = 0;
|
||||||
pub const NS_STYLE_GRID_REPEAT_AUTO_FILL: ::std::os::raw::c_uint = 0;
|
pub const NS_STYLE_GRID_REPEAT_AUTO_FILL: ::std::os::raw::c_uint = 0;
|
||||||
pub const NS_STYLE_GRID_REPEAT_AUTO_FIT: ::std::os::raw::c_uint = 1;
|
pub const NS_STYLE_GRID_REPEAT_AUTO_FIT: ::std::os::raw::c_uint = 1;
|
||||||
|
pub const NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER: f32 = 0.71;
|
||||||
|
pub const NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT: ::std::os::raw::c_uint =
|
||||||
|
8;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_NONE: ::std::os::raw::c_uint = 0;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_NORMAL: ::std::os::raw::c_uint = 1;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD: ::std::os::raw::c_uint = 2;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_ITALIC: ::std::os::raw::c_uint = 3;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD_ITALIC: ::std::os::raw::c_uint = 4;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_SCRIPT: ::std::os::raw::c_uint = 5;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD_SCRIPT: ::std::os::raw::c_uint = 6;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_FRAKTUR: ::std::os::raw::c_uint = 7;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_DOUBLE_STRUCK: ::std::os::raw::c_uint = 8;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD_FRAKTUR: ::std::os::raw::c_uint = 9;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_SANS_SERIF: ::std::os::raw::c_uint = 10;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD_SANS_SERIF: ::std::os::raw::c_uint =
|
||||||
|
11;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_SANS_SERIF_ITALIC: ::std::os::raw::c_uint
|
||||||
|
=
|
||||||
|
12;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_SANS_SERIF_BOLD_ITALIC:
|
||||||
|
::std::os::raw::c_uint =
|
||||||
|
13;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_MONOSPACE: ::std::os::raw::c_uint = 14;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_INITIAL: ::std::os::raw::c_uint = 15;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_TAILED: ::std::os::raw::c_uint = 16;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_LOOPED: ::std::os::raw::c_uint = 17;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_STRETCHED: ::std::os::raw::c_uint = 18;
|
||||||
|
pub const NS_MATHML_DISPLAYSTYLE_INLINE: ::std::os::raw::c_uint = 0;
|
||||||
|
pub const NS_MATHML_DISPLAYSTYLE_BLOCK: ::std::os::raw::c_uint = 1;
|
||||||
pub const NS_STYLE_WIDTH_MAX_CONTENT: ::std::os::raw::c_uint = 0;
|
pub const NS_STYLE_WIDTH_MAX_CONTENT: ::std::os::raw::c_uint = 0;
|
||||||
pub const NS_STYLE_WIDTH_MIN_CONTENT: ::std::os::raw::c_uint = 1;
|
pub const NS_STYLE_WIDTH_MIN_CONTENT: ::std::os::raw::c_uint = 1;
|
||||||
pub const NS_STYLE_WIDTH_FIT_CONTENT: ::std::os::raw::c_uint = 2;
|
pub const NS_STYLE_WIDTH_FIT_CONTENT: ::std::os::raw::c_uint = 2;
|
||||||
|
|
|
@ -540,6 +540,35 @@ pub mod root {
|
||||||
pub const NS_STYLE_GRID_TEMPLATE_SUBGRID: ::std::os::raw::c_uint = 0;
|
pub const NS_STYLE_GRID_TEMPLATE_SUBGRID: ::std::os::raw::c_uint = 0;
|
||||||
pub const NS_STYLE_GRID_REPEAT_AUTO_FILL: ::std::os::raw::c_uint = 0;
|
pub const NS_STYLE_GRID_REPEAT_AUTO_FILL: ::std::os::raw::c_uint = 0;
|
||||||
pub const NS_STYLE_GRID_REPEAT_AUTO_FIT: ::std::os::raw::c_uint = 1;
|
pub const NS_STYLE_GRID_REPEAT_AUTO_FIT: ::std::os::raw::c_uint = 1;
|
||||||
|
pub const NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER: f32 = 0.71;
|
||||||
|
pub const NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT: ::std::os::raw::c_uint =
|
||||||
|
8;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_NONE: ::std::os::raw::c_uint = 0;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_NORMAL: ::std::os::raw::c_uint = 1;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD: ::std::os::raw::c_uint = 2;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_ITALIC: ::std::os::raw::c_uint = 3;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD_ITALIC: ::std::os::raw::c_uint = 4;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_SCRIPT: ::std::os::raw::c_uint = 5;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD_SCRIPT: ::std::os::raw::c_uint = 6;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_FRAKTUR: ::std::os::raw::c_uint = 7;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_DOUBLE_STRUCK: ::std::os::raw::c_uint = 8;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD_FRAKTUR: ::std::os::raw::c_uint = 9;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_SANS_SERIF: ::std::os::raw::c_uint = 10;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_BOLD_SANS_SERIF: ::std::os::raw::c_uint =
|
||||||
|
11;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_SANS_SERIF_ITALIC: ::std::os::raw::c_uint
|
||||||
|
=
|
||||||
|
12;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_SANS_SERIF_BOLD_ITALIC:
|
||||||
|
::std::os::raw::c_uint =
|
||||||
|
13;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_MONOSPACE: ::std::os::raw::c_uint = 14;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_INITIAL: ::std::os::raw::c_uint = 15;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_TAILED: ::std::os::raw::c_uint = 16;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_LOOPED: ::std::os::raw::c_uint = 17;
|
||||||
|
pub const NS_MATHML_MATHVARIANT_STRETCHED: ::std::os::raw::c_uint = 18;
|
||||||
|
pub const NS_MATHML_DISPLAYSTYLE_INLINE: ::std::os::raw::c_uint = 0;
|
||||||
|
pub const NS_MATHML_DISPLAYSTYLE_BLOCK: ::std::os::raw::c_uint = 1;
|
||||||
pub const NS_STYLE_WIDTH_MAX_CONTENT: ::std::os::raw::c_uint = 0;
|
pub const NS_STYLE_WIDTH_MAX_CONTENT: ::std::os::raw::c_uint = 0;
|
||||||
pub const NS_STYLE_WIDTH_MIN_CONTENT: ::std::os::raw::c_uint = 1;
|
pub const NS_STYLE_WIDTH_MIN_CONTENT: ::std::os::raw::c_uint = 1;
|
||||||
pub const NS_STYLE_WIDTH_FIT_CONTENT: ::std::os::raw::c_uint = 2;
|
pub const NS_STYLE_WIDTH_FIT_CONTENT: ::std::os::raw::c_uint = 2;
|
||||||
|
|
|
@ -664,6 +664,7 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
||||||
"MaxLength": impl_style_coord,
|
"MaxLength": impl_style_coord,
|
||||||
"MinLength": impl_style_coord,
|
"MinLength": impl_style_coord,
|
||||||
"Number": impl_simple,
|
"Number": impl_simple,
|
||||||
|
"Integer": impl_simple,
|
||||||
"Opacity": impl_simple,
|
"Opacity": impl_simple,
|
||||||
"CSSColor": impl_color,
|
"CSSColor": impl_color,
|
||||||
"SVGPaint": impl_svg_paint,
|
"SVGPaint": impl_svg_paint,
|
||||||
|
@ -1259,8 +1260,12 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
<%
|
||||||
|
skip_font_longhands = """font-family font-size font-size-adjust font-weight
|
||||||
|
font-synthesis -x-lang font-language-override"""
|
||||||
|
%>
|
||||||
<%self:impl_trait style_struct_name="Font"
|
<%self:impl_trait style_struct_name="Font"
|
||||||
skip_longhands="font-family font-size font-size-adjust font-weight font-synthesis -x-lang font-language-override"
|
skip_longhands="${skip_font_longhands}"
|
||||||
skip_additionals="*">
|
skip_additionals="*">
|
||||||
|
|
||||||
pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) {
|
pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) {
|
||||||
|
|
|
@ -225,7 +225,8 @@ ${helpers.single_keyword("font-style",
|
||||||
gecko_constant_prefix="NS_FONT_STYLE",
|
gecko_constant_prefix="NS_FONT_STYLE",
|
||||||
gecko_ffi_name="mFont.style",
|
gecko_ffi_name="mFont.style",
|
||||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-style",
|
spec="https://drafts.csswg.org/css-fonts/#propdef-font-style",
|
||||||
animation_type="none")}
|
animation_type="none",
|
||||||
|
needs_conversion=True)}
|
||||||
|
|
||||||
${helpers.single_keyword("font-variant",
|
${helpers.single_keyword("font-variant",
|
||||||
"normal small-caps",
|
"normal small-caps",
|
||||||
|
@ -292,19 +293,24 @@ ${helpers.single_keyword("font-variant-caps",
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
}).or_else(|()| {
|
}).or_else(|()| {
|
||||||
match try!(input.expect_integer()) {
|
SpecifiedValue::from_int(input.expect_integer()?)
|
||||||
100 => Ok(SpecifiedValue::Weight100),
|
})
|
||||||
200 => Ok(SpecifiedValue::Weight200),
|
}
|
||||||
300 => Ok(SpecifiedValue::Weight300),
|
|
||||||
400 => Ok(SpecifiedValue::Weight400),
|
impl SpecifiedValue {
|
||||||
500 => Ok(SpecifiedValue::Weight500),
|
pub fn from_int(kw: i32) -> Result<Self, ()> {
|
||||||
600 => Ok(SpecifiedValue::Weight600),
|
match kw {
|
||||||
700 => Ok(SpecifiedValue::Weight700),
|
% for weight in range(100, 901, 100):
|
||||||
800 => Ok(SpecifiedValue::Weight800),
|
${weight} => Ok(SpecifiedValue::Weight${weight}),
|
||||||
900 => Ok(SpecifiedValue::Weight900),
|
% endfor
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
pub fn from_gecko_keyword(kw: u32) -> Self {
|
||||||
|
Self::from_int(kw as i32).expect("Found unexpected value in style
|
||||||
|
struct for font-weight property")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used in @font-face, where relative keywords are not allowed.
|
/// Used in @font-face, where relative keywords are not allowed.
|
||||||
|
@ -453,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;
|
||||||
|
@ -1118,8 +1130,7 @@ ${helpers.single_keyword("font-variant-position",
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="-x-lang" products="gecko" animation_type="none" internal="True"
|
<%helpers:longhand name="-x-lang" products="gecko" animation_type="none" internal="True"
|
||||||
spec="Internal (not web-exposed)"
|
spec="Internal (not web-exposed)">
|
||||||
internal="True">
|
|
||||||
use values::HasViewportPercentage;
|
use values::HasViewportPercentage;
|
||||||
use values::computed::ComputedValueAsSpecified;
|
use values::computed::ComputedValueAsSpecified;
|
||||||
pub use self::computed_value::T as SpecifiedValue;
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
|
@ -1153,3 +1164,156 @@ ${helpers.single_keyword("font-variant-position",
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
// MathML properties
|
||||||
|
<%helpers:longhand name="-moz-script-size-multiplier" products="gecko" animation_type="none"
|
||||||
|
predefined_type="Number" gecko_ffi_name="mScriptSizeMultiplier"
|
||||||
|
spec="Internal (not web-exposed)"
|
||||||
|
internal="True" disable_when_testing="True">
|
||||||
|
use values::HasViewportPercentage;
|
||||||
|
use values::computed::ComputedValueAsSpecified;
|
||||||
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
|
|
||||||
|
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||||
|
no_viewport_percentage!(SpecifiedValue);
|
||||||
|
|
||||||
|
pub mod computed_value {
|
||||||
|
pub type T = f32;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
|
::gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(_context: &ParserContext, _input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||||
|
debug_assert!(false, "Should be set directly by presentation attributes only.");
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
<%helpers:longhand name="-moz-script-level" products="gecko" animation_type="none"
|
||||||
|
predefined_type="Integer" gecko_ffi_name="mScriptLevel"
|
||||||
|
spec="Internal (not web-exposed)"
|
||||||
|
internal="True" disable_when_testing="True" need_clone="True">
|
||||||
|
use std::fmt;
|
||||||
|
use style_traits::ToCss;
|
||||||
|
use values::HasViewportPercentage;
|
||||||
|
|
||||||
|
no_viewport_percentage!(SpecifiedValue);
|
||||||
|
|
||||||
|
pub mod computed_value {
|
||||||
|
pub type T = i8;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
|
pub enum SpecifiedValue {
|
||||||
|
Relative(i32),
|
||||||
|
Absolute(i32),
|
||||||
|
Auto
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for SpecifiedValue {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
match *self {
|
||||||
|
SpecifiedValue::Auto => dest.write_str("auto"),
|
||||||
|
SpecifiedValue::Relative(rel) => write!(dest, "{}", rel),
|
||||||
|
// can only be specified by pres attrs; should not
|
||||||
|
// serialize to anything else
|
||||||
|
SpecifiedValue::Absolute(_) => Ok(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToComputedValue for SpecifiedValue {
|
||||||
|
type ComputedValue = computed_value::T;
|
||||||
|
|
||||||
|
fn to_computed_value(&self, cx: &Context) -> i8 {
|
||||||
|
use properties::longhands::_moz_math_display::SpecifiedValue as DisplayValue;
|
||||||
|
use std::{cmp, i8};
|
||||||
|
|
||||||
|
let int = match *self {
|
||||||
|
SpecifiedValue::Auto => {
|
||||||
|
let parent = cx.inherited_style().get_font().clone__moz_script_level() as i32;
|
||||||
|
let display = cx.inherited_style().get_font().clone__moz_math_display();
|
||||||
|
if display == DisplayValue::inline {
|
||||||
|
parent + 1
|
||||||
|
} else {
|
||||||
|
parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SpecifiedValue::Relative(rel) => {
|
||||||
|
let parent = cx.inherited_style().get_font().clone__moz_script_level();
|
||||||
|
parent as i32 + rel
|
||||||
|
}
|
||||||
|
SpecifiedValue::Absolute(abs) => abs,
|
||||||
|
};
|
||||||
|
cmp::min(int, i8::MAX as i32) as i8
|
||||||
|
}
|
||||||
|
fn from_computed_value(other: &computed_value::T) -> Self {
|
||||||
|
SpecifiedValue::Absolute(*other as i32)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||||
|
if let Ok(i) = input.try(|i| i.expect_integer()) {
|
||||||
|
return Ok(SpecifiedValue::Relative(i))
|
||||||
|
}
|
||||||
|
input.expect_ident_matching("auto")?;
|
||||||
|
Ok(SpecifiedValue::Auto)
|
||||||
|
}
|
||||||
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
${helpers.single_keyword("-moz-math-display",
|
||||||
|
"inline block",
|
||||||
|
gecko_constant_prefix="NS_MATHML_DISPLAYSTYLE",
|
||||||
|
gecko_ffi_name="mMathDisplay",
|
||||||
|
products="gecko",
|
||||||
|
spec="Internal (not web-exposed)",
|
||||||
|
animation_type="none",
|
||||||
|
need_clone="True")}
|
||||||
|
|
||||||
|
${helpers.single_keyword("-moz-math-variant",
|
||||||
|
"""normal bold italic bold-italic script bold-script
|
||||||
|
fraktur double-struck bold-fraktur sans-serif
|
||||||
|
bold-sans-serif sans-serif-italic sans-serif-bold-italic
|
||||||
|
monospace initial tailed looped stretched""",
|
||||||
|
gecko_constant_prefix="NS_MATHML_MATHVARIANT",
|
||||||
|
gecko_ffi_name="mMathVariant",
|
||||||
|
products="gecko",
|
||||||
|
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>
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@ ${helpers.single_keyword("writing-mode",
|
||||||
spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode")}
|
spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode")}
|
||||||
|
|
||||||
${helpers.single_keyword("direction", "ltr rtl", need_clone=True, animation_type="none",
|
${helpers.single_keyword("direction", "ltr rtl", need_clone=True, animation_type="none",
|
||||||
spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction")}
|
spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction",
|
||||||
|
needs_conversion=True)}
|
||||||
|
|
||||||
<%helpers:single_keyword_computed
|
<%helpers:single_keyword_computed
|
||||||
name="text-orientation"
|
name="text-orientation"
|
||||||
|
|
|
@ -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
|
||||||
///
|
///
|
||||||
|
|
|
@ -1327,6 +1327,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations:
|
||||||
let prop = match_wrap_declared! { long,
|
let prop = match_wrap_declared! { long,
|
||||||
MozUserModify => longhands::_moz_user_modify::SpecifiedValue::from_gecko_keyword(value),
|
MozUserModify => longhands::_moz_user_modify::SpecifiedValue::from_gecko_keyword(value),
|
||||||
// TextEmphasisPosition => FIXME implement text-emphasis-position
|
// TextEmphasisPosition => FIXME implement text-emphasis-position
|
||||||
|
Direction => longhands::direction::SpecifiedValue::from_gecko_keyword(value),
|
||||||
Display => longhands::display::SpecifiedValue::from_gecko_keyword(value),
|
Display => longhands::display::SpecifiedValue::from_gecko_keyword(value),
|
||||||
Float => longhands::float::SpecifiedValue::from_gecko_keyword(value),
|
Float => longhands::float::SpecifiedValue::from_gecko_keyword(value),
|
||||||
VerticalAlign => longhands::vertical_align::SpecifiedValue::from_gecko_keyword(value),
|
VerticalAlign => longhands::vertical_align::SpecifiedValue::from_gecko_keyword(value),
|
||||||
|
@ -1337,7 +1338,10 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations:
|
||||||
// We rely on Gecko passing in font-size values (0...7) here.
|
// We rely on Gecko passing in font-size values (0...7) here.
|
||||||
longhands::font_size::SpecifiedValue::from_html_size(value as u8)
|
longhands::font_size::SpecifiedValue::from_html_size(value as u8)
|
||||||
},
|
},
|
||||||
|
FontStyle => longhands::font_style::SpecifiedValue::from_gecko_keyword(value),
|
||||||
|
FontWeight => longhands::font_weight::SpecifiedValue::from_gecko_keyword(value),
|
||||||
ListStyleType => longhands::list_style_type::SpecifiedValue::from_gecko_keyword(value),
|
ListStyleType => longhands::list_style_type::SpecifiedValue::from_gecko_keyword(value),
|
||||||
|
MozMathVariant => longhands::_moz_math_variant::SpecifiedValue::from_gecko_keyword(value),
|
||||||
WhiteSpace => longhands::white_space::SpecifiedValue::from_gecko_keyword(value),
|
WhiteSpace => longhands::white_space::SpecifiedValue::from_gecko_keyword(value),
|
||||||
CaptionSide => longhands::caption_side::SpecifiedValue::from_gecko_keyword(value),
|
CaptionSide => longhands::caption_side::SpecifiedValue::from_gecko_keyword(value),
|
||||||
BorderTopStyle => BorderStyle::from_gecko_keyword(value),
|
BorderTopStyle => BorderStyle::from_gecko_keyword(value),
|
||||||
|
@ -1355,11 +1359,14 @@ pub extern "C" fn Servo_DeclarationBlock_SetIntValue(declarations: RawServoDecla
|
||||||
property: nsCSSPropertyID,
|
property: nsCSSPropertyID,
|
||||||
value: i32) {
|
value: i32) {
|
||||||
use style::properties::{PropertyDeclaration, LonghandId};
|
use style::properties::{PropertyDeclaration, LonghandId};
|
||||||
|
use style::properties::longhands::_moz_script_level::SpecifiedValue as MozScriptLevel;
|
||||||
use style::properties::longhands::_x_span::computed_value::T as Span;
|
use style::properties::longhands::_x_span::computed_value::T as Span;
|
||||||
|
|
||||||
let long = get_longhand_from_id!(property);
|
let long = get_longhand_from_id!(property);
|
||||||
let prop = match_wrap_declared! { long,
|
let prop = match_wrap_declared! { long,
|
||||||
XSpan => Span(value),
|
XSpan => Span(value),
|
||||||
|
// Gecko uses Integer values to signal that it is relative
|
||||||
|
MozScriptLevel => MozScriptLevel::Relative(value),
|
||||||
};
|
};
|
||||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
decls.push(prop, Importance::Normal);
|
decls.push(prop, Importance::Normal);
|
||||||
|
@ -1406,13 +1413,68 @@ 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]
|
||||||
|
pub extern "C" fn Servo_DeclarationBlock_SetNumberValue(declarations:
|
||||||
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
property: nsCSSPropertyID,
|
||||||
|
value: f32) {
|
||||||
|
use style::properties::{PropertyDeclaration, LonghandId};
|
||||||
|
use style::properties::longhands::_moz_script_level::SpecifiedValue as MozScriptLevel;
|
||||||
|
|
||||||
|
let long = get_longhand_from_id!(property);
|
||||||
|
|
||||||
|
let prop = match_wrap_declared! { long,
|
||||||
|
MozScriptSizeMultiplier => value,
|
||||||
|
// Gecko uses Number values to signal that it is absolute
|
||||||
|
MozScriptLevel => MozScriptLevel::Absolute(value as i32),
|
||||||
|
};
|
||||||
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
|
decls.push(prop, Importance::Normal);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations:
|
pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
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);
|
||||||
|
@ -1424,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);
|
||||||
|
@ -1521,6 +1584,33 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_DeclarationBlock_SetBackgroundImage(declarations:
|
||||||
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
value: *const nsAString,
|
||||||
|
raw_extra_data: *mut URLExtraData) {
|
||||||
|
use style::properties::PropertyDeclaration;
|
||||||
|
use style::properties::longhands::background_image::SpecifiedValue as BackgroundImage;
|
||||||
|
use style::properties::longhands::background_image::single_value::SpecifiedValue as SingleBackgroundImage;
|
||||||
|
use style::values::specified::image::Image;
|
||||||
|
use style::values::specified::url::SpecifiedUrl;
|
||||||
|
|
||||||
|
let url_data = unsafe { RefPtr::from_ptr_ref(&raw_extra_data) };
|
||||||
|
let string = unsafe { (*value).to_string() };
|
||||||
|
let error_reporter = StdoutErrorReporter;
|
||||||
|
let context = ParserContext::new(Origin::Author, url_data, &error_reporter, Some(CssRuleType::Style));
|
||||||
|
if let Ok(url) = SpecifiedUrl::parse_from_string(string.into(), &context) {
|
||||||
|
let decl = PropertyDeclaration::BackgroundImage(BackgroundImage(
|
||||||
|
vec![SingleBackgroundImage(
|
||||||
|
Some(Image::Url(url))
|
||||||
|
)]
|
||||||
|
));
|
||||||
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
|
decls.push(decl, Importance::Normal);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarations:
|
pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarations:
|
||||||
RawServoDeclarationBlockBorrowed) {
|
RawServoDeclarationBlockBorrowed) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue