WebCore: Fix for https://bugs.webkit.org/show_bug.cgi?id=33923 REGRESSION
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jan 2010 21:31:39 +0000 (21:31 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jan 2010 21:31:39 +0000 (21:31 +0000)
(Safari 4): AXValueChanged no longer sent for text area scrollbars
-and corresponding-
<rdar://problem/6942686>

Reviewed by Oliver Hunt.

New class AccessibilityScrollbar inherits directly from
AccessibilityObject.
* accessibility/AccessibilityScrollbar.cpp: Added.
(WebCore::AccessibilityScrollbar::AccessibilityScrollbar):
(WebCore::AccessibilityScrollbar::create):
(WebCore::AccessibilityScrollbar::valueForRange):
* accessibility/AccessibilityScrollbar.h: Added.
(WebCore::AccessibilityScrollbar::setScrollbar):
(WebCore::AccessibilityScrollbar::roleValue):
(WebCore::AccessibilityScrollbar::accessibilityIsIgnored):
(WebCore::AccessibilityScrollbar::size):
(WebCore::AccessibilityScrollbar::elementRect):
(WebCore::AccessibilityScrollbar::parentObject):

AXObjectCache::getOrCreate() now has a case for ScrollBarRole,
which will create a new AccessibilityScrollbar. I also added a new
version of postNotification() that does not require a renderer. The
old postNotification() calls the new one.
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::getOrCreate):
(WebCore::AXObjectCache::postNotification):
* accessibility/AXObjectCache.h:

When AX is enabled, getOrCreate an AccessibilityScrollbar and send
a notification.
* platform/Scrollbar.cpp:
(WebCore::Scrollbar::scroll):

Fix project files.
* GNUmakefile.am:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* WebCoreSources.bkl:

LayoutTests: Test for https://bugs.webkit.org/show_bug.cgi?id=33923 REGRESSION
(Safari 4): AXValueChanged no longer sent for text area scrollbars
-and corresponding-
<rdar://problem/6942686>

Reviewed by Oliver Hunt.

* platform/mac/accessibility/change-notification-on-scroll-expected.txt: Added.
* platform/mac/accessibility/change-notification-on-scroll.html: Added.

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/change-notification-on-scroll-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/change-notification-on-scroll.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/accessibility/AXObjectCache.cpp
WebCore/accessibility/AXObjectCache.h
WebCore/accessibility/AccessibilityScrollbar.cpp [new file with mode: 0644]
WebCore/accessibility/AccessibilityScrollbar.h [new file with mode: 0644]
WebCore/platform/Scrollbar.cpp

index 6af42ab..2feea0f 100644 (file)
@@ -1,3 +1,15 @@
+2010-01-21  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Test for https://bugs.webkit.org/show_bug.cgi?id=33923 REGRESSION 
+        (Safari 4): AXValueChanged no longer sent for text area scrollbars
+        -and corresponding-
+        <rdar://problem/6942686>
+
+        * platform/mac/accessibility/change-notification-on-scroll-expected.txt: Added.
+        * platform/mac/accessibility/change-notification-on-scroll.html: Added.
+
 2010-01-21  Simon Fraser  <simon.fraser@apple.com>
 
         No review
