mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +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
|
@ -2,10 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
<%!
|
||||
from data import Keyword, to_rust_ident, to_camel_case
|
||||
from data import LOGICAL_SIDES, PHYSICAL_SIDES, LOGICAL_SIZES, SYSTEM_FONT_LONGHANDS
|
||||
%>
|
||||
<%! from data import Keyword, to_rust_ident, to_camel_case, LOGICAL_SIDES, PHYSICAL_SIDES, LOGICAL_SIZES %>
|
||||
|
||||
<%def name="predefined_type(name, type, initial_value, parse_method='parse',
|
||||
needs_context=True, vector=False, initial_specified_value=None, **kwargs)">
|
||||
|
@ -202,6 +199,7 @@
|
|||
% endif
|
||||
</%call>
|
||||
</%def>
|
||||
|
||||
<%def name="longhand(*args, **kwargs)">
|
||||
<%
|
||||
property = data.declare_longhand(*args, **kwargs)
|
||||
|
@ -267,11 +265,6 @@
|
|||
<% maybe_wm = ", wm" if property.logical else "" %>
|
||||
match *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);
|
||||
% if property.ident == "font_size":
|
||||
if let longhands::font_size::SpecifiedValue::Keyword(kw, fraction)
|
||||
|
@ -400,110 +393,6 @@
|
|||
}
|
||||
</%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)">
|
||||
<%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)):
|
||||
|
@ -537,12 +426,10 @@
|
|||
</%call>
|
||||
</%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:
|
||||
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")]
|
||||
impl ${type} {
|
||||
|
@ -551,55 +438,26 @@
|
|||
/// Intended for use with presentation attributes, not style structs
|
||||
pub fn from_gecko_keyword(kw: u32) -> Self {
|
||||
use gecko_bindings::structs;
|
||||
% for value in values:
|
||||
// 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} {
|
||||
% if keyword.gecko_enum_prefix:
|
||||
% 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
|
||||
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
|
||||
}
|
||||
}
|
||||
}
|
||||
</%def>
|
||||
|
||||
<%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};
|
||||
match kw {
|
||||
% for value in values:
|
||||
${to_rust_ident(value).upper()} => ${type}::${to_rust_ident(value)},
|
||||
% endfor
|
||||
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
|
||||
}
|
||||
% endfor
|
||||
bits
|
||||
}
|
||||
|
||||
pub fn to_gecko_keyword(self) -> ${kw_type} {
|
||||
% for gecko_bit in bit_map.values():
|
||||
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};
|
||||
% else:
|
||||
match kw {
|
||||
% for value in values:
|
||||
structs::${keyword.gecko_constant(value)} => ${type}::${to_rust_ident(value)},
|
||||
% endfor
|
||||
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
|
||||
}
|
||||
% endfor
|
||||
bits
|
||||
% endif
|
||||
}
|
||||
}
|
||||
</%def>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue