Bug 1018324 Add scrollElementIntoView to inIDOMUtils as inIFlasher is going away r=roc
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Mon, 09 Jun 2014 08:35:13 +0100
changeset 187523 c3696dc117434c51338e1201cf84d7579e1e1d3e
parent 187522 7987a44a68140f5341f9659b08729e1305e0e909
child 187524 3395ce618c91f7ba993b34f487d754b9ab494bb8
push id26923
push useremorley@mozilla.com
push dateMon, 09 Jun 2014 14:21:33 +0000
treeherdermozilla-central@43a2f570cea2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1018324
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1018324 Add scrollElementIntoView to inIDOMUtils as inIFlasher is going away r=roc
layout/inspector/inDOMUtils.cpp
layout/inspector/inIDOMUtils.idl
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -873,8 +873,27 @@ NS_IMETHODIMP
 inDOMUtils::ParseStyleSheet(nsIDOMCSSStyleSheet *aSheet,
                             const nsAString& aInput)
 {
   nsRefPtr<nsCSSStyleSheet> sheet = do_QueryObject(aSheet);
   NS_ENSURE_ARG_POINTER(sheet);
 
   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;
+}
--- a/layout/inspector/inIDOMUtils.idl
+++ b/layout/inspector/inIDOMUtils.idl
@@ -11,17 +11,17 @@ interface nsIDOMElement;
 interface nsIDOMDocument;
 interface nsIDOMCSSStyleRule;
 interface nsIDOMNode;
 interface nsIDOMNodeList;
 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
   void getAllStyleSheets (in nsIDOMDocument aDoc,
                           [optional] out unsigned long aLength,
                           [array, size_is (aLength), retval] out nsISupports aSheets);
   nsISupportsArray getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo);
   unsigned long getRuleLine(in nsIDOMCSSStyleRule aRule);
@@ -98,13 +98,20 @@ interface inIDOMUtils : nsISupports
   /**
    * Parse CSS and update the style sheet in place.
    *
    * @param DOMCSSStyleSheet aSheet
    * @param DOMString aInput
    *        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++
 #define IN_DOMUTILS_CONTRACTID "@mozilla.org/inspector/dom-utils;1"
 %}