Bug 1521853 - Remove Throws annotation from some infallible HTMLOptionsCollection/HTMLSelectElement properties. r=qdot
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 22 Jan 2019 19:03:07 +0000
changeset 514857 e73aadc3a039337689f63caedf78e7c31cacda0a
parent 514856 5b00d3ce8cc6f72badc02588c6d85469ccd15600
child 514858 a28a76c23e86c7b3e59bf5dc44c5f04f730c3928
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1521853
milestone66.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 1521853 - Remove Throws annotation from some infallible HTMLOptionsCollection/HTMLSelectElement properties. r=qdot Differential Revision: https://phabricator.services.mozilla.com/D17265
dom/html/HTMLOptionsCollection.cpp
dom/html/HTMLOptionsCollection.h
dom/html/HTMLSelectElement.cpp
dom/html/HTMLSelectElement.h
dom/webidl/HTMLOptionsCollection.webidl
dom/webidl/HTMLSelectElement.webidl
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsComboboxControlFrame.h
layout/forms/nsISelectControlFrame.h
layout/forms/nsListControlFrame.cpp
layout/forms/nsListControlFrame.h
--- a/dom/html/HTMLOptionsCollection.cpp
+++ b/dom/html/HTMLOptionsCollection.cpp
@@ -128,23 +128,22 @@ void HTMLOptionsCollection::IndexedSette
   nsCOMPtr<nsINode> parent = refChild->GetParent();
   if (!parent) {
     return;
   }
 
   parent->ReplaceChild(*aOption, *refChild, aError);
 }
 
-int32_t HTMLOptionsCollection::GetSelectedIndex(ErrorResult& aError) {
+int32_t HTMLOptionsCollection::SelectedIndex() {
   return mSelect->SelectedIndex();
 }
 
-void HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex,
-                                             ErrorResult& aError) {
-  mSelect->SetSelectedIndex(aSelectedIndex, aError);
+void HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex) {
+  mSelect->SetSelectedIndex(aSelectedIndex);
 }
 
 Element* HTMLOptionsCollection::GetElementAt(uint32_t aIndex) {
   return ItemAsOption(aIndex);
 }
 
 HTMLOptionElement* HTMLOptionsCollection::NamedGetter(const nsAString& aName,
                                                       bool& aFound) {
@@ -201,14 +200,12 @@ void HTMLOptionsCollection::GetSupported
 }
 
 void HTMLOptionsCollection::Add(const HTMLOptionOrOptGroupElement& aElement,
                                 const Nullable<HTMLElementOrLong>& aBefore,
                                 ErrorResult& aError) {
   mSelect->Add(aElement, aBefore, aError);
 }
 
-void HTMLOptionsCollection::Remove(int32_t aIndex, ErrorResult& aError) {
-  mSelect->Remove(aIndex);
-}
+void HTMLOptionsCollection::Remove(int32_t aIndex) { mSelect->Remove(aIndex); }
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/html/HTMLOptionsCollection.h
+++ b/dom/html/HTMLOptionsCollection.h
@@ -122,19 +122,19 @@ class HTMLOptionsCollection final : publ
   }
   HTMLOptionElement* NamedGetter(const nsAString& aName, bool& aFound);
   virtual Element* GetFirstNamedElement(const nsAString& aName,
                                         bool& aFound) override {
     return NamedGetter(aName, aFound);
   }
   void Add(const HTMLOptionOrOptGroupElement& aElement,
            const Nullable<HTMLElementOrLong>& aBefore, ErrorResult& aError);
-  void Remove(int32_t aIndex, ErrorResult& aError);
-  int32_t GetSelectedIndex(ErrorResult& aError);
-  void SetSelectedIndex(int32_t aSelectedIndex, ErrorResult& aError);
+  void Remove(int32_t aIndex);
+  int32_t SelectedIndex();
+  void SetSelectedIndex(int32_t aSelectedIndex);
   void IndexedSetter(uint32_t aIndex, HTMLOptionElement* aOption,
                      ErrorResult& aError);
   virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
   void SetLength(uint32_t aLength, ErrorResult& aError);
 
  private:
   /** The list of options (holds strong references).  This is infallible, so
    * various members such as InsertOptionAt are also infallible. */
--- a/dom/html/HTMLSelectElement.cpp
+++ b/dom/html/HTMLSelectElement.cpp
@@ -617,35 +617,31 @@ bool HTMLSelectElement::MatchSelectedOpt
 nsIHTMLCollection* HTMLSelectElement::SelectedOptions() {
   if (!mSelectedOptions) {
     mSelectedOptions = new nsContentList(this, MatchSelectedOptions, nullptr,
                                          nullptr, /* deep */ true);
   }
   return mSelectedOptions;
 }
 
