Bug 1279214 - Use DOM instead of layout in HTMLComboboxAccessible::SelectedOption. r?surkov
MozReview-Commit-ID: GrBSyR9bABT
--- a/accessible/html/HTMLSelectAccessible.cpp
+++ b/accessible/html/HTMLSelectAccessible.cpp
@@ -11,16 +11,17 @@
#include "DocAccessible.h"
#include "nsEventShell.h"
#include "nsTextEquivUtils.h"
#include "Role.h"
#include "States.h"
#include "nsCOMPtr.h"
#include "mozilla/dom/HTMLOptionElement.h"
+#include "mozilla/dom/HTMLSelectElement.h"
#include "nsIComboboxControlFrame.h"
#include "nsContainerFrame.h"
#include "nsIListControlFrame.h"
using namespace mozilla::a11y;
using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
@@ -493,29 +494,25 @@ HTMLComboboxAccessible::SetCurrentItem(A
}
////////////////////////////////////////////////////////////////////////////////
// HTMLComboboxAccessible: protected
Accessible*
HTMLComboboxAccessible::SelectedOption() const
{
- nsIFrame* frame = GetFrame();
- nsIComboboxControlFrame* comboboxFrame = do_QueryFrame(frame);
- if (!comboboxFrame)
- return nullptr;
+ HTMLSelectElement* select = HTMLSelectElement::FromContent(mContent);
+ int32_t selectedIndex = select->SelectedIndex();
- nsIListControlFrame* listControlFrame =
- do_QueryFrame(comboboxFrame->GetDropDown());
- if (listControlFrame) {
- nsCOMPtr<nsIContent> activeOptionNode = listControlFrame->GetCurrentOption();
- if (activeOptionNode) {
+ if (selectedIndex >= 0) {
+ HTMLOptionElement* option = select->Item(selectedIndex);
+ if (option) {
DocAccessible* document = Document();
if (document)
- return document->GetAccessible(activeOptionNode);
+ return document->GetAccessible(option);
}
}
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////