Bug 1018324 Add scrollElementIntoView to inIDOMUtils as inIFlasher is going away r=roc

This commit is contained in:
Neil Rashbrook 2014-06-09 08:35:13 +01:00
parent 9c2ebc48cb
commit 47e0580a88
2 changed files with 27 additions and 1 deletions

View File

@ -878,3 +878,22 @@ inDOMUtils::ParseStyleSheet(nsIDOMCSSStyleSheet *aSheet,
return sheet->ParseSheet(aInput);
}
NS_IMETHODIMP
inDOMUtils::ScrollElementIntoView(nsIDOMElement *aElement)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(content);
nsIPresShell* presShell = content->OwnerDoc()->GetShell();
if (!presShell) {
return NS_OK;
}
presShell->ScrollContentIntoView(content,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
return NS_OK;
}

View File

@ -16,7 +16,7 @@ interface nsIDOMFontFaceList;
interface nsIDOMRange;
interface nsIDOMCSSStyleSheet;
[scriptable, uuid(ceae6c68-f5d4-4597-a3d9-ca5646c25f1a)]
[scriptable, uuid(948792a7-b786-4a2c-910d-f55b0773c2ca)]
interface inIDOMUtils : nsISupports
{
// CSS utilities
@ -103,6 +103,13 @@ interface inIDOMUtils : nsISupports
* The new source string for the style sheet.
*/
void parseStyleSheet(in nsIDOMCSSStyleSheet aSheet, in DOMString aInput);
/**
* Scroll an element completely into view, if possible.
* This is similar to ensureElementIsVisible but for all ancestors.
*
* @param DOMElement aElement
*/
void scrollElementIntoView(in nsIDOMElement aElement);
};
%{ C++