Bug 1240326: Part 1: Add lazyWidth and lazyHeight properties to frame loaders. r?billm
MozReview-Commit-ID: 6uEcjS10KCW
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2332,16 +2332,17 @@ nsFrameLoader::GetWindowDimensions(nsInt
NS_IMETHODIMP
nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame *aIFrame)
{
if (IsRemoteFrame()) {
if (mRemoteBrowser) {
ScreenIntSize size = aIFrame->GetSubdocumentSize();
nsIntRect dimensions;
NS_ENSURE_SUCCESS(GetWindowDimensions(dimensions), NS_ERROR_FAILURE);
+ mLazySize = size;
mRemoteBrowser->UpdateDimensions(dimensions, size);
}
return NS_OK;
}
UpdateBaseWindowPositionAndSize(aIFrame);
return NS_OK;
}
@@ -2362,23 +2363,50 @@ nsFrameLoader::UpdateBaseWindowPositionA
baseWindow->GetPosition(&x, &y);
if (!weakFrame.IsAlive()) {
// GetPosition() killed us
return;
}
ScreenIntSize size = aIFrame->GetSubdocumentSize();
+ mLazySize = size;
baseWindow->SetPositionAndSize(x, y, size.width, size.height,
nsIBaseWindow::eDelayResize);
}
}
NS_IMETHODIMP
+nsFrameLoader::GetLazyWidth(uint32_t* aLazyWidth)
+{
+ *aLazyWidth = mLazySize.width;
+
+ nsIFrame* frame = GetPrimaryFrameOfOwningContent();
+ if (frame) {
+ *aLazyWidth = frame->PresContext()->DevPixelsToIntCSSPixels(*aLazyWidth);
+ }
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsFrameLoader::GetLazyHeight(uint32_t* aLazyHeight)
+{
+ *aLazyHeight = mLazySize.height;
+
+ nsIFrame* frame = GetPrimaryFrameOfOwningContent();
+ if (frame) {
+ *aLazyHeight = frame->PresContext()->DevPixelsToIntCSSPixels(*aLazyHeight);
+ }
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
nsFrameLoader::GetEventMode(uint32_t* aEventMode)
{
*aEventMode = mEventMode;
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::SetEventMode(uint32_t aEventMode)
--- a/dom/base/nsFrameLoader.h
+++ b/dom/base/nsFrameLoader.h
@@ -370,16 +370,19 @@ private:
TabParent* mRemoteBrowser;
uint64_t mChildID;
// See nsIFrameLoader.idl. EVENT_MODE_NORMAL_DISPATCH automatically
// forwards some input events to out-of-process content.
uint32_t mEventMode;
+ // Holds the last known size of the frame.
+ mozilla::ScreenIntSize mLazySize;
+
bool mIsPrerendered : 1;
bool mDepthTooGreat : 1;
bool mIsTopLevelContent : 1;
bool mDestroyCalled : 1;
bool mNeedsAsyncDestroy : 1;
bool mInSwap : 1;
bool mInShow : 1;
bool mHideCalled : 1;
--- a/dom/base/nsIFrameLoader.idl
+++ b/dom/base/nsIFrameLoader.idl
@@ -222,16 +222,31 @@ interface nsIFrameLoader : nsISupports
readonly attribute boolean ownerIsMozBrowserOrAppFrame;
/**
* Find out whether the owner content really is a widget. If this attribute
* returns true, |ownerIsMozBrowserOrAppFrame| must return true.
*/
readonly attribute boolean ownerIsWidget;
+ /**
+ * The last known width of the frame. Reading this property will not trigger
+ * a reflow, and therefore may not reflect the current state of things. It
+ * should only be used in asynchronous APIs where values are not guaranteed
+ * to be up-to-date when received.
+ */
+ readonly attribute unsigned long lazyWidth;
+
+ /**
+ * The last known height of the frame. Reading this property will not trigger
+ * a reflow, and therefore may not reflect the current state of things. It
+ * should only be used in asynchronous APIs where values are not guaranteed
+ * to be up-to-date when received.
+ */
+ readonly attribute unsigned long lazyHeight;
};
%{C++
class nsFrameLoader;
%}
native alreadyAddRefed_nsFrameLoader(already_AddRefed<nsFrameLoader>);