author | Ting-Yu Lin <tlin@mozilla.com> |
Wed, 29 Oct 2014 01:37:00 +0100 | |
changeset 213174 | 10962f2deab176cd40b85e70fb80a18d164f36ea |
parent 213173 | 6797040a2034f95629cbea00f44014fce9e0fb1b |
child 213175 | 5dcc6258e024571a90c7814cdd70c5740036936e |
push id | 27742 |
push user | ryanvm@gmail.com |
push date | Thu, 30 Oct 2014 20:15:35 +0000 |
treeherder | mozilla-central@e0b505a37b1c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | roc |
bugs | 1090785 |
milestone | 36.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
|
--- a/layout/base/TouchCaret.cpp +++ b/layout/base/TouchCaret.cpp @@ -1,14 +1,15 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=2 sw=2 et tw=78: */ /* 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 "prlog.h" #include "TouchCaret.h" #include <algorithm> #include "nsCOMPtr.h" #include "nsFrameSelection.h" #include "nsIFrame.h" #include "nsIScrollableFrame.h" @@ -29,26 +30,35 @@ #include "nsView.h" #include "nsDOMTokenList.h" #include "nsCaret.h" #include "mozilla/dom/CustomEvent.h" #include "nsContentUtils.h" using namespace mozilla; -// To enable all the TOUCHCARET_LOG print statements, change the 0 to 1 in the -// following #define. -#define ENABLE_TOUCHCARET_LOG 0 +#ifdef PR_LOGGING +static PRLogModuleInfo* gTouchCaretLog; +static const char* kTouchCaretLogModuleName = "TouchCaret"; -#if ENABLE_TOUCHCARET_LOG - #define TOUCHCARET_LOG(message, ...) \ - printf_stderr("TouchCaret (%p): %s:%d : " message "\n", this, __func__, __LINE__, ##__VA_ARGS__); +// To enable all the TOUCHCARET_LOG print statements, set the environment +// variable NSPR_LOG_MODULES=TouchCaret:5 +#define TOUCHCARET_LOG(message, ...) \ + PR_LOG(gTouchCaretLog, PR_LOG_DEBUG, \ + ("TouchCaret (%p): %s:%d : " message "\n", this, __FUNCTION__, \ + __LINE__, ##__VA_ARGS__)); + +#define TOUCHCARET_LOG_STATIC(message, ...) \ + PR_LOG(gTouchCaretLog, PR_LOG_DEBUG, \ + ("TouchCaret: %s:%d : " message "\n", __FUNCTION__, __LINE__, \ + ##__VA_ARGS__)); #else - #define TOUCHCARET_LOG(message, ...) -#endif +#define TOUCHCARET_LOG(message, ...) +#define TOUCHCARET_LOG_STATIC(message, ...) +#endif // #ifdef PR_LOGGING // Click on the boundary of input/textarea will place the caret at the // front/end of the content. To advoid this, we need to deflate the content // boundary by 61 app units (1 pixel + 1 app unit). static const int32_t kBoundaryAppUnits = 61; NS_IMPL_ISUPPORTS(TouchCaret, nsISelectionListener) @@ -57,18 +67,25 @@ NS_IMPL_ISUPPORTS(TouchCaret, nsISelecti TouchCaret::TouchCaret(nsIPresShell* aPresShell) : mState(TOUCHCARET_NONE), mActiveTouchId(-1), mCaretCenterToDownPointOffsetY(0), mVisible(false), mIsValidTap(false) { + MOZ_ASSERT(NS_IsMainThread()); + +#ifdef PR_LOGGING + if (!gTouchCaretLog) { + gTouchCaretLog = PR_NewLogModule(kTouchCaretLogModuleName); + } +#endif + TOUCHCARET_LOG("Constructor, PresShell=%p", aPresShell); - MOZ_ASSERT(NS_IsMainThread()); static bool addedTouchCaretPref = false; if (!addedTouchCaretPref) { Preferences::AddIntVarCache(&sTouchCaretInflateSize, "touchcaret.inflatesize.threshold"); Preferences::AddIntVarCache(&sTouchCaretExpirationTime, "touchcaret.expiration.time"); addedTouchCaretPref = true; @@ -306,17 +323,17 @@ TouchCaret::IsOnTouchCaret(const nsPoint return mVisible && nsLayoutUtils::ContainsPoint(GetTouchFrameRect(), aPoint, TouchCaretInflateSize()); } nsresult TouchCaret::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* aSel, int16_t aReason) { - TOUCHCARET_LOG("Reason=%d", aReason); + TOUCHCARET_LOG("aSel (%p), Reason=%d", aSel, aReason); // Hide touch caret while no caret exists. nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell); if (!presShell) { return NS_OK; } nsRefPtr<nsCaret> caret = presShell->GetCaret();