- Revision
- 172005
- Author
- [email protected]
- Date
- 2014-08-04 14:56:08 -0700 (Mon, 04 Aug 2014)
Log Message
AX: isWordEndMatch should allow for multiple word selections
https://bugs.webkit.org/show_bug.cgi?id=135573
Reviewed by Mario Sanchez Prada.
Source/WebCore:
isWordEndMatch was searching from the beginning of the selected range, which meant
that if the result was multiple words, we'd reject the result.
Instead, we should search from the end of the range, so that we encompass all words.
Modified existing test: platform/mac/accessibility/select-text-should-match-whole-words.html
* editing/TextIterator.cpp:
(WebCore::SearchBuffer::isWordEndMatch):
LayoutTests:
* platform/mac/accessibility/select-text-should-match-whole-words-expected.txt:
* platform/mac/accessibility/select-text-should-match-whole-words.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (172004 => 172005)
--- trunk/LayoutTests/ChangeLog 2014-08-04 21:25:22 UTC (rev 172004)
+++ trunk/LayoutTests/ChangeLog 2014-08-04 21:56:08 UTC (rev 172005)
@@ -1,5 +1,15 @@
2014-08-04 Chris Fleizach <[email protected]>
+ AX: isWordEndMatch should allow for multiple word selections
+ https://bugs.webkit.org/show_bug.cgi?id=135573
+
+ Reviewed by Mario Sanchez Prada.
+
+ * platform/mac/accessibility/select-text-should-match-whole-words-expected.txt:
+ * platform/mac/accessibility/select-text-should-match-whole-words.html:
+
+2014-08-04 Chris Fleizach <[email protected]>
+
AX: Secure text fields need to support Search parameterized attributes
https://bugs.webkit.org/show_bug.cgi?id=135568
Modified: trunk/LayoutTests/platform/mac/accessibility/select-text-should-match-whole-words-expected.txt (172004 => 172005)
--- trunk/LayoutTests/platform/mac/accessibility/select-text-should-match-whole-words-expected.txt 2014-08-04 21:25:22 UTC (rev 172004)
+++ trunk/LayoutTests/platform/mac/accessibility/select-text-should-match-whole-words-expected.txt 2014-08-04 21:56:08 UTC (rev 172005)
@@ -1,4 +1,4 @@
-The man jumped high.
+The man jumped higher.
This tests that selection matches whole words, rather than partial matches.
@@ -11,6 +11,12 @@
PASS result is 'jumped'
PASS windowSelection.getRangeAt(0).startOffset is 8
PASS windowSelection.getRangeAt(0).endOffset is 14
+PASS result is 'jumped higher'
+PASS windowSelection.getRangeAt(0).startOffset is 8
+PASS windowSelection.getRangeAt(0).endOffset is 21
+PASS result is ''
+PASS windowSelection.getRangeAt(0).startOffset is 0
+PASS windowSelection.getRangeAt(0).endOffset is 0
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/platform/mac/accessibility/select-text-should-match-whole-words.html (172004 => 172005)
--- trunk/LayoutTests/platform/mac/accessibility/select-text-should-match-whole-words.html 2014-08-04 21:25:22 UTC (rev 172004)
+++ trunk/LayoutTests/platform/mac/accessibility/select-text-should-match-whole-words.html 2014-08-04 21:56:08 UTC (rev 172005)
@@ -6,7 +6,7 @@
</head>
<body>
-<p contenteditable="true" id="text">The man jumped high.</p>
+<p contenteditable="true" id="text">The man jumped higher.</p>
<p id="description"></p>
<div id="console"></div>
@@ -17,7 +17,6 @@
if (window.accessibilityController) {
var text = accessibilityController.accessibleElementById("text");
var windowSelection = window.getSelection();
- windowSelection.removeAllRanges();
// A matching range before the selection should be selected when searching for closest match.
document.getElementById("text").focus();
@@ -26,6 +25,7 @@
var range = document.createRange();
range.setStart(document.getElementById("text").firstChild, 0);
range.setEnd(document.getElementById("text").firstChild, 0);
+ windowSelection.removeAllRanges();
windowSelection.addRange(range);
// Try to select a partial word, it should fail.
@@ -39,7 +39,22 @@
shouldBe("result", "'jumped'");
shouldBe("windowSelection.getRangeAt(0).startOffset", "8");
shouldBe("windowSelection.getRangeAt(0).endOffset", "14");
+ windowSelection.removeAllRanges();
+ windowSelection.addRange(range);
+ // Select multiple whole word, it should succeed.
+ result = text.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestToSelection", "jumped higher");
+ shouldBe("result", "'jumped higher'");
+ shouldBe("windowSelection.getRangeAt(0).startOffset", "8");
+ shouldBe("windowSelection.getRangeAt(0).endOffset", "21");
+ windowSelection.removeAllRanges();
+ windowSelection.addRange(range);
+
+ // Select multiple words, where one is not a whole word, it should fail.
+ result = text.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestToSelection", "jumped high");
+ shouldBe("result", "''");
+ shouldBe("windowSelection.getRangeAt(0).startOffset", "0");
+ shouldBe("windowSelection.getRangeAt(0).endOffset", "0");
}
</script>
Modified: trunk/Source/WebCore/ChangeLog (172004 => 172005)
--- trunk/Source/WebCore/ChangeLog 2014-08-04 21:25:22 UTC (rev 172004)
+++ trunk/Source/WebCore/ChangeLog 2014-08-04 21:56:08 UTC (rev 172005)
@@ -1,5 +1,21 @@
2014-08-04 Chris Fleizach <[email protected]>
+ AX: isWordEndMatch should allow for multiple word selections
+ https://bugs.webkit.org/show_bug.cgi?id=135573
+
+ Reviewed by Mario Sanchez Prada.
+
+ isWordEndMatch was searching from the beginning of the selected range, which meant
+ that if the result was multiple words, we'd reject the result.
+ Instead, we should search from the end of the range, so that we encompass all words.
+
+ Modified existing test: platform/mac/accessibility/select-text-should-match-whole-words.html
+
+ * editing/TextIterator.cpp:
+ (WebCore::SearchBuffer::isWordEndMatch):
+
+2014-08-04 Chris Fleizach <[email protected]>
+
AX: Secure text fields need to support Search parameterized attributes
https://bugs.webkit.org/show_bug.cgi?id=135568
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (172004 => 172005)
--- trunk/Source/WebCore/editing/TextIterator.cpp 2014-08-04 21:25:22 UTC (rev 172004)
+++ trunk/Source/WebCore/editing/TextIterator.cpp 2014-08-04 21:56:08 UTC (rev 172005)
@@ -2121,10 +2121,12 @@
inline bool SearchBuffer::isWordEndMatch(size_t start, size_t length) const
{
+ ASSERT(length);
ASSERT(m_options & AtWordEnds);
int endWord;
- findEndWordBoundary(StringView(m_buffer.data(), m_buffer.size()), start, &endWord);
+ // Start searching at the end of matched search, so that multiple word matches succeed.
+ findEndWordBoundary(StringView(m_buffer.data(), m_buffer.size()), start + length - 1, &endWord);
return static_cast<size_t>(endWord) == (start + length);
}