Bug 1200194 - Make Appearance convertible to string representation. r=roc
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 09 Sep 2015 16:47:20 +0800
changeset 294340 6b470e90aef5b8b6c250673a10184bf0ee3dcf68
parent 294339 1dbf68298734ad14579849f3534fa07c6e897059
child 294341 8d7e8ebd0de628c8a393e36c392eb3b1ab227bdf
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1200194
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1200194 - Make Appearance convertible to string representation. r=roc
layout/base/AccessibleCaret.cpp
--- a/layout/base/AccessibleCaret.cpp
+++ b/layout/base/AccessibleCaret.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "AccessibleCaret.h"
 
 #include "AccessibleCaretLogger.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/ToString.h"
 #include "nsCanvasFrame.h"
 #include "nsCaret.h"
 #include "nsDOMTokenList.h"
 #include "nsIFrame.h"
 
 namespace mozilla {
 using namespace dom;
 
@@ -26,16 +27,34 @@ using namespace dom;
 
 NS_IMPL_ISUPPORTS(AccessibleCaret::DummyTouchListener, nsIDOMEventListener)
 
 float AccessibleCaret::sWidth = 0.0f;
 float AccessibleCaret::sHeight = 0.0f;
 float AccessibleCaret::sMarginLeft = 0.0f;
 float AccessibleCaret::sBarWidth = 0.0f;
 
+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);
+  }
+#undef AC_PROCESS_APPEARANCE_TO_STREAM
+
+  return aStream;
+}
+
 // -----------------------------------------------------------------------------
 // Implementation of AccessibleCaret methods
 
 AccessibleCaret::AccessibleCaret(nsIPresShell* aPresShell)
   : mPresShell(aPresShell)
 {
   // Check all resources required.
   MOZ_ASSERT(mPresShell);
@@ -70,16 +89,19 @@ AccessibleCaret::SetAppearance(Appearanc
 
   ErrorResult rv;
   CaretElement()->ClassList()->Remove(AppearanceString(mAppearance), rv);
   MOZ_ASSERT(!rv.Failed(), "Remove old appearance failed!");
 
   CaretElement()->ClassList()->Add(AppearanceString(aAppearance), rv);
   MOZ_ASSERT(!rv.Failed(), "Add new appearance failed!");
 
+  AC_LOG("%s: %s -> %s", __FUNCTION__, ToString(mAppearance).c_str(),
+         ToString(aAppearance).c_str());
+
   mAppearance = aAppearance;
 
   // Need to reset rect since the cached rect will be compared in SetPosition.
   if (mAppearance == Appearance::None) {
     mImaginaryCaretRect = nsRect();
   }
 }