Bug 1667176 - Collapse ScrollableLayerGuid stringification functions. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D91334
This commit is contained in:
Kartikaya Gupta 2020-09-25 08:57:23 +00:00
parent 328e91296c
commit a36e0f76fb
8 changed files with 28 additions and 32 deletions

View File

@ -259,15 +259,6 @@ void AppendToString(std::stringstream& aStream, const FrameMetrics& m,
aStream << sfx;
}
void AppendToString(std::stringstream& aStream, const ScrollableLayerGuid& s,
const char* pfx, const char* sfx) {
aStream << pfx
<< nsPrintfCString("{ l=0x%" PRIx64 ", p=%u, v=%" PRIu64 " }",
uint64_t(s.mLayersId), s.mPresShellId, s.mScrollId)
.get()
<< sfx;
}
void AppendToString(std::stringstream& aStream, const ZoomConstraints& z,
const char* pfx, const char* sfx) {
aStream << pfx

View File

@ -181,9 +181,6 @@ void AppendToString(std::stringstream& aStream, const FrameMetrics& m,
const char* pfx = "", const char* sfx = "",
bool detailed = false);
void AppendToString(std::stringstream& aStream, const ScrollableLayerGuid& s,
const char* pfx = "", const char* sfx = "");
void AppendToString(std::stringstream& aStream, const ZoomConstraints& z,
const char* pfx = "", const char* sfx = "");

View File

@ -6,7 +6,9 @@
#include "ScrollableLayerGuid.h"
#include <ostream>
#include "mozilla/HashFunctions.h" // for HashGeneric
#include "nsPrintfCString.h" // for nsPrintfCString
namespace mozilla {
namespace layers {
@ -43,6 +45,13 @@ bool ScrollableLayerGuid::operator<(const ScrollableLayerGuid& other) const {
return false;
}
std::ostream& operator<<(std::ostream& aOut, const ScrollableLayerGuid& aGuid) {
return aOut << nsPrintfCString("{ l=0x%" PRIx64 ", p=%u, v=%" PRIu64 " }",
uint64_t(aGuid.mLayersId), aGuid.mPresShellId,
aGuid.mScrollId)
.get();
}
std::size_t ScrollableLayerGuid::HashFn::operator()(
const ScrollableLayerGuid& aGuid) const {
return HashGeneric(uint64_t(aGuid.mLayersId), aGuid.mPresShellId,

View File

@ -7,11 +7,10 @@
#ifndef GFX_SCROLLABLELAYERGUID_H
#define GFX_SCROLLABLELAYERGUID_H
#include <iosfwd> // for ostream
#include <stdint.h> // for uint8_t, uint32_t, uint64_t
#include "mozilla/gfx/Logging.h" // for Log
#include "mozilla/layers/LayersTypes.h" // for LayersId
#include "nsHashKeys.h" // for nsUint64HashKey
#include "nsPrintfCString.h" // for nsPrintfCString
namespace mozilla {
namespace layers {
@ -49,6 +48,9 @@ struct ScrollableLayerGuid {
bool operator!=(const ScrollableLayerGuid& other) const;
bool operator<(const ScrollableLayerGuid& other) const;
friend std::ostream& operator<<(std::ostream& aOut,
const ScrollableLayerGuid& aGuid);
// Helper structs to use as hash/equality functions in std::unordered_map.
// e.g. std::unordered_map<ScrollableLayerGuid,
// ValueType,
@ -72,15 +74,6 @@ struct ScrollableLayerGuid {
};
};
template <int LogLevel>
gfx::Log<LogLevel>& operator<<(gfx::Log<LogLevel>& log,
const ScrollableLayerGuid& aGuid) {
return log << nsPrintfCString("(0x%" PRIx64 ", %u, %" PRIu64 ")",
uint64_t(aGuid.mLayersId), aGuid.mPresShellId,
aGuid.mScrollId)
.get();
}
} // namespace layers
} // namespace mozilla

View File

@ -40,6 +40,7 @@
#include "mozilla/StaticPrefs_accessibility.h"
#include "mozilla/StaticPrefs_apz.h"
#include "mozilla/StaticPrefs_layout.h"
#include "mozilla/ToString.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/EventStateManager.h" // for WheelPrefs
#include "mozilla/webrender/WebRenderAPI.h"
@ -1004,7 +1005,9 @@ template <class ScrollNode>
void APZCTreeManager::PrintAPZCInfo(const ScrollNode& aLayer,
const AsyncPanZoomController* apzc) {
const FrameMetrics& metrics = aLayer.Metrics();
mApzcTreeLog << "APZC " << apzc->GetGuid()
std::stringstream guidStr;
guidStr << apzc->GetGuid();
mApzcTreeLog << "APZC " << guidStr.str()
<< "\tcb=" << metrics.GetCompositionBounds()
<< "\tsr=" << metrics.GetScrollableRect()
<< (metrics.IsScrollInfoLayer() ? "\tscrollinfo" : "")
@ -2431,10 +2434,10 @@ void APZCTreeManager::UpdateZoomConstraints(
if (aConstraints) {
APZCTM_LOG("Recording constraints %s for guid %s\n",
Stringify(aConstraints.value()).c_str(),
Stringify(aGuid).c_str());
ToString(aGuid).c_str());
mZoomConstraints[aGuid] = aConstraints.ref();
} else {
APZCTM_LOG("Removing constraints for guid %s\n", Stringify(aGuid).c_str());
APZCTM_LOG("Removing constraints for guid %s\n", ToString(aGuid).c_str());
mZoomConstraints.erase(aGuid);
}
if (node && aConstraints) {
@ -2804,7 +2807,7 @@ APZCTreeManager::HitTestResult APZCTreeManager::GetAPZCAtPointWR(
for (const wr::WrHitResult& result : results) {
ScrollableLayerGuid guid{result.mLayersId, 0, result.mScrollId};
APZCTM_LOG("Examining result with guid %s hit info 0x%x... ",
Stringify(guid).c_str(), result.mHitInfo.serialize());
ToString(guid).c_str(), result.mHitInfo.serialize());
if (result.mHitInfo == CompositorHitTestInvisibleToHit) {
APZCTM_LOG("skipping due to invisibility.\n");
continue;

View File

@ -10,6 +10,7 @@
#include "mozilla/gfx/Point.h" // for Point4D
#include "mozilla/layers/APZUtils.h" // for AsyncTransform, CompleteAsyncTransform
#include "mozilla/layers/AsyncDragMetrics.h" // for AsyncDragMetrics
#include "mozilla/ToString.h" // for ToString
#include "nsPrintfCString.h" // for nsPrintfCString
#include "UnitTransforms.h" // for ViewAs
@ -432,7 +433,7 @@ void HitTestingTreeNode::Dump(const char* aPrefix) const {
("%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()
mApzc ? ToString(mApzc->GetGuid()).c_str()
: nsPrintfCString("l=0x%" PRIx64, uint64_t(mLayersId)).get(),
(mOverride & EventRegionsOverride::ForceDispatchToContent) ? "fdtc "
: "",

View File

@ -11,6 +11,7 @@
#include "InputBlockState.h"
#include "LayersLogging.h"
#include "mozilla/layers/APZThreadUtils.h"
#include "mozilla/ToString.h"
#include "OverscrollHandoffState.h"
#include "QueuedInput.h"
#include "mozilla/StaticPrefs_apz.h"
@ -787,7 +788,7 @@ void InputQueue::SetConfirmedTargetApzc(
APZThreadUtils::AssertOnControllerThread();
INPQ_LOG("got a target apzc; block=%" PRIu64 " guid=%s\n", aInputBlockId,
aTargetApzc ? Stringify(aTargetApzc->GetGuid()).c_str() : "");
aTargetApzc ? ToString(aTargetApzc->GetGuid()).c_str() : "");
bool success = false;
InputData* firstInput = nullptr;
InputBlockState* inputBlock = FindBlockForId(aInputBlockId, &firstInput);
@ -818,7 +819,7 @@ void InputQueue::ConfirmDragBlock(
INPQ_LOG("got a target apzc; block=%" PRIu64 " guid=%s dragtarget=%" PRIu64
"\n",
aInputBlockId,
aTargetApzc ? Stringify(aTargetApzc->GetGuid()).c_str() : "",
aTargetApzc ? ToString(aTargetApzc->GetGuid()).c_str() : "",
aDragMetrics.mViewId);
bool success = false;
InputData* firstInput = nullptr;

View File

@ -19,6 +19,7 @@
#include "mozilla/PresShell.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_ui.h"
#include "mozilla/ToString.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/ViewportUtils.h"
#include "mozilla/dom/BrowserChild.h"
@ -355,7 +356,7 @@ void APZEventState::ProcessTouchEvent(
sentContentResponse = true;
} else {
APZES_LOG("Event not prevented; pending response for %" PRIu64 " %s\n",
aInputBlockId, Stringify(aGuid).c_str());
aInputBlockId, ToString(aGuid).c_str());
mPendingTouchPreventedResponse = true;
mPendingTouchPreventedGuid = aGuid;
mPendingTouchPreventedBlockId = aInputBlockId;
@ -524,7 +525,7 @@ void APZEventState::ProcessAPZStateChange(ViewID aViewId,
bool APZEventState::SendPendingTouchPreventedResponse(bool aPreventDefault) {
if (mPendingTouchPreventedResponse) {
APZES_LOG("Sending response %d for pending guid: %s\n", aPreventDefault,
Stringify(mPendingTouchPreventedGuid).c_str());
ToString(mPendingTouchPreventedGuid).c_str());
mContentReceivedInputBlockCallback(mPendingTouchPreventedBlockId,
aPreventDefault);
mPendingTouchPreventedResponse = false;