diff options
author | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-04-13 23:07:26 +0900 |
---|---|---|
committer | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-04-14 08:50:16 +0900 |
commit | 6ae5af17ce37e5ffdf36aca84e8e1503d163deb8 (patch) | |
tree | c9e56af6bcf5514c5888fd0ff9901aff959899a9 | |
parent | 24919b3cf818e6755e6453e70216eeba4060f5a0 (diff) | |
download | servo-6ae5af17ce37e5ffdf36aca84e8e1503d163deb8.tar.gz servo-6ae5af17ce37e5ffdf36aca84e8e1503d163deb8.zip |
Make font-variant shorthand.
-rw-r--r-- | components/gfx/font.rs | 10 | ||||
-rw-r--r-- | components/gfx/font_context.rs | 16 | ||||
-rw-r--r-- | components/script/dom/webidls/CSSStyleDeclaration.webidl | 2 | ||||
-rw-r--r-- | components/style/servo/restyle_damage.rs | 2 |
4 files changed, 16 insertions, 14 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 8a0377cd2b0..76f63b2f389 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -18,7 +18,7 @@ use std::rc::Rc; use std::str; use std::sync::Arc; use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering}; -use style::computed_values::{font_stretch, font_variant, font_weight}; +use style::computed_values::{font_stretch, font_variant_caps, font_weight}; use text::Shaper; use text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; use text::shaping::ShaperMethods; @@ -105,7 +105,7 @@ pub struct FontMetrics { pub struct Font { pub handle: FontHandle, pub metrics: FontMetrics, - pub variant: font_variant::T, + pub variant: font_variant_caps::T, pub descriptor: FontTemplateDescriptor, pub requested_pt_size: Au, pub actual_pt_size: Au, @@ -117,7 +117,7 @@ pub struct Font { impl Font { pub fn new(handle: FontHandle, - variant: font_variant::T, + variant: font_variant_caps::T, descriptor: FontTemplateDescriptor, requested_pt_size: Au, actual_pt_size: Au, @@ -262,8 +262,8 @@ impl Font { #[inline] pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { let codepoint = match self.variant { - font_variant::T::small_caps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938 - font_variant::T::normal => codepoint, + font_variant_caps::T::small_caps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938 + font_variant_caps::T::normal => codepoint, }; self.handle.glyph_index(codepoint) } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index f5a7b9659a5..b1b9bbc6838 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -19,7 +19,7 @@ use std::hash::{BuildHasherDefault, Hash, Hasher}; use std::rc::Rc; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; -use style::computed_values::{font_style, font_variant}; +use style::computed_values::{font_style, font_variant_caps}; use style::properties::style_structs; use webrender_traits; @@ -77,14 +77,14 @@ impl FontContext { template: Arc<FontTemplateData>, descriptor: FontTemplateDescriptor, pt_size: Au, - variant: font_variant::T, + variant: font_variant_caps::T, font_key: webrender_traits::FontKey) -> Result<Font, ()> { // TODO: (Bug #3463): Currently we only support fake small-caps // painting. We should also support true small-caps (where the // font supports it) in the future. let actual_pt_size = match variant { - font_variant::T::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), - font_variant::T::normal => pt_size, + font_variant_caps::T::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), + font_variant_caps::T::normal => pt_size, }; let handle = try!(FontHandle::new_from_template(&self.platform_handle, @@ -146,7 +146,7 @@ impl FontContext { let cached_font = (*cached_font_ref).borrow(); if cached_font.descriptor == desc && cached_font.requested_pt_size == style.font_size && - cached_font.variant == style.font_variant { + cached_font.variant == style.font_variant_caps { fonts.push((*cached_font_ref).clone()); cache_hit = true; break; @@ -164,7 +164,7 @@ impl FontContext { let layout_font = self.create_layout_font(template_info.font_template, desc.clone(), style.font_size, - style.font_variant, + style.font_variant_caps, template_info.font_key .expect("No font key present!")); let font = match layout_font { @@ -198,7 +198,7 @@ impl FontContext { let cached_font = cached_font_entry.font.borrow(); if cached_font.descriptor == desc && cached_font.requested_pt_size == style.font_size && - cached_font.variant == style.font_variant { + cached_font.variant == style.font_variant_caps { fonts.push(cached_font_entry.font.clone()); cache_hit = true; break; @@ -210,7 +210,7 @@ impl FontContext { let layout_font = self.create_layout_font(template_info.font_template, desc.clone(), style.font_size, - style.font_variant, + style.font_variant_caps, template_info.font_key.expect("No font key present!")); match layout_font { Ok(layout_font) => { diff --git a/components/script/dom/webidls/CSSStyleDeclaration.webidl b/components/script/dom/webidls/CSSStyleDeclaration.webidl index 498d4a634d4..aebe2b5f7c6 100644 --- a/components/script/dom/webidls/CSSStyleDeclaration.webidl +++ b/components/script/dom/webidls/CSSStyleDeclaration.webidl @@ -281,6 +281,8 @@ partial interface CSSStyleDeclaration { [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontVariant; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-variant; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontVariantCaps; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-variant-caps; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontWeight; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-weight; diff --git a/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs index aad16730126..0ad934278c1 100644 --- a/components/style/servo/restyle_damage.rs +++ b/components/style/servo/restyle_damage.rs @@ -201,7 +201,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo get_inheritedtext.text_transform, get_inheritedtext.word_spacing, get_inheritedtext.overflow_wrap, get_inheritedtext.text_justify, get_inheritedtext.white_space, get_inheritedtext.word_break, get_text.text_overflow, - get_font.font_family, get_font.font_style, get_font.font_variant, get_font.font_weight, + get_font.font_family, get_font.font_style, get_font.font_variant_caps, get_font.font_weight, get_font.font_size, get_font.font_stretch, get_inheritedbox.direction, get_inheritedbox.writing_mode, get_text.text_decoration_line, get_text.unicode_bidi, |