mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1204872 - Prettify enum class printing. r=roc
Provide operator<< functions so that gtest can use them to print enum classes. --HG-- extra : commitid : JYu6ffen2Zr extra : rebase_source : 6628de44b343a0c625fd4526d36dba34ad0cb5cc
This commit is contained in:
parent
64e9080458
commit
549ac3b8f4
@ -32,24 +32,35 @@ float AccessibleCaret::sHeight = 0.0f;
|
||||
float AccessibleCaret::sMarginLeft = 0.0f;
|
||||
float AccessibleCaret::sBarWidth = 0.0f;
|
||||
|
||||
#define AC_PROCESS_ENUM_TO_STREAM(e) case(e): aStream << #e; break;
|
||||
std::ostream&
|
||||
operator<<(std::ostream& aStream, const AccessibleCaret::Appearance& aAppearance)
|
||||
{
|
||||
using Appearance = AccessibleCaret::Appearance;
|
||||
|
||||
#define AC_PROCESS_APPEARANCE_TO_STREAM(e) case(e): aStream << #e; break;
|
||||
switch (aAppearance) {
|
||||
AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::None);
|
||||
AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::Normal);
|
||||
AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::NormalNotShown);
|
||||
AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::Left);
|
||||
AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::Right);
|
||||
AC_PROCESS_ENUM_TO_STREAM(Appearance::None);
|
||||
AC_PROCESS_ENUM_TO_STREAM(Appearance::Normal);
|
||||
AC_PROCESS_ENUM_TO_STREAM(Appearance::NormalNotShown);
|
||||
AC_PROCESS_ENUM_TO_STREAM(Appearance::Left);
|
||||
AC_PROCESS_ENUM_TO_STREAM(Appearance::Right);
|
||||
}
|
||||
#undef AC_PROCESS_APPEARANCE_TO_STREAM
|
||||
|
||||
return aStream;
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& aStream,
|
||||
const AccessibleCaret::PositionChangedResult& aResult)
|
||||
{
|
||||
using PositionChangedResult = AccessibleCaret::PositionChangedResult;
|
||||
switch (aResult) {
|
||||
AC_PROCESS_ENUM_TO_STREAM(PositionChangedResult::NotChanged);
|
||||
AC_PROCESS_ENUM_TO_STREAM(PositionChangedResult::Changed);
|
||||
AC_PROCESS_ENUM_TO_STREAM(PositionChangedResult::Invisible);
|
||||
}
|
||||
return aStream;
|
||||
}
|
||||
#undef AC_PROCESS_ENUM_TO_STREAM
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Implementation of AccessibleCaret methods
|
||||
|
||||
|
@ -69,6 +69,9 @@ public:
|
||||
Right
|
||||
};
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& aStream,
|
||||
const Appearance& aAppearance);
|
||||
|
||||
Appearance GetAppearance() const
|
||||
{
|
||||
return mAppearance;
|
||||
@ -105,6 +108,10 @@ public:
|
||||
// Position is out of scroll port.
|
||||
Invisible
|
||||
};
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& aStream,
|
||||
const PositionChangedResult& aResult);
|
||||
|
||||
virtual PositionChangedResult SetPosition(nsIFrame* aFrame, int32_t aOffset);
|
||||
|
||||
// Does two AccessibleCarets overlap?
|
||||
@ -213,6 +220,12 @@ protected:
|
||||
|
||||
}; // class AccessibleCaret
|
||||
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const AccessibleCaret::Appearance& aAppearance);
|
||||
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const AccessibleCaret::PositionChangedResult& aResult);
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // AccessibleCaret_h__
|
||||
|
@ -34,6 +34,32 @@ using namespace dom;
|
||||
using Appearance = AccessibleCaret::Appearance;
|
||||
using PositionChangedResult = AccessibleCaret::PositionChangedResult;
|
||||
|
||||
#define AC_PROCESS_ENUM_TO_STREAM(e) case(e): aStream << #e; break;
|
||||
std::ostream&
|
||||
operator<<(std::ostream& aStream,
|
||||
const AccessibleCaretManager::CaretMode& aCaretMode)
|
||||
{
|
||||
using CaretMode = AccessibleCaretManager::CaretMode;
|
||||
switch (aCaretMode) {
|
||||
AC_PROCESS_ENUM_TO_STREAM(CaretMode::None);
|
||||
AC_PROCESS_ENUM_TO_STREAM(CaretMode::Cursor);
|
||||
AC_PROCESS_ENUM_TO_STREAM(CaretMode::Selection);
|
||||
}
|
||||
return aStream;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const AccessibleCaretManager::UpdateCaretsHint& aHint)
|
||||
{
|
||||
using UpdateCaretsHint = AccessibleCaretManager::UpdateCaretsHint;
|
||||
switch (aHint) {
|
||||
AC_PROCESS_ENUM_TO_STREAM(UpdateCaretsHint::Default);
|
||||
AC_PROCESS_ENUM_TO_STREAM(UpdateCaretsHint::RespectOldAppearance);
|
||||
}
|
||||
return aStream;
|
||||
}
|
||||
#undef AC_PROCESS_ENUM_TO_STREAM
|
||||
|
||||
AccessibleCaretManager::AccessibleCaretManager(nsIPresShell* aPresShell)
|
||||
: mPresShell(aPresShell)
|
||||
{
|
||||
|
@ -106,6 +106,9 @@ protected:
|
||||
Selection
|
||||
};
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& aStream,
|
||||
const CaretMode& aCaretMode);
|
||||
|
||||
enum class UpdateCaretsHint : uint8_t {
|
||||
// Update everything including appearance and position.
|
||||
Default,
|
||||
@ -115,6 +118,10 @@ protected:
|
||||
// appearance to Normal.
|
||||
RespectOldAppearance
|
||||
};
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& aStream,
|
||||
const UpdateCaretsHint& aResult);
|
||||
|
||||
// Update carets based on current selection status.
|
||||
void UpdateCarets(UpdateCaretsHint aHint = UpdateCaretsHint::Default);
|
||||
|
||||
@ -217,6 +224,12 @@ protected:
|
||||
static const int32_t kAutoScrollTimerDelay = 30;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const AccessibleCaretManager::CaretMode& aCaretMode);
|
||||
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const AccessibleCaretManager::UpdateCaretsHint& aResult);
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // AccessibleCaretManager_h
|
||||
|
Loading…
Reference in New Issue
Block a user