OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 return WebAreaRole; | 384 return WebAreaRole; |
385 } | 385 } |
386 | 386 |
387 if (cssBox && cssBox->isTextField()) | 387 if (cssBox && cssBox->isTextField()) |
388 return TextFieldRole; | 388 return TextFieldRole; |
389 | 389 |
390 if (cssBox && cssBox->isTextArea()) | 390 if (cssBox && cssBox->isTextArea()) |
391 return TextAreaRole; | 391 return TextAreaRole; |
392 | 392 |
393 if (node && node->hasTagName(inputTag)) { | 393 if (node && node->hasTagName(inputTag)) { |
394 HTMLInputElement* input = static_cast<HTMLInputElement*>(node); | 394 HTMLInputElement* input = toHTMLInputElement(node); |
395 if (input->isCheckbox()) | 395 if (input->isCheckbox()) |
396 return CheckBoxRole; | 396 return CheckBoxRole; |
397 if (input->isRadioButton()) | 397 if (input->isRadioButton()) |
398 return RadioButtonRole; | 398 return RadioButtonRole; |
399 if (input->isTextButton()) | 399 if (input->isTextButton()) |
400 return buttonRoleType(); | 400 return buttonRoleType(); |
401 | 401 |
402 #if ENABLE(INPUT_TYPE_COLOR) | 402 #if ENABLE(INPUT_TYPE_COLOR) |
403 const AtomicString& type = input->getAttribute(typeAttr); | 403 const AtomicString& type = input->getAttribute(typeAttr); |
404 if (equalIgnoringCase(type, "color")) | 404 if (equalIgnoringCase(type, "color")) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 return false; | 521 return false; |
522 // Widgets are the replaced elements that we represent to AX as attachments | 522 // Widgets are the replaced elements that we represent to AX as attachments |
523 bool isWidget = renderer->isWidget(); | 523 bool isWidget = renderer->isWidget(); |
524 ASSERT(!isWidget || (renderer->isReplaced() && !isImage())); | 524 ASSERT(!isWidget || (renderer->isReplaced() && !isImage())); |
525 return isWidget; | 525 return isWidget; |
526 } | 526 } |
527 | 527 |
528 bool AccessibilityRenderObject::isFileUploadButton() const | 528 bool AccessibilityRenderObject::isFileUploadButton() const |
529 { | 529 { |
530 if (m_renderer && m_renderer->node() && m_renderer->node()->hasTagName(input
Tag)) { | 530 if (m_renderer && m_renderer->node() && m_renderer->node()->hasTagName(input
Tag)) { |
531 HTMLInputElement* input = static_cast<HTMLInputElement*>(m_renderer->nod
e()); | 531 HTMLInputElement* input = toHTMLInputElement(m_renderer->node()); |
532 return input->isFileUpload(); | 532 return input->isFileUpload(); |
533 } | 533 } |
534 | 534 |
535 return false; | 535 return false; |
536 } | 536 } |
537 | 537 |
538 static bool isLinkable(const AccessibilityObject& object) | 538 static bool isLinkable(const AccessibilityObject& object) |
539 { | 539 { |
540 if (!object.renderer()) | 540 if (!object.renderer()) |
541 return false; | 541 return false; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 return anchor->href(); | 1102 return anchor->href(); |
1103 } | 1103 } |
1104 | 1104 |
1105 if (isWebArea()) | 1105 if (isWebArea()) |
1106 return m_renderer->document()->url(); | 1106 return m_renderer->document()->url(); |
1107 | 1107 |
1108 if (isImage() && m_renderer->node() && m_renderer->node()->hasTagName(imgTag
)) | 1108 if (isImage() && m_renderer->node() && m_renderer->node()->hasTagName(imgTag
)) |
1109 return static_cast<HTMLImageElement*>(m_renderer->node())->src(); | 1109 return static_cast<HTMLImageElement*>(m_renderer->node())->src(); |
1110 | 1110 |
1111 if (isInputImage()) | 1111 if (isInputImage()) |
1112 return static_cast<HTMLInputElement*>(m_renderer->node())->src(); | 1112 return toHTMLInputElement(m_renderer->node())->src(); |
1113 | 1113 |
1114 return KURL(); | 1114 return KURL(); |
1115 } | 1115 } |
1116 | 1116 |
1117 void AccessibilityRenderObject::visibleChildren(AccessibilityChildrenVector& res
ult) | 1117 void AccessibilityRenderObject::visibleChildren(AccessibilityChildrenVector& res
ult) |
1118 { | 1118 { |
1119 ASSERT(result.isEmpty()); | 1119 ASSERT(result.isEmpty()); |
1120 | 1120 |
1121 // only listboxes are asked for their visible children. | 1121 // only listboxes are asked for their visible children. |
1122 if (ariaRoleAttribute() != ListBoxRole) { // native list boxes would be Acce
ssibilityListBoxes, so only check for aria list boxes | 1122 if (ariaRoleAttribute() != ListBoxRole) { // native list boxes would be Acce
ssibilityListBoxes, so only check for aria list boxes |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 return; | 2059 return; |
2060 Element* element = toElement(m_renderer->node()); | 2060 Element* element = toElement(m_renderer->node()); |
2061 | 2061 |
2062 if (!m_renderer->isBoxModelObject()) | 2062 if (!m_renderer->isBoxModelObject()) |
2063 return; | 2063 return; |
2064 RenderBoxModelObject* renderer = toRenderBoxModelObject(m_renderer); | 2064 RenderBoxModelObject* renderer = toRenderBoxModelObject(m_renderer); |
2065 | 2065 |
2066 // FIXME: Do we want to do anything here for ARIA textboxes? | 2066 // FIXME: Do we want to do anything here for ARIA textboxes? |
2067 if (renderer->isTextField()) { | 2067 if (renderer->isTextField()) { |
2068 // FIXME: This is not safe! Other elements could have a TextField rende
rer. | 2068 // FIXME: This is not safe! Other elements could have a TextField rende
rer. |
2069 static_cast<HTMLInputElement*>(element)->setValue(string); | 2069 toHTMLInputElement(element)->setValue(string); |
2070 } else if (renderer->isTextArea()) { | 2070 } else if (renderer->isTextArea()) { |
2071 // FIXME: This is not safe! Other elements could have a TextArea render
er. | 2071 // FIXME: This is not safe! Other elements could have a TextArea render
er. |
2072 static_cast<HTMLTextAreaElement*>(element)->setValue(string); | 2072 static_cast<HTMLTextAreaElement*>(element)->setValue(string); |
2073 } | 2073 } |
2074 } | 2074 } |
2075 | 2075 |
2076 void AccessibilityRenderObject::setSelectedRows(AccessibilityChildrenVector& sel
ectedRows) | 2076 void AccessibilityRenderObject::setSelectedRows(AccessibilityChildrenVector& sel
ectedRows) |
2077 { | 2077 { |
2078 // Setting selected only makes sense in trees and tables (and tree-tables). | 2078 // Setting selected only makes sense in trees and tables (and tree-tables). |
2079 AccessibilityRole role = roleValue(); | 2079 AccessibilityRole role = roleValue(); |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2676 | 2676 |
2677 void AccessibilityRenderObject::addRadioButtonGroupMembers(AccessibilityChildren
Vector& linkedUIElements) const | 2677 void AccessibilityRenderObject::addRadioButtonGroupMembers(AccessibilityChildren
Vector& linkedUIElements) const |
2678 { | 2678 { |
2679 if (!m_renderer || roleValue() != RadioButtonRole) | 2679 if (!m_renderer || roleValue() != RadioButtonRole) |
2680 return; | 2680 return; |
2681 | 2681 |
2682 Node* node = m_renderer->node(); | 2682 Node* node = m_renderer->node(); |
2683 if (!node || !node->hasTagName(inputTag)) | 2683 if (!node || !node->hasTagName(inputTag)) |
2684 return; | 2684 return; |
2685 | 2685 |
2686 HTMLInputElement* input = static_cast<HTMLInputElement*>(node); | 2686 HTMLInputElement* input = toHTMLInputElement(node); |
2687 // if there's a form, then this is easy | 2687 // if there's a form, then this is easy |
2688 if (input->form()) { | 2688 if (input->form()) { |
2689 Vector<RefPtr<Node> > formElements; | 2689 Vector<RefPtr<Node> > formElements; |
2690 input->form()->getNamedElements(input->name(), formElements); | 2690 input->form()->getNamedElements(input->name(), formElements); |
2691 | 2691 |
2692 unsigned len = formElements.size(); | 2692 unsigned len = formElements.size(); |
2693 for (unsigned i = 0; i < len; ++i) { | 2693 for (unsigned i = 0; i < len; ++i) { |
2694 Node* associateElement = formElements[i].get(); | 2694 Node* associateElement = formElements[i].get(); |
2695 if (AccessibilityObject* object = axObjectCache()->getOrCreate(assoc
iateElement)) | 2695 if (AccessibilityObject* object = axObjectCache()->getOrCreate(assoc
iateElement)) |
2696 linkedUIElements.append(object); | 2696 linkedUIElements.append(object); |
2697 } | 2697 } |
2698 } else { | 2698 } else { |
2699 RefPtr<NodeList> list = node->document()->getElementsByTagName("input"); | 2699 RefPtr<NodeList> list = node->document()->getElementsByTagName("input"); |
2700 unsigned len = list->length(); | 2700 unsigned len = list->length(); |
2701 for (unsigned i = 0; i < len; ++i) { | 2701 for (unsigned i = 0; i < len; ++i) { |
2702 if (list->item(i)->hasTagName(inputTag)) { | 2702 if (list->item(i)->hasTagName(inputTag)) { |
2703 HTMLInputElement* associateElement = static_cast<HTMLInputElemen
t*>(list->item(i)); | 2703 HTMLInputElement* associateElement = toHTMLInputElement(list->it
em(i)); |
2704 if (associateElement->isRadioButton() && associateElement->name(
) == input->name()) { | 2704 if (associateElement->isRadioButton() && associateElement->name(
) == input->name()) { |
2705 if (AccessibilityObject* object = axObjectCache()->getOrCrea
te(associateElement)) | 2705 if (AccessibilityObject* object = axObjectCache()->getOrCrea
te(associateElement)) |
2706 linkedUIElements.append(object); | 2706 linkedUIElements.append(object); |
2707 } | 2707 } |
2708 } | 2708 } |
2709 } | 2709 } |
2710 } | 2710 } |
2711 } | 2711 } |
2712 | 2712 |
2713 AccessibilityObject* AccessibilityRenderObject::internalLinkElement() const | 2713 AccessibilityObject* AccessibilityRenderObject::internalLinkElement() const |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2970 insertionIndex += (m_children.size() - previousSize); | 2970 insertionIndex += (m_children.size() - previousSize); |
2971 } | 2971 } |
2972 } | 2972 } |
2973 | 2973 |
2974 void AccessibilityRenderObject::addTextFieldChildren() | 2974 void AccessibilityRenderObject::addTextFieldChildren() |
2975 { | 2975 { |
2976 Node* node = this->node(); | 2976 Node* node = this->node(); |
2977 if (!node || !node->hasTagName(inputTag)) | 2977 if (!node || !node->hasTagName(inputTag)) |
2978 return; | 2978 return; |
2979 | 2979 |
2980 HTMLInputElement* input = static_cast<HTMLInputElement*>(node); | 2980 HTMLInputElement* input = toHTMLInputElement(node); |
2981 HTMLElement* spinButtonElement = input->innerSpinButtonElement(); | 2981 HTMLElement* spinButtonElement = input->innerSpinButtonElement(); |
2982 if (!spinButtonElement || !spinButtonElement->isSpinButtonElement()) | 2982 if (!spinButtonElement || !spinButtonElement->isSpinButtonElement()) |
2983 return; | 2983 return; |
2984 | 2984 |
2985 AccessibilitySpinButton* axSpinButton = static_cast<AccessibilitySpinButton*
>(axObjectCache()->getOrCreate(SpinButtonRole)); | 2985 AccessibilitySpinButton* axSpinButton = static_cast<AccessibilitySpinButton*
>(axObjectCache()->getOrCreate(SpinButtonRole)); |
2986 axSpinButton->setSpinButtonElement(static_cast<SpinButtonElement*>(spinButto
nElement)); | 2986 axSpinButton->setSpinButtonElement(static_cast<SpinButtonElement*>(spinButto
nElement)); |
2987 axSpinButton->setParent(this); | 2987 axSpinButton->setParent(this); |
2988 m_children.append(axSpinButton); | 2988 m_children.append(axSpinButton); |
2989 } | 2989 } |
2990 | 2990 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3180 if (label && label->renderer()) { | 3180 if (label && label->renderer()) { |
3181 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); | 3181 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); |
3182 result.unite(labelRect); | 3182 result.unite(labelRect); |
3183 } | 3183 } |
3184 } | 3184 } |
3185 | 3185 |
3186 return result; | 3186 return result; |
3187 } | 3187 } |
3188 | 3188 |
3189 } // namespace WebCore | 3189 } // namespace WebCore |
OLD | NEW |