-nsresult HTMLSelectElement::SetSelectedIndexInternal(int32_t aIndex,
-                                                     bool aNotify) {
+void HTMLSelectElement::SetSelectedIndexInternal(int32_t aIndex, bool aNotify) {
   int32_t oldSelectedIndex = mSelectedIndex;
   uint32_t mask = IS_SELECTED | CLEAR_ALL | SET_DISABLED;
   if (aNotify) {
     mask |= NOTIFY;
   }
 
   SetOptionsSelectedByIndex(aIndex, aIndex, mask);
 
-  nsresult rv = NS_OK;
   nsISelectControlFrame* selectFrame = GetSelectFrame();
   if (selectFrame) {
-    rv = selectFrame->OnSetSelectedIndex(oldSelectedIndex, mSelectedIndex);
+    selectFrame->OnSetSelectedIndex(oldSelectedIndex, mSelectedIndex);
   }
 
   SetSelectionChanged(true, aNotify);
-
-  return rv;
 }
 
 bool HTMLSelectElement::IsOptionSelectedByIndex(int32_t aIndex) {
   HTMLOptionElement* option = Item(static_cast<uint32_t>(aIndex));
   return option && option->Selected();
 }
 
 void HTMLSelectElement::OnOptionSelected(nsISelectControlFrame* aSelectFrame,
@@ -990,18 +986,17 @@ bool HTMLSelectElement::SelectSomething(
   }
 
   uint32_t count = Length();
   for (uint32_t i = 0; i < count; i++) {
     bool disabled;
     nsresult rv = IsOptionDisabled(i, &disabled);
 
     if (NS_FAILED(rv) || !disabled) {
-      rv = SetSelectedIndexInternal(i, aNotify);
-      NS_ENSURE_SUCCESS(rv, false);
+      SetSelectedIndexInternal(i, aNotify);
 
       UpdateValueMissingValidityState();
       UpdateState(aNotify);
 
       return true;
     }
   }
 
--- a/dom/html/HTMLSelectElement.h
+++ b/dom/html/HTMLSelectElement.h
@@ -175,19 +175,17 @@ class HTMLSelectElement final : public n
     mOptions->IndexedSetter(aIndex, aOption, aRv);
   }
 
   static bool MatchSelectedOptions(Element* aElement, int32_t, nsAtom*, void*);
 
   nsIHTMLCollection* SelectedOptions();
 
   int32_t SelectedIndex() const { return mSelectedIndex; }
-  void SetSelectedIndex(int32_t aIdx, ErrorResult& aRv) {
-    aRv = SetSelectedIndexInternal(aIdx, true);
-  }
+  void SetSelectedIndex(int32_t aIdx) { SetSelectedIndexInternal(aIdx, true); }
   void GetValue(DOMString& aValue);
   void SetValue(const nsAString& aValue);
 
   // Override SetCustomValidity so we update our state properly when it's called
   // via bindings.
   void SetCustomValidity(const nsAString& aError);
 
   using nsINode::Remove;
@@ -449,17 +447,17 @@ class HTMLSelectElement final : public n
    * Rebuilds the options array from scratch as a fallback in error cases.
    */
   void RebuildOptionsArray(bool aNotify);
 
 #ifdef DEBUG
   void VerifyOptionsArray();
 #endif
 
-  nsresult SetSelectedIndexInternal(int32_t aIndex, bool aNotify);
+  void SetSelectedIndexInternal(int32_t aIndex, bool aNotify);
 
   void SetSelectionChanged(bool aValue, bool aNotify);
 
   /**
    * Marks the selectedOptions list as dirty, so that it'll populate itself
    * again.
    */
   void UpdateSelectedOptions();
--- a/dom/webidl/HTMLOptionsCollection.webidl
+++ b/dom/webidl/HTMLOptionsCollection.webidl
@@ -12,13 +12,12 @@
 
 interface HTMLOptionsCollection : HTMLCollection {
   [CEReactions, SetterThrows]
   attribute unsigned long length;
   [CEReactions, Throws]
   setter void (unsigned long index, HTMLOptionElement? option);
   [CEReactions, Throws]
   void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
-  [CEReactions, Throws]
+  [CEReactions]
   void remove(long index);
-  [Throws]
   attribute long selectedIndex;
 };
--- a/dom/webidl/HTMLSelectElement.webidl
+++ b/dom/webidl/HTMLSelectElement.webidl
@@ -38,17 +38,17 @@ interface HTMLSelectElement : HTMLElemen
   [CEReactions, Throws]
   void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
   [CEReactions]
   void remove(long index);
   [CEReactions, Throws]
   setter void (unsigned long index, HTMLOptionElement? option);
 
   readonly attribute HTMLCollection selectedOptions;
-  [SetterThrows, Pure]
+  [Pure]
   attribute long selectedIndex;
   [Pure]
   attribute DOMString value;
 
   readonly attribute boolean willValidate;
   readonly attribute ValidityState validity;
   [Throws]
   readonly attribute DOMString validationMessage;
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1042,17 +1042,17 @@ nsComboboxControlFrame::RemoveOption(int
   }
 
   if (!weakThis.IsAlive()) return NS_OK;
 
   nsListControlFrame* lcf = static_cast<nsListControlFrame*>(mDropdownFrame);
   return lcf->RemoveOption(aIndex);
 }
 
