Bug 26900: AX: Manual spell check with Command-; does not bring up suggestions
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jul 2009 22:01:16 +0000 (22:01 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jul 2009 22:01:16 +0000 (22:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=26900

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45452 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/editable-webarea-context-menu-point-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/editable-webarea-context-menu-point.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/accessibility/AccessibilityObject.h
WebCore/accessibility/AccessibilityRenderObject.cpp
WebCore/accessibility/AccessibilityRenderObject.h
WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp
WebKitTools/DumpRenderTree/AccessibilityUIElement.h
WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp

index f55ab21..d71664b 100644 (file)
@@ -1,3 +1,13 @@
+2009-07-01  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        Tests for Bug 26900: AX: Manual spell check with Command-; does not bring up suggestions
+        https://bugs.webkit.org/show_bug.cgi?id=26900
+
+        * accessibility/editable-webarea-context-menu-point-expected.txt: Added.
+        * accessibility/editable-webarea-context-menu-point.html: Added.
+
 2009-07-01  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
 
         Reviewed by George Staikos.
diff --git a/LayoutTests/accessibility/editable-webarea-context-menu-point-expected.txt b/LayoutTests/accessibility/editable-webarea-context-menu-point-expected.txt
new file mode 100644 (file)
index 0000000..dd1b133
--- /dev/null
@@ -0,0 +1,11 @@
+This tests that the click point, used for opening context menus, changes based on the current selection in an editable web area. This tests that the click point, used for opening context menus, changes based on the current selection in an editable web area.
+This tests that the click point, used for opening context menus, changes based on the current selection in an editable web area (by setting the selection twice and comparing the click point locations)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS succeeded is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/editable-webarea-context-menu-point.html b/LayoutTests/accessibility/editable-webarea-context-menu-point.html
new file mode 100644 (file)
index 0000000..5053240
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body" contenteditable>
+This tests that the click point, used for opening context menus, changes based on the current selection in an editable web area.
+This tests that the click point, used for opening context menus, changes based on the current selection in an editable web area.
+
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the click point, used for opening context menus, changes based on the current selection in an editable web area (by setting the selection twice and comparing the click point locations)");
+
+    if (window.accessibilityController) {
+
+          var body = document.getElementById("body");
+          body.focus();
+
+          x = body.offsetLeft + 10;
+          y = body.offsetTop + 10;
+
+          eventSender.mouseMoveTo(x, y);
+          eventSender.mouseDown();
+          eventSender.mouseUp();
+          eventSender.mouseDown();
+          eventSender.mouseUp();
+
+          var clickPointX1 = accessibilityController.focusedElement.clickPointX;
+
+          x = body.offsetLeft + 100 + 10;
+          y = body.offsetTop + 10;
+
+          eventSender.mouseMoveTo(x, y);
+          eventSender.mouseDown();
+          eventSender.mouseUp();
+          eventSender.mouseDown();
+          eventSender.mouseUp();
+
+          var clickPointX2 = accessibilityController.focusedElement.clickPointX;
+          var succeeded = clickPointX2 != clickPointX1;
+          shouldBe("succeeded", "true");
+
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index d51bffe..a75c6b3 100644 (file)
@@ -1,3 +1,21 @@
+2009-07-01  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        Bug 26900: AX: Manual spell check with Command-; does not bring up suggestions
+        https://bugs.webkit.org/show_bug.cgi?id=26900
+
+        Editable web areas should have a clickpoint that uses where the selection is.
+
+        Test: accessibility/editable-webarea-context-menu-point.html
+
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::clickPoint):
+        * accessibility/AccessibilityRenderObject.h:
+        * accessibility/mac/AccessibilityObjectWrapper.mm:
+        (-[AccessibilityObjectWrapper accessibilityAttributeValue:]):
+
 2009-07-01  David Levin  <levin@chromium.org>
 
         Reviewed by Eric Seidel.
index 8939092..89f03e8 100644 (file)
@@ -285,7 +285,7 @@ public:
     virtual IntRect boundingBoxRect() const;
     virtual IntRect elementRect() const;
     virtual IntSize size() const;
-    IntPoint clickPoint() const;
+    virtual IntPoint clickPoint() const;
     
     virtual KURL url() const;
     virtual PlainTextRange selectedTextRange() const;
index 7d4cb39..ac1e0e9 100644 (file)
@@ -1063,6 +1063,21 @@ IntSize AccessibilityRenderObject::size() const
     return rect.size();
 }
 
+IntPoint AccessibilityRenderObject::clickPoint() const
+{
+    // use the default position unless this is an editable web area, in which case we use the selection bounds.
+    if (!isWebArea() || isReadOnly())
+        return AccessibilityObject::clickPoint();
+    
+    VisibleSelection visSelection = selection();
+    VisiblePositionRange range = VisiblePositionRange(visSelection.visibleStart(), visSelection.visibleEnd());
+    IntRect bounds = boundsForVisiblePositionRange(range);
+#if PLATFORM(MAC)
+    bounds.setLocation(m_renderer->document()->view()->screenToContents(bounds.location()));
+#endif        
+    return IntPoint(bounds.x() + (bounds.width() / 2), bounds.y() - (bounds.height() / 2));
+}
+    
 AccessibilityObject* AccessibilityRenderObject::internalLinkElement() const
 {
     Element* element = anchorElement();
index 4fa325f..4f8e247 100644 (file)
@@ -147,6 +147,7 @@ public:
     virtual IntRect boundingBoxRect() const;
     virtual IntRect elementRect() const;
     virtual IntSize size() const;
+    virtual IntPoint clickPoint() const;
     
     void setRenderer(RenderObject* renderer) { m_renderer = renderer; }
     RenderObject* renderer() const { return m_renderer; }
index 1839ff5..010d8b8 100644 (file)
@@ -1459,6 +1459,10 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if ([attributeName isEqualToString:NSAccessibilityLanguageAttribute]) 
         return m_object->language();
     
+    // this is used only by DumpRenderTree for testing
+    if ([attributeName isEqualToString:@"AXClickPoint"])
+        return [NSValue valueWithPoint:m_object->clickPoint()];
+    
     return nil;
 }
 
index 901cccf..3ab7e10 100644 (file)
@@ -1,3 +1,24 @@
+2009-07-01  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        Bug 26900: AX: Manual spell check with Command-; does not bring up suggestions
+        https://bugs.webkit.org/show_bug.cgi?id=26900
+
+        Expose the ability to get the click point of an element through accessibility.
+
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (getClickPointXCallback):
+        (getClickPointYCallback):
+        (AccessibilityUIElement::getJSClass):
+        * DumpRenderTree/AccessibilityUIElement.h:
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::clickPointX):
+        (AccessibilityUIElement::clickPointY):
+        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+        (AccessibilityUIElement::clickPointX):
+        (AccessibilityUIElement::clickPointY):
+
 2009-07-01  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Simon Fraser.
