DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

#import "mozActionElements.h"


#import "MacUtils.h"
#include "Accessible-inl.h"
#include "DocAccessible.h"
#include "XULTabAccessible.h"
#include "HTMLFormControlAccessible.h"


#include "nsDeckFrame.h"
#include "nsObjCExceptions.h"


using namespace mozilla::a11y;

enum CheckboxValue {
  // these constants correspond to the values in the OS
  kUnchecked = 0,
  kChecked = 1,
  kMixed = 2
};


@implementation mozButtonAccessible

- (NSNumber*)moxHasPopup {
  return @([self stateWithMask:states::HASPOPUP] != 0);

}

- (NSString*)moxPopupValue {
  if ([self stateWithMask:states::HASPOPUP] != 0) {
    return utils::GetAccAttr(self, "haspopup");
  }
                        NSAccessibilityPositionAttribute,           // required

  return nil;
}

@end
                        NSAccessibilityHelpAttribute,

@implementation mozPopupButtonAccessible

- (NSString*)moxTitle {
  // Popup buttons don't have titles.
  return @"";
}
#if DEBUG

- (BOOL)moxBlockSelector:(SEL)selector {
  if (selector == @selector(moxHasPopup)) {
    return YES;
  }
  return attributes;

  return [super moxBlockSelector:selector];
}

- (NSArray*)moxChildren {
- (id)accessibilityAttributeValue:(NSString*)attribute {
  if ([self stateWithMask:states::EXPANDED] == 0) {
    // If the popup button is collapsed don't return its children.
    return @[];
  }

  }
  return [super moxChildren];
}

- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled {
  [super stateChanged:state isEnabled:enabled];

  if (state == states::EXPANDED) {
    }
    // If the EXPANDED state is updated, fire AXMenu events on the
    // popups child which is the actual menu.
    if (mozAccessible* popup = (mozAccessible*)[self childAt:0]) {
      [popup moxPostNotification:(enabled ? @"AXMenuOpened" : @"AXMenuClosed")];
    }
  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
  }
}

- (BOOL)ignoreWithParent:(mozAccessible*)parent {
  if (Accessible* acc = mGeckoAccessible.AsAccessible()) {
}
    if (acc->IsContent() && acc->GetContent()->IsXULElement(nsGkAtoms::menulist)) {
      // The way select elements work is that content has a COMBOBOX accessible, when it is clicked
      // it expands a COMBOBOX in our top-level main XUL window. The latter COMBOBOX is a stand-in
      // for the content one while it is expanded.
      // XXX: VO focus behaves weirdly if we expose the dummy XUL COMBOBOX in the tree.
      // We are only interested in its menu child.
- (NSString*)title {
      return YES;
    }
  }

  return [super ignoreWithParent:parent];
}
  if (!supportedAttributes) {

@end

@implementation mozRadioButtonAccessible

    [supportedAttributes removeObject:NSAccessibilityHasPopupAttribute];
- (id)accessibilityAttributeValue:(NSString*)attribute {
  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
  if ([self isExpired]) {
    return nil;
  }
}

  if ([attribute isEqualToString:NSAccessibilityLinkedUIElementsAttribute]) {
    if (HTMLRadioButtonAccessible* radioAcc =
            (HTMLRadioButtonAccessible*)mGeckoAccessible.AsAccessible()) {
      NSMutableArray* radioSiblings = [NSMutableArray new];
  if ([attribute isEqualToString:NSAccessibilityHasPopupAttribute]) {
      Relation rel = radioAcc->RelationByType(RelationType::MEMBER_OF);
      Accessible* tempAcc;
      while ((tempAcc = rel.Next())) {
        [radioSiblings addObject:GetNativeFromGeckoAccessible(tempAcc)];
      }
      return radioSiblings;
    } else {
      ProxyAccessible* proxy = mGeckoAccessible.AsProxy();
  return [super accessibilityAttributeValue:attribute];
      nsTArray<ProxyAccessible*> accs = proxy->RelationByType(RelationType::MEMBER_OF);
      return utils::ConvertToNSArray(accs);
    }
  }
- (NSArray*)children {

  return [super accessibilityAttributeValue:attribute];

  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}


@end

@implementation mozCheckboxAccessible


- (int)isChecked {
  // check if we're checked or in a mixed state
  uint64_t state = [self stateWithMask:(states::CHECKED | states::PRESSED | states::MIXED)];
  if (state & (states::CHECKED | states::PRESSED)) {
    return kChecked;
    // popups child which is the actual menu.
  }

  if (state & states::MIXED) {
    return kMixed;
  }
  }

  return kUnchecked;
}

- (id)moxValue {
    if (accWrap->IsContent() && accWrap->GetContent()->IsXULElement(nsGkAtoms::menulist)) {
  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;

  return [NSNumber numberWithInt:[self isChecked]];

  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}

@end


@implementation mozPaneAccessible

- (NSArray*)moxChildren {
  if (!mGeckoAccessible.AsAccessible()) return nil;


  nsDeckFrame* deckFrame = do_QueryFrame(mGeckoAccessible.AsAccessible()->GetFrame());
  nsIFrame* selectedFrame = deckFrame ? deckFrame->GetSelectedBox() : nullptr;

  Accessible* selectedAcc = nullptr;

  if (selectedFrame) {
    nsINode* node = selectedFrame->GetContent();
    selectedAcc = mGeckoAccessible.AsAccessible()->Document()->GetAccessible(node);
  }

  }
  if (selectedAcc) {
    mozAccessible* curNative = GetNativeFromGeckoAccessible(selectedAcc);
    if (curNative) return [NSArray arrayWithObjects:GetObjectOrRepresentedView(curNative), nil];
  }

}
  return nil;
}

