Title: [270281] trunk/Source/WebCore
Revision
270281
Author
[email protected]
Date
2020-11-30 18:37:53 -0800 (Mon, 30 Nov 2020)

Log Message

[WebAccessibilityObjectWrapper doAXAttributedStringForRange] needs to run on the main thread.
https://bugs.webkit.org/show_bug.cgi?id=219360

Reviewed by Chris Fleizach.

Dispatch this call to the main thread in isolated tree mode.
In addition, moved several TextMarker static functions and ObjectiveC
wrappers out of the WebAccessibilityObjectWrapper implementation in an
ongoing effort to move core code out of the accessibility platform
wrapper.

* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::textMarkerRangeFromMarkers):
(WebCore::startOrEndTextMarkerForRange):
(WebCore::textMarkerRangeFromRange):
* accessibility/mac/WebAccessibilityObjectWrapperMac.h:
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper doAXAttributedStringForRange:]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
(-[WebAccessibilityObjectWrapper textMarkerRangeFromRange:]): Deleted,
not needed, instead call the C function directly.
(textMarkerRangeFromRange): Deleted, moved to AXObjectCacheMac.mm.
(-[WebAccessibilityObjectWrapper startOrEndTextMarkerForRange:isStart:]):
Deleted, not needed, instead call the C function directly.
(startOrEndTextmarkerForRange): Deleted, Moved to AXObjectCacheMac.mm.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270280 => 270281)


--- trunk/Source/WebCore/ChangeLog	2020-12-01 02:18:01 UTC (rev 270280)
+++ trunk/Source/WebCore/ChangeLog	2020-12-01 02:37:53 UTC (rev 270281)
@@ -1,3 +1,31 @@
+2020-11-30  Andres Gonzalez  <[email protected]>
+
+        [WebAccessibilityObjectWrapper doAXAttributedStringForRange] needs to run on the main thread.
+        https://bugs.webkit.org/show_bug.cgi?id=219360
+
+        Reviewed by Chris Fleizach.
+
+        Dispatch this call to the main thread in isolated tree mode.
+        In addition, moved several TextMarker static functions and ObjectiveC
+        wrappers out of the WebAccessibilityObjectWrapper implementation in an
+        ongoing effort to move core code out of the accessibility platform
+        wrapper.
+
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::textMarkerRangeFromMarkers):
+        (WebCore::startOrEndTextMarkerForRange):
+        (WebCore::textMarkerRangeFromRange):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper doAXAttributedStringForRange:]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+        (-[WebAccessibilityObjectWrapper textMarkerRangeFromRange:]): Deleted,
+        not needed, instead call the C function directly.
+        (textMarkerRangeFromRange): Deleted, moved to AXObjectCacheMac.mm.
+        (-[WebAccessibilityObjectWrapper startOrEndTextMarkerForRange:isStart:]):
+        Deleted, not needed, instead call the C function directly.
+        (startOrEndTextmarkerForRange): Deleted, Moved to AXObjectCacheMac.mm.
+
 2020-11-30  Simon Fraser  <[email protected]>
 
         Pass OptionSet<EventHandling> to various wheel event handler functions

Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (270280 => 270281)


--- trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2020-12-01 02:18:01 UTC (rev 270280)
+++ trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2020-12-01 02:37:53 UTC (rev 270281)
@@ -601,7 +601,7 @@
     return CFBridgingRelease(AXTextMarkerRangeCreate(kCFAllocatorDefault, (AXTextMarkerRef)startMarker, (AXTextMarkerRef)endMarker));
 }
 
-id textMarkerRangeFromMarkers(id textMarker1, id textMarker2)
+static id textMarkerRangeFromMarkers(id textMarker1, id textMarker2)
 {
     if (!textMarker1 || !textMarker2)
         return nil;
@@ -634,6 +634,31 @@
     return textMarkerRangeFromMarkers(startTextMarker, endTextMarker);
 }
 
