bug 767843 - stop using nsIDOMHTMLOptionElement in a11y r=surkov
authorTrevor Saunders <trev.saunders@gmail.com>
Sat, 02 Jun 2012 15:41:29 -0400
changeset 103803 b3ad8edbd748f0e3ba2a0c081852e6d2ee706f2a
parent 103802 94dc6f0b5f8b83c12abaf22a1dedd872e3ef4a5d
child 103804 ca08bbcd7dc496b21d34f7d8f8156289518f2ca2
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerssurkov
bugs767843
milestone18.0a1
bug 767843 - stop using nsIDOMHTMLOptionElement in a11y r=surkov
accessible/src/html/HTMLSelectAccessible.cpp
accessible/src/html/HTMLSelectAccessible.h
--- a/accessible/src/html/HTMLSelectAccessible.cpp
+++ b/accessible/src/html/HTMLSelectAccessible.cpp
@@ -11,25 +11,20 @@
 #include "DocAccessible.h"
 #include "nsEventShell.h"
 #include "nsIAccessibleEvent.h"
 #include "nsTextEquivUtils.h"
 #include "Role.h"
 #include "States.h"
 
 #include "nsCOMPtr.h"
-#include "nsIFrame.h"
+#include "nsHTMLOptionElement.h"
 #include "nsIComboboxControlFrame.h"
-#include "nsIDocument.h"
-#include "nsIDOMHTMLInputElement.h"
-#include "nsIDOMHTMLOptGroupElement.h"
-#include "nsIDOMHTMLSelectElement.h"
+#include "nsIFrame.h"
 #include "nsIListControlFrame.h"
-#include "nsIServiceManager.h"
-#include "nsIMutableArray.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLSelectListAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 HTMLSelectListAccessible::
@@ -233,40 +228,34 @@ HTMLSelectOptionAccessible::NativeState(
   if (!select)
     return state;
 
   uint64_t selectState = select->State();
   if (selectState & states::INVISIBLE)
     return state;
 
   // Are we selected?
-  bool isSelected = false;
-  nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(mContent));
-  if (option) {
-    option->GetSelected(&isSelected);
-    if (isSelected)
-      state |= states::SELECTED;
-  }
+  nsHTMLOptionElement* option = nsHTMLOptionElement::FromContent(mContent);
+  bool selected = option && option->Selected();
+  if (selected)
+    state |= states::SELECTED;
 
   if (selectState & states::OFFSCREEN) {
     state |= states::OFFSCREEN;
-  }
-  else if (selectState & states::COLLAPSED) {
+  } else if (selectState & states::COLLAPSED) {
     // <select> is COLLAPSED: add OFFSCREEN, if not the currently
     // visible option
-    if (!isSelected) {
+    if (!selected) {
       state |= states::OFFSCREEN;
-    }
-    else {
+    } else {
       // Clear offscreen and invisible for currently showing option
       state &= ~(states::OFFSCREEN | states::INVISIBLE);
       state |= selectState & states::OPAQUE1;
     }
-  }
-  else {
+  } else {
     // XXX list frames are weird, don't rely on Accessible's general
     // visibility implementation unless they get reimplemented in layout
     state &= ~states::OFFSCREEN;
     // <select> is not collapsed: compare bounds to calculate OFFSCREEN
     Accessible* listAcc = Parent();
     if (listAcc) {
       int32_t optionX, optionY, optionWidth, optionHeight;
       int32_t listX, listY, listWidth, listHeight;
@@ -343,18 +332,18 @@ HTMLSelectOptionAccessible::DoAction(uin
 }
 
 NS_IMETHODIMP
 HTMLSelectOptionAccessible::SetSelected(bool aSelect)
 {
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIDOMHTMLOptionElement> optionElm(do_QueryInterface(mContent));
-  return optionElm->SetSelected(aSelect);
+  nsHTMLOptionElement* option = nsHTMLOptionElement::FromContent(mContent);
+  return option ? option->SetSelected(aSelect) : NS_ERROR_FAILURE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLSelectOptionAccessible: Widgets
 
 Accessible*
 HTMLSelectOptionAccessible::ContainerWidget() const
 {
--- a/accessible/src/html/HTMLSelectAccessible.h
+++ b/accessible/src/html/HTMLSelectAccessible.h
@@ -2,19 +2,16 @@
 /* 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/. */
 
 #ifndef mozilla_a11y_HTMLSelectAccessible_h__
 #define mozilla_a11y_HTMLSelectAccessible_h__
 
 #include "HTMLFormControlAccessible.h"
-#include "nsIDOMHTMLOptionsCollection.h"
-#include "nsIDOMHTMLOptionElement.h"
-#include "nsIDOMNode.h"
 
 class nsIMutableArray;
 
 namespace mozilla {
 namespace a11y {
 
 /**
   *  Selects, Listboxes and Comboboxes, are made up of a number of different