[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

cfleizach at apple.com cfleizach at apple.com
Wed Dec 22 11:30:35 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 75c49bbf44ca831bc3e9ab1a97d2c65420b1dfd7
Author: cfleizach at apple.com <cfleizach at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jul 27 19:38:49 2010 +0000

    AX: Misspellings not shown in AXAttributedStringForTextMarkerRange when selection is on word
    https://bugs.webkit.org/show_bug.cgi?id=41817
    
    Reviewed by David Kilzer.
    
    WebCore:
    
    Change how misspelled words are identified for accessibility. No longer rely on the
    cached markers in Document. Calculate on the fly, which is more accurate in a variety of
    circumstances (like when selection has not moved across words, of if the cursor is in the middle
    of a misspelled word).
    
    Test: platform/mac/accessibility/attributed-string-includes-misspelled-with-selection.html
    
    * accessibility/mac/AccessibilityObjectWrapper.mm:
    (AXAttributeStringSetSpelling):
    (AXAttributedStringAppendText):
    (-[AccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]):
    
    LayoutTests:
    
    * platform/mac/accessibility/attributed-string-includes-misspelled-with-selection-expected.txt: Added.
    * platform/mac/accessibility/attributed-string-includes-misspelled-with-selection.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64149 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index cccd0ff..19b3928 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-07-27  Chris Fleizach  <cfleizach at apple.com>
+
+        Reviewed by David Kilzer.
+
+        AX: Misspellings not shown in AXAttributedStringForTextMarkerRange when selection is on word
+        https://bugs.webkit.org/show_bug.cgi?id=41817
+
+        * platform/mac/accessibility/attributed-string-includes-misspelled-with-selection-expected.txt: Added.
+        * platform/mac/accessibility/attributed-string-includes-misspelled-with-selection.html: Added.
+
 2010-07-27  Victor Wang  <victorw at chromium.org>
 
         Unreviewed. Update chromium test expectations.
diff --git a/LayoutTests/platform/mac/accessibility/attributed-string-includes-misspelled-with-selection-expected.txt b/LayoutTests/platform/mac/accessibility/attributed-string-includes-misspelled-with-selection-expected.txt
new file mode 100644
index 0000000..519bb51
--- /dev/null
+++ b/LayoutTests/platform/mac/accessibility/attributed-string-includes-misspelled-with-selection-expected.txt
@@ -0,0 +1,11 @@
+word mispelled word
+This tests that if the cursor is on a misspelled word, the misspelled marker will still be returned for that range. The test places selection in the middle of 'mispelled' and then queries for the attributed string.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS attrString.indexOf('AXMisspelled = 1') != -1 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/attributed-string-includes-misspelled-with-selection.html b/LayoutTests/platform/mac/accessibility/attributed-string-includes-misspelled-with-selection.html
new file mode 100644
index 0000000..9b61495
--- /dev/null
+++ b/LayoutTests/platform/mac/accessibility/attributed-string-includes-misspelled-with-selection.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+<script>
+var successfullyParsed = false;
+if (window.layoutTestController)
+   layoutTestController.dumpAsText();
+</script>
+</head>
+<body>
+
+<div contenteditable=true id="content" role="textbox">
+
+word mispelled word
+
+</div>
+
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that if the cursor is on a misspelled word, the misspelled marker will still be returned for that range. The test places selection in the middle of 'mispelled' and then queries for the attributed string.");
+
+    if (window.accessibilityController) {
+        var content = document.getElementById("content");
+        content.focus();
+
+        var s = window.getSelection();
+        s.setPosition(content, 0);
+        for (var k = 0; k < 10; k++) {
+            s.modify("move", "forward", "character");   
+        }
+
+        var text = accessibilityController.focusedElement;
+        var attrString = text.attributedStringForRange(0, document.getElementById("content").innerText.length);
+
+        shouldBeTrue("attrString.indexOf('AXMisspelled = 1') != -1");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+
+</body>
+</html>
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 638d50a..40e9918 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-07-27  Chris Fleizach  <cfleizach at apple.com>
+
+        Reviewed by David Kilzer.
+
+        AX: Misspellings not shown in AXAttributedStringForTextMarkerRange when selection is on word
+        https://bugs.webkit.org/show_bug.cgi?id=41817
+
+        Change how misspelled words are identified for accessibility. No longer rely on the 
+        cached markers in Document. Calculate on the fly, which is more accurate in a variety of 
+        circumstances (like when selection has not moved across words, of if the cursor is in the middle
+        of a misspelled word). 
+
+        Test: platform/mac/accessibility/attributed-string-includes-misspelled-with-selection.html
+
+        * accessibility/mac/AccessibilityObjectWrapper.mm:
+        (AXAttributeStringSetSpelling):
+        (AXAttributedStringAppendText):
+        (-[AccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]):
+
 2010-07-27  Gavin Barraclough  <barraclough at apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm b/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
index bb16ae7..94d2be3 100644
--- a/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
+++ b/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
@@ -41,6 +41,7 @@
 #import "AccessibilityTableRow.h"
 #import "AccessibilityTableColumn.h"
 #import "ColorMac.h"
+#import "EditorClient.h"
 #import "Frame.h"
 #import "HTMLAnchorElement.h"
 #import "HTMLAreaElement.h"
@@ -390,32 +391,24 @@ static void AXAttributeStringSetBlockquoteLevel(NSMutableAttributedString* attrS
         [attrString removeAttribute:NSAccessibilityBlockQuoteLevelAttribute range:range];
 }
 
-static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, Node* node, int offset, NSRange range)
+static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, Node* node, const UChar* chars, int charLength, NSRange range)
 {
-    Vector<DocumentMarker> markers = node->renderer()->document()->markersForNode(node);
-    Vector<DocumentMarker>::iterator markerIt = markers.begin();
-
-    unsigned endOffset = (unsigned)offset + range.length;
-    for ( ; markerIt != markers.end(); markerIt++) {
-        DocumentMarker marker = *markerIt;
-        
-        if (marker.type != DocumentMarker::Spelling)
-            continue;
-        
-        if (marker.endOffset <= (unsigned)offset)
-            continue;
-        
-        if (marker.startOffset > endOffset)
+    // Check the spelling directly since document->markersForNode() does not store the misspelled marking when the cursor is in a word.
+    EditorClient* client = node->document()->page()->editorClient();
+    int currentPosition = 0;
+    while (charLength > 0) {
+        const UChar* charData = chars + currentPosition;
+
+        int misspellingLocation = -1;
+        int misspellingLength = 0;
+        client->checkSpellingOfString(charData, charLength, &misspellingLocation, &misspellingLength);
+        if (misspellingLocation == -1 || !misspellingLength)
             break;
         
-        // add misspelling attribute for the intersection of the marker and the range
-        int rStart = range.location + (marker.startOffset - offset);
-        int rLength = min(marker.endOffset, endOffset) - marker.startOffset;
-        NSRange spellRange = NSMakeRange(rStart, rLength);
+        NSRange spellRange = NSMakeRange(range.location + currentPosition + misspellingLocation, misspellingLength);
         AXAttributeStringSetNumber(attrString, NSAccessibilityMisspelledTextAttribute, [NSNumber numberWithBool:YES], spellRange);
-        
-        if (marker.endOffset > endOffset + 1)
-            break;
+        charLength -= (misspellingLocation + misspellingLength);
+        currentPosition += (misspellingLocation + misspellingLength);
     }
 }
 
@@ -459,7 +452,7 @@ static void AXAttributeStringSetElement(NSMutableAttributedString* attrString, N
         [attrString removeAttribute:attribute range:range];
 }
 
-static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, int offset, const UChar* chars, int length)
+static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, const UChar* chars, int length)
 {
     // skip invisible text
     if (!node->renderer())
@@ -478,6 +471,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
 
     // remove inherited attachment from prior AXAttributedStringAppendReplaced
     [attrString removeAttribute:NSAccessibilityAttachmentTextAttribute range:attrStringRange];
+    [attrString removeAttribute:NSAccessibilityMisspelledTextAttribute range:attrStringRange];
     
     // set new attributes
     AXAttributeStringSetStyle(attrString, node->renderer(), attrStringRange);
@@ -486,7 +480,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     AXAttributeStringSetElement(attrString, NSAccessibilityLinkTextAttribute, AccessibilityObject::anchorElementForNode(node), attrStringRange);
     
     // do spelling last because it tends to break up the range
-    AXAttributeStringSetSpelling(attrString, node, offset, attrStringRange);
+    AXAttributeStringSetSpelling(attrString, node, chars, length, attrStringRange);
 }
 
 static NSString* nsStringForReplacedNode(Node* replacedNode)
@@ -538,9 +532,9 @@ static NSString* nsStringForReplacedNode(Node* replacedNode)
             // Add the text of the list marker item if necessary.
             String listMarkerText = m_object->listMarkerTextForNodeAndPosition(node, VisiblePosition(it.range()->startPosition()));
             if (!listMarkerText.isEmpty())
-                AXAttributedStringAppendText(attrString, node, offset, listMarkerText.characters(), listMarkerText.length());
+                AXAttributedStringAppendText(attrString, node, listMarkerText.characters(), listMarkerText.length());
             
-            AXAttributedStringAppendText(attrString, node, offset, it.characters(), it.length());
+            AXAttributedStringAppendText(attrString, node, it.characters(), it.length());
         } else {
             Node* replacedNode = node->childNode(offset);
             NSString *attachmentString = nsStringForReplacedNode(replacedNode);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list