Bug 878801 - part 1 - introduce nsIDOMWindowUtils.getBoundsWithoutFlushing(); r=roc

This commit is contained in:
Tim Taubert 2013-06-04 08:06:29 +02:00
parent 5be6cc599a
commit 9195d2a157
2 changed files with 35 additions and 1 deletions

View File

@ -1540,6 +1540,35 @@ nsDOMWindowUtils::GetScrollbarSize(bool aFlushLayout, int32_t* aWidth,
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetBoundsWithoutFlushing(nsIDOMElement *aElement,
nsIDOMClientRect** aResult)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsresult rv;
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsClientRect> rect = new nsClientRect(window);
nsIFrame* frame = content->GetPrimaryFrame();
if (frame) {
nsRect r = nsLayoutUtils::GetAllInFlowRectsUnion(frame,
nsLayoutUtils::GetContainingBlockForClientRect(frame),
nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
rect->SetLayoutRect(r);
}
rect.forget(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetRootBounds(nsIDOMClientRect** aResult)
{

View File

@ -42,7 +42,7 @@ interface nsIURI;
interface nsIDOMEventTarget;
interface nsIRunnable;
[scriptable, uuid(dba80826-6251-4947-bf2a-a3873b9ec764)]
[scriptable, uuid(a806d366-cc52-11e2-bc9a-ba3212c84021)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -658,6 +658,11 @@ interface nsIDOMWindowUtils : nsISupports {
*/
void getScrollbarSize(in boolean aFlushLayout, out long aWidth, out long aHeight);
/**
* Returns the given element's bounds without flushing pending layout changes.
*/
nsIDOMClientRect getBoundsWithoutFlushing(in nsIDOMElement aElement);
/**
* Returns the bounds of the window's currently loaded document. This will
* generally be (0, 0, pageWidth, pageHeight) but in some cases (e.g. RTL