mirror of
https://github.com/servo/servo.git
synced 2025-08-08 23:15:33 +01:00
Auto merge of #13860 - canaltinova:text-emphasis-style, r=Manishearth,emilio
Implement parsing/serialization and gecko glue for text-emphasis-style <!-- Please describe your changes on the following line: --> Implementation of parsing/serialization and gecko glue for text-emphasis-style. r? @Manishearth --- <!-- 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 #13853 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13860) <!-- Reviewable:end -->
This commit is contained in:
commit
bfd966f819
5 changed files with 297 additions and 2 deletions
|
@ -1646,7 +1646,7 @@ fn static_assert() {
|
|||
|
||||
|
||||
<%self:impl_trait style_struct_name="InheritedText"
|
||||
skip_longhands="text-align text-shadow line-height letter-spacing word-spacing">
|
||||
skip_longhands="text-align text-emphasis-style text-shadow line-height letter-spacing word-spacing">
|
||||
|
||||
<% text_align_keyword = Keyword("text-align", "start end left right center justify -moz-center -moz-left " +
|
||||
"-moz-right match-parent") %>
|
||||
|
@ -1744,6 +1744,55 @@ fn static_assert() {
|
|||
|
||||
<%call expr="impl_coord_copy('word_spacing', 'mWordSpacing')"></%call>
|
||||
|
||||
fn clear_text_emphasis_style_if_string(&mut self) {
|
||||
use nsstring::nsString;
|
||||
if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
|
||||
self.gecko.mTextEmphasisStyleString.assign(&nsString::new());
|
||||
self.gecko.mTextEmphasisStyle = structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE as u8;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_text_emphasis_style(&mut self, v: longhands::text_emphasis_style::computed_value::T) {
|
||||
use nsstring::nsCString;
|
||||
use properties::longhands::text_emphasis_style::computed_value::T;
|
||||
use properties::longhands::text_emphasis_style::ShapeKeyword;
|
||||
|
||||
self.clear_text_emphasis_style_if_string();
|
||||
let (te, s) = match v {
|
||||
T::None => (structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE, ""),
|
||||
T::Keyword(ref keyword) => {
|
||||
let fill = if keyword.fill {
|
||||
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_FILLED
|
||||
} else {
|
||||
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN
|
||||
};
|
||||
let shape = match keyword.shape {
|
||||
ShapeKeyword::Dot => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT,
|
||||
ShapeKeyword::Circle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE,
|
||||
ShapeKeyword::DoubleCircle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE,
|
||||
ShapeKeyword::Triangle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE,
|
||||
ShapeKeyword::Sesame => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME,
|
||||
};
|
||||
|
||||
(shape | fill, keyword.shape.char(keyword.fill))
|
||||
},
|
||||
T::String(ref s) => {
|
||||
(structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING, &**s)
|
||||
},
|
||||
};
|
||||
self.gecko.mTextEmphasisStyleString.assign_utf8(&nsCString::from(s));
|
||||
self.gecko.mTextEmphasisStyle = te as u8;
|
||||
}
|
||||
|
||||
pub fn copy_text_emphasis_style_from(&mut self, other: &Self) {
|
||||
self.clear_text_emphasis_style_if_string();
|
||||
if other.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
|
||||
self.gecko.mTextEmphasisStyleString
|
||||
.assign(&other.gecko.mTextEmphasisStyleString)
|
||||
}
|
||||
self.gecko.mTextEmphasisStyle = other.gecko.mTextEmphasisStyle;
|
||||
}
|
||||
|
||||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="Text"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue