Merge branch 'master' into calc

This commit is contained in:
Simon Sapin 2015-09-01 18:39:16 +02:00
commit 80d471d5cf
400 changed files with 8129 additions and 11782 deletions

View file

@ -51,7 +51,7 @@ class Longhand(object):
self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident)
self.style_struct = THIS_STYLE_STRUCT
self.experimental = experimental
self.experimental = ("layout.%s.enabled" % name) if experimental else None
self.custom_cascade = custom_cascade
if derived_from is None:
self.derived_from = None
@ -64,7 +64,7 @@ class Shorthand(object):
self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident)
self.derived_from = None
self.experimental = experimental
self.experimental = ("layout.%s.enabled" % name) if experimental else None
self.sub_properties = [LONGHANDS_BY_NAME[s] for s in sub_properties]
class StyleStruct(object):
@ -450,7 +450,9 @@ pub mod longhands {
% for value in values[:-1]:
"${value}" => {
% if value in experimental_values:
if !::util::opts::experimental_enabled() { return Err(()) }
if !::util::prefs::get_pref("layout.${value}.enabled", false) {
return Err(())
}
% endif
Ok(computed_value::T::${to_rust_ident(value)})
},
@ -458,7 +460,9 @@ pub mod longhands {
% for value in values[-1:]:
"${value}" => {
% if value in experimental_values:
if !::util::opts::experimental_enabled() { return Err(()) }
if !::util::prefs::get_pref("layout.${value}.enabled", false) {
return Err(())
}
% endif
Ok(computed_value::T::${to_rust_ident(value)})
}
@ -5726,7 +5730,7 @@ impl PropertyDeclaration {
% if property.derived_from is None:
"${property.name}" => {
% if property.experimental:
if !::util::opts::experimental_enabled() {
if !::util::prefs::get_pref("${property.experimental}", false) {
return PropertyDeclarationParseResult::ExperimentalProperty
}
% endif
@ -5745,7 +5749,7 @@ impl PropertyDeclaration {
% for shorthand in SHORTHANDS:
"${shorthand.name}" => {
% if shorthand.experimental:
if !::util::opts::experimental_enabled() {
if !::util::prefs::get_pref("${shorthand.experimental}", false) {
return PropertyDeclarationParseResult::ExperimentalProperty
}
% endif
@ -6587,6 +6591,9 @@ macro_rules! css_properties_accessors {
$macro_name! {
% for property in SHORTHANDS + LONGHANDS:
% if property.derived_from is None:
% if '-' in property.name:
[${property.ident.capitalize()}, Set${property.ident.capitalize()}, "${property.name}"],
% endif
% if property != LONGHANDS[-1]:
[${property.camel_case}, Set${property.camel_case}, "${property.name}"],
% else:

View file

@ -429,7 +429,7 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
Ok(AtRuleType::WithBlock(AtRulePrelude::FontFace))
},
"viewport" => {
if ::util::opts::experimental_enabled() {
if ::util::prefs::get_pref("layout.viewport.enabled", false) {
Ok(AtRuleType::WithBlock(AtRulePrelude::Viewport))
} else {
Err(())

View file

@ -151,6 +151,7 @@ pub mod specified {
pub enum FontRelativeLength {
Em(CSSFloat),
Ex(CSSFloat),
Ch(CSSFloat),
Rem(CSSFloat)
}
@ -159,6 +160,7 @@ pub mod specified {
match self {
&FontRelativeLength::Em(length) => write!(dest, "{}em", length),
&FontRelativeLength::Ex(length) => write!(dest, "{}ex", length),
&FontRelativeLength::Ch(length) => write!(dest, "{}ch", length),
&FontRelativeLength::Rem(length) => write!(dest, "{}rem", length)
}
}
@ -172,9 +174,10 @@ pub mod specified {
{
match self {
&FontRelativeLength::Em(length) => reference_font_size.scale_by(length),
&FontRelativeLength::Ex(length) => {
let x_height = 0.5; // TODO: find that from the font
reference_font_size.scale_by(length * x_height)
&FontRelativeLength::Ex(length) | &FontRelativeLength::Ch(length) => {
// https://github.com/servo/servo/issues/7462
let em_factor = 0.5;
reference_font_size.scale_by(length * em_factor)
},
&FontRelativeLength::Rem(length) => root_font_size.scale_by(length)
}
@ -284,6 +287,7 @@ pub mod specified {
match self {
FontRelativeLength::Em(v) => FontRelativeLength::Em(v * scalar),
FontRelativeLength::Ex(v) => FontRelativeLength::Ex(v * scalar),
FontRelativeLength::Ch(v) => FontRelativeLength::Ch(v * scalar),
FontRelativeLength::Rem(v) => FontRelativeLength::Rem(v * scalar),
}
}
@ -338,6 +342,7 @@ pub mod specified {
// font-relative
"em" => Ok(Length::FontRelative(FontRelativeLength::Em(value))),
"ex" => Ok(Length::FontRelative(FontRelativeLength::Ex(value))),
"ch" => Ok(Length::FontRelative(FontRelativeLength::Ch(value))),
"rem" => Ok(Length::FontRelative(FontRelativeLength::Rem(value))),
// viewport percentages
"vw" => Ok(Length::ViewportPercentage(ViewportPercentageLength::Vw(value))),