Bug 1427419 - Part 26: Move inIDOMUtils.scrollElementIntoView to InspectorUtils. r?bz draft
authorCameron McCormack <cam@mcc.id.au>
Sat, 06 Jan 2018 15:08:16 +0800
changeset 716771 aef71a498bb1b6e19450bf830a4f1d3eb77c5023
parent 716770 fd4df4e30e4260339af52476fdf971a90135cee3
child 716772 3fefe6a7201990afc7e4bb448c90a07233199184
push id94496
push userbmo:cam@mcc.id.au
push dateSat, 06 Jan 2018 07:08:40 +0000
reviewersbz
bugs1427419
milestone59.0a1
Bug 1427419 - Part 26: Move inIDOMUtils.scrollElementIntoView to InspectorUtils. r?bz This is unused in mozilla-central but still used in comm-central. MozReview-Commit-ID: 9jTqGDkbcFE
dom/webidl/InspectorUtils.webidl
layout/inspector/InspectorUtils.h
layout/inspector/inDOMUtils.cpp
layout/inspector/inIDOMUtils.idl
--- a/dom/webidl/InspectorUtils.webidl
+++ b/dom/webidl/InspectorUtils.webidl
@@ -67,16 +67,17 @@ namespace InspectorUtils {
   sequence<DOMString> getCSSPseudoElementNames();
   void addPseudoClassLock(Element element,
                           DOMString pseudoClass,
                           optional boolean enabled = true);
   void removePseudoClassLock(Element element, DOMString pseudoClass);
   boolean hasPseudoClassLock(Element element, DOMString pseudoClass);
   void clearPseudoClassLocks(Element element);
   [Throws] void parseStyleSheet(CSSStyleSheet sheet, DOMString input);
+  void scrollElementIntoView(Element element);
 };
 
 dictionary PropertyNamesOptions {
   boolean includeAliases = false;
 };
 
 dictionary InspectorRGBATuple {
   /*
--- a/layout/inspector/InspectorUtils.h
+++ b/layout/inspector/InspectorUtils.h
@@ -254,16 +254,22 @@ public:
    * @param DOMString aInput
    *        The new source string for the style sheet.
    */
   static void ParseStyleSheet(GlobalObject& aGlobal,
                               StyleSheet& aSheet,
                               const nsAString& aInput,
                               ErrorResult& aRv);
 
+  /**
+   * Scroll an element completely into view, if possible.
+   * This is similar to ensureElementIsVisible but for all ancestors.
+   */
+  static void ScrollElementIntoView(GlobalObject& aGlobal, Element& aElement);
+
 private:
   static already_AddRefed<nsStyleContext>
     GetCleanStyleContextForElement(Element* aElement, nsAtom* aPseudo);
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -1115,29 +1115,25 @@ InspectorUtils::ParseStyleSheet(GlobalOb
       aRv.Throw(rv);
     }
     return;
   }
 
   aRv.Throw(NS_ERROR_INVALID_POINTER);
 }
 
-} // namespace dom
-} // namespace mozilla
-
-NS_IMETHODIMP
-inDOMUtils::ScrollElementIntoView(nsIDOMElement *aElement)
+void
+InspectorUtils::ScrollElementIntoView(GlobalObject& aGlobalObject,
+                                      Element& aElement)
 {
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
-  NS_ENSURE_ARG_POINTER(content);
-
-  nsIPresShell* presShell = content->OwnerDoc()->GetShell();
+  nsIPresShell* presShell = aElement.OwnerDoc()->GetShell();
   if (!presShell) {
-    return NS_OK;
+    return;
   }
 
-  presShell->ScrollContentIntoView(content,
+  presShell->ScrollContentIntoView(&aElement,
                                    nsIPresShell::ScrollAxis(),
                                    nsIPresShell::ScrollAxis(),
                                    nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
+}
 
-  return NS_OK;
-}
+} // namespace dom
+} // namespace mozilla
--- a/layout/inspector/inIDOMUtils.idl
+++ b/layout/inspector/inIDOMUtils.idl
@@ -15,20 +15,13 @@ interface nsIDOMNode;
 interface nsIDOMNodeList;
 interface nsIDOMFontFaceList;
 interface nsIDOMRange;
 interface nsIDOMCSSStyleSheet;
 
 [scriptable, uuid(362e98c3-82c2-4ad8-8dcb-00e8e4eab497)]
 interface inIDOMUtils : nsISupports
 {
-  /**
-   * 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"
 %}