accessible/src/xul/XULFormControlAccessible.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/xul/XULFormControlAccessible.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,641 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "XULFormControlAccessible.h"
    1.10 +
    1.11 +#include "Accessible-inl.h"
    1.12 +#include "HTMLFormControlAccessible.h"
    1.13 +#include "nsAccUtils.h"
    1.14 +#include "nsCoreUtils.h"
    1.15 +#include "DocAccessible.h"
    1.16 +#include "nsIAccessibleRelation.h"
    1.17 +#include "Relation.h"
    1.18 +#include "Role.h"
    1.19 +#include "States.h"
    1.20 +#include "TreeWalker.h"
    1.21 +#include "XULMenuAccessible.h"
    1.22 +
    1.23 +#include "nsIDOMNSEditableElement.h"
    1.24 +#include "nsIDOMXULButtonElement.h"
    1.25 +#include "nsIDOMXULCheckboxElement.h"
    1.26 +#include "nsIDOMXULMenuListElement.h"
    1.27 +#include "nsIDOMXULSelectCntrlItemEl.h"
    1.28 +#include "nsIDOMXULTextboxElement.h"
    1.29 +#include "nsIEditor.h"
    1.30 +#include "nsIFrame.h"
    1.31 +#include "nsITextControlFrame.h"
    1.32 +#include "nsMenuPopupFrame.h"
    1.33 +#include "nsNameSpaceManager.h"
    1.34 +#include "mozilla/dom/Element.h"
    1.35 +
    1.36 +using namespace mozilla::a11y;
    1.37 +
    1.38 +////////////////////////////////////////////////////////////////////////////////
    1.39 +// XULButtonAccessible
    1.40 +////////////////////////////////////////////////////////////////////////////////
    1.41 +
    1.42 +XULButtonAccessible::
    1.43 +  XULButtonAccessible(nsIContent* aContent, DocAccessible* aDoc) :
    1.44 +  AccessibleWrap(aContent, aDoc)
    1.45 +{
    1.46 +  if (ContainsMenu()) {
    1.47 +    mGenericTypes |= eMenuButton;
    1.48 +  } else {
    1.49 +    mGenericTypes |= eButton;
    1.50 +  }
    1.51 +}
    1.52 +
    1.53 +////////////////////////////////////////////////////////////////////////////////
    1.54 +// XULButtonAccessible: nsISupports
    1.55 +
    1.56 +NS_IMPL_ISUPPORTS_INHERITED0(XULButtonAccessible, Accessible)
    1.57 +
    1.58 +////////////////////////////////////////////////////////////////////////////////
    1.59 +// XULButtonAccessible: nsIAccessible
    1.60 +
    1.61 +uint8_t
    1.62 +XULButtonAccessible::ActionCount()
    1.63 +{
    1.64 +  return 1;
    1.65 +}
    1.66 +
    1.67 +NS_IMETHODIMP
    1.68 +XULButtonAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
    1.69 +{
    1.70 +  if (aIndex == eAction_Click) {
    1.71 +    aName.AssignLiteral("press"); 
    1.72 +    return NS_OK;
    1.73 +  }
    1.74 +  return NS_ERROR_INVALID_ARG;
    1.75 +}
    1.76 +
    1.77 +NS_IMETHODIMP
    1.78 +XULButtonAccessible::DoAction(uint8_t aIndex)
    1.79 +{
    1.80 +  if (aIndex != 0)
    1.81 +    return NS_ERROR_INVALID_ARG;
    1.82 +
    1.83 +  DoCommand();
    1.84 +  return NS_OK;
    1.85 +}
    1.86 +
    1.87 +////////////////////////////////////////////////////////////////////////////////
    1.88 +// XULButtonAccessible: Accessible
    1.89 +
    1.90 +role
    1.91 +XULButtonAccessible::NativeRole()
    1.92 +{
    1.93 +  return roles::PUSHBUTTON;
    1.94 +}
    1.95 +
    1.96 +uint64_t
    1.97 +XULButtonAccessible::NativeState()
    1.98 +{
    1.99 +  // Possible states: focused, focusable, unavailable(disabled).
   1.100 +
   1.101 +  // get focus and disable status from base class
   1.102 +  uint64_t state = Accessible::NativeState();
   1.103 +
   1.104 +  // Buttons can be checked -- they simply appear pressed in rather than checked
   1.105 +  nsCOMPtr<nsIDOMXULButtonElement> xulButtonElement(do_QueryInterface(mContent));
   1.106 +  if (xulButtonElement) {
   1.107 +    nsAutoString type;
   1.108 +    xulButtonElement->GetType(type);
   1.109 +    if (type.EqualsLiteral("checkbox") || type.EqualsLiteral("radio")) {
   1.110 +      state |= states::CHECKABLE;
   1.111 +      bool checked = false;
   1.112 +      int32_t checkState = 0;
   1.113 +      xulButtonElement->GetChecked(&checked);
   1.114 +      if (checked) {
   1.115 +        state |= states::PRESSED;
   1.116 +        xulButtonElement->GetCheckState(&checkState);
   1.117 +        if (checkState == nsIDOMXULButtonElement::CHECKSTATE_MIXED) { 
   1.118 +          state |= states::MIXED;
   1.119 +        }
   1.120 +      }
   1.121 +    }
   1.122 +  }
   1.123 +
   1.124 +  if (ContainsMenu())
   1.125 +    state |= states::HASPOPUP;
   1.126 +
   1.127 +  if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::_default))
   1.128 +    state |= states::DEFAULT;
   1.129 +
   1.130 +  return state;
   1.131 +}
   1.132 +
   1.133 +////////////////////////////////////////////////////////////////////////////////
   1.134 +// XULButtonAccessible: Widgets
   1.135 +
   1.136 +bool
   1.137 +XULButtonAccessible::IsWidget() const
   1.138 +{
   1.139 +  return true;
   1.140 +}
   1.141 +
   1.142 +bool
   1.143 +XULButtonAccessible::IsActiveWidget() const
   1.144 +{
   1.145 +  return FocusMgr()->HasDOMFocus(mContent);
   1.146 +}
   1.147 +
   1.148 +bool
   1.149 +XULButtonAccessible::AreItemsOperable() const
   1.150 +{
   1.151 +  if (IsMenuButton()) {
   1.152 +    Accessible* menuPopup = mChildren.SafeElementAt(0, nullptr);
   1.153 +    if (menuPopup) {
   1.154 +      nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(menuPopup->GetFrame());
   1.155 +      return menuPopupFrame->IsOpen();
   1.156 +    }
   1.157 +  }
   1.158 +  return false; // no items
   1.159 +}
   1.160 +
   1.161 +Accessible*
   1.162 +XULButtonAccessible::ContainerWidget() const
   1.163 +{
   1.164 +  if (IsMenuButton() && mParent && mParent->IsAutoComplete())
   1.165 +    return mParent;
   1.166 +  return nullptr;
   1.167 +}
   1.168 +
   1.169 +bool
   1.170 +XULButtonAccessible::IsAcceptableChild(Accessible* aPossibleChild) const
   1.171 +{
   1.172 +  // In general XUL button has not accessible children. Nevertheless menu
   1.173 +  // buttons can have button (@type="menu-button") and popup accessibles
   1.174 +  // (@type="menu-button", @type="menu" or columnpicker.
   1.175 +
   1.176 +  // XXX: no children until the button is menu button. Probably it's not
   1.177 +  // totally correct but in general AT wants to have leaf buttons.
   1.178 +  roles::Role role = aPossibleChild->Role();
   1.179 +
   1.180 +  // Get an accessible for menupopup or panel elements.
   1.181 +  if (role == roles::MENUPOPUP)
   1.182 +    return true;
   1.183 +
   1.184 +  // Button type="menu-button" contains a real button. Get an accessible
   1.185 +  // for it. Ignore dropmarker button which is placed as a last child.
   1.186 +  if (role != roles::PUSHBUTTON ||
   1.187 +      aPossibleChild->GetContent()->Tag() == nsGkAtoms::dropMarker)
   1.188 +    return false;
   1.189 +
   1.190 +  return mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
   1.191 +                               nsGkAtoms::menuButton, eCaseMatters);
   1.192 +}
   1.193 +
   1.194 +////////////////////////////////////////////////////////////////////////////////
   1.195 +// XULButtonAccessible protected
   1.196 +
   1.197 +bool
   1.198 +XULButtonAccessible::ContainsMenu()
   1.199 +{
   1.200 +  static nsIContent::AttrValuesArray strings[] =
   1.201 +    {&nsGkAtoms::menu, &nsGkAtoms::menuButton, nullptr};
   1.202 +
   1.203 +  return mContent->FindAttrValueIn(kNameSpaceID_None,
   1.204 +                                   nsGkAtoms::type,
   1.205 +                                   strings, eCaseMatters) >= 0;
   1.206 +}
   1.207 +
   1.208 +////////////////////////////////////////////////////////////////////////////////
   1.209 +// XULDropmarkerAccessible
   1.210 +////////////////////////////////////////////////////////////////////////////////
   1.211 +
   1.212 +XULDropmarkerAccessible::
   1.213 +  XULDropmarkerAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.214 +  LeafAccessible(aContent, aDoc)
   1.215 +{
   1.216 +}
   1.217 +
   1.218 +uint8_t
   1.219 +XULDropmarkerAccessible::ActionCount()
   1.220 +{
   1.221 +  return 1;
   1.222 +}
   1.223 +
   1.224 +bool
   1.225 +XULDropmarkerAccessible::DropmarkerOpen(bool aToggleOpen)
   1.226 +{
   1.227 +  bool isOpen = false;
   1.228 +
   1.229 +  nsCOMPtr<nsIDOMXULButtonElement> parentButtonElement =
   1.230 +    do_QueryInterface(mContent->GetFlattenedTreeParent());
   1.231 +
   1.232 +  if (parentButtonElement) {
   1.233 +    parentButtonElement->GetOpen(&isOpen);
   1.234 +    if (aToggleOpen)
   1.235 +      parentButtonElement->SetOpen(!isOpen);
   1.236 +  }
   1.237 +  else {
   1.238 +    nsCOMPtr<nsIDOMXULMenuListElement> parentMenuListElement =
   1.239 +      do_QueryInterface(parentButtonElement);
   1.240 +    if (parentMenuListElement) {
   1.241 +      parentMenuListElement->GetOpen(&isOpen);
   1.242 +      if (aToggleOpen)
   1.243 +        parentMenuListElement->SetOpen(!isOpen);
   1.244 +    }
   1.245 +  }
   1.246 +
   1.247 +  return isOpen;
   1.248 +}
   1.249 +
   1.250 +/**
   1.251 +  * Return the name of our only action
   1.252 +  */
   1.253 +NS_IMETHODIMP
   1.254 +XULDropmarkerAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
   1.255 +{
   1.256 +  if (aIndex == eAction_Click) {
   1.257 +    if (DropmarkerOpen(false))
   1.258 +      aName.AssignLiteral("close");
   1.259 +    else
   1.260 +      aName.AssignLiteral("open");
   1.261 +    return NS_OK;
   1.262 +  }
   1.263 +
   1.264 +  return NS_ERROR_INVALID_ARG;
   1.265 +}
   1.266 +
   1.267 +/**
   1.268 +  * Tell the Dropmarker to do its action
   1.269 +  */
   1.270 +NS_IMETHODIMP
   1.271 +XULDropmarkerAccessible::DoAction(uint8_t index)
   1.272 +{
   1.273 +  if (index == eAction_Click) {
   1.274 +    DropmarkerOpen(true); // Reverse the open attribute
   1.275 +    return NS_OK;
   1.276 +  }
   1.277 +  return NS_ERROR_INVALID_ARG;
   1.278 +}
   1.279 +
   1.280 +role
   1.281 +XULDropmarkerAccessible::NativeRole()
   1.282 +{
   1.283 +  return roles::PUSHBUTTON;
   1.284 +}
   1.285 +
   1.286 +uint64_t
   1.287 +XULDropmarkerAccessible::NativeState()
   1.288 +{
   1.289 +  return DropmarkerOpen(false) ? states::PRESSED : 0;
   1.290 +}
   1.291 +
   1.292 +////////////////////////////////////////////////////////////////////////////////
   1.293 +// XULCheckboxAccessible
   1.294 +////////////////////////////////////////////////////////////////////////////////
   1.295 +
   1.296 +XULCheckboxAccessible::
   1.297 +  XULCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.298 +  LeafAccessible(aContent, aDoc)
   1.299 +{
   1.300 +}
   1.301 +
   1.302 +role
   1.303 +XULCheckboxAccessible::NativeRole()
   1.304 +{
   1.305 +  return roles::CHECKBUTTON;
   1.306 +}
   1.307 +
   1.308 +uint8_t
   1.309 +XULCheckboxAccessible::ActionCount()
   1.310 +{
   1.311 +  return 1;
   1.312 +}
   1.313 +
   1.314 +/**
   1.315 +  * Return the name of our only action
   1.316 +  */
   1.317 +NS_IMETHODIMP
   1.318 +XULCheckboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
   1.319 +{
   1.320 +  if (aIndex == eAction_Click) {
   1.321 +    // check or uncheck
   1.322 +
   1.323 +    if (NativeState() & states::CHECKED)
   1.324 +      aName.AssignLiteral("uncheck");
   1.325 +    else
   1.326 +      aName.AssignLiteral("check");
   1.327 +
   1.328 +    return NS_OK;
   1.329 +  }
   1.330 +  return NS_ERROR_INVALID_ARG;
   1.331 +}
   1.332 +
   1.333 +/**
   1.334 +  * Tell the checkbox to do its only action -- check( or uncheck) itself
   1.335 +  */
   1.336 +NS_IMETHODIMP
   1.337 +XULCheckboxAccessible::DoAction(uint8_t aIndex)
   1.338 +{
   1.339 +  if (aIndex != eAction_Click)
   1.340 +    return NS_ERROR_INVALID_ARG;
   1.341 +
   1.342 +  DoCommand();
   1.343 +  return NS_OK;
   1.344 +}
   1.345 +
   1.346 +uint64_t
   1.347 +XULCheckboxAccessible::NativeState()
   1.348 +{
   1.349 +  // Possible states: focused, focusable, unavailable(disabled), checked
   1.350 +  // Get focus and disable status from base class
   1.351 +  uint64_t state = LeafAccessible::NativeState();
   1.352 +  
   1.353 +  state |= states::CHECKABLE;
   1.354 +  
   1.355 +  // Determine Checked state
   1.356 +  nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement =
   1.357 +    do_QueryInterface(mContent);
   1.358 +  if (xulCheckboxElement) {
   1.359 +    bool checked = false;
   1.360 +    xulCheckboxElement->GetChecked(&checked);
   1.361 +    if (checked) {
   1.362 +      state |= states::CHECKED;
   1.363 +      int32_t checkState = 0;
   1.364 +      xulCheckboxElement->GetCheckState(&checkState);
   1.365 +      if (checkState == nsIDOMXULCheckboxElement::CHECKSTATE_MIXED)
   1.366 +        state |= states::MIXED;
   1.367 +    }
   1.368 +  }
   1.369 +
   1.370 +  return state;
   1.371 +}
   1.372 +
   1.373 +////////////////////////////////////////////////////////////////////////////////
   1.374 +// XULGroupboxAccessible
   1.375 +////////////////////////////////////////////////////////////////////////////////
   1.376 +
   1.377 +XULGroupboxAccessible::
   1.378 +  XULGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.379 +  AccessibleWrap(aContent, aDoc)
   1.380 +{
   1.381 +}
   1.382 +
   1.383 +role
   1.384 +XULGroupboxAccessible::NativeRole()
   1.385 +{
   1.386 +  return roles::GROUPING;
   1.387 +}
   1.388 +
   1.389 +ENameValueFlag
   1.390 +XULGroupboxAccessible::NativeName(nsString& aName)
   1.391 +{
   1.392 +  // XXX: we use the first related accessible only.
   1.393 +  Accessible* label =
   1.394 +    RelationByType(RelationType::LABELLED_BY).Next();
   1.395 +  if (label)
   1.396 +    return label->Name(aName);
   1.397 +
   1.398 +  return eNameOK;
   1.399 +}
   1.400 +
   1.401 +Relation
   1.402 +XULGroupboxAccessible::RelationByType(RelationType aType)
   1.403 +{
   1.404 +  Relation rel = AccessibleWrap::RelationByType(aType);
   1.405 +  if (aType != RelationType::LABELLED_BY)
   1.406 +    return rel;
   1.407 +
   1.408 +  // The label for xul:groupbox is generated from xul:label that is
   1.409 +  // inside the anonymous content of the xul:caption.
   1.410 +  // The xul:label has an accessible object but the xul:caption does not
   1.411 +  uint32_t childCount = ChildCount();
   1.412 +  for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
   1.413 +    Accessible* childAcc = GetChildAt(childIdx);
   1.414 +    if (childAcc->Role() == roles::LABEL) {
   1.415 +      // Ensure that it's our label
   1.416 +      Relation reverseRel = childAcc->RelationByType(RelationType::LABEL_FOR);
   1.417 +      Accessible* testGroupbox = nullptr;
   1.418 +      while ((testGroupbox = reverseRel.Next()))
   1.419 +        if (testGroupbox == this) {
   1.420 +          // The <label> points back to this groupbox
   1.421 +          rel.AppendTarget(childAcc);
   1.422 +        }
   1.423 +    }
   1.424 +  }
   1.425 +
   1.426 +  return rel;
   1.427 +}
   1.428 +
   1.429 +////////////////////////////////////////////////////////////////////////////////
   1.430 +// XULRadioButtonAccessible
   1.431 +////////////////////////////////////////////////////////////////////////////////
   1.432 +
   1.433 +XULRadioButtonAccessible::
   1.434 +  XULRadioButtonAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.435 +  RadioButtonAccessible(aContent, aDoc)
   1.436 +{
   1.437 +}
   1.438 +
   1.439 +uint64_t
   1.440 +XULRadioButtonAccessible::NativeState()
   1.441 +{
   1.442 +  uint64_t state = LeafAccessible::NativeState();
   1.443 +  state |= states::CHECKABLE;
   1.444 +
   1.445 +  nsCOMPtr<nsIDOMXULSelectControlItemElement> radioButton =
   1.446 +    do_QueryInterface(mContent);
   1.447 +  if (radioButton) {
   1.448 +    bool selected = false;   // Radio buttons can be selected
   1.449 +    radioButton->GetSelected(&selected);
   1.450 +    if (selected) {
   1.451 +      state |= states::CHECKED;
   1.452 +    }
   1.453 +  }
   1.454 +
   1.455 +  return state;
   1.456 +}
   1.457 +
   1.458 +uint64_t
   1.459 +XULRadioButtonAccessible::NativeInteractiveState() const
   1.460 +{
   1.461 +  return NativelyUnavailable() ? states::UNAVAILABLE : states::FOCUSABLE;
   1.462 +}
   1.463 +
   1.464 +////////////////////////////////////////////////////////////////////////////////
   1.465 +// XULRadioButtonAccessible: Widgets
   1.466 +
   1.467 +Accessible*
   1.468 +XULRadioButtonAccessible::ContainerWidget() const
   1.469 +{
   1.470 +  return mParent;
   1.471 +}
   1.472 +
   1.473 +
   1.474 +////////////////////////////////////////////////////////////////////////////////
   1.475 +// XULRadioGroupAccessible
   1.476 +////////////////////////////////////////////////////////////////////////////////
   1.477 +
   1.478 +/**
   1.479 +  * XUL Radio Group
   1.480 +  *   The Radio Group proxies for the Radio Buttons themselves. The Group gets
   1.481 +  *   focus whereas the Buttons do not. So we only have an accessible object for
   1.482 +  *   this for the purpose of getting the proper RadioButton. Need this here to 
   1.483 +  *   avoid circular reference problems when navigating the accessible tree and
   1.484 +  *   for getting to the radiobuttons.
   1.485 +  */
   1.486 +
   1.487 +XULRadioGroupAccessible::
   1.488 +  XULRadioGroupAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.489 +  XULSelectControlAccessible(aContent, aDoc)
   1.490 +{ 
   1.491 +}
   1.492 +
   1.493 +role
   1.494 +XULRadioGroupAccessible::NativeRole()
   1.495 +{
   1.496 +  return roles::GROUPING;
   1.497 +}
   1.498 +
   1.499 +uint64_t
   1.500 +XULRadioGroupAccessible::NativeInteractiveState() const
   1.501 +{
   1.502 +  // The radio group is not focusable. Sometimes the focus controller will
   1.503 +  // report that it is focused. That means that the actual selected radio button
   1.504 +  // should be considered focused.
   1.505 +  return NativelyUnavailable() ? states::UNAVAILABLE : 0;
   1.506 +}
   1.507 +
   1.508 +////////////////////////////////////////////////////////////////////////////////
   1.509 +// XULRadioGroupAccessible: Widgets
   1.510 +
   1.511 +bool
   1.512 +XULRadioGroupAccessible::IsWidget() const
   1.513 +{
   1.514 +  return true;
   1.515 +}
   1.516 +
   1.517 +bool
   1.518 +XULRadioGroupAccessible::IsActiveWidget() const
   1.519 +{
   1.520 +  return FocusMgr()->HasDOMFocus(mContent);
   1.521 +}
   1.522 +
   1.523 +bool
   1.524 +XULRadioGroupAccessible::AreItemsOperable() const
   1.525 +{
   1.526 +  return true;
   1.527 +}
   1.528 +
   1.529 +
   1.530 +////////////////////////////////////////////////////////////////////////////////
   1.531 +// XULStatusBarAccessible
   1.532 +////////////////////////////////////////////////////////////////////////////////
   1.533 +
   1.534 +XULStatusBarAccessible::
   1.535 +  XULStatusBarAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.536 +  AccessibleWrap(aContent, aDoc)
   1.537 +{
   1.538 +}
   1.539 +
   1.540 +role
   1.541 +XULStatusBarAccessible::NativeRole()
   1.542 +{
   1.543 +  return roles::STATUSBAR;
   1.544 +}
   1.545 +
   1.546 +
   1.547 +////////////////////////////////////////////////////////////////////////////////
   1.548 +// XULToolbarButtonAccessible
   1.549 +////////////////////////////////////////////////////////////////////////////////
   1.550 +
   1.551 +XULToolbarButtonAccessible::
   1.552 +  XULToolbarButtonAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.553 +  XULButtonAccessible(aContent, aDoc)
   1.554 +{
   1.555 +}
   1.556 +
   1.557 +void
   1.558 +XULToolbarButtonAccessible::GetPositionAndSizeInternal(int32_t* aPosInSet,
   1.559 +                                                       int32_t* aSetSize)
   1.560 +{
   1.561 +  int32_t setSize = 0;
   1.562 +  int32_t posInSet = 0;
   1.563 +
   1.564 +  Accessible* parent = Parent();
   1.565 +  if (!parent)
   1.566 +    return;
   1.567 +
   1.568 +  uint32_t childCount = parent->ChildCount();
   1.569 +  for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
   1.570 +    Accessible* child = parent->GetChildAt(childIdx);
   1.571 +    if (IsSeparator(child)) { // end of a group of buttons
   1.572 +      if (posInSet)
   1.573 +        break; // we've found our group, so we're done
   1.574 +
   1.575 +      setSize = 0; // not our group, so start a new group
   1.576 +
   1.577 +    } else {
   1.578 +      setSize++; // another button in the group
   1.579 +
   1.580 +      if (child == this)
   1.581 +        posInSet = setSize; // we've found our button
   1.582 +    }
   1.583 +  }
   1.584 +
   1.585 +  *aPosInSet = posInSet;
   1.586 +  *aSetSize = setSize;
   1.587 +}
   1.588 +
   1.589 +bool
   1.590 +XULToolbarButtonAccessible::IsSeparator(Accessible* aAccessible)
   1.591 +{
   1.592 +  nsIContent* content = aAccessible->GetContent();
   1.593 +  return content && ((content->Tag() == nsGkAtoms::toolbarseparator) ||
   1.594 +                     (content->Tag() == nsGkAtoms::toolbarspacer) ||
   1.595 +                     (content->Tag() == nsGkAtoms::toolbarspring)); }
   1.596 +
   1.597 +
   1.598 +////////////////////////////////////////////////////////////////////////////////
   1.599 +// XULToolbarAccessible
   1.600 +////////////////////////////////////////////////////////////////////////////////
   1.601 +
   1.602 +XULToolbarAccessible::
   1.603 +  XULToolbarAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.604 +  AccessibleWrap(aContent, aDoc)
   1.605 +{
   1.606 +}
   1.607 +
   1.608 +role
   1.609 +XULToolbarAccessible::NativeRole()
   1.610 +{
   1.611 +  return roles::TOOLBAR;
   1.612 +}
   1.613 +
   1.614 +ENameValueFlag
   1.615 +XULToolbarAccessible::NativeName(nsString& aName)
   1.616 +{
   1.617 +  if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::toolbarname, aName))
   1.618 +    aName.CompressWhitespace();
   1.619 +
   1.620 +  return eNameOK;
   1.621 +}
   1.622 +
   1.623 +
   1.624 +////////////////////////////////////////////////////////////////////////////////
   1.625 +// XULToolbarAccessible
   1.626 +////////////////////////////////////////////////////////////////////////////////
   1.627 +
   1.628 +XULToolbarSeparatorAccessible::
   1.629 +  XULToolbarSeparatorAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.630 +  LeafAccessible(aContent, aDoc)
   1.631 +{
   1.632 +}
   1.633 +
   1.634 +role
   1.635 +XULToolbarSeparatorAccessible::NativeRole()
   1.636 +{
   1.637 +  return roles::SEPARATOR;
   1.638 +}
   1.639 +
   1.640 +uint64_t
   1.641 +XULToolbarSeparatorAccessible::NativeState()
   1.642 +{
   1.643 +  return 0;
   1.644 +}

mercurial