From cad810f21b803229eb11403f9209855525a25d57 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Fri, 6 May 2011 11:45:16 +0100 Subject: Merge WebKit at r75315: Initial merge by git. Change-Id: I570314b346ce101c935ed22a626b48c2af266b84 --- Source/WebCore/accessibility/AXObjectCache.cpp | 632 ++++ Source/WebCore/accessibility/AXObjectCache.h | 198 ++ .../accessibility/AccessibilityARIAGrid.cpp | 154 + .../WebCore/accessibility/AccessibilityARIAGrid.h | 63 + .../accessibility/AccessibilityARIAGridCell.cpp | 96 + .../accessibility/AccessibilityARIAGridCell.h | 55 + .../accessibility/AccessibilityARIAGridRow.cpp | 141 + .../accessibility/AccessibilityARIAGridRow.h | 56 + .../accessibility/AccessibilityAllInOne.cpp | 46 + .../accessibility/AccessibilityImageMapLink.cpp | 149 + .../accessibility/AccessibilityImageMapLink.h | 83 + Source/WebCore/accessibility/AccessibilityList.cpp | 111 + Source/WebCore/accessibility/AccessibilityList.h | 62 + .../WebCore/accessibility/AccessibilityListBox.cpp | 197 ++ .../WebCore/accessibility/AccessibilityListBox.h | 64 + .../accessibility/AccessibilityListBoxOption.cpp | 219 ++ .../accessibility/AccessibilityListBoxOption.h | 79 + .../accessibility/AccessibilityMediaControls.cpp | 331 ++ .../accessibility/AccessibilityMediaControls.h | 117 + .../accessibility/AccessibilityMenuList.cpp | 90 + .../WebCore/accessibility/AccessibilityMenuList.h | 61 + .../accessibility/AccessibilityMenuListOption.cpp | 118 + .../accessibility/AccessibilityMenuListOption.h | 70 + .../accessibility/AccessibilityMenuListPopup.cpp | 126 + .../accessibility/AccessibilityMenuListPopup.h | 68 + .../WebCore/accessibility/AccessibilityObject.cpp | 1071 ++++++ Source/WebCore/accessibility/AccessibilityObject.h | 614 ++++ .../AccessibilityProgressIndicator.cpp | 78 + .../accessibility/AccessibilityProgressIndicator.h | 57 + .../accessibility/AccessibilityRenderObject.cpp | 3688 ++++++++++++++++++++ .../accessibility/AccessibilityRenderObject.h | 332 ++ .../accessibility/AccessibilityScrollView.cpp | 165 + .../accessibility/AccessibilityScrollView.h | 79 + .../accessibility/AccessibilityScrollbar.cpp | 105 + .../WebCore/accessibility/AccessibilityScrollbar.h | 72 + .../WebCore/accessibility/AccessibilitySlider.cpp | 184 + Source/WebCore/accessibility/AccessibilitySlider.h | 93 + .../WebCore/accessibility/AccessibilityTable.cpp | 567 +++ Source/WebCore/accessibility/AccessibilityTable.h | 97 + .../accessibility/AccessibilityTableCell.cpp | 179 + .../WebCore/accessibility/AccessibilityTableCell.h | 65 + .../accessibility/AccessibilityTableColumn.cpp | 200 ++ .../accessibility/AccessibilityTableColumn.h | 75 + .../AccessibilityTableHeaderContainer.cpp | 98 + .../AccessibilityTableHeaderContainer.h | 66 + .../accessibility/AccessibilityTableRow.cpp | 125 + .../WebCore/accessibility/AccessibilityTableRow.h | 65 + .../chromium/AXObjectCacheChromium.cpp | 127 + .../chromium/AccessibilityObjectChromium.cpp | 45 + .../chromium/AccessibilityObjectWrapper.h | 54 + .../accessibility/efl/AccessibilityObjectEfl.cpp | 36 + .../WebCore/accessibility/gtk/AXObjectCacheAtk.cpp | 166 + .../accessibility/gtk/AccessibilityObjectAtk.cpp | 136 + .../gtk/AccessibilityObjectWrapperAtk.cpp | 2489 +++++++++++++ .../gtk/AccessibilityObjectWrapperAtk.h | 67 + .../gtk/WebKitAccessibleHyperlink.cpp | 392 +++ .../accessibility/gtk/WebKitAccessibleHyperlink.h | 63 + .../WebCore/accessibility/mac/AXObjectCacheMac.mm | 139 + .../accessibility/mac/AccessibilityObjectMac.mm | 66 + .../accessibility/mac/AccessibilityObjectWrapper.h | 60 + .../mac/AccessibilityObjectWrapper.mm | 2850 +++++++++++++++ .../accessibility/qt/AccessibilityObjectQt.cpp | 42 + .../WebCore/accessibility/win/AXObjectCacheWin.cpp | 147 + .../accessibility/win/AccessibilityObjectWin.cpp | 48 + .../win/AccessibilityObjectWrapperWin.h | 54 + .../accessibility/wx/AccessibilityObjectWx.cpp | 42 + 66 files changed, 18484 insertions(+) create mode 100644 Source/WebCore/accessibility/AXObjectCache.cpp create mode 100644 Source/WebCore/accessibility/AXObjectCache.h create mode 100644 Source/WebCore/accessibility/AccessibilityARIAGrid.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityARIAGrid.h create mode 100644 Source/WebCore/accessibility/AccessibilityARIAGridCell.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityARIAGridCell.h create mode 100644 Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityARIAGridRow.h create mode 100644 Source/WebCore/accessibility/AccessibilityAllInOne.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityImageMapLink.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityImageMapLink.h create mode 100644 Source/WebCore/accessibility/AccessibilityList.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityList.h create mode 100644 Source/WebCore/accessibility/AccessibilityListBox.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityListBox.h create mode 100644 Source/WebCore/accessibility/AccessibilityListBoxOption.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityListBoxOption.h create mode 100644 Source/WebCore/accessibility/AccessibilityMediaControls.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityMediaControls.h create mode 100644 Source/WebCore/accessibility/AccessibilityMenuList.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityMenuList.h create mode 100644 Source/WebCore/accessibility/AccessibilityMenuListOption.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityMenuListOption.h create mode 100644 Source/WebCore/accessibility/AccessibilityMenuListPopup.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityMenuListPopup.h create mode 100644 Source/WebCore/accessibility/AccessibilityObject.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityObject.h create mode 100644 Source/WebCore/accessibility/AccessibilityProgressIndicator.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityProgressIndicator.h create mode 100644 Source/WebCore/accessibility/AccessibilityRenderObject.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityRenderObject.h create mode 100644 Source/WebCore/accessibility/AccessibilityScrollView.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityScrollView.h create mode 100644 Source/WebCore/accessibility/AccessibilityScrollbar.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityScrollbar.h create mode 100644 Source/WebCore/accessibility/AccessibilitySlider.cpp create mode 100644 Source/WebCore/accessibility/AccessibilitySlider.h create mode 100644 Source/WebCore/accessibility/AccessibilityTable.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityTable.h create mode 100644 Source/WebCore/accessibility/AccessibilityTableCell.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityTableCell.h create mode 100644 Source/WebCore/accessibility/AccessibilityTableColumn.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityTableColumn.h create mode 100644 Source/WebCore/accessibility/AccessibilityTableHeaderContainer.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityTableHeaderContainer.h create mode 100644 Source/WebCore/accessibility/AccessibilityTableRow.cpp create mode 100644 Source/WebCore/accessibility/AccessibilityTableRow.h create mode 100644 Source/WebCore/accessibility/chromium/AXObjectCacheChromium.cpp create mode 100644 Source/WebCore/accessibility/chromium/AccessibilityObjectChromium.cpp create mode 100644 Source/WebCore/accessibility/chromium/AccessibilityObjectWrapper.h create mode 100644 Source/WebCore/accessibility/efl/AccessibilityObjectEfl.cpp create mode 100644 Source/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp create mode 100644 Source/WebCore/accessibility/gtk/AccessibilityObjectAtk.cpp create mode 100644 Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp create mode 100644 Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.h create mode 100644 Source/WebCore/accessibility/gtk/WebKitAccessibleHyperlink.cpp create mode 100644 Source/WebCore/accessibility/gtk/WebKitAccessibleHyperlink.h create mode 100644 Source/WebCore/accessibility/mac/AXObjectCacheMac.mm create mode 100644 Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm create mode 100644 Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.h create mode 100644 Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm create mode 100644 Source/WebCore/accessibility/qt/AccessibilityObjectQt.cpp create mode 100644 Source/WebCore/accessibility/win/AXObjectCacheWin.cpp create mode 100644 Source/WebCore/accessibility/win/AccessibilityObjectWin.cpp create mode 100644 Source/WebCore/accessibility/win/AccessibilityObjectWrapperWin.h create mode 100644 Source/WebCore/accessibility/wx/AccessibilityObjectWx.cpp (limited to 'Source/WebCore/accessibility') diff --git a/Source/WebCore/accessibility/AXObjectCache.cpp b/Source/WebCore/accessibility/AXObjectCache.cpp new file mode 100644 index 0000000..d0d19f7 --- /dev/null +++ b/Source/WebCore/accessibility/AXObjectCache.cpp @@ -0,0 +1,632 @@ +/* + * Copyright (C) 2008, 2009, 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 "AXObjectCache.h" + +#include "AccessibilityARIAGrid.h" +#include "AccessibilityARIAGridCell.h" +#include "AccessibilityARIAGridRow.h" +#include "AccessibilityImageMapLink.h" +#include "AccessibilityList.h" +#include "AccessibilityListBox.h" +#include "AccessibilityListBoxOption.h" +#include "AccessibilityMediaControls.h" +#include "AccessibilityMenuList.h" +#include "AccessibilityMenuListOption.h" +#include "AccessibilityMenuListPopup.h" +#include "AccessibilityProgressIndicator.h" +#include "AccessibilityRenderObject.h" +#include "AccessibilityScrollView.h" +#include "AccessibilityScrollbar.h" +#include "AccessibilitySlider.h" +#include "AccessibilityTable.h" +#include "AccessibilityTableCell.h" +#include "AccessibilityTableColumn.h" +#include "AccessibilityTableHeaderContainer.h" +#include "AccessibilityTableRow.h" +#include "Document.h" +#include "FocusController.h" +#include "Frame.h" +#include "HTMLAreaElement.h" +#include "HTMLImageElement.h" +#include "HTMLNames.h" +#if ENABLE(VIDEO) +#include "MediaControlElements.h" +#endif +#include "InputElement.h" +#include "Page.h" +#include "RenderListBox.h" +#include "RenderMenuList.h" +#include "RenderProgress.h" +#include "RenderSlider.h" +#include "RenderTable.h" +#include "RenderTableCell.h" +#include "RenderTableRow.h" +#include "RenderView.h" +#include "ScrollView.h" + +#include + +namespace WebCore { + +using namespace HTMLNames; + +bool AXObjectCache::gAccessibilityEnabled = false; +bool AXObjectCache::gAccessibilityEnhancedUserInterfaceEnabled = false; + +AXObjectCache::AXObjectCache(const Document* doc) + : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired) +{ + m_document = const_cast(doc); +} + +AXObjectCache::~AXObjectCache() +{ + HashMap >::iterator end = m_objects.end(); + for (HashMap >::iterator it = m_objects.begin(); it != end; ++it) { + AccessibilityObject* obj = (*it).second.get(); + detachWrapper(obj); + obj->detach(); + removeAXID(obj); + } +} + +AccessibilityObject* AXObjectCache::focusedImageMapUIElement(HTMLAreaElement* areaElement) +{ + // Find the corresponding accessibility object for the HTMLAreaElement. This should be + // in the list of children for its corresponding image. + if (!areaElement) + return 0; + + HTMLImageElement* imageElement = areaElement->imageElement(); + if (!imageElement) + return 0; + + AccessibilityObject* axRenderImage = areaElement->document()->axObjectCache()->getOrCreate(imageElement->renderer()); + if (!axRenderImage) + return 0; + + AccessibilityObject::AccessibilityChildrenVector imageChildren = axRenderImage->children(); + unsigned count = imageChildren.size(); + for (unsigned k = 0; k < count; ++k) { + AccessibilityObject* child = imageChildren[k].get(); + if (!child->isImageMapLink()) + continue; + + if (static_cast(child)->areaElement() == areaElement) + return child; + } + + return 0; +} + +AccessibilityObject* AXObjectCache::focusedUIElementForPage(const Page* page) +{ + // get the focused node in the page + Document* focusedDocument = page->focusController()->focusedOrMainFrame()->document(); + Node* focusedNode = focusedDocument->focusedNode(); + if (!focusedNode) + focusedNode = focusedDocument; + + if (focusedNode->hasTagName(areaTag)) + return focusedImageMapUIElement(static_cast(focusedNode)); + + RenderObject* focusedNodeRenderer = focusedNode->renderer(); + if (!focusedNodeRenderer) + return 0; + + AccessibilityObject* obj = focusedNodeRenderer->document()->axObjectCache()->getOrCreate(focusedNodeRenderer); + + if (obj->shouldFocusActiveDescendant()) { + if (AccessibilityObject* descendant = obj->activeDescendant()) + obj = descendant; + } + + // the HTML element, for example, is focusable but has an AX object that is ignored + if (obj->accessibilityIsIgnored()) + obj = obj->parentObjectUnignored(); + + return obj; +} + +AccessibilityObject* AXObjectCache::get(Widget* widget) +{ + if (!widget) + return 0; + + AXID axID = m_widgetObjectMapping.get(widget); + ASSERT(!HashTraits::isDeletedValue(axID)); + if (!axID) + return 0; + + return m_objects.get(axID).get(); +} + +AccessibilityObject* AXObjectCache::get(RenderObject* renderer) +{ + if (!renderer) + return 0; + + AXID axID = m_renderObjectMapping.get(renderer); + ASSERT(!HashTraits::isDeletedValue(axID)); + if (!axID) + return 0; + + return m_objects.get(axID).get(); +} + +// FIXME: This probably belongs on Node. +// FIXME: This should take a const char*, but one caller passes nullAtom. +bool nodeHasRole(Node* node, const String& role) +{ + if (!node || !node->isElementNode()) + return false; + + return equalIgnoringCase(static_cast(node)->getAttribute(roleAttr), role); +} + +static PassRefPtr createFromRenderer(RenderObject* renderer) +{ + // FIXME: How could renderer->node() ever not be an Element? + Node* node = renderer->node(); + + // If the node is aria role="list" or the aria role is empty and its a + // ul/ol/dl type (it shouldn't be a list if aria says otherwise). + if (node && ((nodeHasRole(node, "list") || nodeHasRole(node, "directory")) + || (nodeHasRole(node, nullAtom) && (node->hasTagName(ulTag) || node->hasTagName(olTag) || node->hasTagName(dlTag))))) + return AccessibilityList::create(renderer); + + // aria tables + if (nodeHasRole(node, "grid") || nodeHasRole(node, "treegrid")) + return AccessibilityARIAGrid::create(renderer); + if (nodeHasRole(node, "row")) + return AccessibilityARIAGridRow::create(renderer); + if (nodeHasRole(node, "gridcell") || nodeHasRole(node, "columnheader") || nodeHasRole(node, "rowheader")) + return AccessibilityARIAGridCell::create(renderer); + +#if ENABLE(VIDEO) + // media controls + if (node && node->isMediaControlElement()) + return AccessibilityMediaControl::create(renderer); +#endif + + if (renderer->isBoxModelObject()) { + RenderBoxModelObject* cssBox = toRenderBoxModelObject(renderer); + if (cssBox->isListBox()) + return AccessibilityListBox::create(toRenderListBox(cssBox)); + if (cssBox->isMenuList()) + return AccessibilityMenuList::create(toRenderMenuList(cssBox)); + + // standard tables + if (cssBox->isTable()) + return AccessibilityTable::create(toRenderTable(cssBox)); + if (cssBox->isTableRow()) + return AccessibilityTableRow::create(toRenderTableRow(cssBox)); + if (cssBox->isTableCell()) + return AccessibilityTableCell::create(toRenderTableCell(cssBox)); + +#if ENABLE(PROGRESS_TAG) + // progress bar + if (cssBox->isProgress()) + return AccessibilityProgressIndicator::create(toRenderProgress(cssBox)); +#endif + + // input type=range + if (cssBox->isSlider()) + return AccessibilitySlider::create(toRenderSlider(cssBox)); + } + + return AccessibilityRenderObject::create(renderer); +} + +AccessibilityObject* AXObjectCache::getOrCreate(Widget* widget) +{ + if (!widget) + return 0; + + if (AccessibilityObject* obj = get(widget)) + return obj; + + RefPtr newObj = 0; + if (widget->isFrameView()) + newObj = AccessibilityScrollView::create(static_cast(widget)); + else if (widget->isScrollbar()) + newObj = AccessibilityScrollbar::create(static_cast(widget)); + + getAXID(newObj.get()); + + m_widgetObjectMapping.set(widget, newObj->axObjectID()); + m_objects.set(newObj->axObjectID(), newObj); + attachWrapper(newObj.get()); + return newObj.get(); +} + +AccessibilityObject* AXObjectCache::getOrCreate(RenderObject* renderer) +{ + if (!renderer) + return 0; + + if (AccessibilityObject* obj = get(renderer)) + return obj; + + RefPtr newObj = createFromRenderer(renderer); + + getAXID(newObj.get()); + + m_renderObjectMapping.set(renderer, newObj->axObjectID()); + m_objects.set(newObj->axObjectID(), newObj); + attachWrapper(newObj.get()); + return newObj.get(); +} + +AccessibilityObject* AXObjectCache::rootObject() +{ + return getOrCreate(m_document->view()); +} + +AccessibilityObject* AXObjectCache::getOrCreate(AccessibilityRole role) +{ + RefPtr obj = 0; + + // will be filled in... + switch (role) { + case ListBoxOptionRole: + obj = AccessibilityListBoxOption::create(); + break; + case ImageMapLinkRole: + obj = AccessibilityImageMapLink::create(); + break; + case ColumnRole: + obj = AccessibilityTableColumn::create(); + break; + case TableHeaderContainerRole: + obj = AccessibilityTableHeaderContainer::create(); + break; + case SliderThumbRole: + obj = AccessibilitySliderThumb::create(); + break; + case MenuListPopupRole: + obj = AccessibilityMenuListPopup::create(); + break; + case MenuListOptionRole: + obj = AccessibilityMenuListOption::create(); + break; + default: + obj = 0; + } + + if (obj) + getAXID(obj.get()); + else + return 0; + + m_objects.set(obj->axObjectID(), obj); + attachWrapper(obj.get()); + return obj.get(); +} + +void AXObjectCache::remove(AXID axID) +{ + if (!axID) + return; + + // first fetch object to operate some cleanup functions on it + AccessibilityObject* obj = m_objects.get(axID).get(); + if (!obj) + return; + + detachWrapper(obj); + obj->detach(); + removeAXID(obj); + + // finally remove the object + if (!m_objects.take(axID)) + return; + + ASSERT(m_objects.size() >= m_idsInUse.size()); +} + +void AXObjectCache::remove(RenderObject* renderer) +{ + if (!renderer) + return; + + AXID axID = m_renderObjectMapping.get(renderer); + remove(axID); + m_renderObjectMapping.remove(renderer); +} + +void AXObjectCache::remove(Widget* view) +{ + if (!view) + return; + + AXID axID = m_widgetObjectMapping.get(view); + remove(axID); + m_widgetObjectMapping.remove(view); +} + + +#if !PLATFORM(WIN) || OS(WINCE) +AXID AXObjectCache::platformGenerateAXID() const +{ + static AXID lastUsedID = 0; + + // Generate a new ID. + AXID objID = lastUsedID; + do { + ++objID; + } while (!objID || HashTraits::isDeletedValue(objID) || m_idsInUse.contains(objID)); + + lastUsedID = objID; + + return objID; +} +#endif + +AXID AXObjectCache::getAXID(AccessibilityObject* obj) +{ + // check for already-assigned ID + AXID objID = obj->axObjectID(); + if (objID) { + ASSERT(m_idsInUse.contains(objID)); + return objID; + } + + objID = platformGenerateAXID(); + + m_idsInUse.add(objID); + obj->setAXObjectID(objID); + + return objID; +} + +void AXObjectCache::removeAXID(AccessibilityObject* object) +{ + if (!object) + return; + + AXID objID = object->axObjectID(); + if (!objID) + return; + ASSERT(!HashTraits::isDeletedValue(objID)); + ASSERT(m_idsInUse.contains(objID)); + object->setAXObjectID(0); + m_idsInUse.remove(objID); +} + +#if HAVE(ACCESSIBILITY) +void AXObjectCache::contentChanged(RenderObject* renderer) +{ + AccessibilityObject* object = getOrCreate(renderer); + if (object) + object->contentChanged(); +} +#endif + +void AXObjectCache::childrenChanged(RenderObject* renderer) +{ + if (!renderer) + return; + + AXID axID = m_renderObjectMapping.get(renderer); + if (!axID) + return; + + AccessibilityObject* obj = m_objects.get(axID).get(); + if (obj) + obj->childrenChanged(); +} + +void AXObjectCache::notificationPostTimerFired(Timer*) +{ + m_notificationPostTimer.stop(); + + unsigned i = 0, count = m_notificationsToPost.size(); + for (i = 0; i < count; ++i) { + AccessibilityObject* obj = m_notificationsToPost[i].first.get(); +#ifndef NDEBUG + // Make sure none of the render views are in the process of being layed out. + // Notifications should only be sent after the renderer has finished + if (obj->isAccessibilityRenderObject()) { + AccessibilityRenderObject* renderObj = static_cast(obj); + RenderObject* renderer = renderObj->renderer(); + if (renderer && renderer->view()) + ASSERT(!renderer->view()->layoutState()); + } +#endif + + postPlatformNotification(obj, m_notificationsToPost[i].second); + } + + m_notificationsToPost.clear(); +} + +#if HAVE(ACCESSIBILITY) +void AXObjectCache::postNotification(RenderObject* renderer, AXNotification notification, bool postToElement, PostType postType) +{ + // Notifications for text input objects are sent to that object. + // All others are sent to the top WebArea. + if (!renderer) + return; + + // 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 object = get(renderer); + while (!object && renderer) { + renderer = renderer->parent(); + object = get(renderer); + } + + if (!renderer) + return; + + 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(object, notification)); + if (!m_notificationPostTimer.isActive()) + m_notificationPostTimer.startOneShot(0); + } else + postPlatformNotification(object, notification); +} + +void AXObjectCache::selectedChildrenChanged(RenderObject* renderer) +{ + // postToElement is false so that you can pass in any child of an element and it will go up the parent tree + // to find the container which should send out the notification. + postNotification(renderer, AXSelectedChildrenChanged, false); +} + +void AXObjectCache::nodeTextChangeNotification(RenderObject* renderer, AXTextChange textChange, unsigned offset, unsigned count) +{ + if (!renderer) + return; + + // Delegate on the right platform + AccessibilityObject* obj = getOrCreate(renderer); + nodeTextChangePlatformNotification(obj, textChange, offset, count); +} +#endif + +#if HAVE(ACCESSIBILITY) + +void AXObjectCache::handleScrollbarUpdate(ScrollView* view) +{ + if (!view) + return; + + // We don't want to create a scroll view from this method, only update an existing one. + AccessibilityObject* scrollViewObject = get(view); + if (scrollViewObject) + scrollViewObject->updateChildrenIfNecessary(); +} + +void AXObjectCache::handleAriaExpandedChange(RenderObject *renderer) +{ + if (!renderer) + return; + AccessibilityObject* obj = getOrCreate(renderer); + if (obj) + obj->handleAriaExpandedChanged(); +} + +void AXObjectCache::handleActiveDescendantChanged(RenderObject* renderer) +{ + if (!renderer) + return; + AccessibilityObject* obj = getOrCreate(renderer); + if (obj) + obj->handleActiveDescendantChanged(); +} + +void AXObjectCache::handleAriaRoleChanged(RenderObject* renderer) +{ + if (!renderer) + return; + AccessibilityObject* obj = getOrCreate(renderer); + if (obj && obj->isAccessibilityRenderObject()) + static_cast(obj)->updateAccessibilityRole(); +} +#endif + +VisiblePosition AXObjectCache::visiblePositionForTextMarkerData(TextMarkerData& textMarkerData) +{ + if (!isNodeInUse(textMarkerData.node)) + return VisiblePosition(); + + VisiblePosition visiblePos = VisiblePosition(textMarkerData.node, textMarkerData.offset, textMarkerData.affinity); + Position deepPos = visiblePos.deepEquivalent(); + if (deepPos.isNull()) + return VisiblePosition(); + + RenderObject* renderer = deepPos.node()->renderer(); + if (!renderer) + return VisiblePosition(); + + AXObjectCache* cache = renderer->document()->axObjectCache(); + if (!cache->isIDinUse(textMarkerData.axID)) + return VisiblePosition(); + + if (deepPos.node() != textMarkerData.node || deepPos.deprecatedEditingOffset() != textMarkerData.offset) + return VisiblePosition(); + + return visiblePos; +} + +void AXObjectCache::textMarkerDataForVisiblePosition(TextMarkerData& textMarkerData, const VisiblePosition& visiblePos) +{ + // This memory must be bzero'd so instances of TextMarkerData can be tested for byte-equivalence. + // This also allows callers to check for failure by looking at textMarkerData upon return. + memset(&textMarkerData, 0, sizeof(TextMarkerData)); + + if (visiblePos.isNull()) + return; + + Position deepPos = visiblePos.deepEquivalent(); + Node* domNode = deepPos.node(); + ASSERT(domNode); + if (!domNode) + return; + + if (domNode->isHTMLElement()) { + InputElement* inputElement = toInputElement(static_cast(domNode)); + if (inputElement && inputElement->isPasswordField()) + return; + } + + // locate the renderer, which must exist for a visible dom node + RenderObject* renderer = domNode->renderer(); + ASSERT(renderer); + + // find or create an accessibility object for this renderer + AXObjectCache* cache = renderer->document()->axObjectCache(); + RefPtr obj = cache->getOrCreate(renderer); + + textMarkerData.axID = obj.get()->axObjectID(); + textMarkerData.node = domNode; + textMarkerData.offset = deepPos.deprecatedEditingOffset(); + textMarkerData.affinity = visiblePos.affinity(); + + cache->setNodeInUse(domNode); +} + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AXObjectCache.h b/Source/WebCore/accessibility/AXObjectCache.h new file mode 100644 index 0000000..670d6e0 --- /dev/null +++ b/Source/WebCore/accessibility/AXObjectCache.h @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2011 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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 AXObjectCache_h +#define AXObjectCache_h + +#include "AccessibilityObject.h" +#include "Timer.h" +#include +#include +#include +#include +#include + +#ifdef __OBJC__ +@class WebCoreTextMarker; +#else +class WebCoreTextMarker; +#endif + +namespace WebCore { + +class Document; +class HTMLAreaElement; +class Node; +class Page; +class RenderObject; +class ScrollView; +class VisiblePosition; +class Widget; + +struct TextMarkerData { + AXID axID; + Node* node; + int offset; + EAffinity affinity; +}; + +enum PostType { PostSynchronously, PostAsynchronously }; + +class AXObjectCache : public Noncopyable { +public: + AXObjectCache(const Document*); + ~AXObjectCache(); + + static AccessibilityObject* focusedUIElementForPage(const Page*); + + AccessibilityObject* rootObject(); + + // For AX objects with elements that back them. + AccessibilityObject* getOrCreate(RenderObject*); + AccessibilityObject* getOrCreate(Widget*); + + // used for objects without backing elements + AccessibilityObject* getOrCreate(AccessibilityRole); + + // will only return the AccessibilityObject if it already exists + AccessibilityObject* get(RenderObject*); + + void remove(RenderObject*); + void remove(Widget*); + void remove(AXID); + + void detachWrapper(AccessibilityObject*); + void attachWrapper(AccessibilityObject*); + void childrenChanged(RenderObject*); + void selectedChildrenChanged(RenderObject*); + // Called by a node when text or a text equivalent (e.g. alt) attribute is changed. + void contentChanged(RenderObject*); + + void handleActiveDescendantChanged(RenderObject*); + void handleAriaRoleChanged(RenderObject*); + void handleFocusedUIElementChanged(RenderObject* oldFocusedRenderer, RenderObject* newFocusedRenderer); + void handleScrolledToAnchor(const Node* anchorNode); + void handleAriaExpandedChange(RenderObject*); + void handleScrollbarUpdate(ScrollView*); + + static void enableAccessibility() { gAccessibilityEnabled = true; } + static void enableEnhancedUserInterfaceAccessibility() { gAccessibilityEnhancedUserInterfaceEnabled = true; } + + static bool accessibilityEnabled() { return gAccessibilityEnabled; } + static bool accessibilityEnhancedUserInterfaceEnabled() { return gAccessibilityEnhancedUserInterfaceEnabled; } + + void removeAXID(AccessibilityObject*); + bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); } + AXID platformGenerateAXID() const; + AccessibilityObject* objectFromAXID(AXID id) const { return m_objects.get(id).get(); } + + // This is a weak reference cache for knowing if Nodes used by TextMarkers are valid. + void setNodeInUse(Node* n) { m_textMarkerNodes.add(n); } + void removeNodeForUse(Node* n) { m_textMarkerNodes.remove(n); } + bool isNodeInUse(Node* n) { return m_textMarkerNodes.contains(n); } + + // Text marker utilities. + void textMarkerDataForVisiblePosition(TextMarkerData&, const VisiblePosition&); + VisiblePosition visiblePositionForTextMarkerData(TextMarkerData&); + + enum AXNotification { + AXActiveDescendantChanged, + AXCheckedStateChanged, + AXChildrenChanged, + AXFocusedUIElementChanged, + AXLayoutComplete, + AXLoadComplete, + AXSelectedChildrenChanged, + AXSelectedTextChanged, + AXValueChanged, + AXScrolledToAnchor, + AXLiveRegionChanged, + AXMenuListValueChanged, + AXRowCountChanged, + AXRowCollapsed, + AXRowExpanded, + AXInvalidStatusChanged, + }; + + void postNotification(RenderObject*, AXNotification, bool postToElement, PostType = PostAsynchronously); + void postNotification(AccessibilityObject*, Document*, AXNotification, bool postToElement, PostType = PostAsynchronously); + + enum AXTextChange { + AXTextInserted, + AXTextDeleted, + }; + + void nodeTextChangeNotification(RenderObject*, AXTextChange, unsigned offset, unsigned count); + + bool nodeHasRole(Node*, const AtomicString& role); + +protected: + void postPlatformNotification(AccessibilityObject*, AXNotification); + void nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned offset, unsigned count); + +private: + Document* m_document; + HashMap > m_objects; + HashMap m_renderObjectMapping; + HashMap m_widgetObjectMapping; + HashSet m_textMarkerNodes; + static bool gAccessibilityEnabled; + static bool gAccessibilityEnhancedUserInterfaceEnabled; + + HashSet m_idsInUse; + + Timer m_notificationPostTimer; + Vector, AXNotification> > m_notificationsToPost; + void notificationPostTimerFired(Timer*); + + static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*); + + AXID getAXID(AccessibilityObject*); + AccessibilityObject* get(Widget*); +}; + +bool nodeHasRole(Node*, const String& role); + +#if !HAVE(ACCESSIBILITY) +inline void AXObjectCache::handleActiveDescendantChanged(RenderObject*) { } +inline void AXObjectCache::handleAriaRoleChanged(RenderObject*) { } +inline void AXObjectCache::detachWrapper(AccessibilityObject*) { } +inline void AXObjectCache::attachWrapper(AccessibilityObject*) { } +inline void AXObjectCache::selectedChildrenChanged(RenderObject*) { } +inline void AXObjectCache::postNotification(RenderObject*, AXNotification, bool postToElement, PostType) { } +inline void AXObjectCache::postNotification(AccessibilityObject*, Document*, AXNotification, bool postToElement, PostType) { } +inline void AXObjectCache::postPlatformNotification(AccessibilityObject*, AXNotification) { } +inline void AXObjectCache::nodeTextChangeNotification(RenderObject*, AXTextChange, unsigned, unsigned) { } +inline void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, unsigned) { } +inline void AXObjectCache::handleFocusedUIElementChanged(RenderObject*, RenderObject*) { } +inline void AXObjectCache::handleScrolledToAnchor(const Node*) { } +inline void AXObjectCache::contentChanged(RenderObject*) { } +inline void AXObjectCache::handleAriaExpandedChange(RenderObject*) { } +inline void AXObjectCache::handleScrollbarUpdate(ScrollView*) { } +#endif + +} + +#endif diff --git a/Source/WebCore/accessibility/AccessibilityARIAGrid.cpp b/Source/WebCore/accessibility/AccessibilityARIAGrid.cpp new file mode 100644 index 0000000..8651a80 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityARIAGrid.cpp @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2009 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 "AccessibilityARIAGrid.h" + +#include "AXObjectCache.h" +#include "AccessibilityTableCell.h" +#include "AccessibilityTableColumn.h" +#include "AccessibilityTableHeaderContainer.h" +#include "AccessibilityTableRow.h" +#include "RenderObject.h" + +using namespace std; + +namespace WebCore { + +AccessibilityARIAGrid::AccessibilityARIAGrid(RenderObject* renderer) + : AccessibilityTable(renderer) +{ +#if ACCESSIBILITY_TABLES + m_isAccessibilityTable = true; +#else + m_isAccessibilityTable = false; +#endif +} + +AccessibilityARIAGrid::~AccessibilityARIAGrid() +{ +} + +PassRefPtr AccessibilityARIAGrid::create(RenderObject* renderer) +{ + return adoptRef(new AccessibilityARIAGrid(renderer)); +} + +void AccessibilityARIAGrid::addChild(AccessibilityObject* child, HashSet& appendedRows, unsigned& columnCount) +{ + if (!child || !child->isTableRow() || child->ariaRoleAttribute() != RowRole) + return; + + AccessibilityTableRow* row = static_cast(child); + if (appendedRows.contains(row)) + return; + + // store the maximum number of columns + unsigned rowCellCount = row->children().size(); + if (rowCellCount > columnCount) + columnCount = rowCellCount; + + row->setRowIndex((int)m_rows.size()); + m_rows.append(row); + m_children.append(row); + appendedRows.add(row); +} + +void AccessibilityARIAGrid::addChildren() +{ + ASSERT(!m_haveChildren); + + if (!isAccessibilityTable()) { + AccessibilityRenderObject::addChildren(); + return; + } + + m_haveChildren = true; + if (!m_renderer) + return; + + AXObjectCache* axCache = m_renderer->document()->axObjectCache(); + + // add only rows that are labeled as aria rows + HashSet appendedRows; + unsigned columnCount = 0; + for (RefPtr child = firstChild(); child; child = child->nextSibling()) { + + // in case the render tree doesn't match the expected ARIA hierarchy, look at the children + if (child->accessibilityIsIgnored()) { + if (!child->hasChildren()) + child->addChildren(); + + AccessibilityChildrenVector children = child->children(); + unsigned length = children.size(); + for (unsigned i = 0; i < length; ++i) + addChild(children[i].get(), appendedRows, columnCount); + } else + addChild(child.get(), appendedRows, columnCount); + } + + // make the columns based on the number of columns in the first body + for (unsigned i = 0; i < columnCount; ++i) { + AccessibilityTableColumn* column = static_cast(axCache->getOrCreate(ColumnRole)); + column->setColumnIndex((int)i); + column->setParentTable(this); + m_columns.append(column); + if (!column->accessibilityIsIgnored()) + m_children.append(column); + } + + AccessibilityObject* headerContainerObject = headerContainer(); + if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored()) + m_children.append(headerContainerObject); +} + +AccessibilityTableCell* AccessibilityARIAGrid::cellForColumnAndRow(unsigned column, unsigned row) +{ + if (!m_renderer) + return 0; + + updateChildrenIfNecessary(); + + if (column >= columnCount() || row >= rowCount()) + return 0; + + AccessibilityObject* tableRow = m_rows[row].get(); + if (!tableRow) + return 0; + + AccessibilityChildrenVector children = tableRow->children(); + // in case this row had fewer columns than other rows + AccessibilityObject* tableCell = 0; + if (column >= children.size()) + return 0; + + tableCell = children[column].get(); + return static_cast(tableCell); +} + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AccessibilityARIAGrid.h b/Source/WebCore/accessibility/AccessibilityARIAGrid.h new file mode 100644 index 0000000..02ff4d0 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityARIAGrid.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2009 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 AccessibilityARIAGrid_h +#define AccessibilityARIAGrid_h + +#include "AccessibilityTable.h" +#include + +namespace WebCore { + +class AccessibilityTableCell; +class AccessibilityTableHeaderContainer; + +class AccessibilityARIAGrid : public AccessibilityTable { + +private: + AccessibilityARIAGrid(RenderObject*); +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityARIAGrid(); + + virtual bool isAriaTable() const { return true; } + + virtual void addChildren(); + + virtual AccessibilityTableCell* cellForColumnAndRow(unsigned column, unsigned row); + +private: + // ARIA treegrids and grids support selected rows. + virtual bool supportsSelectedRows() { return true; } + + void addChild(AccessibilityObject*, HashSet& appendedRows, unsigned& columnCount); +}; + +} // namespace WebCore + +#endif // AccessibilityARIAGrid_h diff --git a/Source/WebCore/accessibility/AccessibilityARIAGridCell.cpp b/Source/WebCore/accessibility/AccessibilityARIAGridCell.cpp new file mode 100644 index 0000000..c8157f5 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityARIAGridCell.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2009 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 "AccessibilityARIAGridCell.h" + +#include "AccessibilityObject.h" +#include "AccessibilityTableRow.h" + +using namespace std; + +namespace WebCore { + +AccessibilityARIAGridCell::AccessibilityARIAGridCell(RenderObject* renderer) + : AccessibilityTableCell(renderer) +{ +} + +AccessibilityARIAGridCell::~AccessibilityARIAGridCell() +{ +} + +PassRefPtr AccessibilityARIAGridCell::create(RenderObject* renderer) +{ + return adoptRef(new AccessibilityARIAGridCell(renderer)); +} + +AccessibilityObject* AccessibilityARIAGridCell::parentTable() const +{ + AccessibilityObject* parent = parentObjectUnignored(); + if (!parent || !parent->isTableRow()) + return 0; + + parent = parent->parentObjectUnignored(); + if (!parent || !parent->isAccessibilityTable()) + return 0; + + return parent; +} + +void AccessibilityARIAGridCell::rowIndexRange(pair& rowRange) +{ + AccessibilityObject* parent = parentObjectUnignored(); + if (!parent || !parent->isTableRow()) + return; + + // as far as I can tell, grid cells cannot span rows + rowRange.first = static_cast(parent)->rowIndex(); + rowRange.second = 1; +} + +void AccessibilityARIAGridCell::columnIndexRange(pair& columnRange) +{ + AccessibilityObject* parent = parentObjectUnignored(); + if (!parent || !parent->isTableRow()) + return; + + AccessibilityChildrenVector siblings = parent->children(); + unsigned childrenSize = siblings.size(); + for (unsigned k = 0; k < childrenSize; ++k) { + if (siblings[k].get() == this) { + columnRange.first = k; + break; + } + } + + // as far as I can tell, grid cells cannot span columns + columnRange.second = 1; +} + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AccessibilityARIAGridCell.h b/Source/WebCore/accessibility/AccessibilityARIAGridCell.h new file mode 100644 index 0000000..2923de8 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityARIAGridCell.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2009 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 AccessibilityARIAGridCell_h +#define AccessibilityARIAGridCell_h + +#include "AccessibilityTableCell.h" + +namespace WebCore { + +class AccessibilityARIAGridCell : public AccessibilityTableCell { + +private: + AccessibilityARIAGridCell(RenderObject*); +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityARIAGridCell(); + + // fills in the start location and row span of cell + virtual void rowIndexRange(pair& rowRange); + // fills in the start location and column span of cell + virtual void columnIndexRange(pair& columnRange); + +protected: + virtual AccessibilityObject* parentTable() const; +}; + +} // namespace WebCore + +#endif // AccessibilityARIAGridCell_h diff --git a/Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp b/Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp new file mode 100644 index 0000000..2b96036 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2009 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 "AccessibilityARIAGridRow.h" + +#include "AccessibilityObject.h" +#include "AccessibilityTable.h" +#include "RenderObject.h" + +using namespace std; + +namespace WebCore { + +AccessibilityARIAGridRow::AccessibilityARIAGridRow(RenderObject* renderer) + : AccessibilityTableRow(renderer) +{ +} + +AccessibilityARIAGridRow::~AccessibilityARIAGridRow() +{ +} + +PassRefPtr AccessibilityARIAGridRow::create(RenderObject* renderer) +{ + return adoptRef(new AccessibilityARIAGridRow(renderer)); +} + +bool AccessibilityARIAGridRow::isARIATreeGridRow() const +{ + AccessibilityObject* parent = parentTable(); + if (!parent) + return false; + + return parent->ariaRoleAttribute() == TreeGridRole; +} + +void AccessibilityARIAGridRow::disclosedRows(AccessibilityChildrenVector& disclosedRows) +{ + // The contiguous disclosed rows will be the rows in the table that + // have an aria-level of plus 1 from this row. + AccessibilityObject* parent = parentObjectUnignored(); + if (!parent || !parent->isAccessibilityTable()) + return; + + // Search for rows that match the correct level. + // Only take the subsequent rows from this one that are +1 from this row's level. + int index = rowIndex(); + if (index < 0) + return; + + unsigned level = hierarchicalLevel(); + AccessibilityChildrenVector& allRows = static_cast(parent)->rows(); + int rowCount = allRows.size(); + for (int k = index + 1; k < rowCount; ++k) { + AccessibilityObject* row = allRows[k].get(); + // Stop at the first row that doesn't match the correct level. + if (row->hierarchicalLevel() != level + 1) + break; + + disclosedRows.append(row); + } +} + +AccessibilityObject* AccessibilityARIAGridRow::disclosedByRow() const +{ + // The row that discloses this one is the row in the table + // that is aria-level subtract 1 from this row. + AccessibilityObject* parent = parentObjectUnignored(); + if (!parent || !parent->isAccessibilityTable()) + return 0; + + // If the level is 1 or less, than nothing discloses this row. + unsigned level = hierarchicalLevel(); + if (level <= 1) + return 0; + + // Search for the previous row that matches the correct level. + int index = rowIndex(); + AccessibilityChildrenVector& allRows = static_cast(parent)->rows(); + int rowCount = allRows.size(); + if (index >= rowCount) + return 0; + + for (int k = index - 1; k >= 0; --k) { + AccessibilityObject* row = allRows[k].get(); + if (row->hierarchicalLevel() == level - 1) + return row; + } + + return 0; +} + +AccessibilityObject* AccessibilityARIAGridRow::parentTable() const +{ + AccessibilityObject* parent = parentObjectUnignored(); + if (!parent->isAccessibilityTable()) + return 0; + + return parent; +} + +AccessibilityObject* AccessibilityARIAGridRow::headerObject() +{ + AccessibilityChildrenVector rowChildren = children(); + unsigned childrenCount = rowChildren.size(); + for (unsigned i = 0; i < childrenCount; ++i) { + AccessibilityObject* cell = rowChildren[i].get(); + if (cell->ariaRoleAttribute() == RowHeaderRole) + return cell; + } + + return 0; +} + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AccessibilityARIAGridRow.h b/Source/WebCore/accessibility/AccessibilityARIAGridRow.h new file mode 100644 index 0000000..f89ea92 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityARIAGridRow.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 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 AccessibilityARIAGridRow_h +#define AccessibilityARIAGridRow_h + +#include "AccessibilityTableRow.h" + +namespace WebCore { + +class AccessibilityARIAGridRow : public AccessibilityTableRow { + +private: + AccessibilityARIAGridRow(RenderObject*); +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityARIAGridRow(); + + void disclosedRows(AccessibilityChildrenVector&); + AccessibilityObject* disclosedByRow() const; + + virtual AccessibilityObject* headerObject(); + virtual AccessibilityObject* parentTable() const; + +private: + virtual bool isARIATreeGridRow() const; +}; + +} // namespace WebCore + +#endif // AccessibilityARIAGridRow_h diff --git a/Source/WebCore/accessibility/AccessibilityAllInOne.cpp b/Source/WebCore/accessibility/AccessibilityAllInOne.cpp new file mode 100644 index 0000000..1c2836e --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityAllInOne.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 INC. OR + * 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. + */ + +// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/Source/WebCore/accessibility/AccessibilityImageMapLink.cpp b/Source/WebCore/accessibility/AccessibilityImageMapLink.cpp new file mode 100644 index 0000000..5676206 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityImageMapLink.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2008 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 "AccessibilityImageMapLink.h" + +#include "AXObjectCache.h" +#include "AccessibilityRenderObject.h" +#include "Document.h" +#include "HTMLNames.h" +#include "RenderBoxModelObject.h" + +namespace WebCore { + +using namespace HTMLNames; + +AccessibilityImageMapLink::AccessibilityImageMapLink() + : m_areaElement(0) + , m_mapElement(0) +{ +} + +AccessibilityImageMapLink::~AccessibilityImageMapLink() +{ +} + +PassRefPtr AccessibilityImageMapLink::create() +{ + return adoptRef(new AccessibilityImageMapLink()); +} + +AccessibilityObject* AccessibilityImageMapLink::parentObject() const +{ + if (m_parent) + return m_parent; + + if (!m_mapElement.get() || !m_mapElement->renderer()) + return 0; + + return m_mapElement->document()->axObjectCache()->getOrCreate(m_mapElement->renderer()); +} + +AccessibilityRole AccessibilityImageMapLink::roleValue() const +{ + if (!m_areaElement) + return WebCoreLinkRole; + + const AtomicString& ariaRole = getAttribute(roleAttr); + if (!ariaRole.isEmpty()) + return AccessibilityObject::ariaRoleToWebCoreRole(ariaRole); + + return WebCoreLinkRole; +} + +Element* AccessibilityImageMapLink::actionElement() const +{ + return anchorElement(); +} + +Element* AccessibilityImageMapLink::anchorElement() const +{ + return m_areaElement.get(); +} + +KURL AccessibilityImageMapLink::url() const +{ + if (!m_areaElement.get()) + return KURL(); + + return m_areaElement->href(); +} + +String AccessibilityImageMapLink::accessibilityDescription() const +{ + const AtomicString& ariaLabel = getAttribute(aria_labelAttr); + if (!ariaLabel.isEmpty()) + return ariaLabel; + const AtomicString& alt = getAttribute(altAttr); + if (!alt.isEmpty()) + return alt; + + return String(); +} + +String AccessibilityImageMapLink::title() const +{ + const AtomicString& title = getAttribute(titleAttr); + if (!title.isEmpty()) + return title; + const AtomicString& summary = getAttribute(summaryAttr); + if (!summary.isEmpty()) + return summary; + + return String(); +} + +IntRect AccessibilityImageMapLink::elementRect() const +{ + if (!m_mapElement.get() || !m_areaElement.get()) + return IntRect(); + + RenderObject* renderer; + if (m_parent && m_parent->isAccessibilityRenderObject()) + renderer = static_cast(m_parent)->renderer(); + else + renderer = m_mapElement->renderer(); + + if (!renderer) + return IntRect(); + + return m_areaElement->getRect(renderer); +} + +String AccessibilityImageMapLink::stringValueForMSAA() const +{ + return url(); +} + +String AccessibilityImageMapLink::nameForMSAA() const +{ + return accessibilityDescription(); +} + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AccessibilityImageMapLink.h b/Source/WebCore/accessibility/AccessibilityImageMapLink.h new file mode 100644 index 0000000..4b02b2b --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityImageMapLink.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2008 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 AccessibilityImageMapLink_h +#define AccessibilityImageMapLink_h + +#include "AccessibilityObject.h" +#include "HTMLAreaElement.h" +#include "HTMLMapElement.h" + +namespace WebCore { + +class AccessibilityImageMapLink : public AccessibilityObject { + +private: + AccessibilityImageMapLink(); +public: + static PassRefPtr create(); + virtual ~AccessibilityImageMapLink(); + + void setHTMLAreaElement(HTMLAreaElement* element) { m_areaElement = element; } + HTMLAreaElement* areaElement() const { return m_areaElement.get(); } + + void setHTMLMapElement(HTMLMapElement* element) { m_mapElement = element; } + HTMLMapElement* mapElement() const { return m_mapElement.get(); } + + virtual Node* node() const { return m_areaElement.get(); } + void setParent(AccessibilityObject* parent) { m_parent = parent; } + + virtual AccessibilityRole roleValue() const; + virtual bool accessibilityIsIgnored() const { return false; } + virtual bool isEnabled() const { return true; } + + virtual AccessibilityObject* parentObject() const; + virtual Element* anchorElement() const; + virtual Element* actionElement() const; + virtual KURL url() const; + virtual bool isLink() const { return true; } + virtual bool isLinked() const { return true; } + virtual String title() const; + virtual String accessibilityDescription() const; + + virtual String stringValueForMSAA() const; + virtual String nameForMSAA() const; + + virtual IntRect elementRect() const; + +private: + RefPtr m_areaElement; + RefPtr m_mapElement; + AccessibilityObject* m_parent; + + virtual bool isImageMapLink() const { return true; } +}; + +} // namespace WebCore + +#endif // AccessibilityImageMapLink_h diff --git a/Source/WebCore/accessibility/AccessibilityList.cpp b/Source/WebCore/accessibility/AccessibilityList.cpp new file mode 100644 index 0000000..073b0fc --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityList.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2008 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 "AccessibilityList.h" + +#include "AXObjectCache.h" +#include "HTMLNames.h" +#include "RenderObject.h" + +using namespace std; + +namespace WebCore { + +using namespace HTMLNames; + +AccessibilityList::AccessibilityList(RenderObject* renderer) + : AccessibilityRenderObject(renderer) +{ +} + +AccessibilityList::~AccessibilityList() +{ +} + +PassRefPtr AccessibilityList::create(RenderObject* renderer) +{ + return adoptRef(new AccessibilityList(renderer)); +} + +bool AccessibilityList::accessibilityIsIgnored() const +{ + AccessibilityObjectInclusion decision = accessibilityIsIgnoredBase(); + if (decision == IncludeObject) + return false; + if (decision == IgnoreObject) + return true; + + // lists don't appear on tiger/leopard on the mac +#if ACCESSIBILITY_LISTS + return false; +#else + return true; +#endif +} + +bool AccessibilityList::isUnorderedList() const +{ + if (!m_renderer) + return false; + + Node* node = m_renderer->node(); + + // The ARIA spec says the "list" role is supposed to mimic a UL or OL tag. + // Since it can't be both, it's probably OK to say that it's an un-ordered list. + // On the Mac, there's no distinction to the client. + if (ariaRoleAttribute() == ListRole) + return true; + + return node && node->hasTagName(ulTag); +} + +bool AccessibilityList::isOrderedList() const +{ + if (!m_renderer) + return false; + + // ARIA says a directory is like a static table of contents, which sounds like an ordered list. + if (ariaRoleAttribute() == DirectoryRole) + return true; + + Node* node = m_renderer->node(); + return node && node->hasTagName(olTag); +} + +bool AccessibilityList::isDefinitionList() const +{ + if (!m_renderer) + return false; + + Node* node = m_renderer->node(); + return node && node->hasTagName(dlTag); +} + + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AccessibilityList.h b/Source/WebCore/accessibility/AccessibilityList.h new file mode 100644 index 0000000..b7265b2 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityList.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2008 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 AccessibilityList_h +#define AccessibilityList_h + +#if PLATFORM(MAC) && (defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)) +#define ACCESSIBILITY_LISTS 0 +#else +#define ACCESSIBILITY_LISTS 1 +#endif + +#include "AccessibilityRenderObject.h" + +namespace WebCore { + +class AccessibilityList : public AccessibilityRenderObject { + +private: + AccessibilityList(RenderObject*); +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityList(); + + virtual bool isList() const { return true; } + bool isUnorderedList() const; + bool isOrderedList() const; + bool isDefinitionList() const; + + virtual AccessibilityRole roleValue() const { return ListRole; } + virtual bool accessibilityIsIgnored() const; + +}; + +} // namespace WebCore + +#endif // AccessibilityList_h diff --git a/Source/WebCore/accessibility/AccessibilityListBox.cpp b/Source/WebCore/accessibility/AccessibilityListBox.cpp new file mode 100644 index 0000000..191a041 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityListBox.cpp @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2008 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 "AccessibilityListBox.h" + +#include "AXObjectCache.h" +#include "AccessibilityListBoxOption.h" +#include "HTMLNames.h" +#include "HTMLSelectElement.h" +#include "HitTestResult.h" +#include "RenderListBox.h" +#include "RenderObject.h" + +using namespace std; + +namespace WebCore { + +using namespace HTMLNames; + +AccessibilityListBox::AccessibilityListBox(RenderObject* renderer) + : AccessibilityRenderObject(renderer) +{ +} + +AccessibilityListBox::~AccessibilityListBox() +{ +} + +PassRefPtr AccessibilityListBox::create(RenderObject* renderer) +{ + return adoptRef(new AccessibilityListBox(renderer)); +} + +bool AccessibilityListBox::canSetSelectedChildrenAttribute() const +{ + Node* selectNode = m_renderer->node(); + if (!selectNode) + return false; + + return !static_cast(selectNode)->disabled(); +} + +void AccessibilityListBox::addChildren() +{ + Node* selectNode = m_renderer->node(); + if (!selectNode) + return; + + m_haveChildren = true; + + const Vector& listItems = static_cast(selectNode)->listItems(); + unsigned length = listItems.size(); + for (unsigned i = 0; i < length; i++) { + // The cast to HTMLElement below is safe because the only other possible listItem type + // would be a WMLElement, but WML builds don't use accessibility features at all. + AccessibilityObject* listOption = listBoxOptionAccessibilityObject(static_cast(listItems[i])); + if (listOption && !listOption->accessibilityIsIgnored()) + m_children.append(listOption); + } +} + +void AccessibilityListBox::setSelectedChildren(AccessibilityChildrenVector& children) +{ + if (!canSetSelectedChildrenAttribute()) + return; + + Node* selectNode = m_renderer->node(); + if (!selectNode) + return; + + // disable any selected options + unsigned length = m_children.size(); + for (unsigned i = 0; i < length; i++) { + AccessibilityListBoxOption* listBoxOption = static_cast(m_children[i].get()); + if (listBoxOption->isSelected()) + listBoxOption->setSelected(false); + } + + length = children.size(); + for (unsigned i = 0; i < length; i++) { + AccessibilityObject* obj = children[i].get(); + if (obj->roleValue() != ListBoxOptionRole) + continue; + + static_cast(obj)->setSelected(true); + } +} + +void AccessibilityListBox::selectedChildren(AccessibilityChildrenVector& result) +{ + ASSERT(result.isEmpty()); + + if (!hasChildren()) + addChildren(); + + unsigned length = m_children.size(); + for (unsigned i = 0; i < length; i++) { + if (static_cast(m_children[i].get())->isSelected()) + result.append(m_children[i]); + } +} + +void AccessibilityListBox::visibleChildren(AccessibilityChildrenVector& result) +{ + ASSERT(result.isEmpty()); + + if (!hasChildren()) + addChildren(); + + unsigned length = m_children.size(); + for (unsigned i = 0; i < length; i++) { + if (toRenderListBox(m_renderer)->listIndexIsVisible(i)) + result.append(m_children[i]); + } +} + +AccessibilityObject* AccessibilityListBox::listBoxOptionAccessibilityObject(HTMLElement* element) const +{ + // skip hr elements + if (!element || element->hasTagName(hrTag)) + return 0; + + AccessibilityObject* listBoxObject = m_renderer->document()->axObjectCache()->getOrCreate(ListBoxOptionRole); + static_cast(listBoxObject)->setHTMLElement(element); + + return listBoxObject; +} + +bool AccessibilityListBox::accessibilityIsIgnored() const +{ + AccessibilityObjectInclusion decision = accessibilityIsIgnoredBase(); + if (decision == IncludeObject) + return false; + if (decision == IgnoreObject) + return true; + + return false; +} + +AccessibilityObject* AccessibilityListBox::elementAccessibilityHitTest(const IntPoint& point) const +{ + // the internal HTMLSelectElement methods for returning a listbox option at a point + // ignore optgroup elements. + if (!m_renderer) + return 0; + + Node* node = m_renderer->node(); + if (!node) + return 0; + + IntRect parentRect = boundingBoxRect(); + + AccessibilityObject* listBoxOption = 0; + unsigned length = m_children.size(); + for (unsigned i = 0; i < length; i++) { + IntRect rect = toRenderListBox(m_renderer)->itemBoundingBoxRect(parentRect.x(), parentRect.y(), i); + // The cast to HTMLElement below is safe because the only other possible listItem type + // would be a WMLElement, but WML builds don't use accessibility features at all. + if (rect.contains(point)) { + listBoxOption = m_children[i].get(); + break; + } + } + + if (listBoxOption && !listBoxOption->accessibilityIsIgnored()) + return listBoxOption; + + return axObjectCache()->getOrCreate(m_renderer); +} + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AccessibilityListBox.h b/Source/WebCore/accessibility/AccessibilityListBox.h new file mode 100644 index 0000000..cfccb52 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityListBox.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2008 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 AccessibilityListBox_h +#define AccessibilityListBox_h + +#include "AccessibilityRenderObject.h" + +namespace WebCore { + +class AccessibilityListBox : public AccessibilityRenderObject { + +private: + AccessibilityListBox(RenderObject*); +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityListBox(); + + virtual bool isListBox() const { return true; } + + virtual bool canSetFocusAttribute() const { return true; } + virtual bool canSetSelectedChildrenAttribute() const; + void setSelectedChildren(AccessibilityChildrenVector&); + virtual AccessibilityRole roleValue() const { return ListBoxRole; } + + virtual void selectedChildren(AccessibilityChildrenVector&); + virtual void visibleChildren(AccessibilityChildrenVector&); + + virtual void addChildren(); + +private: + AccessibilityObject* listBoxOptionAccessibilityObject(HTMLElement*) const; + virtual bool accessibilityIsIgnored() const; + virtual AccessibilityObject* elementAccessibilityHitTest(const IntPoint&) const; +}; + +} // namespace WebCore + +#endif // AccessibilityListBox_h diff --git a/Source/WebCore/accessibility/AccessibilityListBoxOption.cpp b/Source/WebCore/accessibility/AccessibilityListBoxOption.cpp new file mode 100644 index 0000000..01420c5 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityListBoxOption.cpp @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2008 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 "AccessibilityListBoxOption.h" + +#include "AXObjectCache.h" +#include "AccessibilityListBox.h" +#include "Element.h" +#include "HTMLElement.h" +#include "HTMLNames.h" +#include "HTMLOptGroupElement.h" +#include "HTMLOptionElement.h" +#include "HTMLSelectElement.h" +#include "IntRect.h" +#include "RenderListBox.h" +#include "RenderObject.h" + +using namespace std; + +namespace WebCore { + +using namespace HTMLNames; + +AccessibilityListBoxOption::AccessibilityListBoxOption() + : m_optionElement(0) +{ +} + +AccessibilityListBoxOption::~AccessibilityListBoxOption() +{ +} + +PassRefPtr AccessibilityListBoxOption::create() +{ + return adoptRef(new AccessibilityListBoxOption()); +} + +bool AccessibilityListBoxOption::isEnabled() const +{ + if (!m_optionElement) + return false; + + if (m_optionElement->hasTagName(optgroupTag)) + return false; + + return true; +} + +bool AccessibilityListBoxOption::isSelected() const +{ + if (!m_optionElement) + return false; + + if (!m_optionElement->hasTagName(optionTag)) + return false; + + return static_cast(m_optionElement)->selected(); +} + +IntRect AccessibilityListBoxOption::elementRect() const +{ + IntRect rect; + if (!m_optionElement) + return rect; + + HTMLSelectElement* listBoxParentNode = listBoxOptionParentNode(); + if (!listBoxParentNode) + return rect; + + RenderObject* listBoxRenderer = listBoxParentNode->renderer(); + if (!listBoxRenderer) + return rect; + + IntRect parentRect = listBoxRenderer->document()->axObjectCache()->getOrCreate(listBoxRenderer)->boundingBoxRect(); + int index = listBoxOptionIndex(); + if (index != -1) + rect = toRenderListBox(listBoxRenderer)->itemBoundingBoxRect(parentRect.x(), parentRect.y(), index); + + return rect; +} + +bool AccessibilityListBoxOption::accessibilityIsIgnored() const +{ + if (!m_optionElement) + return true; + + if (equalIgnoringCase(getAttribute(aria_hiddenAttr), "true")) + return true; + + return parentObject()->accessibilityIsIgnored(); +} + +bool AccessibilityListBoxOption::canSetSelectedAttribute() const +{ + if (!m_optionElement) + return false; + + if (!m_optionElement->hasTagName(optionTag)) + return false; + + if (m_optionElement->disabled()) + return false; + + HTMLSelectElement* selectElement = listBoxOptionParentNode(); + if (selectElement && selectElement->disabled()) + return false; + + return true; +} + +String AccessibilityListBoxOption::stringValue() const +{ + if (!m_optionElement) + return String(); + + const AtomicString& ariaLabel = getAttribute(aria_labelAttr); + if (!ariaLabel.isNull()) + return ariaLabel; + + if (m_optionElement->hasTagName(optionTag)) + return static_cast(m_optionElement)->text(); + + if (m_optionElement->hasTagName(optgroupTag)) + return static_cast(m_optionElement)->groupLabelText(); + + return String(); +} + +Element* AccessibilityListBoxOption::actionElement() const +{ + return m_optionElement; +} + +AccessibilityObject* AccessibilityListBoxOption::parentObject() const +{ + HTMLSelectElement* parentNode = listBoxOptionParentNode(); + if (!parentNode) + return 0; + + return m_optionElement->document()->axObjectCache()->getOrCreate(parentNode->renderer()); +} + +void AccessibilityListBoxOption::setSelected(bool selected) +{ + HTMLSelectElement* selectElement = listBoxOptionParentNode(); + if (!selectElement) + return; + + if (!canSetSelectedAttribute()) + return; + + bool isOptionSelected = isSelected(); + if ((isOptionSelected && selected) || (!isOptionSelected && !selected)) + return; + + // Convert from the entire list index to the option index. + int optionIndex = static_cast(selectElement)->listToOptionIndex(listBoxOptionIndex()); + selectElement->accessKeySetSelectedIndex(optionIndex); +} + +HTMLSelectElement* AccessibilityListBoxOption::listBoxOptionParentNode() const +{ + if (!m_optionElement) + return 0; + + if (m_optionElement->hasTagName(optionTag)) + return static_cast(m_optionElement)->ownerSelectElement(); + + if (m_optionElement->hasTagName(optgroupTag)) + return static_cast(m_optionElement)->ownerSelectElement(); + + return 0; +} + +int AccessibilityListBoxOption::listBoxOptionIndex() const +{ + if (!m_optionElement) + return -1; + + HTMLSelectElement* selectElement = listBoxOptionParentNode(); + if (!selectElement) + return -1; + + const Vector& listItems = selectElement->listItems(); + unsigned length = listItems.size(); + for (unsigned i = 0; i < length; i++) + if (listItems[i] == m_optionElement) + return i; + + return -1; +} + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AccessibilityListBoxOption.h b/Source/WebCore/accessibility/AccessibilityListBoxOption.h new file mode 100644 index 0000000..597c731 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityListBoxOption.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2008 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 AccessibilityListBoxOption_h +#define AccessibilityListBoxOption_h + +#include "AccessibilityObject.h" +#include "HTMLElement.h" +#include + +namespace WebCore { + +class AccessibilityListBox; +class Element; +class HTMLElement; +class HTMLSelectElement; + +class AccessibilityListBoxOption : public AccessibilityObject { + +private: + AccessibilityListBoxOption(); +public: + static PassRefPtr create(); + virtual ~AccessibilityListBoxOption(); + + void setHTMLElement(HTMLElement* element) { m_optionElement = element; } + + virtual AccessibilityRole roleValue() const { return ListBoxOptionRole; } + virtual bool accessibilityIsIgnored() const; + virtual bool isSelected() const; + virtual bool isEnabled() const; + virtual String stringValue() const; + virtual Element* actionElement() const; + virtual Node* node() const { return m_optionElement; } + virtual void setSelected(bool); + virtual bool canSetSelectedAttribute() const; + + virtual IntRect elementRect() const; + virtual AccessibilityObject* parentObject() const; + bool isListBoxOption() const { return true; } + +private: + HTMLElement* m_optionElement; + + virtual bool canHaveChildren() const { return false; } + HTMLSelectElement* listBoxOptionParentNode() const; + int listBoxOptionIndex() const; + IntRect listBoxOptionRect() const; + AccessibilityObject* listBoxOptionAccessibilityObject(HTMLElement*) const; +}; + +} // namespace WebCore + +#endif // AccessibilityListBoxOption_h diff --git a/Source/WebCore/accessibility/AccessibilityMediaControls.cpp b/Source/WebCore/accessibility/AccessibilityMediaControls.cpp new file mode 100644 index 0000000..2f98acd --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityMediaControls.cpp @@ -0,0 +1,331 @@ +/* + * Copyright (C) 2009 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" + +#if ENABLE(VIDEO) + +#include "AccessibilityMediaControls.h" + +#include "AXObjectCache.h" +#include "HTMLInputElement.h" +#include "HTMLNames.h" +#include "LocalizedStrings.h" +#include "MediaControlElements.h" +#include "RenderObject.h" +#include "RenderSlider.h" + +namespace WebCore { + +using namespace HTMLNames; + + +AccessibilityMediaControl::AccessibilityMediaControl(RenderObject* renderer) + : AccessibilityRenderObject(renderer) +{ +} + +PassRefPtr AccessibilityMediaControl::create(RenderObject* renderer) +{ + ASSERT(renderer->node() && renderer->node()->isMediaControlElement()); + + Node* node = renderer->node(); + MediaControlElementType controlType; + + if (node->hasTagName(inputTag)) + controlType = static_cast(node)->displayType(); + else + controlType = static_cast(node)->displayType(); + + PassRefPtr obj; + switch (controlType) { + case MediaSlider: + obj = AccessibilityMediaTimeline::create(renderer); + break; + + case MediaCurrentTimeDisplay: + case MediaTimeRemainingDisplay: + obj = AccessibilityMediaTimeDisplay::create(renderer); + break; + + case MediaControlsPanel: + obj = AccessibilityMediaControlsContainer::create(renderer); + break; + + default: + obj = adoptRef(new AccessibilityMediaControl(renderer)); + break; + } + + return obj; +} + +MediaControlElementType AccessibilityMediaControl::controlType() const +{ + if (!renderer() || !renderer()->node()) + return MediaTimelineContainer; // Timeline container is not accessible. + + Node* node = renderer()->node(); + + if (node->hasTagName(inputTag)) + return static_cast(node)->displayType(); + + return static_cast(node)->displayType(); +} + +String AccessibilityMediaControl::controlTypeName() const +{ + DEFINE_STATIC_LOCAL(const String, mediaFullscreenButtonName, ("FullscreenButton")); + DEFINE_STATIC_LOCAL(const String, mediaMuteButtonName, ("MuteButton")); + DEFINE_STATIC_LOCAL(const String, mediaPlayButtonName, ("PlayButton")); + DEFINE_STATIC_LOCAL(const String, mediaSeekBackButtonName, ("SeekBackButton")); + DEFINE_STATIC_LOCAL(const String, mediaSeekForwardButtonName, ("SeekForwardButton")); + DEFINE_STATIC_LOCAL(const String, mediaRewindButtonName, ("RewindButton")); + DEFINE_STATIC_LOCAL(const String, mediaReturnToRealtimeButtonName, ("ReturnToRealtimeButton")); + DEFINE_STATIC_LOCAL(const String, mediaUnMuteButtonName, ("UnMuteButton")); + DEFINE_STATIC_LOCAL(const String, mediaPauseButtonName, ("PauseButton")); + DEFINE_STATIC_LOCAL(const String, mediaStatusDisplayName, ("StatusDisplay")); + DEFINE_STATIC_LOCAL(const String, mediaCurrentTimeDisplay, ("CurrentTimeDisplay")); + DEFINE_STATIC_LOCAL(const String, mediaTimeRemainingDisplay, ("TimeRemainingDisplay")); + DEFINE_STATIC_LOCAL(const String, mediaShowClosedCaptionsButtonName, ("ShowClosedCaptionsButton")); + DEFINE_STATIC_LOCAL(const String, mediaHideClosedCaptionsButtonName, ("HideClosedCaptionsButton")); + + switch (controlType()) { + case MediaFullscreenButton: + return mediaFullscreenButtonName; + case MediaMuteButton: + return mediaMuteButtonName; + case MediaPlayButton: + return mediaPlayButtonName; + case MediaSeekBackButton: + return mediaSeekBackButtonName; + case MediaSeekForwardButton: + return mediaSeekForwardButtonName; + case MediaRewindButton: + return mediaRewindButtonName; + case MediaReturnToRealtimeButton: + return mediaReturnToRealtimeButtonName; + case MediaUnMuteButton: + return mediaUnMuteButtonName; + case MediaPauseButton: + return mediaPauseButtonName; + case MediaStatusDisplay: + return mediaStatusDisplayName; + case MediaCurrentTimeDisplay: + return mediaCurrentTimeDisplay; + case MediaTimeRemainingDisplay: + return mediaTimeRemainingDisplay; + case MediaShowClosedCaptionsButton: + return mediaShowClosedCaptionsButtonName; + case MediaHideClosedCaptionsButton: + return mediaHideClosedCaptionsButtonName; + + default: + break; + } + + return String(); +} + +String AccessibilityMediaControl::title() const +{ + DEFINE_STATIC_LOCAL(const String, controlsPanel, ("ControlsPanel")); + + if (controlType() == MediaControlsPanel) + return localizedMediaControlElementString(controlsPanel); + + return AccessibilityRenderObject::title(); +} + +String AccessibilityMediaControl::accessibilityDescription() const +{ + return localizedMediaControlElementString(controlTypeName()); +} + +String AccessibilityMediaControl::helpText() const +{ + return localizedMediaControlElementHelpText(controlTypeName()); +} + +bool AccessibilityMediaControl::accessibilityIsIgnored() const +{ + if (!m_renderer || !m_renderer->style() || m_renderer->style()->visibility() != VISIBLE || controlType() == MediaTimelineContainer) + return true; + + return false; +} + +AccessibilityRole AccessibilityMediaControl::roleValue() const +{ + switch (controlType()) { + case MediaFullscreenButton: + case MediaMuteButton: + case MediaPlayButton: + case MediaSeekBackButton: + case MediaSeekForwardButton: + case MediaRewindButton: + case MediaReturnToRealtimeButton: + case MediaUnMuteButton: + case MediaPauseButton: + case MediaShowClosedCaptionsButton: + case MediaHideClosedCaptionsButton: + return ButtonRole; + + case MediaStatusDisplay: + return StaticTextRole; + + case MediaTimelineContainer: + return GroupRole; + + default: + break; + } + + return UnknownRole; +} + + + +// +// AccessibilityMediaControlsContainer + +AccessibilityMediaControlsContainer::AccessibilityMediaControlsContainer(RenderObject* renderer) + : AccessibilityMediaControl(renderer) +{ +} + +PassRefPtr AccessibilityMediaControlsContainer::create(RenderObject* renderer) +{ + return adoptRef(new AccessibilityMediaControlsContainer(renderer)); +} + +String AccessibilityMediaControlsContainer::accessibilityDescription() const +{ + return localizedMediaControlElementString(elementTypeName()); +} + +String AccessibilityMediaControlsContainer::helpText() const +{ + return localizedMediaControlElementHelpText(elementTypeName()); +} + +bool AccessibilityMediaControlsContainer::controllingVideoElement() const +{ + if (!m_renderer->node()) + return true; + + MediaControlTimeDisplayElement* element = static_cast(m_renderer->node()); + + return element->mediaElement()->isVideo(); +} + +const String AccessibilityMediaControlsContainer::elementTypeName() const +{ + DEFINE_STATIC_LOCAL(const String, videoElement, ("VideoElement")); + DEFINE_STATIC_LOCAL(const String, audioElement, ("AudioElement")); + + if (controllingVideoElement()) + return videoElement; + return audioElement; +} + + +// +// AccessibilityMediaTimeline + +AccessibilityMediaTimeline::AccessibilityMediaTimeline(RenderObject* renderer) + : AccessibilitySlider(renderer) +{ +} + +PassRefPtr AccessibilityMediaTimeline::create(RenderObject* renderer) +{ + return adoptRef(new AccessibilityMediaTimeline(renderer)); +} + +String AccessibilityMediaTimeline::valueDescription() const +{ + ASSERT(m_renderer->node()->hasTagName(inputTag)); + + float time = static_cast(m_renderer->node())->value().toFloat(); + return localizedMediaTimeDescription(time); +} + +String AccessibilityMediaTimeline::helpText() const +{ + DEFINE_STATIC_LOCAL(const String, slider, ("Slider")); + return localizedMediaControlElementHelpText(slider); +} + + +// +// AccessibilityMediaTimeDisplay + +AccessibilityMediaTimeDisplay::AccessibilityMediaTimeDisplay(RenderObject* renderer) + : AccessibilityMediaControl(renderer) +{ +} + +PassRefPtr AccessibilityMediaTimeDisplay::create(RenderObject* renderer) +{ + return adoptRef(new AccessibilityMediaTimeDisplay(renderer)); +} + +bool AccessibilityMediaTimeDisplay::accessibilityIsIgnored() const +{ + if (!m_renderer || !m_renderer->style() || m_renderer->style()->visibility() != VISIBLE) + return true; + + return !m_renderer->style()->width().value(); +} + +String AccessibilityMediaTimeDisplay::accessibilityDescription() const +{ + DEFINE_STATIC_LOCAL(const String, currentTimeDisplay, ("CurrentTimeDisplay")); + DEFINE_STATIC_LOCAL(const String, timeRemainingDisplay, ("TimeRemainingDisplay")); + + if (controlType() == MediaCurrentTimeDisplay) + return localizedMediaControlElementString(currentTimeDisplay); + + return localizedMediaControlElementString(timeRemainingDisplay); +} + +String AccessibilityMediaTimeDisplay::stringValue() const +{ + if (!m_renderer || !m_renderer->node()) + return String(); + + MediaControlTimeDisplayElement* element = static_cast(m_renderer->node()); + float time = element->currentValue(); + return localizedMediaTimeDescription(fabsf(time)); +} + +} // namespace WebCore + +#endif // ENABLE(VIDEO) diff --git a/Source/WebCore/accessibility/AccessibilityMediaControls.h b/Source/WebCore/accessibility/AccessibilityMediaControls.h new file mode 100644 index 0000000..6f51b2c --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityMediaControls.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2009 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 AccessibilityMediaControls_h +#define AccessibilityMediaControls_h + +#if ENABLE(VIDEO) + +#include "AccessibilitySlider.h" +#include "MediaControlElements.h" + +namespace WebCore { + +class AccessibilityMediaControl : public AccessibilityRenderObject { + +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityMediaControl() { } + + virtual AccessibilityRole roleValue() const; + virtual bool accessibilityIsIgnored() const; + + virtual String title() const; + virtual String accessibilityDescription() const; + virtual String helpText() const; + +protected: + AccessibilityMediaControl(RenderObject*); + MediaControlElementType controlType() const; + String controlTypeName() const; +}; + + +class AccessibilityMediaTimeline : public AccessibilitySlider { + +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityMediaTimeline() { } + + virtual bool isMediaTimeline() const { return true; } + + virtual String helpText() const; + virtual String valueDescription() const; + const AtomicString& getAttribute(const QualifiedName& attribute) const; + +private: + AccessibilityMediaTimeline(RenderObject*); +}; + + +class AccessibilityMediaControlsContainer : public AccessibilityMediaControl { + +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityMediaControlsContainer() { } + + virtual AccessibilityRole roleValue() const { return ToolbarRole; } + virtual bool accessibilityIsIgnored() const { return false; } + + virtual String helpText() const; + virtual String accessibilityDescription() const; + +private: + AccessibilityMediaControlsContainer(RenderObject*); + bool controllingVideoElement() const; + const String elementTypeName() const; +}; + + +class AccessibilityMediaTimeDisplay : public AccessibilityMediaControl { + +public: + static PassRefPtr create(RenderObject*); + virtual ~AccessibilityMediaTimeDisplay() { } + + virtual AccessibilityRole roleValue() const { return StaticTextRole; } + virtual bool accessibilityIsIgnored() const; + + virtual String stringValue() const; + virtual String accessibilityDescription() const; + +private: + AccessibilityMediaTimeDisplay(RenderObject*); +}; + + +} // namespace WebCore + +#endif // ENABLE(VIDEO) + +#endif // AccessibilityMediaControls_h diff --git a/Source/WebCore/accessibility/AccessibilityMenuList.cpp b/Source/WebCore/accessibility/AccessibilityMenuList.cpp new file mode 100644 index 0000000..bde4cd4 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityMenuList.cpp @@ -0,0 +1,90 @@ +/* + * 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 INC. OR + * 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 "AccessibilityMenuList.h" + +#include "AXObjectCache.h" +#include "AccessibilityMenuListPopup.h" +#include "RenderMenuList.h" + +namespace WebCore { + +AccessibilityMenuList::AccessibilityMenuList(RenderMenuList* renderer) + : AccessibilityRenderObject(renderer) +{ +} + +RenderMenuList* AccessibilityMenuList::renderer() const +{ + return toRenderMenuList(AccessibilityRenderObject::renderer()); +} + +bool AccessibilityMenuList::press() const +{ + RenderMenuList* menuList = static_cast(m_renderer); + if (menuList->popupIsVisible()) + menuList->hidePopup(); + else + menuList->showPopup(); + return true; +} + +void AccessibilityMenuList::addChildren() +{ + m_haveChildren = true; + + AXObjectCache* cache = m_renderer->document()->axObjectCache(); + + AccessibilityObject* list = cache->getOrCreate(MenuListPopupRole); + if (!list) + return; + + if (list->accessibilityPlatformIncludesObject() == IgnoreObject) { + cache->remove(list->axObjectID()); + return; + } + + static_cast(list)->setMenuList(this); + m_children.append(list); + + list->addChildren(); +} + +void AccessibilityMenuList::childrenChanged() +{ + if (m_children.isEmpty()) + return; + + ASSERT(m_children.size() == 1); + m_children[0]->childrenChanged(); +} + +bool AccessibilityMenuList::isCollapsed() const +{ + return !static_cast(m_renderer)->popupIsVisible(); +} + +} // namespace WebCore diff --git a/Source/WebCore/accessibility/AccessibilityMenuList.h b/Source/WebCore/accessibility/AccessibilityMenuList.h new file mode 100644 index 0000000..4082f0a --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityMenuList.h @@ -0,0 +1,61 @@ +/* + * 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 INC. OR + * 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 AccessibilityMenuList_h +#define AccessibilityMenuList_h + +#include "AccessibilityRenderObject.h" + +namespace WebCore { + +class AccessibilityMenuList; +class AccessibilityMenuListPopup; +class HTMLOptionElement; +class RenderMenuList; + +class AccessibilityMenuList : public AccessibilityRenderObject { +public: + static PassRefPtr create(RenderMenuList* renderer) { return adoptRef(new AccessibilityMenuList(renderer)); } + + virtual bool isCollapsed() const; + virtual bool press() const; + + RenderMenuList* renderer() const; + +private: + AccessibilityMenuList(RenderMenuList*); + + virtual bool isMenuList() const { return true; } + virtual AccessibilityRole roleValue() const { return PopUpButtonRole; } + virtual bool accessibilityIsIgnored() const { return false; } + virtual bool canSetFocusAttribute() const { return true; } + + virtual void addChildren(); + virtual void childrenChanged(); +}; + +} // namespace WebCore + +#endif // AccessibilityMenuList_h diff --git a/Source/WebCore/accessibility/AccessibilityMenuListOption.cpp b/Source/WebCore/accessibility/AccessibilityMenuListOption.cpp new file mode 100644 index 0000000..5bca580 --- /dev/null +++ b/Source/WebCore/accessibility/AccessibilityMenuListOption.cpp @@ -0,0 +1,118 @@ +/* + * 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 INC. OR + * 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 "AccessibilityMenuListOption.h" + +#include "AXObjectCache.h" +#include "AccessibilityMenuListPopup.h" +#include "HTMLNames.h" +#include "HTMLOptionElement.h" + +namespace WebCore { + +using namespace HTMLNames; + +AccessibilityMenuListOption::AccessibilityMenuListOption() + : m_popup(0) +{ +} + +void AccessibilityMenuListOption::setElement(HTMLElement* element) +{ + ASSERT_ARG(element, element->hasTagName(optionTag)); + m_element = element; +} + +Element* AccessibilityMenuListOption::actionElement() const +{ + return m_element.get(); +} + +AccessibilityObject* AccessibilityMenuListOption::parentObject() const +{ + return m_popup; +} + +bool AccessibilityMenuListOption::isEnabled() const +{ + // disabled() returns true if the parent