| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 { | 124 { |
| 125 // Find the corresponding accessibility object for the HTMLAreaElement. This
should be | 125 // Find the corresponding accessibility object for the HTMLAreaElement. This
should be |
| 126 // in the list of children for its corresponding image. | 126 // in the list of children for its corresponding image. |
| 127 if (!areaElement) | 127 if (!areaElement) |
| 128 return 0; | 128 return 0; |
| 129 | 129 |
| 130 HTMLImageElement* imageElement = areaElement->imageElement(); | 130 HTMLImageElement* imageElement = areaElement->imageElement(); |
| 131 if (!imageElement) | 131 if (!imageElement) |
| 132 return 0; | 132 return 0; |
| 133 | 133 |
| 134 AccessibilityObject* axRenderImage = areaElement->document()->axObjectCache(
)->getOrCreate(imageElement); | 134 AccessibilityObject* axRenderImage = areaElement->document().axObjectCache()
->getOrCreate(imageElement); |
| 135 if (!axRenderImage) | 135 if (!axRenderImage) |
| 136 return 0; | 136 return 0; |
| 137 | 137 |
| 138 AccessibilityObject::AccessibilityChildrenVector imageChildren = axRenderIma
ge->children(); | 138 AccessibilityObject::AccessibilityChildrenVector imageChildren = axRenderIma
ge->children(); |
| 139 unsigned count = imageChildren.size(); | 139 unsigned count = imageChildren.size(); |
| 140 for (unsigned k = 0; k < count; ++k) { | 140 for (unsigned k = 0; k < count; ++k) { |
| 141 AccessibilityObject* child = imageChildren[k].get(); | 141 AccessibilityObject* child = imageChildren[k].get(); |
| 142 if (!child->isImageMapLink()) | 142 if (!child->isImageMapLink()) |
| 143 continue; | 143 continue; |
| 144 | 144 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 156 | 156 |
| 157 // get the focused node in the page | 157 // get the focused node in the page |
| 158 Document* focusedDocument = page->focusController().focusedOrMainFrame()->do
cument(); | 158 Document* focusedDocument = page->focusController().focusedOrMainFrame()->do
cument(); |
| 159 Node* focusedNode = focusedDocument->focusedElement(); | 159 Node* focusedNode = focusedDocument->focusedElement(); |
| 160 if (!focusedNode) | 160 if (!focusedNode) |
| 161 focusedNode = focusedDocument; | 161 focusedNode = focusedDocument; |
| 162 | 162 |
| 163 if (isHTMLAreaElement(focusedNode)) | 163 if (isHTMLAreaElement(focusedNode)) |
| 164 return focusedImageMapUIElement(toHTMLAreaElement(focusedNode)); | 164 return focusedImageMapUIElement(toHTMLAreaElement(focusedNode)); |
| 165 | 165 |
| 166 AccessibilityObject* obj = focusedNode->document()->axObjectCache()->getOrCr
eate(focusedNode); | 166 AccessibilityObject* obj = focusedNode->document().axObjectCache()->getOrCre
ate(focusedNode); |
| 167 if (!obj) | 167 if (!obj) |
| 168 return 0; | 168 return 0; |
| 169 | 169 |
| 170 if (obj->shouldFocusActiveDescendant()) { | 170 if (obj->shouldFocusActiveDescendant()) { |
| 171 if (AccessibilityObject* descendant = obj->activeDescendant()) | 171 if (AccessibilityObject* descendant = obj->activeDescendant()) |
| 172 obj = descendant; | 172 obj = descendant; |
| 173 } | 173 } |
| 174 | 174 |
| 175 // the HTML element, for example, is focusable but has an AX object that is
ignored | 175 // the HTML element, for example, is focusable but has an AX object that is
ignored |
| 176 if (obj->accessibilityIsIgnored()) | 176 if (obj->accessibilityIsIgnored()) |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 // because a render update may be in progress and creating an AX object can
re-trigger a layout | 657 // because a render update may be in progress and creating an AX object can
re-trigger a layout |
| 658 RefPtr<AccessibilityObject> object = get(renderer); | 658 RefPtr<AccessibilityObject> object = get(renderer); |
| 659 while (!object && renderer) { | 659 while (!object && renderer) { |
| 660 renderer = renderer->parent(); | 660 renderer = renderer->parent(); |
| 661 object = get(renderer); | 661 object = get(renderer); |
| 662 } | 662 } |
| 663 | 663 |
| 664 if (!renderer) | 664 if (!renderer) |
| 665 return; | 665 return; |
| 666 | 666 |
| 667 postNotification(object.get(), renderer->document(), notification, postToEle
ment, postType); | 667 postNotification(object.get(), &renderer->document(), notification, postToEl
ement, postType); |
| 668 } | 668 } |
| 669 | 669 |
| 670 void AXObjectCache::postNotification(Node* node, AXNotification notification, bo
ol postToElement, PostType postType) | 670 void AXObjectCache::postNotification(Node* node, AXNotification notification, bo
ol postToElement, PostType postType) |
| 671 { | 671 { |
| 672 if (!node) | 672 if (!node) |
| 673 return; | 673 return; |
| 674 | 674 |
| 675 stopCachingComputedObjectAttributes(); | 675 stopCachingComputedObjectAttributes(); |
| 676 | 676 |
| 677 // Get an accessibility object that already exists. One should not be create
d here | 677 // Get an accessibility object that already exists. One should not be create
d here |
| 678 // because a render update may be in progress and creating an AX object can
re-trigger a layout | 678 // because a render update may be in progress and creating an AX object can
re-trigger a layout |
| 679 RefPtr<AccessibilityObject> object = get(node); | 679 RefPtr<AccessibilityObject> object = get(node); |
| 680 while (!object && node) { | 680 while (!object && node) { |
| 681 node = node->parentNode(); | 681 node = node->parentNode(); |
| 682 object = get(node); | 682 object = get(node); |
| 683 } | 683 } |
| 684 | 684 |
| 685 if (!node) | 685 if (!node) |
| 686 return; | 686 return; |
| 687 | 687 |
| 688 postNotification(object.get(), node->document(), notification, postToElement
, postType); | 688 postNotification(object.get(), &node->document(), notification, postToElemen
t, postType); |
| 689 } | 689 } |
| 690 | 690 |
| 691 void AXObjectCache::postNotification(AccessibilityObject* object, Document* docu
ment, AXNotification notification, bool postToElement, PostType postType) | 691 void AXObjectCache::postNotification(AccessibilityObject* object, Document* docu
ment, AXNotification notification, bool postToElement, PostType postType) |
| 692 { | 692 { |
| 693 stopCachingComputedObjectAttributes(); | 693 stopCachingComputedObjectAttributes(); |
| 694 | 694 |
| 695 if (object && !postToElement) | 695 if (object && !postToElement) |
| 696 object = object->observableObject(); | 696 object = object->observableObject(); |
| 697 | 697 |
| 698 if (!object && document) | 698 if (!object && document) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 // FIXME: Accessability should make it clear these are DOM-compliant offsets
or store Position objects. | 825 // FIXME: Accessability should make it clear these are DOM-compliant offsets
or store Position objects. |
| 826 VisiblePosition visiblePos = VisiblePosition(createLegacyEditingPosition(tex
tMarkerData.node, textMarkerData.offset), textMarkerData.affinity); | 826 VisiblePosition visiblePos = VisiblePosition(createLegacyEditingPosition(tex
tMarkerData.node, textMarkerData.offset), textMarkerData.affinity); |
| 827 Position deepPos = visiblePos.deepEquivalent(); | 827 Position deepPos = visiblePos.deepEquivalent(); |
| 828 if (deepPos.isNull()) | 828 if (deepPos.isNull()) |
| 829 return VisiblePosition(); | 829 return VisiblePosition(); |
| 830 | 830 |
| 831 RenderObject* renderer = deepPos.deprecatedNode()->renderer(); | 831 RenderObject* renderer = deepPos.deprecatedNode()->renderer(); |
| 832 if (!renderer) | 832 if (!renderer) |
| 833 return VisiblePosition(); | 833 return VisiblePosition(); |
| 834 | 834 |
| 835 AXObjectCache* cache = renderer->document()->axObjectCache(); | 835 AXObjectCache* cache = renderer->document().axObjectCache(); |
| 836 if (!cache->isIDinUse(textMarkerData.axID)) | 836 if (!cache->isIDinUse(textMarkerData.axID)) |
| 837 return VisiblePosition(); | 837 return VisiblePosition(); |
| 838 | 838 |
| 839 if (deepPos.deprecatedNode() != textMarkerData.node || deepPos.deprecatedEdi
tingOffset() != textMarkerData.offset) | 839 if (deepPos.deprecatedNode() != textMarkerData.node || deepPos.deprecatedEdi
tingOffset() != textMarkerData.offset) |
| 840 return VisiblePosition(); | 840 return VisiblePosition(); |
| 841 | 841 |
| 842 return visiblePos; | 842 return visiblePos; |
| 843 } | 843 } |
| 844 | 844 |
| 845 void AXObjectCache::textMarkerDataForVisiblePosition(TextMarkerData& textMarkerD
ata, const VisiblePosition& visiblePos) | 845 void AXObjectCache::textMarkerDataForVisiblePosition(TextMarkerData& textMarkerD
ata, const VisiblePosition& visiblePos) |
| 846 { | 846 { |
| 847 // This memory must be bzero'd so instances of TextMarkerData can be tested
for byte-equivalence. | 847 // This memory must be bzero'd so instances of TextMarkerData can be tested
for byte-equivalence. |
| 848 // This also allows callers to check for failure by looking at textMarkerDat
a upon return. | 848 // This also allows callers to check for failure by looking at textMarkerDat
a upon return. |
| 849 memset(&textMarkerData, 0, sizeof(TextMarkerData)); | 849 memset(&textMarkerData, 0, sizeof(TextMarkerData)); |
| 850 | 850 |
| 851 if (visiblePos.isNull()) | 851 if (visiblePos.isNull()) |
| 852 return; | 852 return; |
| 853 | 853 |
| 854 Position deepPos = visiblePos.deepEquivalent(); | 854 Position deepPos = visiblePos.deepEquivalent(); |
| 855 Node* domNode = deepPos.deprecatedNode(); | 855 Node* domNode = deepPos.deprecatedNode(); |
| 856 ASSERT(domNode); | 856 ASSERT(domNode); |
| 857 if (!domNode) | 857 if (!domNode) |
| 858 return; | 858 return; |
| 859 | 859 |
| 860 if (domNode->hasTagName(inputTag) && toHTMLInputElement(domNode)->isPassword
Field()) | 860 if (domNode->hasTagName(inputTag) && toHTMLInputElement(domNode)->isPassword
Field()) |
| 861 return; | 861 return; |
| 862 | 862 |
| 863 // find or create an accessibility object for this node | 863 // find or create an accessibility object for this node |
| 864 AXObjectCache* cache = domNode->document()->axObjectCache(); | 864 AXObjectCache* cache = domNode->document().axObjectCache(); |
| 865 RefPtr<AccessibilityObject> obj = cache->getOrCreate(domNode); | 865 RefPtr<AccessibilityObject> obj = cache->getOrCreate(domNode); |
| 866 | 866 |
| 867 textMarkerData.axID = obj.get()->axObjectID(); | 867 textMarkerData.axID = obj.get()->axObjectID(); |
| 868 textMarkerData.node = domNode; | 868 textMarkerData.node = domNode; |
| 869 textMarkerData.offset = deepPos.deprecatedEditingOffset(); | 869 textMarkerData.offset = deepPos.deprecatedEditingOffset(); |
| 870 textMarkerData.affinity = visiblePos.affinity(); | 870 textMarkerData.affinity = visiblePos.affinity(); |
| 871 | 871 |
| 872 cache->setNodeInUse(domNode); | 872 cache->setNodeInUse(domNode); |
| 873 } | 873 } |
| 874 | 874 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 } | 942 } |
| 943 | 943 |
| 944 client.postAccessibilityNotification(obj, notification); | 944 client.postAccessibilityNotification(obj, notification); |
| 945 } | 945 } |
| 946 | 946 |
| 947 void AXObjectCache::handleFocusedUIElementChanged(Node*, Node* newFocusedNode) | 947 void AXObjectCache::handleFocusedUIElementChanged(Node*, Node* newFocusedNode) |
| 948 { | 948 { |
| 949 if (!newFocusedNode) | 949 if (!newFocusedNode) |
| 950 return; | 950 return; |
| 951 | 951 |
| 952 Page* page = newFocusedNode->document()->page(); | 952 Page* page = newFocusedNode->document().page(); |
| 953 if (!page) | 953 if (!page) |
| 954 return; | 954 return; |
| 955 | 955 |
| 956 AccessibilityObject* focusedObject = focusedUIElementForPage(page); | 956 AccessibilityObject* focusedObject = focusedUIElementForPage(page); |
| 957 if (!focusedObject) | 957 if (!focusedObject) |
| 958 return; | 958 return; |
| 959 | 959 |
| 960 postPlatformNotification(focusedObject, AXFocusedUIElementChanged); | 960 postPlatformNotification(focusedObject, AXFocusedUIElementChanged); |
| 961 } | 961 } |
| 962 | 962 |
| 963 void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode) | 963 void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode) |
| 964 { | 964 { |
| 965 // The anchor node may not be accessible. Post the notification for the | 965 // The anchor node may not be accessible. Post the notification for the |
| 966 // first accessible object. | 966 // first accessible object. |
| 967 postPlatformNotification(AccessibilityObject::firstAccessibleObjectFromNode(
anchorNode), AXScrolledToAnchor); | 967 postPlatformNotification(AccessibilityObject::firstAccessibleObjectFromNode(
anchorNode), AXScrolledToAnchor); |
| 968 } | 968 } |
| 969 | 969 |
| 970 } // namespace WebCore | 970 } // namespace WebCore |
| 971 | 971 |
| 972 #endif // HAVE(ACCESSIBILITY) | 972 #endif // HAVE(ACCESSIBILITY) |
| OLD | NEW |