Bug 1492326, change methods of nsIDOMXUL* interfaces so that they return Elements to reduce usages as most callers want the return values as elements, r=peterv
authorNeil Deakin <neil@mozilla.com>
Tue, 04 Dec 2018 11:25:41 -0500
changeset 449717 8e8ca5becf683f32102d3dfe3429599e70542fae
parent 449716 1bb44497f6c0601c16de02b9595402ccc661b29a
child 449718 f69b2af6280a1a7c75b570cdc75c59d2be0a9b6a
push id35183
push usercbrindusan@mozilla.com
push dateMon, 10 Dec 2018 22:05:53 +0000
treeherdermozilla-central@13f891b92db1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1492326
milestone65.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 1492326, change methods of nsIDOMXUL* interfaces so that they return Elements to reduce usages as most callers want the return values as elements, r=peterv
accessible/base/nsAccUtils.cpp
accessible/xul/XULComboboxAccessible.cpp
accessible/xul/XULListboxAccessible.cpp
accessible/xul/XULSelectControlAccessible.cpp
dom/interfaces/xul/nsIDOMXULContainerElement.idl
dom/interfaces/xul/nsIDOMXULMultSelectCntrlEl.idl
dom/interfaces/xul/nsIDOMXULSelectCntrlEl.idl
dom/interfaces/xul/nsIDOMXULSelectCntrlItemEl.idl
dom/xul/nsXULElement.cpp
layout/base/PresShell.cpp
layout/xul/nsMenuPopupFrame.cpp
--- a/accessible/base/nsAccUtils.cpp
+++ b/accessible/base/nsAccUtils.cpp
@@ -90,28 +90,29 @@ int32_t nsAccUtils::GetARIAOrDefaultLeve
 
   return GetDefaultLevel(aAccessible);
 }
 
 int32_t nsAccUtils::GetLevelForXULContainerItem(nsIContent* aContent) {
   nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aContent));
   if (!item) return 0;
 
