Bug 744901 - Store the page size in FrameMetrics in CSS pixels in addition to device pixels. r=cjones

--HG--
extra : rebase_source : ac38e2ff9dda55bd5dc44d757b67cb1550da1eaa
This commit is contained in:
Jeff Muizelaar 2012-04-12 15:55:26 -04:00
parent 8f1b4dec1d
commit 78533845be
5 changed files with 34 additions and 3 deletions

View File

@ -109,6 +109,7 @@ public:
, mContentSize(0, 0)
, mViewportScrollOffset(0, 0)
, mScrollId(NULL_SCROLL_ID)
, mCSSContentSize(0, 0)
{}
// Default copy ctor and operator= are fine
@ -146,6 +147,10 @@ public:
nsIntPoint mViewportScrollOffset;
nsIntRect mDisplayPort;
ViewID mScrollId;
// Consumers often want to know the size before scaling to pixels
// so we record this size as well.
gfx::Size mCSSContentSize;
};
#define MOZ_LAYER_DECL_NAME(n, e) \

View File

@ -67,6 +67,7 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mCSSContentSize);
WriteParam(aMsg, aParam.mViewport);
WriteParam(aMsg, aParam.mContentSize);
WriteParam(aMsg, aParam.mViewportScrollOffset);
@ -76,7 +77,8 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mViewport) &&
return (ReadParam(aMsg, aIter, &aResult->mCSSContentSize) &&
ReadParam(aMsg, aIter, &aResult->mViewport) &&
ReadParam(aMsg, aIter, &aResult->mContentSize) &&
ReadParam(aMsg, aIter, &aResult->mViewportScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&

View File

@ -42,6 +42,7 @@
#include "chrome/common/ipc_message_utils.h"
#include "mozilla/Util.h"
#include "mozilla/gfx/2D.h"
#include "prtypes.h"
#include "nsID.h"
@ -751,6 +752,25 @@ struct ParamTraits<nsIntSize>
}
};
template<>
struct ParamTraits<mozilla::gfx::Size>
{
typedef mozilla::gfx::Size paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.width);
WriteParam(msg, param.height);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->width) &&
ReadParam(msg, iter, &result->height));
}
};
template<>
struct ParamTraits<nsRect>
{

View File

@ -233,6 +233,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
nsSize contentSize =
scrollableFrame->GetScrollRange().Size() +
scrollableFrame->GetScrollPortRect().Size();
metrics.mCSSContentSize = gfx::Size(nsPresContext::AppUnitsToFloatCSSPixels(contentSize.width),
nsPresContext::AppUnitsToFloatCSSPixels(contentSize.height));
metrics.mContentSize = contentSize.ScaleToNearestPixels(
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel);
metrics.mViewportScrollOffset = scrollableFrame->GetScrollPosition().ScaleToNearestPixels(
@ -240,6 +242,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
}
else {
nsSize contentSize = aForFrame->GetSize();
metrics.mCSSContentSize = gfx::Size(nsPresContext::AppUnitsToFloatCSSPixels(contentSize.width),
nsPresContext::AppUnitsToFloatCSSPixels(contentSize.height));
metrics.mContentSize = contentSize.ScaleToNearestPixels(
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel);
}

View File

@ -411,8 +411,8 @@ BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
NSIntPixelsToAppUnits(metrics.mViewport.width, auPerDevPixel) * aXScale,
NSIntPixelsToAppUnits(metrics.mViewport.height, auPerDevPixel) * aYScale);
view->mContentSize = nsSize(
NSIntPixelsToAppUnits(metrics.mContentSize.width, auPerDevPixel) * aXScale,
NSIntPixelsToAppUnits(metrics.mContentSize.height, auPerDevPixel) * aYScale);
nsPresContext::CSSPixelsToAppUnits(metrics.mCSSContentSize.width) * aXScale,
nsPresContext::CSSPixelsToAppUnits(metrics.mCSSContentSize.height) * aYScale);
newContentViews[scrollId] = view;
}