mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1921348 - Remove global constructor from layout/generic/nsTextFrame.cpp r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D223872
This commit is contained in:
parent
aba653510a
commit
d4657c7ef2
@ -1228,28 +1228,28 @@ class MOZ_RAII AutoHideSelectionChanges final {
|
||||
|
||||
} // namespace dom
|
||||
|
||||
inline bool IsValidRawSelectionType(RawSelectionType aRawSelectionType) {
|
||||
constexpr bool IsValidRawSelectionType(RawSelectionType aRawSelectionType) {
|
||||
return aRawSelectionType >= nsISelectionController::SELECTION_NONE &&
|
||||
aRawSelectionType <= nsISelectionController::SELECTION_URLSTRIKEOUT;
|
||||
}
|
||||
|
||||
inline SelectionType ToSelectionType(RawSelectionType aRawSelectionType) {
|
||||
constexpr SelectionType ToSelectionType(RawSelectionType aRawSelectionType) {
|
||||
if (!IsValidRawSelectionType(aRawSelectionType)) {
|
||||
return SelectionType::eInvalid;
|
||||
}
|
||||
return static_cast<SelectionType>(aRawSelectionType);
|
||||
}
|
||||
|
||||
inline RawSelectionType ToRawSelectionType(SelectionType aSelectionType) {
|
||||
constexpr RawSelectionType ToRawSelectionType(SelectionType aSelectionType) {
|
||||
MOZ_ASSERT(aSelectionType != SelectionType::eInvalid);
|
||||
return static_cast<RawSelectionType>(aSelectionType);
|
||||
}
|
||||
|
||||
inline RawSelectionType ToRawSelectionType(TextRangeType aTextRangeType) {
|
||||
constexpr RawSelectionType ToRawSelectionType(TextRangeType aTextRangeType) {
|
||||
return ToRawSelectionType(ToSelectionType(aTextRangeType));
|
||||
}
|
||||
|
||||
inline SelectionTypeMask ToSelectionTypeMask(SelectionType aSelectionType) {
|
||||
constexpr SelectionTypeMask ToSelectionTypeMask(SelectionType aSelectionType) {
|
||||
MOZ_ASSERT(aSelectionType != SelectionType::eInvalid);
|
||||
return aSelectionType == SelectionType::eNone
|
||||
? 0
|
||||
|
@ -339,10 +339,10 @@ static const SelectionType kPresentSelectionTypes[] = {
|
||||
};
|
||||
|
||||
// Please include mozilla/dom/Selection.h for the following APIs.
|
||||
inline bool IsValidRawSelectionType(RawSelectionType aRawSelectionType);
|
||||
inline SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
|
||||
inline RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
|
||||
inline SelectionTypeMask ToSelectionTypeMask(SelectionType aSelectionType);
|
||||
constexpr bool IsValidRawSelectionType(RawSelectionType aRawSelectionType);
|
||||
constexpr SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
|
||||
constexpr RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
|
||||
constexpr SelectionTypeMask ToSelectionTypeMask(SelectionType aSelectionType);
|
||||
|
||||
} // namespace mozilla
|
||||
%}
|
||||
|
@ -5472,7 +5472,7 @@ gfxFloat nsTextFrame::ComputeDescentLimitForSelectionUnderline(
|
||||
}
|
||||
|
||||
// Make sure this stays in sync with DrawSelectionDecorations below
|
||||
static const SelectionTypeMask kSelectionTypesWithDecorations =
|
||||
static constexpr SelectionTypeMask kSelectionTypesWithDecorations =
|
||||
ToSelectionTypeMask(SelectionType::eSpellCheck) |
|
||||
ToSelectionTypeMask(SelectionType::eURLStrikeout) |
|
||||
ToSelectionTypeMask(SelectionType::eIMERawClause) |
|
||||
|
@ -137,12 +137,6 @@ enum class TextRangeType : RawTextRangeType {
|
||||
eSelectedClause = nsITextInputProcessor::ATTR_SELECTED_CLAUSE
|
||||
};
|
||||
|
||||
bool IsValidRawTextRangeValue(RawTextRangeType aRawTextRangeValue);
|
||||
RawTextRangeType ToRawTextRangeType(TextRangeType aTextRangeType);
|
||||
TextRangeType ToTextRangeType(RawTextRangeType aRawTextRangeType);
|
||||
const char* ToChar(TextRangeType aTextRangeType);
|
||||
SelectionType ToSelectionType(TextRangeType aTextRangeType);
|
||||
|
||||
struct TextRange {
|
||||
TextRange()
|
||||
: mStartOffset(0),
|
||||
@ -178,6 +172,64 @@ struct TextRange {
|
||||
}
|
||||
};
|
||||
|
||||
constexpr bool IsValidRawTextRangeValue(RawTextRangeType aRawTextRangeType) {
|
||||
switch (static_cast<TextRangeType>(aRawTextRangeType)) {
|
||||
case TextRangeType::eUninitialized:
|
||||
case TextRangeType::eCaret:
|
||||
case TextRangeType::eRawClause:
|
||||
case TextRangeType::eSelectedRawClause:
|
||||
case TextRangeType::eConvertedClause:
|
||||
case TextRangeType::eSelectedClause:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr RawTextRangeType ToRawTextRangeType(TextRangeType aTextRangeType) {
|
||||
return static_cast<RawTextRangeType>(aTextRangeType);
|
||||
}
|
||||
|
||||
constexpr TextRangeType ToTextRangeType(RawTextRangeType aRawTextRangeType) {
|
||||
MOZ_ASSERT(IsValidRawTextRangeValue(aRawTextRangeType));
|
||||
return static_cast<TextRangeType>(aRawTextRangeType);
|
||||
}
|
||||
|
||||
constexpr const char* ToChar(TextRangeType aTextRangeType) {
|
||||
switch (aTextRangeType) {
|
||||
case TextRangeType::eUninitialized:
|
||||
return "TextRangeType::eUninitialized";
|
||||
case TextRangeType::eCaret:
|
||||
return "TextRangeType::eCaret";
|
||||
case TextRangeType::eRawClause:
|
||||
return "TextRangeType::eRawClause";
|
||||
case TextRangeType::eSelectedRawClause:
|
||||
return "TextRangeType::eSelectedRawClause";
|
||||
case TextRangeType::eConvertedClause:
|
||||
return "TextRangeType::eConvertedClause";
|
||||
case TextRangeType::eSelectedClause:
|
||||
return "TextRangeType::eSelectedClause";
|
||||
default:
|
||||
return "Invalid TextRangeType";
|
||||
}
|
||||
}
|
||||
|
||||
constexpr SelectionType ToSelectionType(TextRangeType aTextRangeType) {
|
||||
switch (aTextRangeType) {
|
||||
case TextRangeType::eRawClause:
|
||||
return SelectionType::eIMERawClause;
|
||||
case TextRangeType::eSelectedRawClause:
|
||||
return SelectionType::eIMESelectedRawClause;
|
||||
case TextRangeType::eConvertedClause:
|
||||
return SelectionType::eIMEConvertedClause;
|
||||
case TextRangeType::eSelectedClause:
|
||||
return SelectionType::eIMESelectedClause;
|
||||
default:
|
||||
MOZ_CRASH("TextRangeType is invalid");
|
||||
return SelectionType::eNormal;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* mozilla::TextRangeArray
|
||||
******************************************************************************/
|
||||
|
@ -256,64 +256,6 @@ const nsCString GetDOMKeyCodeName(uint32_t aKeyCode) {
|
||||
}
|
||||
}
|
||||
|
||||
bool IsValidRawTextRangeValue(RawTextRangeType aRawTextRangeType) {
|
||||
switch (static_cast<TextRangeType>(aRawTextRangeType)) {
|
||||
case TextRangeType::eUninitialized:
|
||||
case TextRangeType::eCaret:
|
||||
case TextRangeType::eRawClause:
|
||||
case TextRangeType::eSelectedRawClause:
|
||||
case TextRangeType::eConvertedClause:
|
||||
case TextRangeType::eSelectedClause:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
RawTextRangeType ToRawTextRangeType(TextRangeType aTextRangeType) {
|
||||
return static_cast<RawTextRangeType>(aTextRangeType);
|
||||
}
|
||||
|
||||
TextRangeType ToTextRangeType(RawTextRangeType aRawTextRangeType) {
|
||||
MOZ_ASSERT(IsValidRawTextRangeValue(aRawTextRangeType));
|
||||
return static_cast<TextRangeType>(aRawTextRangeType);
|
||||
}
|
||||
|
||||
const char* ToChar(TextRangeType aTextRangeType) {
|
||||
switch (aTextRangeType) {
|
||||
case TextRangeType::eUninitialized:
|
||||
return "TextRangeType::eUninitialized";
|
||||
case TextRangeType::eCaret:
|
||||
return "TextRangeType::eCaret";
|
||||
case TextRangeType::eRawClause:
|
||||
return "TextRangeType::eRawClause";
|
||||
case TextRangeType::eSelectedRawClause:
|
||||
return "TextRangeType::eSelectedRawClause";
|
||||
case TextRangeType::eConvertedClause:
|
||||
return "TextRangeType::eConvertedClause";
|
||||
case TextRangeType::eSelectedClause:
|
||||
return "TextRangeType::eSelectedClause";
|
||||
default:
|
||||
return "Invalid TextRangeType";
|
||||
}
|
||||
}
|
||||
|
||||
SelectionType ToSelectionType(TextRangeType aTextRangeType) {
|
||||
switch (aTextRangeType) {
|
||||
case TextRangeType::eRawClause:
|
||||
return SelectionType::eIMERawClause;
|
||||
case TextRangeType::eSelectedRawClause:
|
||||
return SelectionType::eIMESelectedRawClause;
|
||||
case TextRangeType::eConvertedClause:
|
||||
return SelectionType::eIMEConvertedClause;
|
||||
case TextRangeType::eSelectedClause:
|
||||
return SelectionType::eIMESelectedClause;
|
||||
default:
|
||||
MOZ_CRASH("TextRangeType is invalid");
|
||||
return SelectionType::eNormal;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* non class method implementation
|
||||
******************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user