AX: The scrollArea is not correctly returning the scrollbars
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2011 21:48:43 +0000 (21:48 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2011 21:48:43 +0000 (21:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70247

Reviewed by Beth Dakin.

Source/WebCore:

A few bugs that were preventing this from working.
   1) In accessibilityAttributeValue: when an element did not have a renderer() we were returning earlier than we should have
   2) We were not updating and clearing the scrollbars correctly when children were cleared or when asked for.

Test: platform/mac/accessibility/scrollbars.html

* accessibility/AccessibilityScrollView.cpp:
(WebCore::AccessibilityScrollView::scrollBar):
(WebCore::AccessibilityScrollView::clearChildren):
* accessibility/AccessibilityScrollView.h:
* accessibility/mac/WebAccessibilityObjectWrapper.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

LayoutTests:

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

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/scrollbars-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/scrollbars.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityScrollView.cpp
Source/WebCore/accessibility/AccessibilityScrollView.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm

index 983f1df..7a2a8f2 100755 (executable)
@@ -1,3 +1,13 @@
+2011-11-17  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: The scrollArea is not correctly returning the scrollbars
+        https://bugs.webkit.org/show_bug.cgi?id=70247
+
+        Reviewed by Beth Dakin.
+
+        * platform/mac/accessibility/scrollbars-expected.txt: Added.
+        * platform/mac/accessibility/scrollbars.html: Added.
+
 2011-11-17  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r100659.
diff --git a/LayoutTests/platform/mac/accessibility/scrollbars-expected.txt b/LayoutTests/platform/mac/accessibility/scrollbars-expected.txt
new file mode 100644 (file)
index 0000000..d35b41e
--- /dev/null
@@ -0,0 +1,310 @@
+This tests that a scroll area will return scroll bars when asked.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS scrollArea.role is 'AXRole: AXScrollArea'
+PASS scrollArea.verticalScrollbar.role is 'AXRole: AXScrollBar'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LayoutTests/platform/mac/accessibility/scrollbars.html b/LayoutTests/platform/mac/accessibility/scrollbars.html
new file mode 100644 (file)
index 0000000..383e735
--- /dev/null
@@ -0,0 +1,45 @@
+<!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" tabindex="0">
+
+<p id="description"></p>
+<div id="console"></div>
+
+<div role="textbox" id="iframeGroup"></div>
+
+<script>
+
+    description("This tests that a scroll area will return scroll bars when asked.");
+
+   if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var body = accessibilityController.focusedElement;
+    }
+
+    // Cause the web page to gain scrollbars.
+    for (var k = 0; k < 100; k++) {
+       document.getElementById("body").innerHTML += "<br><br><br>";
+    }
+
+     if (window.accessibilityController) {
+          document.getElementById("body").focus();
+          var body = accessibilityController.focusedElement;
+
+          var scrollArea = body.parentElement();
+          shouldBe("scrollArea.role", "'AXRole: AXScrollArea'");
+          shouldBe("scrollArea.verticalScrollbar.role", "'AXRole: AXScrollBar'");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 3150aa4..dcd088d 100644 (file)
@@ -1,3 +1,23 @@
+2011-11-17  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: The scrollArea is not correctly returning the scrollbars
+        https://bugs.webkit.org/show_bug.cgi?id=70247
+
+        Reviewed by Beth Dakin.
+
+        A few bugs that were preventing this from working.
+           1) In accessibilityAttributeValue: when an element did not have a renderer() we were returning earlier than we should have
+           2) We were not updating and clearing the scrollbars correctly when children were cleared or when asked for.
+
+        Test: platform/mac/accessibility/scrollbars.html
+
+        * accessibility/AccessibilityScrollView.cpp:
+        (WebCore::AccessibilityScrollView::scrollBar):
+        (WebCore::AccessibilityScrollView::clearChildren):
+        * accessibility/AccessibilityScrollView.h:
+        * accessibility/mac/WebAccessibilityObjectWrapper.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+
 2011-11-14  Adam Barth  <abarth@webkit.org>
 
         Unique origins shouldn't remember their scheme, host, or port
index bbec914..6910b34 100644 (file)
@@ -487,7 +487,7 @@ public:
     virtual bool exposesTitleUIElement() const { return true; }
     virtual AccessibilityObject* correspondingLabelForControlElement() const { return 0; }
     virtual AccessibilityObject* correspondingControlForLabelElement() const { return 0; }
