Changeset 286102 in webkit
- Timestamp:
- Nov 21, 2021, 10:35:21 AM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h (modified) (3 diffs)
-
WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm (modified) (49 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r286093 r286102 1 2021-11-21 Andres Gonzalez <andresg_22@apple.com> 2 3 Dispatch all AccessibilityUIElement parameterized attribute requests to the AX thread for isolated tree mode. 4 https://bugs.webkit.org/show_bug.cgi?id=233377 5 <rdar://problem/85613334> 6 7 Reviewed by Chris Fleizach. 8 9 To simulate AT client requests in isolated tree mode, all parameterized 10 attribute requests should be dispatched to the AX thread. 11 This patch adds AccessibilityUIElement::attributeValueForParameter that 12 does the appropriate dispatch to the AX thread. 13 14 * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: 15 * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: 16 (WTR::attributeValue): 17 (WTR::AccessibilityUIElement::attributeValue const): 18 (WTR::AccessibilityUIElement::attributeValueForParameter const): 19 (WTR::AccessibilityUIElement::lineForIndex): 20 (WTR::AccessibilityUIElement::rangeForLine): 21 (WTR::AccessibilityUIElement::rangeForPosition): 22 (WTR::AccessibilityUIElement::boundsForRange): 23 (WTR::AccessibilityUIElement::stringForRange): 24 (WTR::AccessibilityUIElement::attributedStringForRange): 25 (WTR::AccessibilityUIElement::attributedStringRangeIsMisspelled): 26 (WTR::AccessibilityUIElement::uiElementCountForSearchPredicate): 27 (WTR::AccessibilityUIElement::uiElementForSearchPredicate): 28 (WTR::AccessibilityUIElement::selectTextWithCriteria): 29 (WTR::AccessibilityUIElement::searchTextWithCriteria): 30 (WTR::AccessibilityUIElement::cellForColumnAndRow): 31 (WTR::AccessibilityUIElement::lineTextMarkerRangeForTextMarker): 32 (WTR::AccessibilityUIElement::lineIndexForTextMarker const): 33 (WTR::AccessibilityUIElement::misspellingTextMarkerRange): 34 (WTR::AccessibilityUIElement::textMarkerRangeForElement): 35 (WTR::AccessibilityUIElement::textMarkerRangeLength): 36 (WTR::AccessibilityUIElement::previousTextMarker): 37 (WTR::AccessibilityUIElement::nextTextMarker): 38 (WTR::AccessibilityUIElement::stringForTextMarkerRange): 39 (WTR::AccessibilityUIElement::textMarkerRangeForMarkers): 40 (WTR::AccessibilityUIElement::textMarkerRangeForRange): 41 (WTR::AccessibilityUIElement::resetSelectedTextMarkerRange): 42 (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange): 43 (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange): 44 (WTR::AccessibilityUIElement::endTextMarkerForBounds): 45 (WTR::AccessibilityUIElement::startTextMarkerForBounds): 46 (WTR::AccessibilityUIElement::textMarkerForPoint): 47 (WTR::AccessibilityUIElement::accessibilityElementForTextMarker): 48 (WTR::AccessibilityUIElement::attributedStringForTextMarkerRange): 49 (WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions): 50 (WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute): 51 (WTR::AccessibilityUIElement::indexForTextMarker): 52 (WTR::AccessibilityUIElement::isTextMarkerValid): 53 (WTR::AccessibilityUIElement::textMarkerForIndex): 54 (WTR::AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker): 55 (WTR::AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker): 56 (WTR::AccessibilityUIElement::previousWordStartTextMarkerForTextMarker): 57 (WTR::AccessibilityUIElement::nextWordEndTextMarkerForTextMarker): 58 (WTR::AccessibilityUIElement::paragraphTextMarkerRangeForTextMarker): 59 (WTR::AccessibilityUIElement::previousParagraphStartTextMarkerForTextMarker): 60 (WTR::AccessibilityUIElement::nextParagraphEndTextMarkerForTextMarker): 61 (WTR::AccessibilityUIElement::sentenceTextMarkerRangeForTextMarker): 62 (WTR::AccessibilityUIElement::previousSentenceStartTextMarkerForTextMarker): 63 (WTR::AccessibilityUIElement::nextSentenceEndTextMarkerForTextMarker): 64 (WTR::_convertMathMultiscriptPairsToString): 65 1 66 2021-11-19 Carlos Garcia Campos <cgarcia@igalia.com> 2 67 -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
r285996 r286102 65 65 // Helper functions that dispatch the corresponding AccessibilityObjectWrapper method to the AX secondary thread when appropriate. 66 66 friend RetainPtr<NSArray> supportedAttributes(id); 67 friend RetainPtr<id> attributeValue(id, NSString *);68 67 friend void setAttributeValue(id, NSString *, id, bool synchronous); 69 68 #endif … … 134 133 bool boolAttributeValue(JSStringRef attribute); 135 134 #if PLATFORM(MAC) 135 RetainPtr<id> attributeValue(NSString *) const; 136 136 void attributeValueAsync(JSStringRef attribute, JSValueRef callback); 137 137 #else … … 402 402 403 403 #if PLATFORM(MAC) 404 RetainPtr<id> attributeValue (NSString *) const;404 RetainPtr<id> attributeValueForParameter(NSString *, id) const; 405 405 NSString *descriptionOfValue(id valueObject) const; 406 406 #endif -
trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
r285872 r286102 140 140 } 141 141 142 RetainPtr<id> attributeValue(id element, NSString *attribute) 143 { 144 RetainPtr<id> value; 145 146 BEGIN_AX_OBJC_EXCEPTIONS 147 AccessibilityUIElement::s_controller->executeOnAXThreadAndWait([&element, &attribute, &value] { 148 // The given `element` may not respond to `accessibilityAttributeValue`, so first check to see if it responds to the attribute-specific selector. 149 if ([attribute isEqual:NSAccessibilityChildrenAttribute] && [element respondsToSelector:@selector(accessibilityChildren)]) 150 value = [element accessibilityChildren]; 151 else if ([attribute isEqual:NSAccessibilityDescriptionAttribute] && [element respondsToSelector:@selector(accessibilityLabel)]) 152 value = [element accessibilityLabel]; 153 else if ([attribute isEqual:NSAccessibilityParentAttribute] && [element respondsToSelector:@selector(accessibilityParent)]) 154 value = [element accessibilityParent]; 155 else if ([attribute isEqual:NSAccessibilityRoleAttribute] && [element respondsToSelector:@selector(accessibilityRole)]) 156 value = [element accessibilityRole]; 157 else if ([attribute isEqual:NSAccessibilityValueAttribute] && [element respondsToSelector:@selector(accessibilityValue)]) 158 value = [element accessibilityValue]; 159 else if ([attribute isEqual:NSAccessibilityFocusedUIElementAttribute] && [element respondsToSelector:@selector(accessibilityFocusedUIElement)]) 160 value = [element accessibilityFocusedUIElement]; 161 else 162 value = [element accessibilityAttributeValue:attribute]; 163 }); 164 END_AX_OBJC_EXCEPTIONS 165 166 return value; 142 static id attributeValue(id element, NSString *attribute) 143 { 144 // The given `element` may not respond to `accessibilityAttributeValue`, so first check to see if it responds to the attribute-specific selector. 145 if ([attribute isEqual:NSAccessibilityChildrenAttribute] && [element respondsToSelector:@selector(accessibilityChildren)]) 146 return [element accessibilityChildren]; 147 if ([attribute isEqual:NSAccessibilityDescriptionAttribute] && [element respondsToSelector:@selector(accessibilityLabel)]) 148 return [element accessibilityLabel]; 149 if ([attribute isEqual:NSAccessibilityParentAttribute] && [element respondsToSelector:@selector(accessibilityParent)]) 150 return [element accessibilityParent]; 151 if ([attribute isEqual:NSAccessibilityRoleAttribute] && [element respondsToSelector:@selector(accessibilityRole)]) 152 return [element accessibilityRole]; 153 if ([attribute isEqual:NSAccessibilityValueAttribute] && [element respondsToSelector:@selector(accessibilityValue)]) 154 return [element accessibilityValue]; 155 if ([attribute isEqual:NSAccessibilityFocusedUIElementAttribute] && [element respondsToSelector:@selector(accessibilityFocusedUIElement)]) 156 return [element accessibilityFocusedUIElement]; 157 158 return [element accessibilityAttributeValue:attribute]; 167 159 } 168 160 … … 316 308 } 317 309 318 inline RetainPtr<id> AccessibilityUIElement::attributeValue(NSString *attributeName) const 319 { 320 return WTR::attributeValue(m_element.get(), attributeName); 310 RetainPtr<id> AccessibilityUIElement::attributeValue(NSString *attributeName) const 311 { 312 RetainPtr<id> value; 313 314 BEGIN_AX_OBJC_EXCEPTIONS 315 s_controller->executeOnAXThreadAndWait([this, &attributeName, &value] { 316 value = WTR::attributeValue(m_element.get(), attributeName); 317 }); 318 END_AX_OBJC_EXCEPTIONS 319 320 return value; 321 } 322 323 RetainPtr<id> AccessibilityUIElement::attributeValueForParameter(NSString *attributeName, id parameter) const 324 { 325 RetainPtr<id> value; 326 327 BEGIN_AX_OBJC_EXCEPTIONS 328 s_controller->executeOnAXThreadAndWait([this, &attributeName, ¶meter, &value] { 329 value = [m_element accessibilityAttributeValue:attributeName forParameter:parameter]; 330 }); 331 END_AX_OBJC_EXCEPTIONS 332 333 return value; 321 334 } 322 335 … … 1132 1145 { 1133 1146 BEGIN_AX_OBJC_EXCEPTIONS 1134 id value = [m_element accessibilityAttributeValue:NSAccessibilityLineForIndexParameterizedAttribute forParameter:@(index)];1147 auto value = attributeValueForParameter(NSAccessibilityLineForIndexParameterizedAttribute, @(index)); 1135 1148 if ([value isKindOfClass:[NSNumber class]]) 1136 1149 return [(NSNumber *)value intValue]; … … 1143 1156 { 1144 1157 BEGIN_AX_OBJC_EXCEPTIONS 1145 id value = [m_element accessibilityAttributeValue:NSAccessibilityRangeForLineParameterizedAttribute forParameter:@(line)];1158 auto value = attributeValueForParameter(NSAccessibilityRangeForLineParameterizedAttribute, @(line)); 1146 1159 if ([value isKindOfClass:[NSValue class]]) 1147 1160 return [NSStringFromRange([value rangeValue]) createJSStringRef]; 1148 1161 END_AX_OBJC_EXCEPTIONS 1149 1162 1150 1163 return nullptr; 1151 1164 } … … 1154 1167 { 1155 1168 BEGIN_AX_OBJC_EXCEPTIONS 1156 id value = [m_element accessibilityAttributeValue:NSAccessibilityRangeForPositionParameterizedAttribute forParameter:[NSValue valueWithPoint:NSMakePoint(x, y)]];1169 auto value = attributeValueForParameter(NSAccessibilityRangeForPositionParameterizedAttribute, [NSValue valueWithPoint:NSMakePoint(x, y)]); 1157 1170 if ([value isKindOfClass:[NSValue class]]) 1158 1171 return [NSStringFromRange([value rangeValue]) createJSStringRef]; … … 1166 1179 NSRange range = NSMakeRange(location, length); 1167 1180 BEGIN_AX_OBJC_EXCEPTIONS 1168 id value = [m_element accessibilityAttributeValue:NSAccessibilityBoundsForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]];1181 auto value = attributeValueForParameter(NSAccessibilityBoundsForRangeParameterizedAttribute, [NSValue valueWithRange:range]); 1169 1182 NSRect rect = NSMakeRect(0,0,0,0); 1170 1183 if ([value isKindOfClass:[NSValue class]]) 1171 1184 rect = [value rectValue]; 1172 1185 1173 1186 // don't return position information because it is platform dependent 1174 1187 NSMutableString* boundsDescription = [NSMutableString stringWithFormat:@"{{%f, %f}, {%f, %f}}",-1.0f,-1.0f,rect.size.width,rect.size.height]; 1175 1188 return [boundsDescription createJSStringRef]; 1176 1189 END_AX_OBJC_EXCEPTIONS 1190 1191 return nullptr; 1192 } 1193 1194 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned location, unsigned length) 1195 { 1196 NSRange range = NSMakeRange(location, length); 1197 BEGIN_AX_OBJC_EXCEPTIONS 1198 auto string = attributeValueForParameter(NSAccessibilityStringForRangeParameterizedAttribute, [NSValue valueWithRange:range]); 1199 if (![string isKindOfClass:[NSString class]]) 1200 return nullptr; 1201 1202 return [string createJSStringRef]; 1203 END_AX_OBJC_EXCEPTIONS 1177 1204 1178 1205 return nullptr; 1179 1206 } 1180 1207 1181 JSRetainPtr<JSStringRef> AccessibilityUIElement:: stringForRange(unsigned location, unsigned length)1208 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length) 1182 1209 { 1183 1210 NSRange range = NSMakeRange(location, length); 1184 1211 BEGIN_AX_OBJC_EXCEPTIONS 1185 id string = [m_element accessibilityAttributeValue:NSAccessibilityStringForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]]; 1186 if (![string isKindOfClass:[NSString class]]) 1187 return nullptr; 1188 1189 return [string createJSStringRef]; 1190 END_AX_OBJC_EXCEPTIONS 1191 1192 return nullptr; 1193 } 1194 1195 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length) 1196 { 1197 NSRange range = NSMakeRange(location, length); 1198 BEGIN_AX_OBJC_EXCEPTIONS 1199 NSAttributedString* string = [m_element accessibilityAttributeValue:NSAccessibilityAttributedStringForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]]; 1212 auto string = attributeValueForParameter(NSAccessibilityAttributedStringForRangeParameterizedAttribute, [NSValue valueWithRange:range]); 1200 1213 if (![string isKindOfClass:[NSAttributedString class]]) 1201 1214 return nullptr; 1202 1215 1203 1216 NSString* stringWithAttrs = [string description]; 1204 1217 return [stringWithAttrs createJSStringRef]; 1205 1218 END_AX_OBJC_EXCEPTIONS 1206 1219 1207 1220 return nullptr; 1208 1221 } … … 1212 1225 NSRange range = NSMakeRange(location, length); 1213 1226 BEGIN_AX_OBJC_EXCEPTIONS 1214 NSAttributedString* string = [m_element accessibilityAttributeValue:NSAccessibilityAttributedStringForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]];1227 auto string = attributeValueForParameter(NSAccessibilityAttributedStringForRangeParameterizedAttribute, [NSValue valueWithRange:range]); 1215 1228 if (![string isKindOfClass:[NSAttributedString class]]) 1216 1229 return false; … … 1224 1237 return misspelled; 1225 1238 END_AX_OBJC_EXCEPTIONS 1226 1239 1227 1240 return false; 1228 1241 } … … 1232 1245 BEGIN_AX_OBJC_EXCEPTIONS 1233 1246 NSDictionary *parameterizedAttribute = searchPredicateParameterizedAttributeForSearchCriteria(context, startElement, isDirectionNext, UINT_MAX, searchKey, searchText, visibleOnly, immediateDescendantsOnly); 1234 id value = [m_element accessibilityAttributeValue:@"AXUIElementCountForSearchPredicate" forParameter:parameterizedAttribute];1247 auto value = attributeValueForParameter(@"AXUIElementCountForSearchPredicate", parameterizedAttribute); 1235 1248 if ([value isKindOfClass:[NSNumber class]]) 1236 1249 return [value unsignedIntValue]; … … 1244 1257 BEGIN_AX_OBJC_EXCEPTIONS 1245 1258 NSDictionary *parameterizedAttribute = searchPredicateParameterizedAttributeForSearchCriteria(context, startElement, isDirectionNext, 1, searchKey, searchText, visibleOnly, immediateDescendantsOnly); 1246 id searchResults = [m_element accessibilityAttributeValue:@"AXUIElementsForSearchPredicate" forParameter:parameterizedAttribute];1259 auto searchResults = attributeValueForParameter(@"AXUIElementsForSearchPredicate", parameterizedAttribute); 1247 1260 if ([searchResults isKindOfClass:[NSArray class]]) { 1248 1261 if (id lastResult = [searchResults lastObject]) … … 1250 1263 } 1251 1264 END_AX_OBJC_EXCEPTIONS 1252 1265 1253 1266 return nullptr; 1254 1267 } … … 1258 1271 BEGIN_AX_OBJC_EXCEPTIONS 1259 1272 NSDictionary *parameterizedAttribute = selectTextParameterizedAttributeForCriteria(context, ambiguityResolution, searchStrings, replacementString, activity); 1260 RetainPtr<id> result; 1261 s_controller->executeOnAXThreadAndWait([¶meterizedAttribute, &result, this] { 1262 result = [m_element accessibilityAttributeValue:@"AXSelectTextWithCriteria" forParameter:parameterizedAttribute]; 1263 }); 1264 if ([result.get() isKindOfClass:[NSString class]]) 1273 auto result = attributeValueForParameter(@"AXSelectTextWithCriteria", parameterizedAttribute); 1274 if ([result isKindOfClass:[NSString class]]) 1265 1275 return [result.get() createJSStringRef]; 1266 1276 END_AX_OBJC_EXCEPTIONS … … 1274 1284 BEGIN_AX_OBJC_EXCEPTIONS 1275 1285 NSDictionary *parameterizedAttribute = searchTextParameterizedAttributeForCriteria(context, searchStrings, startFrom, direction); 1276 id result = [m_element accessibilityAttributeValue:@"AXSearchTextWithCriteria" forParameter:parameterizedAttribute];1286 auto result = attributeValueForParameter(@"AXSearchTextWithCriteria", parameterizedAttribute); 1277 1287 if ([result isKindOfClass:[NSArray class]]) 1278 return makeJSArray(makeVector<RefPtr<AccessibilityTextMarkerRange>>(result ));1288 return makeJSArray(makeVector<RefPtr<AccessibilityTextMarkerRange>>(result.get())); 1279 1289 END_AX_OBJC_EXCEPTIONS 1280 1290 … … 1415 1425 NSArray *colRowArray = @[@(col), @(row)]; 1416 1426 BEGIN_AX_OBJC_EXCEPTIONS 1417 if ( id cell = [m_element accessibilityAttributeValue:@"AXCellForColumnAndRow" forParameter:colRowArray])1418 return AccessibilityUIElement::create(cell );1427 if (auto cell = attributeValueForParameter(@"AXCellForColumnAndRow", colRowArray)) 1428 return AccessibilityUIElement::create(cell.get()); 1419 1429 END_AX_OBJC_EXCEPTIONS 1420 1430 … … 1851 1861 1852 1862 BEGIN_AX_OBJC_EXCEPTIONS 1853 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXLineTextMarkerRangeForTextMarker" forParameter:textMarker->platformTextMarker()];1854 return AccessibilityTextMarkerRange::create(textMarkerRange );1855 END_AX_OBJC_EXCEPTIONS 1856 1863 auto textMarkerRange = attributeValueForParameter(@"AXLineTextMarkerRangeForTextMarker", textMarker->platformTextMarker()); 1864 return AccessibilityTextMarkerRange::create(textMarkerRange.get()); 1865 END_AX_OBJC_EXCEPTIONS 1866 1857 1867 return nullptr; 1858 1868 } … … 1864 1874 1865 1875 BEGIN_AX_OBJC_EXCEPTIONS 1866 return [ [m_element accessibilityAttributeValue:@"AXLineForTextMarker" forParameter:marker->platformTextMarker()]intValue];1876 return [attributeValueForParameter(@"AXLineForTextMarker", marker->platformTextMarker()) intValue]; 1867 1877 END_AX_OBJC_EXCEPTIONS 1868 1878 … … 1874 1884 BEGIN_AX_OBJC_EXCEPTIONS 1875 1885 NSDictionary *parameters = misspellingSearchParameterizedAttributeForCriteria(start, forward); 1876 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXMisspellingTextMarkerRange" forParameter:parameters];1877 return AccessibilityTextMarkerRange::create(textMarkerRange );1886 auto textMarkerRange = attributeValueForParameter(@"AXMisspellingTextMarkerRange", parameters); 1887 return AccessibilityTextMarkerRange::create(textMarkerRange.get()); 1878 1888 END_AX_OBJC_EXCEPTIONS 1879 1889 … … 1884 1894 { 1885 1895 BEGIN_AX_OBJC_EXCEPTIONS 1886 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXTextMarkerRangeForUIElement" forParameter:element->platformUIElement()];1887 return AccessibilityTextMarkerRange::create(textMarkerRange );1888 END_AX_OBJC_EXCEPTIONS 1889 1896 auto textMarkerRange = attributeValueForParameter(@"AXTextMarkerRangeForUIElement", element->platformUIElement()); 1897 return AccessibilityTextMarkerRange::create(textMarkerRange.get()); 1898 END_AX_OBJC_EXCEPTIONS 1899 1890 1900 return nullptr; 1891 1901 } … … 1897 1907 1898 1908 BEGIN_AX_OBJC_EXCEPTIONS 1899 NSNumber* lengthValue = [m_element accessibilityAttributeValue:@"AXLengthForTextMarkerRange" forParameter:range->platformTextMarkerRange()];1909 auto lengthValue = attributeValueForParameter(@"AXLengthForTextMarkerRange", range->platformTextMarkerRange()); 1900 1910 return [lengthValue intValue]; 1901 1911 END_AX_OBJC_EXCEPTIONS 1902 1912 1903 1913 return 0; 1904 1914 } … … 1910 1920 1911 1921 BEGIN_AX_OBJC_EXCEPTIONS 1912 id previousMarker = [m_element accessibilityAttributeValue:@"AXPreviousTextMarkerForTextMarker" forParameter:textMarker->platformTextMarker()];1913 return AccessibilityTextMarker::create(previousMarker );1914 END_AX_OBJC_EXCEPTIONS 1915 1922 auto previousMarker = attributeValueForParameter(@"AXPreviousTextMarkerForTextMarker", textMarker->platformTextMarker()); 1923 return AccessibilityTextMarker::create(previousMarker.get()); 1924 END_AX_OBJC_EXCEPTIONS 1925 1916 1926 return nullptr; 1917 1927 } … … 1923 1933 1924 1934 BEGIN_AX_OBJC_EXCEPTIONS 1925 id nextMarker = [m_element accessibilityAttributeValue:@"AXNextTextMarkerForTextMarker" forParameter:textMarker->platformTextMarker()];1926 return AccessibilityTextMarker::create(nextMarker );1927 END_AX_OBJC_EXCEPTIONS 1928 1935 auto nextMarker = attributeValueForParameter(@"AXNextTextMarkerForTextMarker", textMarker->platformTextMarker()); 1936 return AccessibilityTextMarker::create(nextMarker.get()); 1937 END_AX_OBJC_EXCEPTIONS 1938 1929 1939 return nullptr; 1930 1940 } … … 1936 1946 1937 1947 BEGIN_AX_OBJC_EXCEPTIONS 1938 id textString = [m_element accessibilityAttributeValue:@"AXStringForTextMarkerRange" forParameter:markerRange->platformTextMarkerRange()];1948 auto textString = attributeValueForParameter(@"AXStringForTextMarkerRange", markerRange->platformTextMarkerRange()); 1939 1949 return [textString createJSStringRef]; 1940 1950 END_AX_OBJC_EXCEPTIONS 1941 1951 1942 1952 return nullptr; 1943 1953 } … … 1953 1963 BEGIN_AX_OBJC_EXCEPTIONS 1954 1964 NSArray *textMarkers = @[startMarker->platformTextMarker(), endMarker->platformTextMarker()]; 1955 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXTextMarkerRangeForTextMarkers" forParameter:textMarkers];1956 return AccessibilityTextMarkerRange::create(textMarkerRange );1965 auto textMarkerRange = attributeValueForParameter(@"AXTextMarkerRangeForTextMarkers", textMarkers); 1966 return AccessibilityTextMarkerRange::create(textMarkerRange.get()); 1957 1967 END_AX_OBJC_EXCEPTIONS 1958 1968 … … 1963 1973 { 1964 1974 BEGIN_AX_OBJC_EXCEPTIONS 1965 return AccessibilityTextMarkerRange::create( [m_element accessibilityAttributeValue:@"AXTextMarkerRangeForNSRange"1966 forParameter:[NSValue valueWithRange:NSMakeRange(location, length)]]);1975 return AccessibilityTextMarkerRange::create(attributeValueForParameter(@"AXTextMarkerRangeForNSRange", 1976 [NSValue valueWithRange:NSMakeRange(location, length)]).get()); 1967 1977 END_AX_OBJC_EXCEPTIONS 1968 1978 … … 1987 1997 1988 1998 NSArray *textMarkers = @[start.get(), start.get()]; 1989 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXTextMarkerRangeForUnorderedTextMarkers" forParameter:textMarkers];1999 auto textMarkerRange = attributeValueForParameter(@"AXTextMarkerRangeForUnorderedTextMarkers", textMarkers); 1990 2000 if (!textMarkerRange) 1991 2001 return; 1992 2002 1993 setAttributeValue(m_element.get(), NSAccessibilitySelectedTextMarkerRangeAttribute, textMarkerRange , true);2003 setAttributeValue(m_element.get(), NSAccessibilitySelectedTextMarkerRangeAttribute, textMarkerRange.get(), true); 1994 2004 } 1995 2005 … … 2000 2010 2001 2011 BEGIN_AX_OBJC_EXCEPTIONS 2002 id textMarker = [m_element accessibilityAttributeValue:@"AXStartTextMarkerForTextMarkerRange" forParameter:range->platformTextMarkerRange()];2003 return AccessibilityTextMarker::create(textMarker );2004 END_AX_OBJC_EXCEPTIONS 2005 2012 auto textMarker = attributeValueForParameter(@"AXStartTextMarkerForTextMarkerRange", range->platformTextMarkerRange()); 2013 return AccessibilityTextMarker::create(textMarker.get()); 2014 END_AX_OBJC_EXCEPTIONS 2015 2006 2016 return nullptr; 2007 2017 } … … 2013 2023 2014 2024 BEGIN_AX_OBJC_EXCEPTIONS 2015 id textMarker = [m_element accessibilityAttributeValue:@"AXEndTextMarkerForTextMarkerRange" forParameter:range->platformTextMarkerRange()];2016 return AccessibilityTextMarker::create(textMarker );2017 END_AX_OBJC_EXCEPTIONS 2018 2025 auto textMarker = attributeValueForParameter(@"AXEndTextMarkerForTextMarkerRange", range->platformTextMarkerRange()); 2026 return AccessibilityTextMarker::create(textMarker.get()); 2027 END_AX_OBJC_EXCEPTIONS 2028 2019 2029 return nullptr; 2020 2030 } … … 2023 2033 { 2024 2034 BEGIN_AX_OBJC_EXCEPTIONS 2025 id textMarker = [m_element accessibilityAttributeValue:NSAccessibilityEndTextMarkerForBoundsParameterizedAttribute forParameter:[NSValue valueWithRect:NSMakeRect(x, y, width, height)]]; 2026 return AccessibilityTextMarker::create(textMarker); 2027 END_AX_OBJC_EXCEPTIONS 2028 2035 auto textMarker = attributeValueForParameter(NSAccessibilityEndTextMarkerForBoundsParameterizedAttribute, 2036 [NSValue valueWithRect:NSMakeRect(x, y, width, height)]); 2037 return AccessibilityTextMarker::create(textMarker.get()); 2038 END_AX_OBJC_EXCEPTIONS 2039 2029 2040 return nullptr; 2030 2041 } … … 2054 2065 { 2055 2066 BEGIN_AX_OBJC_EXCEPTIONS 2056 id textMarker = [m_element accessibilityAttributeValue:NSAccessibilityStartTextMarkerForBoundsParameterizedAttribute forParameter:[NSValue valueWithRect:NSMakeRect(x, y, width, height)]]; 2057 return AccessibilityTextMarker::create(textMarker); 2058 END_AX_OBJC_EXCEPTIONS 2059 2067 auto textMarker = attributeValueForParameter(NSAccessibilityStartTextMarkerForBoundsParameterizedAttribute, 2068 [NSValue valueWithRect:NSMakeRect(x, y, width, height)]); 2069 return AccessibilityTextMarker::create(textMarker.get()); 2070 END_AX_OBJC_EXCEPTIONS 2071 2060 2072 return nullptr; 2061 2073 } … … 2064 2076 { 2065 2077 BEGIN_AX_OBJC_EXCEPTIONS 2066 id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForPosition" forParameter:[NSValue valueWithPoint:NSMakePoint(x, y)]];2067 return AccessibilityTextMarker::create(textMarker );2068 END_AX_OBJC_EXCEPTIONS 2069 2078 auto textMarker = attributeValueForParameter(@"AXTextMarkerForPosition", [NSValue valueWithPoint:NSMakePoint(x, y)]); 2079 return AccessibilityTextMarker::create(textMarker.get()); 2080 END_AX_OBJC_EXCEPTIONS 2081 2070 2082 return nullptr; 2071 2083 } … … 2077 2089 2078 2090 BEGIN_AX_OBJC_EXCEPTIONS 2079 id uiElement = [m_element accessibilityAttributeValue:@"AXUIElementForTextMarker" forParameter:marker->platformTextMarker()];2091 auto uiElement = attributeValueForParameter(@"AXUIElementForTextMarker", marker->platformTextMarker()); 2080 2092 if (uiElement) 2081 return AccessibilityUIElement::create(uiElement );2082 END_AX_OBJC_EXCEPTIONS 2083 2093 return AccessibilityUIElement::create(uiElement.get()); 2094 END_AX_OBJC_EXCEPTIONS 2095 2084 2096 return nullptr; 2085 2097 } … … 2109 2121 return nullptr; 2110 2122 2111 NSAttributedString* string = nil; 2112 2113 BEGIN_AX_OBJC_EXCEPTIONS 2114 string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRange" forParameter:markerRange->platformTextMarkerRange()]; 2115 END_AX_OBJC_EXCEPTIONS 2116 2117 if (![string isKindOfClass:[NSAttributedString class]]) 2118 return nil; 2119 2120 return createJSStringRef(string); 2123 BEGIN_AX_OBJC_EXCEPTIONS 2124 auto string = attributeValueForParameter(@"AXAttributedStringForTextMarkerRange", markerRange->platformTextMarkerRange()); 2125 if ([string isKindOfClass:[NSAttributedString class]]) 2126 return createJSStringRef(string.get()); 2127 END_AX_OBJC_EXCEPTIONS 2128 2129 return nil; 2121 2130 } 2122 2131 … … 2125 2134 if (!markerRange || !markerRange->platformTextMarkerRange()) 2126 2135 return nullptr; 2127 2128 NSAttributedString* string = nil;2129 2136 2130 2137 id parameter = nil; … … 2135 2142 2136 2143 BEGIN_AX_OBJC_EXCEPTIONS 2137 string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRangeWithOptions" forParameter:parameter]; 2138 END_AX_OBJC_EXCEPTIONS 2139 2140 if (![string isKindOfClass:[NSAttributedString class]]) 2141 return nil; 2142 2143 return createJSStringRef(string); 2144 auto string = attributeValueForParameter(@"AXAttributedStringForTextMarkerRangeWithOptions", parameter); 2145 if ([string isKindOfClass:[NSAttributedString class]]) 2146 return createJSStringRef(string.get()); 2147 END_AX_OBJC_EXCEPTIONS 2148 2149 return nil; 2144 2150 } 2145 2151 … … 2150 2156 2151 2157 BEGIN_AX_OBJC_EXCEPTIONS 2152 NSAttributedString* string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRange" forParameter:range->platformTextMarkerRange()];2158 auto string = attributeValueForParameter(@"AXAttributedStringForTextMarkerRange", range->platformTextMarkerRange()); 2153 2159 if (![string isKindOfClass:[NSAttributedString class]]) 2154 2160 return false; 2155 2161 2156 2162 NSDictionary* attrs = [string attributesAtIndex:0 effectiveRange:nil]; 2157 2163 if ([attrs objectForKey:[NSString stringWithJSStringRef:attribute]]) 2158 2164 return true; 2159 2165 END_AX_OBJC_EXCEPTIONS 2160 2166 2161 2167 return false; 2162 2168 } … … 2168 2174 2169 2175 BEGIN_AX_OBJC_EXCEPTIONS 2170 NSNumber* indexNumber = [m_element accessibilityAttributeValue:@"AXIndexForTextMarker" forParameter:marker->platformTextMarker()];2176 auto indexNumber = attributeValueForParameter(@"AXIndexForTextMarker", marker->platformTextMarker()); 2171 2177 return [indexNumber intValue]; 2172 2178 END_AX_OBJC_EXCEPTIONS 2173 2179 2174 2180 return -1; 2175 2181 } … … 2181 2187 2182 2188 BEGIN_AX_OBJC_EXCEPTIONS 2183 NSNumber* validNumber = [m_element accessibilityAttributeValue:@"AXTextMarkerIsValid" forParameter:textMarker->platformTextMarker()];2184 return [val idNumberboolValue];2185 END_AX_OBJC_EXCEPTIONS 2186 2189 auto value = attributeValueForParameter(@"AXTextMarkerIsValid", textMarker->platformTextMarker()); 2190 return [value boolValue]; 2191 END_AX_OBJC_EXCEPTIONS 2192 2187 2193 return false; 2188 2194 } … … 2191 2197 { 2192 2198 BEGIN_AX_OBJC_EXCEPTIONS 2193 id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForIndex" forParameter:[NSNumber numberWithInteger:textIndex]];2194 return AccessibilityTextMarker::create(textMarker );2195 END_AX_OBJC_EXCEPTIONS 2196 2199 auto textMarker = attributeValueForParameter(@"AXTextMarkerForIndex", [NSNumber numberWithInteger:textIndex]); 2200 return AccessibilityTextMarker::create(textMarker.get()); 2201 END_AX_OBJC_EXCEPTIONS 2202 2197 2203 return nullptr; 2198 2204 } … … 2224 2230 2225 2231 BEGIN_AX_OBJC_EXCEPTIONS 2226 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXLeftWordTextMarkerRangeForTextMarker" forParameter:textMarker->platformTextMarker()];2227 return AccessibilityTextMarkerRange::create(textMarkerRange );2228 END_AX_OBJC_EXCEPTIONS 2229 2232 auto textMarkerRange = attributeValueForParameter(@"AXLeftWordTextMarkerRangeForTextMarker", textMarker->platformTextMarker()); 2233 return AccessibilityTextMarkerRange::create(textMarkerRange.get()); 2234 END_AX_OBJC_EXCEPTIONS 2235 2230 2236 return nullptr; 2231 2237 } … … 2237 2243 2238 2244 BEGIN_AX_OBJC_EXCEPTIONS 2239 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXRightWordTextMarkerRangeForTextMarker" forParameter:textMarker->platformTextMarker()];2240 return AccessibilityTextMarkerRange::create(textMarkerRange );2241 END_AX_OBJC_EXCEPTIONS 2242 2245 auto textMarkerRange = attributeValueForParameter(@"AXRightWordTextMarkerRangeForTextMarker", textMarker->platformTextMarker()); 2246 return AccessibilityTextMarkerRange::create(textMarkerRange.get()); 2247 END_AX_OBJC_EXCEPTIONS 2248 2243 2249 return nullptr; 2244 2250 } … … 2250 2256 2251 2257 BEGIN_AX_OBJC_EXCEPTIONS 2252 id previousWordStartMarker = [m_element accessibilityAttributeValue:@"AXPreviousWordStartTextMarkerForTextMarker" forParameter:textMarker->platformTextMarker()];2253 return AccessibilityTextMarker::create(previousWordStartMarker );2254 END_AX_OBJC_EXCEPTIONS 2255 2258 auto previousWordStartMarker = attributeValueForParameter(@"AXPreviousWordStartTextMarkerForTextMarker", textMarker->platformTextMarker()); 2259 return AccessibilityTextMarker::create(previousWordStartMarker.get()); 2260 END_AX_OBJC_EXCEPTIONS 2261 2256 2262 return nullptr; 2257 2263 } … … 2263 2269 2264 2270 BEGIN_AX_OBJC_EXCEPTIONS 2265 id nextWordEndMarker = [m_element accessibilityAttributeValue:@"AXNextWordEndTextMarkerForTextMarker" forParameter:textMarker->platformTextMarker()];2266 return AccessibilityTextMarker::create(nextWordEndMarker );2267 END_AX_OBJC_EXCEPTIONS 2268 2271 auto nextWordEndMarker = attributeValueForParameter(@"AXNextWordEndTextMarkerForTextMarker", textMarker->platformTextMarker()); 2272 return AccessibilityTextMarker::create(nextWordEndMarker.get()); 2273 END_AX_OBJC_EXCEPTIONS 2274 2269 2275 return nullptr; 2270 2276 } … … 2276 2282 2277 2283 BEGIN_AX_OBJC_EXCEPTIONS 2278 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXParagraphTextMarkerRangeForTextMarker" forParameter:textMarker->platformTextMarker()];2279 return AccessibilityTextMarkerRange::create(textMarkerRange );2280 END_AX_OBJC_EXCEPTIONS 2281 2284 auto textMarkerRange = attributeValueForParameter(@"AXParagraphTextMarkerRangeForTextMarker", textMarker->platformTextMarker()); 2285 return AccessibilityTextMarkerRange::create(textMarkerRange.get()); 2286 END_AX_OBJC_EXCEPTIONS 2287 2282 2288 return nullptr; 2283 2289 } … … 2289 2295 2290 2296 BEGIN_AX_OBJC_EXCEPTIONS 2291 id previousParagraphStartMarker = [m_element accessibilityAttributeValue:@"AXPreviousParagraphStartTextMarkerForTextMarker" forParameter:textMarker->platformTextMarker()];2292 return AccessibilityTextMarker::create(previousParagraphStartMarker );2293 END_AX_OBJC_EXCEPTIONS 2294 2297 auto previousParagraphStartMarker = attributeValueForParameter(@"AXPreviousParagraphStartTextMarkerForTextMarker", textMarker->platformTextMarker()); 2298 return AccessibilityTextMarker::create(previousParagraphStartMarker.get()); 2299 END_AX_OBJC_EXCEPTIONS 2300 2295 2301 return nullptr; 2296 2302 } … … 2302 2308 2303 2309 BEGIN_AX_OBJC_EXCEPTIONS 2304 id nextParagraphEndMarker = [m_element accessibilityAttributeValue:@"AXNextParagraphEndTextMarkerForTextMarker" forParameter:textMarker->platformTextMarker()];2305 return AccessibilityTextMarker::create(nextParagraphEndMarker );2306 END_AX_OBJC_EXCEPTIONS 2307 2310 auto nextParagraphEndMarker = attributeValueForParameter(@"AXNextParagraphEndTextMarkerForTextMarker", textMarker->platformTextMarker()); 2311 return AccessibilityTextMarker::create(nextParagraphEndMarker.get()); 2312 END_AX_OBJC_EXCEPTIONS 2313 2308 2314 return nullptr; 2309 2315 } … … 2315 2321 2316 2322 BEGIN_AX_OBJC_EXCEPTIONS 2317 id textMarkerRange = [m_element accessibilityAttributeValue:@"AXSentenceTextMarkerRangeForTextMarker" forParameter:textMarker->platformTextMarker()];2318 return AccessibilityTextMarkerRange::create(textMarkerRange );2319 END_AX_OBJC_EXCEPTIONS 2320 2323 auto textMarkerRange = attributeValueForParameter(@"AXSentenceTextMarkerRangeForTextMarker", textMarker->platformTextMarker()); 2324 return AccessibilityTextMarkerRange::create(textMarkerRange.get()); 2325 END_AX_OBJC_EXCEPTIONS 2326 2321 2327 return nullptr; 2322 2328 } … … 2328 2334 2329 2335 BEGIN_AX_OBJC_EXCEPTIONS 2330 id previousParagraphStartMarker = [m_element accessibilityAttributeValue:@"AXPreviousSentenceStartTextMarkerForTextMarker" forParameter:textMarker->platformTextMarker()];2331 return AccessibilityTextMarker::create(previousParagraphStartMarker );2332 END_AX_OBJC_EXCEPTIONS 2333 2336 auto previousParagraphStartMarker = attributeValueForParameter(@"AXPreviousSentenceStartTextMarkerForTextMarker", textMarker->platformTextMarker()); 2337 return AccessibilityTextMarker::create(previousParagraphStartMarker.get()); 2338 END_AX_OBJC_EXCEPTIONS 2339 2334 2340 return nullptr; 2335 2341 } … … 2341 2347 2342 2348 BEGIN_AX_OBJC_EXCEPTIONS 2343 id nextParagraphEndMarker = [m_element accessibilityAttributeValue:@"AXNextSentenceEndTextMarkerForTextMarker" forParameter:textMarker->platformTextMarker()];2344 return AccessibilityTextMarker::create(nextParagraphEndMarker );2345 END_AX_OBJC_EXCEPTIONS 2346 2349 auto nextParagraphEndMarker = attributeValueForParameter(@"AXNextSentenceEndTextMarkerForTextMarker", textMarker->platformTextMarker()); 2350 return AccessibilityTextMarker::create(nextParagraphEndMarker.get()); 2351 END_AX_OBJC_EXCEPTIONS 2352 2347 2353 return nullptr; 2348 2354 } … … 2352 2358 __block NSMutableString *result = [NSMutableString string]; 2353 2359 [pairs enumerateObjectsUsingBlock:^(id pair, NSUInteger index, BOOL *stop) { 2354 for (NSString *key in pair) 2355 [result appendFormat:@"\t%lu. %@ = %@\n", (unsigned long)index, key, [[pair objectForKey:key] accessibilityAttributeValue:NSAccessibilitySubroleAttribute]]; 2360 for (NSString *key in pair) { 2361 auto element = AccessibilityUIElement::create([pair objectForKey:key]); 2362 auto subrole = element->attributeValue(NSAccessibilitySubroleAttribute); 2363 [result appendFormat:@"\t%lu. %@ = %@\n", (unsigned long)index, key, subrole.get()]; 2364 } 2356 2365 }]; 2357 2366
Note:
See TracChangeset
for help on using the changeset viewer.