bug 1109891 - part 1 - use an accessor method to get mGeckoAccessible r=tbsaunde
authorLorien Hu <lorien@lorienhu.com>
Fri, 22 May 2015 10:59:26 -0400
changeset 263267 52644686f06215de2aad79845ffeef8fd5388d43
parent 263266 00c2e00e3c37d714a371e9571c033f80bfe0ad80
child 263268 cda6c79898f6eeaa83a3020bad18645e6986862c
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1109891
milestone41.0a1
bug 1109891 - part 1 - use an accessor method to get mGeckoAccessible r=tbsaunde
accessible/mac/mozAccessible.h
accessible/mac/mozAccessible.mm
accessible/mac/mozActionElements.mm
accessible/mac/mozDocAccessible.mm
accessible/mac/mozHTMLAccessible.mm
accessible/mac/mozTextAccessible.mm
--- a/accessible/mac/mozAccessible.h
+++ b/accessible/mac/mozAccessible.h
@@ -49,16 +49,19 @@ GetNativeFromGeckoAccessible(mozilla::a1
   mozAccessible* mParent;
 
   /**
    * The role of our gecko accessible.
    */
   mozilla::a11y::role        mRole;
 }
 
+// return the Accessible for this mozAccessible.
+- (mozilla::a11y::AccessibleWrap*) getGeckoAccessible;
+
 // inits with the gecko owner.
 - (id)initWithAccessible:(mozilla::a11y::AccessibleWrap*)geckoParent;
 
 // our accessible parent (AXParent)
 - (id <mozAccessible>)parent;
 
 // a lazy cache of our accessible children (AXChildren). updated
 - (NSArray*)children;
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -78,37 +78,44 @@ GetClosestInterestingAccessible(id anObj
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   [mChildren release];
   [super dealloc];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
+
+- (mozilla::a11y::AccessibleWrap*)getGeckoAccessible
+{
+  return mGeckoAccessible;
+}
  
 #pragma mark -
 
 - (BOOL)accessibilityIsIgnored
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   // unknown (either unimplemented, or irrelevant) elements are marked as ignored
   // as well as expired elements.
-  return !mGeckoAccessible || ([[self role] isEqualToString:NSAccessibilityUnknownRole] &&
-                               !(mGeckoAccessible->InteractiveState() & states::FOCUSABLE));
+
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  return !accWrap || ([[self role] isEqualToString:NSAccessibilityUnknownRole] &&
+                               !(accWrap->InteractiveState() & states::FOCUSABLE));
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
 }
 
 - (NSArray*)accessibilityAttributeNames
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   // if we're expired, we don't support any attributes.
-  if (!mGeckoAccessible)
+  if (![self getGeckoAccessible])
     return [NSArray array];
   
   static NSArray *generalAttributes = nil;
   
   if (!generalAttributes) {
     // standard attributes that are shared and supported by all generic elements.
     generalAttributes = [[NSArray alloc] initWithObjects:  NSAccessibilityChildrenAttribute, 
                                                            NSAccessibilityParentAttribute,
@@ -136,17 +143,17 @@ GetClosestInterestingAccessible(id anObj
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (id)accessibilityAttributeValue:(NSString*)attribute
 {  
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  if (!mGeckoAccessible)
+  if (![self getGeckoAccessible])
     return nil;
 
 #if DEBUG
   if ([attribute isEqualToString:@"AXMozDescription"])
     return [NSString stringWithFormat:@"role = %u native = %@", mRole, [self class]];
 #endif
   
   if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
@@ -178,17 +185,18 @@ GetClosestInterestingAccessible(id anObj
     return [self size];
   if ([attribute isEqualToString:NSAccessibilityWindowAttribute])
     return [self window];
   if ([attribute isEqualToString:NSAccessibilityTopLevelUIElementAttribute])
     return [self window];
   if ([attribute isEqualToString:NSAccessibilityTitleAttribute])
     return [self title];
   if ([attribute isEqualToString:NSAccessibilityTitleUIElementAttribute]) {
-    Relation rel = mGeckoAccessible->RelationByType(RelationType::LABELLED_BY);
+    Relation rel =
+      [self getGeckoAccessible]->RelationByType(RelationType::LABELLED_BY);
     Accessible* tempAcc = rel.Next();
     return tempAcc ? GetNativeFromGeckoAccessible(tempAcc) : nil;
   }
   if ([attribute isEqualToString:NSAccessibilityHelpAttribute])
     return [self help];
     
 #ifdef DEBUG
  NSLog (@"!!! %@ can't respond to attribute %@", self, attribute);
@@ -222,30 +230,33 @@ GetClosestInterestingAccessible(id anObj
   if ([attribute isEqualToString:NSAccessibilityFocusedAttribute] && [value boolValue])
     [self focus];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (id)accessibilityHitTest:(NSPoint)point
 {
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  if (!accWrap)
     return nil;
 
   // Convert the given screen-global point in the cocoa coordinate system (with
   // origin in the bottom-left corner of the screen) into point in the Gecko
   // coordinate system (with origin in a top-left screen point).
   NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
   NSPoint tmpPoint = NSMakePoint(point.x,
                                  [mainView frame].size.height - point.y);
   nsIntPoint geckoPoint = nsCocoaUtils::
     CocoaPointsToDevPixels(tmpPoint, nsCocoaUtils::GetBackingScaleFactor(mainView));
 
-  Accessible* child = mGeckoAccessible->ChildAtPoint(geckoPoint.x, geckoPoint.y,
-                                                     Accessible::eDeepestChild);
+  Accessible* child =
+    accWrap->ChildAtPoint(geckoPoint.x, geckoPoint.y,
+                          Accessible::eDeepestChild);
 
   if (child) {
     mozAccessible* nativeChild = GetNativeFromGeckoAccessible(child);
     if (nativeChild)
       return GetClosestInterestingAccessible(nativeChild);
   }
 
   // if we didn't find anything, return ourself (or the first unignored ancestor).
@@ -265,50 +276,54 @@ GetClosestInterestingAccessible(id anObj
 }
 
 - (void)accessibilityPerformAction:(NSString*)action 
 {
 }
 
 - (id)accessibilityFocusedUIElement
 {
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  if (!accWrap)
     return nil;
   
-  Accessible* focusedGeckoChild = mGeckoAccessible->FocusedChild();
+  Accessible* focusedGeckoChild = accWrap->FocusedChild();
   if (focusedGeckoChild) {
     mozAccessible *focusedChild = GetNativeFromGeckoAccessible(focusedGeckoChild);
     if (focusedChild)
       return GetClosestInterestingAccessible(focusedChild);
   }
   
   // return ourself if we can't get a native focused child.
   return GetClosestInterestingAccessible(self);
 }
 
 #pragma mark -
 
 - (id <mozAccessible>)parent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  Accessible* accessibleParent = mGeckoAccessible->GetUnignoredParent();
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  Accessible* accessibleParent = accWrap->GetUnignoredParent();
   if (accessibleParent) {
     id nativeParent = GetNativeFromGeckoAccessible(accessibleParent);
     if (nativeParent)
       return GetClosestInterestingAccessible(nativeParent);
   }
   
   // GetUnignoredParent() returns null when there is no unignored accessible all the way up to
   // the root accessible. so we'll have to return whatever native accessible is above our root accessible 
   // (which might be the owning NSWindow in the application, for example).
   //
   // get the native root accessible, and tell it to return its first parent unignored accessible.
   id nativeParent =
-    GetNativeFromGeckoAccessible(mGeckoAccessible->RootAccessible());
+    GetNativeFromGeckoAccessible(accWrap->RootAccessible());
   NSAssert1 (nativeParent, @"!!! we can't find a parent for %@", self);
 
   return GetClosestInterestingAccessible(nativeParent);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (BOOL)hasRepresentedView
@@ -327,24 +342,26 @@ GetClosestInterestingAccessible(id anObj
 }
 
 // gets our native children lazily.
 // returns nil when there are no children.
 - (NSArray*)children
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  if (mChildren || !mGeckoAccessible->AreChildrenCached())
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  if (mChildren || !accWrap->AreChildrenCached())
     return mChildren;
 
   mChildren = [[NSMutableArray alloc] init];
 
   // get the array of children.
   nsAutoTArray<Accessible*, 10> childrenArray;
-  mGeckoAccessible->GetUnignoredChildren(&childrenArray);
+  accWrap->GetUnignoredChildren(&childrenArray);
 
   // now iterate through the children array, and get each native accessible.
   uint32_t totalCount = childrenArray.Length();
   for (uint32_t idx = 0; idx < totalCount; idx++) {
     Accessible* curAccessible = childrenArray.ElementAt(idx);
     if (curAccessible) {
       mozAccessible *curNative = GetNativeFromGeckoAccessible(curAccessible);
       if (curNative)
@@ -365,54 +382,58 @@ GetClosestInterestingAccessible(id anObj
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (NSValue*)position
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  if (!accWrap)
     return nil;
 
-  nsIntRect rect = mGeckoAccessible->Bounds();
+  nsIntRect rect = accWrap->Bounds();
 
   NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
   CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mainView);
   NSPoint p = NSMakePoint(static_cast<CGFloat>(rect.x) / scaleFactor,
                          [mainView frame].size.height - static_cast<CGFloat>(rect.y + rect.height) / scaleFactor);
 
   return [NSValue valueWithPoint:p];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (NSValue*)size
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  if (!accWrap)
     return nil;
 
-  nsIntRect rect = mGeckoAccessible->Bounds();
+  nsIntRect rect = accWrap->Bounds();
   CGFloat scaleFactor =
     nsCocoaUtils::GetBackingScaleFactor([[NSScreen screens] objectAtIndex:0]);
   return [NSValue valueWithSize:NSMakeSize(static_cast<CGFloat>(rect.width) / scaleFactor,
                                            static_cast<CGFloat>(rect.height) / scaleFactor)];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (NSString*)role
 {
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  if (!accWrap)
     return nil;
 
 #ifdef DEBUG_A11Y
-  NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(mGeckoAccessible),
+  NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(accWrap),
                "Does not support Text when it should");
 #endif
 
 #define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule) \
   case roles::geckoRole: \
     return macRole;
 
   switch (mRole) {
@@ -422,20 +443,21 @@ GetClosestInterestingAccessible(id anObj
       return NSAccessibilityUnknownRole;
   }
 
 #undef ROLE
 }
 
 - (NSString*)subrole
 {
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  if (!accWrap)
     return nil;
 
-  nsIAtom* landmark = mGeckoAccessible->LandmarkRole();
+  nsIAtom* landmark = accWrap->LandmarkRole();
   if (landmark) {
     if (landmark == nsGkAtoms::application)
       return @"AXLandmarkApplication";
     if (landmark == nsGkAtoms::banner)
       return @"AXLandmarkBanner";
     if (landmark == nsGkAtoms::complementary)
       return @"AXLandmarkComplementary";
     if (landmark == nsGkAtoms::contentinfo)
@@ -452,17 +474,17 @@ GetClosestInterestingAccessible(id anObj
       return @"AXSearchField";
   }
 
   switch (mRole) {
     case roles::LIST:
       return @"AXContentList"; // 10.6+ NSAccessibilityContentListSubrole;
 
     case roles::ENTRY:
-      if (mGeckoAccessible->IsSearchbox())
+      if (accWrap->IsSearchbox())
         return @"AXSearchField";
       break;
 
     case roles::DEFINITION_LIST:
       return @"AXDefinitionList"; // 10.6+ NSAccessibilityDefinitionListSubrole;
 
     case roles::TERM:
       return @"AXTerm";
@@ -523,28 +545,28 @@ struct RoleDescrComparator
   return NSAccessibilityRoleDescription([self role], subrole);
 }
 
 - (NSString*)title
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString title;
-  mGeckoAccessible->Name(title);
+  [self getGeckoAccessible]->Name(title);
   return nsCocoaUtils::ToNSString(title);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (id)value
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString value;
-  mGeckoAccessible->Value(value);
+  [self getGeckoAccessible]->Value(value);
   return nsCocoaUtils::ToNSString(value);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (void)valueDidChange
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
@@ -562,33 +584,34 @@ struct RoleDescrComparator
 {
   // Do nothing. mozTextAccessible will.
 }
 
 - (NSString*)customDescription
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  if (mGeckoAccessible->IsDefunct())
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  if (accWrap->IsDefunct())
     return nil;
 
   nsAutoString desc;
-  mGeckoAccessible->Description(desc);
+  accWrap->Description(desc);
 
   return nsCocoaUtils::ToNSString(desc);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (NSString*)help
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString helpText;
-  mGeckoAccessible->Help(helpText);
+  [self getGeckoAccessible]->Help(helpText);
   return nsCocoaUtils::ToNSString(helpText);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 // objc-style description (from NSObject); not to be confused with the accessible description above.
 - (NSString*)description
 {
@@ -596,36 +619,39 @@ struct RoleDescrComparator
 
   return [NSString stringWithFormat:@"(%p) %@", self, [self role]];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (BOOL)isFocused
 {
-  return FocusMgr()->IsFocused(mGeckoAccessible);
+  return FocusMgr()->IsFocused([self getGeckoAccessible]);
 }
 
 - (BOOL)canBeFocused
 {
-  return mGeckoAccessible && (mGeckoAccessible->InteractiveState() & states::FOCUSABLE);
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  return accWrap && (accWrap->InteractiveState() & states::FOCUSABLE);
 }
 
 - (BOOL)focus
 {
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  if (!accWrap)
     return NO;
 
-  mGeckoAccessible->TakeFocus();
+  accWrap->TakeFocus();
   return YES;
 }
 
 - (BOOL)isEnabled
 {
-  return mGeckoAccessible && ((mGeckoAccessible->InteractiveState() & states::UNAVAILABLE) == 0);
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  return accWrap && ((accWrap->InteractiveState() & states::UNAVAILABLE) == 0);
 }
 
 // The root accessible calls this when the focused node was
 // changed to us.
 - (void)didReceiveFocus
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
@@ -638,17 +664,17 @@ struct RoleDescrComparator
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (NSWindow*)window
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  AccessibleWrap* accWrap = static_cast<AccessibleWrap*>(mGeckoAccessible);
+  AccessibleWrap* accWrap = static_cast<AccessibleWrap*>([self getGeckoAccessible]);
 
   // Get a pointer to the native window (NSWindow) we reside in.
   NSWindow *nativeWindow = nil;
   DocAccessible* docAcc = accWrap->Document();
   if (docAcc)
     nativeWindow = static_cast<NSWindow*>(docAcc->GetNativeWindow());
 
   NSAssert1(nativeWindow, @"Could not get native window for %@", self);
@@ -687,17 +713,17 @@ struct RoleDescrComparator
 
   mGeckoAccessible = nullptr;
   
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (BOOL)isExpired
 {
-  return !mGeckoAccessible;
+  return ![self getGeckoAccessible];
 }
 
 #pragma mark -
 #pragma mark Debug methods
 #pragma mark -
 
 #ifdef DEBUG
 
--- a/accessible/mac/mozActionElements.mm
+++ b/accessible/mac/mozActionElements.mm
@@ -68,17 +68,17 @@ enum CheckboxValue {
   
   return [super accessibilityAttributeValue:attribute];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (BOOL)accessibilityIsIgnored
 {
-  return !mGeckoAccessible;
+  return ![self getGeckoAccessible];
 }
 
 - (NSArray*)accessibilityActionNames
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if ([self isEnabled])
     return [NSArray arrayWithObject:NSAccessibilityPressAction];
@@ -113,22 +113,23 @@ enum CheckboxValue {
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (void)click
 {
   // both buttons and checkboxes have only one action. we should really stop using arbitrary
   // arrays with actions, and define constants for these actions.
-  mGeckoAccessible->DoAction(0);
+  [self getGeckoAccessible]->DoAction(0);
 }
 
 - (BOOL)isTab
 {
-  return (mGeckoAccessible && (mGeckoAccessible->Role() == roles::PAGETAB));
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+  return (accWrap && (accWrap->Role() == roles::PAGETAB));
 }
 
 @end
 
 @implementation mozCheckboxAccessible
 
 - (NSString*)accessibilityActionDescription:(NSString*)action 
 {
@@ -143,17 +144,17 @@ enum CheckboxValue {
   
   return nil;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (int)isChecked
 {
-  uint64_t state = mGeckoAccessible->NativeState();
+  uint64_t state = [self getGeckoAccessible]->NativeState();
 
   // check if we're checked or in a mixed state
   if (state & states::CHECKED) {
     return (state & states::MIXED) ? kMixed : kChecked;
   }
   
   return kUnchecked;
 }
@@ -287,20 +288,20 @@ enum CheckboxValue {
   return [super accessibilityAttributeValue:attribute];  
 }
 
 /**
  * Returns the selected tab (the mozAccessible)
  */
 - (id)value
 {
-  if (!mGeckoAccessible)
+  if (![self getGeckoAccessible])
     return nil;
 
-  Accessible* accessible = mGeckoAccessible->GetSelectedItem(0);
+  Accessible* accessible = [self getGeckoAccessible]->GetSelectedItem(0);
   if (!accessible)
     return nil;
 
   mozAccessible* nativeAcc = nil;
   accessible->GetNativeInterface((void**)&nativeAcc);
 
   return nativeAcc;
 }
@@ -334,39 +335,39 @@ enum CheckboxValue {
 }
 
 @end
 
 @implementation mozPaneAccessible
 
 - (NSUInteger)accessibilityArrayAttributeCount:(NSString*)attribute
 {
-  if (!mGeckoAccessible)
+  if (![self getGeckoAccessible])
     return 0;
 
   // By default this calls -[[mozAccessible children] count].
   // Since we don't cache mChildren. This is faster.
   if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
-    return mGeckoAccessible->ChildCount() ? 1 : 0;
+    return [self getGeckoAccessible]->ChildCount() ? 1 : 0;
 
   return [super accessibilityArrayAttributeCount:attribute];
 }
 
 - (NSArray*)children
 {
-  if (!mGeckoAccessible)
+  if (![self getGeckoAccessible])
     return nil;
 
-  nsDeckFrame* deckFrame = do_QueryFrame(mGeckoAccessible->GetFrame());
+  nsDeckFrame* deckFrame = do_QueryFrame([self getGeckoAccessible]->GetFrame());
   nsIFrame* selectedFrame = deckFrame ? deckFrame->GetSelectedBox() : nullptr;
 
   Accessible* selectedAcc = nullptr;
   if (selectedFrame) {
     nsINode* node = selectedFrame->GetContent();
-    selectedAcc = mGeckoAccessible->Document()->GetAccessible(node);
+    selectedAcc = [self getGeckoAccessible]->Document()->GetAccessible(node);
   }
 
   if (selectedAcc) {
     mozAccessible *curNative = GetNativeFromGeckoAccessible(selectedAcc);
     if (curNative)
       return [NSArray arrayWithObjects:GetObjectOrRepresentedView(curNative), nil];
   }
 
--- a/accessible/mac/mozDocAccessible.mm
+++ b/accessible/mac/mozDocAccessible.mm
@@ -28,17 +28,17 @@ getNativeViewFromRootAccessible(Accessib
 
 @implementation mozRootAccessible
 
 - (NSArray*)accessibilityAttributeNames
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
   
   // if we're expired, we don't support any attributes.
-  if (!mGeckoAccessible)
+  if (![self getGeckoAccessible])
     return [NSArray array];
   
   // standard attributes that are shared and supported by root accessible (AXMain) elements.
   static NSMutableArray* attributes = nil;
   
   if (!attributes) {
     attributes = [[super accessibilityAttributeNames] mutableCopy];
     [attributes addObject:NSAccessibilityMainAttribute];
@@ -90,17 +90,17 @@ getNativeViewFromRootAccessible(Accessib
 // this will return our parallell NSView. see mozDocAccessible.h
 - (id)representedView
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if (mParallelView)
     return (id)mParallelView;
   
-  mParallelView = getNativeViewFromRootAccessible (mGeckoAccessible);
+  mParallelView = getNativeViewFromRootAccessible ([self getGeckoAccessible]);
   
   NSAssert(mParallelView, @"can't return root accessible's native parallel view.");
   return mParallelView;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (BOOL)isRoot
--- a/accessible/mac/mozHTMLAccessible.mm
+++ b/accessible/mac/mozHTMLAccessible.mm
@@ -15,42 +15,44 @@
 @implementation mozHeadingAccessible
 
 - (NSString*)title
 {
   nsAutoString title;
   mozilla::ErrorResult rv;
   // XXX use the flattening API when there are available
   // see bug 768298
-  mGeckoAccessible->GetContent()->GetTextContent(title, rv);
+  [self getGeckoAccessible]->GetContent()->GetTextContent(title, rv);
 
   return nsCocoaUtils::ToNSString(title);
 }
 
 - (id)value
 {
-  if (!mGeckoAccessible || !mGeckoAccessible->IsHyperText())
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  if (!accWrap || !accWrap->IsHyperText())
     return nil;
 
-  uint32_t level = mGeckoAccessible->AsHyperText()->GetLevelInternal();
+  uint32_t level = accWrap->AsHyperText()->GetLevelInternal();
   return [NSNumber numberWithInt:level];
 }
 
 @end
 
 @interface mozLinkAccessible ()
 -(NSURL*)url;
 @end
 
 @implementation mozLinkAccessible
 
 - (NSArray*)accessibilityAttributeNames
 {
   // if we're expired, we don't support any attributes.
-  if (!mGeckoAccessible)
+  if (![self getGeckoAccessible])
     return [NSArray array];
   
   static NSMutableArray* attributes = nil;
   
   if (!attributes) {
     attributes = [[super accessibilityAttributeNames] mutableCopy];
     [attributes addObject:NSAccessibilityURLAttribute];
   }
@@ -64,57 +66,59 @@
     return [self url];
 
   return [super accessibilityAttributeValue:attribute];
 }
 
 - (NSArray*)accessibilityActionNames 
 {
     // if we're expired, we don't support any attributes.
-  if (!mGeckoAccessible)
+  if (![self getGeckoAccessible])
     return [NSArray array];
 
   static NSArray* actionNames = nil;
 
   if (!actionNames) {
     actionNames = [[NSArray alloc] initWithObjects:NSAccessibilityPressAction,
                                    nil];
   }
 
   return actionNames;
 }
 
 - (void)accessibilityPerformAction:(NSString*)action 
 {
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  if (!accWrap)
     return;
 
   if ([action isEqualToString:NSAccessibilityPressAction])
-    mGeckoAccessible->DoAction(0);
+    accWrap->DoAction(0);
   else
     [super accessibilityPerformAction:action];
 }
 
 - (NSString*)customDescription
 {
   return @"";
 }
 
 - (NSString*)value
 {
   return @"";
 }
 
 - (NSURL*)url
 {
-  if (!mGeckoAccessible || mGeckoAccessible->IsDefunct())
+  if (![self getGeckoAccessible] || [self getGeckoAccessible]->IsDefunct())
     return nil;
 
   nsAutoString value;
-  mGeckoAccessible->Value(value);
+  [self getGeckoAccessible]->Value(value);
 
   NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value);
   if (!urlString)
     return nil;
 
   return [NSURL URLWithString:urlString];
 }
 
--- a/accessible/mac/mozTextAccessible.mm
+++ b/accessible/mac/mozTextAccessible.mm
@@ -62,17 +62,17 @@ ToNSString(id aValue)
   }
   return self;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (BOOL)accessibilityIsIgnored
 {
-  return !mGeckoAccessible;
+  return ![self getGeckoAccessible];
 }
 
 - (NSArray*)accessibilityAttributeNames
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   static NSMutableArray* supportedAttributes = nil;
   if (!supportedAttributes) {
@@ -121,21 +121,23 @@ ToNSString(id aValue)
     if ([[self role] isEqualToString:NSAccessibilityStaticTextRole]) {
       NSString* selectedText = [self selectedText];
       return (selectedText && [selectedText length]) ? selectedText : [self text];
     }
 
     return [self text];
   }
 
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
   if ([attribute isEqualToString:@"AXRequired"])
-    return [NSNumber numberWithBool:!!(mGeckoAccessible->State() & states::REQUIRED)];
+    return [NSNumber numberWithBool:!!(accWrap->State() & states::REQUIRED)];
 
   if ([attribute isEqualToString:@"AXInvalid"])
-    return [NSNumber numberWithBool:!!(mGeckoAccessible->State() & states::INVALID)];
+    return [NSNumber numberWithBool:!!(accWrap->State() & states::INVALID)];
 
   if ([attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute])
     return [self visibleCharacterRange];
 
   // let mozAccessible handle all other attributes
   return [super accessibilityAttributeValue:attribute];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
@@ -318,17 +320,17 @@ ToNSString(id aValue)
 - (BOOL)isReadOnly
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   if ([[self role] isEqualToString:NSAccessibilityStaticTextRole])
     return YES;
 
   if (mGeckoTextAccessible)
-    return (mGeckoAccessible->State() & states::READONLY) == 0;
+    return ([self getGeckoAccessible]->State() & states::READONLY) == 0;
 
   return NO;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
 }
 
 - (NSNumber*)caretLineNumber
 {
@@ -348,17 +350,17 @@ ToNSString(id aValue)
     mGeckoTextAccessible->ReplaceText(text);
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (NSString*)text
 {
-  if (!mGeckoAccessible || !mGeckoTextAccessible)
+  if (![self getGeckoAccessible] || !mGeckoTextAccessible)
     return nil;
 
   // A password text field returns an empty value
   if (mRole == roles::PASSWORD_TEXT)
     return @"";
 
   nsAutoString text;
   mGeckoTextAccessible->TextSubstring(0,
@@ -366,17 +368,17 @@ ToNSString(id aValue)
                                       text);
   return nsCocoaUtils::ToNSString(text);
 }
 
 - (long)textLength
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
-  if (!mGeckoAccessible || !mGeckoTextAccessible)
+  if (![self getGeckoAccessible] || !mGeckoTextAccessible)
     return 0;
 
   return mGeckoTextAccessible ? mGeckoTextAccessible->CharacterCount() : 0;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
 }
 
 - (long)selectedTextLength
@@ -491,23 +493,27 @@ ToNSString(id aValue)
   if ([attribute isEqualToString:NSAccessibilityValueAttribute])
     return [self text];
 
   return [super accessibilityAttributeValue:attribute];
 }
 
 - (NSString*)text
 {
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  if (!accWrap)
     return nil;
 
-  return nsCocoaUtils::ToNSString(mGeckoAccessible->AsTextLeaf()->Text());
+  return nsCocoaUtils::ToNSString(accWrap->AsTextLeaf()->Text());
 }
 
 - (long)textLength
 {
-  if (!mGeckoAccessible)
+  AccessibleWrap* accWrap = [self getGeckoAccessible];
+
+  if (!accWrap)
     return 0;
 
-  return mGeckoAccessible->AsTextLeaf()->Text().Length();
+  return accWrap->AsTextLeaf()->Text().Length();
 }
 
 @end