diff options
Diffstat (limited to 'WebCore/accessibility')
8 files changed, 53 insertions, 154 deletions
diff --git a/WebCore/accessibility/AccessibilityImageMapLink.cpp b/WebCore/accessibility/AccessibilityImageMapLink.cpp index 870efe3..9b77400 100644 --- a/WebCore/accessibility/AccessibilityImageMapLink.cpp +++ b/WebCore/accessibility/AccessibilityImageMapLink.cpp @@ -59,7 +59,7 @@ AccessibilityObject* AccessibilityImageMapLink::parentObject() const if (m_parent) return m_parent; - if (!m_mapElement.get() || !m_mapElement->renderer()) + if (!m_mapElement || !m_mapElement->renderer()) return 0; return m_mapElement->document()->axObjectCache()->getOrCreate(m_mapElement->renderer()); @@ -84,12 +84,12 @@ Element* AccessibilityImageMapLink::actionElement() const Element* AccessibilityImageMapLink::anchorElement() const { - return m_areaElement.get(); + return m_areaElement; } KURL AccessibilityImageMapLink::url() const { - if (!m_areaElement.get()) + if (!m_areaElement) return KURL(); return m_areaElement->href(); @@ -121,7 +121,7 @@ String AccessibilityImageMapLink::title() const IntRect AccessibilityImageMapLink::elementRect() const { - if (!m_mapElement.get() || !m_areaElement.get()) + if (!m_mapElement || !m_areaElement) return IntRect(); RenderObject* renderer; diff --git a/WebCore/accessibility/AccessibilityImageMapLink.h b/WebCore/accessibility/AccessibilityImageMapLink.h index 011d5de..e2e1544 100644 --- a/WebCore/accessibility/AccessibilityImageMapLink.h +++ b/WebCore/accessibility/AccessibilityImageMapLink.h @@ -44,12 +44,12 @@ public: virtual ~AccessibilityImageMapLink(); void setHTMLAreaElement(HTMLAreaElement* element) { m_areaElement = element; } - HTMLAreaElement* areaElement() const { return m_areaElement.get(); } + HTMLAreaElement* areaElement() const { return m_areaElement; } void setHTMLMapElement(HTMLMapElement* element) { m_mapElement = element; } - HTMLMapElement* mapElement() const { return m_mapElement.get(); } + HTMLMapElement* mapElement() const { return m_mapElement; } - virtual Node* node() const { return m_areaElement.get(); } + virtual Node* node() const { return m_areaElement; } void setParent(AccessibilityObject* parent) { m_parent = parent; } virtual AccessibilityRole roleValue() const; @@ -72,8 +72,8 @@ public: virtual IntRect elementRect() const; private: - RefPtr<HTMLAreaElement> m_areaElement; - RefPtr<HTMLMapElement> m_mapElement; + HTMLAreaElement* m_areaElement; + HTMLMapElement* m_mapElement; AccessibilityObject* m_parent; virtual bool isImageMapLink() const { return true; } diff --git a/WebCore/accessibility/AccessibilityMenuListOption.cpp b/WebCore/accessibility/AccessibilityMenuListOption.cpp index 5bca580..d7473de 100644 --- a/WebCore/accessibility/AccessibilityMenuListOption.cpp +++ b/WebCore/accessibility/AccessibilityMenuListOption.cpp @@ -91,7 +91,7 @@ void AccessibilityMenuListOption::setSelected(bool b) String AccessibilityMenuListOption::nameForMSAA() const { - return stringValue(); + return static_cast<HTMLOptionElement*>(m_element.get())->text(); } bool AccessibilityMenuListOption::canSetSelectedAttribute() const @@ -110,9 +110,4 @@ IntRect AccessibilityMenuListOption::elementRect() const return grandparent->elementRect(); } -String AccessibilityMenuListOption::stringValue() const -{ - return static_cast<HTMLOptionElement*>(m_element.get())->text(); -} - } // namespace WebCore diff --git a/WebCore/accessibility/AccessibilityMenuListOption.h b/WebCore/accessibility/AccessibilityMenuListOption.h index 9393d56..7e27888 100644 --- a/WebCore/accessibility/AccessibilityMenuListOption.h +++ b/WebCore/accessibility/AccessibilityMenuListOption.h @@ -59,7 +59,6 @@ private: virtual void setSelected(bool); virtual bool canSetSelectedAttribute() const; virtual IntRect elementRect() const; - virtual String stringValue() const; RefPtr<HTMLElement> m_element; AccessibilityMenuListPopup* m_popup; diff --git a/WebCore/accessibility/AccessibilityRenderObject.cpp b/WebCore/accessibility/AccessibilityRenderObject.cpp index 3c6079b..141d725 100644 --- a/WebCore/accessibility/AccessibilityRenderObject.cpp +++ b/WebCore/accessibility/AccessibilityRenderObject.cpp @@ -1325,30 +1325,17 @@ String AccessibilityRenderObject::ariaDescribedByAttribute() const return accessibilityDescriptionForElements(elements); } - -String AccessibilityRenderObject::ariaAccessibilityDescription() const -{ - const AtomicString& ariaLabel = getAttribute(aria_labelAttr); - if (!ariaLabel.isEmpty()) - return ariaLabel; - - String ariaDescription = ariaDescribedByAttribute(); - if (!ariaDescription.isEmpty()) - return ariaDescription; - - return String(); -} String AccessibilityRenderObject::accessibilityDescription() const { if (!m_renderer) return String(); - // Static text should not have a description, it should only have a stringValue. - if (roleValue() == StaticTextRole) - return String(); + const AtomicString& ariaLabel = getAttribute(aria_labelAttr); + if (!ariaLabel.isEmpty()) + return ariaLabel; - String ariaDescription = ariaAccessibilityDescription(); + String ariaDescription = ariaDescribedByAttribute(); if (!ariaDescription.isEmpty()) return ariaDescription; @@ -1908,7 +1895,7 @@ String AccessibilityRenderObject::text() const { // If this is a user defined static text, use the accessible name computation. if (ariaRoleAttribute() == StaticTextRole) - return ariaAccessibilityDescription(); + return accessibilityDescription(); if (!isTextControl() || isPasswordField()) return String(); diff --git a/WebCore/accessibility/AccessibilityRenderObject.h b/WebCore/accessibility/AccessibilityRenderObject.h index a01008a..970ef9f 100644 --- a/WebCore/accessibility/AccessibilityRenderObject.h +++ b/WebCore/accessibility/AccessibilityRenderObject.h @@ -300,7 +300,6 @@ private: String accessibilityDescriptionForElements(Vector<Element*> &elements) const; void elementsFromAttribute(Vector<Element*>& elements, const QualifiedName& name) const; - String ariaAccessibilityDescription() const; virtual ESpeak speakProperty() const; diff --git a/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp b/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp index c341a2d..4216be4 100644 --- a/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp +++ b/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp @@ -95,19 +95,10 @@ static void notifyChildrenSelectionChange(AccessibilityObject* object) void AXObjectCache::postPlatformNotification(AccessibilityObject* coreObject, AXNotification notification) { - AtkObject* axObject = coreObject->wrapper(); - if (!axObject) - return; - if (notification == AXCheckedStateChanged) { if (!coreObject->isCheckboxOrRadio()) return; - g_signal_emit_by_name(axObject, "state-change", "checked", coreObject->isChecked()); - } else if (notification == AXMenuListValueChanged) { - if (!coreObject->isMenuList()) - return; - g_signal_emit_by_name(axObject, "focus-event", true); - g_signal_emit_by_name(axObject, "state-change", "focused", true); + g_signal_emit_by_name(coreObject->wrapper(), "state-change", "checked", coreObject->isChecked()); } else if (notification == AXSelectedChildrenChanged) notifyChildrenSelectionChange(coreObject); } diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp index ca0d80b..3156505 100644 --- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp +++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp @@ -58,7 +58,6 @@ #include "RenderListItem.h" #include "RenderListMarker.h" #include "RenderText.h" -#include "SelectElement.h" #include "TextEncoding.h" #include "TextIterator.h" #include "WebKitAccessibleHyperlink.h" @@ -172,7 +171,7 @@ static const gchar* webkit_accessible_get_name(AtkObject* object) return webkit_accessible_text_get_text(ATK_TEXT(atkObject), 0, -1); } - // Try text under the node + // Try text under the node. String textUnder = renderObject->textUnderElement(); if (textUnder.length()) return returnString(textUnder); @@ -188,6 +187,13 @@ static const gchar* webkit_accessible_get_name(AtkObject* object) } } + // Fallback for the webArea object: just return the document's title. + if (renderObject->isWebArea()) { + Document* document = coreObject->document(); + if (document) + return returnString(document->title()); + } + return returnString(coreObject->stringValue()); } @@ -501,12 +507,6 @@ static void setAtkStateSetFromCoreObject(AccessibilityObject* coreObject, AtkSta atk_state_set_add_state(stateSet, ATK_STATE_SENSITIVE); } - if (coreObject->canSetExpandedAttribute()) - atk_state_set_add_state(stateSet, ATK_STATE_EXPANDABLE); - - if (coreObject->isExpanded()) - atk_state_set_add_state(stateSet, ATK_STATE_EXPANDED); - if (coreObject->canSetFocusAttribute()) atk_state_set_add_state(stateSet, ATK_STATE_FOCUSABLE); @@ -701,44 +701,13 @@ static void atk_action_interface_init(AtkActionIface* iface) // Selection (for controls) -static AccessibilityObject* listObjectForSelection(AtkSelection* selection) -{ - AccessibilityObject* coreSelection = core(selection); - - // Only list boxes and menu lists supported so far. - if (!coreSelection->isListBox() && !coreSelection->isMenuList()) - return 0; - - // For list boxes the list object is just itself. - if (coreSelection->isListBox()) - return coreSelection; - - // For menu lists we need to return the first accessible child, - // with role MenuListPopupRole, since that's the one holding the list - // of items with role MenuListOptionRole. - AccessibilityObject::AccessibilityChildrenVector children = coreSelection->children(); - if (!children.size()) - return 0; - - AccessibilityObject* listObject = children.at(0).get(); - if (!listObject->isMenuListPopup()) - return 0; - - return listObject; -} - static AccessibilityObject* optionFromList(AtkSelection* selection, gint i) { AccessibilityObject* coreSelection = core(selection); if (!coreSelection || i < 0) return 0; - // Need to select the proper list object depending on the type. - AccessibilityObject* listObject = listObjectForSelection(selection); - if (!listObject) - return 0; - - AccessibilityRenderObject::AccessibilityChildrenVector options = listObject->children(); + AccessibilityRenderObject::AccessibilityChildrenVector options = core(selection)->children(); if (i < static_cast<gint>(options.size())) return options.at(i).get(); @@ -750,26 +719,14 @@ static AccessibilityObject* optionFromSelection(AtkSelection* selection, gint i) // i is the ith selection as opposed to the ith child. AccessibilityObject* coreSelection = core(selection); - if (!coreSelection || !coreSelection->isAccessibilityRenderObject() || i < 0) + if (!coreSelection || i < 0) return 0; AccessibilityRenderObject::AccessibilityChildrenVector selectedItems; if (coreSelection->isListBox()) - coreSelection->selectedChildren(selectedItems); - else if (coreSelection->isMenuList()) { - RenderObject* renderer = toAccessibilityRenderObject(coreSelection)->renderer(); - if (!renderer) - return 0; + static_cast<AccessibilityListBox*>(coreSelection)->selectedChildren(selectedItems); - SelectElement* selectNode = toSelectElement(static_cast<Element*>(renderer->node())); - int selectedIndex = selectNode->selectedIndex(); - const Vector<Element*> listItems = selectNode->listItems(); - - if (selectedIndex < 0 || selectedIndex >= static_cast<int>(listItems.size())) - return 0; - - return optionFromList(selection, selectedIndex); - } + // TODO: Combo boxes if (i < static_cast<gint>(selectedItems.size())) return selectedItems.at(i).get(); @@ -779,14 +736,11 @@ static AccessibilityObject* optionFromSelection(AtkSelection* selection, gint i) static gboolean webkit_accessible_selection_add_selection(AtkSelection* selection, gint i) { - AccessibilityObject* coreSelection = core(selection); - if (!coreSelection) - return false; - AccessibilityObject* option = optionFromList(selection, i); - if (option && (coreSelection->isListBox() || coreSelection->isMenuList())) { - option->setSelected(true); - return option->isSelected(); + if (option && core(selection)->isListBox()) { + AccessibilityListBoxOption* listBoxOption = static_cast<AccessibilityListBoxOption*>(option); + listBoxOption->setSelected(true); + return listBoxOption->isSelected(); } return false; @@ -799,7 +753,7 @@ static gboolean webkit_accessible_selection_clear_selection(AtkSelection* select return false; AccessibilityRenderObject::AccessibilityChildrenVector selectedItems; - if (coreSelection->isListBox() || coreSelection->isMenuList()) { + if (coreSelection->isListBox()) { // Set the list of selected items to an empty list; then verify that it worked. AccessibilityListBox* listBox = static_cast<AccessibilityListBox*>(coreSelection); listBox->setSelectedChildren(selectedItems); @@ -824,54 +778,32 @@ static AtkObject* webkit_accessible_selection_ref_selection(AtkSelection* select static gint webkit_accessible_selection_get_selection_count(AtkSelection* selection) { AccessibilityObject* coreSelection = core(selection); - if (!coreSelection || !coreSelection->isAccessibilityRenderObject()) - return 0; - - if (coreSelection->isListBox()) { + if (coreSelection && coreSelection->isListBox()) { AccessibilityRenderObject::AccessibilityChildrenVector selectedItems; - coreSelection->selectedChildren(selectedItems); + static_cast<AccessibilityListBox*>(coreSelection)->selectedChildren(selectedItems); return static_cast<gint>(selectedItems.size()); } - if (coreSelection->isMenuList()) { - RenderObject* renderer = toAccessibilityRenderObject(coreSelection)->renderer(); - if (!renderer) - return 0; - - SelectElement* selectNode = toSelectElement(static_cast<Element*>(renderer->node())); - int selectedIndex = selectNode->selectedIndex(); - const Vector<Element*> listItems = selectNode->listItems(); - - return selectedIndex >= 0 && selectedIndex < static_cast<int>(listItems.size()); - } - return 0; } static gboolean webkit_accessible_selection_is_child_selected(AtkSelection* selection, gint i) { - AccessibilityObject* coreSelection = core(selection); - if (!coreSelection) - return 0; - AccessibilityObject* option = optionFromList(selection, i); - if (option && (coreSelection->isListBox() || coreSelection->isMenuList())) - return option->isSelected(); + if (option && core(selection)->isListBox()) + return static_cast<AccessibilityListBoxOption*>(option)->isSelected(); return false; } static gboolean webkit_accessible_selection_remove_selection(AtkSelection* selection, gint i) { - AccessibilityObject* coreSelection = core(selection); - if (!coreSelection) - return 0; - // TODO: This is only getting called if i == 0. What is preventing the rest? AccessibilityObject* option = optionFromSelection(selection, i); - if (option && (coreSelection->isListBox() || coreSelection->isMenuList())) { - option->setSelected(false); - return !option->isSelected(); + if (option && core(selection)->isListBox()) { + AccessibilityListBoxOption* listBoxOption = static_cast<AccessibilityListBoxOption*>(option); + listBoxOption->setSelected(false); + return !listBoxOption->isSelected(); } return false; @@ -1044,11 +976,8 @@ static gchar* webkit_accessible_text_get_text(AtkText* text, gint startOffset, g if (coreObject->isTextControl()) ret = coreObject->doAXStringForRange(PlainTextRange(start, length)); - else { - ret = coreObject->stringValue().substring(start, length); - if (!ret) - ret = coreObject->textUnderElement().substring(start, length); - } + else + ret = coreObject->textUnderElement().substring(start, length); if (!ret.length()) { // This can happen at least with anonymous RenderBlocks (e.g. body text amongst paragraphs) @@ -2255,23 +2184,19 @@ static guint16 getInterfaceMaskFromObject(AccessibilityObject* coreObject) AccessibilityRole role = coreObject->roleValue(); // Action - // As the implementation of the AtkAction interface is a very - // basic one (just relays in executing the default action for each - // object, and only supports having one action per object), it is - // better just to implement this interface for every instance of - // the WebKitAccessible class and let WebCore decide what to do. - interfaceMask |= 1 << WAI_ACTION; + if (!coreObject->actionVerb().isEmpty()) { + interfaceMask |= 1 << WAI_ACTION; - // Hyperlink - if (coreObject->isLink()) - interfaceMask |= 1 << WAI_HYPERLINK; + if (!coreObject->accessibilityIsIgnored() && coreObject->isLink()) + interfaceMask |= 1 << WAI_HYPERLINK; + } // Selection - if (coreObject->isListBox() || coreObject->isMenuList()) + if (coreObject->isListBox()) interfaceMask |= 1 << WAI_SELECTION; // Text & Editable Text - if (role == StaticTextRole || coreObject->isMenuListOption()) + if (role == StaticTextRole) interfaceMask |= 1 << WAI_TEXT; else if (coreObject->isAccessibilityRenderObject()) { if (coreObject->isTextControl()) { @@ -2378,6 +2303,9 @@ void webkit_accessible_detach(WebKitAccessible* accessible) { ASSERT(accessible->m_object); + if (core(accessible)->roleValue() == WebAreaRole) + g_signal_emit_by_name(accessible, "state-change", "defunct", true); + // We replace the WebCore AccessibilityObject with a fallback object that // provides default implementations to avoid repetitive null-checking after // detachment. |