index 9509f86..511643c 100644 (file)
@@ -268,6 +268,16 @@ static JSValueRef getHeightCallback(JSContextRef context, JSObjectRef thisObject
     return JSValueMakeNumber(context, toAXElement(thisObject)->height());
 }
 
+static JSValueRef getClickPointXCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+{
+    return JSValueMakeNumber(context, toAXElement(thisObject)->clickPointX());
+}
+
+static JSValueRef getClickPointYCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+{
+    return JSValueMakeNumber(context, toAXElement(thisObject)->clickPointY());
+}
+
 static JSValueRef getIntValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
     return JSValueMakeNumber(context, toAXElement(thisObject)->intValue());
@@ -329,6 +339,8 @@ JSClassRef AccessibilityUIElement::getJSClass()
         { "y", getYCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "width", getWidthCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "height", getHeightCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "clickPointX", getClickPointXCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "clickPointY", getClickPointYCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "intValue", getIntValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "minValue", getMinValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "maxValue", getMaxValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index 9e7ed93..227e092 100644 (file)
@@ -93,6 +93,8 @@ public:
     JSStringRef selectedTextRange();
     bool supportsPressAction();
     bool isEnabled();
+    double clickPointX();
+    double clickPointY();
 
     // Table-specific attributes
     JSStringRef attributesOfColumnHeaders();
index 6c9a1ac..204d500 100644 (file)
@@ -348,6 +348,18 @@ double AccessibilityUIElement::height()
     return static_cast<double>([sizeValue sizeValue].height);
 }
 
+double AccessibilityUIElement::clickPointX()
+{
+    NSValue* positionValue = [m_element accessibilityAttributeValue:@"AXClickPoint"];
+    return static_cast<double>([positionValue pointValue].x);        
+}
+
+double AccessibilityUIElement::clickPointY()
+{
+    NSValue* positionValue = [m_element accessibilityAttributeValue:@"AXClickPoint"];
+    return static_cast<double>([positionValue pointValue].x);            
+}
+
 double AccessibilityUIElement::intValue()
 {
     id value = [m_element accessibilityAttributeValue:NSAccessibilityValueAttribute];
index 79e60ac..5f31723 100644 (file)
@@ -214,6 +214,16 @@ double AccessibilityUIElement::height()
     return height;
 }
 
+double AccessibilityUIElement::clickPointX()
+{
+    return 0;
+}
+
+double AccessibilityUIElement::clickPointY()
+{
+    return 0;
+}
+
 double AccessibilityUIElement::intValue()
 {
     BSTR valueBSTR;