From 76b48c3c41475fd0baf8a7cabbc6090e3599ccdc Mon Sep 17 00:00:00 2001 From: Jeremy Chen Date: Mon, 10 Apr 2017 17:15:55 +0800 Subject: [PATCH] Stylo - add glue code for initial-letter property --- components/style/properties/gecko.mako.rs | 25 ++++++++++++++++++- .../style/properties/longhand/text.mako.rs | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index ff3529bb53b7..0ae387646b4e 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3012,7 +3012,7 @@ fn static_assert() { <%self:impl_trait style_struct_name="Text" - skip_longhands="text-decoration-line text-overflow" + skip_longhands="text-decoration-line text-overflow initial-letter" skip_additionals="*"> pub fn set_text_decoration_line(&mut self, v: longhands::text_decoration_line::computed_value::T) { @@ -3093,6 +3093,29 @@ fn static_assert() { self.gecko.mTextOverflow.mLogicalDirections = other.gecko.mTextOverflow.mLogicalDirections; } + pub fn set_initial_letter(&mut self, v: longhands::initial_letter::computed_value::T) { + use properties::longhands::initial_letter::computed_value::T; + match v { + T::Normal => { + self.gecko.mInitialLetterSize = 0.; + self.gecko.mInitialLetterSink = 0; + }, + T::Specified(size, sink) => { + self.gecko.mInitialLetterSize = size.value; + if let Some(sink) = sink { + self.gecko.mInitialLetterSink = sink.value(); + } else { + self.gecko.mInitialLetterSink = size.value.floor() as i32; + } + } + } + } + + pub fn copy_initial_letter_from(&mut self, other: &Self) { + self.gecko.mInitialLetterSize = other.gecko.mInitialLetterSize; + self.gecko.mInitialLetterSink = other.gecko.mInitialLetterSink; + } + #[inline] pub fn has_underline(&self) -> bool { (self.gecko.mTextDecorationLine & (structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8)) != 0 diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 69db04020c97..170b2476311a 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -233,7 +233,7 @@ ${helpers.predefined_type( <%helpers:longhand name="initial-letter" animation_type="none" - products="none" + products="gecko" spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials"> use std::fmt; use style_traits::ToCss;