mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Revert #16517 for Gecko heap write hazard failures.
This commit is contained in:
parent
2f8d9013a0
commit
408100818d
11 changed files with 192 additions and 858 deletions
|
@ -468,7 +468,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::FontFamily(
|
PropertyDeclaration::FontFamily(
|
||||||
font_family::SpecifiedValue::Values(vec![
|
font_family::computed_value::T(vec![
|
||||||
font_family::computed_value::FontFamily::from_atom(
|
font_family::computed_value::FontFamily::from_atom(
|
||||||
font_family)]))));
|
font_family)]))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,9 +695,6 @@ extern "C" {
|
||||||
pub fn Gecko_Atomize(aString: *const ::std::os::raw::c_char, aLength: u32)
|
pub fn Gecko_Atomize(aString: *const ::std::os::raw::c_char, aLength: u32)
|
||||||
-> *mut nsIAtom;
|
-> *mut nsIAtom;
|
||||||
}
|
}
|
||||||
extern "C" {
|
|
||||||
pub fn Gecko_Atomize16(aString: *const nsAString) -> *mut nsIAtom;
|
|
||||||
}
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_AddRefAtom(aAtom: *mut nsIAtom);
|
pub fn Gecko_AddRefAtom(aAtom: *mut nsIAtom);
|
||||||
}
|
}
|
||||||
|
@ -734,14 +731,6 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyFontFamilyFrom(dst: *mut nsFont, src: *const nsFont);
|
pub fn Gecko_CopyFontFamilyFrom(dst: *mut nsFont, src: *const nsFont);
|
||||||
}
|
}
|
||||||
extern "C" {
|
|
||||||
pub fn Gecko_nsFont_InitSystem(dst: *mut nsFont, font_id: i32,
|
|
||||||
font: *const nsStyleFont,
|
|
||||||
pres_context: RawGeckoPresContextBorrowed);
|
|
||||||
}
|
|
||||||
extern "C" {
|
|
||||||
pub fn Gecko_nsFont_Destroy(dst: *mut nsFont);
|
|
||||||
}
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_SetImageOrientation(aVisibility: *mut nsStyleVisibility,
|
pub fn Gecko_SetImageOrientation(aVisibility: *mut nsStyleVisibility,
|
||||||
aRadians: f64, aFlip: bool);
|
aRadians: f64, aFlip: bool);
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
|
|
||||||
use gecko_bindings::bindings::Gecko_AddRefAtom;
|
use gecko_bindings::bindings::Gecko_AddRefAtom;
|
||||||
use gecko_bindings::bindings::Gecko_Atomize;
|
use gecko_bindings::bindings::Gecko_Atomize;
|
||||||
use gecko_bindings::bindings::Gecko_Atomize16;
|
|
||||||
use gecko_bindings::bindings::Gecko_ReleaseAtom;
|
use gecko_bindings::bindings::Gecko_ReleaseAtom;
|
||||||
use gecko_bindings::structs::nsIAtom;
|
use gecko_bindings::structs::nsIAtom;
|
||||||
use nsstring::nsAString;
|
|
||||||
use precomputed_hash::PrecomputedHash;
|
use precomputed_hash::PrecomputedHash;
|
||||||
use std::borrow::{Cow, Borrow};
|
use std::borrow::{Cow, Borrow};
|
||||||
use std::char::{self, DecodeUtf16};
|
use std::char::{self, DecodeUtf16};
|
||||||
|
@ -283,17 +281,6 @@ impl<'a> From<&'a str> for Atom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a nsAString> for Atom {
|
|
||||||
#[inline]
|
|
||||||
fn from(string: &nsAString) -> Atom {
|
|
||||||
unsafe {
|
|
||||||
Atom(WeakAtom::new(
|
|
||||||
Gecko_Atomize16(string)
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> From<Cow<'a, str>> for Atom {
|
impl<'a> From<Cow<'a, str>> for Atom {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(string: Cow<'a, str>) -> Atom {
|
fn from(string: Cow<'a, str>) -> Atom {
|
||||||
|
|
|
@ -13,13 +13,6 @@ LOGICAL_SIZES = ["block-size", "inline-size"]
|
||||||
ALL_SIDES = [(side, False) for side in PHYSICAL_SIDES] + [(side, True) for side in LOGICAL_SIDES]
|
ALL_SIDES = [(side, False) for side in PHYSICAL_SIDES] + [(side, True) for side in LOGICAL_SIDES]
|
||||||
ALL_SIZES = [(size, False) for size in PHYSICAL_SIZES] + [(size, True) for size in LOGICAL_SIZES]
|
ALL_SIZES = [(size, False) for size in PHYSICAL_SIZES] + [(size, True) for size in LOGICAL_SIZES]
|
||||||
|
|
||||||
SYSTEM_FONT_LONGHANDS = """font_family font_size font_style
|
|
||||||
font_variant_caps font_stretch font_kerning
|
|
||||||
font_variant_position font_weight
|
|
||||||
font_size_adjust font_variant_alternates
|
|
||||||
font_variant_ligatures font_variant_east_asian
|
|
||||||
font_variant_numeric font_language_override""".split()
|
|
||||||
|
|
||||||
|
|
||||||
def maybe_moz_logical_alias(product, side, prop):
|
def maybe_moz_logical_alias(product, side, prop):
|
||||||
if product == "gecko" and side[1]:
|
if product == "gecko" and side[1]:
|
||||||
|
@ -40,11 +33,6 @@ def to_camel_case(ident):
|
||||||
return re.sub("(^|_|-)([a-z])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
|
return re.sub("(^|_|-)([a-z])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
|
||||||
|
|
||||||
|
|
||||||
def to_camel_case_lower(ident):
|
|
||||||
camel = to_camel_case(ident)
|
|
||||||
return camel[0].lower() + camel[1:]
|
|
||||||
|
|
||||||
|
|
||||||
def parse_aliases(value):
|
def parse_aliases(value):
|
||||||
aliases = {}
|
aliases = {}
|
||||||
for pair in value.split():
|
for pair in value.split():
|
||||||
|
|
|
@ -95,8 +95,6 @@ pub struct ComputedValues {
|
||||||
/// When this is Some, we compute font sizes by computing the keyword against
|
/// When this is Some, we compute font sizes by computing the keyword against
|
||||||
/// the generic font, and then multiplying it by the ratio.
|
/// the generic font, and then multiplying it by the ratio.
|
||||||
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
|
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
|
||||||
/// The cached system font. See longhand/font.mako.rs
|
|
||||||
pub cached_system_font: Option<longhands::system_font::ComputedSystemFont>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComputedValues {
|
impl ComputedValues {
|
||||||
|
@ -106,7 +104,6 @@ impl ComputedValues {
|
||||||
writing_mode: parent.writing_mode,
|
writing_mode: parent.writing_mode,
|
||||||
root_font_size: parent.root_font_size,
|
root_font_size: parent.root_font_size,
|
||||||
font_size_keyword: parent.font_size_keyword,
|
font_size_keyword: parent.font_size_keyword,
|
||||||
cached_system_font: None,
|
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
% if style_struct.inherited:
|
% if style_struct.inherited:
|
||||||
${style_struct.ident}: parent.${style_struct.ident}.clone(),
|
${style_struct.ident}: parent.${style_struct.ident}.clone(),
|
||||||
|
@ -129,7 +126,6 @@ impl ComputedValues {
|
||||||
custom_properties: custom_properties,
|
custom_properties: custom_properties,
|
||||||
writing_mode: writing_mode,
|
writing_mode: writing_mode,
|
||||||
root_font_size: root_font_size,
|
root_font_size: root_font_size,
|
||||||
cached_system_font: None,
|
|
||||||
font_size_keyword: font_size_keyword,
|
font_size_keyword: font_size_keyword,
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
${style_struct.ident}: ${style_struct.ident},
|
${style_struct.ident}: ${style_struct.ident},
|
||||||
|
@ -143,7 +139,6 @@ impl ComputedValues {
|
||||||
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||||
root_font_size: longhands::font_size::get_initial_value(), // FIXME(bz): Also seems dubious?
|
root_font_size: longhands::font_size::get_initial_value(), // FIXME(bz): Also seems dubious?
|
||||||
font_size_keyword: Some((Default::default(), 1.)),
|
font_size_keyword: Some((Default::default(), 1.)),
|
||||||
cached_system_font: None,
|
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
${style_struct.ident}: style_structs::${style_struct.name}::default(pres_context),
|
${style_struct.ident}: style_structs::${style_struct.name}::default(pres_context),
|
||||||
% endfor
|
% endfor
|
||||||
|
@ -299,6 +294,27 @@ def set_gecko_property(ffi_name, expr):
|
||||||
}
|
}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%def name="impl_bitflags_setter(ident, gecko_ffi_name, bit_map, gecko_bit_prefix, cast_type='u8')">
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||||
|
% for gecko_bit in bit_map.values():
|
||||||
|
use gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
|
||||||
|
% endfor
|
||||||
|
|
||||||
|
let mut bits: ${cast_type} = 0;
|
||||||
|
// FIXME: if we ensure that the Servo bitflags storage is the same
|
||||||
|
// as Gecko's one, we can just copy it.
|
||||||
|
% for servo_bit, gecko_bit in bit_map.iteritems():
|
||||||
|
if v.contains(longhands::${ident}::${servo_bit}) {
|
||||||
|
bits |= ${gecko_bit_prefix}${gecko_bit} as ${cast_type};
|
||||||
|
}
|
||||||
|
% endfor
|
||||||
|
|
||||||
|
self.gecko.${gecko_ffi_name} = bits as ${cast_type};
|
||||||
|
}
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
/// Convert a Servo color into an nscolor; with currentColor as 0
|
/// Convert a Servo color into an nscolor; with currentColor as 0
|
||||||
///
|
///
|
||||||
/// Call sites will need to be updated after https://bugzilla.mozilla.org/show_bug.cgi?id=760345
|
/// Call sites will need to be updated after https://bugzilla.mozilla.org/show_bug.cgi?id=760345
|
||||||
|
@ -1415,10 +1431,20 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
${impl_simple_copy('font_language_override', 'mFont.languageOverride')}
|
${impl_simple_copy('font_language_override', 'mFont.languageOverride')}
|
||||||
|
|
||||||
pub fn set_font_variant_alternates(&mut self, v: longhands::font_variant_alternates::computed_value::T) {
|
<% font_variant_alternates_map = { "HISTORICAL_FORMS": "HISTORICAL",
|
||||||
self.gecko.mFont.variantAlternates = v.to_gecko_keyword()
|
"STYLISTIC": "STYLISTIC",
|
||||||
}
|
"STYLESET": "STYLESET",
|
||||||
|
"CHARACTER_VARIANT": "CHARACTER_VARIANT",
|
||||||
|
"SWASH": "SWASH",
|
||||||
|
"ORNAMENTS": "ORNAMENTS",
|
||||||
|
"ANNOTATION": "ANNOTATION" } %>
|
||||||
|
// FIXME: Set alternateValues as well.
|
||||||
|
// self.gecko.mFont.alternateValues = xxx;
|
||||||
|
${impl_bitflags_setter('font_variant_alternates',
|
||||||
|
'mFont.variantAlternates',
|
||||||
|
font_variant_alternates_map,
|
||||||
|
'NS_FONT_VARIANT_ALTERNATES_',
|
||||||
|
cast_type='u16')}
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn copy_font_variant_alternates_from(&mut self, other: &Self) {
|
pub fn copy_font_variant_alternates_from(&mut self, other: &Self) {
|
||||||
self.gecko.mFont.variantAlternates = other.gecko.mFont.variantAlternates;
|
self.gecko.mFont.variantAlternates = other.gecko.mFont.variantAlternates;
|
||||||
|
@ -1426,22 +1452,53 @@ fn static_assert() {
|
||||||
// self.gecko.mFont.alternateValues = other.gecko.mFont.alternateValues;
|
// self.gecko.mFont.alternateValues = other.gecko.mFont.alternateValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_font_variant_ligatures(&mut self, v: longhands::font_variant_ligatures::computed_value::T) {
|
// servo_bit: gecko_bit
|
||||||
self.gecko.mFont.variantLigatures = v.to_gecko_keyword()
|
<% font_variant_ligatures_map = { "NONE": "NONE",
|
||||||
}
|
"COMMON_LIGATURES": "COMMON",
|
||||||
|
"NO_COMMON_LIGATURES": "NO_COMMON",
|
||||||
|
"DISCRETIONARY_LIGATURES": "DISCRETIONARY",
|
||||||
|
"NO_DISCRETIONARY_LIGATURES": "NO_DISCRETIONARY",
|
||||||
|
"HISTORICAL_LIGATURES": "HISTORICAL",
|
||||||
|
"NO_HISTORICAL_LIGATURES": "NO_HISTORICAL",
|
||||||
|
"CONTEXTUAL": "CONTEXTUAL",
|
||||||
|
"NO_CONTEXTUAL": "NO_CONTEXTUAL" } %>
|
||||||
|
${impl_bitflags_setter('font_variant_ligatures',
|
||||||
|
'mFont.variantLigatures',
|
||||||
|
font_variant_ligatures_map,
|
||||||
|
'NS_FONT_VARIANT_LIGATURES_',
|
||||||
|
cast_type='u16')}
|
||||||
${impl_simple_copy('font_variant_ligatures', 'mFont.variantLigatures')}
|
${impl_simple_copy('font_variant_ligatures', 'mFont.variantLigatures')}
|
||||||
|
|
||||||
pub fn set_font_variant_east_asian(&mut self, v: longhands::font_variant_east_asian::computed_value::T) {
|
// servo_bit: gecko_bit
|
||||||
self.gecko.mFont.variantEastAsian = v.to_gecko_keyword()
|
<% font_variant_east_asian_map = { "JIS78": "JIS78",
|
||||||
}
|
"JIS83": "JIS83",
|
||||||
|
"JIS90": "JIS90",
|
||||||
|
"JIS04": "JIS04",
|
||||||
|
"SIMPLIFIED": "SIMPLIFIED",
|
||||||
|
"TRADITIONAL": "TRADITIONAL",
|
||||||
|
"FULL_WIDTH": "FULL_WIDTH",
|
||||||
|
"PROPORTIONAL_WIDTH": "PROP_WIDTH",
|
||||||
|
"RUBY": "RUBY" } %>
|
||||||
|
${impl_bitflags_setter('font_variant_east_asian',
|
||||||
|
'mFont.variantEastAsian',
|
||||||
|
font_variant_east_asian_map,
|
||||||
|
'NS_FONT_VARIANT_EAST_ASIAN_',
|
||||||
|
cast_type='u16')}
|
||||||
${impl_simple_copy('font_variant_east_asian', 'mFont.variantEastAsian')}
|
${impl_simple_copy('font_variant_east_asian', 'mFont.variantEastAsian')}
|
||||||
|
|
||||||
pub fn set_font_variant_numeric(&mut self, v: longhands::font_variant_numeric::computed_value::T) {
|
// servo_bit: gecko_bit
|
||||||
self.gecko.mFont.variantNumeric = v.to_gecko_keyword()
|
<% font_variant_numeric_map = { "LINING_NUMS": "LINING",
|
||||||
}
|
"OLDSTYLE_NUMS": "OLDSTYLE",
|
||||||
|
"PROPORTIONAL_NUMS": "PROPORTIONAL",
|
||||||
|
"TABULAR_NUMS": "TABULAR",
|
||||||
|
"DIAGONAL_FRACTIONS": "DIAGONAL_FRACTIONS",
|
||||||
|
"STACKED_FRACTIONS": "STACKED_FRACTIONS",
|
||||||
|
"SLASHED_ZERO": "SLASHZERO",
|
||||||
|
"ORDINAL": "ORDINAL" } %>
|
||||||
|
${impl_bitflags_setter('font_variant_numeric',
|
||||||
|
'mFont.variantNumeric',
|
||||||
|
font_variant_numeric_map,
|
||||||
|
'NS_FONT_VARIANT_NUMERIC_')}
|
||||||
${impl_simple_copy('font_variant_numeric', 'mFont.variantNumeric')}
|
${impl_simple_copy('font_variant_numeric', 'mFont.variantNumeric')}
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
<%!
|
<%! from data import Keyword, to_rust_ident, to_camel_case, LOGICAL_SIDES, PHYSICAL_SIDES, LOGICAL_SIZES %>
|
||||||
from data import Keyword, to_rust_ident, to_camel_case
|
|
||||||
from data import LOGICAL_SIDES, PHYSICAL_SIDES, LOGICAL_SIZES, SYSTEM_FONT_LONGHANDS
|
|
||||||
%>
|
|
||||||
|
|
||||||
<%def name="predefined_type(name, type, initial_value, parse_method='parse',
|
<%def name="predefined_type(name, type, initial_value, parse_method='parse',
|
||||||
needs_context=True, vector=False, initial_specified_value=None, **kwargs)">
|
needs_context=True, vector=False, initial_specified_value=None, **kwargs)">
|
||||||
|
@ -202,6 +199,7 @@
|
||||||
% endif
|
% endif
|
||||||
</%call>
|
</%call>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="longhand(*args, **kwargs)">
|
<%def name="longhand(*args, **kwargs)">
|
||||||
<%
|
<%
|
||||||
property = data.declare_longhand(*args, **kwargs)
|
property = data.declare_longhand(*args, **kwargs)
|
||||||
|
@ -267,11 +265,6 @@
|
||||||
<% maybe_wm = ", wm" if property.logical else "" %>
|
<% maybe_wm = ", wm" if property.logical else "" %>
|
||||||
match *value {
|
match *value {
|
||||||
DeclaredValue::Value(ref specified_value) => {
|
DeclaredValue::Value(ref specified_value) => {
|
||||||
% if property.ident in SYSTEM_FONT_LONGHANDS and product == "gecko":
|
|
||||||
if let Some(sf) = specified_value.get_system() {
|
|
||||||
longhands::system_font::resolve_system_font(sf, context);
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
let computed = specified_value.to_computed_value(context);
|
let computed = specified_value.to_computed_value(context);
|
||||||
% if property.ident == "font_size":
|
% if property.ident == "font_size":
|
||||||
if let longhands::font_size::SpecifiedValue::Keyword(kw, fraction)
|
if let longhands::font_size::SpecifiedValue::Keyword(kw, fraction)
|
||||||
|
@ -400,110 +393,6 @@
|
||||||
}
|
}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="single_keyword_system(name, values, **kwargs)">
|
|
||||||
<%
|
|
||||||
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
|
|
||||||
'gecko_constant_prefix', 'gecko_enum_prefix',
|
|
||||||
'extra_gecko_values', 'extra_servo_values',
|
|
||||||
'custom_consts', 'gecko_inexhaustive',
|
|
||||||
]}
|
|
||||||
keyword = keyword=Keyword(name, values, **keyword_kwargs)
|
|
||||||
%>
|
|
||||||
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
|
|
||||||
use values::HasViewportPercentage;
|
|
||||||
use properties::longhands::system_font::SystemFont;
|
|
||||||
use std::fmt;
|
|
||||||
use style_traits::ToCss;
|
|
||||||
no_viewport_percentage!(SpecifiedValue);
|
|
||||||
|
|
||||||
pub mod computed_value {
|
|
||||||
use cssparser::Parser;
|
|
||||||
use parser::{Parse, ParserContext};
|
|
||||||
|
|
||||||
use style_traits::ToCss;
|
|
||||||
define_css_keyword_enum! { T:
|
|
||||||
% for value in keyword.values_for(product):
|
|
||||||
"${value}" => ${to_rust_ident(value)},
|
|
||||||
% endfor
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for T {
|
|
||||||
fn parse(_: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
|
||||||
T::parse(input)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
${gecko_keyword_conversion(keyword, keyword.values_for(product), type="T", cast_to="i32")}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
|
||||||
pub enum SpecifiedValue {
|
|
||||||
Keyword(computed_value::T),
|
|
||||||
System(SystemFont),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToCss for SpecifiedValue {
|
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
|
||||||
match *self {
|
|
||||||
SpecifiedValue::Keyword(k) => k.to_css(dest),
|
|
||||||
SpecifiedValue::System(_) => Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
|
||||||
Ok(SpecifiedValue::Keyword(computed_value::T::parse(input)?))
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToComputedValue for SpecifiedValue {
|
|
||||||
type ComputedValue = computed_value::T;
|
|
||||||
fn to_computed_value(&self, _cx: &Context) -> Self::ComputedValue {
|
|
||||||
match *self {
|
|
||||||
SpecifiedValue::Keyword(v) => v,
|
|
||||||
SpecifiedValue::System(_) => {
|
|
||||||
% if product == "gecko":
|
|
||||||
_cx.style.cached_system_font.as_ref().unwrap().${to_rust_ident(name)}
|
|
||||||
% else:
|
|
||||||
unreachable!()
|
|
||||||
% endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn from_computed_value(other: &computed_value::T) -> Self {
|
|
||||||
SpecifiedValue::Keyword(*other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<computed_value::T> for SpecifiedValue {
|
|
||||||
fn from(other: computed_value::T) -> Self {
|
|
||||||
SpecifiedValue::Keyword(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
|
||||||
computed_value::T::${to_rust_ident(values.split()[0])}
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
|
||||||
SpecifiedValue::Keyword(computed_value::T::${to_rust_ident(values.split()[0])})
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SpecifiedValue {
|
|
||||||
pub fn system_font(f: SystemFont) -> Self {
|
|
||||||
SpecifiedValue::System(f)
|
|
||||||
}
|
|
||||||
pub fn get_system(&self) -> Option<SystemFont> {
|
|
||||||
if let SpecifiedValue::System(s) = *self {
|
|
||||||
Some(s)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</%call>
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
<%def name="single_keyword(name, values, vector=False, **kwargs)">
|
<%def name="single_keyword(name, values, vector=False, **kwargs)">
|
||||||
<%call expr="single_keyword_computed(name, values, vector, **kwargs)">
|
<%call expr="single_keyword_computed(name, values, vector, **kwargs)">
|
||||||
% if not "extra_specified" in kwargs and ("aliases" in kwargs or (("extra_%s_aliases" % product) in kwargs)):
|
% if not "extra_specified" in kwargs and ("aliases" in kwargs or (("extra_%s_aliases" % product) in kwargs)):
|
||||||
|
@ -537,12 +426,10 @@
|
||||||
</%call>
|
</%call>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="gecko_keyword_conversion(keyword, values=None, type='SpecifiedValue', cast_to=None)">
|
<%def name="gecko_keyword_conversion(keyword, values=None, type='SpecifiedValue')">
|
||||||
<%
|
<%
|
||||||
if not values:
|
if not values:
|
||||||
values = keyword.values_for(product)
|
values = keyword.values_for(product)
|
||||||
maybe_cast = "as %s" % cast_to if cast_to else ""
|
|
||||||
const_type = cast_to if cast_to else "u32"
|
|
||||||
%>
|
%>
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl ${type} {
|
impl ${type} {
|
||||||
|
@ -551,55 +438,26 @@
|
||||||
/// Intended for use with presentation attributes, not style structs
|
/// Intended for use with presentation attributes, not style structs
|
||||||
pub fn from_gecko_keyword(kw: u32) -> Self {
|
pub fn from_gecko_keyword(kw: u32) -> Self {
|
||||||
use gecko_bindings::structs;
|
use gecko_bindings::structs;
|
||||||
% for value in values:
|
% if keyword.gecko_enum_prefix:
|
||||||
// We can't match on enum values if we're matching on a u32
|
|
||||||
const ${to_rust_ident(value).upper()}: ${const_type}
|
|
||||||
= structs::${keyword.gecko_constant(value)} as ${const_type};
|
|
||||||
% endfor
|
|
||||||
match kw ${maybe_cast} {
|
|
||||||
% for value in values:
|
% for value in values:
|
||||||
${to_rust_ident(value).upper()} => ${type}::${to_rust_ident(value)},
|
// We can't match on enum values if we're matching on a u32
|
||||||
|
const ${to_rust_ident(value).upper()}: u32
|
||||||
|
= structs::${keyword.gecko_enum_prefix}::${to_camel_case(value)} as u32;
|
||||||
% endfor
|
% endfor
|
||||||
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
|
match kw {
|
||||||
}
|
% for value in values:
|
||||||
}
|
${to_rust_ident(value).upper()} => ${type}::${to_rust_ident(value)},
|
||||||
}
|
% endfor
|
||||||
</%def>
|
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
|
||||||
|
|
||||||
<%def name="gecko_bitflags_conversion(bit_map, gecko_bit_prefix, type, kw_type='u8')">
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
impl ${type} {
|
|
||||||
/// Obtain a specified value from a Gecko keyword value
|
|
||||||
///
|
|
||||||
/// Intended for use with presentation attributes, not style structs
|
|
||||||
pub fn from_gecko_keyword(kw: ${kw_type}) -> Self {
|
|
||||||
% for gecko_bit in bit_map.values():
|
|
||||||
use gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
|
|
||||||
% endfor
|
|
||||||
|
|
||||||
let mut bits = ${type}::empty();
|
|
||||||
% for servo_bit, gecko_bit in bit_map.iteritems():
|
|
||||||
if kw & (${gecko_bit_prefix}${gecko_bit} as ${kw_type}) != 0 {
|
|
||||||
bits |= ${servo_bit};
|
|
||||||
}
|
}
|
||||||
% endfor
|
% else:
|
||||||
bits
|
match kw {
|
||||||
}
|
% for value in values:
|
||||||
|
structs::${keyword.gecko_constant(value)} => ${type}::${to_rust_ident(value)},
|
||||||
pub fn to_gecko_keyword(self) -> ${kw_type} {
|
% endfor
|
||||||
% for gecko_bit in bit_map.values():
|
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
|
||||||
use gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
|
|
||||||
% endfor
|
|
||||||
|
|
||||||
let mut bits: ${kw_type} = 0;
|
|
||||||
// FIXME: if we ensure that the Servo bitflags storage is the same
|
|
||||||
// as Gecko's one, we can just copy it.
|
|
||||||
% for servo_bit, gecko_bit in bit_map.iteritems():
|
|
||||||
if self.contains(${servo_bit}) {
|
|
||||||
bits |= ${gecko_bit_prefix}${gecko_bit} as ${kw_type};
|
|
||||||
}
|
}
|
||||||
% endfor
|
% endif
|
||||||
bits
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||||
|
|
||||||
<% from data import SYSTEM_FONT_LONGHANDS %>
|
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{Color as CSSParserColor, Parser, RGBA};
|
use cssparser::{Color as CSSParserColor, Parser, RGBA};
|
||||||
use euclid::{Point2D, Size2D};
|
use euclid::{Point2D, Size2D};
|
||||||
|
@ -360,8 +358,7 @@ impl AnimationValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct an AnimationValue from a property declaration
|
/// Construct an AnimationValue from a property declaration
|
||||||
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
pub fn from_declaration(decl: &PropertyDeclaration, context: &Context, initial: &ComputedValues) -> Option<Self> {
|
||||||
initial: &ComputedValues) -> Option<Self> {
|
|
||||||
use error_reporting::StdoutErrorReporter;
|
use error_reporting::StdoutErrorReporter;
|
||||||
use properties::LonghandId;
|
use properties::LonghandId;
|
||||||
use properties::DeclaredValue;
|
use properties::DeclaredValue;
|
||||||
|
@ -370,11 +367,6 @@ impl AnimationValue {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
PropertyDeclaration::${prop.camel_case}(ref val) => {
|
PropertyDeclaration::${prop.camel_case}(ref val) => {
|
||||||
% if prop.ident in SYSTEM_FONT_LONGHANDS and product == "gecko":
|
|
||||||
if let Some(sf) = val.get_system() {
|
|
||||||
longhands::system_font::resolve_system_font(sf, context);
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
Some(AnimationValue::${prop.camel_case}(val.to_computed_value(context)))
|
Some(AnimationValue::${prop.camel_case}(val.to_computed_value(context)))
|
||||||
},
|
},
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -93,8 +93,7 @@
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
${helpers.gecko_keyword_conversion(Keyword('display', ' '.join(values),
|
${helpers.gecko_keyword_conversion(Keyword('display', ' '.join(values),
|
||||||
gecko_enum_prefix='StyleDisplay',
|
gecko_enum_prefix='StyleDisplay'))}
|
||||||
gecko_strip_moz_prefix=False))}
|
|
||||||
|
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||||
<% from data import SYSTEM_FONT_LONGHANDS %>
|
|
||||||
|
|
||||||
<%helpers:shorthand name="font"
|
<%helpers:shorthand name="font"
|
||||||
sub_properties="font-style font-variant-caps font-weight font-stretch
|
sub_properties="font-style font-variant-caps font-weight font-stretch
|
||||||
|
@ -17,10 +16,8 @@
|
||||||
${'font-variant-position' if product == 'gecko' or data.testing else ''}
|
${'font-variant-position' if product == 'gecko' or data.testing else ''}
|
||||||
${'font-language-override' if product == 'gecko' or data.testing else ''}"
|
${'font-language-override' if product == 'gecko' or data.testing else ''}"
|
||||||
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font">
|
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font">
|
||||||
use properties::longhands::{font_family, font_style, font_weight, font_stretch};
|
use properties::longhands::{font_style, font_variant_caps, font_weight, font_stretch};
|
||||||
use properties::longhands::{font_size, line_height, font_variant_caps};
|
use properties::longhands::{font_size, line_height};
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
use properties::longhands::system_font::SystemFont;
|
|
||||||
<%
|
<%
|
||||||
gecko_sub_properties = "kerning language_override size_adjust \
|
gecko_sub_properties = "kerning language_override size_adjust \
|
||||||
variant_alternates variant_east_asian \
|
variant_alternates variant_east_asian \
|
||||||
|
@ -32,7 +29,7 @@
|
||||||
use properties::longhands::font_${prop};
|
use properties::longhands::font_${prop};
|
||||||
% endfor
|
% endfor
|
||||||
% endif
|
% endif
|
||||||
use self::font_family::SpecifiedValue as FontFamily;
|
use properties::longhands::font_family::SpecifiedValue as FontFamily;
|
||||||
|
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
let mut nb_normals = 0;
|
let mut nb_normals = 0;
|
||||||
|
@ -41,17 +38,6 @@
|
||||||
let mut weight = None;
|
let mut weight = None;
|
||||||
let mut stretch = None;
|
let mut stretch = None;
|
||||||
let size;
|
let size;
|
||||||
% if product == "gecko":
|
|
||||||
if let Ok(sys) = input.try(SystemFont::parse) {
|
|
||||||
return Ok(Longhands {
|
|
||||||
% for name in SYSTEM_FONT_LONGHANDS:
|
|
||||||
${name}: ${name}::SpecifiedValue::system_font(sys),
|
|
||||||
% endfor
|
|
||||||
// line-height is just reset to initial
|
|
||||||
line_height: line_height::get_initial_specified_value(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
loop {
|
loop {
|
||||||
// Special-case 'normal' because it is valid in each of
|
// Special-case 'normal' because it is valid in each of
|
||||||
// font-style, font-weight, font-variant and font-stretch.
|
// font-style, font-weight, font-variant and font-stretch.
|
||||||
|
@ -102,7 +88,7 @@
|
||||||
};
|
};
|
||||||
let family = FontFamily::parse(input)?;
|
let family = FontFamily::parse(input)?;
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
% for name in "style weight stretch size variant_caps".split():
|
% for name in "style variant_caps weight stretch size".split():
|
||||||
font_${name}: unwrap_or_initial!(font_${name}, ${name}),
|
font_${name}: unwrap_or_initial!(font_${name}, ${name}),
|
||||||
% endfor
|
% endfor
|
||||||
line_height: unwrap_or_initial!(line_height),
|
line_height: unwrap_or_initial!(line_height),
|
||||||
|
@ -115,51 +101,9 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
% if product == "gecko":
|
|
||||||
enum CheckSystemResult {
|
|
||||||
AllSystem(SystemFont),
|
|
||||||
SomeSystem,
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> LonghandsToSerialize<'a> {
|
|
||||||
/// Check if some or all members are system fonts
|
|
||||||
fn check_system(&self) -> CheckSystemResult {
|
|
||||||
let mut sys = None;
|
|
||||||
let mut all = true;
|
|
||||||
|
|
||||||
% for prop in SYSTEM_FONT_LONGHANDS:
|
|
||||||
if let Some(s) = self.${prop}.get_system() {
|
|
||||||
debug_assert!(sys.is_none() || s == sys.unwrap());
|
|
||||||
sys = Some(s);
|
|
||||||
} else {
|
|
||||||
all = false;
|
|
||||||
}
|
|
||||||
% endfor
|
|
||||||
if self.line_height != &line_height::get_initial_specified_value() {
|
|
||||||
all = false
|
|
||||||
}
|
|
||||||
if all {
|
|
||||||
CheckSystemResult::AllSystem(sys.unwrap())
|
|
||||||
} else if sys.is_some() {
|
|
||||||
CheckSystemResult::SomeSystem
|
|
||||||
} else {
|
|
||||||
CheckSystemResult::None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
|
|
||||||
// This may be a bit off, unsure, possibly needs changes
|
// This may be a bit off, unsure, possibly needs changes
|
||||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
% if product == "gecko":
|
|
||||||
match self.check_system() {
|
|
||||||
CheckSystemResult::AllSystem(sys) => return sys.to_css(dest),
|
|
||||||
CheckSystemResult::SomeSystem => return Ok(()),
|
|
||||||
CheckSystemResult::None => ()
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
|
|
||||||
% if product == "gecko" or data.testing:
|
% if product == "gecko" or data.testing:
|
||||||
% for name in gecko_sub_properties:
|
% for name in gecko_sub_properties:
|
||||||
|
|
|
@ -1393,7 +1393,7 @@ 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::computed_value::T::from_gecko_keyword(value).into(),
|
FontStyle => longhands::font_style::SpecifiedValue::from_gecko_keyword(value),
|
||||||
FontWeight => longhands::font_weight::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),
|
MozMathVariant => longhands::_moz_math_variant::SpecifiedValue::from_gecko_keyword(value),
|
||||||
|
@ -1631,7 +1631,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations:
|
||||||
let mut parser = Parser::new(&string);
|
let mut parser = Parser::new(&string);
|
||||||
if let Ok(family) = FontFamily::parse(&mut parser) {
|
if let Ok(family) = FontFamily::parse(&mut parser) {
|
||||||
if parser.is_exhausted() {
|
if parser.is_exhausted() {
|
||||||
let decl = PropertyDeclaration::FontFamily(Box::new(family));
|
let decl = PropertyDeclaration::FontFamily(family);
|
||||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
decls.push(decl, Importance::Normal);
|
decls.push(decl, Importance::Normal);
|
||||||
})
|
})
|
||||||
|
@ -1928,7 +1928,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
||||||
let default_values = data.default_computed_values();
|
let default_values = data.default_computed_values();
|
||||||
let metrics = get_metrics_provider_for_product();
|
let metrics = get_metrics_provider_for_product();
|
||||||
|
|
||||||
let mut context = Context {
|
let context = Context {
|
||||||
is_root_element: false,
|
is_root_element: false,
|
||||||
device: &data.stylist.device,
|
device: &data.stylist.device,
|
||||||
inherited_style: parent_style.unwrap_or(default_values),
|
inherited_style: parent_style.unwrap_or(default_values),
|
||||||
|
@ -1956,8 +1956,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
||||||
.filter_map(|&(ref decl, imp)| {
|
.filter_map(|&(ref decl, imp)| {
|
||||||
if imp == Importance::Normal {
|
if imp == Importance::Normal {
|
||||||
let property = TransitionProperty::from_declaration(decl);
|
let property = TransitionProperty::from_declaration(decl);
|
||||||
let animation = AnimationValue::from_declaration(decl, &mut context,
|
let animation = AnimationValue::from_declaration(decl, &context, default_values);
|
||||||
default_values);
|
|
||||||
debug_assert!(property.is_none() == animation.is_none(),
|
debug_assert!(property.is_none() == animation.is_none(),
|
||||||
"The failure condition of TransitionProperty::from_declaration \
|
"The failure condition of TransitionProperty::from_declaration \
|
||||||
and AnimationValue::from_declaration should be the same");
|
and AnimationValue::from_declaration should be the same");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue