Bug 1802799 - [refactor] Migrate NS_STYLE_TEXT_DECORATION_STYLE_* defines r=emilio,geckoview-reviewers,ohall

Differential Revision: https://phabricator.services.mozilla.com/D163177
This commit is contained in:
Ben Freist 2022-12-19 22:47:24 +00:00
Родитель 1f44b4724e
Коммит ce6cd37bc7
21 изменённых файлов: 122 добавлений и 116 удалений

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

@ -64,21 +64,22 @@ void StyleInfo::FormatColor(const nscolor& aValue, nsAString& aFormattedValue) {
aFormattedValue.Append(')'); aFormattedValue.Append(')');
} }
already_AddRefed<nsAtom> StyleInfo::TextDecorationStyleToAtom(uint8_t aValue) { already_AddRefed<nsAtom> StyleInfo::TextDecorationStyleToAtom(
StyleTextDecorationStyle aValue) {
// TODO: When these are enum classes that rust also understands we should just // TODO: When these are enum classes that rust also understands we should just
// make an FFI call here. // make an FFI call here.
switch (aValue) { switch (aValue) {
case NS_STYLE_TEXT_DECORATION_STYLE_NONE: case StyleTextDecorationStyle::None:
return NS_Atomize("-moz-none"); return NS_Atomize("-moz-none");
case NS_STYLE_TEXT_DECORATION_STYLE_SOLID: case StyleTextDecorationStyle::Solid:
return NS_Atomize("solid"); return NS_Atomize("solid");
case NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE: case StyleTextDecorationStyle::Double:
return NS_Atomize("double"); return NS_Atomize("double");
case NS_STYLE_TEXT_DECORATION_STYLE_DOTTED: case StyleTextDecorationStyle::Dotted:
return NS_Atomize("dotted"); return NS_Atomize("dotted");
case NS_STYLE_TEXT_DECORATION_STYLE_DASHED: case StyleTextDecorationStyle::Dashed:
return NS_Atomize("dashed"); return NS_Atomize("dashed");
case NS_STYLE_TEXT_DECORATION_STYLE_WAVY: case StyleTextDecorationStyle::Wavy:
return NS_Atomize("wavy"); return NS_Atomize("wavy");
default: default:
MOZ_ASSERT_UNREACHABLE("Unknown decoration style"); MOZ_ASSERT_UNREACHABLE("Unknown decoration style");

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

@ -30,7 +30,8 @@ class StyleInfo {
CSSCoord MarginBottom() { return Margin(eSideBottom); } CSSCoord MarginBottom() { return Margin(eSideBottom); }
static void FormatColor(const nscolor& aValue, nsAString& aFormattedValue); static void FormatColor(const nscolor& aValue, nsAString& aFormattedValue);
static already_AddRefed<nsAtom> TextDecorationStyleToAtom(uint8_t aValue); static already_AddRefed<nsAtom> TextDecorationStyleToAtom(
StyleTextDecorationStyle aValue);
private: private:
StyleInfo() = delete; StyleInfo() = delete;

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

@ -364,11 +364,11 @@ class TextAttrsMgr {
TextDecorValue() TextDecorValue()
: mColor{0}, : mColor{0},
mLine{StyleTextDecorationLine::NONE}, mLine{StyleTextDecorationLine::NONE},
mStyle{NS_STYLE_TEXT_DECORATION_STYLE_NONE} {} mStyle{StyleTextDecorationStyle::None} {}
explicit TextDecorValue(nsIFrame* aFrame); explicit TextDecorValue(nsIFrame* aFrame);
nscolor Color() const { return mColor; } nscolor Color() const { return mColor; }
uint8_t Style() const { return mStyle; } mozilla::StyleTextDecorationStyle Style() const { return mStyle; }
bool IsDefined() const { return IsUnderline() || IsLineThrough(); } bool IsDefined() const { return IsUnderline() || IsLineThrough(); }
bool IsUnderline() const { bool IsUnderline() const {
@ -387,7 +387,7 @@ class TextAttrsMgr {
private: private:
nscolor mColor; nscolor mColor;
mozilla::StyleTextDecorationLine mLine; mozilla::StyleTextDecorationLine mLine;
uint8_t mStyle; mozilla::StyleTextDecorationStyle mStyle;
}; };
class TextDecorTextAttr : public TTextAttr<TextDecorValue> { class TextDecorTextAttr : public TTextAttr<TextDecorValue> {

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

@ -509,7 +509,7 @@ specified with following prefs. The values must be string of "#rrggbb" format.
Underline style can be specified with the following prefs. The values are Underline style can be specified with the following prefs. The values are
integer, 0: none, 1: dotted, 2: dashed, 3: solid, 4: double, 5: wavy (The integer, 0: none, 1: dotted, 2: dashed, 3: solid, 4: double, 5: wavy (The
values same as ``NS_STYLE_TEXT_DECORATION_STYLE_*`` defined in values same as ``mozilla::StyleTextDecorationStyle`` defined in
`nsStyleConsts.h <https://searchfox.org/mozilla-central/source/layout/style/nsStyleConsts.h>`__). `nsStyleConsts.h <https://searchfox.org/mozilla-central/source/layout/style/nsStyleConsts.h>`__).
* ``ui.IMERawInputUnderlineStyle`` * ``ui.IMERawInputUnderlineStyle``

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

@ -261,7 +261,8 @@ class TextDrawTarget : public DrawTarget {
// as the top-left corner of the rect. // as the top-left corner of the rect.
void AppendDecoration(const Point& aStart, const Point& aEnd, void AppendDecoration(const Point& aStart, const Point& aEnd,
const float aThickness, const bool aVertical, const float aThickness, const bool aVertical,
const DeviceColor& aColor, const uint8_t aStyle) { const DeviceColor& aColor,
const StyleTextDecorationStyle aStyle) {
auto pos = LayoutDevicePoint::FromUnknownPoint(aStart); auto pos = LayoutDevicePoint::FromUnknownPoint(aStart);
LayoutDeviceSize size; LayoutDeviceSize size;
@ -281,19 +282,19 @@ class TextDrawTarget : public DrawTarget {
: wr::LineOrientation::Horizontal; : wr::LineOrientation::Horizontal;
switch (aStyle) { switch (aStyle) {
case NS_STYLE_TEXT_DECORATION_STYLE_SOLID: case StyleTextDecorationStyle::Solid:
decoration.style = wr::LineStyle::Solid; decoration.style = wr::LineStyle::Solid;
break; break;
case NS_STYLE_TEXT_DECORATION_STYLE_DOTTED: case StyleTextDecorationStyle::Dotted:
decoration.style = wr::LineStyle::Dotted; decoration.style = wr::LineStyle::Dotted;
break; break;
case NS_STYLE_TEXT_DECORATION_STYLE_DASHED: case StyleTextDecorationStyle::Dashed:
decoration.style = wr::LineStyle::Dashed; decoration.style = wr::LineStyle::Dashed;
break; break;
// Wavy lines should go through AppendWavyDecoration // Wavy lines should go through AppendWavyDecoration
case NS_STYLE_TEXT_DECORATION_STYLE_WAVY: case StyleTextDecorationStyle::Wavy:
// Double lines should be lowered to two solid lines // Double lines should be lowered to two solid lines
case NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE: case StyleTextDecorationStyle::Double:
default: default:
MOZ_CRASH("TextDrawTarget received unsupported line style"); MOZ_CRASH("TextDrawTarget received unsupported line style");
} }

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

@ -441,12 +441,13 @@ class nsTextPaintStyle {
nscolor* aBackColor); nscolor* aBackColor);
// if this returns false, we don't need to draw underline. // if this returns false, we don't need to draw underline.
bool GetSelectionUnderlineForPaint(int32_t aIndex, nscolor* aLineColor, bool GetSelectionUnderlineForPaint(int32_t aIndex, nscolor* aLineColor,
float* aRelativeSize, uint8_t* aStyle); float* aRelativeSize,
StyleTextDecorationStyle* aStyle);
// if this returns false, we don't need to draw underline. // if this returns false, we don't need to draw underline.
static bool GetSelectionUnderline(nsIFrame*, int32_t aIndex, static bool GetSelectionUnderline(nsIFrame*, int32_t aIndex,
nscolor* aLineColor, float* aRelativeSize, nscolor* aLineColor, float* aRelativeSize,
uint8_t* aStyle); StyleTextDecorationStyle* aStyle);
// if this returns false, no text-shadow was specified for the selection // if this returns false, no text-shadow was specified for the selection
// and the *aShadow parameter was not modified. // and the *aShadow parameter was not modified.
@ -513,7 +514,7 @@ class nsTextPaintStyle {
nscolor mTextColor; nscolor mTextColor;
nscolor mBGColor; nscolor mBGColor;
nscolor mUnderlineColor; nscolor mUnderlineColor;
uint8_t mUnderlineStyle; StyleTextDecorationStyle mUnderlineStyle;
float mUnderlineRelativeSize; float mUnderlineRelativeSize;
}; };
nsSelectionStyle mSelectionStyle[5]; nsSelectionStyle mSelectionStyle[5];
@ -4170,16 +4171,15 @@ void nsTextPaintStyle::GetIMESelectionColors(int32_t aIndex,
*aBackColor = selectionStyle->mBGColor; *aBackColor = selectionStyle->mBGColor;
} }
bool nsTextPaintStyle::GetSelectionUnderlineForPaint(int32_t aIndex, bool nsTextPaintStyle::GetSelectionUnderlineForPaint(
nscolor* aLineColor, int32_t aIndex, nscolor* aLineColor, float* aRelativeSize,
float* aRelativeSize, StyleTextDecorationStyle* aStyle) {
uint8_t* aStyle) {
NS_ASSERTION(aLineColor, "aLineColor is null"); NS_ASSERTION(aLineColor, "aLineColor is null");
NS_ASSERTION(aRelativeSize, "aRelativeSize is null"); NS_ASSERTION(aRelativeSize, "aRelativeSize is null");
NS_ASSERTION(aIndex >= 0 && aIndex < 5, "Index out of range"); NS_ASSERTION(aIndex >= 0 && aIndex < 5, "Index out of range");
nsSelectionStyle* selectionStyle = GetSelectionStyle(aIndex); nsSelectionStyle* selectionStyle = GetSelectionStyle(aIndex);
if (selectionStyle->mUnderlineStyle == NS_STYLE_TEXT_DECORATION_STYLE_NONE || if (selectionStyle->mUnderlineStyle == StyleTextDecorationStyle::None ||
selectionStyle->mUnderlineColor == NS_TRANSPARENT || selectionStyle->mUnderlineColor == NS_TRANSPARENT ||
selectionStyle->mUnderlineRelativeSize <= 0.0f) selectionStyle->mUnderlineRelativeSize <= 0.0f)
return false; return false;
@ -4375,7 +4375,7 @@ void nsTextPaintStyle::InitSelectionStyle(int32_t aIndex) {
nscolor lineColor; nscolor lineColor;
float relativeSize; float relativeSize;
uint8_t lineStyle; StyleTextDecorationStyle lineStyle;
GetSelectionUnderline(mFrame, aIndex, &lineColor, &relativeSize, &lineStyle); GetSelectionUnderline(mFrame, aIndex, &lineColor, &relativeSize, &lineStyle);
if (mResolveColors) { if (mResolveColors) {
@ -4394,7 +4394,7 @@ void nsTextPaintStyle::InitSelectionStyle(int32_t aIndex) {
bool nsTextPaintStyle::GetSelectionUnderline(nsIFrame* aFrame, int32_t aIndex, bool nsTextPaintStyle::GetSelectionUnderline(nsIFrame* aFrame, int32_t aIndex,
nscolor* aLineColor, nscolor* aLineColor,
float* aRelativeSize, float* aRelativeSize,
uint8_t* aStyle) { StyleTextDecorationStyle* aStyle) {
NS_ASSERTION(aFrame, "aFrame is null"); NS_ASSERTION(aFrame, "aFrame is null");
NS_ASSERTION(aRelativeSize, "aRelativeSize is null"); NS_ASSERTION(aRelativeSize, "aRelativeSize is null");
NS_ASSERTION(aStyle, "aStyle is null"); NS_ASSERTION(aStyle, "aStyle is null");
@ -4403,10 +4403,11 @@ bool nsTextPaintStyle::GetSelectionUnderline(nsIFrame* aFrame, int32_t aIndex,
StyleIDs& styleID = SelectionStyleIDs[aIndex]; StyleIDs& styleID = SelectionStyleIDs[aIndex];
nscolor color = LookAndFeel::Color(styleID.mLine, aFrame); nscolor color = LookAndFeel::Color(styleID.mLine, aFrame);
int32_t style = LookAndFeel::GetInt(styleID.mLineStyle); const int32_t lineStyle = LookAndFeel::GetInt(styleID.mLineStyle);
if (style > NS_STYLE_TEXT_DECORATION_STYLE_MAX) { auto style = static_cast<StyleTextDecorationStyle>(lineStyle);
if (lineStyle > static_cast<int32_t>(StyleTextDecorationStyle::Sentinel)) {
NS_ERROR("Invalid underline style value is specified"); NS_ERROR("Invalid underline style value is specified");
style = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; style = StyleTextDecorationStyle::Solid;
} }
float size = LookAndFeel::GetFloat(styleID.mLineRelativeSize); float size = LookAndFeel::GetFloat(styleID.mLineRelativeSize);
@ -4418,8 +4419,8 @@ bool nsTextPaintStyle::GetSelectionUnderline(nsIFrame* aFrame, int32_t aIndex,
*aRelativeSize = size; *aRelativeSize = size;
*aStyle = style; *aStyle = style;
return style != NS_STYLE_TEXT_DECORATION_STYLE_NONE && return style != StyleTextDecorationStyle::None && color != NS_TRANSPARENT &&
color != NS_TRANSPARENT && size > 0.0f; size > 0.0f;
} }
bool nsTextPaintStyle::GetSelectionShadow( bool nsTextPaintStyle::GetSelectionShadow(
@ -5336,7 +5337,7 @@ void nsTextFrame::GetTextDecorations(
physicalBlockStartOffset += physicalBlockStartOffset +=
vertical ? f->GetNormalPosition().x : f->GetNormalPosition().y; vertical ? f->GetNormalPosition().x : f->GetNormalPosition().y;
const uint8_t style = styleTextReset->mTextDecorationStyle; const auto style = styleTextReset->mTextDecorationStyle;
if (textDecorations) { if (textDecorations) {
nscolor color; nscolor color;
if (useOverride) { if (useOverride) {
@ -5675,13 +5676,13 @@ void nsTextFrame::UnionAdditionalOverflow(nsPresContext* aPresContext,
// The underline/overline drawable area must be contained in the overflow // The underline/overline drawable area must be contained in the overflow
// rect when this is in floating first letter frame at *both* modes. // rect when this is in floating first letter frame at *both* modes.
// In this case, aBlock is the ::first-letter frame. // In this case, aBlock is the ::first-letter frame.
uint8_t decorationStyle = auto decorationStyle =
aBlock->Style()->StyleTextReset()->mTextDecorationStyle; aBlock->Style()->StyleTextReset()->mTextDecorationStyle;
// If the style is none, let's include decoration line rect as solid style // If the style is none, let's include decoration line rect as solid style
// since changing the style from none to solid/dotted/dashed doesn't cause // since changing the style from none to solid/dotted/dashed doesn't cause
// reflow. // reflow.
if (decorationStyle == NS_STYLE_TEXT_DECORATION_STYLE_NONE) { if (decorationStyle == StyleTextDecorationStyle::None) {
decorationStyle = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; decorationStyle = StyleTextDecorationStyle::Solid;
} }
nsCSSRendering::DecorationRectParams params; nsCSSRendering::DecorationRectParams params;
@ -5780,8 +5781,8 @@ void nsTextFrame::UnionAdditionalOverflow(nsPresContext* aPresContext,
// If the style is solid, let's include decoration line rect of // If the style is solid, let's include decoration line rect of
// solid style since changing the style from none to // solid style since changing the style from none to
// solid/dotted/dashed doesn't cause reflow. // solid/dotted/dashed doesn't cause reflow.
if (params.style == NS_STYLE_TEXT_DECORATION_STYLE_NONE) { if (params.style == StyleTextDecorationStyle::None) {
params.style = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; params.style = StyleTextDecorationStyle::Solid;
} }
float inflation = GetInflationForTextDecorations( float inflation = GetInflationForTextDecorations(
@ -5964,23 +5965,23 @@ void nsTextFrame::PaintDecorationLine(
} }
} }
static uint8_t ToStyleLineStyle(const TextRangeStyle& aStyle) { static StyleTextDecorationStyle ToStyleLineStyle(const TextRangeStyle& aStyle) {
switch (aStyle.mLineStyle) { switch (aStyle.mLineStyle) {
case TextRangeStyle::LineStyle::None: case TextRangeStyle::LineStyle::None:
return NS_STYLE_TEXT_DECORATION_STYLE_NONE; return StyleTextDecorationStyle::None;
case TextRangeStyle::LineStyle::Solid: case TextRangeStyle::LineStyle::Solid:
return NS_STYLE_TEXT_DECORATION_STYLE_SOLID; return StyleTextDecorationStyle::Solid;
case TextRangeStyle::LineStyle::Dotted: case TextRangeStyle::LineStyle::Dotted:
return NS_STYLE_TEXT_DECORATION_STYLE_DOTTED; return StyleTextDecorationStyle::Dotted;
case TextRangeStyle::LineStyle::Dashed: case TextRangeStyle::LineStyle::Dashed:
return NS_STYLE_TEXT_DECORATION_STYLE_DASHED; return StyleTextDecorationStyle::Dashed;
case TextRangeStyle::LineStyle::Double: case TextRangeStyle::LineStyle::Double:
return NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE; return StyleTextDecorationStyle::Double;
case TextRangeStyle::LineStyle::Wavy: case TextRangeStyle::LineStyle::Wavy:
return NS_STYLE_TEXT_DECORATION_STYLE_WAVY; return StyleTextDecorationStyle::Wavy;
} }
MOZ_ASSERT_UNREACHABLE("Invalid line style"); MOZ_ASSERT_UNREACHABLE("Invalid line style");
return NS_STYLE_TEXT_DECORATION_STYLE_NONE; return StyleTextDecorationStyle::None;
} }
/** /**
@ -6107,7 +6108,7 @@ void nsTextFrame::DrawSelectionDecorations(
relativeSize = 2.0f; relativeSize = 2.0f;
aTextPaintStyle.GetURLSecondaryColor(&params.color); aTextPaintStyle.GetURLSecondaryColor(&params.color);
params.style = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; params.style = StyleTextDecorationStyle::Solid;
params.defaultLineThickness = metrics.strikeoutSize; params.defaultLineThickness = metrics.strikeoutSize;
params.lineSize.height = ComputeDecorationLineThickness( params.lineSize.height = ComputeDecorationLineThickness(
decThickness, params.defaultLineThickness, metrics, decThickness, params.defaultLineThickness, metrics,
@ -7306,7 +7307,7 @@ void nsTextFrame::DrawTextRunAndDecorations(
auto paintDecorationLine = [&](const LineDecoration& dec, auto paintDecorationLine = [&](const LineDecoration& dec,
gfxFloat Metrics::*lineSize, gfxFloat Metrics::*lineSize,
StyleTextDecorationLine lineType) { StyleTextDecorationLine lineType) {
if (dec.mStyle == NS_STYLE_TEXT_DECORATION_STYLE_NONE) { if (dec.mStyle == StyleTextDecorationStyle::None) {
return; return;
} }

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

@ -835,7 +835,7 @@ class nsTextFrame : public nsIFrame {
// thickness of the decoration line // thickness of the decoration line
const mozilla::StyleTextDecorationLength mTextDecorationThickness; const mozilla::StyleTextDecorationLength mTextDecorationThickness;
nscolor mColor; nscolor mColor;
uint8_t mStyle; mozilla::StyleTextDecorationStyle mStyle;
// The text-underline-position property; affects the underline offset only // The text-underline-position property; affects the underline offset only
// if mTextUnderlineOffset is auto. // if mTextUnderlineOffset is auto.
@ -845,7 +845,8 @@ class nsTextFrame : public nsIFrame {
mozilla::StyleTextUnderlinePosition aUnderlinePosition, mozilla::StyleTextUnderlinePosition aUnderlinePosition,
const mozilla::LengthPercentageOrAuto& aUnderlineOffset, const mozilla::LengthPercentageOrAuto& aUnderlineOffset,
const mozilla::StyleTextDecorationLength& aDecThickness, const mozilla::StyleTextDecorationLength& aDecThickness,
const nscolor aColor, const uint8_t aStyle) const nscolor aColor,
const mozilla::StyleTextDecorationStyle aStyle)
: mFrame(aFrame), : mFrame(aFrame),
mBaselineOffset(aOff), mBaselineOffset(aOff),
mTextUnderlineOffset(aUnderlineOffset), mTextUnderlineOffset(aUnderlineOffset),

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

@ -3619,12 +3619,13 @@ void nsCSSRendering::GetTableBorderSolidSegments(
// End table border-collapsing section // End table border-collapsing section
Rect nsCSSRendering::ExpandPaintingRectForDecorationLine( Rect nsCSSRendering::ExpandPaintingRectForDecorationLine(
nsIFrame* aFrame, const uint8_t aStyle, const Rect& aClippedRect, nsIFrame* aFrame, const StyleTextDecorationStyle aStyle,
const Float aICoordInFrame, const Float aCycleLength, bool aVertical) { const Rect& aClippedRect, const Float aICoordInFrame,
const Float aCycleLength, bool aVertical) {
switch (aStyle) { switch (aStyle) {
case NS_STYLE_TEXT_DECORATION_STYLE_DOTTED: case StyleTextDecorationStyle::Dotted:
case NS_STYLE_TEXT_DECORATION_STYLE_DASHED: case StyleTextDecorationStyle::Dashed:
case NS_STYLE_TEXT_DECORATION_STYLE_WAVY: case StyleTextDecorationStyle::Wavy:
break; break;
default: default:
NS_ERROR("Invalid style was specified"); NS_ERROR("Invalid style was specified");
@ -3969,7 +3970,7 @@ static void SkipInk(nsIFrame* aFrame, DrawTarget& aDrawTarget,
void nsCSSRendering::PaintDecorationLine( void nsCSSRendering::PaintDecorationLine(
nsIFrame* aFrame, DrawTarget& aDrawTarget, nsIFrame* aFrame, DrawTarget& aDrawTarget,
const PaintDecorationLineParams& aParams) { const PaintDecorationLineParams& aParams) {
NS_ASSERTION(aParams.style != NS_STYLE_TEXT_DECORATION_STYLE_NONE, NS_ASSERTION(aParams.style != StyleTextDecorationStyle::None,
"aStyle is none"); "aStyle is none");
Rect rect = ToRect(GetTextDecorationRectInternal(aParams.pt, aParams)); Rect rect = ToRect(GetTextDecorationRectInternal(aParams.pt, aParams));
@ -4143,10 +4144,10 @@ void nsCSSRendering::PaintDecorationLineInternal(
} }
switch (aParams.style) { switch (aParams.style) {
case NS_STYLE_TEXT_DECORATION_STYLE_SOLID: case StyleTextDecorationStyle::Solid:
case NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE: case StyleTextDecorationStyle::Double:
break; break;
case NS_STYLE_TEXT_DECORATION_STYLE_DASHED: { case StyleTextDecorationStyle::Dashed: {
autoPopClips.PushClipRect(aRect); autoPopClips.PushClipRect(aRect);
Float dashWidth = lineThickness * DOT_LENGTH * DASH_LENGTH; Float dashWidth = lineThickness * DOT_LENGTH * DASH_LENGTH;
dash[0] = dashWidth; dash[0] = dashWidth;
@ -4161,7 +4162,7 @@ void nsCSSRendering::PaintDecorationLineInternal(
aRect.width += dashWidth; aRect.width += dashWidth;
break; break;
} }
case NS_STYLE_TEXT_DECORATION_STYLE_DOTTED: { case StyleTextDecorationStyle::Dotted: {
autoPopClips.PushClipRect(aRect); autoPopClips.PushClipRect(aRect);
Float dashWidth = lineThickness * DOT_LENGTH; Float dashWidth = lineThickness * DOT_LENGTH;
if (lineThickness > 2.0) { if (lineThickness > 2.0) {
@ -4181,7 +4182,7 @@ void nsCSSRendering::PaintDecorationLineInternal(
aRect.width += dashWidth; aRect.width += dashWidth;
break; break;
} }
case NS_STYLE_TEXT_DECORATION_STYLE_WAVY: case StyleTextDecorationStyle::Wavy:
autoPopClips.PushClipRect(aRect); autoPopClips.PushClipRect(aRect);
if (lineThickness > 2.0) { if (lineThickness > 2.0) {
drawOptions.mAntialiasMode = AntialiasMode::SUBPIXEL; drawOptions.mAntialiasMode = AntialiasMode::SUBPIXEL;
@ -4205,9 +4206,9 @@ void nsCSSRendering::PaintDecorationLineInternal(
} }
switch (aParams.style) { switch (aParams.style) {
case NS_STYLE_TEXT_DECORATION_STYLE_SOLID: case StyleTextDecorationStyle::Solid:
case NS_STYLE_TEXT_DECORATION_STYLE_DOTTED: case StyleTextDecorationStyle::Dotted:
case NS_STYLE_TEXT_DECORATION_STYLE_DASHED: { case StyleTextDecorationStyle::Dashed: {
Point p1 = aRect.TopLeft(); Point p1 = aRect.TopLeft();
Point p2 = aParams.vertical ? aRect.BottomLeft() : aRect.TopRight(); Point p2 = aParams.vertical ? aRect.BottomLeft() : aRect.TopRight();
if (textDrawer) { if (textDrawer) {
@ -4218,7 +4219,7 @@ void nsCSSRendering::PaintDecorationLineInternal(
} }
return; return;
} }
case NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE: { case StyleTextDecorationStyle::Double: {
/** /**
* We are drawing double line as: * We are drawing double line as:
* *
@ -4247,18 +4248,16 @@ void nsCSSRendering::PaintDecorationLineInternal(
if (textDrawer) { if (textDrawer) {
textDrawer->AppendDecoration(p1a, p2a, lineThickness, aParams.vertical, textDrawer->AppendDecoration(p1a, p2a, lineThickness, aParams.vertical,
color, color, StyleTextDecorationStyle::Solid);
NS_STYLE_TEXT_DECORATION_STYLE_SOLID);
textDrawer->AppendDecoration(p1b, p2b, lineThickness, aParams.vertical, textDrawer->AppendDecoration(p1b, p2b, lineThickness, aParams.vertical,
color, color, StyleTextDecorationStyle::Solid);
NS_STYLE_TEXT_DECORATION_STYLE_SOLID);
} else { } else {
aDrawTarget.StrokeLine(p1a, p2a, colorPat, strokeOptions, drawOptions); aDrawTarget.StrokeLine(p1a, p2a, colorPat, strokeOptions, drawOptions);
aDrawTarget.StrokeLine(p1b, p2b, colorPat, strokeOptions, drawOptions); aDrawTarget.StrokeLine(p1b, p2b, colorPat, strokeOptions, drawOptions);
} }
return; return;
} }
case NS_STYLE_TEXT_DECORATION_STYLE_WAVY: { case StyleTextDecorationStyle::Wavy: {
/** /**
* We are drawing wavy line as: * We are drawing wavy line as:
* *
@ -4388,7 +4387,7 @@ void nsCSSRendering::PaintDecorationLineInternal(
Rect nsCSSRendering::DecorationLineToPath( Rect nsCSSRendering::DecorationLineToPath(
const PaintDecorationLineParams& aParams) { const PaintDecorationLineParams& aParams) {
NS_ASSERTION(aParams.style != NS_STYLE_TEXT_DECORATION_STYLE_NONE, NS_ASSERTION(aParams.style != StyleTextDecorationStyle::None,
"aStyle is none"); "aStyle is none");
Rect path; // To benefit from RVO, we return this from all return points Rect path; // To benefit from RVO, we return this from all return points
@ -4405,7 +4404,7 @@ Rect nsCSSRendering::DecorationLineToPath(
return path; return path;
} }
if (aParams.style != NS_STYLE_TEXT_DECORATION_STYLE_SOLID) { if (aParams.style != StyleTextDecorationStyle::Solid) {
// For the moment, we support only solid text decorations. // For the moment, we support only solid text decorations.
return path; return path;
} }
@ -4429,7 +4428,7 @@ Rect nsCSSRendering::DecorationLineToPath(
nsRect nsCSSRendering::GetTextDecorationRect( nsRect nsCSSRendering::GetTextDecorationRect(
nsPresContext* aPresContext, const DecorationRectParams& aParams) { nsPresContext* aPresContext, const DecorationRectParams& aParams) {
NS_ASSERTION(aPresContext, "aPresContext is null"); NS_ASSERTION(aPresContext, "aPresContext is null");
NS_ASSERTION(aParams.style != NS_STYLE_TEXT_DECORATION_STYLE_NONE, NS_ASSERTION(aParams.style != StyleTextDecorationStyle::None,
"aStyle is none"); "aStyle is none");
gfxRect rect = GetTextDecorationRectInternal(Point(0, 0), aParams); gfxRect rect = GetTextDecorationRectInternal(Point(0, 0), aParams);
@ -4444,11 +4443,12 @@ nsRect nsCSSRendering::GetTextDecorationRect(
gfxRect nsCSSRendering::GetTextDecorationRectInternal( gfxRect nsCSSRendering::GetTextDecorationRectInternal(
const Point& aPt, const DecorationRectParams& aParams) { const Point& aPt, const DecorationRectParams& aParams) {
NS_ASSERTION(aParams.style <= NS_STYLE_TEXT_DECORATION_STYLE_WAVY, NS_ASSERTION(aParams.style <= StyleTextDecorationStyle::Wavy,
"Invalid aStyle value"); "Invalid aStyle value");
if (aParams.style == NS_STYLE_TEXT_DECORATION_STYLE_NONE) if (aParams.style == StyleTextDecorationStyle::None) {
return gfxRect(0, 0, 0, 0); return gfxRect(0, 0, 0, 0);
}
bool canLiftUnderline = aParams.descentLimit >= 0.0; bool canLiftUnderline = aParams.descentLimit >= 0.0;
@ -4477,7 +4477,7 @@ gfxRect nsCSSRendering::GetTextDecorationRectInternal(
gfxFloat suggestedMaxRectHeight = gfxFloat suggestedMaxRectHeight =
std::max(std::min(ascent, descentLimit), 1.0); std::max(std::min(ascent, descentLimit), 1.0);
r.height = lineThickness; r.height = lineThickness;
if (aParams.style == NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE) { if (aParams.style == StyleTextDecorationStyle::Double) {
/** /**
* We will draw double line as: * We will draw double line as:
* *
@ -4503,7 +4503,7 @@ gfxRect nsCSSRendering::GetTextDecorationRectInternal(
r.height = std::max(suggestedMaxRectHeight, lineThickness * 2.0 + 1.0); r.height = std::max(suggestedMaxRectHeight, lineThickness * 2.0 + 1.0);
} }
} }
} else if (aParams.style == NS_STYLE_TEXT_DECORATION_STYLE_WAVY) { } else if (aParams.style == StyleTextDecorationStyle::Wavy) {
/** /**
* We will draw wavy line as: * We will draw wavy line as:
* *

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

@ -618,9 +618,9 @@ struct nsCSSRendering {
// UNDERLINE or OVERLINE or LINE_THROUGH. // UNDERLINE or OVERLINE or LINE_THROUGH.
mozilla::StyleTextDecorationLine decoration = mozilla::StyleTextDecorationLine decoration =
mozilla::StyleTextDecorationLine::UNDERLINE; mozilla::StyleTextDecorationLine::UNDERLINE;
// The style of the decoration line such as // The style of the decoration line
// NS_STYLE_TEXT_DECORATION_STYLE_*. mozilla::StyleTextDecorationStyle style =
uint8_t style = NS_STYLE_TEXT_DECORATION_STYLE_NONE; mozilla::StyleTextDecorationStyle::None;
bool vertical = false; bool vertical = false;
bool sidewaysLeft = false; bool sidewaysLeft = false;
gfxTextRun::Range glyphRange; gfxTextRun::Range glyphRange;
@ -764,9 +764,6 @@ struct nsCSSRendering {
* input: * input:
* @param aFrame the frame which needs the decoration line. * @param aFrame the frame which needs the decoration line.
* @param aStyle the style of the complex decoration line * @param aStyle the style of the complex decoration line
* NS_STYLE_TEXT_DECORATION_STYLE_DOTTED or
* NS_STYLE_TEXT_DECORATION_STYLE_DASHED or
* NS_STYLE_TEXT_DECORATION_STYLE_WAVY.
* @param aClippedRect the clipped rect for the decoration line. * @param aClippedRect the clipped rect for the decoration line.
* in other words, visible area of the line. * in other words, visible area of the line.
* @param aICoordInFrame the distance between inline-start edge of aFrame * @param aICoordInFrame the distance between inline-start edge of aFrame
@ -774,8 +771,9 @@ struct nsCSSRendering {
* @param aCycleLength the width of one cycle of the line style. * @param aCycleLength the width of one cycle of the line style.
*/ */
static Rect ExpandPaintingRectForDecorationLine( static Rect ExpandPaintingRectForDecorationLine(
nsIFrame* aFrame, const uint8_t aStyle, const Rect& aClippedRect, nsIFrame* aFrame, const mozilla::StyleTextDecorationStyle aStyle,
const Float aICoordInFrame, const Float aCycleLength, bool aVertical); const Rect& aClippedRect, const Float aICoordInFrame,
const Float aCycleLength, bool aVertical);
}; };
/* /*

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

@ -145,6 +145,7 @@ rusty-enums = [
"mozilla::StyleShapeRendering", "mozilla::StyleShapeRendering",
"mozilla::StyleTextAnchor", "mozilla::StyleTextAnchor",
"mozilla::StyleObjectFit", "mozilla::StyleObjectFit",
"mozilla::StyleTextDecorationStyle",
"mozilla::StyleTopLayer", "mozilla::StyleTopLayer",
"mozilla::StyleIsolation", "mozilla::StyleIsolation",
"mozilla::StyleTextOrientation", "mozilla::StyleTextOrientation",

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

@ -473,14 +473,15 @@ enum class StyleObjectFit : uint8_t {
}; };
// See nsStyleText // See nsStyleText
#define NS_STYLE_TEXT_DECORATION_STYLE_NONE \ enum class StyleTextDecorationStyle : uint8_t {
0 // not in CSS spec, mapped to -moz-none None, // not in CSS spec, mapped to -moz-none
#define NS_STYLE_TEXT_DECORATION_STYLE_DOTTED 1 Dotted,
#define NS_STYLE_TEXT_DECORATION_STYLE_DASHED 2 Dashed,
#define NS_STYLE_TEXT_DECORATION_STYLE_SOLID 3 Solid,
#define NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE 4 Double,
#define NS_STYLE_TEXT_DECORATION_STYLE_WAVY 5 Wavy,
#define NS_STYLE_TEXT_DECORATION_STYLE_MAX NS_STYLE_TEXT_DECORATION_STYLE_WAVY Sentinel = Wavy
};
// See nsStyleDisplay // See nsStyleDisplay
enum class StyleTopLayer : uint8_t { enum class StyleTopLayer : uint8_t {

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

@ -2869,7 +2869,7 @@ void nsStyleContent::TriggerImageLoads(Document& aDoc,
nsStyleTextReset::nsStyleTextReset(const Document& aDocument) nsStyleTextReset::nsStyleTextReset(const Document& aDocument)
: mTextOverflow(), : mTextOverflow(),
mTextDecorationLine(StyleTextDecorationLine::NONE), mTextDecorationLine(StyleTextDecorationLine::NONE),
mTextDecorationStyle(NS_STYLE_TEXT_DECORATION_STYLE_SOLID), mTextDecorationStyle(StyleTextDecorationStyle::Solid),
mUnicodeBidi(StyleUnicodeBidi::Normal), mUnicodeBidi(StyleUnicodeBidi::Normal),
mInitialLetterSink(0), mInitialLetterSink(0),
mInitialLetterSize(0.0f), mInitialLetterSize(0.0f),

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

@ -919,7 +919,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTextReset {
mozilla::StyleTextOverflow mTextOverflow; mozilla::StyleTextOverflow mTextOverflow;
mozilla::StyleTextDecorationLine mTextDecorationLine; mozilla::StyleTextDecorationLine mTextDecorationLine;
uint8_t mTextDecorationStyle; // NS_STYLE_TEXT_DECORATION_STYLE_* mozilla::StyleTextDecorationStyle mTextDecorationStyle;
mozilla::StyleUnicodeBidi mUnicodeBidi; mozilla::StyleUnicodeBidi mUnicodeBidi;
nscoord mInitialLetterSink; // 0 means normal nscoord mInitialLetterSink; // 0 means normal
float mInitialLetterSize; // 0.0f means normal float mInitialLetterSize; // 0.0f means normal

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

@ -354,9 +354,9 @@ void nsTextBoxFrame::DrawText(gfxContext& aRenderingContext,
nscolor overColor = 0; nscolor overColor = 0;
nscolor underColor = 0; nscolor underColor = 0;
nscolor strikeColor = 0; nscolor strikeColor = 0;
uint8_t overStyle = 0; auto overStyle = StyleTextDecorationStyle::None;
uint8_t underStyle = 0; auto underStyle = StyleTextDecorationStyle::None;
uint8_t strikeStyle = 0; auto strikeStyle = StyleTextDecorationStyle::None;
// Begin with no decorations // Begin with no decorations
auto decorations = StyleTextDecorationLine::NONE; auto decorations = StyleTextDecorationLine::NONE;
@ -384,7 +384,7 @@ void nsTextBoxFrame::DrawText(gfxContext& aRenderingContext,
} else { } else {
color = styleText->mTextDecorationColor.CalcColor(*context); color = styleText->mTextDecorationColor.CalcColor(*context);
} }
uint8_t style = styleText->mTextDecorationStyle; const auto style = styleText->mTextDecorationStyle;
if (StyleTextDecorationLine::UNDERLINE & decorMask & if (StyleTextDecorationLine::UNDERLINE & decorMask &
styleText->mTextDecorationLine) { styleText->mTextDecorationLine) {
@ -453,7 +453,7 @@ void nsTextBoxFrame::DrawText(gfxContext& aRenderingContext,
fontMet->GetUnderline(offset, size); fontMet->GetUnderline(offset, size);
params.lineSize.height = presContext->AppUnitsToGfxUnits(size); params.lineSize.height = presContext->AppUnitsToGfxUnits(size);
if ((decorations & StyleTextDecorationLine::UNDERLINE) && if ((decorations & StyleTextDecorationLine::UNDERLINE) &&
underStyle != NS_STYLE_TEXT_DECORATION_STYLE_NONE) { underStyle != StyleTextDecorationStyle::None) {
params.color = underColor; params.color = underColor;
params.offset = presContext->AppUnitsToGfxUnits(offset); params.offset = presContext->AppUnitsToGfxUnits(offset);
params.decoration = StyleTextDecorationLine::UNDERLINE; params.decoration = StyleTextDecorationLine::UNDERLINE;
@ -461,7 +461,7 @@ void nsTextBoxFrame::DrawText(gfxContext& aRenderingContext,
nsCSSRendering::PaintDecorationLine(this, *drawTarget, params); nsCSSRendering::PaintDecorationLine(this, *drawTarget, params);
} }
if ((decorations & StyleTextDecorationLine::OVERLINE) && if ((decorations & StyleTextDecorationLine::OVERLINE) &&
overStyle != NS_STYLE_TEXT_DECORATION_STYLE_NONE) { overStyle != StyleTextDecorationStyle::None) {
params.color = overColor; params.color = overColor;
params.offset = params.ascent; params.offset = params.ascent;
params.decoration = StyleTextDecorationLine::OVERLINE; params.decoration = StyleTextDecorationLine::OVERLINE;
@ -537,7 +537,7 @@ void nsTextBoxFrame::DrawText(gfxContext& aRenderingContext,
// Strikeout is drawn on top of the text, per // Strikeout is drawn on top of the text, per
// http://www.w3.org/TR/CSS21/zindex.html point 7.2.1.4.1.1. // http://www.w3.org/TR/CSS21/zindex.html point 7.2.1.4.1.1.
if ((decorations & StyleTextDecorationLine::LINE_THROUGH) && if ((decorations & StyleTextDecorationLine::LINE_THROUGH) &&
strikeStyle != NS_STYLE_TEXT_DECORATION_STYLE_NONE) { strikeStyle != StyleTextDecorationStyle::None) {
fontMet->GetStrikeout(offset, size); fontMet->GetStrikeout(offset, size);
params.color = strikeColor; params.color = strikeColor;
params.lineSize.height = presContext->AppUnitsToGfxUnits(size); params.lineSize.height = presContext->AppUnitsToGfxUnits(size);

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

@ -43,6 +43,7 @@ ${helpers.single_keyword(
"text-decoration-style", "text-decoration-style",
"solid double dotted dashed wavy -moz-none", "solid double dotted dashed wavy -moz-none",
engines="gecko servo-2020", engines="gecko servo-2020",
gecko_enum_prefix="StyleTextDecorationStyle",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-style", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-style",
)} )}

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

@ -330,7 +330,7 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
break; break;
case IntID::SpellCheckerUnderlineStyle: case IntID::SpellCheckerUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY; aResult = reinterpret_cast<int32_t>(StyleTextDecorationStyle::Wavy);
break; break;
case IntID::ScrollbarButtonAutoRepeatBehavior: case IntID::ScrollbarButtonAutoRepeatBehavior:

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

@ -462,10 +462,10 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
case IntID::IMEConvertedTextUnderlineStyle: case IntID::IMEConvertedTextUnderlineStyle:
case IntID::IMESelectedRawTextUnderlineStyle: case IntID::IMESelectedRawTextUnderlineStyle:
case IntID::IMESelectedConvertedTextUnderline: case IntID::IMESelectedConvertedTextUnderline:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Solid);
break; break;
case IntID::SpellCheckerUnderlineStyle: case IntID::SpellCheckerUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Dotted);
break; break;
case IntID::ScrollbarButtonAutoRepeatBehavior: case IntID::ScrollbarButtonAutoRepeatBehavior:
aResult = 0; aResult = 0;

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

@ -889,14 +889,14 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
break; break;
case IntID::IMERawInputUnderlineStyle: case IntID::IMERawInputUnderlineStyle:
case IntID::IMEConvertedTextUnderlineStyle: case IntID::IMEConvertedTextUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Solid);
break; break;
case IntID::IMESelectedRawTextUnderlineStyle: case IntID::IMESelectedRawTextUnderlineStyle:
case IntID::IMESelectedConvertedTextUnderline: case IntID::IMESelectedConvertedTextUnderline:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE; aResult = static_cast<int32_t>(StyleTextDecorationStyle::None);
break; break;
case IntID::SpellCheckerUnderlineStyle: case IntID::SpellCheckerUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Wavy);
break; break;
case IntID::MenuBarDrag: case IntID::MenuBarDrag:
EnsureInit(); EnsureInit();

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

@ -114,10 +114,10 @@ nsresult HeadlessLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
case IntID::IMESelectedRawTextUnderlineStyle: case IntID::IMESelectedRawTextUnderlineStyle:
case IntID::IMEConvertedTextUnderlineStyle: case IntID::IMEConvertedTextUnderlineStyle:
case IntID::IMESelectedConvertedTextUnderline: case IntID::IMESelectedConvertedTextUnderline:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Solid);
break; break;
case IntID::SpellCheckerUnderlineStyle: case IntID::SpellCheckerUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Dotted);
break; break;
case IntID::MenuBarDrag: case IntID::MenuBarDrag:
aResult = 0; aResult = 0;

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

@ -311,10 +311,10 @@ nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
case IntID::IMEConvertedTextUnderlineStyle: case IntID::IMEConvertedTextUnderlineStyle:
case IntID::IMESelectedRawTextUnderlineStyle: case IntID::IMESelectedRawTextUnderlineStyle:
case IntID::IMESelectedConvertedTextUnderline: case IntID::IMESelectedConvertedTextUnderline:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Solid);
break; break;
case IntID::SpellCheckerUnderlineStyle: case IntID::SpellCheckerUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Dotted);
break; break;
case IntID::ContextMenuOffsetVertical: case IntID::ContextMenuOffsetVertical:
case IntID::ContextMenuOffsetHorizontal: case IntID::ContextMenuOffsetHorizontal:

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

@ -558,14 +558,14 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
break; break;
case IntID::IMERawInputUnderlineStyle: case IntID::IMERawInputUnderlineStyle:
case IntID::IMEConvertedTextUnderlineStyle: case IntID::IMEConvertedTextUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_DASHED; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Dashed);
break; break;
case IntID::IMESelectedRawTextUnderlineStyle: case IntID::IMESelectedRawTextUnderlineStyle:
case IntID::IMESelectedConvertedTextUnderline: case IntID::IMESelectedConvertedTextUnderline:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE; aResult = static_cast<int32_t>(StyleTextDecorationStyle::None);
break; break;
case IntID::SpellCheckerUnderlineStyle: case IntID::SpellCheckerUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY; aResult = static_cast<int32_t>(StyleTextDecorationStyle::Wavy);
break; break;
case IntID::ScrollbarButtonAutoRepeatBehavior: case IntID::ScrollbarButtonAutoRepeatBehavior:
aResult = 0; aResult = 0;