summaryrefslogtreecommitdiffstats
path: root/WebCore/accessibility
diff options
context:
space:
mode:
authorAndrei Popescu <andreip@google.com>2009-08-19 14:09:30 +0100
committerAndrei Popescu <andreip@google.com>2009-08-19 14:09:30 +0100
commit058ccc7ba0a4d59b9f6e92808332aa9895425fc7 (patch)
tree276aad5a2bbc2fd7d65d21bfca42c9de88b3dd20 /WebCore/accessibility
parent2796dd1bf3b4b01e7e1d96ea91bd3a212f647579 (diff)
downloadexternal_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.zip
external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.tar.gz
external_webkit-058ccc7ba0a4d59b9f6e92808332aa9895425fc7.tar.bz2
Revert "Merge WebKit r47420"
This reverts commit d227fc870c7a697500a3c900c31baf05fb9a8524.
Diffstat (limited to 'WebCore/accessibility')
-rw-r--r--WebCore/accessibility/AXObjectCache.cpp62
-rw-r--r--WebCore/accessibility/AXObjectCache.h19
-rw-r--r--WebCore/accessibility/AccessibilityObject.cpp49
-rw-r--r--WebCore/accessibility/AccessibilityObject.h13
-rw-r--r--WebCore/accessibility/AccessibilityRenderObject.cpp29
-rw-r--r--WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp2
-rw-r--r--WebCore/accessibility/mac/AccessibilityObjectWrapper.mm20
-rw-r--r--WebCore/accessibility/win/AXObjectCacheWin.cpp39
8 files changed, 49 insertions, 184 deletions
diff --git a/WebCore/accessibility/AXObjectCache.cpp b/WebCore/accessibility/AXObjectCache.cpp
index db57f3b..0b758e6 100644
--- a/WebCore/accessibility/AXObjectCache.cpp
+++ b/WebCore/accessibility/AXObjectCache.cpp
@@ -43,11 +43,8 @@
#include "AccessibilityTableColumn.h"
#include "AccessibilityTableHeaderContainer.h"
#include "AccessibilityTableRow.h"
-#include "FocusController.h"
-#include "Frame.h"
-#include "HTMLNames.h"
#include "InputElement.h"
-#include "Page.h"
+#include "HTMLNames.h"
#include "RenderObject.h"
#include "RenderView.h"
@@ -60,9 +57,8 @@ using namespace HTMLNames;
bool AXObjectCache::gAccessibilityEnabled = false;
bool AXObjectCache::gAccessibilityEnhancedUserInterfaceEnabled = false;
-AXObjectCache::AXObjectCache(const Document* document)
+AXObjectCache::AXObjectCache()
: m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired)
- , m_document(document)
{
}
@@ -77,32 +73,6 @@ AXObjectCache::~AXObjectCache()
}
}
-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;
-
- 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(RenderObject* renderer)
{
if (!renderer)
@@ -243,23 +213,6 @@ void AXObjectCache::remove(RenderObject* renderer)
m_renderObjectMapping.remove(renderer);
}
-#if !PLATFORM(WIN)
-AXID AXObjectCache::platformGenerateAXID() const
-{
- static AXID lastUsedID = 0;
-
- // Generate a new ID.
- AXID objID = lastUsedID;
- do {
- ++objID;
- } while (objID == 0 || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
-
- lastUsedID = objID;
-
- return objID;
-}
-#endif
-
AXID AXObjectCache::getAXID(AccessibilityObject* obj)
{
// check for already-assigned ID
@@ -268,10 +221,15 @@ AXID AXObjectCache::getAXID(AccessibilityObject* obj)
ASSERT(m_idsInUse.contains(objID));
return objID;
}
-
- objID = platformGenerateAXID();
-
+
+ // generate a new ID
+ static AXID lastUsedID = 0;
+ objID = lastUsedID;
+ do
+ ++objID;
+ while (objID == 0 || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
m_idsInUse.add(objID);
+ lastUsedID = objID;
obj->setAXObjectID(objID);
return objID;
diff --git a/WebCore/accessibility/AXObjectCache.h b/WebCore/accessibility/AXObjectCache.h
index 96ded44..7a808dd 100644
--- a/WebCore/accessibility/AXObjectCache.h
+++ b/WebCore/accessibility/AXObjectCache.h
@@ -42,12 +42,13 @@ class WebCoreTextMarker;
namespace WebCore {
- class Document;
- class Node;
- class Page;
class RenderObject;
class String;
class VisiblePosition;
+ class AccessibilityObject;
+ class Node;
+
+ typedef unsigned AXID;
struct TextMarkerData {
AXID axID;
@@ -58,11 +59,9 @@ namespace WebCore {
class AXObjectCache {
public:
- AXObjectCache(const Document*);
+ AXObjectCache();
~AXObjectCache();
-
- static AccessibilityObject* focusedUIElementForPage(const Page*);
-
+
// to be used with render objects
AccessibilityObject* getOrCreate(RenderObject*);
@@ -95,13 +94,11 @@ namespace WebCore {
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(); }
// Text marker utilities.
static void textMarkerDataForVisiblePosition(TextMarkerData&, const VisiblePosition&);
static VisiblePosition visiblePositionForTextMarkerData(TextMarkerData&);
-
+
private:
HashMap<AXID, RefPtr<AccessibilityObject> > m_objects;
HashMap<RenderObject*, AXID> m_renderObjectMapping;
@@ -116,8 +113,6 @@ namespace WebCore {
AXID getAXID(AccessibilityObject*);
bool nodeIsAriaType(Node* node, String role);
-
- const Document* m_document;
};
#if !HAVE(ACCESSIBILITY)
diff --git a/WebCore/accessibility/AccessibilityObject.cpp b/WebCore/accessibility/AccessibilityObject.cpp
index 4fb4e3a..d6fd969 100644
--- a/WebCore/accessibility/AccessibilityObject.cpp
+++ b/WebCore/accessibility/AccessibilityObject.cpp
@@ -41,7 +41,6 @@
#include "NotImplemented.h"
#include "Page.h"
#include "RenderImage.h"
-#include "RenderListItem.h"
#include "RenderListMarker.h"
#include "RenderMenuList.h"
#include "RenderTextControl.h"
@@ -364,49 +363,6 @@ static bool replacedNodeNeedsCharacter(Node* replacedNode)
return true;
}
-// Finds a RenderListItem parent give a node.
-RenderListItem* AccessibilityObject::renderListItemContainerForNode(Node* node) const
-{
- for (Node* stringNode = node; stringNode; stringNode = stringNode->parent()) {
- RenderObject* renderObject = stringNode->renderer();
- if (!renderObject || !renderObject->isListItem())
- continue;
-
- return toRenderListItem(renderObject);
- }
-
- return 0;
-}
-
-// Returns the text associated with a list marker if this node is contained within a list item.
-String AccessibilityObject::listMarkerTextForNodeAndPosition(Node* node, const VisiblePosition& visiblePositionStart) const
-{
- // If the range does not contain the start of the line, the list marker text should not be included.
- if (!isStartOfLine(visiblePositionStart))
- return String();
-
- RenderListItem* listItem = renderListItemContainerForNode(node);
- if (!listItem)
- return String();
-
- // If this is in a list item, we need to manually add the text for the list marker
- // because a RenderListMarker does not have a Node equivalent and thus does not appear
- // when iterating text.
- const String& markerText = listItem->markerText();
- if (markerText.isEmpty())
- return String();
-
- // Append text, plus the period that follows the text.
- // FIXME: Not all list marker styles are followed by a period, but this
- // sounds much better when there is a synthesized pause because of a period.
- Vector<UChar> resultVector;
- resultVector.append(markerText.characters(), markerText.length());
- resultVector.append('.');
- resultVector.append(' ');
-
- return String::adopt(resultVector);
-}
-
String AccessibilityObject::stringForVisiblePositionRange(const VisiblePositionRange& visiblePositionRange) const
{
if (visiblePositionRange.isNull())
@@ -417,11 +373,6 @@ String AccessibilityObject::stringForVisiblePositionRange(const VisiblePositionR
for (TextIterator it(range.get()); !it.atEnd(); it.advance()) {
// non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX)
if (it.length() != 0) {
- // Add a textual representation for list marker text
- String listMarkerText = listMarkerTextForNodeAndPosition(it.node(), visiblePositionRange.start);
- if (!listMarkerText.isEmpty())
- resultVector.append(listMarkerText.characters(), listMarkerText.length());
-
resultVector.append(it.characters(), it.length());
} else {
// locate the node and starting offset for this replaced range
diff --git a/WebCore/accessibility/AccessibilityObject.h b/WebCore/accessibility/AccessibilityObject.h
index 9173953..3f6c395 100644
--- a/WebCore/accessibility/AccessibilityObject.h
+++ b/WebCore/accessibility/AccessibilityObject.h
@@ -86,13 +86,10 @@ class IntPoint;
class IntSize;
class Node;
class RenderObject;
-class RenderListItem;
class VisibleSelection;
class String;
class Widget;
-typedef unsigned AXID;
-
enum AccessibilityRole {
UnknownRole = 1,
ButtonRole,
@@ -307,8 +304,8 @@ public:
virtual PassRefPtr<Range> ariaSelectedTextDOMRange() const { return 0; }
virtual AXObjectCache* axObjectCache() const { return 0; }
- AXID axObjectID() const { return m_id; }
- void setAXObjectID(AXID axObjectID) { m_id = axObjectID; }
+ unsigned axObjectID() const { return m_id; }
+ void setAXObjectID(unsigned axObjectID) { m_id = axObjectID; }
static AccessibilityObject* anchorElementForNode(Node*);
virtual Element* anchorElement() const { return 0; }
@@ -411,7 +408,6 @@ public:
virtual String doAXStringForRange(const PlainTextRange&) const { return String(); }
virtual IntRect doAXBoundsForRange(const PlainTextRange&) const { return IntRect(); }
- String listMarkerTextForNodeAndPosition(Node*, const VisiblePosition&) const;
unsigned doAXLineForIndex(unsigned);
@@ -440,15 +436,14 @@ public:
virtual void updateBackingStore() { }
protected:
- AXID m_id;
+ unsigned m_id;
AccessibilityChildrenVector m_children;
mutable bool m_haveChildren;
AccessibilityRole m_role;
virtual void clearChildren();
virtual bool isDetached() const { return true; }
- RenderListItem* renderListItemContainerForNode(Node* node) const;
-
+
#if PLATFORM(MAC)
RetainPtr<AccessibilityObjectWrapper> m_wrapper;
#elif PLATFORM(WIN) && !PLATFORM(WINCE)
diff --git a/WebCore/accessibility/AccessibilityRenderObject.cpp b/WebCore/accessibility/AccessibilityRenderObject.cpp
index b0b97fc..e0f9a91 100644
--- a/WebCore/accessibility/AccessibilityRenderObject.cpp
+++ b/WebCore/accessibility/AccessibilityRenderObject.cpp
@@ -35,6 +35,7 @@
#include "CharacterNames.h"
#include "EventNames.h"
#include "FloatRect.h"
+#include "FocusController.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "HTMLAreaElement.h"
@@ -53,6 +54,7 @@
#include "HitTestResult.h"
#include "LocalizedStrings.h"
#include "NodeList.h"
+#include "Page.h"
#include "RenderButton.h"
#include "RenderFieldset.h"
#include "RenderFileUploadControl.h"
@@ -1656,7 +1658,7 @@ AccessibilityObject* AccessibilityRenderObject::accessibilityParentForImageMap(H
// The HTMLImageElement's useMap() value includes the '#' symbol at the beginning,
// which has to be stripped off
- String useMapName = static_cast<HTMLImageElement*>(curr)->getAttribute(usemapAttr).string().substring(1).lower();
+ String useMapName = static_cast<HTMLImageElement*>(curr)->useMap().substring(1).lower();
if (useMapName == mapName)
return axObjectCache()->getOrCreate(obj);
}
@@ -2100,11 +2102,32 @@ AccessibilityObject* AccessibilityRenderObject::doAccessibilityHitTest(const Int
AccessibilityObject* AccessibilityRenderObject::focusedUIElement() const
{
+ // get the focused node in the page
Page* page = m_renderer->document()->page();
if (!page)
return 0;
-
- return AXObjectCache::focusedUIElementForPage(page);
+
+ Document* focusedDocument = page->focusController()->focusedOrMainFrame()->document();
+ Node* focusedNode = focusedDocument->focusedNode();
+ if (!focusedNode)
+ focusedNode = focusedDocument;
+
+ 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;
}
bool AccessibilityRenderObject::shouldFocusActiveDescendant() const
diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
index f346a81..6d3729b 100644
--- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
+++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
@@ -60,7 +60,7 @@ using namespace WebCore;
static AccessibilityObject* fallbackObject()
{
- static AXObjectCache* fallbackCache = new AXObjectCache(0);
+ static AXObjectCache* fallbackCache = new AXObjectCache();
static AccessibilityObject* object = 0;
if (!object) {
// FIXME: using fallbackCache->getOrCreate(ListBoxOptionRole) is a hack
diff --git a/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm b/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
index 75cefee..d1e0599 100644
--- a/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
+++ b/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
@@ -378,7 +378,7 @@ static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString,
// add misspelling attribute for the intersection of the marker and the range
int rStart = range.location + (marker.startOffset - offset);
- int rLength = min(marker.endOffset, endOffset) - marker.startOffset;
+ int rLength = MIN(marker.endOffset, endOffset) - marker.startOffset;
NSRange spellRange = NSMakeRange(rStart, rLength);
AXAttributeStringSetNumber(attrString, NSAccessibilityMisspelledTextAttribute, [NSNumber numberWithBool:YES], spellRange);
@@ -478,9 +478,6 @@ static NSString* nsStringForReplacedNode(Node* replacedNode)
- (NSAttributedString*)doAXAttributedStringForTextMarkerRange:(WebCoreTextMarkerRange*)textMarkerRange
{
- if (!m_object)
- return nil;
-
// extract the start and end VisiblePosition
VisiblePosition startVisiblePosition = visiblePositionForStartOfTextMarkerRange(textMarkerRange);
if (startVisiblePosition.isNull())
@@ -490,7 +487,6 @@ static NSString* nsStringForReplacedNode(Node* replacedNode)
if (endVisiblePosition.isNull())
return nil;
- VisiblePositionRange visiblePositionRange(startVisiblePosition, endVisiblePosition);
// iterate over the range to build the AX attributed string
NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] init];
TextIterator it(makeRange(startVisiblePosition, endVisiblePosition).get());
@@ -503,11 +499,6 @@ static NSString* nsStringForReplacedNode(Node* replacedNode)
// non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX)
if (it.length() != 0) {
- // Add the text of the list marker item if necessary.
- String listMarkerText = m_object->listMarkerTextForNodeAndPosition(node, VisiblePosition(it.range()->startPosition()));
- if (!listMarkerText.isEmpty())
- AXAttributedStringAppendText(attrString, node, offset, listMarkerText.characters(), listMarkerText.length());
-
AXAttributedStringAppendText(attrString, node, offset, it.characters(), it.length());
} else {
Node* replacedNode = node->childNode(offset);
@@ -1590,7 +1581,6 @@ static NSString* roleValueToNSString(AccessibilityRole value)
@"AXStyleTextMarkerRangeForTextMarker",
@"AXLengthForTextMarkerRange",
NSAccessibilityBoundsForRangeParameterizedAttribute,
- NSAccessibilityStringForRangeParameterizedAttribute,
nil];
}
@@ -1942,14 +1932,6 @@ static RenderObject* rendererForView(NSView* view)
NSRect rect = m_object->boundsForVisiblePositionRange(VisiblePositionRange(start, end));
return [NSValue valueWithRect:rect];
}
-
- if ([attribute isEqualToString:NSAccessibilityStringForRangeParameterizedAttribute]) {
- VisiblePosition start = m_object->visiblePositionForIndex(range.location);
- VisiblePosition end = m_object->visiblePositionForIndex(range.location+range.length);
- if (start.isNull() || end.isNull())
- return nil;
- return m_object->stringForVisiblePositionRange(VisiblePositionRange(start, end));
- }
if ([attribute isEqualToString: @"AXAttributedStringForTextMarkerRange"])
return [self doAXAttributedStringForTextMarkerRange:textMarkerRange];
diff --git a/WebCore/accessibility/win/AXObjectCacheWin.cpp b/WebCore/accessibility/win/AXObjectCacheWin.cpp
index f782ceb..e39d5a5 100644
--- a/WebCore/accessibility/win/AXObjectCacheWin.cpp
+++ b/WebCore/accessibility/win/AXObjectCacheWin.cpp
@@ -28,10 +28,6 @@
#include "AXObjectCache.h"
#include "AccessibilityObject.h"
-#include "Document.h"
-#include "Page.h"
-
-using namespace std;
namespace WebCore {
@@ -54,43 +50,8 @@ void AXObjectCache::postPlatformNotification(AccessibilityObject*, const String&
{
}
-AXID AXObjectCache::platformGenerateAXID() const
-{
- static AXID lastUsedID = 0;
-
- // Generate a new ID. Windows accessibility relies on a positive AXID,
- // ranging from 1 to LONG_MAX.
- AXID objID = lastUsedID;
- do {
- ++objID;
- objID %= std::numeric_limits<LONG>::max();
- } while (objID == 0 || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
-
- ASSERT(objID >= 1 && objID <= std::numeric_limits<LONG>::max());
-
- lastUsedID = objID;
-
- return objID;
-}
-
void AXObjectCache::handleFocusedUIElementChanged()
{
- Page* page = m_document->page();
- if (!page || !page->chrome()->platformWindow())
- return;
-
- AccessibilityObject* focusedObject = focusedUIElementForPage(page);
- if (!focusedObject)
- return;
-
- ASSERT(!focusedObject->accessibilityIsIgnored());
- ASSERT(focusedObject->axObjectID() >= 1 && focusedObject->axObjectID() <= numeric_limits<LONG>::max());
-
- // Windows will end up calling get_accChild() on the root accessible
- // object for the WebView, passing the child ID that we specify below. We
- // negate the AXID so we know that the caller is passing the ID of an
- // element, not the index of a child element.
- NotifyWinEvent(EVENT_OBJECT_FOCUS, page->chrome()->platformWindow(), OBJID_CLIENT, -static_cast<LONG>(focusedObject->axObjectID()));
}
} // namespace WebCore