Commit b2b0b4d9 authored by cfleizach@apple.com's avatar cfleizach@apple.com

AX: Make SVG Group containers accessible elements

https://bugs.webkit.org/show_bug.cgi?id=113939

Reviewed by Simon Fraser.

Source/WebCore: 

SVG group containers are currently not exposed in the AX tree. 
When an SVG element has a <title> child, that is not being used for the AX label.
When hit-testing, from Accessibility, SVG groups are never returned.

All these issues are fixed for Mac and iOS.
There are two tests because right now iOS skips all the top-level accessibility tests
due to fundamental architectural differences.

Tests: accessibility/svg-group-element-with-title.html
       platform/iphone-simulator/accessibility/svg-group-element-with-title.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::alternativeText):
(WebCore::AccessibilityNodeObject::accessibilityDescription):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::accessibilityHitTest):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper isSVGGroupElement]):
(-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
(-[WebAccessibilityObjectWrapper accessibilityClickPoint]):
* rendering/HitTestRequest.h:
    Add a new option, AccessibilityHitTest, that will allow us to override normal behavior.
* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::nodeAtFloatPoint):
   Allow a SVG group to be the node at a point, for accessibility hit tests.

Tools: 

Implement axController.elementAtPoint for iOS.
Implement a correct version of clickPoint for iOS.

* DumpRenderTree/ios/AccessibilityControllerIOS.mm:
(AccessibilityController::elementAtPoint):
* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::clickPointX):
(AccessibilityUIElement::clickPointY):

LayoutTests: 

