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(')');
}
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
// make an FFI call here.
switch (aValue) {
case NS_STYLE_TEXT_DECORATION_STYLE_NONE:
case StyleTextDecorationStyle::None:
return NS_Atomize("-moz-none");
case NS_STYLE_TEXT_DECORATION_STYLE_SOLID:
case StyleTextDecorationStyle::Solid:
return NS_Atomize("solid");
case NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE:
case StyleTextDecorationStyle::Double:
return NS_Atomize("double");
case NS_STYLE_TEXT_DECORATION_STYLE_DOTTED:
case StyleTextDecorationStyle::Dotted:
return NS_Atomize("dotted");
case NS_STYLE_TEXT_DECORATION_STYLE_DASHED:
case StyleTextDecorationStyle::Dashed:
return NS_Atomize("dashed");
case NS_STYLE_TEXT_DECORATION_STYLE_WAVY:
case StyleTextDecorationStyle::Wavy:
return NS_Atomize("wavy");
default:
MOZ_ASSERT_UNREACHABLE("Unknown decoration style");

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -618,9 +618,9 @@ struct nsCSSRendering {
// UNDERLINE or OVERLINE or LINE_THROUGH.
mozilla::StyleTextDecorationLine decoration =
mozilla::StyleTextDecorationLine::UNDERLINE;
// The style of the decoration line such as
// NS_STYLE_TEXT_DECORATION_STYLE_*.
uint8_t style = NS_STYLE_TEXT_DECORATION_STYLE_NONE;
// The style of the decoration line
mozilla::StyleTextDecorationStyle style =
mozilla::StyleTextDecorationStyle::None;
bool vertical = false;
bool sidewaysLeft = false;
gfxTextRun::Range glyphRange;
@ -764,9 +764,6 @@ struct nsCSSRendering {
* input:
* @param aFrame the frame which needs the 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.
* in other words, visible area of the line.
* @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.
*/
static Rect ExpandPaintingRectForDecorationLine(
nsIFrame* aFrame, const uint8_t aStyle, const Rect& aClippedRect,
const Float aICoordInFrame, const Float aCycleLength, bool aVertical);
nsIFrame* aFrame, const mozilla::StyleTextDecorationStyle aStyle,
const Rect& aClippedRect, const Float aICoordInFrame,
const Float aCycleLength, bool aVertical);
};
/*

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

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

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

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

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

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

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

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

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

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

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

@ -43,6 +43,7 @@ ${helpers.single_keyword(
"text-decoration-style",
"solid double dotted dashed wavy -moz-none",
engines="gecko servo-2020",
gecko_enum_prefix="StyleTextDecorationStyle",
animation_value_type="discrete",
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;
case IntID::SpellCheckerUnderlineStyle:
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
aResult = reinterpret_cast<int32_t>(StyleTextDecorationStyle::Wavy);
break;
case IntID::ScrollbarButtonAutoRepeatBehavior:

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

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

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

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

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

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

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

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

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

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