+id startOrEndTextMarkerForRange(AXObjectCache* cache, const Optional<SimpleRange>& range, bool isStart)
+{
+    ASSERT(isMainThread());
+    if (!cache || !range)
+        return nil;
+
+    TextMarkerData textMarkerData;
+    cache->startOrEndTextMarkerDataForRange(textMarkerData, *range, isStart);
+    if (!textMarkerData.axID)
+        return nil;
+
+    return CFBridgingRelease(AXTextMarkerCreate(kCFAllocatorDefault, (const UInt8*)&textMarkerData, sizeof(textMarkerData)));
 }
 
+id textMarkerRangeFromRange(AXObjectCache* cache, const Optional<SimpleRange>& range)
+{
+    ASSERT(isMainThread());
+    if (!cache)
+        return nil;
+
+    id startTextMarker = startOrEndTextMarkerForRange(cache, range, true);
+    id endTextMarker = startOrEndTextMarkerForRange(cache, range, false);
+    return textMarkerRangeFromMarkers(startTextMarker, endTextMarker);
+}
+
+}
+
 #endif // ENABLE(ACCESSIBILITY) && PLATFORM(MAC)

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.h (270280 => 270281)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.h	2020-12-01 02:18:01 UTC (rev 270280)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.h	2020-12-01 02:37:53 UTC (rev 270281)
@@ -49,8 +49,9 @@
 
 namespace WebCore {
 
-id textMarkerRangeFromMarkers(id textMarker1, id textMarker2);
 id textMarkerForVisiblePosition(AXObjectCache*, const VisiblePosition&);
 id textMarkerRangeFromVisiblePositions(AXObjectCache*, const VisiblePosition&, const VisiblePosition&);
+id startOrEndTextMarkerForRange(AXObjectCache*, const Optional<SimpleRange>&, bool isStart);
+id textMarkerRangeFromRange(AXObjectCache*, const Optional<SimpleRange>&);
 
 }

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (270280 => 270281)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2020-12-01 02:18:01 UTC (rev 270280)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2020-12-01 02:37:53 UTC (rev 270281)
@@ -778,41 +778,6 @@
     return cache->accessibilityObjectForTextMarkerData(textMarkerData);
 }
 
-- (id)textMarkerRangeFromRange:(const Optional<SimpleRange>&)range
-{
-    if (auto* backingObject = self.axBackingObject)
-        return textMarkerRangeFromRange(backingObject->axObjectCache(), range);
-    return nil;
-}
-
-static id textMarkerRangeFromRange(AXObjectCache* cache, const Optional<SimpleRange>& range)
-{
-    id startTextMarker = startOrEndTextmarkerForRange(cache, range, true);
-    id endTextMarker = startOrEndTextmarkerForRange(cache, range, false);
-    return textMarkerRangeFromMarkers(startTextMarker, endTextMarker);
-}
-
-- (id)startOrEndTextMarkerForRange:(const Optional<SimpleRange>&)range isStart:(BOOL)isStart
-{
-    return startOrEndTextmarkerForRange(self.axBackingObject->axObjectCache(), range, isStart);
-}
-
-static id startOrEndTextmarkerForRange(AXObjectCache* cache, const Optional<SimpleRange>& range, bool isStart)
-{
-    if (!cache)
-        return nil;
-
-    if (!range)
-        return nil;
-
-    TextMarkerData textMarkerData;
-    cache->startOrEndTextMarkerDataForRange(textMarkerData, *range, isStart);
-    if (!textMarkerData.axID)
-        return nil;
-
-    return CFBridgingRelease(AXTextMarkerCreate(kCFAllocatorDefault, (const UInt8*)&textMarkerData, sizeof(textMarkerData)));
-}
-
 static id nextTextMarkerForCharacterOffset(AXObjectCache* cache, CharacterOffset& characterOffset)
 {
     if (!cache)
@@ -3623,8 +3588,14 @@
 // object that is specified by the given range.
 - (NSAttributedString *)doAXAttributedStringForRange:(NSRange)range
 {
-    auto webRange = self.axBackingObject->rangeForPlainTextRange(range);
-    return [self doAXAttributedStringForTextMarkerRange:[self textMarkerRangeFromRange:webRange] spellCheck:YES];
+    return Accessibility::retrieveAutoreleasedValueFromMainThread<NSAttributedString *>([&range, protectedSelf = retainPtr(self)] () -> RetainPtr<NSAttributedString> {
+        auto* backingObject = protectedSelf.get().axBackingObject;
+        if (!backingObject)
+            return nil;
+
+        auto webRange = backingObject->rangeForPlainTextRange(range);
+        return [protectedSelf doAXAttributedStringForTextMarkerRange:textMarkerRangeFromRange(backingObject->axObjectCache(), webRange) spellCheck:YES];
+    });
 }
 
 // FIXME: No reason for this to be a method instead of a function; can get document from range.
@@ -3953,7 +3924,7 @@
             if (ranges.isEmpty())
                 return nil;
             return createNSArray(ranges, [&] (auto& range) {
-                return [protectedSelf textMarkerRangeFromRange:range];
+                return textMarkerRangeFromRange(backingObject->axObjectCache(), range);
             }).autorelease();
         });
     }