diff --git a/LayoutTests/platform/mac/accessibility/change-notification-on-scroll-expected.txt b/LayoutTests/platform/mac/accessibility/change-notification-on-scroll-expected.txt
new file mode 100644 (file)
index 0000000..9c03cb8
--- /dev/null
@@ -0,0 +1,2 @@
+
+Success!
diff --git a/LayoutTests/platform/mac/accessibility/change-notification-on-scroll.html b/LayoutTests/platform/mac/accessibility/change-notification-on-scroll.html
new file mode 100644 (file)
index 0000000..96725c2
--- /dev/null
@@ -0,0 +1,36 @@
+<html>
+<body>
+<textarea rows=25 cols=10 id="textarea">
+hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello 
+</textarea>
+
+<div id="result">This test has either failed, or it is being run manually.</div>
+
+<script>
+
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function ariaCallback(notification) {
+        if (notification == "AXValueChanged") {
+            var result = document.getElementById("result");
+            result.innerHTML = "Success!"; 
+            window.layoutTestController.notifyDone();
+        }
+    }
+
+    if (window.accessibilityController) {
+        window.layoutTestController.waitUntilDone();
+        document.getElementById("textarea").focus();
+        var textarea = window.accessibilityController.focusedElement;
+        
+        var addedNotification = textarea.addNotificationListener(ariaCallback);
+        
+        window.eventSender.mouseMoveTo(80, 150);
+        window.eventSender.mouseDown();
+        window.eventSender.mouseUp();
+    }
+</script>
+
+</body>
+</html>
index ee59d17..362c932 100644 (file)
@@ -1,3 +1,46 @@
+2010-01-21  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=33923 REGRESSION 
+        (Safari 4): AXValueChanged no longer sent for text area scrollbars
+        -and corresponding-
+        <rdar://problem/6942686>
+
+        New class AccessibilityScrollbar inherits directly from 
+        AccessibilityObject.
+        * accessibility/AccessibilityScrollbar.cpp: Added.
+        (WebCore::AccessibilityScrollbar::AccessibilityScrollbar):
+        (WebCore::AccessibilityScrollbar::create):
+        (WebCore::AccessibilityScrollbar::valueForRange):
+        * accessibility/AccessibilityScrollbar.h: Added.
+        (WebCore::AccessibilityScrollbar::setScrollbar):
+        (WebCore::AccessibilityScrollbar::roleValue):
+        (WebCore::AccessibilityScrollbar::accessibilityIsIgnored):
+        (WebCore::AccessibilityScrollbar::size):
+        (WebCore::AccessibilityScrollbar::elementRect):
+        (WebCore::AccessibilityScrollbar::parentObject):
+
+        AXObjectCache::getOrCreate() now has a case for ScrollBarRole, 
+        which will create a new AccessibilityScrollbar. I also added a new 
+        version of postNotification() that does not require a renderer. The 
+        old postNotification() calls the new one.
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::getOrCreate):
+        (WebCore::AXObjectCache::postNotification):
+        * accessibility/AXObjectCache.h:
+
+        When AX is enabled, getOrCreate an AccessibilityScrollbar and send 
+        a notification.
+        * platform/Scrollbar.cpp:
+        (WebCore::Scrollbar::scroll):
+
+        Fix project files.
+        * GNUmakefile.am:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * WebCoreSources.bkl:
+
 2010-01-21  Eric Uhrhane  <ericu@chromium.org>
 
         Reviewed by Dmitry Titov.
index 31950c4..9d7f1b4 100644 (file)
@@ -328,6 +328,8 @@ webcore_sources += \
        WebCore/accessibility/AccessibilityObject.h \
        WebCore/accessibility/AccessibilityRenderObject.cpp \
        WebCore/accessibility/AccessibilityRenderObject.h \
+       WebCore/accessibility/AccessibilityScrollbar.cpp \
+       WebCore/accessibility/AccessibilityScrollbar.h \
        WebCore/accessibility/AccessibilitySlider.cpp \
        WebCore/accessibility/AccessibilitySlider.h \
        WebCore/accessibility/AccessibilityTable.cpp \
index 80a3c67..f4bddc6 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\accessibility\AccessibilityScrollbar.cpp"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug_Internal|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug_Cairo|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release_Cairo|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug_All|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\accessibility\AccessibilityScrollbar.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\accessibility\AccessibilitySlider.cpp"\r
                                >\r
                                <FileConfiguration\r
index 4de9bb7..5ae7c58 100644 (file)
                93C441EF0F813A1A00C1A634 /* CollectionCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93C441ED0F813A1A00C1A634 /* CollectionCache.cpp */; };
                93C441F00F813A1A00C1A634 /* CollectionCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C441EE0F813A1A00C1A634 /* CollectionCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93C442000F813AE100C1A634 /* CollectionType.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C441FF0F813AE100C1A634 /* CollectionType.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               93C4F6EA1108F9A50099D0DB /* AccessibilityScrollbar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93C4F6E81108F9A50099D0DB /* AccessibilityScrollbar.cpp */; };
+               93C4F6EB1108F9A50099D0DB /* AccessibilityScrollbar.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C4F6E91108F9A50099D0DB /* AccessibilityScrollbar.h */; };
                93C841F809CE855C00DFF5E5 /* DOMImplementationFront.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C841F709CE855C00DFF5E5 /* DOMImplementationFront.h */; };
                93C841FF09CE858300DFF5E5 /* DOMImplementationFront.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93C841FE09CE858300DFF5E5 /* DOMImplementationFront.cpp */; };
                93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CCF0260AF6C52900018E89 /* NavigationAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93C441ED0F813A1A00C1A634 /* CollectionCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CollectionCache.cpp; sourceTree = "<group>"; };
                93C441EE0F813A1A00C1A634 /* CollectionCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionCache.h; sourceTree = "<group>"; };
                93C441FF0F813AE100C1A634 /* CollectionType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionType.h; sourceTree = "<group>"; };
+               93C4F6E81108F9A50099D0DB /* AccessibilityScrollbar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityScrollbar.cpp; sourceTree = "<group>"; };
+               93C4F6E91108F9A50099D0DB /* AccessibilityScrollbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityScrollbar.h; sourceTree = "<group>"; };
                93C841F709CE855C00DFF5E5 /* DOMImplementationFront.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMImplementationFront.h; sourceTree = "<group>"; };
                93C841FE09CE858300DFF5E5 /* DOMImplementationFront.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMImplementationFront.cpp; sourceTree = "<group>"; };
                93CA4C9909DF93FA00DF8677 /* html.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = html.css; sourceTree = "<group>"; };
                                07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */,
                                76CDD2EC1103DA6600680521 /* AccessibilityMenuList.cpp */,
                                76CDD2ED1103DA6600680521 /* AccessibilityMenuList.h */,
