Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014, Google Inc. All rights reserved. | 2 * Copyright (C) 2014, Google 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 textChanged(getOrCreate(layoutObject)); | 640 textChanged(getOrCreate(layoutObject)); |
| 641 } | 641 } |
| 642 | 642 |
| 643 void AXObjectCacheImpl::textChanged(AXObject* obj) | 643 void AXObjectCacheImpl::textChanged(AXObject* obj) |
| 644 { | 644 { |
| 645 if (!obj) | 645 if (!obj) |
| 646 return; | 646 return; |
| 647 | 647 |
| 648 bool parentAlreadyExists = obj->parentObjectIfExists(); | 648 bool parentAlreadyExists = obj->parentObjectIfExists(); |
| 649 obj->textChanged(); | 649 obj->textChanged(); |
| 650 postNotification(obj, AXObjectCacheImpl::AXTextChanged, true); | 650 postNotification(obj, AXObjectCacheImpl::AXTextChanged); |
| 651 if (parentAlreadyExists) | 651 if (parentAlreadyExists) |
| 652 obj->notifyIfIgnoredValueChanged(); | 652 obj->notifyIfIgnoredValueChanged(); |
| 653 } | 653 } |
| 654 | 654 |
| 655 void AXObjectCacheImpl::updateCacheAfterNodeIsAttached(Node* node) | 655 void AXObjectCacheImpl::updateCacheAfterNodeIsAttached(Node* node) |
| 656 { | 656 { |
| 657 // Calling get() will update the AX object if we had an AXNodeObject but now we need | 657 // Calling get() will update the AX object if we had an AXNodeObject but now we need |
| 658 // an AXLayoutObject, because it was reparented to a location outside of a c anvas. | 658 // an AXLayoutObject, because it was reparented to a location outside of a c anvas. |
| 659 get(node); | 659 get(node); |
| 660 } | 660 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 AXNotification notification = m_notificationsToPost[i].second; | 706 AXNotification notification = m_notificationsToPost[i].second; |
| 707 postPlatformNotification(obj, notification); | 707 postPlatformNotification(obj, notification); |
| 708 | 708 |
| 709 if (notification == AXChildrenChanged && obj->parentObjectIfExists() && obj->lastKnownIsIgnoredValue() != obj->accessibilityIsIgnored()) | 709 if (notification == AXChildrenChanged && obj->parentObjectIfExists() && obj->lastKnownIsIgnoredValue() != obj->accessibilityIsIgnored()) |
| 710 childrenChanged(obj->parentObject()); | 710 childrenChanged(obj->parentObject()); |
| 711 } | 711 } |
| 712 | 712 |
| 713 m_notificationsToPost.clear(); | 713 m_notificationsToPost.clear(); |
| 714 } | 714 } |
| 715 | 715 |
| 716 void AXObjectCacheImpl::postNotification(LayoutObject* layoutObject, AXNotificat ion notification, bool postToElement) | 716 void AXObjectCacheImpl::postNotification(LayoutObject* layoutObject, AXNotificat ion notification) |
| 717 { | 717 { |
| 718 if (!layoutObject) | 718 if (!layoutObject) |
| 719 return; | 719 return; |
| 720 | 720 |
| 721 m_modificationCount++; | 721 m_modificationCount++; |
| 722 postNotification(get(layoutObject), notification, postToElement); | 722 postNotification(get(layoutObject), notification); |
| 723 } | 723 } |
| 724 | 724 |
| 725 void AXObjectCacheImpl::postNotification(Node* node, AXNotification notification , bool postToElement) | 725 void AXObjectCacheImpl::postNotification(Node* node, AXNotification notification ) |
| 726 { | 726 { |
| 727 if (!node) | 727 if (!node) |
| 728 return; | 728 return; |
| 729 | 729 |
| 730 m_modificationCount++; | 730 m_modificationCount++; |
| 731 postNotification(get(node), notification, postToElement); | 731 postNotification(get(node), notification); |
| 732 } | 732 } |
| 733 | 733 |
| 734 void AXObjectCacheImpl::postNotification(AXObject* object, AXNotification notifi cation, bool postToElement) | 734 void AXObjectCacheImpl::postNotification(AXObject* object, AXNotification notifi cation) |
| 735 { | 735 { |
| 736 m_modificationCount++; | 736 m_modificationCount++; |
| 737 | |
| 738 if (object && !postToElement) | |
| 739 object = object->observableObject(); | |
| 740 | |
| 741 if (!object) | 737 if (!object) |
| 742 return; | 738 return; |
| 743 | 739 |
| 744 m_notificationsToPost.append(std::make_pair(object, notification)); | 740 m_notificationsToPost.append(std::make_pair(object, notification)); |
| 745 if (!m_notificationPostTimer.isActive()) | 741 if (!m_notificationPostTimer.isActive()) |
| 746 m_notificationPostTimer.startOneShot(0, FROM_HERE); | 742 m_notificationPostTimer.startOneShot(0, FROM_HERE); |
| 747 } | 743 } |
| 748 | 744 |
| 749 void AXObjectCacheImpl::checkedStateChanged(Node* node) | 745 void AXObjectCacheImpl::checkedStateChanged(Node* node) |
| 750 { | 746 { |
| 751 postNotification(node, AXObjectCacheImpl::AXCheckedStateChanged, true); | 747 postNotification(node, AXObjectCacheImpl::AXCheckedStateChanged); |
| 752 } | 748 } |
| 753 | 749 |
| 754 void AXObjectCacheImpl::selectedChildrenChanged(Node* node) | 750 void AXObjectCacheImpl::selectedChildrenChanged(Node* node) |
| 755 { | 751 { |
| 756 // postToElement is false so that you can pass in any child of an element an d it will go up the parent tree | 752 AXObject* obj = get(node); |
| 757 // to find the container which should send out the notification. | 753 while (obj && obj->roleValue() != ListBoxRole) |
| 758 postNotification(node, AXSelectedChildrenChanged, false); | 754 obj = obj->parentObject(); |
|
je_julie(Not used)
2015/03/27 09:37:21
How about adding a helper function for this?
dmazzoni
2015/03/27 18:31:35
Done.
| |
| 755 postNotification(obj, AXSelectedChildrenChanged); | |
| 759 } | 756 } |
| 760 | 757 |
| 761 void AXObjectCacheImpl::selectedChildrenChanged(LayoutObject* layoutObject) | 758 void AXObjectCacheImpl::selectedChildrenChanged(LayoutObject* layoutObject) |
| 762 { | 759 { |
| 763 // postToElement is false so that you can pass in any child of an element an d it will go up the parent tree | 760 AXObject* obj = get(layoutObject); |
| 764 // to find the container which should send out the notification. | 761 while (obj && obj->roleValue() != ListBoxRole) |
| 765 postNotification(layoutObject, AXSelectedChildrenChanged, false); | 762 obj = obj->parentObject(); |
| 763 postNotification(obj, AXSelectedChildrenChanged); | |
| 766 } | 764 } |
| 767 | 765 |
| 768 void AXObjectCacheImpl::handleScrollbarUpdate(FrameView* view) | 766 void AXObjectCacheImpl::handleScrollbarUpdate(FrameView* view) |
| 769 { | 767 { |
| 770 if (!view) | 768 if (!view) |
| 771 return; | 769 return; |
| 772 | 770 |
| 773 // We don't want to create a scroll view from this method, only update an ex isting one. | 771 // We don't want to create a scroll view from this method, only update an ex isting one. |
| 774 if (AXObject* scrollViewObject = get(view)) { | 772 if (AXObject* scrollViewObject = get(view)) { |
| 775 m_modificationCount++; | 773 m_modificationCount++; |
| 776 scrollViewObject->updateChildrenIfNecessary(); | 774 scrollViewObject->updateChildrenIfNecessary(); |
| 777 } | 775 } |
| 778 } | 776 } |
| 779 | 777 |
| 780 void AXObjectCacheImpl::handleLayoutComplete(LayoutObject* layoutObject) | 778 void AXObjectCacheImpl::handleLayoutComplete(LayoutObject* layoutObject) |
| 781 { | 779 { |
| 782 if (!layoutObject) | 780 if (!layoutObject) |
| 783 return; | 781 return; |
| 784 | 782 |
| 785 m_modificationCount++; | 783 m_modificationCount++; |
| 786 | 784 |
| 787 // Create the AXObject if it didn't yet exist - that's always safe at the en d of a layout, and it | 785 // Create the AXObject if it didn't yet exist - that's always safe at the en d of a layout, and it |
| 788 // allows an AX notification to be sent when a page has its first layout, ra ther than when the | 786 // allows an AX notification to be sent when a page has its first layout, ra ther than when the |
| 789 // document first loads. | 787 // document first loads. |
| 790 if (AXObject* obj = getOrCreate(layoutObject)) | 788 if (AXObject* obj = getOrCreate(layoutObject)) |
| 791 postNotification(obj, AXLayoutComplete, true); | 789 postNotification(obj, AXLayoutComplete); |
| 792 } | 790 } |
| 793 | 791 |
| 794 void AXObjectCacheImpl::handleAriaExpandedChange(Node* node) | 792 void AXObjectCacheImpl::handleAriaExpandedChange(Node* node) |
| 795 { | 793 { |
| 796 if (AXObject* obj = getOrCreate(node)) | 794 if (AXObject* obj = getOrCreate(node)) |
| 797 obj->handleAriaExpandedChanged(); | 795 obj->handleAriaExpandedChanged(); |
| 798 } | 796 } |
| 799 | 797 |
| 800 void AXObjectCacheImpl::handleActiveDescendantChanged(Node* node) | 798 void AXObjectCacheImpl::handleActiveDescendantChanged(Node* node) |
| 801 { | 799 { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 820 textChanged(element); | 818 textChanged(element); |
| 821 else if (attrName == forAttr && isHTMLLabelElement(*element)) | 819 else if (attrName == forAttr && isHTMLLabelElement(*element)) |
| 822 labelChanged(element); | 820 labelChanged(element); |
| 823 | 821 |
| 824 if (!attrName.localName().startsWith("aria-")) | 822 if (!attrName.localName().startsWith("aria-")) |
| 825 return; | 823 return; |
| 826 | 824 |
| 827 if (attrName == aria_activedescendantAttr) | 825 if (attrName == aria_activedescendantAttr) |
| 828 handleActiveDescendantChanged(element); | 826 handleActiveDescendantChanged(element); |
| 829 else if (attrName == aria_valuenowAttr || attrName == aria_valuetextAttr) | 827 else if (attrName == aria_valuenowAttr || attrName == aria_valuetextAttr) |
| 830 postNotification(element, AXObjectCacheImpl::AXValueChanged, true); | 828 postNotification(element, AXObjectCacheImpl::AXValueChanged); |
| 831 else if (attrName == aria_labelAttr || attrName == aria_labeledbyAttr || att rName == aria_labelledbyAttr) | 829 else if (attrName == aria_labelAttr || attrName == aria_labeledbyAttr || att rName == aria_labelledbyAttr) |
| 832 textChanged(element); | 830 textChanged(element); |
| 833 else if (attrName == aria_checkedAttr) | 831 else if (attrName == aria_checkedAttr) |
| 834 checkedStateChanged(element); | 832 checkedStateChanged(element); |
| 835 else if (attrName == aria_selectedAttr) | 833 else if (attrName == aria_selectedAttr) |
| 836 selectedChildrenChanged(element); | 834 selectedChildrenChanged(element); |
| 837 else if (attrName == aria_expandedAttr) | 835 else if (attrName == aria_expandedAttr) |
| 838 handleAriaExpandedChange(element); | 836 handleAriaExpandedChange(element); |
| 839 else if (attrName == aria_hiddenAttr) | 837 else if (attrName == aria_hiddenAttr) |
| 840 childrenChanged(element->parentNode()); | 838 childrenChanged(element->parentNode()); |
| 841 else if (attrName == aria_invalidAttr) | 839 else if (attrName == aria_invalidAttr) |
| 842 postNotification(element, AXObjectCacheImpl::AXInvalidStatusChanged, tru e); | 840 postNotification(element, AXObjectCacheImpl::AXInvalidStatusChanged); |
| 843 else | 841 else |
| 844 postNotification(element, AXObjectCacheImpl::AXAriaAttributeChanged, tru e); | 842 postNotification(element, AXObjectCacheImpl::AXAriaAttributeChanged); |
| 845 } | 843 } |
| 846 | 844 |
| 847 void AXObjectCacheImpl::labelChanged(Element* element) | 845 void AXObjectCacheImpl::labelChanged(Element* element) |
| 848 { | 846 { |
| 849 textChanged(toHTMLLabelElement(element)->control()); | 847 textChanged(toHTMLLabelElement(element)->control()); |
| 850 } | 848 } |
| 851 | 849 |
| 852 void AXObjectCacheImpl::recomputeIsIgnored(LayoutObject* layoutObject) | 850 void AXObjectCacheImpl::recomputeIsIgnored(LayoutObject* layoutObject) |
| 853 { | 851 { |
| 854 if (AXObject* obj = get(layoutObject)) | 852 if (AXObject* obj = get(layoutObject)) |
| 855 obj->notifyIfIgnoredValueChanged(); | 853 obj->notifyIfIgnoredValueChanged(); |
| 856 } | 854 } |
| 857 | 855 |
| 858 void AXObjectCacheImpl::inlineTextBoxesUpdated(LayoutObject* layoutObject) | 856 void AXObjectCacheImpl::inlineTextBoxesUpdated(LayoutObject* layoutObject) |
| 859 { | 857 { |
| 860 if (!inlineTextBoxAccessibilityEnabled()) | 858 if (!inlineTextBoxAccessibilityEnabled()) |
| 861 return; | 859 return; |
| 862 | 860 |
| 863 // Only update if the accessibility object already exists and it's | 861 // Only update if the accessibility object already exists and it's |
| 864 // not already marked as dirty. | 862 // not already marked as dirty. |
| 865 if (AXObject* obj = get(layoutObject)) { | 863 if (AXObject* obj = get(layoutObject)) { |
| 866 if (!obj->needsToUpdateChildren()) { | 864 if (!obj->needsToUpdateChildren()) { |
| 867 obj->setNeedsToUpdateChildren(); | 865 obj->setNeedsToUpdateChildren(); |
| 868 postNotification(layoutObject, AXChildrenChanged, true); | 866 postNotification(layoutObject, AXChildrenChanged); |
| 869 } | 867 } |
| 870 } | 868 } |
| 871 } | 869 } |
| 872 | 870 |
| 873 Settings* AXObjectCacheImpl::settings() | 871 Settings* AXObjectCacheImpl::settings() |
| 874 { | 872 { |
| 875 return m_document.settings(); | 873 return m_document.settings(); |
| 876 } | 874 } |
| 877 | 875 |
| 878 bool AXObjectCacheImpl::accessibilityEnabled() | 876 bool AXObjectCacheImpl::accessibilityEnabled() |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 | 983 |
| 986 AXObject* focusedObject = focusedUIElementForPage(page); | 984 AXObject* focusedObject = focusedUIElementForPage(page); |
| 987 if (!focusedObject) | 985 if (!focusedObject) |
| 988 return; | 986 return; |
| 989 | 987 |
| 990 postPlatformNotification(focusedObject, AXFocusedUIElementChanged); | 988 postPlatformNotification(focusedObject, AXFocusedUIElementChanged); |
| 991 } | 989 } |
| 992 | 990 |
| 993 void AXObjectCacheImpl::handleInitialFocus() | 991 void AXObjectCacheImpl::handleInitialFocus() |
| 994 { | 992 { |
| 995 postNotification(&m_document, AXObjectCache::AXFocusedUIElementChanged, true ); | 993 postNotification(&m_document, AXObjectCache::AXFocusedUIElementChanged); |
| 996 } | 994 } |
| 997 | 995 |
| 998 void AXObjectCacheImpl::handleEditableTextContentChanged(Node* node) | 996 void AXObjectCacheImpl::handleEditableTextContentChanged(Node* node) |
| 999 { | 997 { |
| 1000 postNotification(node, AXObjectCache::AXValueChanged, false); | 998 AXObject* obj = get(node); |
| 999 while (obj && !obj->isNativeTextControl() && !obj->isNonNativeTextControl()) | |
| 1000 obj = obj->parentObject(); | |
| 1001 postNotification(obj, AXObjectCache::AXValueChanged); | |
| 1001 } | 1002 } |
| 1002 | 1003 |
| 1003 void AXObjectCacheImpl::handleTextFormControlChanged(Node* node) | 1004 void AXObjectCacheImpl::handleTextFormControlChanged(Node* node) |
| 1004 { | 1005 { |
| 1005 postNotification(node, AXObjectCache::AXValueChanged, false); | 1006 AXObject* obj = get(node); |
| 1007 while (obj && !obj->isNativeTextControl() && !obj->isNonNativeTextControl()) | |
| 1008 obj = obj->parentObject(); | |
| 1009 postNotification(obj, AXObjectCache::AXValueChanged); | |
|
je_julie(Not used)
2015/03/27 09:37:21
ditto.
dmazzoni
2015/03/27 18:31:35
Sure, in this case I'll just call handleEditableTe
| |
| 1006 } | 1010 } |
| 1007 | 1011 |
| 1008 void AXObjectCacheImpl::handleValueChanged(Node* node) | 1012 void AXObjectCacheImpl::handleValueChanged(Node* node) |
| 1009 { | 1013 { |
| 1010 postNotification(node, AXObjectCache::AXValueChanged, true); | 1014 postNotification(node, AXObjectCache::AXValueChanged); |
| 1011 } | 1015 } |
| 1012 | 1016 |
| 1013 void AXObjectCacheImpl::handleUpdateActiveMenuOption(LayoutMenuList* menuList, i nt optionIndex) | 1017 void AXObjectCacheImpl::handleUpdateActiveMenuOption(LayoutMenuList* menuList, i nt optionIndex) |
| 1014 { | 1018 { |
| 1015 if (AXMenuList* axMenuList = static_cast<AXMenuList*>(get(menuList))) | 1019 if (AXMenuList* axMenuList = static_cast<AXMenuList*>(get(menuList))) |
| 1016 axMenuList->didUpdateActiveOption(optionIndex); | 1020 axMenuList->didUpdateActiveOption(optionIndex); |
| 1017 } | 1021 } |
| 1018 | 1022 |
| 1019 void AXObjectCacheImpl::handleLoadComplete(Document* document) | 1023 void AXObjectCacheImpl::handleLoadComplete(Document* document) |
| 1020 { | 1024 { |
| 1021 postNotification(getOrCreate(document), AXObjectCache::AXLoadComplete, true) ; | 1025 postNotification(getOrCreate(document), AXObjectCache::AXLoadComplete); |
| 1022 } | 1026 } |
| 1023 | 1027 |
| 1024 void AXObjectCacheImpl::handleLayoutComplete(Document* document) | 1028 void AXObjectCacheImpl::handleLayoutComplete(Document* document) |
| 1025 { | 1029 { |
| 1026 postNotification(getOrCreate(document), AXObjectCache::AXLayoutComplete, tru e); | 1030 postNotification(getOrCreate(document), AXObjectCache::AXLayoutComplete); |
| 1027 } | 1031 } |
| 1028 | 1032 |
| 1029 void AXObjectCacheImpl::handleScrolledToAnchor(const Node* anchorNode) | 1033 void AXObjectCacheImpl::handleScrolledToAnchor(const Node* anchorNode) |
| 1030 { | 1034 { |
| 1031 // The anchor node may not be accessible. Post the notification for the | 1035 // The anchor node may not be accessible. Post the notification for the |
| 1032 // first accessible object. | 1036 // first accessible object. |
| 1033 postPlatformNotification(firstAccessibleObjectFromNode(anchorNode), AXScroll edToAnchor); | 1037 postPlatformNotification(firstAccessibleObjectFromNode(anchorNode), AXScroll edToAnchor); |
| 1034 } | 1038 } |
| 1035 | 1039 |
| 1036 void AXObjectCacheImpl::handleScrollPositionChanged(FrameView* frameView) | 1040 void AXObjectCacheImpl::handleScrollPositionChanged(FrameView* frameView) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1094 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect & rect) | 1098 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect & rect) |
| 1095 { | 1099 { |
| 1096 AXObject* obj = getOrCreate(element); | 1100 AXObject* obj = getOrCreate(element); |
| 1097 if (!obj) | 1101 if (!obj) |
| 1098 return; | 1102 return; |
| 1099 | 1103 |
| 1100 obj->setElementRect(rect); | 1104 obj->setElementRect(rect); |
| 1101 } | 1105 } |
| 1102 | 1106 |
| 1103 } // namespace blink | 1107 } // namespace blink |
| OLD | NEW |