Bug 1446961, remove deprecated showPopup method of PopupBoxObject as well as unused GetPopupSetFrame method, and move some methods' positions to group related methods together better, r=paolo,bz
authorNeil Deakin <neil@mozilla.com>
Fri, 27 Apr 2018 11:04:37 -0400
changeset 416130 5659ad69e1451dfe2fc9a13b7a0f81526951c6aa
parent 416129 5be83a2594fbd2e4e7612d4a779027f03c22b39c
child 416131 962c081b13149f3d35f1f38bd514697aacd1a82a
push id33917
push userapavel@mozilla.com
push dateSat, 28 Apr 2018 17:30:55 +0000
treeherdermozilla-central@08f68e2c892c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo, bz
bugs1446961
milestone61.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 1446961, remove deprecated showPopup method of PopupBoxObject as well as unused GetPopupSetFrame method, and move some methods' positions to group related methods together better, r=paolo,bz
dom/webidl/PopupBoxObject.webidl
layout/xul/PopupBoxObject.cpp
layout/xul/PopupBoxObject.h
toolkit/content/widgets/popup.xml
--- a/dom/webidl/PopupBoxObject.webidl
+++ b/dom/webidl/PopupBoxObject.webidl
@@ -2,49 +2,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 [Func="IsChromeOrXBL"]
 interface PopupBoxObject : BoxObject
 {
   /**
-   *  This method is deprecated. Use openPopup or openPopupAtScreen instead.
-   */
-  void showPopup(Element? srcContent, Element popupContent,
-                 long xpos, long ypos,
-                 optional DOMString popupType = "",
-                 optional DOMString anchorAlignment = "",
-                 optional DOMString popupAlignment = "");
-
-  /**
-   *  Hide the popup if it is open. The cancel argument is used as a hint that
-   *  the popup is being closed because it has been cancelled, rather than
-   *  something being selected within the panel.
-   *
-   * @param cancel if true, then the popup is being cancelled.
-   */
-  void hidePopup(optional boolean cancel = false);
-
-  /**
    * Allow the popup to automatically position itself.
    */
   attribute boolean autoPosition;
 
   /**
-   * Size the popup to the given dimensions
-   */
-  void sizeTo(long width, long height);
-
-  /**
-   * Move the popup to a point on screen in CSS pixels.
-   */
-  void moveTo(long left, long top);
-
-  /**
    * Open the popup relative to a specified node at a specific location.
    *
    * The popup may be either anchored to another node or opened freely.
    * To anchor a popup to a node, supply an anchor node and set the position
    * to a string indicating the manner in which the popup should be anchored.
    * Possible values for position are:
    *    before_start, before_end, after_start, after_end,
    *    start_before, start_after, end_before, end_after,
@@ -110,16 +82,25 @@ interface PopupBoxObject : BoxObject
                              long y,
                              long width,
                              long height,
                              boolean isContextMenu,
                              boolean attributesOverride,
                              Event? triggerEvent);
 
   /**
+   *  Hide the popup if it is open. The cancel argument is used as a hint that
+   *  the popup is being closed because it has been cancelled, rather than
+   *  something being selected within the panel.
+   *
+   * @param cancel if true, then the popup is being cancelled.
+   */
+  void hidePopup(optional boolean cancel = false);
+
+  /**
    * Returns the state of the popup:
    *   closed - the popup is closed
    *   open - the popup is open
    *   showing - the popup is in the process of being shown
    *   hiding - the popup is in the process of being hidden
    */
   readonly attribute DOMString popupState;
 
@@ -137,25 +118,35 @@ interface PopupBoxObject : BoxObject
 
   /**
    * Retrieve the screen rectangle of the popup, including the area occupied by
    * any titlebar or borders present.
    */
   DOMRect getOuterScreenRect();
 
   /**
+   * Move the popup to a point on screen in CSS pixels.
+   */
+  void moveTo(long left, long top);
+
+  /**
    * Move an open popup to the given anchor position. The arguments have the same
    * meaning as the corresponding argument to openPopup. This method has no effect
    * on popups that are not open.
    */
   void moveToAnchor(Element? anchorElement,
                     optional DOMString position = "",
                     long x, long y,
                     boolean attributesOverride);
 
+  /**
+   * Size the popup to the given dimensions
+   */
+  void sizeTo(long width, long height);
+
   /** Returns the alignment position where the popup has appeared relative to its
    *  anchor node or point, accounting for any flipping that occurred.
    */
   readonly attribute DOMString alignmentPosition;
   readonly attribute long alignmentOffset;
 
   void setConstraintRect(DOMRectReadOnly rect);
 };
