Bug 1279214 - Use DOM instead of layout in HTMLComboboxAccessible::SelectedOption. r?surkov draft
authorEitan Isaacson <eitan@monotonous.org>
Thu, 30 Jun 2016 19:59:38 -0700
changeset 383033 d2a4891fbef64f60d4ac940cbbbbcd6d952a5ebf
parent 382798 82e1f1b9c0559f38a8460e2f2f3044de4c7712d6
child 383254 a21aaf39742da2ab21a11b0d14e196d45161a5ed
push id21908
push userbmo:eitan@monotonous.org
push dateFri, 01 Jul 2016 03:04:33 +0000
reviewerssurkov
bugs1279214
milestone50.0a1
Bug 1279214 - Use DOM instead of layout in HTMLComboboxAccessible::SelectedOption. r?surkov MozReview-Commit-ID: GrBSyR9bABT
accessible/html/HTMLSelectAccessible.cpp
--- 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;
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////