-  nsCOMPtr<nsIDOMXULContainerElement> container;
-  item->GetParentContainer(getter_AddRefs(container));
+  nsCOMPtr<Element> containerElement;
+  item->GetParentContainer(getter_AddRefs(containerElement));
+  nsCOMPtr<nsIDOMXULContainerElement> container =
+      do_QueryInterface(containerElement);
   if (!container) return 0;
 
   // Get level of the item.
   int32_t level = -1;
   while (container) {
     level++;
 
-    nsCOMPtr<nsIDOMXULContainerElement> parentContainer;
-    container->GetParentContainer(getter_AddRefs(parentContainer));
-    parentContainer.swap(container);
+    container->GetParentContainer(getter_AddRefs(containerElement));
+    container = do_QueryInterface(containerElement);
   }
 
   return level;
 }
 
 void nsAccUtils::SetLiveContainerAttributes(
     nsIPersistentProperties* aAttributes, nsIContent* aStartContent,
     dom::Element* aTopEl) {
--- a/accessible/xul/XULComboboxAccessible.cpp
+++ b/accessible/xul/XULComboboxAccessible.cpp
@@ -68,22 +68,20 @@ uint64_t XULComboboxAccessible::NativeSt
 }
 
 void XULComboboxAccessible::Description(nsString& aDescription) {
   aDescription.Truncate();
   // Use description of currently focused option
   nsCOMPtr<nsIDOMXULMenuListElement> menuListElm(do_QueryInterface(mContent));
   if (!menuListElm) return;
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> focusedOptionItem;
+  nsCOMPtr<Element> focusedOptionItem;
   menuListElm->GetSelectedItem(getter_AddRefs(focusedOptionItem));
-  nsCOMPtr<nsIContent> focusedOptionContent =
-      do_QueryInterface(focusedOptionItem);
-  if (focusedOptionContent && mDoc) {
-    Accessible* focusedOptionAcc = mDoc->GetAccessible(focusedOptionContent);
+  if (focusedOptionItem && mDoc) {
+    Accessible* focusedOptionAcc = mDoc->GetAccessible(focusedOptionItem);
     if (focusedOptionAcc) focusedOptionAcc->Description(aDescription);
   }
 }
 
 void XULComboboxAccessible::Value(nsString& aValue) const {
   aValue.Truncate();
 
   // The value is the option or text shown entered in the combobox.
--- a/accessible/xul/XULListboxAccessible.cpp
+++ b/accessible/xul/XULListboxAccessible.cpp
@@ -103,18 +103,21 @@ uint64_t XULListboxAccessible::NativeSta
 /**
  * Our value is the label of our ( first ) selected child.
  */
 void XULListboxAccessible::Value(nsString& aValue) const {
   aValue.Truncate();
 
   nsCOMPtr<nsIDOMXULSelectControlElement> select(do_QueryInterface(mContent));
   if (select) {
-    nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem;
-    select->GetSelectedItem(getter_AddRefs(selectedItem));
+    RefPtr<Element> element;
+    select->GetSelectedItem(getter_AddRefs(element));
+
+    nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem =
+        do_QueryInterface(element);
     if (selectedItem) selectedItem->GetLabel(aValue);
   }
 }
 
 role XULListboxAccessible::NativeRole() const {
   // A richlistbox is used with the new autocomplete URL bar, and has a parent
   // popup <panel>.
   if (mContent->GetParent() &&
@@ -138,24 +141,21 @@ uint32_t XULListboxAccessible::RowCount(
   return itemCount;
 }
 
 Accessible* XULListboxAccessible::CellAt(uint32_t aRowIndex,
                                          uint32_t aColumnIndex) {
   nsCOMPtr<nsIDOMXULSelectControlElement> control = do_QueryInterface(mContent);
   NS_ENSURE_TRUE(control, nullptr);
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
-  control->GetItemAtIndex(aRowIndex, getter_AddRefs(item));
-  if (!item) return nullptr;
+  RefPtr<Element> element;
+  control->GetItemAtIndex(aRowIndex, getter_AddRefs(element));
+  if (!element) return nullptr;
 
-  nsCOMPtr<nsIContent> itemContent(do_QueryInterface(item));
-  if (!itemContent) return nullptr;
-
-  Accessible* row = mDoc->GetAccessible(itemContent);
+  Accessible* row = mDoc->GetAccessible(element);
   NS_ENSURE_TRUE(row, nullptr);
 
   return row->GetChildAt(aColumnIndex);
 }
 
 bool XULListboxAccessible::IsColSelected(uint32_t aColIdx) {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
       do_QueryInterface(mContent);
@@ -168,20 +168,22 @@ bool XULListboxAccessible::IsColSelected
 
   return selectedrowCount == static_cast<int32_t>(RowCount());
 }
 
 bool XULListboxAccessible::IsRowSelected(uint32_t aRowIdx) {
   nsCOMPtr<nsIDOMXULSelectControlElement> control = do_QueryInterface(mContent);
   NS_ASSERTION(control, "Doesn't implement nsIDOMXULSelectControlElement.");
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
-  nsresult rv = control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
+  RefPtr<Element> element;
+  nsresult rv = control->GetItemAtIndex(aRowIdx, getter_AddRefs(element));
   NS_ENSURE_SUCCESS(rv, false);
 
+  nsCOMPtr<nsIDOMXULSelectControlItemElement> item = do_QueryInterface(element);
+
   bool isSelected = false;
   item->GetSelected(&isSelected);
   return isSelected;
 }
 
 bool XULListboxAccessible::IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) {
   return IsRowSelected(aRowIdx);
 }
@@ -327,30 +329,34 @@ void XULListboxAccessible::SelectedRowIn
 }
 
 void XULListboxAccessible::SelectRow(uint32_t aRowIdx) {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
       do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
+  RefPtr<Element> item;
   control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
-  control->SelectItem(item);
+
+  nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm = do_QueryInterface(item);
+  control->SelectItem(itemElm);
 }
 
 void XULListboxAccessible::UnselectRow(uint32_t aRowIdx) {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
       do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
+  RefPtr<Element> item;
   control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
-  control->RemoveItemFromSelection(item);
+
+  nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm = do_QueryInterface(item);
+  control->RemoveItemFromSelection(itemElm);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULListboxAccessible: Widgets
 
 bool XULListboxAccessible::IsWidget() const { return true; }
 
 bool XULListboxAccessible::IsActiveWidget() const {
@@ -421,23 +427,21 @@ XULListitemAccessible::~XULListitemAcces
 
 Accessible* XULListitemAccessible::GetListAccessible() const {
   if (IsDefunct()) return nullptr;
 
   nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
       do_QueryInterface(mContent);
   if (!listItem) return nullptr;
 
-  nsCOMPtr<nsIDOMXULSelectControlElement> list;
-  listItem->GetControl(getter_AddRefs(list));
+  RefPtr<Element> listElement;
+  listItem->GetControl(getter_AddRefs(listElement));
+  if (!listElement) return nullptr;
 
-  nsCOMPtr<nsIContent> listContent(do_QueryInterface(list));
-  if (!listContent) return nullptr;
-
-  return mDoc->GetAccessible(listContent);
+  return mDoc->GetAccessible(listElement);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULListitemAccessible Accessible
 
 void XULListitemAccessible::Description(nsString& aDesc) {
   AccessibleWrap::Description(aDesc);
 }
--- a/accessible/xul/XULSelectControlAccessible.cpp
+++ b/accessible/xul/XULSelectControlAccessible.cpp
@@ -46,45 +46,43 @@ void XULSelectControlAccessible::Shutdow
 void XULSelectControlAccessible::SelectedItems(nsTArray<Accessible*>* aItems) {
   // For XUL multi-select control
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> xulMultiSelect =
       do_QueryInterface(mSelectControl);
   if (xulMultiSelect) {
     int32_t length = 0;
     xulMultiSelect->GetSelectedCount(&length);
     for (int32_t index = 0; index < length; index++) {
-      nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm;
-      xulMultiSelect->MultiGetSelectedItem(index, getter_AddRefs(itemElm));
-      nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemElm));
-      Accessible* item = mDoc->GetAccessible(itemNode);
+      RefPtr<Element> element;
+      xulMultiSelect->MultiGetSelectedItem(index, getter_AddRefs(element));
+      Accessible* item = mDoc->GetAccessible(element);
       if (item) aItems->AppendElement(item);
     }
   } else {  // Single select?
-    nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm;
-    mSelectControl->GetSelectedItem(getter_AddRefs(itemElm));
-    nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemElm));
-    if (itemNode) {
-      Accessible* item = mDoc->GetAccessible(itemNode);
+    RefPtr<Element> element;
+    mSelectControl->GetSelectedItem(getter_AddRefs(element));
+    if (element) {
+      Accessible* item = mDoc->GetAccessible(element);
       if (item) aItems->AppendElement(item);
     }
   }
 }
 
 Accessible* XULSelectControlAccessible::GetSelectedItem(uint32_t aIndex) {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
       do_QueryInterface(mSelectControl);
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm;
-  if (multiSelectControl)
-    multiSelectControl->MultiGetSelectedItem(aIndex, getter_AddRefs(itemElm));
-  else if (aIndex == 0)
-    mSelectControl->GetSelectedItem(getter_AddRefs(itemElm));
+  RefPtr<Element> element;
+  if (multiSelectControl) {
+    multiSelectControl->MultiGetSelectedItem(aIndex, getter_AddRefs(element));
+  } else if (aIndex == 0) {
+    mSelectControl->GetSelectedItem(getter_AddRefs(element));
+  }
 
-  nsCOMPtr<nsINode> itemNode(do_QueryInterface(itemElm));
-  return itemNode && mDoc ? mDoc->GetAccessible(itemNode) : nullptr;
+  return element && mDoc ? mDoc->GetAccessible(element) : nullptr;
 }
 
 uint32_t XULSelectControlAccessible::SelectedItemCount() {
   // For XUL multi-select control
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
       do_QueryInterface(mSelectControl);
   if (multiSelectControl) {
     int32_t count = 0;
@@ -108,20 +106,21 @@ bool XULSelectControlAccessible::AddItem
 
   bool isItemSelected = false;
   itemElm->GetSelected(&isItemSelected);
   if (isItemSelected) return true;
 
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
       do_QueryInterface(mSelectControl);
 
-  if (multiSelectControl)
+  if (multiSelectControl) {
     multiSelectControl->AddItemToSelection(itemElm);
-  else
-    mSelectControl->SetSelectedItem(itemElm);
+  } else {
+    mSelectControl->SetSelectedItem(item->Elm());
+  }
 
   return true;
 }
 
 bool XULSelectControlAccessible::RemoveItemFromSelection(uint32_t aIndex) {
   Accessible* item = GetChildAt(aIndex);
   if (!item) return false;
 
@@ -179,39 +178,36 @@ bool XULSelectControlAccessible::SelectA
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULSelectControlAccessible: Widgets
 
 Accessible* XULSelectControlAccessible::CurrentItem() const {
   if (!mSelectControl) return nullptr;
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> currentItemElm;
+  RefPtr<Element> currentItemElm;
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
       do_QueryInterface(mSelectControl);
-  if (multiSelectControl)
+  if (multiSelectControl) {
     multiSelectControl->GetCurrentItem(getter_AddRefs(currentItemElm));
-  else
+  } else {
     mSelectControl->GetSelectedItem(getter_AddRefs(currentItemElm));
+  }
 
-  nsCOMPtr<nsINode> DOMNode;
-  if (currentItemElm) DOMNode = do_QueryInterface(currentItemElm);
-
-  if (DOMNode) {
+  if (currentItemElm) {
     DocAccessible* document = Document();
-    if (document) return document->GetAccessible(DOMNode);
+    if (document) return document->GetAccessible(currentItemElm);
   }
 
   return nullptr;
 }
 
 void XULSelectControlAccessible::SetCurrentItem(const Accessible* aItem) {
   if (!mSelectControl) return;
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
-      do_QueryInterface(aItem->GetContent());
+  nsCOMPtr<Element> itemElm = aItem->Elm();
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
       do_QueryInterface(mSelectControl);
   if (multiSelectControl)
     multiSelectControl->SetCurrentItem(itemElm);
   else
     mSelectControl->SetSelectedItem(itemElm);
 }
--- a/dom/interfaces/xul/nsIDOMXULContainerElement.idl
+++ b/dom/interfaces/xul/nsIDOMXULContainerElement.idl
@@ -1,22 +1,24 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "nsISupports.idl"
 interface nsIDOMXULContainerElement;
 
+webidl Element;
+
 [scriptable, uuid(800a68c7-b854-4597-a436-3055ce5c5c96)]
 interface nsIDOMXULContainerItemElement : nsISupports
 {
   /**
    * Returns the parent container if any.
    */
-  readonly attribute nsIDOMXULContainerElement parentContainer;
+  readonly attribute Element parentContainer;
 };
 
 [scriptable, uuid(b2bc96b8-31fc-42f4-937a-bd27291af40b)]
 interface nsIDOMXULContainerElement : nsIDOMXULContainerItemElement
 {
 };
 
--- a/dom/interfaces/xul/nsIDOMXULMultSelectCntrlEl.idl
+++ b/dom/interfaces/xul/nsIDOMXULMultSelectCntrlEl.idl
@@ -1,23 +1,24 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "nsIDOMXULSelectCntrlEl.idl"
 
+webidl Element;
 webidl NodeList;
 
 [scriptable, uuid(40654a10-8204-4f06-9f21-7baa31c7b1dd)]
 interface nsIDOMXULMultiSelectControlElement : nsIDOMXULSelectControlElement
 {
   attribute AString selType;
 
-  attribute nsIDOMXULSelectControlItemElement currentItem;
+  attribute Element currentItem;
   attribute long currentIndex;
 
   readonly attribute NodeList selectedItems;
   
   void addItemToSelection(in nsIDOMXULSelectControlItemElement item);
   void removeItemFromSelection(in nsIDOMXULSelectControlItemElement item);
   void toggleItemSelection(in nsIDOMXULSelectControlItemElement item);
 
@@ -27,10 +28,10 @@ interface nsIDOMXULMultiSelectControlEle
   void selectAll();
   void invertSelection();
   void clearSelection();
 
   // XXX - temporary, pending implementation of scriptable, 
   //       mutable NodeList for selectedItems
   readonly attribute long selectedCount;
   [binaryname(MultiGetSelectedItem)]
-  nsIDOMXULSelectControlItemElement getSelectedItem(in long index);
+  Element getSelectedItem(in long index);
 };
--- a/dom/interfaces/xul/nsIDOMXULSelectCntrlEl.idl
+++ b/dom/interfaces/xul/nsIDOMXULSelectCntrlEl.idl
@@ -1,20 +1,22 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "nsIDOMXULControlElement.idl"
 interface nsIDOMXULSelectControlItemElement;
 
+webidl Element;
+
 [scriptable, uuid(9bf188a7-d6f9-431b-b5c7-118013998e8b)]
 interface nsIDOMXULSelectControlElement : nsIDOMXULControlElement {
-  attribute nsIDOMXULSelectControlItemElement selectedItem;
+  attribute Element selectedItem;
   attribute long selectedIndex;
 
   attribute AString value;
 
   readonly attribute unsigned long itemCount;
   long getIndexOfItem(in nsIDOMXULSelectControlItemElement item);
-  nsIDOMXULSelectControlItemElement getItemAtIndex(in long index);
+  Element getItemAtIndex(in long index);
 };
 
--- a/dom/interfaces/xul/nsIDOMXULSelectCntrlItemEl.idl
+++ b/dom/interfaces/xul/nsIDOMXULSelectCntrlItemEl.idl
@@ -1,28 +1,30 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "nsISupports.idl"
 interface nsIDOMXULSelectControlElement;
 
+webidl Element;
+
 [scriptable, uuid(5c6be58f-17df-4750-88a5-4a59ac28adc9)]
 interface nsIDOMXULSelectControlItemElement : nsISupports {
   attribute boolean disabled;
   attribute AString crop;
   attribute AString image;
   attribute AString label;
   attribute AString accessKey;
   attribute AString command;
   
   attribute AString value;
   
   readonly attribute boolean selected;
   
-  readonly attribute nsIDOMXULSelectControlElement control;
+  readonly attribute Element control;
   
   // XXX defined in XULElement, but should be defined here
   // void doCommand();
 };
 
 
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -544,19 +544,17 @@ bool nsXULElement::PerformAccesskey(bool
         // for radio buttons, focus the radiogroup instead
         if (content->IsXULElement(nsGkAtoms::radio)) {
           nsCOMPtr<nsIDOMXULSelectControlItemElement> controlItem(
               do_QueryInterface(content));
           if (controlItem) {
             bool disabled;
             controlItem->GetDisabled(&disabled);
             if (!disabled) {
-              nsCOMPtr<nsIDOMXULSelectControlElement> selectControl;
-              controlItem->GetControl(getter_AddRefs(selectControl));
-              elementToFocus = do_QueryInterface(selectControl);
+              controlItem->GetControl(getter_AddRefs(elementToFocus));
             }
           }
         } else {
           elementToFocus = content;
         }
         if (elementToFocus) {
           fm->SetFocus(elementToFocus, nsIFocusManager::FLAG_BYKEY);
 
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -7892,17 +7892,17 @@ void PresShell::GetCurrentItemAndPositio
   bool istree = false, checkLineHeight = true;
   nscoord extraTreeY = 0;
 
 #ifdef MOZ_XUL
   // Set the position to just underneath the current item for multi-select
   // lists or just underneath the selected item for single-select lists. If
   // the element is not a list, or there is no selection, leave the position
   // as is.
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
+  nsCOMPtr<Element> item;
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect =
       do_QueryInterface(aFocusedElement);
   if (multiSelect) {
     checkLineHeight = false;
 
     int32_t currentIndex;
     multiSelect->GetCurrentIndex(&currentIndex);
     if (currentIndex >= 0) {
@@ -7952,17 +7952,19 @@ void PresShell::GetCurrentItemAndPositio
           do_QueryInterface(aFocusedElement);
       if (select) {
         checkLineHeight = false;
         select->GetSelectedItem(getter_AddRefs(item));
       }
     }
   }
 
-  if (item) focusedContent = do_QueryInterface(item);
+  if (item) {
+    focusedContent = item;
+  }
 #endif
 
   nsIFrame* frame = focusedContent->GetPrimaryFrame();
   if (frame) {
     NS_ASSERTION(
         frame->PresContext() == GetPresContext(),
         "handling event for focused content that is not in our document?");
 
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -1112,20 +1112,18 @@ nsIFrame* nsMenuPopupFrame::GetSelectedI
   if (!select) {
     // If there isn't an anchor, then try just getting the parent of the popup.
     select = do_QueryInterface(mContent->GetParent());
     if (!select) {
       return nullptr;
     }
   }
 
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
-  select->GetSelectedItem(getter_AddRefs(item));
-
-  nsCOMPtr<nsIContent> selectedElement = do_QueryInterface(item);
+  nsCOMPtr<Element> selectedElement;
+  select->GetSelectedItem(getter_AddRefs(selectedElement));
   return selectedElement ? selectedElement->GetPrimaryFrame() : nullptr;
 }
 
 nscoord nsMenuPopupFrame::SlideOrResize(nscoord& aScreenPoint, nscoord aSize,
                                         nscoord aScreenBegin,
                                         nscoord aScreenEnd, nscoord* aOffset) {
   // The popup may be positioned such that either the left/top or bottom/right
   // is outside the screen - but never both.