-NS_IMETHODIMP
+NS_IMETHODIMP_(void)
 nsComboboxControlFrame::OnSetSelectedIndex(int32_t aOldIndex,
                                            int32_t aNewIndex) {
   nsAutoScriptBlocker scriptBlocker;
   mDisplayedIndex = aNewIndex;
   RedisplayText();
   NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
 
   nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame);
--- a/layout/forms/nsComboboxControlFrame.h
+++ b/layout/forms/nsComboboxControlFrame.h
@@ -168,17 +168,18 @@ class nsComboboxControlFrame final : pub
     return IsDroppedDown() || IsOpenInParentProcess();
   }
 
   // nsISelectControlFrame
   NS_IMETHOD AddOption(int32_t index) override;
   NS_IMETHOD RemoveOption(int32_t index) override;
   NS_IMETHOD DoneAddingChildren(bool aIsDone) override;
   NS_IMETHOD OnOptionSelected(int32_t aIndex, bool aSelected) override;
-  NS_IMETHOD OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) override;
+  NS_IMETHOD_(void)
+  OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) override;
 
   // nsIRollupListener
   /**
    * Hide the dropdown menu and stop capturing mouse events.
    * @note This method might destroy |this|.
    */
   virtual bool Rollup(uint32_t aCount, bool aFlush, const nsIntPoint* pos,
                       nsIContent** aLastRolledUp) override;
--- a/layout/forms/nsISelectControlFrame.h
+++ b/layout/forms/nsISelectControlFrame.h
@@ -38,12 +38,13 @@ class nsISelectControlFrame : public nsQ
    * Notify the frame when an option is selected
    */
   NS_IMETHOD OnOptionSelected(int32_t aIndex, bool aSelected) = 0;
 
   /**
    * Notify the frame when selectedIndex was changed.  This might
    * destroy the frame.
    */
-  NS_IMETHOD OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) = 0;
+  NS_IMETHOD_(void)
+  OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) = 0;
 };
 
 #endif
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -1291,38 +1291,36 @@ void nsListControlFrame::FireOnInputAndO
                        "Failed to dispatch input event");
 
   // Dispatch the change event.
   nsContentUtils::DispatchTrustedEvent(element->OwnerDoc(), element,
                                        NS_LITERAL_STRING("change"),
                                        CanBubble::eYes, Cancelable::eNo);
 }
 
-NS_IMETHODIMP
+NS_IMETHODIMP_(void)
 nsListControlFrame::OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) {
   if (mComboboxFrame) {
     // UpdateRecentIndex with NS_SKIP_NOTIFY_INDEX, so that we won't fire an
     // onchange event for this setting of selectedIndex.
     mComboboxFrame->UpdateRecentIndex(NS_SKIP_NOTIFY_INDEX);
   }
 
   AutoWeakFrame weakFrame(this);
   ScrollToIndex(aNewIndex);
   if (!weakFrame.IsAlive()) {
-    return NS_OK;
+    return;
   }
   mStartSelectionIndex = aNewIndex;
   mEndSelectionIndex = aNewIndex;
   InvalidateFocus();
 
 #ifdef ACCESSIBILITY
   FireMenuItemActiveEvent();
 #endif
-
-  return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // End nsISelectControlFrame
 //----------------------------------------------------------------------
 
 nsresult nsListControlFrame::SetFormProperty(nsAtom* aName,
                                              const nsAString& aValue) {
--- a/layout/forms/nsListControlFrame.h
+++ b/layout/forms/nsListControlFrame.h
@@ -147,17 +147,18 @@ class nsListControlFrame final : public 
   NS_IMETHOD RemoveOption(int32_t index) override;
   NS_IMETHOD DoneAddingChildren(bool aIsDone) override;
 
   /**
    * Gets the content (an option) by index and then set it as
    * being selected or not selected.
    */
   NS_IMETHOD OnOptionSelected(int32_t aIndex, bool aSelected) override;
-  NS_IMETHOD OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) override;
+  NS_IMETHOD_(void)
+  OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) override;
 
   /**
    * Mouse event listeners.
    * @note These methods might destroy the frame, pres shell and other objects.
    */
   nsresult MouseDown(mozilla::dom::Event* aMouseEvent);
   MOZ_CAN_RUN_SCRIPT
   nsresult MouseUp(mozilla::dom::Event* aMouseEvent);