Changeset 34254 in webkit
- Timestamp:
- May 29, 2008 11:05:44 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r34213 r34254 1 2008-05-29 Chris Fleizach <cfleizach@apple.com> 2 3 Reviewed by Darin Adler. 4 5 <rdar://problem/4783102> Radio button/checkbox embedded with <label> tag should combine the text and the label as a single element 6 <rdar://problem/5091386> Seed: VO reads form labels twice in Safari 7 8 * page/AccessibilityObject.cpp: 9 (WebCore::AccessibilityObject::titleUIElement): 10 * page/AccessibilityObject.h: 11 (WebCore::AccessibilityObject::isControl): 12 * page/AccessibilityRenderObject.cpp: 13 (WebCore::AccessibilityRenderObject::isControl): 14 (WebCore::AccessibilityRenderObject::labelElementContainer): 15 (WebCore::AccessibilityRenderObject::title): 16 (WebCore::AccessibilityRenderObject::checkboxOrRadioRect): 17 (WebCore::AccessibilityRenderObject::elementRect): 18 (WebCore::AccessibilityRenderObject::titleUIElement): 19 (WebCore::AccessibilityRenderObject::accessibilityIsIgnored): 20 (WebCore::AccessibilityRenderObject::roleValue): 21 * page/AccessibilityRenderObject.h: 22 * page/mac/AccessibilityObjectWrapper.mm: 23 (-[AccessibilityObjectWrapper accessibilityAttributeNames]): 24 (-[AccessibilityObjectWrapper accessibilityAttributeValue:]): 25 1 26 2008-05-29 Timothy Hatcher <timothy@apple.com> 2 27 -
trunk/WebCore/page/AccessibilityObject.cpp
r33937 r34254 208 208 return 0; 209 209 } 210 211 AccessibilityObject* AccessibilityObject::titleUIElement() const 212 { 213 return 0; 214 } 210 215 211 216 int AccessibilityObject::textLength() const -
trunk/WebCore/page/AccessibilityObject.h
r34129 r34254 211 211 virtual bool isFileUploadButton() const { return false; }; 212 212 virtual bool isProgressIndicator() const { return false; }; 213 virtual bool isControl() const { return false; }; 213 214 214 215 virtual bool isChecked() const { return false; }; … … 253 254 virtual AccessibilityObject* observableObject() const; 254 255 virtual AccessibilityObject* linkedUIElement() const; 256 virtual AccessibilityObject* titleUIElement() const; 255 257 virtual AccessibilityRole ariaRoleAttribute() const; 256 258 virtual AccessibilityRole roleValue() const; -
trunk/WebCore/page/AccessibilityRenderObject.cpp
r34129 r34254 406 406 return roleValue() == WebCoreLinkRole; 407 407 } 408 409 bool AccessibilityRenderObject::isControl() const 410 { 411 if (!m_renderer) 412 return false; 413 414 Node* node = m_renderer->element(); 415 return node && (node->isControl() || AccessibilityObject::isARIAControl(ariaRoleAttribute())); 416 } 408 417 409 418 const AtomicString& AccessibilityRenderObject::getAttribute(const QualifiedName& attribute) const … … 780 789 return 0; 781 790 } 791 792 HTMLLabelElement* AccessibilityRenderObject::labelElementContainer() const 793 { 794 if (!m_renderer) 795 return false; 796 797 // the control element should not be considered part of the label 798 if (isControl()) 799 return false; 800 801 // find if this has a parent that is a label 802 for (Node* parentNode = m_renderer->element(); parentNode; parentNode = parentNode->parentNode()) { 803 if (parentNode->hasTagName(labelTag)) 804 return static_cast<HTMLLabelElement*>(parentNode); 805 } 806 807 return 0; 808 } 782 809 783 810 String AccessibilityRenderObject::title() const … … 807 834 } 808 835 809 if (isInputTag || AccessibilityObject::isARIAInput(ariaRole) ) {836 if (isInputTag || AccessibilityObject::isARIAInput(ariaRole) || isControl()) { 810 837 HTMLLabelElement* label = labelForElement(static_cast<Element*>(node)); 811 838 if (label) … … 897 924 return rect; 898 925 } 926 927 IntRect AccessibilityRenderObject::checkboxOrRadioRect() const 928 { 929 if (!m_renderer) 930 return IntRect(); 931 932 HTMLLabelElement* label = labelForElement(static_cast<Element*>(m_renderer->element())); 933 if (!label || !label->renderer()) 934 return IntRect(); 935 936 IntRect labelRect = axObjectCache()->get(label->renderer())->elementRect(); 937 labelRect.unite(boundingBoxRect()); 938 return labelRect; 939 } 899 940 900 941 IntRect AccessibilityRenderObject::elementRect() const … … 902 943 if (m_areaElement) 903 944 return m_areaElement->getRect(m_renderer); 945 946 // a checkbox or radio button should encompass its label 947 if (isCheckboxOrRadio()) 948 return checkboxOrRadioRect(); 904 949 905 950 return boundingBoxRect(); … … 951 996 } 952 997 998 AccessibilityObject* AccessibilityRenderObject::titleUIElement() const 999 { 1000 if (!m_renderer) 1001 return 0; 1002 1003 // checkbox and radio hide their labels. Only controls get titleUIElements for now 1004 if (isCheckboxOrRadio() || !isControl()) 1005 return 0; 1006 1007 Node* element = m_renderer->element(); 1008 HTMLLabelElement* label = labelForElement(static_cast<Element*>(element)); 1009 if (label && label->renderer()) 1010 return axObjectCache()->get(label->renderer()); 1011 1012 return 0; 1013 } 1014 953 1015 bool AccessibilityRenderObject::accessibilityIsIgnored() const 954 1016 { … … 966 1028 } 967 1029 1030 // find out if this element is inside of a label element. 1031 // if so, it may be ignored because it's the label for a checkbox or radio button 1032 HTMLLabelElement* labelElement = labelElementContainer(); 1033 if (labelElement) { 1034 HTMLElement* correspondingControl = labelElement->correspondingControl(); 1035 if (correspondingControl && correspondingControl->renderer()) { 1036 AccessibilityObject* controlObject = axObjectCache()->get(correspondingControl->renderer()); 1037 if (controlObject->isCheckboxOrRadio()) 1038 return true; 1039 } 1040 } 1041 968 1042 AccessibilityRole ariaRole = ariaRoleAttribute(); 969 1043 if (ariaRole == TextAreaRole || ariaRole == StaticTextRole) { … … 988 1062 989 1063 // all controls are accessible 990 if (m_renderer->element() && (m_renderer->element()->isControl() || AccessibilityObject::isARIAControl(ariaRoleAttribute()))) 1064 if (isControl()) 1065 return false; 1066 1067 // don't ignore labels, because they serve as TitleUIElements 1068 Node* node = m_renderer->element(); 1069 if (node && node->hasTagName(labelTag)) 991 1070 return false; 992 1071 … … 996 1075 // ignore images seemingly used as spacers 997 1076 if (isImage()) { 998 Node* node = m_renderer->element();999 1077 if (node && node->isElementNode()) { 1000 1078 Element* elt = static_cast<Element*>(node); … … 1917 1995 return HeadingRole; 1918 1996 1919 if (m_renderer->isBlockFlow() )1997 if (m_renderer->isBlockFlow() || node->hasTagName(labelTag)) 1920 1998 return GroupRole; 1921 1999 -
trunk/WebCore/page/AccessibilityRenderObject.h
r34129 r34254 42 42 class HTMLAreaElement; 43 43 class HTMLElement; 44 class HTMLLabelElement; 44 45 class HTMLSelectElement; 45 46 class IntPoint; … … 81 82 virtual bool isMenuButton() const; 82 83 virtual bool isMenuItem() const; 84 virtual bool isControl() const; 83 85 84 86 virtual bool isEnabled() const; … … 120 122 virtual AccessibilityObject* observableObject() const; 121 123 virtual AccessibilityObject* linkedUIElement() const; 124 virtual AccessibilityObject* titleUIElement() const; 122 125 virtual AccessibilityRole ariaRoleAttribute() const; 123 126 void setAriaRole(); … … 143 146 Document* document() const; 144 147 FrameView* topDocumentFrameView() const; 148 HTMLLabelElement* labelElementContainer() const; 145 149 146 150 virtual KURL url() const; … … 217 221 AccessibilityRole determineAriaRoleAttribute() const; 218 222 223 IntRect checkboxOrRadioRect() const; 224 219 225 }; 220 226 -
trunk/WebCore/page/mac/AccessibilityObjectWrapper.mm
r34058 r34254 537 537 static NSArray* menuItemAttrs = nil; 538 538 static NSArray* menuButtonAttrs = nil; 539 static NSArray* controlAttrs = nil; 539 540 NSMutableArray* tempArray; 540 541 if (attributes == nil) { … … 594 595 [tempArray addObject:NSAccessibilityVisibleCharacterRangeAttribute]; 595 596 [tempArray addObject:NSAccessibilityInsertionPointLineNumberAttribute]; 597 [tempArray addObject:NSAccessibilityTitleUIElementAttribute]; 596 598 textAttrs = [[NSArray alloc] initWithArray:tempArray]; 597 599 [tempArray release]; … … 602 604 [tempArray addObject:NSAccessibilityVisibleChildrenAttribute]; 603 605 [tempArray addObject:NSAccessibilityOrientationAttribute]; 606 [tempArray addObject:NSAccessibilityTitleUIElementAttribute]; 604 607 listBoxAttrs = [[NSArray alloc] initWithArray:tempArray]; 605 608 [tempArray release]; … … 658 661 NSAccessibilityChildrenAttribute, nil]; 659 662 } 663 if (controlAttrs == nil) { 664 tempArray = [[NSMutableArray alloc] initWithArray:attributes]; 665 [tempArray addObject:NSAccessibilityTitleUIElementAttribute]; 666 controlAttrs = [[NSArray alloc] initWithArray:tempArray]; 667 [tempArray release]; 668 } 660 669 661 670 if (m_object->isPasswordField()) … … 677 686 return progressIndicatorAttrs; 678 687 688 if (m_object->isControl()) 689 return controlAttrs; 690 679 691 if (m_object->isMenu()) 680 692 return menuAttrs; … … 1104 1116 } 1105 1117 1118 if ([attributeName isEqualToString:NSAccessibilityTitleUIElementAttribute]) { 1119 AccessibilityObject* obj = m_object->titleUIElement(); 1120 if (obj) 1121 return obj->wrapper(); 1122 return nil; 1123 } 1124 1106 1125 return nil; 1107 1126 }
Note: See TracChangeset
for help on using the changeset viewer.