-                               76CDD2EE1103DA6600680521 /* AccessibilityMenuListPopup.cpp */,
-                               76CDD2EF1103DA6600680521 /* AccessibilityMenuListPopup.h */,
                                76CDD2F01103DA6600680521 /* AccessibilityMenuListOption.cpp */,
                                76CDD2F11103DA6600680521 /* AccessibilityMenuListOption.h */,
+                               76CDD2EE1103DA6600680521 /* AccessibilityMenuListPopup.cpp */,
+                               76CDD2EF1103DA6600680521 /* AccessibilityMenuListPopup.h */,
                                29A8121E0FBB9C1D00510293 /* AccessibilityObject.cpp */,
                                29A812180FBB9C1D00510293 /* AccessibilityObject.h */,
                                29A812080FBB9C1D00510293 /* AccessibilityRenderObject.cpp */,
                                29A8121B0FBB9C1D00510293 /* AccessibilityRenderObject.h */,
+                               93C4F6E81108F9A50099D0DB /* AccessibilityScrollbar.cpp */,
+                               93C4F6E91108F9A50099D0DB /* AccessibilityScrollbar.h */,
                                0709FC4B1025DED80059CDBA /* AccessibilitySlider.cpp */,
                                0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */,
                                29A812090FBB9C1D00510293 /* AccessibilityTable.cpp */,
                                2E2D99E710E2BC1C00496337 /* DOMBlob.h in Headers */,
                                2E2D99EA10E2BC3800496337 /* DOMBlobInternal.h in Headers */,
                                59B5977511086579007159E8 /* BridgeJSC.h in Headers */,
+                               93C4F6EB1108F9A50099D0DB /* AccessibilityScrollbar.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                2E2D99CD10E2BBDA00496337 /* JSBlob.cpp in Sources */,
                                2E2D99E810E2BC1C00496337 /* DOMBlob.mm in Sources */,
                                59B597731108656B007159E8 /* BridgeJSC.cpp in Sources */,
