Skip to content

Commit

Permalink
Bug 1667176 - Collapse ScrollableLayerGuid stringification functions.…
Browse files Browse the repository at this point in the history
… r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D91334
  • Loading branch information
staktrace committed Sep 25, 2020
1 parent 328e912 commit a36e0f7
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 32 deletions.
9 changes: 0 additions & 9 deletions gfx/layers/LayersLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions gfx/layers/LayersLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "");

Expand Down
9 changes: 9 additions & 0 deletions gfx/layers/ScrollableLayerGuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

#include "ScrollableLayerGuid.h"

#include <ostream>
#include "mozilla/HashFunctions.h" // for HashGeneric
#include "nsPrintfCString.h" // for nsPrintfCString

namespace mozilla {
namespace layers {
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 4 additions & 11 deletions gfx/layers/ScrollableLayerGuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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

Expand Down
11 changes: 7 additions & 4 deletions gfx/layers/apz/src/APZCTreeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" : "")
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion gfx/layers/apz/src/HitTestingTreeNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 "
: "",
Expand Down
5 changes: 3 additions & 2 deletions gfx/layers/apz/src/InputQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions gfx/layers/apz/util/APZEventState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a36e0f7

Please sign in to comment.