AXObjectCacheWin.cpp [plain text]
#include "config.h"
#include "AXObjectCache.h"
#include "AccessibilityObject.h"
#include "Chrome.h"
#include "ChromeClient.h"
#include "Document.h"
#include "Page.h"
#include "RenderObject.h"
#define IA2_EVENT_DOCUMENT_LOAD_COMPLETE 261
using namespace std;
namespace WebCore {
void AXObjectCache::detachWrapper(AccessibilityObject* obj, AccessibilityDetachmentType)
{
if (AccessibilityObjectWrapper* wrapper = obj->wrapper())
wrapper->detach();
}
void AXObjectCache::attachWrapper(AccessibilityObject*)
{
}
void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode)
{
postPlatformNotification(AccessibilityObject::firstAccessibleObjectFromNode(anchorNode), AXScrolledToAnchor);
}
void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotification notification)
{
if (!obj)
return;
Document* document = obj->document();
if (!document)
return;
Page* page = document->page();
if (!page || !page->chrome().platformPageClient())
return;
DWORD msaaEvent;
switch (notification) {
case AXCheckedStateChanged:
msaaEvent = EVENT_OBJECT_STATECHANGE;
break;
case AXFocusedUIElementChanged:
case AXActiveDescendantChanged:
msaaEvent = EVENT_OBJECT_FOCUS;
break;
case AXScrolledToAnchor:
msaaEvent = EVENT_SYSTEM_SCROLLINGSTART;
break;
case AXLayoutComplete:
msaaEvent = EVENT_OBJECT_REORDER;
break;
case AXLoadComplete:
msaaEvent = IA2_EVENT_DOCUMENT_LOAD_COMPLETE;
break;
case AXValueChanged:
case AXMenuListValueChanged:
msaaEvent = EVENT_OBJECT_VALUECHANGE;
break;
case AXMenuListItemSelected:
msaaEvent = EVENT_OBJECT_SELECTION;
break;
default:
return;
}
ASSERT(obj->axObjectID() >= 1);
ASSERT(obj->axObjectID() <= numeric_limits<LONG>::max());
NotifyWinEvent(msaaEvent, page->chrome().platformPageClient(), OBJID_CLIENT, -static_cast<LONG>(obj->axObjectID()));
}
void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&)
{
}
void AXObjectCache::frameLoadingEventPlatformNotification(AccessibilityObject* obj, AXLoadingEvent notification)
{
if (!obj)
return;
Document* document = obj->document();
if (!document)
return;
Page* page = document->page();
if (!page)
return;
if (notification == AXLoadingStarted)
page->chrome().client().AXStartFrameLoad();
else if (notification == AXLoadingFinished)
page->chrome().client().AXFinishFrameLoad();
}
AXID AXObjectCache::platformGenerateAXID() const
{
static AXID lastUsedID = 0;
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::platformHandleFocusedUIElementChanged(Node*, Node* newFocusedNode)
{
if (!newFocusedNode)
return;
Page* page = newFocusedNode->document().page();
if (!page || !page->chrome().platformPageClient())
return;
AccessibilityObject* focusedObject = focusedUIElementForPage(page);
if (!focusedObject)
return;
ASSERT(!focusedObject->accessibilityIsIgnored());
postPlatformNotification(focusedObject, AXFocusedUIElementChanged);
}
}