Diff
Modified: trunk/LayoutTests/ChangeLog (94133 => 94134)
--- trunk/LayoutTests/ChangeLog 2011-08-31 00:18:43 UTC (rev 94133)
+++ trunk/LayoutTests/ChangeLog 2011-08-31 00:21:18 UTC (rev 94134)
@@ -1,3 +1,13 @@
+2011-08-30 Alice Boxhall <[email protected]>
+
+ Correctly report selected text range for accessibility APIs for role=textbox
+ https://bugs.webkit.org/show_bug.cgi?id=65900
+
+ Reviewed by Chris Fleizach.
+
+ * accessibility/textbox-role-reports-selection-expected.txt: Added.
+ * accessibility/textbox-role-reports-selection.html: Added.
+
2011-08-30 Rachel Blum <[email protected]>
The "port" property of an <a> whose href does not specify a port returns the wrong value
Added: trunk/LayoutTests/accessibility/textbox-role-reports-selection-expected.txt (0 => 94134)
--- trunk/LayoutTests/accessibility/textbox-role-reports-selection-expected.txt (rev 0)
+++ trunk/LayoutTests/accessibility/textbox-role-reports-selection-expected.txt 2011-08-31 00:21:18 UTC (rev 94134)
@@ -0,0 +1,12 @@
+This tests that the AXSelection property is correctly reported for non-native text boxes.
+Some text in a textbox (34 chars).
+PASS: axSelection is {0, 0} (Collapsed selection at start)
+PASS: axSelection is {34, 0} (Collapsed selection at end)
+PASS: axSelection is {15, 0} (Collapsed selection in the middle)
+PASS: axSelection is {15, 2} (Non-collapsed selection in the middle)
+PASS: axSelection is {0, 15} (Non-collapsed selection at the start)
+PASS: axSelection is {15, 19} (Non-collapsed selection at the end)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/accessibility/textbox-role-reports-selection.html (0 => 94134)
--- trunk/LayoutTests/accessibility/textbox-role-reports-selection.html (rev 0)
+++ trunk/LayoutTests/accessibility/textbox-role-reports-selection.html 2011-08-31 00:21:18 UTC (rev 94134)
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script>
+var successfullyParsed = false;
+</script>
+<script src=""
+</head>
+<body>
+This tests that the AXSelection property is correctly reported for non-native text boxes.<br>
+<div role="textbox" id="ariaTextBox" aria-multiline="false" tabindex="0">Some text in a textbox (34 chars).</div>
+<div id="console"></div>
+<script>
+ function assertEvaluatesTo(actual, expected, message) {
+ var actualValue = 0;
+ try {
+ actualValue = eval(actual);
+ } catch (e) {
+ debug("Evaluating " + actual + ": Threw exception " + e);
+ return;
+ }
+ if (actualValue === expected)
+ debug("PASS: " + actual + " is " + expected + (message ? " (" + message + ")" : ""));
+ else
+ debug("FAIL: " + actual + " should be " + expected + ", got " + actualValue + (message ? " (" + message + ")" : ""));
+ }
+
+ function assertCorrectAXSelection(element, selection, message) {
+ element.focus();
+ var selectionValues = /\{(\d+), (\d+)\}/.exec(selection);
+ var selectionStart = eval(selectionValues[1]);
+ var selectionLength = eval(selectionValues[2]);
+ var selectionEnd = selectionStart + selectionLength;
+
+ window.getSelection().setBaseAndExtent(element.firstChild, selectionStart, element.firstChild, selectionEnd);
+ var axElement = accessibilityController.focusedElement;
+ axSelection = axElement.selectedTextRange;
+ assertEvaluatesTo("axSelection", selection, message);
+ }
+
+ if (window.layoutTestController && window.accessibilityController) {
+ window.layoutTestController.dumpAsText();
+ var ariaTextBox = document.getElementById("ariaTextBox");
+ var textLength = ariaTextBox.textContent.length;
+
+ assertCorrectAXSelection(ariaTextBox, "{0, 0}", "Collapsed selection at start");
+ assertCorrectAXSelection(ariaTextBox, "{" + textLength + ", 0}", "Collapsed selection at end");
+ assertCorrectAXSelection(ariaTextBox, "{15, 0}", "Collapsed selection in the middle");
+ assertCorrectAXSelection(ariaTextBox, "{15, 2}", "Non-collapsed selection in the middle");
+ assertCorrectAXSelection(ariaTextBox, "{0, 15}", "Non-collapsed selection at the start");
+ assertCorrectAXSelection(ariaTextBox, "{15, "+ (textLength - 15) + "}", "Non-collapsed selection at the end");
+ }
+
+ successfullyParsed = true;
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (94133 => 94134)
--- trunk/Source/WebCore/ChangeLog 2011-08-31 00:18:43 UTC (rev 94133)
+++ trunk/Source/WebCore/ChangeLog 2011-08-31 00:21:18 UTC (rev 94134)
@@ -1,3 +1,19 @@
+2011-08-30 Alice Boxhall <[email protected]>
+
+ Correctly report selected text range for accessibility APIs for role=textbox
+ https://bugs.webkit.org/show_bug.cgi?id=65900
+
+ Reviewed by Chris Fleizach.
+
+ Test: accessibility/textbox-role-reports-selection.html
+
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::indexForVisiblePosition):
+ (WebCore::AccessibilityRenderObject::rootEditableElementForPosition):
+ (WebCore::AccessibilityRenderObject::nodeIsTextControl):
+ (WebCore::AccessibilityRenderObject::determineAriaRoleAttribute):
+ * accessibility/AccessibilityRenderObject.h:
+
2011-08-30 Rachel Blum <[email protected]>
The "port" property of an <a> whose href does not specify a port returns the wrong value
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (94133 => 94134)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2011-08-31 00:18:43 UTC (rev 94133)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2011-08-31 00:21:18 UTC (rev 94134)
@@ -2518,7 +2518,7 @@
return 0;
Position indexPosition = pos.deepEquivalent();
- if (indexPosition.isNull() || pos.rootEditableElement() != node)
+ if (indexPosition.isNull() || rootEditableElementForPosition(indexPosition) != node)
return 0;
ExceptionCode ec = 0;
@@ -2535,6 +2535,38 @@
#endif
}
+Element* AccessibilityRenderObject::rootEditableElementForPosition(const Position& position) const
+{
+ // Find the root editable or pseudo-editable (i.e. having an editable ARIA role) element.
+ Element* result = 0;
+
+ Element* rootEditableElement = position.rootEditableElement();
+
+ for (Element* e = position.element(); e && e != rootEditableElement; e = e->parentElement()) {
+ if (nodeIsTextControl(e))
+ result = e;
+ if (e->hasTagName(bodyTag))
+ break;
+ }
+
+ if (result)
+ return result;
+
+ return rootEditableElement;
+}
+
+bool AccessibilityRenderObject::nodeIsTextControl(const Node* node) const
+{
+ if (!node)
+ return false;
+
+ const AccessibilityObject* axObjectForNode = axObjectCache()->getOrCreate(node->renderer());
+ if (!axObjectForNode)
+ return false;
+
+ return axObjectForNode->isTextControl();
+}
+
LayoutRect AccessibilityRenderObject::boundsForVisiblePositionRange(const VisiblePositionRange& visiblePositionRange) const
{
if (visiblePositionRange.isNull())
@@ -3026,7 +3058,7 @@
if (role)
return role;
-
+
return UnknownRole;
}
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (94133 => 94134)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h 2011-08-31 00:18:43 UTC (rev 94133)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h 2011-08-31 00:21:18 UTC (rev 94134)
@@ -1,4 +1,3 @@
-
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
@@ -247,7 +246,7 @@
virtual VisiblePosition visiblePositionForIndex(int) const;
virtual int indexForVisiblePosition(const VisiblePosition&) const;
-
+
virtual PlainTextRange doAXRangeForLine(unsigned) const;
virtual PlainTextRange doAXRangeForIndex(unsigned) const;
@@ -280,13 +279,15 @@
bool hasTextAlternative() const;
String positionalDescriptionForMSAA() const;
PlainTextRange ariaSelectedTextRange() const;
+ Element* rootEditableElementForPosition(const Position&) const;
+ bool nodeIsTextControl(const Node*) const;
Element* menuElementForMenuButton() const;
Element* menuItemElementForMenu() const;
AccessibilityRole determineAccessibilityRole();
AccessibilityRole determineAriaRoleAttribute() const;
AccessibilityRole remapAriaRoleDueToParent(AccessibilityRole) const;
-
+
bool isTabItemSelected() const;
void alterSliderValue(bool increase);
void changeValueByStep(bool increase);