| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 setLastKnownIsIgnoredValue(isIgnored); | 817 setLastKnownIsIgnoredValue(isIgnored); |
| 818 } | 818 } |
| 819 } | 819 } |
| 820 | 820 |
| 821 void AXObject::selectionChanged() | 821 void AXObject::selectionChanged() |
| 822 { | 822 { |
| 823 if (AXObject* parent = parentObjectIfExists()) | 823 if (AXObject* parent = parentObjectIfExists()) |
| 824 parent->selectionChanged(); | 824 parent->selectionChanged(); |
| 825 } | 825 } |
| 826 | 826 |
| 827 static VisiblePosition startOfStyleRange(const VisiblePosition& visiblePos) | |
| 828 { | |
| 829 RenderObject* renderer = visiblePos.deepEquivalent().deprecatedNode()->rende
rer(); | |
| 830 RenderObject* startRenderer = renderer; | |
| 831 RenderStyle* style = renderer->style(); | |
| 832 | |
| 833 // traverse backward by renderer to look for style change | |
| 834 for (RenderObject* r = renderer->previousInPreOrder(); r; r = r->previousInP
reOrder()) { | |
| 835 // skip non-leaf nodes | |
| 836 if (r->firstChild()) | |
| 837 continue; | |
| 838 | |
| 839 // stop at style change | |
| 840 if (r->style() != style) | |
| 841 break; | |
| 842 | |
| 843 // remember match | |
| 844 startRenderer = r; | |
| 845 } | |
| 846 | |
| 847 return firstPositionInOrBeforeNode(startRenderer->node()); | |
| 848 } | |
| 849 | |
| 850 static VisiblePosition endOfStyleRange(const VisiblePosition& visiblePos) | |
| 851 { | |
| 852 RenderObject* renderer = visiblePos.deepEquivalent().deprecatedNode()->rende
rer(); | |
| 853 RenderObject* endRenderer = renderer; | |
| 854 RenderStyle* style = renderer->style(); | |
| 855 | |
| 856 // traverse forward by renderer to look for style change | |
| 857 for (RenderObject* r = renderer->nextInPreOrder(); r; r = r->nextInPreOrder(
)) { | |
| 858 // skip non-leaf nodes | |
| 859 if (r->firstChild()) | |
| 860 continue; | |
| 861 | |
| 862 // stop at style change | |
| 863 if (r->style() != style) | |
| 864 break; | |
| 865 | |
| 866 // remember match | |
| 867 endRenderer = r; | |
| 868 } | |
| 869 | |
| 870 return lastPositionInOrAfterNode(endRenderer->node()); | |
| 871 } | |
| 872 | |
| 873 static bool replacedNodeNeedsCharacter(Node* replacedNode) | |
| 874 { | |
| 875 // we should always be given a rendered node and a replaced node, but be saf
e | |
| 876 // replaced nodes are either attachments (widgets) or images | |
| 877 if (!replacedNode || !replacedNode->renderer() || !replacedNode->renderer()-
>isReplaced() || replacedNode->isTextNode()) | |
| 878 return false; | |
| 879 | |
| 880 // create an AX object, but skip it if it is not supposed to be seen | |
| 881 AXObject* object = replacedNode->renderer()->document().axObjectCache()->get
OrCreate(replacedNode); | |
| 882 if (object->accessibilityIsIgnored()) | |
| 883 return false; | |
| 884 | |
| 885 return true; | |
| 886 } | |
| 887 | |
| 888 int AXObject::lineForPosition(const VisiblePosition& visiblePos) const | 827 int AXObject::lineForPosition(const VisiblePosition& visiblePos) const |
| 889 { | 828 { |
| 890 if (visiblePos.isNull() || !node()) | 829 if (visiblePos.isNull() || !node()) |
| 891 return -1; | 830 return -1; |
| 892 | 831 |
| 893 // If the position is not in the same editable region as this AX object, ret
urn -1. | 832 // If the position is not in the same editable region as this AX object, ret
urn -1. |
| 894 Node* containerNode = visiblePos.deepEquivalent().containerNode(); | 833 Node* containerNode = visiblePos.deepEquivalent().containerNode(); |
| 895 if (!containerNode->containsIncludingShadowDOM(node()) && !node()->containsI
ncludingShadowDOM(containerNode)) | 834 if (!containerNode->containsIncludingShadowDOM(node()) && !node()->containsI
ncludingShadowDOM(containerNode)) |
| 896 return -1; | 835 return -1; |
| 897 | 836 |
| 898 int lineCount = -1; | 837 int lineCount = -1; |
| 899 VisiblePosition currentVisiblePos = visiblePos; | 838 VisiblePosition currentVisiblePos = visiblePos; |
| 900 VisiblePosition savedVisiblePos; | 839 VisiblePosition savedVisiblePos; |
| 901 | 840 |
| 902 // move up until we get to the top | 841 // move up until we get to the top |
| 903 // FIXME: This only takes us to the top of the rootEditableElement, not the
top of the | 842 // FIXME: This only takes us to the top of the rootEditableElement, not the
top of the |
| 904 // top document. | 843 // top document. |
| 905 do { | 844 do { |
| 906 savedVisiblePos = currentVisiblePos; | 845 savedVisiblePos = currentVisiblePos; |
| 907 VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos,
0, HasEditableAXRole); | 846 VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos,
0, HasEditableAXRole); |
| 908 currentVisiblePos = prevVisiblePos; | 847 currentVisiblePos = prevVisiblePos; |
| 909 ++lineCount; | 848 ++lineCount; |
| 910 } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, s
avedVisiblePos))); | 849 } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, s
avedVisiblePos))); |
| 911 | 850 |
| 912 return lineCount; | 851 return lineCount; |
| 913 } | 852 } |
| 914 | 853 |
| 915 // Finds a RenderListItem parent give a node. | |
| 916 static RenderListItem* renderListItemContainerForNode(Node* node) | |
| 917 { | |
| 918 for (; node; node = node->parentNode()) { | |
| 919 RenderBoxModelObject* renderer = node->renderBoxModelObject(); | |
| 920 if (renderer && renderer->isListItem()) | |
| 921 return toRenderListItem(renderer); | |
| 922 } | |
| 923 return 0; | |
| 924 } | |
| 925 | |
| 926 bool AXObject::isARIAControl(AccessibilityRole ariaRole) | 854 bool AXObject::isARIAControl(AccessibilityRole ariaRole) |
| 927 { | 855 { |
| 928 return isARIAInput(ariaRole) || ariaRole == TextAreaRole || ariaRole == Butt
onRole | 856 return isARIAInput(ariaRole) || ariaRole == TextAreaRole || ariaRole == Butt
onRole |
| 929 || ariaRole == ComboBoxRole || ariaRole == SliderRole; | 857 || ariaRole == ComboBoxRole || ariaRole == SliderRole; |
| 930 } | 858 } |
| 931 | 859 |
| 932 bool AXObject::isARIAInput(AccessibilityRole ariaRole) | 860 bool AXObject::isARIAInput(AccessibilityRole ariaRole) |
| 933 { | 861 { |
| 934 return ariaRole == RadioButtonRole || ariaRole == CheckBoxRole || ariaRole =
= TextFieldRole; | 862 return ariaRole == RadioButtonRole || ariaRole == CheckBoxRole || ariaRole =
= TextFieldRole; |
| 935 } | 863 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 | 903 |
| 976 for (AXObject* object = parentObject(); object; object = object->parentObjec
t()) { | 904 for (AXObject* object = parentObject(); object; object = object->parentObjec
t()) { |
| 977 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true")) | 905 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true")) |
| 978 return true; | 906 return true; |
| 979 } | 907 } |
| 980 | 908 |
| 981 return false; | 909 return false; |
| 982 } | 910 } |
| 983 | 911 |
| 984 } // namespace WebCore | 912 } // namespace WebCore |
| OLD | NEW |