Changeset 47311 in webkit


Ignore:
Timestamp:
Aug 14, 2009 11:14:50 PM (15 years ago)
Author:
jhoneycutt@apple.com
Message:

WebCore:

2009-08-13 Jon Honeycutt <jhoneycutt@apple.com>

Part of <rdar://problem/6218721> No MSAA focus events fired for Webkit
nightly (20866)

https://bugs.webkit.org/show_bug.cgi?id=20866

Reviewed by Oliver Hunt.

  • accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::AXObjectCache): Changed to take a pointer to its owner document. This is used by AXObjectCache::handleFocusedUIElementChanged(). (WebCore::AXObjectCache::focusedUIElementForPage): Code moved from AccessibilityRenderObject::focusedUIElement(). Modified to be a static function and to take a pointer to a Page. (WebCore::AXObjectCache::platformGenerateAXID): Moved the code to generate the next AXID from getAXID() to here. Added a #if to make this non-WIN only, because Windows has its own implementation. (WebCore::AXObjectCache::getAXID): Ensure that we generate a positive AXID, ranging from 1 to LONG_MAX.
  • accessibility/AXObjectCache.h: Add a declaration for Document and Page. Removed the declaration of AccessibilityObject, because we include the header. Reordered the declaration of Node alphabetically. Moved the typedef for AXID to AccessibilityObject. Removed some trailing whitespace. Added a member variable to hold a pointer to the owner Document. (WebCore::AXObjectCache::AXObjectCache): Changed to take a pointer to its owner Document. (WebCore::AXObjectCache::focusedUIElementForPage): Added; code moved from AccessiblityRenderObject::focusedUIElement(). Returns the focused element with respect to accessibility. (WebCore::AXObjectCache::platformGenerateAXID): Declare a function to generate an AXID. (WebCore::AXObjectCache::objectFromAXID): Return the AccessibilityObject with the given AXID.
  • accessibility/AccessibilityObject.h: Moved the typedef for AXID from AXObjectCache to here. Made the m_id member use the typedef. (WebCore::AccessibilityObject::axObjectID): Changed the return type to use the typedef. (WebCore::AccessibilityObject::setAXObjectID): Changed the argument type to use the typedef.
  • accessibility/AccessibilityRenderObject.cpp: Removed some unneeded #includes. (WebCore::AccessibilityRenderObject::focusedUIElement): Moved the code to AXObjectCache::focusedUIElementForPage(), which we now call.
  • accessibility/win/AXObjectCacheWin.cpp: (WebCore::AXObjectCache::platformGenerateAXID): Ensure that we generate an AXID that is in the range 1 to LONG_MAX. (WebCore::AXObjectCache::handleFocusedUIElementChanged): If the Document has no Page, return. If the Page has not focused element (respecting accessibility), return. Assert that the accessibility of the focused element is not ignored, and that the object's AXID will be negative and fit into a LONG when negated. Broadcast a focus event for the object.
  • dom/Document.cpp: (WebCore::Document::axObjectCache): Pass this when creating the AXObjectCache. (WebCore::Document::setFocusedNode): Call AXObjectCache::handleFocusedUIElementChanged() on Windows.

WebKit/win:

2009-08-13 Jon Honeycutt <jhoneycutt@apple.com>

Part of <rdar://problem/6218721> No MSAA focus events fired for Webkit
nightly (20866)

https://bugs.webkit.org/show_bug.cgi?id=20866

