servo: Merge #17517 - stylo: Implement font-language-override descriptor for @font-face rule (from canaltinova:font-lang-override); r=SimonSapin

Generally  we use computed values for `@font-face` rule descriptors but that descriptor is a bit different than the others in gecko side. It accepts strings instead of unsigned integer(which is computed value of this property). So we had to use SpecifiedValue for that in here.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1355364](https://bugzilla.mozilla.org/show_bug.cgi?id=1355364)

Source-Repo: https://github.com/servo/servo
Source-Revision: 2843eb5ddf0c8170854eb420774bd5a34bc6710d

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 16c60065370286715fd5a8459c7707b858e1504c
This commit is contained in:
Nazım Can Altınova 2017-06-27 11:35:33 -07:00
Родитель eaeb65f509
Коммит 57d89b1ef4
3 изменённых файлов: 27 добавлений и 2 удалений

Просмотреть файл

@ -17,6 +17,8 @@ use error_reporting::ContextualParseError;
#[cfg(feature = "gecko")] use gecko_bindings::structs::CSSFontFaceDescriptors; #[cfg(feature = "gecko")] use gecko_bindings::structs::CSSFontFaceDescriptors;
#[cfg(feature = "gecko")] use cssparser::UnicodeRange; #[cfg(feature = "gecko")] use cssparser::UnicodeRange;
use parser::{ParserContext, log_css_error, Parse}; use parser::{ParserContext, log_css_error, Parse};
#[cfg(feature = "gecko")]
use properties::longhands::font_language_override;
use selectors::parser::SelectorParseError; use selectors::parser::SelectorParseError;
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use std::fmt; use std::fmt;
@ -407,7 +409,10 @@ font_face_descriptors! {
font_feature_settings::T::Normal font_feature_settings::T::Normal
}, },
// FIXME: add font-language-override. /// The language override of this font face.
"font-language-override" language_override / mFontLanguageOverride: font_language_override::SpecifiedValue = {
font_language_override::SpecifiedValue::Normal
},
] ]
} }

Просмотреть файл

@ -15,6 +15,7 @@ use gecko_bindings::structs::{self, nsCSSFontFaceRule, nsCSSValue};
use gecko_bindings::structs::{nsCSSCounterDesc, nsCSSCounterStyleRule}; use gecko_bindings::structs::{nsCSSCounterDesc, nsCSSCounterStyleRule};
use gecko_bindings::sugar::ns_css_value::ToNsCssValue; use gecko_bindings::sugar::ns_css_value::ToNsCssValue;
use gecko_bindings::sugar::refptr::{RefPtr, UniqueRefPtr}; use gecko_bindings::sugar::refptr::{RefPtr, UniqueRefPtr};
use properties::longhands::font_language_override;
use shared_lock::{ToCssWithGuard, SharedRwLockReadGuard}; use shared_lock::{ToCssWithGuard, SharedRwLockReadGuard};
use std::{fmt, str}; use std::{fmt, str};
use values::generics::FontSettings; use values::generics::FontSettings;
@ -67,6 +68,17 @@ impl ToNsCssValue for font_feature_settings::T {
} }
} }
impl ToNsCssValue for font_language_override::SpecifiedValue {
fn convert(self, nscssvalue: &mut nsCSSValue) {
match self {
font_language_override::SpecifiedValue::Normal => nscssvalue.set_normal(),
font_language_override::SpecifiedValue::Override(ref lang) => nscssvalue.set_string(&*lang),
// This path is unreachable because the descriptor is only specified by the user.
font_language_override::SpecifiedValue::System(_) => unreachable!(),
}
}
}
macro_rules! map_enum { macro_rules! map_enum {
( (
$( $(

Просмотреть файл

@ -2012,7 +2012,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
// OpenType "language system" tag, so we should be able to compute // OpenType "language system" tag, so we should be able to compute
// it and store it as a 32-bit integer // it and store it as a 32-bit integer
// (see http://www.microsoft.com/typography/otspec/languagetags.htm). // (see http://www.microsoft.com/typography/otspec/languagetags.htm).
#[derive(PartialEq, Clone, Copy, Debug)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub u32); pub struct T(pub u32);
} }
@ -2082,6 +2082,14 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
} }
} }
/// Used in @font-face.
impl Parse for SpecifiedValue {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<Self, ParseError<'i>> {
parse(context, input)
}
}
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
impl From<u32> for computed_value::T { impl From<u32> for computed_value::T {
fn from(bits: u32) -> computed_value::T { fn from(bits: u32) -> computed_value::T {