Bug 1386411 - Part 3: Inline some helper functions in Selection.cpp; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2017-08-01 17:19:19 -04:00
Родитель 1774c1cc7d
Коммит 7fe0be04ed
5 изменённых файлов: 53 добавлений и 51 удалений

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

@ -132,48 +132,6 @@ ToChar(SelectionType aSelectionType)
}
}
static bool
IsValidSelectionType(RawSelectionType aRawSelectionType)
{
switch (static_cast<SelectionType>(aRawSelectionType)) {
case SelectionType::eNone:
case SelectionType::eNormal:
case SelectionType::eSpellCheck:
case SelectionType::eIMERawClause:
case SelectionType::eIMESelectedRawClause:
case SelectionType::eIMEConvertedClause:
case SelectionType::eIMESelectedClause:
case SelectionType::eAccessibility:
case SelectionType::eFind:
case SelectionType::eURLSecondary:
case SelectionType::eURLStrikeout:
return true;
default:
return false;
}
}
SelectionType
ToSelectionType(RawSelectionType aRawSelectionType)
{
if (!IsValidSelectionType(aRawSelectionType)) {
return SelectionType::eInvalid;
}
return static_cast<SelectionType>(aRawSelectionType);
}
RawSelectionType
ToRawSelectionType(SelectionType aSelectionType)
{
return static_cast<RawSelectionType>(aSelectionType);
}
bool operator &(SelectionType aSelectionType,
RawSelectionType aRawSelectionTypes)
{
return (ToRawSelectionType(aSelectionType) & aRawSelectionTypes) != 0;
}
} // namespace mozilla
//#define DEBUG_SELECTION // uncomment for printf describing every collapse and extend.

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

@ -515,6 +515,54 @@ public:
};
} // namespace dom
inline bool
IsValidSelectionType(RawSelectionType aRawSelectionType)
{
switch (static_cast<SelectionType>(aRawSelectionType)) {
case SelectionType::eNone:
case SelectionType::eNormal:
case SelectionType::eSpellCheck:
case SelectionType::eIMERawClause:
case SelectionType::eIMESelectedRawClause:
case SelectionType::eIMEConvertedClause:
case SelectionType::eIMESelectedClause:
case SelectionType::eAccessibility:
case SelectionType::eFind:
case SelectionType::eURLSecondary:
case SelectionType::eURLStrikeout:
return true;
default:
return false;
}
}
inline SelectionType
ToSelectionType(RawSelectionType aRawSelectionType)
{
if (!IsValidSelectionType(aRawSelectionType)) {
return SelectionType::eInvalid;
}
return static_cast<SelectionType>(aRawSelectionType);
}
inline RawSelectionType
ToRawSelectionType(SelectionType aSelectionType)
{
return static_cast<RawSelectionType>(aSelectionType);
}
inline RawSelectionType ToRawSelectionType(TextRangeType aTextRangeType)
{
return ToRawSelectionType(ToSelectionType(aTextRangeType));
}
inline bool operator &(SelectionType aSelectionType,
RawSelectionType aRawSelectionTypes)
{
return (ToRawSelectionType(aSelectionType) & aRawSelectionTypes) != 0;
}
} // namespace mozilla
inline mozilla::dom::Selection*

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

@ -313,10 +313,10 @@ enum : size_t
};
const char* ToChar(SelectionType aSelectionType);
SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
bool operator &(SelectionType aSelectionType,
RawSelectionType aRawSelectionTypes);
inline SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
inline RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
inline bool operator &(SelectionType aSelectionType,
RawSelectionType aRawSelectionTypes);
} // namespace mozilla
%}

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

@ -145,11 +145,6 @@ TextRangeType ToTextRangeType(RawTextRangeType aRawTextRangeType);
const char* ToChar(TextRangeType aTextRangeType);
SelectionType ToSelectionType(TextRangeType aTextRangeType);
inline RawSelectionType ToRawSelectionType(TextRangeType aTextRangeType)
{
return ToRawSelectionType(ToSelectionType(aTextRangeType));
}
struct TextRange
{
TextRange()

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

@ -14,6 +14,7 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/dom/Selection.h"
#include "InputData.h"
namespace IPC