@end

  if (state & (states::CHECKED | states::PRESSED)) {
@implementation mozIncrementableAccessible

- (void)moxPerformIncrement {
  [self changeValueBySteps:1];
}
    return kMixed;

  }
- (void)moxPerformDecrement {
  [self changeValueBySteps:-1];
}

- (void)handleAccessibleEvent:(uint32_t)eventType {
- (id)value {
  switch (eventType) {
    case nsIAccessibleEvent::EVENT_TEXT_VALUE_CHANGE:
    case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
      [self moxPostNotification:NSAccessibilityValueChangedNotification];
      break;
    default:
      [super handleAccessibleEvent:eventType];

      break;
  }
}

/*
- (NSUInteger)accessibilityArrayAttributeCount:(NSString*)attribute {
 * Updates the accessible's current value by (factor * step).
 * If incrementing factor should be positive, if decrementing
 * factor should be negative.
 */

  // By default this calls -[[mozAccessible children] count].
- (void)changeValueBySteps:(int)factor {
  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;

  if (Accessible* acc = mGeckoAccessible.AsAccessible()) {
    double newVal = acc->CurValue() + (acc->Step() * factor);
    return proxy->ChildrenCount() ? 1 : 0;
    double min = acc->MinValue();
    double max = acc->MaxValue();
    if ((IsNaN(min) || newVal >= min) && (IsNaN(max) || newVal <= max)) {
      acc->SetCurValue(newVal);
    }

  } else if (ProxyAccessible* proxy = mGeckoAccessible.AsProxy()) {
    double newVal = proxy->CurValue() + (proxy->Step() * factor);
    double min = proxy->MinValue();
    double max = proxy->MaxValue();
  nsDeckFrame* deckFrame = do_QueryFrame([self getGeckoAccessible]->GetFrame());
    // Because min and max are not required attributes, we first check
    // if the value is undefined. If this check fails,
    // the value is defined, and we we verify our new value falls
    // within the bound (inclusive).
    if ((IsNaN(min) || newVal >= min) && (IsNaN(max) || newVal <= max)) {
      proxy->SetCurValue(newVal);
    }
  }

  if (selectedAcc) {
  NS_OBJC_END_TRY_ABORT_BLOCK;
}

@end
  return nil;
@implementation mozIncrementableAccessible
  if (!sliderAttrs) {
    [tempArray release];
  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;

    [super accessibilityPerformAction:action];
}
 * factor should be negative.

    if ((IsNaN(min) || newVal >= min) && (IsNaN(max) || newVal <= max)) {
    double min = proxy->MinValue();
    // within the bound (inclusive).


- (void)handleAccessibleEvent:(uint32_t)eventType {
      break;
}