-    virtual AccessibilityObject* scrollBar(AccessibilityOrientation) const { return 0; }
+    virtual AccessibilityObject* scrollBar(AccessibilityOrientation) { return 0; }
     
     virtual AccessibilityRole ariaRoleAttribute() const { return UnknownRole; }
     virtual bool isPresentationalChildOfAriaRole() const { return false; }
index 40b1532..46bd8a0 100644 (file)
@@ -48,8 +48,10 @@ PassRefPtr<AccessibilityScrollView> AccessibilityScrollView::create(ScrollView*
     return adoptRef(new AccessibilityScrollView(view));
 }
     
-AccessibilityObject* AccessibilityScrollView::scrollBar(AccessibilityOrientation orientation) const
+AccessibilityObject* AccessibilityScrollView::scrollBar(AccessibilityOrientation orientation)
 {
+    updateScrollbars();
+    
     switch (orientation) {
     case AccessibilityOrientationVertical:
         return m_verticalScrollbar ? m_verticalScrollbar.get() : 0;
@@ -121,6 +123,13 @@ AccessibilityScrollbar* AccessibilityScrollView::addChildScrollbar(Scrollbar* sc
     return scrollBarObject;
 }
         
+void AccessibilityScrollView::clearChildren()
+{
+    AccessibilityObject::clearChildren();
+    m_verticalScrollbar = 0;
+    m_horizontalScrollbar = 0;
+}
+    
 void AccessibilityScrollView::addChildren()
 {
     ASSERT(!m_haveChildren);
index 905be98..8d41af1 100644 (file)
@@ -50,8 +50,9 @@ private:
     virtual bool isAttachment() const;
     virtual Widget* widgetForAttachmentView() const;
     
-    virtual AccessibilityObject* scrollBar(AccessibilityOrientation) const;
+    virtual AccessibilityObject* scrollBar(AccessibilityOrientation);
     virtual void addChildren();
+    virtual void clearChildren();
     virtual AccessibilityObject* accessibilityHitTest(const LayoutPoint&) const;
     virtual void updateChildrenIfNecessary();
     virtual void setNeedsToUpdateChildren() { m_childrenDirty = true; }
index f1b5620..845e81f 100644 (file)
@@ -2218,31 +2218,18 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if ([attributeName isEqualToString: @"AXSelectedTextMarkerRange"])
         return [self textMarkerRangeForSelection];
     
-    if (m_object->isAccessibilityRenderObject()) {
-        RenderObject* renderer = static_cast<AccessibilityRenderObject*>(m_object)->renderer();
-        if (!renderer)
-            return nil;
-        
+    if (m_object->renderer()) {
         if ([attributeName isEqualToString: @"AXStartTextMarker"])
-            return [self textMarkerForVisiblePosition:startOfDocument(renderer->document())];
+            return [self textMarkerForVisiblePosition:startOfDocument(m_object->renderer()->document())];
         if ([attributeName isEqualToString: @"AXEndTextMarker"])
-            return [self textMarkerForVisiblePosition:endOfDocument(renderer->document())];
-
-        if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute])
-            return [NSNumber numberWithInt:m_object->blockquoteLevel()];
-        if ([attributeName isEqualToString:@"AXTableLevel"])
-            return [NSNumber numberWithInt:m_object->tableLevel()];
-    } else {
-        AccessibilityObject* parent = m_object->parentObjectUnignored();
-        if (!parent)
-            return [NSNumber numberWithInt:0];
-        
-        if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute])
-            return [parent->wrapper() accessibilityAttributeValue:NSAccessibilityBlockQuoteLevelAttribute];
-        if ([attributeName isEqualToString:@"AXTableLevel"])
-            return [parent->wrapper() accessibilityAttributeValue:@"AXTableLevel"];
+            return [self textMarkerForVisiblePosition:endOfDocument(m_object->renderer()->document())];
     }
     
+    if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute])
+        return [NSNumber numberWithInt:m_object->blockquoteLevel()];
+    if ([attributeName isEqualToString:@"AXTableLevel"])
+        return [NSNumber numberWithInt:m_object->tableLevel()];
+    
     if ([attributeName isEqualToString: NSAccessibilityLinkedUIElementsAttribute]) {
         AccessibilityObject::AccessibilityChildrenVector linkedUIElements;
         m_object->linkedUIElements(linkedUIElements);