Changeset 47311 in webkit
- Timestamp:
- Aug 14, 2009 11:14:50 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r47310 r47311 1 2009-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 1 70 2009-08-14 Jiahua Huang <jhuangjiahua@gmail.com> 2 71 -
trunk/WebCore/accessibility/AXObjectCache.cpp
r47140 r47311 44 44 #include "AccessibilityTableHeaderContainer.h" 45 45 #include "AccessibilityTableRow.h" 46 #include "FocusController.h" 47 #include "Frame.h" 48 #include "HTMLNames.h" 46 49 #include "InputElement.h" 47 #include " HTMLNames.h"50 #include "Page.h" 48 51 #include "RenderObject.h" 49 52 #include "RenderView.h" … … 58 61 bool AXObjectCache::gAccessibilityEnhancedUserInterfaceEnabled = false; 59 62 60 AXObjectCache::AXObjectCache( )63 AXObjectCache::AXObjectCache(const Document* document) 61 64 : m_notificationPostTimer(this, &AXObjectCache::notificationPostTimerFired) 65 , m_document(document) 62 66 { 63 67 } … … 72 76 removeAXID(obj); 73 77 } 78 } 79 80 AccessibilityObject* 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; 74 104 } 75 105 … … 214 244 } 215 245 246 #if !PLATFORM(WIN) 247 AXID 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 216 263 AXID AXObjectCache::getAXID(AccessibilityObject* obj) 217 264 { … … 222 269 return objID; 223 270 } 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 231 274 m_idsInUse.add(objID); 232 lastUsedID = objID;233 275 obj->setAXObjectID(objID); 234 276 -
trunk/WebCore/accessibility/AXObjectCache.h
r47140 r47311 43 43 namespace WebCore { 44 44 45 class Document; 46 class Node; 47 class Page; 45 48 class RenderObject; 46 49 class String; 47 50 class VisiblePosition; 48 class AccessibilityObject;49 class Node;50 51 typedef unsigned AXID;52 51 53 52 struct TextMarkerData { … … 60 59 class AXObjectCache { 61 60 public: 62 AXObjectCache( );61 AXObjectCache(const Document*); 63 62 ~AXObjectCache(); 64 63 64 static AccessibilityObject* focusedUIElementForPage(const Page*); 65 65 66 // to be used with render objects 66 67 AccessibilityObject* getOrCreate(RenderObject*); … … 95 96 void removeAXID(AccessibilityObject*); 96 97 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(); } 97 100 98 101 // Text marker utilities. 99 102 static void textMarkerDataForVisiblePosition(TextMarkerData&, const VisiblePosition&); 100 103 static VisiblePosition visiblePositionForTextMarkerData(TextMarkerData&); 101 104 102 105 private: 103 106 HashMap<AXID, RefPtr<AccessibilityObject> > m_objects; … … 114 117 AXID getAXID(AccessibilityObject*); 115 118 bool nodeIsAriaType(Node* node, String role); 119 120 const Document* m_document; 116 121 }; 117 122 -
trunk/WebCore/accessibility/AccessibilityObject.h
r47140 r47311 91 91 class String; 92 92 class Widget; 93 94 typedef unsigned AXID; 93 95 94 96 enum AccessibilityRole { … … 306 308 307 309 virtual AXObjectCache* axObjectCache() const { return 0; } 308 unsignedaxObjectID() const { return m_id; }309 void setAXObjectID( unsignedaxObjectID) { m_id = axObjectID; }310 AXID axObjectID() const { return m_id; } 311 void setAXObjectID(AXID axObjectID) { m_id = axObjectID; } 310 312 311 313 static AccessibilityObject* anchorElementForNode(Node*); … … 439 441 440 442 protected: 441 unsignedm_id;443 AXID m_id; 442 444 AccessibilityChildrenVector m_children; 443 445 mutable bool m_haveChildren; -
trunk/WebCore/accessibility/AccessibilityRenderObject.cpp
r46978 r47311 36 36 #include "EventNames.h" 37 37 #include "FloatRect.h" 38 #include "FocusController.h"39 38 #include "Frame.h" 40 39 #include "FrameLoader.h" … … 55 54 #include "LocalizedStrings.h" 56 55 #include "NodeList.h" 57 #include "Page.h"58 56 #include "RenderButton.h" 59 57 #include "RenderFieldset.h" … … 2103 2101 AccessibilityObject* AccessibilityRenderObject::focusedUIElement() const 2104 2102 { 2105 // get the focused node in the page2106 2103 Page* page = m_renderer->document()->page(); 2107 2104 if (!page) 2108 2105 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); 2131 2108 } 2132 2109 -
trunk/WebCore/accessibility/win/AXObjectCacheWin.cpp
r44266 r47311 29 29 30 30 #include "AccessibilityObject.h" 31 #include "Document.h" 32 #include "Page.h" 33 34 using namespace std; 31 35 32 36 namespace WebCore { … … 51 55 } 52 56 57 AXID 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 53 76 void AXObjectCache::handleFocusedUIElementChanged() 54 77 { 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())); 55 94 } 56 95 -
trunk/WebCore/dom/Document.cpp
r47078 r47311 1468 1468 1469 1469 // this is the top-level document, so install a new cache 1470 m_axObjectCache = new AXObjectCache ;1470 m_axObjectCache = new AXObjectCache(this); 1471 1471 return m_axObjectCache; 1472 1472 } … … 2623 2623 } 2624 2624 2625 #if PLATFORM(MAC) && !PLATFORM(CHROMIUM)2625 #if (PLATFORM(MAC) || PLATFORM(WIN)) && !PLATFORM(CHROMIUM) 2626 2626 if (!focusChangeBlocked && m_focusedNode && AXObjectCache::accessibilityEnabled()) 2627 2627 axObjectCache()->handleFocusedUIElementChanged(); -
trunk/WebKit/win/AccessibleBase.cpp
r43027 r47311 593 593 if (vChild.lVal == CHILDID_SELF) 594 594 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 { 596 604 size_t childIndex = static_cast<size_t>(vChild.lVal - 1); 597 605 -
trunk/WebKit/win/ChangeLog
r47161 r47311 1 2009-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 1 14 2009-08-12 Brian Weinstein <bweinstein@apple.com> 2 15
Note: See TracChangeset
for help on using the changeset viewer.