Bug 1666802 - Modify the ScrollPositionUpdate serializer to write to an ostream directly. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D93142
This commit is contained in:
Kartikaya Gupta 2020-10-11 21:18:51 +00:00
Родитель 623306a175
Коммит deb6ba5e6c
5 изменённых файлов: 15 добавлений и 20 удалений

Просмотреть файл

@ -191,14 +191,6 @@ void AppendToString(std::stringstream& aStream, ImageFormat format,
aStream << sfx;
}
void AppendToString(std::stringstream& aStream,
const mozilla::ScrollPositionUpdate& aUpdate,
const char* pfx, const char* sfx) {
aStream << pfx;
aUpdate.AppendToString(aStream);
aStream << sfx;
}
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -45,10 +45,6 @@ void AppendToString(std::stringstream& aStream, gfx::SurfaceType format,
void AppendToString(std::stringstream& aStream, ImageFormat format,
const char* pfx = "", const char* sfx = "");
void AppendToString(std::stringstream& aStream,
const mozilla::ScrollPositionUpdate& aUpdate,
const char* pfx = "", const char* sfx = "");
// Sometimes, you just want a string from a single value.
template <typename T>
std::string Stringify(const T& obj) {

Просмотреть файл

@ -4706,7 +4706,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(
bool scrollOffsetUpdated = false;
for (const auto& scrollUpdate : aScrollMetadata.GetScrollUpdates()) {
APZC_LOG("%p processing scroll update %s\n", this,
Stringify(scrollUpdate).c_str());
ToString(scrollUpdate).c_str());
if (scrollUpdate.GetGeneration() <= Metrics().GetScrollGeneration()) {
// This is stale, let's ignore it
// XXX maybe use a 64-bit value for the scroll generation, or add some

Просмотреть файл

@ -4,6 +4,8 @@
#include "ScrollPositionUpdate.h"
#include <ostream>
#include "mozilla/Assertions.h"
namespace mozilla {
@ -117,12 +119,15 @@ CSSPoint ScrollPositionUpdate::GetDelta() const {
return mDelta;
}
void ScrollPositionUpdate::AppendToString(std::stringstream& aStream) const {
aStream << "ScrollPositionUpdate(gen=" << mScrollGeneration
<< ", type=" << (int)mType << ", mode=" << (int)mScrollMode
<< ", origin=" << (int)mScrollOrigin << ", dst=" << mDestination.x
<< "," << mDestination.y << ", src=" << mSource.x << "," << mSource.y
<< ", delta=" << mDelta.x << "," << mDelta.y << ")";
std::ostream& operator<<(std::ostream& aStream,
const ScrollPositionUpdate& aUpdate) {
aStream << "{ gen=" << aUpdate.mScrollGeneration
<< ", type=" << (int)aUpdate.mType
<< ", mode=" << (int)aUpdate.mScrollMode
<< ", origin=" << (int)aUpdate.mScrollOrigin
<< ", dst=" << aUpdate.mDestination << ", src=" << aUpdate.mSource
<< ", delta=" << aUpdate.mDelta << " }";
return aStream;
}
} // namespace mozilla

Просмотреть файл

@ -6,6 +6,7 @@
#define mozilla_ScrollPositionUpdate_h_
#include <cstdint>
#include <iosfwd>
#include "nsPoint.h"
#include "mozilla/ScrollOrigin.h"
@ -83,7 +84,8 @@ class ScrollPositionUpdate {
// GetDelta is only valid for the PureRelative type; it asserts otherwise.
CSSPoint GetDelta() const;
void AppendToString(std::stringstream& aStream) const;
friend std::ostream& operator<<(std::ostream& aStream,
const ScrollPositionUpdate& aUpdate);
private:
uint32_t mScrollGeneration;