diff options
Diffstat (limited to 'Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm')
-rw-r--r-- | Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm b/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm index c0dd795..ed3eba8 100644 --- a/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm +++ b/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm @@ -480,12 +480,26 @@ static void AXAttributeStringSetBlockquoteLevel(NSMutableAttributedString* attrS static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, Node* node, const UChar* chars, int charLength, NSRange range) { +#if USE(UNIFIED_TEXT_CHECKING) // Check the spelling directly since document->markersForNode() does not store the misspelled marking when the cursor is in a word. + TextCheckerClient* checker = node->document()->frame()->editor()->textChecker(); + + // checkTextOfParagraph is the only spelling/grammar checker implemented in WK1 and WK2 + Vector<TextCheckingResult> results; + checker->checkTextOfParagraph(chars, charLength, TextCheckingTypeSpelling, results); + + size_t size = results.size(); + NSNumber* trueValue = [NSNumber numberWithBool:YES]; + for (unsigned i = 0; i < size; i++) { + const TextCheckingResult& result = results[i]; + AXAttributeStringSetNumber(attrString, NSAccessibilityMisspelledTextAttribute, trueValue, NSMakeRange(result.location + range.location, result.length)); + } +#else int currentPosition = 0; while (charLength > 0) { const UChar* charData = chars + currentPosition; TextCheckerClient* checker = node->document()->frame()->editor()->textChecker(); - + int misspellingLocation = -1; int misspellingLength = 0; checker->checkSpellingOfString(charData, charLength, &misspellingLocation, &misspellingLength); @@ -497,6 +511,7 @@ static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, charLength -= (misspellingLocation + misspellingLength); currentPosition += (misspellingLocation + misspellingLength); } +#endif } static void AXAttributeStringSetHeadingLevel(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range) |