@@ -4029,7 +4000,7 @@
                 return nil;
 
             if (auto misspellingRange = backingObject->misspellingRange(*criteria.first, criteria.second))
-                return [protectedSelf textMarkerRangeFromRange:*misspellingRange];
+                return textMarkerRangeFromRange(backingObject->axObjectCache(), *misspellingRange);
             return nil;
         });
     }
@@ -4068,8 +4039,8 @@
     }
 
     if ([attribute isEqualToString:@"AXTextMarkerRangeForUIElement"]) {
-        return Accessibility::retrieveAutoreleasedValueFromMainThread<id>([&uiElement, protectedSelf = retainPtr(self)] () -> RetainPtr<id> {
-            return [protectedSelf textMarkerRangeFromRange:uiElement.get()->elementRange()];
+        return Accessibility::retrieveAutoreleasedValueFromMainThread<id>([&uiElement] () -> RetainPtr<id> {
+            return textMarkerRangeFromRange(uiElement.get()->axObjectCache(), uiElement.get()->elementRange());
         });
     }
 
@@ -4221,7 +4192,7 @@
             CharacterOffset characterOffset1 = [protectedSelf characterOffsetForTextMarker:textMarker1];
             CharacterOffset characterOffset2 = [protectedSelf characterOffsetForTextMarker:textMarker2];
             auto range = cache->rangeForUnorderedCharacterOffsets(characterOffset1, characterOffset2);
-            return [protectedSelf textMarkerRangeFromRange:range];
+            return textMarkerRangeFromRange(cache, range);
         });
     }
 
@@ -4315,16 +4286,16 @@
 
     // Used only by DumpRenderTree (so far).
     if ([attribute isEqualToString:@"AXStartTextMarkerForTextMarkerRange"]) {
-        return Accessibility::retrieveAutoreleasedValueFromMainThread<id>([&textMarkerRange, protectedSelf = retainPtr(self)] () -> RetainPtr<id> {
+        return Accessibility::retrieveAutoreleasedValueFromMainThread<id>([&textMarkerRange, &backingObject, protectedSelf = retainPtr(self)] () -> RetainPtr<id> {
             auto range = [protectedSelf rangeForTextMarkerRange:textMarkerRange];
-            return [protectedSelf startOrEndTextMarkerForRange:range isStart:YES];
+            return startOrEndTextMarkerForRange(backingObject->axObjectCache(), range, true);
         });
     }
 
     if ([attribute isEqualToString:@"AXEndTextMarkerForTextMarkerRange"]) {
-        return Accessibility::retrieveAutoreleasedValueFromMainThread<id>([&textMarkerRange, protectedSelf = retainPtr(self)] () -> RetainPtr<id> {
+        return Accessibility::retrieveAutoreleasedValueFromMainThread<id>([&textMarkerRange, &backingObject, protectedSelf = retainPtr(self)] () -> RetainPtr<id> {
             auto range = [protectedSelf rangeForTextMarkerRange:textMarkerRange];
-            return [protectedSelf startOrEndTextMarkerForRange:range isStart:NO];
+            return startOrEndTextMarkerForRange(backingObject->axObjectCache(), range, false);
         });
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to