--- a/layout/xul/PopupBoxObject.cpp
+++ b/layout/xul/PopupBoxObject.cpp
@@ -35,56 +35,26 @@ nsIContent* PopupBoxObject::GetParentObj
   return BoxObject::GetParentObject();
 }
 
 JSObject* PopupBoxObject::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return PopupBoxObjectBinding::Wrap(aCx, this, aGivenProto);
 }
 
-nsPopupSetFrame*
-PopupBoxObject::GetPopupSetFrame()
-{
-  nsIRootBox* rootBox = nsIRootBox::GetRootBox(GetPresShell(false));
-  if (!rootBox)
-    return nullptr;
-
-  return rootBox->GetPopupSetFrame();
-}
-
 void
 PopupBoxObject::HidePopup(bool aCancel)
 {
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
   if (pm && mContent) {
     pm->HidePopup(mContent, false, true, false, aCancel);
   }
 }
 
 void
-PopupBoxObject::ShowPopup(Element* aAnchorElement,
-                          Element& aPopupElement,
-                          int32_t aXPos, int32_t aYPos,
-                          const nsAString& aPopupType,
-                          const nsAString& aAnchorAlignment,
-                          const nsAString& aPopupAlignment)
-{
-  nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
-  if (pm && mContent) {
-    nsCOMPtr<nsIContent> anchorContent(do_QueryInterface(aAnchorElement));
-    nsAutoString popupType(aPopupType);
-    nsAutoString anchor(aAnchorAlignment);
-    nsAutoString align(aPopupAlignment);
-    pm->ShowPopupWithAnchorAlign(mContent, anchorContent, anchor, align,
-                                 aXPos, aYPos,
-                                 popupType.EqualsLiteral("context"));
-  }
-}
-
-void
 PopupBoxObject::OpenPopup(Element* aAnchorElement,
                           const nsAString& aPosition,
                           int32_t aXPos, int32_t aYPos,
                           bool aIsContextMenu,
                           bool aAttributesOverride,
                           Event* aTriggerEvent)
 {
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
--- a/layout/xul/PopupBoxObject.h
+++ b/layout/xul/PopupBoxObject.h
@@ -10,17 +10,16 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "mozilla/dom/BoxObject.h"
 #include "nsString.h"
 
 struct JSContext;
-class nsPopupSetFrame;
 
 namespace mozilla {
 namespace dom {
 
 class DOMRect;
 class Element;
 class Event;
 
@@ -29,34 +28,20 @@ class PopupBoxObject final : public BoxO
 public:
   NS_INLINE_DECL_REFCOUNTING_INHERITED(PopupBoxObject, BoxObject)
 
   PopupBoxObject();
 
   nsIContent* GetParentObject() const;
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
-  void ShowPopup(Element* aAnchorElement,
-                 Element& aPopupElement,
-                 int32_t aXPos,
-                 int32_t aYPos,
-                 const nsAString& aPopupType,
-                 const nsAString& aAnchorAlignment,
-                 const nsAString& aPopupAlignment);
-
-  void HidePopup(bool aCancel);
-
   bool AutoPosition();
 
   void SetAutoPosition(bool aShouldAutoPosition);
 
-  void SizeTo(int32_t aWidth, int32_t aHeight);
-
-  void MoveTo(int32_t aLeft, int32_t aTop);
-
   void OpenPopup(Element* aAnchorElement,
                  const nsAString& aPosition,
                  int32_t aXPos,
                  int32_t aYPos,
                  bool aIsContextMenu, bool aAttributesOverride,
                  Event* aTriggerEvent);
 
   void OpenPopupAtScreen(int32_t aXPos,
@@ -66,39 +51,42 @@ public:
 
   void OpenPopupAtScreenRect(const nsAString& aPosition,
                              int32_t aXPos, int32_t aYPos,
                              int32_t aWidth, int32_t aHeight,
                              bool aIsContextMenu,
                              bool aAttributesOverride,
                              Event* aTriggerEvent);
 
+  void HidePopup(bool aCancel);
+
   void GetPopupState(nsString& aState);
 
   nsINode* GetTriggerNode() const;
 
   Element* GetAnchorNode() const;
 
   already_AddRefed<DOMRect> GetOuterScreenRect();
 
+  void MoveTo(int32_t aLeft, int32_t aTop);
+
   void MoveToAnchor(Element* aAnchorElement,
                     const nsAString& aPosition,
                     int32_t aXPos,
                     int32_t aYPos,
                     bool aAttributesOverride);
 
+  void SizeTo(int32_t aWidth, int32_t aHeight);
+
   void GetAlignmentPosition(nsString& positionStr);
 
   int32_t AlignmentOffset();
 
   void SetConstraintRect(dom::DOMRectReadOnly& aRect);
 
 private:
   ~PopupBoxObject();
-
-protected:
-  nsPopupSetFrame* GetPopupSetFrame();
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_PopupBoxObject_h
--- a/toolkit/content/widgets/popup.xml
+++ b/toolkit/content/widgets/popup.xml
@@ -101,41 +101,16 @@
             if (popupBox)
               popupBox.openPopupAtScreenRect(aPosition, aX, aY, aWidth, aHeight,
                                              aIsContextMenu, aAttributesOverride, aTriggerEvent);
           } catch (e) {}
         ]]>
         </body>
       </method>
 
-      <method name="showPopup">
-        <parameter name="element"/>
-        <parameter name="xpos"/>
-        <parameter name="ypos"/>
-        <parameter name="popuptype"/>
-        <parameter name="anchoralignment"/>
-        <parameter name="popupalignment"/>
-        <body>
-        <![CDATA[
-          var popupBox = null;
-          var menuBox = null;
-          try {
-            popupBox = this.popupBoxObject;
-          } catch (e) {}
-          try {
-            menuBox = this.parentNode.boxObject;
-          } catch (e) {}
-          if (menuBox instanceof MenuBoxObject)
-            menuBox.openMenu(true);
-          else if (popupBox)
-            popupBox.showPopup(element, this, xpos, ypos, popuptype, anchoralignment, popupalignment);
-        ]]>
-        </body>
-      </method>
-
       <method name="hidePopup">
         <parameter name="cancel"/>
         <body>
         <![CDATA[
           var popupBox = null;
           var menuBox = null;
           try {
             popupBox = this.popupBoxObject;
@@ -175,26 +150,16 @@
       <property name="alignmentOffset" readonly="true">
         <getter>
         <![CDATA[
           return this.popupBoxObject.alignmentOffset;
         ]]>
         </getter>
       </property>
 
-      <method name="sizeTo">
-        <parameter name="aWidth"/>
-        <parameter name="aHeight"/>
-        <body>
-        <![CDATA[
-          this.popupBoxObject.sizeTo(aWidth, aHeight);
-        ]]>
-        </body>
-      </method>
-
       <method name="moveTo">
         <parameter name="aLeft"/>
         <parameter name="aTop"/>
         <body>
         <![CDATA[
           this.popupBoxObject.moveTo(aLeft, aTop);
         ]]>
         </body>
@@ -208,16 +173,26 @@
         <parameter name="aAttributesOverride"/>
         <body>
         <![CDATA[
           this.popupBoxObject.moveToAnchor(aAnchorElement, aPosition, aX, aY, aAttributesOverride);
         ]]>
         </body>
       </method>
 
+      <method name="sizeTo">
+        <parameter name="aWidth"/>
+        <parameter name="aHeight"/>
+        <body>
+        <![CDATA[
+          this.popupBoxObject.sizeTo(aWidth, aHeight);
+        ]]>
+        </body>
+      </method>
+
       <method name="getOuterScreenRect">
         <body>
         <![CDATA[
           return this.popupBoxObject.getOuterScreenRect();
         ]]>
         </body>
       </method>