Reviewed by Oliver Hunt.

  • AccessibleBase.cpp: (AccessibleBase::getAccessibilityObjectForChild): If the child ID is negative, negate it and treat it as an AXID.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r47310 r47311  
     12009-08-13  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Part of <rdar://problem/6218721> No MSAA focus events fired for Webkit
     4        nightly (20866)
     5
     6        https://bugs.webkit.org/show_bug.cgi?id=20866
     7
     8        Reviewed by Oliver Hunt.
     9
     10        * accessibility/AXObjectCache.cpp:
     11        (WebCore::AXObjectCache::AXObjectCache):
     12        Changed to take a pointer to its owner document. This is used by
     13        AXObjectCache::handleFocusedUIElementChanged().
     14        (WebCore::AXObjectCache::focusedUIElementForPage):
     15        Code moved from AccessibilityRenderObject::focusedUIElement(). Modified
     16        to be a static function and to take a pointer to a Page.
     17        (WebCore::AXObjectCache::platformGenerateAXID):
     18        Moved the code to generate the next AXID from getAXID() to here. Added
     19        a #if to make this non-WIN only, because Windows has its own
     20        implementation.
     21        (WebCore::AXObjectCache::getAXID):
     22        Ensure that we generate a positive AXID, ranging from 1 to LONG_MAX.
     23
     24        * accessibility/AXObjectCache.h:
     25        Add a declaration for Document and Page. Removed the declaration of
     26        AccessibilityObject, because we include the header. Reordered the
     27        declaration of Node alphabetically. Moved the typedef for AXID to
     28        AccessibilityObject. Removed some trailing whitespace. Added a member
     29        variable to hold a pointer to the owner Document.
     30        (WebCore::AXObjectCache::AXObjectCache):
     31        Changed to take a pointer to its owner Document.
     32        (WebCore::AXObjectCache::focusedUIElementForPage):
     33        Added; code moved from AccessiblityRenderObject::focusedUIElement().
     34        Returns the focused element with respect to accessibility.
     35        (WebCore::AXObjectCache::platformGenerateAXID):
     36        Declare a function to generate an AXID.
     37        (WebCore::AXObjectCache::objectFromAXID):
     38        Return the AccessibilityObject with the given AXID.
     39
     40        * accessibility/AccessibilityObject.h:
     41        Moved the typedef for AXID from AXObjectCache to here. Made the m_id
     42        member use the typedef.
     43        (WebCore::AccessibilityObject::axObjectID):
     44        Changed the return type to use the typedef.
     45        (WebCore::AccessibilityObject::setAXObjectID):
     46        Changed the argument type to use the typedef.
     47
     48        * accessibility/AccessibilityRenderObject.cpp:
     49        Removed some unneeded #includes.
     50        (WebCore::AccessibilityRenderObject::focusedUIElement):
     51        Moved the code to AXObjectCache::focusedUIElementForPage(), which we now
     52        call.
     53
     54        * accessibility/win/AXObjectCacheWin.cpp:
     55        (WebCore::AXObjectCache::platformGenerateAXID):
     56        Ensure that we generate an AXID that is in the range 1 to LONG_MAX.
     57        (WebCore::AXObjectCache::handleFocusedUIElementChanged):
     58        If the Document has no Page, return. If the Page has not focused
     59        element (respecting accessibility), return. Assert that the
     60        accessibility of the focused element is not ignored, and that the
     61        object's AXID will be negative and fit into a LONG when negated.
     62        Broadcast a focus event for the object.
     63
     64        * dom/Document.cpp:
     65        (WebCore::Document::axObjectCache):
     66        Pass this when creating the AXObjectCache.
     67        (WebCore::Document::setFocusedNode):
     68        Call AXObjectCache::handleFocusedUIElementChanged() on Windows.
     69
    1702009-08-14  Jiahua Huang  <jhuangjiahua@gmail.com>
    271
  • trunk/WebCore/accessibility/AXObjectCache.cpp

    r47140 r47311  
    4444#include "AccessibilityTableHeaderContainer.h"
    4545#include "AccessibilityTableRow.h"
     46#include "FocusController.h"
     47#include "Frame.h"
     48#include "HTMLNames.h"
    4649#include "InputElement.h"
    47 #include "HTMLNames.h"
     50#include "Page.h"
    4851#include "RenderObject.h"
    4952#include "RenderView.h"
     
    5861bool AXObjectCache::gAccessibilityEnhancedUserInterfaceEnabled = false;
    5962
    60 AXObjectCache::AXObjectCache()
     63AXObjectCache::AXObjectCache(const Document* document)
    6164    : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired)
     65    , m_document(document)
    6266{
    6367}
     
    7276        removeAXID(obj);
    7377    }
     78}
     79
     80AccessibilityObject* AXObjectCache::focusedUIElementForPage(const Page* page)
     81{
     82    // get the focused node in the page
     83    Document* focusedDocument = page->focusController()->focusedOrMainFrame()->document();
     84    Node* focusedNode = focusedDocument->focusedNode();
     85    if (!focusedNode)
     86        focusedNode = focusedDocument;
     87
     88    RenderObject* focusedNodeRenderer = focusedNode->renderer();
     89    if (!focusedNodeRenderer)
     90        return 0;
     91
     92    AccessibilityObject* obj = focusedNodeRenderer->document()->axObjectCache()->getOrCreate(focusedNodeRenderer);
     93
     94    if (obj->shouldFocusActiveDescendant()) {
     95        if (AccessibilityObject* descendant = obj->activeDescendant())
     96            obj = descendant;
     97    }
     98
     99    // the HTML element, for example, is focusable but has an AX object that is ignored
     100    if (obj->accessibilityIsIgnored())
     101        obj = obj->parentObjectUnignored();
     102
     103    return obj;
    74104}
    75105
     
    214244}
    215245
     246#if !PLATFORM(WIN)
     247AXID AXObjectCache::platformGenerateAXID() const
     248{
     249    static AXID lastUsedID = 0;
     250
     251    // Generate a new ID.
     252    AXID objID = lastUsedID;
     253    do {
     254        ++objID;
     255    } while (objID == 0 || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
     256
     257    lastUsedID = objID;
     258
     259    return objID;
     260}
     261#endif
     262
    216263AXID AXObjectCache::getAXID(AccessibilityObject* obj)
    217264{
     
    222269        return objID;
    223270    }
    224    
    225     // generate a new ID
    226     static AXID lastUsedID = 0;
    227     objID = lastUsedID;
    228     do
    229         ++objID;
    230     while (objID == 0 || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
     271
     272    objID = platformGenerateAXID();
     273
    231274    m_idsInUse.add(objID);
    232     lastUsedID = objID;
    233275    obj->setAXObjectID(objID);
    234276   
  • trunk/WebCore/accessibility/AXObjectCache.h

    r47140 r47311  
    4343namespace WebCore {
    4444
     45    class Document;
     46    class Node;
     47    class Page;
    4548    class RenderObject;
    4649    class String;
    4750    class VisiblePosition;
    48     class AccessibilityObject;
    49     class Node;
    50    
    51     typedef unsigned AXID;
    5251
    5352    struct TextMarkerData  {
     
    6059    class AXObjectCache {
    6160    public:
    62         AXObjectCache();
     61        AXObjectCache(const Document*);
    6362        ~AXObjectCache();
    64        
     63
     64        static AccessibilityObject* focusedUIElementForPage(const Page*);
     65
    6566        // to be used with render objects
    6667        AccessibilityObject* getOrCreate(RenderObject*);
     
    9596        void removeAXID(AccessibilityObject*);
    9697        bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); }
     98        AXID platformGenerateAXID() const;
     99        AccessibilityObject* objectFromAXID(AXID id) const { return m_objects.get(id).get(); }
    97100
    98101        // Text marker utilities.
    99102        static void textMarkerDataForVisiblePosition(TextMarkerData&, const VisiblePosition&);
    100103        static VisiblePosition visiblePositionForTextMarkerData(TextMarkerData&);
    101                
     104
    102105    private:
    103106        HashMap<AXID, RefPtr<AccessibilityObject> > m_objects;
     
    114117        AXID getAXID(AccessibilityObject*);
    115118        bool nodeIsAriaType(Node* node, String role);
     119
     120        const Document* m_document;
    116121    };
    117122
  • trunk/WebCore/accessibility/AccessibilityObject.h

    r47140 r47311  
    9191class String;
    9292class Widget;
     93
     94typedef unsigned AXID;
    9395
    9496enum AccessibilityRole {
     
    306308
    307309    virtual AXObjectCache* axObjectCache() const { return 0; }
    308     unsigned axObjectID() const { return m_id; }
    309     void setAXObjectID(unsigned axObjectID) { m_id = axObjectID; }
     310    AXID axObjectID() const { return m_id; }
     311    void setAXObjectID(AXID axObjectID) { m_id = axObjectID; }
    310312   
    311313    static AccessibilityObject* anchorElementForNode(Node*);
     
    439441   
    440442protected:
    441     unsigned m_id;
     443    AXID m_id;
    442444    AccessibilityChildrenVector m_children;
    443445    mutable bool m_haveChildren;
  • trunk/WebCore/accessibility/AccessibilityRenderObject.cpp

    r46978 r47311  
    3636#include "EventNames.h"
    3737#include "FloatRect.h"
    38 #include "FocusController.h"
    3938#include "Frame.h"
    4039#include "FrameLoader.h"
     
    5554#include "LocalizedStrings.h"
    5655#include "NodeList.h"
    57 #include "Page.h"
    5856#include "RenderButton.h"
    5957#include "RenderFieldset.h"
     
    21032101AccessibilityObject* AccessibilityRenderObject::focusedUIElement() const
    21042102{
    2105     // get the focused node in the page
    21062103    Page* page = m_renderer->document()->page();
    21072104    if (!page)
    21082105        return 0;
    2109    
    2110     Document* focusedDocument = page->focusController()->focusedOrMainFrame()->document();
    2111     Node* focusedNode = focusedDocument->focusedNode();
    2112     if (!focusedNode)
    2113         focusedNode = focusedDocument;
    2114    
    2115     RenderObject* focusedNodeRenderer = focusedNode->renderer();
    2116     if (!focusedNodeRenderer)
    2117         return 0;
    2118    
    2119     AccessibilityObject* obj = focusedNodeRenderer->document()->axObjectCache()->getOrCreate(focusedNodeRenderer);
    2120    
    2121     if (obj->shouldFocusActiveDescendant()) {
    2122         if (AccessibilityObject* descendant = obj->activeDescendant())
    2123             obj = descendant;
    2124     }
    2125    
    2126     // the HTML element, for example, is focusable but has an AX object that is ignored
    2127     if (obj->accessibilityIsIgnored())
    2128         obj = obj->parentObjectUnignored();
    2129    
    2130     return obj;
     2106
     2107    return AXObjectCache::focusedUIElementForPage(page);
    21312108}
    21322109
  • trunk/WebCore/accessibility/win/AXObjectCacheWin.cpp

    r44266 r47311  
    2929
    3030#include "AccessibilityObject.h"
     31#include "Document.h"
     32#include "Page.h"
     33
     34using namespace std;
    3135
    3236namespace WebCore {
     
    5155}
    5256
     57AXID AXObjectCache::platformGenerateAXID() const
     58{
     59    static AXID lastUsedID = 0;
     60
     61    // Generate a new ID. Windows accessibility relies on a positive AXID,
     62    // ranging from 1 to LONG_MAX.
     63    AXID objID = lastUsedID;
     64    do {
     65        ++objID;
     66        objID %= std::numeric_limits<LONG>::max();
     67    } while (objID == 0 || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
     68
     69    ASSERT(objID >= 1 && objID <= std::numeric_limits<LONG>::max());
     70
     71    lastUsedID = objID;
     72
     73    return objID;
     74}
     75
    5376void AXObjectCache::handleFocusedUIElementChanged()
    5477{
     78    Page* page = m_document->page();
     79    if (!page || !page->chrome()->platformWindow())
     80        return;
     81
     82    AccessibilityObject* focusedObject = focusedUIElementForPage(page);
     83    if (!focusedObject)
     84        return;
     85
     86    ASSERT(!focusedObject->accessibilityIsIgnored());
     87    ASSERT(focusedObject->axObjectID() >= 1 && focusedObject->axObjectID() <= numeric_limits<LONG>::max());
     88
     89    // Windows will end up calling get_accChild() on the root accessible
     90    // object for the WebView, passing the child ID that we specify below. We
     91    // negate the AXID so we know that the caller is passing the ID of an
     92    // element, not the index of a child element.
     93    NotifyWinEvent(EVENT_OBJECT_FOCUS, page->chrome()->platformWindow(), OBJID_CLIENT, -static_cast<LONG>(focusedObject->axObjectID()));
    5594}
    5695
  • trunk/WebCore/dom/Document.cpp

    r47078 r47311  
    14681468   
    14691469    // this is the top-level document, so install a new cache
    1470     m_axObjectCache = new AXObjectCache;
     1470    m_axObjectCache = new AXObjectCache(this);
    14711471    return m_axObjectCache;
    14721472}
     
    26232623    }
    26242624
    2625 #if PLATFORM(MAC) && !PLATFORM(CHROMIUM)
     2625#if (PLATFORM(MAC) || PLATFORM(WIN)) && !PLATFORM(CHROMIUM)
    26262626    if (!focusChangeBlocked && m_focusedNode && AXObjectCache::accessibilityEnabled())
    26272627        axObjectCache()->handleFocusedUIElementChanged();
  • trunk/WebKit/win/AccessibleBase.cpp

    r43027 r47311  
    593593    if (vChild.lVal == CHILDID_SELF)
    594594        childObj = m_object;
    595     else {
     595    else if (vChild.lVal < 0) {
     596        // When broadcasting MSAA events, we negate the AXID and pass it as the
     597        // child ID.
     598        Document* document = m_object->document();
     599        if (!document)
     600            return E_FAIL;
     601
     602        childObj = document->axObjectCache()->objectFromAXID(-vChild.lVal);
     603    } else {
    596604        size_t childIndex = static_cast<size_t>(vChild.lVal - 1);
    597605
  • trunk/WebKit/win/ChangeLog

    r47161 r47311  
     12009-08-13  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Part of <rdar://problem/6218721> No MSAA focus events fired for Webkit
     4        nightly (20866)
     5
     6        https://bugs.webkit.org/show_bug.cgi?id=20866
     7
     8        Reviewed by Oliver Hunt.
     9
     10        * AccessibleBase.cpp:
     11        (AccessibleBase::getAccessibilityObjectForChild):
     12        If the child ID is negative, negate it and treat it as an AXID.
     13
    1142009-08-12  Brian Weinstein  <bweinstein@apple.com>
    215
Note: See TracChangeset for help on using the changeset viewer.