* accessibility/svg-group-element-with-title-expected.txt: Added.
* accessibility/svg-group-element-with-title.html: Added.
* platform/iphone-simulator/accessibility/svg-group-element-with-title-expected.txt: Added.
* platform/iphone-simulator/accessibility/svg-group-element-with-title.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147802 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 16399b98
2013-04-05 Chris Fleizach <cfleizach@apple.com>
AX: Make SVG Group containers accessible elements
https://bugs.webkit.org/show_bug.cgi?id=113939
Reviewed by Simon Fraser.
* accessibility/svg-group-element-with-title-expected.txt: Added.
* accessibility/svg-group-element-with-title.html: Added.
* platform/iphone-simulator/accessibility/svg-group-element-with-title-expected.txt: Added.
* platform/iphone-simulator/accessibility/svg-group-element-with-title.html: Added.
2013-04-05 Chris Fleizach <cfleizach@apple.com>
WebSpeech: event.elapsedTime is always 1364484608
This tests SVG group elements are accessible and that the svg:title element is returned properly.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Verify that the SVG group is returned as an accessible element.
PASS group1.role is 'AXRole: AXGroup'
PASS group1.description is 'AXDescription: SVG TITLE 1'
Verify that you can hit-test to the SVG group.
PASS hitTestElement.isEqual(group1) is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
</head>
<body id="body">
<svg width="500" height="300" xmlns="http://www.w3.org/2000/svg">
<g id="group1">
<title>SVG TITLE 1</title>
<rect x="10" y="10" width="200" height="100"
style="fill:none; stroke:blue; stroke-width:1px"/>
</g>
</svg>
<div id="console"></div>
<script>
description("This tests SVG group elements are accessible and that the svg:title element is returned properly.");
if (window.accessibilityController) {
debug("Verify that the SVG group is returned as an accessible element.");
var group1 = accessibilityController.accessibleElementById("group1");
shouldBe("group1.role", "'AXRole: AXGroup'");
shouldBe("group1.description", "'AXDescription: SVG TITLE 1'");
debug("\nVerify that you can hit-test to the SVG group.");
var hitTestElement = group1.elementAtPoint(group1.clickPointX, group1.clickPointY);
shouldBeTrue("hitTestElement.isEqual(group1)");
}
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>
This tests SVG group elements are accessible and that the svg:title element is returned properly.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Verify that the SVG group is returned as an accessible element.
PASS group1.iphoneLabel is 'AXLabel: SVG TITLE 1'
PASS group1.iphoneIsElement is true
Verify that you can hit-test to the SVG group.
PASS hitTestElement.isEqual(group1) is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../fast/js/resources/js-test-pre.js"></script>
</head>
<body id="body">
<svg width="500" height="300" xmlns="http://www.w3.org/2000/svg">
<g id="group1">
<title>SVG TITLE 1</title>
<rect x="10" y="10" width="200" height="100"
style="fill:none; stroke:blue; stroke-width:1px"/>
</g>
</svg>
<div id="console"></div>
<script>
description("This tests SVG group elements are accessible and that the svg:title element is returned properly.");
if (window.accessibilityController) {
debug("Verify that the SVG group is returned as an accessible element.");
var group1 = accessibilityController.accessibleElementById("group1");
shouldBe("group1.iphoneLabel", "'AXLabel: SVG TITLE 1'");
shouldBeTrue("group1.iphoneIsElement");
debug("\nVerify that you can hit-test to the SVG group.");
var hitTestElement = accessibilityController.elementAtPoint(group1.clickPointX, group1.clickPointY);
shouldBeTrue("hitTestElement.isEqual(group1)");
}
</script>
<script src="../../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
2013-04-05 Chris Fleizach <cfleizach@apple.com>
AX: Make SVG Group containers accessible elements
https://bugs.webkit.org/show_bug.cgi?id=113939
Reviewed by Simon Fraser.
SVG group containers are currently not exposed in the AX tree.
When an SVG element has a <title> child, that is not being used for the AX label.
When hit-testing, from Accessibility, SVG groups are never returned.
All these issues are fixed for Mac and iOS.
There are two tests because right now iOS skips all the top-level accessibility tests
due to fundamental architectural differences.
Tests: accessibility/svg-group-element-with-title.html
platform/iphone-simulator/accessibility/svg-group-element-with-title.html
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::alternativeText):
(WebCore::AccessibilityNodeObject::accessibilityDescription):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::accessibilityHitTest):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper isSVGGroupElement]):
(-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
(-[WebAccessibilityObjectWrapper accessibilityClickPoint]):
* rendering/HitTestRequest.h:
Add a new option, AccessibilityHitTest, that will allow us to override normal behavior.
* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::nodeAtFloatPoint):
Allow a SVG group to be the node at a point, for accessibility hit tests.
2013-04-05 Chris Fleizach <cfleizach@apple.com>
WebSpeech: event.elapsedTime is always 1364484608
......@@ -66,6 +66,9 @@
#include "NodeTraversal.h"
#include "Page.h"
#include "ProgressTracker.h"
#include "SVGElement.h"
#include "SVGNames.h"
#include "SVGStyledElement.h"
#include "Text.h"
#include "TextControlInnerElements.h"
#include "TextIterator.h"
......@@ -1184,9 +1187,18 @@ void AccessibilityNodeObject::alternativeText(Vector<AccessibilityText>& textOrd
textOrder.append(AccessibilityText(alt, AlternativeText));
}
#if ENABLE(MATHML)
Node* node = this->node();
if (node && node->isElementNode() && toElement(node)->isMathMLElement())
if (!node)
return;
#if ENABLE(SVG)
// SVG elements all can have a <svg:title> element inside which should act as the descriptive text.
if (node->isSVGElement() && toSVGElement(node)->isSVGStyledElement())
textOrder.append(AccessibilityText(toSVGStyledElement(node)->title(), AlternativeText));
#endif
#if ENABLE(MATHML)
if (node->isElementNode() && toElement(node)->isMathMLElement())
textOrder.append(AccessibilityText(getAttribute(MathMLNames::alttextAttr), AlternativeText));
#endif
}
......@@ -1370,9 +1382,14 @@ String AccessibilityNodeObject::accessibilityDescription() const
return alt;
}
#if ENABLE(SVG)
// SVG elements all can have a <svg:title> element inside which should act as the descriptive text.
if (m_node && m_node->isSVGElement() && toSVGElement(m_node)->isSVGStyledElement())
return toSVGStyledElement(m_node)->title();
#endif
#if ENABLE(MATHML)
Node* node = this->node();
if (node && node->isElementNode() && toElement(node)->isMathMLElement())
if (m_node && m_node->isElementNode() && toElement(m_node)->isMathMLElement())
return getAttribute(MathMLNames::alttextAttr);
#endif
......
......@@ -76,6 +76,7 @@
#include "RenderMathMLBlock.h"
#include "RenderMathMLOperator.h"
#include "RenderMenuList.h"
#include "RenderSVGShape.h"
#include "RenderText.h"
#include "RenderTextControl.h"
#include "RenderTextControlSingleLine.h"
......@@ -87,6 +88,7 @@
#include "SVGDocument.h"
#include "SVGImage.h"
#include "SVGImageChromeClient.h"
#include "SVGNames.h"
#include "SVGSVGElement.h"
#include "Text.h"
#include "TextControlInnerElements.h"
......@@ -2157,7 +2159,7 @@ AccessibilityObject* AccessibilityRenderObject::accessibilityHitTest(const IntPo
RenderLayer* layer = toRenderBox(m_renderer)->layer();
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AccessibilityHitTest);
HitTestResult hitTestResult = HitTestResult(point);
layer->hitTest(request, hitTestResult);
if (!hitTestResult.innerNode())
......@@ -2460,6 +2462,8 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
return ImageRole;
if (m_renderer->isSVGRoot())
return SVGRootRole;
if (node && node->hasTagName(SVGNames::gTag))
return GroupRole;
#endif
#if ENABLE(MATHML)
......
......@@ -44,6 +44,7 @@
#import "Range.h"
#import "RenderView.h"
#import "RuntimeApplicationChecksIOS.h"
#import "SVGNames.h"
#import "TextIterator.h"
#import "WAKScrollView.h"
#import "WAKView.h"
......@@ -544,6 +545,18 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
return traits;
}
- (BOOL)isSVGGroupElement
{
// If an SVG group element has a title, it should be an accessible element on iOS.
#if ENABLE(SVG)
Node* node = m_object->node();
if (node && node->hasTagName(SVGNames::gTag) && [[self accessibilityLabel] length] > 0)
return YES;
#endif
return NO;
}
- (BOOL)determineIsAccessibilityElement
{
if (!m_object)
......@@ -601,7 +614,9 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
if ([self containsUnnaturallySegmentedChildren] || ![self accessibilityElementCount])
return true;
return false;
case GroupRole:
if ([self isSVGGroupElement])
return true;
// All other elements are ignored on the iphone.
default:
case UnknownRole:
......@@ -609,7 +624,6 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
case ScrollAreaRole:
case TableRole:
case ApplicationRole:
case GroupRole:
case RadioGroupRole:
case ListRole:
case ListBoxRole:
......@@ -2057,6 +2071,11 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
return nil;
}
- (CGPoint)accessibilityClickPoint
{
return m_object->clickPoint();
}
// These are used by DRT so that it can know when notifications are sent.
// Since they are static, only one callback can be installed at a time (that's all DRT should need).
typedef void (*AXPostedNotificationCallback)(id element, NSString* notification, void* context);
......
......@@ -38,7 +38,8 @@ public:
DisallowShadowContent = 1 << 8,
AllowFrameScrollbars = 1 << 9,
AllowChildFrameContent = 1 << 10,
ChildFrameHitTest = 1 << 11
ChildFrameHitTest = 1 << 11,
AccessibilityHitTest = 1 << 12
};
typedef unsigned HitTestRequestType;
......
......@@ -186,6 +186,12 @@ bool RenderSVGContainer::nodeAtFloatPoint(const HitTestRequest& request, HitTest
}
}
// Accessibility wants to return SVG containers, if appropriate.
if (request.type() & HitTestRequest::AccessibilityHitTest && m_objectBoundingBox.contains(localPoint)) {
updateHitTestResult(result, roundedLayoutPoint(localPoint));
return true;
}
// Spec: Only graphical elements can be targeted by the mouse, period.
// 16.4: "If there are no graphics elements whose relevant graphics content is under the pointer (i.e., there is no target element), the event is not dispatched."
return false;
......
2013-04-05 Chris Fleizach <cfleizach@apple.com>
AX: Make SVG Group containers accessible elements
https://bugs.webkit.org/show_bug.cgi?id=113939
Reviewed by Simon Fraser.
Implement axController.elementAtPoint for iOS.
Implement a correct version of clickPoint for iOS.
* DumpRenderTree/ios/AccessibilityControllerIOS.mm:
(AccessibilityController::elementAtPoint):
* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::clickPointX):
(AccessibilityUIElement::clickPointY):
2013-04-05 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r147773 and r147774.
......@@ -49,8 +49,7 @@ AccessibilityController::~AccessibilityController()
AccessibilityUIElement AccessibilityController::elementAtPoint(int x, int y)
{
// FIXME: implement
return 0;
return rootElement().elementAtPoint(x, y);
}
AccessibilityUIElement AccessibilityController::focusedElement()
......
......@@ -74,6 +74,7 @@ AccessibilityUIElement::~AccessibilityUIElement()
- (NSString *)stringForRange:(NSRange)range;
- (NSArray *)elementsForRange:(NSRange)range;
- (NSString *)selectionRangeString;
- (CGPoint)accessibilityClickPoint;
- (void)accessibilityModifySelection:(WebCore::TextGranularity)granularity increase:(BOOL)increase;
- (void)accessibilitySetPostedNotificationCallback:(AXPostedNotificationCallback)function withContext:(void*)context;
@end
......@@ -168,13 +169,13 @@ double AccessibilityUIElement::height()
double AccessibilityUIElement::clickPointX()
{
CGPoint centerPoint = [m_element accessibilityActivationPoint];
CGPoint centerPoint = [m_element accessibilityClickPoint];
return centerPoint.x;
}
double AccessibilityUIElement::clickPointY()
{
CGPoint centerPoint = [m_element accessibilityActivationPoint];
CGPoint centerPoint = [m_element accessibilityClickPoint];
return centerPoint.y;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment