Bug 1328540 - convert NS_STYLE_HYPHENS_* to an enum class.
MozReview-Commit-ID: BwTzbA29Y3H
--- a/gfx/src/nsFontMetrics.cpp
+++ b/gfx/src/nsFontMetrics.cpp
@@ -13,17 +13,17 @@
#include "gfxTypes.h" // for gfxFloat
#include "nsBoundingMetrics.h" // for nsBoundingMetrics
#include "nsDebug.h" // for NS_ERROR
#include "nsDeviceContext.h" // for nsDeviceContext
#include "nsIAtom.h" // for nsIAtom
#include "nsMathUtils.h" // for NS_round
#include "nsRenderingContext.h" // for nsRenderingContext
#include "nsString.h" // for nsString
-#include "nsStyleConsts.h" // for NS_STYLE_HYPHENS_NONE
+#include "nsStyleConsts.h" // for StyleHyphens::None
#include "mozilla/Assertions.h" // for MOZ_ASSERT
#include "mozilla/UniquePtr.h" // for UniquePtr
class gfxUserFontSet;
using namespace mozilla;
namespace {
@@ -82,19 +82,19 @@ private:
};
class StubPropertyProvider : public gfxTextRun::PropertyProvider {
public:
virtual void GetHyphenationBreaks(gfxTextRun::Range aRange,
bool* aBreakBefore) {
NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
}
- virtual int8_t GetHyphensOption() {
+ virtual mozilla::StyleHyphens GetHyphensOption() {
NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
- return NS_STYLE_HYPHENS_NONE;
+ return mozilla::StyleHyphens::None;
}
virtual gfxFloat GetHyphenWidth() {
NS_ERROR("This shouldn't be called because we never enable hyphens");
return 0;
}
virtual already_AddRefed<mozilla::gfx::DrawTarget> GetDrawTarget() {
NS_ERROR("This shouldn't be called because we never enable hyphens");
return nullptr;
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -857,18 +857,18 @@ gfxTextRun::BreakAndMeasureText(uint32_t
std::min<uint32_t>(aMaxLength, MEASUREMENT_BUFFER_SIZE));
PropertyProvider::Spacing spacingBuffer[MEASUREMENT_BUFFER_SIZE];
bool haveSpacing = aProvider && (mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING) != 0;
if (haveSpacing) {
GetAdjustedSpacing(this, bufferRange, aProvider, spacingBuffer);
}
bool hyphenBuffer[MEASUREMENT_BUFFER_SIZE];
bool haveHyphenation = aProvider &&
- (aProvider->GetHyphensOption() == NS_STYLE_HYPHENS_AUTO ||
- (aProvider->GetHyphensOption() == NS_STYLE_HYPHENS_MANUAL &&
+ (aProvider->GetHyphensOption() == StyleHyphens::Auto ||
+ (aProvider->GetHyphensOption() == StyleHyphens::Manual &&
(mFlags & gfxTextRunFactory::TEXT_ENABLE_HYPHEN_BREAKS) != 0));
if (haveHyphenation) {
aProvider->GetHyphenationBreaks(bufferRange, hyphenBuffer);
}
gfxFloat width = 0;
gfxFloat advance = 0;
// The number of space characters that can be trimmed or hang at a soft-wrap
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -30,16 +30,17 @@ class gfxFontGroup;
class gfxUserFontEntry;
class gfxUserFontSet;
class nsIAtom;
class nsILanguageAtomService;
class gfxMissingFontRecorder;
namespace mozilla {
class SVGContextPaint;
+enum class StyleHyphens : uint8_t;
};
/**
* Callback for Draw() to use when drawing text with mode
* DrawMode::GLYPH_PATH.
*/
struct gfxTextRunDrawCallbacks {
@@ -187,18 +188,18 @@ public:
class PropertyProvider {
public:
// Detect hyphenation break opportunities in the given range; breaks
// not at cluster boundaries will be ignored.
virtual void GetHyphenationBreaks(Range aRange, bool *aBreakBefore) = 0;
// Returns the provider's hyphenation setting, so callers can decide
// whether it is necessary to call GetHyphenationBreaks.
- // Result is an NS_STYLE_HYPHENS_* value.
- virtual int8_t GetHyphensOption() = 0;
+ // Result is an StyleHyphens value.
+ virtual mozilla::StyleHyphens GetHyphensOption() = 0;
// Returns the extra width that will be consumed by a hyphen. This should
// be constant for a given textrun.
virtual gfxFloat GetHyphenWidth() = 0;
typedef gfxFont::Spacing Spacing;
/**
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -2594,17 +2594,17 @@ BuildTextRunsScanner::SetupBreakSinksFor
flags |= nsLineBreaker::BREAK_SUPPRESS_INSIDE;
}
if (aTextRun->GetFlags() & nsTextFrameUtils::TEXT_NO_BREAKS) {
flags |= nsLineBreaker::BREAK_SKIP_SETTING_NO_BREAKS;
}
if (textStyle->mTextTransform == NS_STYLE_TEXT_TRANSFORM_CAPITALIZE) {
flags |= nsLineBreaker::BREAK_NEED_CAPITALIZATION;
}
- if (textStyle->mHyphens == NS_STYLE_HYPHENS_AUTO) {
+ if (textStyle->mHyphens == StyleHyphens::Auto) {
flags |= nsLineBreaker::BREAK_USE_AUTO_HYPHENATION;
}
if (HasCompressedLeadingWhitespace(startFrame, textStyle,
mappedFlow->GetContentEnd(), iter)) {
mLineBreaker.AppendInvisibleWhitespace(flags);
}
@@ -3112,17 +3112,17 @@ public:
// Call this after construction if you're not going to reflow the text
void InitializeForDisplay(bool aTrimAfter);
void InitializeForMeasure();
virtual void GetSpacing(Range aRange, Spacing* aSpacing);
virtual gfxFloat GetHyphenWidth();
virtual void GetHyphenationBreaks(Range aRange, bool* aBreakBefore);
- virtual int8_t GetHyphensOption() {
+ virtual StyleHyphens GetHyphensOption() {
return mTextStyle->mHyphens;
}
virtual already_AddRefed<DrawTarget> GetDrawTarget() {
return CreateReferenceDrawTarget(GetFrame());
}
virtual uint32_t GetAppUnitsPerDevUnit() {
@@ -3555,17 +3555,17 @@ PropertyProvider::GetHyphenWidth()
void
PropertyProvider::GetHyphenationBreaks(Range aRange, bool* aBreakBefore)
{
NS_PRECONDITION(IsInBounds(mStart, mLength, aRange), "Range out of bounds");
NS_PRECONDITION(mLength != INT32_MAX, "Can't call this with undefined length");
if (!mTextStyle->WhiteSpaceCanWrap(mFrame) ||
- mTextStyle->mHyphens == NS_STYLE_HYPHENS_NONE)
+ mTextStyle->mHyphens == StyleHyphens::None)
{
memset(aBreakBefore, false, aRange.Length() * sizeof(bool));
return;
}
// Iterate through the original-string character runs
nsSkipCharsRunIterator run(
mStart, nsSkipCharsRunIterator::LENGTH_UNSKIPPED_ONLY, aRange.Length());
@@ -3593,17 +3593,17 @@ PropertyProvider::GetHyphenationBreaks(R
// Don't allow hyphen breaks at the start of the line
aBreakBefore[runOffsetInSubstring] = allowHyphenBreakBeforeNextChar &&
(!(mFrame->GetStateBits() & TEXT_START_OF_LINE) ||
run.GetSkippedOffset() > mStart.GetSkippedOffset());
allowHyphenBreakBeforeNextChar = false;
}
}
- if (mTextStyle->mHyphens == NS_STYLE_HYPHENS_AUTO) {
+ if (mTextStyle->mHyphens == StyleHyphens::Auto) {
for (uint32_t i = 0; i < aRange.Length(); ++i) {
if (mTextRun->CanHyphenateBefore(aRange.start + i)) {
aBreakBefore[i] = true;
}
}
}
}
@@ -8333,18 +8333,18 @@ nsTextFrame::AddInlineMinISizeForFlow(ns
// OK since we can't really handle tabs for intrinsic sizing anyway.
const nsStyleText* textStyle = StyleText();
const nsTextFragment* frag = mContent->GetText();
// If we're hyphenating, the PropertyProvider needs the actual length;
// otherwise we can just pass INT32_MAX to mean "all the text"
int32_t len = INT32_MAX;
bool hyphenating = frag->GetLength() > 0 &&
- (textStyle->mHyphens == NS_STYLE_HYPHENS_AUTO ||
- (textStyle->mHyphens == NS_STYLE_HYPHENS_MANUAL &&
+ (textStyle->mHyphens == StyleHyphens::Auto ||
+ (textStyle->mHyphens == StyleHyphens::Manual &&
(textRun->GetFlags() & gfxTextRunFactory::TEXT_ENABLE_HYPHEN_BREAKS) != 0));
if (hyphenating) {
gfxSkipCharsIterator tmp(iter);
len = std::min<int32_t>(GetContentOffset() + GetInFlowContentLength(),
tmp.ConvertSkippedToOriginal(flowEndInTextRun)) - iter.GetOriginalOffset();
}
PropertyProvider provider(textRun, textStyle, frag, this,
iter, len, nullptr, 0, aTextRunType);
@@ -9505,17 +9505,17 @@ nsTextFrame::ReflowText(nsLineLayout& aL
// frame to accumulate with trimmable width from this frame.)
if (transformedCharsFit > 0) {
aLineLayout.SetTrimmableISize(NSToCoordFloor(trimmableWidth));
AddStateBits(TEXT_HAS_NONCOLLAPSED_CHARACTERS);
}
bool breakAfter = forceBreakAfter;
if (!shouldSuppressLineBreak) {
if (charsFit > 0 && charsFit == length &&
- textStyle->mHyphens != NS_STYLE_HYPHENS_NONE &&
+ textStyle->mHyphens != StyleHyphens::None &&
HasSoftHyphenBefore(frag, mTextRun, offset, end)) {
bool fits =
textMetrics.mAdvanceWidth + provider.GetHyphenWidth() <= availWidth;
// Record a potential break after final soft hyphen
aLineLayout.NotifyOptionalBreakPosition(this, length, fits,
gfxBreakPriority::eNormalBreak);
}
// length == 0 means either the text is empty or it's all collapsed away
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1474,19 +1474,19 @@ const KTableEntry nsCSSProps::kFlexDirec
const KTableEntry nsCSSProps::kFlexWrapKTable[] = {
{ eCSSKeyword_nowrap, NS_STYLE_FLEX_WRAP_NOWRAP },
{ eCSSKeyword_wrap, NS_STYLE_FLEX_WRAP_WRAP },
{ eCSSKeyword_wrap_reverse, NS_STYLE_FLEX_WRAP_WRAP_REVERSE },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kHyphensKTable[] = {
- { eCSSKeyword_none, NS_STYLE_HYPHENS_NONE },
- { eCSSKeyword_manual, NS_STYLE_HYPHENS_MANUAL },
- { eCSSKeyword_auto, NS_STYLE_HYPHENS_AUTO },
+ { eCSSKeyword_none, StyleHyphens::None },
+ { eCSSKeyword_manual, StyleHyphens::Manual },
+ { eCSSKeyword_auto, StyleHyphens::Auto },
{ eCSSKeyword_UNKNOWN, -1 }
};
KTableEntry nsCSSProps::kFloatKTable[] = {
{ eCSSKeyword_none, StyleFloat::None },
{ eCSSKeyword_left, StyleFloat::Left },
{ eCSSKeyword_right, StyleFloat::Right },
{ eCSSKeyword_inline_start, StyleFloat::InlineStart },
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1443,16 +1443,17 @@ struct SetEnumValueHelper
DEFINE_ENUM_CLASS_SETTER(StyleBoxDirection, Normal, Reverse)
DEFINE_ENUM_CLASS_SETTER(StyleBoxOrient, Horizontal, Vertical)
DEFINE_ENUM_CLASS_SETTER(StyleBoxPack, Start, Justify)
DEFINE_ENUM_CLASS_SETTER(StyleBoxSizing, Content, Border)
DEFINE_ENUM_CLASS_SETTER(StyleClear, None, Both)
DEFINE_ENUM_CLASS_SETTER(StyleFillRule, Nonzero, Evenodd)
DEFINE_ENUM_CLASS_SETTER(StyleFloat, None, InlineEnd)
DEFINE_ENUM_CLASS_SETTER(StyleFloatEdge, ContentBox, MarginBox)
+ DEFINE_ENUM_CLASS_SETTER(StyleHyphens, None, Auto)
DEFINE_ENUM_CLASS_SETTER(StyleUserFocus, None, SelectMenu)
DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None, MozText)
DEFINE_ENUM_CLASS_SETTER(StyleUserInput, None, Auto)
DEFINE_ENUM_CLASS_SETTER(StyleUserModify, ReadOnly, WriteOnly)
DEFINE_ENUM_CLASS_SETTER(StyleWindowDragging, Default, NoDrag)
DEFINE_ENUM_CLASS_SETTER(StyleOrient, Inline, Vertical)
#ifdef MOZ_XUL
DEFINE_ENUM_CLASS_SETTER(StyleDisplay, None, MozPopup)
@@ -4927,17 +4928,17 @@ nsRuleNode::ComputeTextData(void* aStart
SETVAL_ENUMERATED | SETVAL_UNSET_INHERIT,
parentText->mOverflowWrap,
NS_STYLE_OVERFLOWWRAP_NORMAL);
// hyphens: enum, inherit, initial
SetValue(*aRuleData->ValueForHyphens(), text->mHyphens, conditions,
SETVAL_ENUMERATED | SETVAL_UNSET_INHERIT,
parentText->mHyphens,
- NS_STYLE_HYPHENS_MANUAL);
+ StyleHyphens::Manual);
// ruby-align: enum, inherit, initial
SetValue(*aRuleData->ValueForRubyAlign(),
text->mRubyAlign, conditions,
SETVAL_ENUMERATED | SETVAL_UNSET_INHERIT,
parentText->mRubyAlign,
NS_STYLE_RUBY_ALIGN_SPACE_AROUND);
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -160,16 +160,23 @@ enum class StyleFloat : uint8_t {
};
// float-edge
enum class StyleFloatEdge : uint8_t {
ContentBox,
MarginBox,
};
+// Hyphens
+enum class StyleHyphens : uint8_t {
+ None,
+ Manual,
+ Auto,
+};
+
// shape-box for shape-outside
enum class StyleShapeOutsideShapeBox : uint8_t {
NoBox,
Content,
Padding,
Border,
Margin
};
@@ -966,21 +973,16 @@ enum class StyleDisplay : uint8_t {
#define NS_STYLE_WORDBREAK_NORMAL 0
#define NS_STYLE_WORDBREAK_BREAK_ALL 1
#define NS_STYLE_WORDBREAK_KEEP_ALL 2
// See nsStyleText
#define NS_STYLE_OVERFLOWWRAP_NORMAL 0
#define NS_STYLE_OVERFLOWWRAP_BREAK_WORD 1
-// See nsStyleText
-#define NS_STYLE_HYPHENS_NONE 0
-#define NS_STYLE_HYPHENS_MANUAL 1
-#define NS_STYLE_HYPHENS_AUTO 2
-
// ruby-align, see nsStyleText
#define NS_STYLE_RUBY_ALIGN_START 0
#define NS_STYLE_RUBY_ALIGN_CENTER 1
#define NS_STYLE_RUBY_ALIGN_SPACE_BETWEEN 2
#define NS_STYLE_RUBY_ALIGN_SPACE_AROUND 3
// ruby-position, see nsStyleText
#define NS_STYLE_RUBY_POSITION_OVER 0
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3773,17 +3773,17 @@ nsStyleText::nsStyleText(StyleStructCont
: mTextAlign(NS_STYLE_TEXT_ALIGN_START)
, mTextAlignLast(NS_STYLE_TEXT_ALIGN_AUTO)
, mTextAlignTrue(false)
, mTextAlignLastTrue(false)
, mTextTransform(NS_STYLE_TEXT_TRANSFORM_NONE)
, mWhiteSpace(NS_STYLE_WHITESPACE_NORMAL)
, mWordBreak(NS_STYLE_WORDBREAK_NORMAL)
, mOverflowWrap(NS_STYLE_OVERFLOWWRAP_NORMAL)
- , mHyphens(NS_STYLE_HYPHENS_MANUAL)
+ , mHyphens(StyleHyphens::Manual)
, mRubyAlign(NS_STYLE_RUBY_ALIGN_SPACE_AROUND)
, mRubyPosition(NS_STYLE_RUBY_POSITION_OVER)
, mTextSizeAdjust(NS_STYLE_TEXT_SIZE_ADJUST_AUTO)
, mTextCombineUpright(NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE)
, mControlCharacterVisibility(nsCSSParser::ControlCharVisibilityDefault())
, mTextEmphasisStyle(NS_STYLE_TEXT_EMPHASIS_STYLE_NONE)
, mTextRendering(NS_STYLE_TEXT_RENDERING_AUTO)
, mTextEmphasisColor(StyleComplexColor::CurrentColor())
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2077,17 +2077,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
uint8_t mTextAlign; // [inherited] see nsStyleConsts.h
uint8_t mTextAlignLast; // [inherited] see nsStyleConsts.h
bool mTextAlignTrue : 1; // [inherited] see nsStyleConsts.h
bool mTextAlignLastTrue : 1; // [inherited] see nsStyleConsts.h
uint8_t mTextTransform; // [inherited] see nsStyleConsts.h
uint8_t mWhiteSpace; // [inherited] see nsStyleConsts.h
uint8_t mWordBreak; // [inherited] see nsStyleConsts.h
uint8_t mOverflowWrap; // [inherited] see nsStyleConsts.h
- uint8_t mHyphens; // [inherited] see nsStyleConsts.h
+ mozilla::StyleHyphens mHyphens; // [inherited] see nsStyleConsts.h
uint8_t mRubyAlign; // [inherited] see nsStyleConsts.h
uint8_t mRubyPosition; // [inherited] see nsStyleConsts.h
uint8_t mTextSizeAdjust; // [inherited] see nsStyleConsts.h
uint8_t mTextCombineUpright; // [inherited] see nsStyleConsts.h
uint8_t mControlCharacterVisibility; // [inherited] see nsStyleConsts.h
uint8_t mTextEmphasisPosition; // [inherited] see nsStyleConsts.h
uint8_t mTextEmphasisStyle; // [inherited] see nsStyleConsts.h
uint8_t mTextRendering; // [inherited] see nsStyleConsts.h