diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index aabc6a77d9b2..c95b2389df01 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -53,17 +53,11 @@ #include "GestureEventListener.h" // for GestureEventListener::setLongTapEnabled #include "UnitTransforms.h" // for ViewAs -#define ENABLE_APZCTM_LOGGING 0 -// #define ENABLE_APZCTM_LOGGING 1 +static mozilla::LazyLogModule sApzMgrLog("apz.manager"); +#define APZCTM_LOG(...) MOZ_LOG(sApzMgrLog, LogLevel::Debug, (__VA_ARGS__)) -#if ENABLE_APZCTM_LOGGING -# define APZCTM_LOG(...) printf_stderr("APZCTM: " __VA_ARGS__) -#else -# define APZCTM_LOG(...) -#endif - -// #define APZ_KEY_LOG(...) printf_stderr("APZKEY: " __VA_ARGS__) -#define APZ_KEY_LOG(...) +static mozilla::LazyLogModule sApzKeyLog("apz.key"); +#define APZ_KEY_LOG(...) MOZ_LOG(sApzKeyLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { @@ -647,13 +641,10 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, state.mNodesToDestroy[i]->Destroy(); } -#if ENABLE_APZCTM_LOGGING - // Make the hit-test tree line up with the layer dump - printf_stderr("APZCTreeManager (%p)\n", this); + APZCTM_LOG("APZCTreeManager (%p)\n", this); if (mRootNode) { mRootNode->Dump(" "); } -#endif SendSubtreeTransformsToChromeMainThread(nullptr); } diff --git a/gfx/layers/apz/src/AndroidAPZ.cpp b/gfx/layers/apz/src/AndroidAPZ.cpp index c2d3b21b6fa4..0edae785e9af 100644 --- a/gfx/layers/apz/src/AndroidAPZ.cpp +++ b/gfx/layers/apz/src/AndroidAPZ.cpp @@ -16,8 +16,8 @@ #include "ViewConfiguration.h" #include "mozilla/StaticPrefs_apz.h" -#define ANDROID_APZ_LOG(...) -// #define ANDROID_APZ_LOG(...) printf_stderr("ANDROID_APZ: " __VA_ARGS__) +static mozilla::LazyLogModule sApzAndLog("apz.android"); +#define ANDROID_APZ_LOG(...) MOZ_LOG(sApzAndLog, LogLevel::Debug, (__VA_ARGS__)) static float sMaxFlingSpeed = 0.0f; diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 54bf92e99483..3f3f30baf0a6 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -97,22 +97,15 @@ # include "mozilla/layers/AndroidDynamicToolbarAnimator.h" #endif // defined(MOZ_WIDGET_ANDROID) -#define ENABLE_APZC_LOGGING 0 -// #define ENABLE_APZC_LOGGING 1 - -#if ENABLE_APZC_LOGGING -# define APZC_LOG(...) printf_stderr("APZC: " __VA_ARGS__) -# define APZC_LOG_FM(fm, prefix, ...) \ - { \ - std::stringstream ss; \ - ss << nsPrintfCString(prefix, __VA_ARGS__).get(); \ - AppendToString(ss, fm, ":", "", true); \ - APZC_LOG("%s\n", ss.str().c_str()); \ - } -#else -# define APZC_LOG(...) -# define APZC_LOG_FM(fm, prefix, ...) -#endif +static mozilla::LazyLogModule sApzCtlLog("apz.controller"); +#define APZC_LOG(...) MOZ_LOG(sApzCtlLog, LogLevel::Debug, (__VA_ARGS__)) +#define APZC_LOG_FM(fm, prefix, ...) \ + if (MOZ_LOG_TEST(sApzCtlLog, LogLevel::Debug)) { \ + std::stringstream ss; \ + ss << nsPrintfCString(prefix, __VA_ARGS__).get(); \ + AppendToString(ss, fm, ":", "", true); \ + APZC_LOG("%s\n", ss.str().c_str()); \ + } namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/Axis.cpp b/gfx/layers/apz/src/Axis.cpp index 8a5be662be7d..7bfe041a5b0e 100644 --- a/gfx/layers/apz/src/Axis.cpp +++ b/gfx/layers/apz/src/Axis.cpp @@ -24,8 +24,8 @@ #include "nsThreadUtils.h" // for NS_DispatchToMainThread, etc #include "nscore.h" // for NS_IMETHOD -#define AXIS_LOG(...) -// #define AXIS_LOG(...) printf_stderr("AXIS: " __VA_ARGS__) +static mozilla::LazyLogModule sApzAxsLog("apz.axis"); +#define AXIS_LOG(...) MOZ_LOG(sApzAxsLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/DesktopFlingPhysics.h b/gfx/layers/apz/src/DesktopFlingPhysics.h index b7ba4f9a3ea8..e93cc07a2312 100644 --- a/gfx/layers/apz/src/DesktopFlingPhysics.h +++ b/gfx/layers/apz/src/DesktopFlingPhysics.h @@ -12,9 +12,6 @@ #include "mozilla/Assertions.h" #include "mozilla/StaticPrefs_apz.h" -#define FLING_PHYS_LOG(...) -// #define FLING_PHYS_LOG(...) printf_stderr("FLING: " __VA_ARGS__) - namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/DragTracker.cpp b/gfx/layers/apz/src/DragTracker.cpp index fb0a435fa9f9..4b995559f0b0 100644 --- a/gfx/layers/apz/src/DragTracker.cpp +++ b/gfx/layers/apz/src/DragTracker.cpp @@ -8,8 +8,8 @@ #include "InputData.h" -#define DRAG_LOG(...) -// #define DRAG_LOG(...) printf_stderr("DRAG: " __VA_ARGS__) +static mozilla::LazyLogModule sApzDrgLog("apz.drag"); +#define DRAG_LOG(...) MOZ_LOG(sApzDrgLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/FocusState.cpp b/gfx/layers/apz/src/FocusState.cpp index 5a2fe6cce76a..8ed5cc686b7e 100644 --- a/gfx/layers/apz/src/FocusState.cpp +++ b/gfx/layers/apz/src/FocusState.cpp @@ -8,8 +8,8 @@ #include "mozilla/layers/APZThreadUtils.h" -// #define FS_LOG(...) printf_stderr("FS: " __VA_ARGS__) -#define FS_LOG(...) +static mozilla::LazyLogModule sApzFstLog("apz.focusstate"); +#define FS_LOG(...) MOZ_LOG(sApzFstLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/FocusTarget.cpp b/gfx/layers/apz/src/FocusTarget.cpp index 023c7855a068..6e5b9f514d6f 100644 --- a/gfx/layers/apz/src/FocusTarget.cpp +++ b/gfx/layers/apz/src/FocusTarget.cpp @@ -15,16 +15,8 @@ #include "nsIContentInlines.h" // for nsINode::IsEditable() #include "nsLayoutUtils.h" // for nsLayoutUtils -#define ENABLE_FT_LOGGING 0 -// #define ENABLE_FT_LOGGING 1 - -#if ENABLE_FT_LOGGING -# define FT_LOG(FMT, ...) \ - printf_stderr("FT (%s): " FMT, \ - XRE_IsParentProcess() ? "chrome" : "content", __VA_ARGS__) -#else -# define FT_LOG(...) -#endif +static mozilla::LazyLogModule sApzFtgLog("apz.focustarget"); +#define FT_LOG(...) MOZ_LOG(sApzFtgLog, LogLevel::Debug, (__VA_ARGS__)) using namespace mozilla::dom; using namespace mozilla::layout; diff --git a/gfx/layers/apz/src/GenericFlingAnimation.h b/gfx/layers/apz/src/GenericFlingAnimation.h index 02e8c34ebe5a..85046abcce39 100644 --- a/gfx/layers/apz/src/GenericFlingAnimation.h +++ b/gfx/layers/apz/src/GenericFlingAnimation.h @@ -22,8 +22,8 @@ #include "mozilla/TimeStamp.h" #include "nsThreadUtils.h" -#define FLING_LOG(...) -// #define FLING_LOG(...) printf_stderr("FLING: " __VA_ARGS__) +static mozilla::LazyLogModule sApzFlgLog("apz.fling"); +#define FLING_LOG(...) MOZ_LOG(sApzFlgLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index f965095508a6..4895929945c9 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -16,8 +16,8 @@ #include "nsDebug.h" // for NS_WARNING #include "nsMathUtils.h" // for NS_hypot -#define GEL_LOG(...) -// #define GEL_LOG(...) printf_stderr("GEL: " __VA_ARGS__) +static mozilla::LazyLogModule sApzGelLog("apz.gesture"); +#define GEL_LOG(...) MOZ_LOG(sApzGelLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/HitTestingTreeNode.cpp b/gfx/layers/apz/src/HitTestingTreeNode.cpp index fbe39f59b6fe..24a1e7ced7b2 100644 --- a/gfx/layers/apz/src/HitTestingTreeNode.cpp +++ b/gfx/layers/apz/src/HitTestingTreeNode.cpp @@ -14,6 +14,8 @@ #include "nsPrintfCString.h" // for nsPrintfCString #include "UnitTransforms.h" // for ViewAs +static mozilla::LazyLogModule sApzMgrLog("apz.manager"); + namespace mozilla { namespace layers { @@ -415,21 +417,23 @@ void HitTestingTreeNode::Dump(const char* aPrefix) const { if (mPrevSibling) { mPrevSibling->Dump(aPrefix); } - printf_stderr( - "%sHitTestingTreeNode (%p) APZC (%p) g=(%s) %s%s%sr=(%s) t=(%s) " - "c=(%s)%s%s\n", - aPrefix, this, mApzc.get(), - mApzc ? Stringify(mApzc->GetGuid()).c_str() - : nsPrintfCString("l=0x%" PRIx64, uint64_t(mLayersId)).get(), - (mOverride & EventRegionsOverride::ForceDispatchToContent) ? "fdtc " : "", - (mOverride & EventRegionsOverride::ForceEmptyHitRegion) ? "fehr " : "", - (mFixedPosTarget != ScrollableLayerGuid::NULL_SCROLL_ID) - ? nsPrintfCString("fixed=%" PRIu64 " ", mFixedPosTarget).get() - : "", - Stringify(mEventRegions).c_str(), Stringify(mTransform).c_str(), - mClipRegion ? Stringify(mClipRegion.ref()).c_str() : "none", - mScrollbarData.mDirection.isSome() ? " scrollbar" : "", - IsScrollThumbNode() ? " scrollthumb" : ""); + MOZ_LOG( + sApzMgrLog, LogLevel::Debug, + ("%sHitTestingTreeNode (%p) APZC (%p) g=(%s) %s%s%sr=(%s) t=(%s) " + "c=(%s)%s%s\n", + aPrefix, this, mApzc.get(), + mApzc ? Stringify(mApzc->GetGuid()).c_str() + : nsPrintfCString("l=0x%" PRIx64, uint64_t(mLayersId)).get(), + (mOverride & EventRegionsOverride::ForceDispatchToContent) ? "fdtc " + : "", + (mOverride & EventRegionsOverride::ForceEmptyHitRegion) ? "fehr " : "", + (mFixedPosTarget != ScrollableLayerGuid::NULL_SCROLL_ID) + ? nsPrintfCString("fixed=%" PRIu64 " ", mFixedPosTarget).get() + : "", + Stringify(mEventRegions).c_str(), Stringify(mTransform).c_str(), + mClipRegion ? Stringify(mClipRegion.ref()).c_str() : "none", + mScrollbarData.mDirection.isSome() ? " scrollbar" : "", + IsScrollThumbNode() ? " scrollthumb" : "")); if (mLastChild) { mLastChild->Dump(nsPrintfCString("%s ", aPrefix).get()); } diff --git a/gfx/layers/apz/src/InputBlockState.cpp b/gfx/layers/apz/src/InputBlockState.cpp index fe3e0df7d0ad..318c18fd3bca 100644 --- a/gfx/layers/apz/src/InputBlockState.cpp +++ b/gfx/layers/apz/src/InputBlockState.cpp @@ -20,8 +20,8 @@ #include "OverscrollHandoffState.h" #include "QueuedInput.h" -#define TBS_LOG(...) -// #define TBS_LOG(...) printf_stderr("TBS: " __VA_ARGS__) +static mozilla::LazyLogModule sApzIbsLog("apz.inputstate"); +#define TBS_LOG(...) MOZ_LOG(sApzIbsLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/InputQueue.cpp b/gfx/layers/apz/src/InputQueue.cpp index 03267f92213d..dc3de00bf453 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -16,8 +16,8 @@ #include "mozilla/StaticPrefs_apz.h" #include "mozilla/StaticPrefs_layout.h" -#define INPQ_LOG(...) -// #define INPQ_LOG(...) printf_stderr("INPQ: " __VA_ARGS__) +static mozilla::LazyLogModule sApzInpLog("apz.inputqueue"); +#define INPQ_LOG(...) MOZ_LOG(sApzInpLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/src/SimpleVelocityTracker.cpp b/gfx/layers/apz/src/SimpleVelocityTracker.cpp index af52438c196b..4705d289a62d 100644 --- a/gfx/layers/apz/src/SimpleVelocityTracker.cpp +++ b/gfx/layers/apz/src/SimpleVelocityTracker.cpp @@ -10,8 +10,8 @@ #include "mozilla/StaticPrefs_apz.h" #include "mozilla/StaticPtr.h" // for StaticAutoPtr -#define SVT_LOG(...) -// #define SVT_LOG(...) printf_stderr("SimpleVelocityTracker: " __VA_ARGS__) +static mozilla::LazyLogModule sApzSvtLog("apz.simplevelocitytracker"); +#define SVT_LOG(...) MOZ_LOG(sApzSvtLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 2e4573b03465..3d810b8464bb 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -34,12 +34,8 @@ #include "nsView.h" #include "Layers.h" -// #define APZCCH_LOGGING 1 -#ifdef APZCCH_LOGGING -# define APZCCH_LOG(...) printf_stderr("APZCCH: " __VA_ARGS__) -#else -# define APZCCH_LOG(...) -#endif +static mozilla::LazyLogModule sApzHlpLog("apz.helper"); +#define APZCCH_LOG(...) MOZ_LOG(sApzHlpLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers { @@ -700,15 +696,15 @@ static bool PrepareForSetTargetAPZCNotification( target ? target : aRootFrame); } -#ifdef APZCCH_LOGGING - nsAutoString dpElementDesc; - if (dpElement) { - dpElement->Describe(dpElementDesc); + if (MOZ_LOG_TEST(sApzHlpLog, LogLevel::Debug)) { + nsAutoString dpElementDesc; + if (dpElement) { + dpElement->Describe(dpElementDesc); + } + APZCCH_LOG("For event at %s found scrollable element %p (%s)\n", + Stringify(aRefPoint).c_str(), dpElement.get(), + NS_LossyConvertUTF16toASCII(dpElementDesc).get()); } - APZCCH_LOG("For event at %s found scrollable element %p (%s)\n", - Stringify(aRefPoint).c_str(), dpElement.get(), - NS_LossyConvertUTF16toASCII(dpElementDesc).get()); -#endif bool guidIsValid = APZCCallbackHelper::GetOrCreateScrollIdentifiers( dpElement, &(guid.mScrollableLayerGuid.mPresShellId), diff --git a/gfx/layers/apz/util/APZEventState.cpp b/gfx/layers/apz/util/APZEventState.cpp index 38e813a4d68b..9d10f0702c33 100644 --- a/gfx/layers/apz/util/APZEventState.cpp +++ b/gfx/layers/apz/util/APZEventState.cpp @@ -36,8 +36,8 @@ #include "nsLayoutUtils.h" #include "nsQueryFrame.h" -#define APZES_LOG(...) -// #define APZES_LOG(...) printf_stderr("APZES: " __VA_ARGS__) +static mozilla::LazyLogModule sApzEvtLog("apz.eventstate"); +#define APZES_LOG(...) MOZ_LOG(sApzEvtLog, LogLevel::Debug, (__VA_ARGS__)) // Static helper functions namespace { diff --git a/gfx/layers/apz/util/ActiveElementManager.cpp b/gfx/layers/apz/util/ActiveElementManager.cpp index 61f3c79c7f50..765fbdd2e163 100644 --- a/gfx/layers/apz/util/ActiveElementManager.cpp +++ b/gfx/layers/apz/util/ActiveElementManager.cpp @@ -14,8 +14,8 @@ #include "mozilla/dom/Element.h" #include "mozilla/dom/Document.h" -#define AEM_LOG(...) -// #define AEM_LOG(...) printf_stderr("AEM: " __VA_ARGS__) +static mozilla::LazyLogModule sApzAemLog("apz.activeelement"); +#define AEM_LOG(...) MOZ_LOG(sApzAemLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { namespace layers {