AX: click point for AXHeadings often returns point on empty space (results in wrong...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 18:04:54 +0000 (18:04 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 18:04:54 +0000 (18:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69262

Source/WebCore:

When the contextual menu is opened for a heading, often it will open on empty space because
the heading is wider than the content inside. The click point should thus use the content
inside the heading as the click point.

To accomplish this we need to query whether we have children using children() which is a non-const
method, hence the removal of const from clickPoint().

Reviewed by John Sullivan.

Test: platform/mac/accessibility/heading-clickpoint.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::clickPoint):
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::clickPoint):
* accessibility/AccessibilityRenderObject.h:

LayoutTests:

Reviewed by John Sullivan.

* platform/mac/accessibility/heading-clickpoint-expected.txt: Added.
* platform/mac/accessibility/heading-clickpoint.html: Added.

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

LayoutTests/ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.h

index 1c4e4e3..b13e47c 100644 (file)
@@ -1,3 +1,13 @@
+2011-10-03  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: click point for AXHeadings often returns point on empty space (results in wrong context menu)
+        https://bugs.webkit.org/show_bug.cgi?id=69262
+
+        Reviewed by John Sullivan.
+
+        * platform/mac/accessibility/heading-clickpoint-expected.txt: Added.
+        * platform/mac/accessibility/heading-clickpoint.html: Added.
+
 2011-10-03  Adam Barth  <abarth@webkit.org>
 
         Unbork the test_expectations file.
index cda23bd..7f3cb1d 100644 (file)
@@ -1,3 +1,26 @@
+2011-10-03  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: click point for AXHeadings often returns point on empty space (results in wrong context menu)
+        https://bugs.webkit.org/show_bug.cgi?id=69262
+
+        When the contextual menu is opened for a heading, often it will open on empty space because
+        the heading is wider than the content inside. The click point should thus use the content
+        inside the heading as the click point.
+
+        To accomplish this we need to query whether we have children using children() which is a non-const
+        method, hence the removal of const from clickPoint().
+
+        Reviewed by John Sullivan.
+
+        Test: platform/mac/accessibility/heading-clickpoint.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::clickPoint):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::clickPoint):
+        * accessibility/AccessibilityRenderObject.h:
+
 2011-10-03  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r96500.
index 90f3be2..d55dd3b 100644 (file)
@@ -399,7 +399,7 @@ bool AccessibilityObject::isARIAControl(AccessibilityRole ariaRole)
     || ariaRole == ComboBoxRole || ariaRole == SliderRole; 
 }
 
-LayoutPoint AccessibilityObject::clickPoint() const
+LayoutPoint AccessibilityObject::clickPoint()
 {
     LayoutRect rect = elementRect();
     return LayoutPoint(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2);
index ab13167..1007e4b 100644 (file)
@@ -507,7 +507,7 @@ public:
     virtual LayoutRect boundingBoxRect() const { return LayoutRect(); }
     virtual LayoutRect elementRect() const = 0;
     virtual LayoutSize size() const { return elementRect().size(); }
-    virtual LayoutPoint clickPoint() const;
+    virtual LayoutPoint clickPoint();
 
     virtual PlainTextRange selectedTextRange() const { return PlainTextRange(); }
     unsigned selectionStart() const { return selectedTextRange().start; }
index 95c2318..29232b0 100644 (file)
@@ -1496,8 +1496,12 @@ LayoutSize AccessibilityRenderObject::size() const
     return rect.size();
 }
 
-LayoutPoint AccessibilityRenderObject::clickPoint() const
+LayoutPoint AccessibilityRenderObject::clickPoint()
 {
+    // Headings are usually much wider than their textual content. If the mid point is used, often it can be wrong.
+    if (isHeading() && children().size() == 1)
+        return children()[0]->clickPoint();
+
     // 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();
index 97afdd1..6a20706 100644 (file)
@@ -166,7 +166,7 @@ public:
     virtual LayoutRect boundingBoxRect() const;
     virtual LayoutRect elementRect() const;
     virtual LayoutSize size() const;
-    virtual LayoutPoint clickPoint() const;
+    virtual LayoutPoint clickPoint();
     
     void setRenderer(RenderObject* renderer) { m_renderer = renderer; }
     virtual RenderObject* renderer() const { return m_renderer; }