зеркало из https://github.com/mozilla/pjs.git
Bug 605618 Part 7: Include viewport and content size in API r=cjones sr=roc
This commit is contained in:
Родитель
85c0c53ebd
Коммит
826ab38edc
|
@ -92,6 +92,18 @@ interface nsIContentView : nsISupports
|
||||||
readonly attribute float scrollX;
|
readonly attribute float scrollX;
|
||||||
readonly attribute float scrollY;
|
readonly attribute float scrollY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dimensions of the viewport in chrome-document CSS pixels.
|
||||||
|
*/
|
||||||
|
readonly attribute float viewportWidth;
|
||||||
|
readonly attribute float viewportHeight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dimensions of scrolled content in chrome-document CSS pixels.
|
||||||
|
*/
|
||||||
|
readonly attribute float contentWidth;
|
||||||
|
readonly attribute float contentHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID that can be used in conjunction with nsIDOMWindowUtils to change
|
* ID that can be used in conjunction with nsIDOMWindowUtils to change
|
||||||
* the actual document, instead of just how it is transformed.
|
* the actual document, instead of just how it is transformed.
|
||||||
|
|
|
@ -236,6 +236,34 @@ nsContentView::GetScrollY(float* aViewScrollY)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsContentView::GetViewportWidth(float* aWidth)
|
||||||
|
{
|
||||||
|
*aWidth = nsPresContext::AppUnitsToFloatCSSPixels(mViewportSize.width);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsContentView::GetViewportHeight(float* aHeight)
|
||||||
|
{
|
||||||
|
*aHeight = nsPresContext::AppUnitsToFloatCSSPixels(mViewportSize.height);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsContentView::GetContentWidth(float* aWidth)
|
||||||
|
{
|
||||||
|
*aWidth = nsPresContext::AppUnitsToFloatCSSPixels(mContentSize.width);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsContentView::GetContentHeight(float* aHeight)
|
||||||
|
{
|
||||||
|
*aHeight = nsPresContext::AppUnitsToFloatCSSPixels(mContentSize.height);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsContentView::GetId(nsContentViewId* aId)
|
nsContentView::GetId(nsContentViewId* aId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,7 +131,9 @@ public:
|
||||||
|
|
||||||
nsContentView(nsIContent* aOwnerContent, ViewID aScrollId,
|
nsContentView(nsIContent* aOwnerContent, ViewID aScrollId,
|
||||||
ViewConfig aConfig = ViewConfig())
|
ViewConfig aConfig = ViewConfig())
|
||||||
: mOwnerContent(aOwnerContent)
|
: mViewportSize(0, 0)
|
||||||
|
, mContentSize(0, 0)
|
||||||
|
, mOwnerContent(aOwnerContent)
|
||||||
, mScrollId(aScrollId)
|
, mScrollId(aScrollId)
|
||||||
, mConfig(aConfig)
|
, mConfig(aConfig)
|
||||||
{}
|
{}
|
||||||
|
@ -148,6 +150,9 @@ public:
|
||||||
return mConfig;
|
return mConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsSize mViewportSize;
|
||||||
|
nsSize mContentSize;
|
||||||
|
|
||||||
nsIContent *mOwnerContent; // WEAK
|
nsIContent *mOwnerContent; // WEAK
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -97,6 +97,7 @@ public:
|
||||||
|
|
||||||
FrameMetrics()
|
FrameMetrics()
|
||||||
: mViewport(0, 0, 0, 0)
|
: mViewport(0, 0, 0, 0)
|
||||||
|
, mContentSize(0, 0)
|
||||||
, mViewportScrollOffset(0, 0)
|
, mViewportScrollOffset(0, 0)
|
||||||
, mScrollId(NULL_SCROLL_ID)
|
, mScrollId(NULL_SCROLL_ID)
|
||||||
{}
|
{}
|
||||||
|
@ -127,6 +128,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIntRect mViewport;
|
nsIntRect mViewport;
|
||||||
|
nsIntSize mContentSize;
|
||||||
nsIntPoint mViewportScrollOffset;
|
nsIntPoint mViewportScrollOffset;
|
||||||
nsIntRect mDisplayPort;
|
nsIntRect mDisplayPort;
|
||||||
ViewID mScrollId;
|
ViewID mScrollId;
|
||||||
|
|
|
@ -64,6 +64,7 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
|
||||||
static void Write(Message* aMsg, const paramType& aParam)
|
static void Write(Message* aMsg, const paramType& aParam)
|
||||||
{
|
{
|
||||||
WriteParam(aMsg, aParam.mViewport);
|
WriteParam(aMsg, aParam.mViewport);
|
||||||
|
WriteParam(aMsg, aParam.mContentSize);
|
||||||
WriteParam(aMsg, aParam.mViewportScrollOffset);
|
WriteParam(aMsg, aParam.mViewportScrollOffset);
|
||||||
WriteParam(aMsg, aParam.mDisplayPort);
|
WriteParam(aMsg, aParam.mDisplayPort);
|
||||||
WriteParam(aMsg, aParam.mScrollId);
|
WriteParam(aMsg, aParam.mScrollId);
|
||||||
|
@ -72,6 +73,7 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
|
||||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||||
{
|
{
|
||||||
return (ReadParam(aMsg, aIter, &aResult->mViewport) &&
|
return (ReadParam(aMsg, aIter, &aResult->mViewport) &&
|
||||||
|
ReadParam(aMsg, aIter, &aResult->mContentSize) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mViewportScrollOffset) &&
|
ReadParam(aMsg, aIter, &aResult->mViewportScrollOffset) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
|
ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mScrollId));
|
ReadParam(aMsg, aIter, &aResult->mScrollId));
|
||||||
|
|
|
@ -173,6 +173,12 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
|
||||||
nsIScrollableFrame* rootScrollableFrame =
|
nsIScrollableFrame* rootScrollableFrame =
|
||||||
presShell->GetRootScrollFrameAsScrollable();
|
presShell->GetRootScrollFrameAsScrollable();
|
||||||
if (rootScrollableFrame) {
|
if (rootScrollableFrame) {
|
||||||
|
nsSize contentSize =
|
||||||
|
rootScrollableFrame->GetScrollRange().Size() +
|
||||||
|
rootScrollableFrame->GetScrollPortRect().Size();
|
||||||
|
metrics.mContentSize = nsIntSize(NSAppUnitsToIntPixels(contentSize.width, auPerDevPixel),
|
||||||
|
NSAppUnitsToIntPixels(contentSize.height, auPerDevPixel));
|
||||||
|
|
||||||
metrics.mViewportScrollOffset =
|
metrics.mViewportScrollOffset =
|
||||||
rootScrollableFrame->GetScrollPosition().ToNearestPixels(auPerDevPixel);
|
rootScrollableFrame->GetScrollPosition().ToNearestPixels(auPerDevPixel);
|
||||||
|
|
||||||
|
|
|
@ -372,6 +372,13 @@ BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
|
||||||
view = new nsContentView(aFrameLoader->GetOwnerContent(), scrollId, config);
|
view = new nsContentView(aFrameLoader->GetOwnerContent(), scrollId, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view->mViewportSize = nsSize(
|
||||||
|
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);
|
||||||
|
|
||||||
newContentViews.insert(ViewMap::value_type(scrollId, view));
|
newContentViews.insert(ViewMap::value_type(scrollId, view));
|
||||||
|
|
||||||
for (Layer* child = aLayer->GetFirstChild();
|
for (Layer* child = aLayer->GetFirstChild();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче