Modified: trunk/Source/WebCore/ChangeLog (257254 => 257255)
--- trunk/Source/WebCore/ChangeLog 2020-02-24 22:08:30 UTC (rev 257254)
+++ trunk/Source/WebCore/ChangeLog 2020-02-24 22:18:59 UTC (rev 257255)
@@ -1,3 +1,40 @@
+2020-02-24 Andres Gonzalez <andresg...@apple.com>
+
+ [WebAccessibilityObjectWrapper updateObjectBackingStore] should return the backing object.
+ https://bugs.webkit.org/show_bug.cgi?id=208153
+
+ Reviewed by Chris Fleizach.
+
+ Covered by existing tests.
+
+ Currently in many WebAccessibilityObjectWrapper's methods we call
+ updateObjectBackingStore followed by one or more calls to
+ axBackingObject. This patch eliminates this unnecessary call by making
+ updateObjectBackingStore return the backing object. It also cleans up
+ other unnecessary calls to axBackingObject and does some minor code
+ cleanup.
+
+ * accessibility/mac/WebAccessibilityObjectWrapperBase.h:
+ * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+ (-[WebAccessibilityObjectWrapperBase updateObjectBackingStore]):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper ALLOW_DEPRECATED_IMPLEMENTATIONS_END]):
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+ (-[WebAccessibilityObjectWrapper accessibilityFocusedUIElement]):
+ (-[WebAccessibilityObjectWrapper accessibilityHitTest:]):
+ (-[WebAccessibilityObjectWrapper accessibilityIsAttributeSettable:]):
+ (-[WebAccessibilityObjectWrapper _accessibilityPerformPressAction]):
+ (-[WebAccessibilityObjectWrapper _accessibilityPerformIncrementAction]):
+ (-[WebAccessibilityObjectWrapper _accessibilityPerformDecrementAction]):
+ (-[WebAccessibilityObjectWrapper accessibilityPerformAction:]):
+ (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]):
+ (-[WebAccessibilityObjectWrapper accessibilityInsertText:]):
+ (-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+ (-[WebAccessibilityObjectWrapper accessibilityIndexOfChild:]):
+ (-[WebAccessibilityObjectWrapper accessibilityArrayAttributeCount:]):
+ (-[WebAccessibilityObjectWrapper accessibilityArrayAttributeValues:index:maxCount:]):
+
2020-02-24 Zalan Bujtas <za...@apple.com>
[LFC][IFC][Floats] Fix float box handling inside unbreakable content
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h (257254 => 257255)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h 2020-02-24 22:08:30 UTC (rev 257254)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h 2020-02-24 22:18:59 UTC (rev 257255)
@@ -61,7 +61,9 @@
@property (nonatomic, assign) WebCore::AXID identifier;
-- (BOOL)updateObjectBackingStore;
+// Updates the underlying object and accessibility hierarchy , and returns the
+// corresponding AXCoreObject.
+- (WebCore::AXCoreObject*)updateObjectBackingStore;
// This can be either an AccessibilityObject or an AXIsolatedObject
- (WebCore::AXCoreObject*)axBackingObject;
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm (257254 => 257255)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm 2020-02-24 22:08:30 UTC (rev 257254)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm 2020-02-24 22:18:59 UTC (rev 257255)
@@ -335,7 +335,7 @@
[self detachAXObject];
}
-- (BOOL)updateObjectBackingStore
+- (WebCore::AXCoreObject*)updateObjectBackingStore
{
// Calling updateBackingStore() can invalidate this element so self must be retained.
// If it does become invalidated, self.axBackingObject will be nil.
@@ -343,13 +343,11 @@
CFAutorelease((__bridge CFTypeRef)self);
if (!self.axBackingObject)
- return NO;
-
+ return nil;
+
self.axBackingObject->updateBackingStore();
- if (!self.axBackingObject)
- return NO;
-
- return YES;
+
+ return self.axBackingObject;
}
- (id)attachmentView
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (257254 => 257255)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2020-02-24 22:08:30 UTC (rev 257254)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2020-02-24 22:18:59 UTC (rev 257255)
@@ -1341,9 +1341,10 @@
- (NSArray*)accessibilityActionNames
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return nil;
-
+
// All elements should get ShowMenu and ScrollToVisible.
// But certain earlier VoiceOver versions do not support scroll to visible, and it confuses them to see it in the list.
static NSArray *defaultElementActions = [[NSArray alloc] initWithObjects:NSAccessibilityShowMenuAction, NSAccessibilityScrollToVisibleAction, nil];
@@ -1357,19 +1358,19 @@
// Slider elements allow Increment/Decrement.
static NSArray *sliderActions = [[defaultElementActions arrayByAddingObjectsFromArray:[NSArray arrayWithObjects:NSAccessibilityIncrementAction, NSAccessibilityDecrementAction, nil]] retain];
-
+
NSArray *actions;
- if (self.axBackingObject->supportsPressAction())
+ if (backingObject->supportsPressAction())
actions = actionElementActions;
- else if (self.axBackingObject->isMenuRelated())
+ else if (backingObject->isMenuRelated())
actions = menuElementActions;
- else if (self.axBackingObject->isSlider())
+ else if (backingObject->isSlider())
actions = sliderActions;
- else if (self.axBackingObject->isAttachment())
+ else if (backingObject->isAttachment())
actions = [[self attachmentView] accessibilityActionNames];
else
actions = defaultElementActions;
-
+
return actions;
}
@@ -2371,10 +2372,9 @@
- (id)accessibilityAttributeValue:(NSString*)attributeName
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return nil;
- // FIXME: make updateObjectBackingStore above return the backing object.
- auto* backingObject = self.axBackingObject;
if (backingObject->isDetachedFromParent())
return nil;
@@ -3197,23 +3197,22 @@
- (id)accessibilityFocusedUIElement
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return nil;
-
- auto focusedObject = self.axBackingObject->focusedUIElement();
- if (!focusedObject)
- return nil;
-
- return focusedObject->wrapper();
+
+ auto focusedObject = backingObject->focusedUIElement();
+ return focusedObject ? focusedObject->wrapper() : nil;
}
- (id)accessibilityHitTest:(NSPoint)point
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return nil;
-
- self.axBackingObject->updateChildrenIfNecessary();
- AXCoreObject* axObject = self.axBackingObject->accessibilityHitTest(IntPoint(point));
+
+ backingObject->updateChildrenIfNecessary();
+ AXCoreObject* axObject = backingObject->accessibilityHitTest(IntPoint(point));
if (axObject) {
if (axObject->isAttachment() && [axObject->wrapper() attachmentView])
return [axObject->wrapper() attachmentView];
@@ -3226,45 +3225,45 @@
- (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return NO;
-
+
if ([attributeName isEqualToString: @"AXSelectedTextMarkerRange"])
return YES;
-
+
if ([attributeName isEqualToString: NSAccessibilityFocusedAttribute])
- return self.axBackingObject->canSetFocusAttribute();
-
+ return backingObject->canSetFocusAttribute();
+
if ([attributeName isEqualToString: NSAccessibilityValueAttribute])
- return self.axBackingObject->canSetValueAttribute();
-
+ return backingObject->canSetValueAttribute();
+
if ([attributeName isEqualToString: NSAccessibilitySelectedAttribute])
- return self.axBackingObject->canSetSelectedAttribute();
-
+ return backingObject->canSetSelectedAttribute();
+
if ([attributeName isEqualToString: NSAccessibilitySelectedChildrenAttribute])
- return self.axBackingObject->canSetSelectedChildrenAttribute();
-
+ return backingObject->canSetSelectedChildrenAttribute();
+
if ([attributeName isEqualToString:NSAccessibilityDisclosingAttribute]
|| [attributeName isEqualToString:NSAccessibilityExpandedAttribute])
- return self.axBackingObject->canSetExpandedAttribute();
-
+ return backingObject->canSetExpandedAttribute();
+
if ([attributeName isEqualToString:NSAccessibilitySelectedRowsAttribute])
return YES;
-
- if ([attributeName isEqualToString: NSAccessibilitySelectedTextAttribute] ||
- [attributeName isEqualToString: NSAccessibilitySelectedTextRangeAttribute] ||
- [attributeName isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute])
- return self.axBackingObject->canSetTextRangeAttributes();
-
+
+ if ([attributeName isEqualToString: NSAccessibilitySelectedTextAttribute]
+ || [attributeName isEqualToString: NSAccessibilitySelectedTextRangeAttribute]
+ || [attributeName isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute])
+ return backingObject->canSetTextRangeAttributes();
+
if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute])
return YES;
-
- if (self.axBackingObject->isWebArea() && [attributeName isEqualToString:NSAccessibilityPreventKeyboardDOMEventDispatchAttribute])
+
+ if (backingObject->isWebArea()
+ && ([attributeName isEqualToString:NSAccessibilityPreventKeyboardDOMEventDispatchAttribute]
+ || [attributeName isEqualToString:NSAccessibilityCaretBrowsingEnabledAttribute]))
return YES;
-
- if (self.axBackingObject->isWebArea() && [attributeName isEqualToString:NSAccessibilityCaretBrowsingEnabledAttribute])
- return YES;
-
+
return NO;
}
@@ -3281,12 +3280,13 @@
- (BOOL)accessibilityIsIgnored
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return YES;
-
- if (self.axBackingObject->isAttachment())
+
+ if (backingObject->isAttachment())
return [[self attachmentView] accessibilityIsIgnored];
- return self.axBackingObject->accessibilityIsIgnored();
+ return backingObject->accessibilityIsIgnored();
}
ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
@@ -3293,10 +3293,9 @@
- (NSArray* )accessibilityParameterizedAttributeNames
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return nil;
- // FIXME: make updateObjectBackingStore above return the backing object.
- auto* backingObject = self.axBackingObject;
if (backingObject->isAttachment())
return nil;
@@ -3408,13 +3407,14 @@
- (void)_accessibilityPerformPressAction
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return;
-
- if (self.axBackingObject->isAttachment())
+
+ if (backingObject->isAttachment())
[[self attachmentView] accessibilityPerformAction:NSAccessibilityPressAction];
else
- self.axBackingObject->press();
+ backingObject->press();
}
- (void)accessibilityPerformIncrementAction
@@ -3426,13 +3426,14 @@
- (void)_accessibilityPerformIncrementAction
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return;
-
- if (self.axBackingObject->isAttachment())
+
+ if (backingObject->isAttachment())
[[self attachmentView] accessibilityPerformAction:NSAccessibilityIncrementAction];
else
- self.axBackingObject->increment();
+ backingObject->increment();
}
- (void)accessibilityPerformDecrementAction
@@ -3444,13 +3445,14 @@
- (void)_accessibilityPerformDecrementAction
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return;
-
- if (self.axBackingObject->isAttachment())
+
+ if (backingObject->isAttachment())
[[self attachmentView] accessibilityPerformAction:NSAccessibilityDecrementAction];
else
- self.axBackingObject->decrement();
+ backingObject->decrement();
}
ALLOW_DEPRECATED_DECLARATIONS_END
@@ -3526,31 +3528,26 @@
- (void)accessibilityPerformAction:(NSString*)action
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return;
-
+
if ([action isEqualToString:NSAccessibilityPressAction])
[self accessibilityPerformPressAction];
-
- // Used in layout tests, so that we don't have to wait for the async press action.
- else if ([action isEqualToString:@"AXSyncPressAction"])
+ else if ([action isEqualToString:@"AXSyncPressAction"]) {
+ // Used in layout tests, so that we don't have to wait for the async press action.
[self _accessibilityPerformPressAction];
-
+ }
else if ([action isEqualToString:@"AXSyncIncrementAction"])
[self _accessibilityPerformIncrementAction];
-
else if ([action isEqualToString:@"AXSyncDecrementAction"])
[self _accessibilityPerformDecrementAction];
-
else if ([action isEqualToString:NSAccessibilityShowMenuAction])
[self accessibilityPerformShowMenuAction];
-
else if ([action isEqualToString:NSAccessibilityIncrementAction])
[self accessibilityPerformIncrementAction];
-
else if ([action isEqualToString:NSAccessibilityDecrementAction])
[self accessibilityPerformDecrementAction];
-
else if ([action isEqualToString:NSAccessibilityScrollToVisibleAction])
[self accessibilityScrollToVisible];
}
@@ -3557,18 +3554,20 @@
- (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return NO;
-
- return self.axBackingObject->replaceTextInRange(string, PlainTextRange(range));
+
+ return backingObject->replaceTextInRange(string, PlainTextRange(range));
}
- (BOOL)accessibilityInsertText:(NSString *)text
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return NO;
- return self.axBackingObject->insertText(text);
+ return backingObject->insertText(text);
}
ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
@@ -3589,10 +3588,9 @@
- (void)_accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return;
- // FIXME: make updateObjectBackingStore above return the backing object.
- auto* backingObject = self.axBackingObject;
id textMarkerRange = nil;
NSNumber* number = nil;
@@ -3833,10 +3831,9 @@
- (id)accessibilityAttributeValue:(NSString*)attribute forParameter:(id)parameter
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return nil;
- // FIXME: make updateObjectBackingStore above return the backing object.
- auto* backingObject = self.axBackingObject;
// Basic parameter validation.
if (!attribute || !parameter)
@@ -4413,29 +4410,30 @@
// API that AppKit uses for faster access
- (NSUInteger)accessibilityIndexOfChild:(id)child
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return NSNotFound;
-
+
// Tree objects return their rows as their children. We can use the original method
// here, because we won't gain any speed up.
- if (self.axBackingObject->isTree())
+ if (backingObject->isTree())
return [super accessibilityIndexOfChild:child];
-
+
NSArray *children = self.childrenVectorArray;
if (!children.count)
return [[self renderWidgetChildren] indexOfObject:child];
-
+
NSUInteger count = [children count];
for (NSUInteger i = 0; i < count; ++i) {
WebAccessibilityObjectWrapper *wrapper = children[i];
- auto backingObject = [wrapper axBackingObject];
- if (!backingObject)
+ auto* object = wrapper.axBackingObject;
+ if (!object)
continue;
- if (wrapper == child || (backingObject->isAttachment() && [wrapper attachmentView] == child))
+ if (wrapper == child || (object->isAttachment() && [wrapper attachmentView] == child))
return i;
}
-
+
return NSNotFound;
}
@@ -4442,22 +4440,23 @@
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
- (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return 0;
-
+
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
// Tree items object returns a different set of children than those that are in children()
// because an AXOutline (the mac role is becomes) has some odd stipulations.
- if (self.axBackingObject->isTree() || self.axBackingObject->isTreeItem())
+ if (backingObject->isTree() || backingObject->isTreeItem())
return [[self accessibilityAttributeValue:NSAccessibilityChildrenAttribute] count];
-
+
auto childrenSize = self.childrenVectorSize;
if (!childrenSize)
return [[self renderWidgetChildren] count];
-
+
return childrenSize;
}
-
+
return [super accessibilityArrayAttributeCount:attribute];
}
ALLOW_DEPRECATED_DECLARATIONS_END
@@ -4464,36 +4463,37 @@
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount
{
- if (![self updateObjectBackingStore])
+ auto* backingObject = self.updateObjectBackingStore;
+ if (!backingObject)
return nil;
-
+
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
if (!self.childrenVectorSize) {
NSArray *children = [self renderWidgetChildren];
if (!children)
return nil;
-
+
NSUInteger childCount = [children count];
if (index >= childCount)
return nil;
-
+
NSUInteger arrayLength = std::min(childCount - index, maxCount);
return [children subarrayWithRange:NSMakeRange(index, arrayLength)];
}
- if (self.axBackingObject->isTree() || self.axBackingObject->isTreeItem()) {
+ if (backingObject->isTree() || backingObject->isTreeItem()) {
// Tree objects return their rows as their children & tree items return their contents sans rows.
// We can use the original method in this case.
return [super accessibilityArrayAttributeValues:attribute index:index maxCount:maxCount];
}
-
+
auto children = self.childrenVectorArray;
unsigned childCount = [children count];
if (index >= childCount)
return nil;
-
+
unsigned available = std::min(childCount - index, maxCount);
-
+
NSMutableArray *subarray = [NSMutableArray arrayWithCapacity:available];
for (unsigned added = 0; added < available; ++index, ++added) {
WebAccessibilityObjectWrapper* wrapper = children[index];
@@ -4501,10 +4501,10 @@
BOOL isAttachment = [wrapper isKindOfClass:[WebAccessibilityObjectWrapper class]] && wrapper.axBackingObject->isAttachment() && [wrapper attachmentView];
[subarray addObject:isAttachment ? [wrapper attachmentView] : wrapper];
}
-
+
return subarray;
}
-
+
return [super accessibilityArrayAttributeValues:attribute index:index maxCount:maxCount];
}