Backed out 2 changesets (bug 1572805) for build-rusttests failure. On a CLOSED TREE

Backed out changeset 849ca4b3f9de (bug 1572805)
Backed out changeset 81b56d76505a (bug 1572805)
This commit is contained in:
Daniel Varga 2019-08-10 21:07:03 +03:00
Родитель 35260ac921
Коммит 3430859a68
10 изменённых файлов: 242 добавлений и 146 удалений

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

@ -1672,7 +1672,7 @@ void nsLineLayout::AdjustLeadings(nsIFrame* spanFrame, PerSpanData* psd,
requiredStartLeading += leadings.mStart;
requiredEndLeading += leadings.mEnd;
}
if (aStyleText->HasEffectiveTextEmphasis()) {
if (aStyleText->HasTextEmphasis()) {
nscoord bsize = GetBSizeOfEmphasisMarks(spanFrame, aInflation);
LogicalSide side = aStyleText->TextEmphasisSide(mRootSpan->mWritingMode);
if (side == eLogicalSideBStart) {
@ -2279,7 +2279,7 @@ void nsLineLayout::VerticalAlignFrames(PerSpanData* psd) {
fm, minimumLineBSize, lineWM.IsLineInverted());
nscoord blockEnd = blockStart + minimumLineBSize;
if (mStyleText->HasEffectiveTextEmphasis()) {
if (mStyleText->HasTextEmphasis()) {
nscoord fontMaxHeight = fm->MaxHeight();
nscoord emphasisHeight =
GetBSizeOfEmphasisMarks(spanFrame, inflation);
@ -3303,7 +3303,7 @@ void nsLineLayout::RelativePositionFrames(PerSpanData* psd,
// (4) When there are text strokes
if (pfd->mRecomputeOverflow ||
frame->Style()->HasTextDecorationLines() ||
frame->StyleText()->HasEffectiveTextEmphasis() ||
frame->StyleText()->HasTextEmphasis() ||
frame->StyleText()->HasWebkitTextStroke()) {
nsTextFrame* f = static_cast<nsTextFrame*>(frame);
r = f->RecomputeOverflow(mBlockReflowInput->mFrame);

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

@ -2161,7 +2161,7 @@ already_AddRefed<gfxTextRun> BuildTextRunsScanner::BuildTextRunForFrames(
lastComputedStyle->IsTextCombined()) {
anyTextTransformStyle = true;
}
if (textStyle->HasEffectiveTextEmphasis()) {
if (textStyle->HasTextEmphasis()) {
anyTextEmphasis = true;
}
flags |= GetSpacingFlags(f);
@ -5233,38 +5233,10 @@ struct EmphasisMarkInfo {
NS_DECLARE_FRAME_PROPERTY_DELETABLE(EmphasisMarkProperty, EmphasisMarkInfo)
static void ComputeTextEmphasisStyleString(const StyleTextEmphasisStyle& aStyle,
nsAString& aOut) {
MOZ_ASSERT(!aStyle.IsNone());
if (aStyle.IsString()) {
nsDependentCSubstring string = aStyle.AsString().AsString();
AppendUTF8toUTF16(string, aOut);
return;
}
const auto& keyword = aStyle.AsKeyword();
const bool fill = keyword.fill == StyleTextEmphasisFillMode::Filled;
switch (keyword.shape) {
case StyleTextEmphasisShapeKeyword::Dot:
return aOut.AppendLiteral(fill ? u"\u2022" : u"\u25e6");
case StyleTextEmphasisShapeKeyword::Circle:
return aOut.AppendLiteral(fill ? u"\u25cf" : u"\u25cb");
case StyleTextEmphasisShapeKeyword::DoubleCircle:
return aOut.AppendLiteral(fill ? u"\u25c9" : u"\u25ce");
case StyleTextEmphasisShapeKeyword::Triangle:
return aOut.AppendLiteral(fill ? u"\u25b2" : u"\u25b3");
case StyleTextEmphasisShapeKeyword::Sesame:
return aOut.AppendLiteral(fill ? u"\ufe45" : u"\ufe46");
default:
MOZ_ASSERT_UNREACHABLE("Unknown emphasis style shape");
}
}
static already_AddRefed<gfxTextRun> GenerateTextRunForEmphasisMarks(
nsTextFrame* aFrame, gfxFontGroup* aFontGroup,
ComputedStyle* aComputedStyle, const nsStyleText* aStyleText) {
nsAutoString string;
ComputeTextEmphasisStyleString(aStyleText->mTextEmphasisStyle, string);
const nsString& emphasisString = aStyleText->mTextEmphasisStyleString;
RefPtr<DrawTarget> dt = CreateReferenceDrawTarget(aFrame);
auto appUnitsPerDevUnit = aFrame->PresContext()->AppUnitsPerDevPixel();
gfx::ShapedTextFlags flags =
@ -5273,9 +5245,9 @@ static already_AddRefed<gfxTextRun> GenerateTextRunForEmphasisMarks(
// The emphasis marks should always be rendered upright per spec.
flags = gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT;
}
return aFontGroup->MakeTextRun<char16_t>(string.get(), string.Length(), dt,
appUnitsPerDevUnit, flags,
nsTextFrameUtils::Flags(), nullptr);
return aFontGroup->MakeTextRun<char16_t>(
emphasisString.get(), emphasisString.Length(), dt, appUnitsPerDevUnit,
flags, nsTextFrameUtils::Flags(), nullptr);
}
static nsRubyFrame* FindFurthestInlineRubyAncestor(nsTextFrame* aFrame) {
@ -5293,7 +5265,7 @@ static nsRubyFrame* FindFurthestInlineRubyAncestor(nsTextFrame* aFrame) {
nsRect nsTextFrame::UpdateTextEmphasis(WritingMode aWM,
PropertyProvider& aProvider) {
const nsStyleText* styleText = StyleText();
if (!styleText->HasEffectiveTextEmphasis()) {
if (!styleText->HasTextEmphasis()) {
DeleteProperty(EmphasisMarkProperty());
return nsRect();
}
@ -7145,8 +7117,7 @@ void nsTextFrame::DrawText(Range aRange, const gfx::Point& aTextBaselinePt,
// Hide text decorations if we're currently hiding @font-face fallback text
const bool drawDecorations =
!aParams.provider->GetFontGroup()->ShouldSkipDrawing() &&
(decorations.HasDecorationLines() ||
StyleText()->HasEffectiveTextEmphasis());
(decorations.HasDecorationLines() || StyleText()->HasTextEmphasis());
if (drawDecorations) {
DrawTextRunAndDecorations(aRange, aTextBaselinePt, aParams, decorations);
} else {

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

@ -519,7 +519,6 @@ cbindgen-types = [
{ gecko = "StyleGenericTrackListValue", servo = "values::generics::grid::TrackListValue" },
{ gecko = "StyleGenericTrackList", servo = "values::generics::grid::TrackList" },
{ gecko = "StyleGenericGridTemplateComponent", servo = "values::generics::grid::GridTemplateComponent" },
{ gecko = "StyleTextEmphasisStyle", servo = "values::computed::text::TextEmphasisStyle" },
]
mapped-generic-types = [

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

@ -730,6 +730,24 @@ enum class StyleWhiteSpace : uint8_t {
(NS_STYLE_TEXT_EMPHASIS_POSITION_UNDER | \
NS_STYLE_TEXT_EMPHASIS_POSITION_RIGHT)
// text-emphasis-style
// Note that filled and none here both have zero as their value. This is
// not an problem because:
// * In specified style, none is represented as eCSSUnit_None.
// * In computed style, 'filled' always has its shape computed, and thus
// the combined value is never zero.
#define NS_STYLE_TEXT_EMPHASIS_STYLE_NONE 0
#define NS_STYLE_TEXT_EMPHASIS_STYLE_FILL_MASK (1 << 3)
#define NS_STYLE_TEXT_EMPHASIS_STYLE_FILLED (0 << 3)
#define NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN (1 << 3)
#define NS_STYLE_TEXT_EMPHASIS_STYLE_SHAPE_MASK 7
#define NS_STYLE_TEXT_EMPHASIS_STYLE_DOT 1
#define NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE 2
#define NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE 3
#define NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE 4
#define NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME 5
#define NS_STYLE_TEXT_EMPHASIS_STYLE_STRING 255
// text-rendering
enum class StyleTextRendering : uint8_t {
Auto,

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

@ -3371,6 +3371,7 @@ nsStyleText::nsStyleText(const Document& aDocument)
mTextCombineUpright(NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE),
mControlCharacterVisibility(
nsLayoutUtils::ControlCharVisibilityDefault()),
mTextEmphasisStyle(NS_STYLE_TEXT_EMPHASIS_STYLE_NONE),
mTextRendering(StyleTextRendering::Auto),
mTextEmphasisColor(StyleColor::CurrentColor()),
mWebkitTextFillColor(StyleColor::CurrentColor()),
@ -3383,8 +3384,7 @@ nsStyleText::nsStyleText(const Document& aDocument)
mTextIndent(LengthPercentage::Zero()),
mTextUnderlineOffset(LengthOrAuto::Auto()),
mTextDecorationSkipInk(StyleTextDecorationSkipInk::Auto),
mWebkitTextStrokeWidth(0),
mTextEmphasisStyle(StyleTextEmphasisStyle::None()) {
mWebkitTextStrokeWidth(0) {
MOZ_COUNT_CTOR(nsStyleText);
RefPtr<nsAtom> language = aDocument.GetContentLanguageAsAtomForStyle();
mTextEmphasisPosition =
@ -3410,6 +3410,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
mTextCombineUpright(aSource.mTextCombineUpright),
mControlCharacterVisibility(aSource.mControlCharacterVisibility),
mTextEmphasisPosition(aSource.mTextEmphasisPosition),
mTextEmphasisStyle(aSource.mTextEmphasisStyle),
mTextRendering(aSource.mTextRendering),
mTextEmphasisColor(aSource.mTextEmphasisColor),
mWebkitTextFillColor(aSource.mWebkitTextFillColor),
@ -3423,7 +3424,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
mTextDecorationSkipInk(aSource.mTextDecorationSkipInk),
mWebkitTextStrokeWidth(aSource.mWebkitTextStrokeWidth),
mTextShadow(aSource.mTextShadow),
mTextEmphasisStyle(aSource.mTextEmphasisStyle) {
mTextEmphasisStyleString(aSource.mTextEmphasisStyleString) {
MOZ_COUNT_CTOR(nsStyleText);
}
@ -3462,8 +3463,8 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aNewData) const {
return NS_STYLE_HINT_REFLOW;
}
if (HasEffectiveTextEmphasis() != aNewData.HasEffectiveTextEmphasis() ||
(HasEffectiveTextEmphasis() &&
if (HasTextEmphasis() != aNewData.HasTextEmphasis() ||
(HasTextEmphasis() &&
mTextEmphasisPosition != aNewData.mTextEmphasisPosition)) {
// Text emphasis position change could affect line height calculation.
return nsChangeHint_AllReflowHints | nsChangeHint_RepaintFrame;
@ -3481,6 +3482,7 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aNewData) const {
if (mTextShadow != aNewData.mTextShadow ||
mTextEmphasisStyle != aNewData.mTextEmphasisStyle ||
mTextEmphasisStyleString != aNewData.mTextEmphasisStyleString ||
mWebkitTextStrokeWidth != aNewData.mWebkitTextStrokeWidth) {
hint |= nsChangeHint_UpdateSubtreeOverflow | nsChangeHint_SchedulePaint |
nsChangeHint_RepaintFrame;

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

@ -1146,6 +1146,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText {
uint8_t
mControlCharacterVisibility; // NS_STYLE_CONTROL_CHARACTER_VISIBILITY_*
uint8_t mTextEmphasisPosition; // NS_STYLE_TEXT_EMPHASIS_POSITION_*
uint8_t mTextEmphasisStyle; // NS_STYLE_TEXT_EMPHASIS_STYLE_*
mozilla::StyleTextRendering mTextRendering;
mozilla::StyleColor mTextEmphasisColor;
mozilla::StyleColor mWebkitTextFillColor;
@ -1163,7 +1164,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText {
nscoord mWebkitTextStrokeWidth; // coord
mozilla::StyleArcSlice<mozilla::StyleSimpleShadow> mTextShadow;
mozilla::StyleTextEmphasisStyle mTextEmphasisStyle;
nsString mTextEmphasisStyleString;
mozilla::StyleWordBreak EffectiveWordBreak() const {
if (mWordBreak == mozilla::StyleWordBreak::BreakWord) {
@ -1223,16 +1225,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText {
owrap == mozilla::StyleOverflowWrap::Anywhere;
}
bool HasEffectiveTextEmphasis() const {
if (mTextEmphasisStyle.IsNone()) {
return false;
}
if (mTextEmphasisStyle.IsString() &&
mTextEmphasisStyle.AsString().AsString().IsEmpty()) {
return false;
}
return true;
}
bool HasTextEmphasis() const { return !mTextEmphasisStyleString.IsEmpty(); }
bool HasWebkitTextStroke() const { return mWebkitTextStrokeWidth > 0; }

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

@ -2578,15 +2578,97 @@ fn static_assert() {
<%self:impl_trait style_struct_name="InheritedText"
skip_longhands="text-align -webkit-text-stroke-width text-emphasis-position">
skip_longhands="text-align text-emphasis-style
-webkit-text-stroke-width text-emphasis-position">
<% text_align_keyword = Keyword("text-align",
"start end left right center justify -moz-center -moz-left -moz-right char",
gecko_strip_moz_prefix=False) %>
${impl_keyword('text_align', 'mTextAlign', text_align_keyword)}
fn clear_text_emphasis_style_if_string(&mut self) {
if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
self.gecko.mTextEmphasisStyleString.truncate();
self.gecko.mTextEmphasisStyle = structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE as u8;
}
}
${impl_simple_type_with_conversion("text_emphasis_position")}
pub fn set_text_emphasis_style(&mut self, v: values::computed::TextEmphasisStyle) {
use crate::values::computed::TextEmphasisStyle;
use crate::values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword};
self.clear_text_emphasis_style_if_string();
let (te, s) = match v {
TextEmphasisStyle::None => (structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE, ""),
TextEmphasisStyle::Keyword(ref keyword) => {
let fill = match keyword.fill {
TextEmphasisFillMode::Filled => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_FILLED,
TextEmphasisFillMode::Open => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN,
};
let shape = match keyword.shape {
TextEmphasisShapeKeyword::Dot => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT,
TextEmphasisShapeKeyword::Circle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE,
TextEmphasisShapeKeyword::DoubleCircle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE,
TextEmphasisShapeKeyword::Triangle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE,
TextEmphasisShapeKeyword::Sesame => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME,
};
(shape | fill, keyword.shape.char(keyword.fill))
},
TextEmphasisStyle::String(ref s) => {
(structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING, &**s)
},
};
self.gecko.mTextEmphasisStyleString.assign_str(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;
}
pub fn reset_text_emphasis_style(&mut self, other: &Self) {
self.copy_text_emphasis_style_from(other)
}
pub fn clone_text_emphasis_style(&self) -> values::computed::TextEmphasisStyle {
use crate::values::computed::TextEmphasisStyle;
use crate::values::computed::text::TextEmphasisKeywordValue;
use crate::values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword};
if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE as u8 {
return TextEmphasisStyle::None;
}
if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
return TextEmphasisStyle::String(self.gecko.mTextEmphasisStyleString.to_string());
}
let fill =
self.gecko.mTextEmphasisStyle & structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN as u8 == 0;
let fill = if fill { TextEmphasisFillMode::Filled } else { TextEmphasisFillMode::Open };
let shape =
match self.gecko.mTextEmphasisStyle as u32 & !structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN {
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT => TextEmphasisShapeKeyword::Dot,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE => TextEmphasisShapeKeyword::Circle,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE => TextEmphasisShapeKeyword::DoubleCircle,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE => TextEmphasisShapeKeyword::Triangle,
structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME => TextEmphasisShapeKeyword::Sesame,
_ => panic!("Unexpected value in style struct for text-emphasis-style property")
};
TextEmphasisStyle::Keyword(TextEmphasisKeywordValue { fill, shape })
}
${impl_non_negative_length('_webkit_text_stroke_width',
'mWebkitTextStrokeWidth')}

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

@ -194,21 +194,22 @@ impl TextDecorationsInEffect {
}
}
/// Computed value for the text-emphasis-style property
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
/// computed value for the text-emphasis-style property
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
#[allow(missing_docs)]
#[repr(C, u8)]
pub enum TextEmphasisStyle {
/// [ <fill> || <shape> ]
Keyword {
#[css(skip_if = "TextEmphasisFillMode::is_filled")]
fill: TextEmphasisFillMode,
shape: TextEmphasisShapeKeyword,
},
/// Keyword value for the text-emphasis-style property (`filled` `open`)
Keyword(TextEmphasisKeywordValue),
/// `none`
None,
/// `<string>` (of which only the first grapheme cluster will be used).
String(crate::OwnedStr),
/// String (will be used only first grapheme cluster) for the text-emphasis-style property
String(String),
}
/// Keyword value for the text-emphasis-style property
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
pub struct TextEmphasisKeywordValue {
/// fill for the text-emphasis-style property
pub fill: TextEmphasisFillMode,
/// shape for the text-emphasis-style property
pub shape: TextEmphasisShapeKeyword,
}

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

@ -7,6 +7,7 @@
use crate::parser::{Parse, ParserContext};
use crate::properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode;
use crate::values::computed::text::LineHeight as ComputedLineHeight;
use crate::values::computed::text::TextEmphasisKeywordValue as ComputedTextEmphasisKeywordValue;
use crate::values::computed::text::TextEmphasisStyle as ComputedTextEmphasisStyle;
use crate::values::computed::text::TextOverflow as ComputedTextOverflow;
use crate::values::computed::{Context, ToComputedValue};
@ -644,34 +645,48 @@ impl ToComputedValue for TextAlign {
}
}
fn fill_mode_is_default_and_shape_exists(
fill: &TextEmphasisFillMode,
shape: &Option<TextEmphasisShapeKeyword>,
) -> bool {
shape.is_some() && fill.is_filled()
}
/// Specified value of text-emphasis-style property.
///
/// https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
#[allow(missing_docs)]
pub enum TextEmphasisStyle {
/// [ <fill> || <shape> ]
Keyword {
#[css(contextual_skip_if = "fill_mode_is_default_and_shape_exists")]
fill: TextEmphasisFillMode,
shape: Option<TextEmphasisShapeKeyword>,
},
/// <fill> <shape>
Keyword(TextEmphasisKeywordValue),
/// `none`
None,
/// `<string>` (of which only the first grapheme cluster will be used).
String(crate::OwnedStr),
/// String (will be used only first grapheme cluster) for the text-emphasis-style property
String(String),
}
/// Keyword value for the text-emphasis-style property
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
pub enum TextEmphasisKeywordValue {
/// <fill>
Fill(TextEmphasisFillMode),
/// <shape>
Shape(TextEmphasisShapeKeyword),
/// <fill> <shape>
FillAndShape(TextEmphasisFillMode, TextEmphasisShapeKeyword),
}
impl TextEmphasisKeywordValue {
fn fill(&self) -> Option<TextEmphasisFillMode> {
match *self {
TextEmphasisKeywordValue::Fill(fill) |
TextEmphasisKeywordValue::FillAndShape(fill, _) => Some(fill),
_ => None,
}
}
fn shape(&self) -> Option<TextEmphasisShapeKeyword> {
match *self {
TextEmphasisKeywordValue::Shape(shape) |
TextEmphasisKeywordValue::FillAndShape(_, shape) => Some(shape),
_ => None,
}
}
}
/// Fill mode for the text-emphasis-style property
#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
#[repr(u8)]
pub enum TextEmphasisFillMode {
/// `filled`
Filled,
@ -679,19 +694,10 @@ pub enum TextEmphasisFillMode {
Open,
}
impl TextEmphasisFillMode {
/// Whether the value is `filled`.
#[inline]
pub fn is_filled(&self) -> bool {
matches!(*self, TextEmphasisFillMode::Filled)
}
}
/// Shape keyword for the text-emphasis-style property
#[derive(
Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
)]
#[repr(u8)]
pub enum TextEmphasisShapeKeyword {
/// `dot`
Dot,
@ -705,39 +711,77 @@ pub enum TextEmphasisShapeKeyword {
Sesame,
}
impl TextEmphasisShapeKeyword {
/// converts fill mode to a unicode char
pub fn char(&self, fill: TextEmphasisFillMode) -> &str {
let fill = fill == TextEmphasisFillMode::Filled;
match *self {
TextEmphasisShapeKeyword::Dot => {
if fill {
"\u{2022}"
} else {
"\u{25e6}"
}
},
TextEmphasisShapeKeyword::Circle => {
if fill {
"\u{25cf}"
} else {
"\u{25cb}"
}
},
TextEmphasisShapeKeyword::DoubleCircle => {
if fill {
"\u{25c9}"
} else {
"\u{25ce}"
}
},
TextEmphasisShapeKeyword::Triangle => {
if fill {
"\u{25b2}"
} else {
"\u{25b3}"
}
},
TextEmphasisShapeKeyword::Sesame => {
if fill {
"\u{fe45}"
} else {
"\u{fe46}"
}
},
}
}
}
impl ToComputedValue for TextEmphasisStyle {
type ComputedValue = ComputedTextEmphasisStyle;
#[inline]
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
match *self {
TextEmphasisStyle::Keyword { fill, shape } => {
let shape = shape.unwrap_or_else(|| {
// FIXME(emilio, bug 1572958): This should set the
// rule_cache_conditions properly.
//
// Also should probably use WritingMode::is_vertical rather
// than the computed value of the `writing-mode` property.
if context.style().get_inherited_box().clone_writing_mode() ==
SpecifiedWritingMode::HorizontalTb
{
TextEmphasisShapeKeyword::Circle
} else {
TextEmphasisShapeKeyword::Sesame
}
});
ComputedTextEmphasisStyle::Keyword { fill, shape }
TextEmphasisStyle::Keyword(ref keyword) => {
// FIXME(emilio): This should set the rule_cache_conditions
// properly.
let default_shape = if context.style().get_inherited_box().clone_writing_mode() ==
SpecifiedWritingMode::HorizontalTb
{
TextEmphasisShapeKeyword::Circle
} else {
TextEmphasisShapeKeyword::Sesame
};
ComputedTextEmphasisStyle::Keyword(ComputedTextEmphasisKeywordValue {
fill: keyword.fill().unwrap_or(TextEmphasisFillMode::Filled),
shape: keyword.shape().unwrap_or(default_shape),
})
},
TextEmphasisStyle::None => ComputedTextEmphasisStyle::None,
TextEmphasisStyle::String(ref s) => {
// Passing `true` to iterate over extended grapheme clusters, following
// recommendation at http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
//
// FIXME(emilio): Doing this at computed value time seems wrong.
// The spec doesn't say that this should be a computed-value
// time operation. This is observable from getComputedStyle().
let s = s.graphemes(true).next().unwrap_or("").to_string();
ComputedTextEmphasisStyle::String(s.into())
let string = s.graphemes(true).next().unwrap_or("").to_string();
ComputedTextEmphasisStyle::String(string)
},
}
}
@ -745,10 +789,9 @@ impl ToComputedValue for TextEmphasisStyle {
#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
match *computed {
ComputedTextEmphasisStyle::Keyword { fill, shape } => TextEmphasisStyle::Keyword {
fill,
shape: Some(shape),
},
ComputedTextEmphasisStyle::Keyword(ref keyword) => TextEmphasisStyle::Keyword(
TextEmphasisKeywordValue::FillAndShape(keyword.fill, keyword.shape),
),
ComputedTextEmphasisStyle::None => TextEmphasisStyle::None,
ComputedTextEmphasisStyle::String(ref string) => {
TextEmphasisStyle::String(string.clone())
@ -771,7 +814,7 @@ impl Parse for TextEmphasisStyle {
if let Ok(s) = input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned())) {
// Handle <string>
return Ok(TextEmphasisStyle::String(s.into()));
return Ok(TextEmphasisStyle::String(s));
}
// Handle a pair of keywords
@ -781,17 +824,14 @@ impl Parse for TextEmphasisStyle {
shape = input.try(TextEmphasisShapeKeyword::parse).ok();
}
if shape.is_none() && fill.is_none() {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
// If a shape keyword is specified but neither of filled nor open is
// specified, filled is assumed.
let fill = fill.unwrap_or(TextEmphasisFillMode::Filled);
// We cannot do the same because the default `<shape>` depends on the
// computed writing-mode.
Ok(TextEmphasisStyle::Keyword { fill, shape })
// At least one of shape or fill must be handled
let keyword_value = match (fill, shape) {
(Some(fill), Some(shape)) => TextEmphasisKeywordValue::FillAndShape(fill, shape),
(Some(fill), None) => TextEmphasisKeywordValue::Fill(fill),
(None, Some(shape)) => TextEmphasisKeywordValue::Shape(shape),
_ => return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
};
Ok(TextEmphasisStyle::Keyword(keyword_value))
}
}

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

@ -165,7 +165,6 @@ include = [
"SVGPaint",
"SVGPaintKind",
"GridTemplateComponent",
"TextEmphasisStyle",
]
item_types = ["enums", "structs", "typedefs", "functions", "constants"]
renaming_overrides_prefixing = true
@ -678,12 +677,3 @@ renaming_overrides_prefixing = true
inline Span<const StyleOwnedSlice<StyleCustomIdent>> LineNameLists(bool aIsSubgrid) const;
inline Span<const StyleGenericTrackListValue<L, I>> TrackListValues() const;
"""
"TextEmphasisStyle" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleTextEmphasisStyle() {}
public:
"""