diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp
index 4c75c303e4c..10ebb25c76a 100644
--- a/accessible/src/html/nsHTMLSelectAccessible.cpp
+++ b/accessible/src/html/nsHTMLSelectAccessible.cpp
@@ -265,9 +265,12 @@ nsHTMLSelectOptionAccessible::NativeState()
// because we don't want EDITABLE or SELECTABLE_TEXT
PRUint64 state = nsAccessible::NativeState();
- PRUint64 selectState = 0;
- nsIContent* selectContent = GetSelectState(&selectState);
- if (!selectContent || selectState & states::INVISIBLE)
+ nsAccessible* select = GetSelect();
+ if (!select)
+ return state;
+
+ PRUint64 selectState = select->State();
+ if (selectState & states::INVISIBLE)
return state;
// Focusable and selectable
@@ -391,30 +394,6 @@ nsHTMLSelectOptionAccessible::ContainerWidget() const
return mParent && mParent->IsListControl() ? mParent : nsnull;
}
-////////////////////////////////////////////////////////////////////////////////
-// nsHTMLSelectOptionAccessible: private methods
-
-nsIContent*
-nsHTMLSelectOptionAccessible::GetSelectState(PRUint64* aState)
-{
- *aState = 0;
-
- nsIContent* selectNode = mContent;
- while (selectNode && selectNode->Tag() != nsGkAtoms::select) {
- selectNode = selectNode->GetParent();
- }
-
- if (selectNode) {
- nsAccessible* select = mDoc->GetAccessible(selectNode);
- if (select) {
- *aState = select->State();
- return selectNode;
- }
- }
- return nsnull;
-}
-
-
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectOptGroupAccessible
////////////////////////////////////////////////////////////////////////////////
diff --git a/accessible/src/html/nsHTMLSelectAccessible.h b/accessible/src/html/nsHTMLSelectAccessible.h
index 52cbea41973..f8cb73e1be6 100644
--- a/accessible/src/html/nsHTMLSelectAccessible.h
+++ b/accessible/src/html/nsHTMLSelectAccessible.h
@@ -133,11 +133,17 @@ public:
private:
/**
- * Get Select element's accessible state
- * @param aState, Select element state
- * @return Select element content, returns null if not avaliable
+ * Return a select accessible the option belongs to if any.
*/
- nsIContent* GetSelectState(PRUint64* aState);
+ nsAccessible* GetSelect() const
+ {
+ if (mParent && mParent->IsListControl()) {
+ nsAccessible* combobox = mParent->Parent();
+ return combobox && combobox->IsCombobox() ? combobox : mParent;
+ }
+
+ return nsnull;
+ }
/**
* Return a combobox accessible the option belongs to if any.
@@ -146,7 +152,7 @@ private:
{
if (mParent && mParent->IsListControl()) {
nsAccessible* combobox = mParent->Parent();
- return combobox->IsCombobox() ? combobox : nsnull;
+ return combobox && combobox->IsCombobox() ? combobox : nsnull;
}
return nsnull;