From e2eae8dab7c7cac4f77787cf36288fe8e69a30ea Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Thu, 8 Aug 2013 15:56:09 -0400 Subject: [PATCH] Bug 898580 - Add nsIDOMWindowUtils.getViewId(element). r=smaug --- dom/base/nsDOMWindowUtils.cpp | 10 ++++++++++ dom/interfaces/base/nsIDOMWindowUtils.idl | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index e8170d7a2d2c..b5fe80ff25b8 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1694,6 +1694,16 @@ nsDOMWindowUtils::FindElementWithViewId(nsViewID aID, return content ? CallQueryInterface(content, aResult) : NS_OK; } +NS_IMETHODIMP +nsDOMWindowUtils::GetViewId(nsIDOMElement* aElement, nsViewID* aResult) +{ + nsCOMPtr content = do_QueryInterface(aElement); + if (content && nsLayoutUtils::FindIDFor(content, aResult)) { + return NS_OK; + } + return NS_ERROR_NOT_AVAILABLE; +} + NS_IMETHODIMP nsDOMWindowUtils::GetScreenPixelsPerCSSPixel(float* aScreenPixels) { diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 5f397fda534f..dffb0f9dfd94 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -42,7 +42,7 @@ interface nsIURI; interface nsIDOMEventTarget; interface nsIRunnable; -[scriptable, uuid(ff1cec22-b183-40d3-8b42-b81a2f0ba4e6)] +[scriptable, uuid(d6e733ef-492b-4e67-b723-28571c2959f0)] interface nsIDOMWindowUtils : nsISupports { /** @@ -1177,6 +1177,12 @@ interface nsIDOMWindowUtils : nsISupports { */ nsIDOMElement findElementWithViewId(in nsViewID aId); + /** + * Find the view ID for a given element. This is the reverse of + * findElementWithViewId(). + */ + nsViewID getViewId(in nsIDOMElement aElement); + /** * Checks the layer tree for this window and returns true * if all layers have transforms that are translations by integers,