+                               93C4F6EA1108F9A50099D0DB /* AccessibilityScrollbar.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 43fb7e3..6d4c2b2 100644 (file)
@@ -43,6 +43,7 @@ This file contains the list of files needed to build WebCore.
         accessibility/AccessibilityListBox.cpp
         accessibility/AccessibilityListBoxOption.cpp
         accessibility/AccessibilityRenderObject.cpp
+        accessibility/AccessibilityScrollbar.cpp
         accessibility/AccessibilitySlider.cpp
         accessibility/AccessibilityTable.cpp
         accessibility/AccessibilityTableCell.cpp
index 7a7a4f2..1cd917f 100644 (file)
@@ -41,6 +41,7 @@
 #include "AccessibilityMenuListPopup.h"
 #include "AccessibilityMenuListOption.h"
 #include "AccessibilityRenderObject.h"
+#include "AccessibilityScrollbar.h"
 #include "AccessibilitySlider.h"
 #include "AccessibilityTable.h"
 #include "AccessibilityTableCell.h"
@@ -220,6 +221,9 @@ AccessibilityObject* AXObjectCache::getOrCreate(AccessibilityRole role)
     case MenuListOptionRole:
         obj = AccessibilityMenuListOption::create();
         break;
+    case ScrollBarRole:
+        obj = AccessibilityScrollbar::create();
+        break;
     default:
         obj = 0;
     }
@@ -368,31 +372,35 @@ void AXObjectCache::postNotification(RenderObject* renderer, AXNotification noti
     
     // Get an accessibility object that already exists. One should not be created here
     // because a render update may be in progress and creating an AX object can re-trigger a layout
-    RefPtr<AccessibilityObject> obj = get(renderer);
-    while (!obj && renderer) {
+    RefPtr<AccessibilityObject> object = get(renderer);
+    while (!object && renderer) {
         renderer = renderer->parent();
-        obj = get(renderer); 
+        object = get(renderer); 
     }
     
     if (!renderer)
         return;
-
-    if (obj && !postToElement)
-        obj = obj->observableObject();
-    
-    Document* document = renderer->document();
-    if (!obj && document)
-        obj = get(document->renderer());
     
-    if (!obj)
+    postNotification(object.get(), renderer->document(), notification, postToElement, postType);
+}
+
+void AXObjectCache::postNotification(AccessibilityObject* object, Document* document, AXNotification notification, bool postToElement, PostType postType)
+{
+    if (object && !postToElement)
+        object = object->observableObject();
+
+    if (!object && document)
+        object = get(document->renderer());
+
+    if (!object)
         return;
 
     if (postType == PostAsynchronously) {
-        m_notificationsToPost.append(make_pair(obj, notification));
+        m_notificationsToPost.append(make_pair(object, notification));
         if (!m_notificationPostTimer.isActive())
             m_notificationPostTimer.startOneShot(0);
     } else
-        postPlatformNotification(obj.get(), notification);
+        postPlatformNotification(object, notification);
 }
 
 void AXObjectCache::selectedChildrenChanged(RenderObject* renderer)
index 986241e..ee51ff5 100644 (file)
@@ -118,6 +118,7 @@ public:
     };
 
     void postNotification(RenderObject*, AXNotification, bool postToElement, PostType = PostAsynchronously);
+    void postNotification(AccessibilityObject*, Document*, AXNotification, bool postToElement, PostType = PostAsynchronously);
 
 protected:
     void postPlatformNotification(AccessibilityObject*, AXNotification);
diff --git a/WebCore/accessibility/AccessibilityScrollbar.cpp b/WebCore/accessibility/AccessibilityScrollbar.cpp
new file mode 100644 (file)
index 0000000..717d0da
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AccessibilityScrollbar.h"
+
+#include "Scrollbar.h"
+
+namespace WebCore {
+
+AccessibilityScrollbar::AccessibilityScrollbar()
+    : m_scrollbar(0)
+{
+}
+
+PassRefPtr<AccessibilityScrollbar> AccessibilityScrollbar::create()
+{
+    return adoptRef(new AccessibilityScrollbar);
+}
+
+float AccessibilityScrollbar::valueForRange() const
+{
+    if (!m_scrollbar)
+        return 0;
+    return m_scrollbar->currentPos();
+}
+
+} // namespace WebCore
diff --git a/WebCore/accessibility/AccessibilityScrollbar.h b/WebCore/accessibility/AccessibilityScrollbar.h
new file mode 100644 (file)
index 0000000..d75e60c
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef AccessibilityScrollbar_h
+#define AccessibilityScrollbar_h
+
+#include "AccessibilityObject.h"
+
+namespace WebCore {
+
+class Scrollbar;
+
+class AccessibilityScrollbar : public AccessibilityObject {
+public:
+    static PassRefPtr<AccessibilityScrollbar> create();
+
+    void setScrollbar(Scrollbar* scrollbar) { m_scrollbar = scrollbar; }
+
+    virtual AccessibilityRole roleValue() const { return ScrollBarRole; }
+
+    virtual float valueForRange() const;
+
+private:
+    AccessibilityScrollbar();
+
+    virtual bool accessibilityIsIgnored() const { return false; }
+
+    // These should never be reached since the AccessibilityScrollbar is not part of
+    // the accessibility tree.
+    virtual IntSize size() const { ASSERT_NOT_REACHED(); return IntSize(); }
+    virtual IntRect elementRect() const { ASSERT_NOT_REACHED(); return IntRect(); }
+    virtual AccessibilityObject* parentObject() const { ASSERT_NOT_REACHED(); return 0; }
+
+    Scrollbar* m_scrollbar;
+};
+
+} // namespace WebCore
+
+#endif // AccessibilityScrollbar_h
index 4eb2c4a..8e0909e 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "Scrollbar.h"
 
+#include "AccessibilityScrollbar.h"
+#include "AXObjectCache.h"
 #include "EventHandler.h"
 #include "Frame.h"
 #include "FrameView.h"
@@ -117,6 +119,16 @@ void Scrollbar::setSteps(int lineStep, int pageStep, int pixelsPerStep)
 
 bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
 {
+    if (AXObjectCache::accessibilityEnabled()) {
+        if (parent() && parent()->isFrameView()) {
+            Document* document = static_cast<FrameView*>(parent())->frame()->document();
+            AXObjectCache* cache = document->axObjectCache();
+            AccessibilityScrollbar* axObject = static_cast<AccessibilityScrollbar*>(cache->getOrCreate(ScrollBarRole));
+            axObject->setScrollbar(this);
+            cache->postNotification(axObject, document, AXObjectCache::AXValueChanged, true);
+        }
+    }
+
     float step = 0;
     if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar))
         step = -1;