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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 return false; | 467 return false; |
468 // Widgets are the replaced elements that we represent to AX as attachments | 468 // Widgets are the replaced elements that we represent to AX as attachments |
469 bool isWidget = renderer->isWidget(); | 469 bool isWidget = renderer->isWidget(); |
470 ASSERT(!isWidget || (renderer->isReplaced() && !isImage())); | 470 ASSERT(!isWidget || (renderer->isReplaced() && !isImage())); |
471 return isWidget && ariaRoleAttribute() == UnknownRole; | 471 return isWidget && ariaRoleAttribute() == UnknownRole; |
472 } | 472 } |
473 | 473 |
474 bool AccessibilityRenderObject::isFileUploadButton() const | 474 bool AccessibilityRenderObject::isFileUploadButton() const |
475 { | 475 { |
476 if (m_renderer && m_renderer->node() && m_renderer->node()->hasTagName(input
Tag)) { | 476 if (m_renderer && m_renderer->node() && m_renderer->node()->hasTagName(input
Tag)) { |
477 HTMLInputElement* input = static_cast<HTMLInputElement*>(m_renderer->nod
e()); | 477 Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(m_renderer
->node())); |
478 return input->isFileUpload(); | 478 return input->isFileUpload(); |
479 } | 479 } |
480 | 480 |
481 return false; | 481 return false; |
482 } | 482 } |
483 | 483 |
484 bool AccessibilityRenderObject::isReadOnly() const | 484 bool AccessibilityRenderObject::isReadOnly() const |
485 { | 485 { |
486 ASSERT(m_renderer); | 486 ASSERT(m_renderer); |
487 | 487 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 staticText = textUnderElement(); | 635 staticText = textUnderElement(); |
636 return staticText; | 636 return staticText; |
637 } | 637 } |
638 | 638 |
639 if (m_renderer->isText()) | 639 if (m_renderer->isText()) |
640 return textUnderElement(); | 640 return textUnderElement(); |
641 | 641 |
642 if (cssBox && cssBox->isMenuList()) { | 642 if (cssBox && cssBox->isMenuList()) { |
643 // RenderMenuList will go straight to the text() of its selected item. | 643 // RenderMenuList will go straight to the text() of its selected item. |
644 // This has to be overridden in the case where the selected item has an
ARIA label. | 644 // This has to be overridden in the case where the selected item has an
ARIA label. |
645 HTMLSelectElement* selectElement = toHTMLSelectElement(m_renderer->node(
)); | 645 Handle<HTMLSelectElement> selectElement = toHTMLSelectElement(m_renderer
->node()); |
646 int selectedIndex = selectElement->selectedIndex(); | 646 int selectedIndex = selectElement->selectedIndex(); |
647 const Vector<HTMLElement*> listItems = selectElement->listItems(); | 647 const Vector<HTMLElement*> listItems = selectElement->listItems(); |
648 if (selectedIndex >= 0 && static_cast<size_t>(selectedIndex) < listItems
.size()) { | 648 if (selectedIndex >= 0 && static_cast<size_t>(selectedIndex) < listItems
.size()) { |
649 const AtomicString& overriddenDescription = listItems[selectedIndex]
->fastGetAttribute(aria_labelAttr); | 649 const AtomicString& overriddenDescription = listItems[selectedIndex]
->fastGetAttribute(aria_labelAttr); |
650 if (!overriddenDescription.isNull()) | 650 if (!overriddenDescription.isNull()) |
651 return overriddenDescription; | 651 return overriddenDescription; |
652 } | 652 } |
653 return toRenderMenuList(m_renderer)->text(); | 653 return toRenderMenuList(m_renderer)->text(); |
654 } | 654 } |
655 | 655 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 | 826 |
827 void AccessibilityRenderObject::addRadioButtonGroupMembers(AccessibilityChildren
Vector& linkedUIElements) const | 827 void AccessibilityRenderObject::addRadioButtonGroupMembers(AccessibilityChildren
Vector& linkedUIElements) const |
828 { | 828 { |
829 if (!m_renderer || roleValue() != RadioButtonRole) | 829 if (!m_renderer || roleValue() != RadioButtonRole) |
830 return; | 830 return; |
831 | 831 |
832 Node* node = m_renderer->node(); | 832 Node* node = m_renderer->node(); |
833 if (!node || !node->hasTagName(inputTag)) | 833 if (!node || !node->hasTagName(inputTag)) |
834 return; | 834 return; |
835 | 835 |
836 HTMLInputElement* input = static_cast<HTMLInputElement*>(node); | 836 Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(node)); |
837 // if there's a form, then this is easy | 837 // if there's a form, then this is easy |
838 if (input->form()) { | 838 if (input->form()) { |
839 Vector<RefPtr<Node> > formElements; | 839 Vector<RefPtr<Node> > formElements; |
840 input->form()->getNamedElements(input->name(), formElements); | 840 input->form()->getNamedElements(input->name(), formElements); |
841 | 841 |
842 unsigned len = formElements.size(); | 842 unsigned len = formElements.size(); |
843 for (unsigned i = 0; i < len; ++i) { | 843 for (unsigned i = 0; i < len; ++i) { |
844 Node* associateElement = formElements[i].get(); | 844 Node* associateElement = formElements[i].get(); |
845 if (AccessibilityObject* object = axObjectCache()->getOrCreate(assoc
iateElement)) | 845 if (AccessibilityObject* object = axObjectCache()->getOrCreate(assoc
iateElement)) |
846 linkedUIElements.append(object); | 846 linkedUIElements.append(object); |
847 } | 847 } |
848 } else { | 848 } else { |
849 RefPtr<NodeList> list = node->document()->getElementsByTagName("input"); | 849 RefPtr<NodeList> list = node->document()->getElementsByTagName("input"); |
850 unsigned len = list->length(); | 850 unsigned len = list->length(); |
851 for (unsigned i = 0; i < len; ++i) { | 851 for (unsigned i = 0; i < len; ++i) { |
852 if (list->item(i)->hasTagName(inputTag)) { | 852 if (list->item(i)->hasTagName(inputTag)) { |
853 HTMLInputElement* associateElement = static_cast<HTMLInputElemen
t*>(list->item(i)); | 853 Handle<HTMLInputElement> associateElement(static_cast<HTMLInputE
lement*>(list->item(i))); |
854 if (associateElement->isRadioButton() && associateElement->name(
) == input->name()) { | 854 if (associateElement->isRadioButton() && associateElement->name(
) == input->name()) { |
855 if (AccessibilityObject* object = axObjectCache()->getOrCrea
te(associateElement)) | 855 if (AccessibilityObject* object = axObjectCache()->getOrCrea
te(associateElement.raw())) |
856 linkedUIElements.append(object); | 856 linkedUIElements.append(object); |
857 } | 857 } |
858 } | 858 } |
859 } | 859 } |
860 } | 860 } |
861 } | 861 } |
862 | 862 |
863 // linked ui elements could be all the related radio buttons in a group | 863 // linked ui elements could be all the related radio buttons in a group |
864 // or an internal anchor connection | 864 // or an internal anchor connection |
865 void AccessibilityRenderObject::linkedUIElements(AccessibilityChildrenVector& li
nkedUIElements) const | 865 void AccessibilityRenderObject::linkedUIElements(AccessibilityChildrenVector& li
nkedUIElements) const |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 } | 1267 } |
1268 | 1268 |
1269 String AccessibilityRenderObject::selectedText() const | 1269 String AccessibilityRenderObject::selectedText() const |
1270 { | 1270 { |
1271 ASSERT(isTextControl()); | 1271 ASSERT(isTextControl()); |
1272 | 1272 |
1273 if (isPasswordField()) | 1273 if (isPasswordField()) |
1274 return String(); // need to return something distinct from empty string | 1274 return String(); // need to return something distinct from empty string |
1275 | 1275 |
1276 if (isNativeTextControl()) { | 1276 if (isNativeTextControl()) { |
1277 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | 1277 Handle<HTMLTextFormControlElement> textControl = toRenderTextControl(m_r
enderer)->textFormControlElement(); |
1278 return textControl->selectedText(); | 1278 return textControl->selectedText(); |
1279 } | 1279 } |
1280 | 1280 |
1281 if (ariaRoleAttribute() == UnknownRole) | 1281 if (ariaRoleAttribute() == UnknownRole) |
1282 return String(); | 1282 return String(); |
1283 | 1283 |
1284 return doAXStringForRange(ariaSelectedTextRange()); | 1284 return doAXStringForRange(ariaSelectedTextRange()); |
1285 } | 1285 } |
1286 | 1286 |
1287 const AtomicString& AccessibilityRenderObject::accessKey() const | 1287 const AtomicString& AccessibilityRenderObject::accessKey() const |
(...skipping 13 matching lines...) Expand all Loading... |
1301 | 1301 |
1302 PlainTextRange AccessibilityRenderObject::selectedTextRange() const | 1302 PlainTextRange AccessibilityRenderObject::selectedTextRange() const |
1303 { | 1303 { |
1304 ASSERT(isTextControl()); | 1304 ASSERT(isTextControl()); |
1305 | 1305 |
1306 if (isPasswordField()) | 1306 if (isPasswordField()) |
1307 return PlainTextRange(); | 1307 return PlainTextRange(); |
1308 | 1308 |
1309 AccessibilityRole ariaRole = ariaRoleAttribute(); | 1309 AccessibilityRole ariaRole = ariaRoleAttribute(); |
1310 if (isNativeTextControl() && ariaRole == UnknownRole) { | 1310 if (isNativeTextControl() && ariaRole == UnknownRole) { |
1311 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | 1311 Handle<HTMLTextFormControlElement> textControl = toRenderTextControl(m_r
enderer)->textFormControlElement(); |
1312 return PlainTextRange(textControl->selectionStart(), textControl->select
ionEnd() - textControl->selectionStart()); | 1312 return PlainTextRange(textControl->selectionStart(), textControl->select
ionEnd() - textControl->selectionStart()); |
1313 } | 1313 } |
1314 | 1314 |
1315 if (ariaRole == UnknownRole) | 1315 if (ariaRole == UnknownRole) |
1316 return PlainTextRange(); | 1316 return PlainTextRange(); |
1317 | 1317 |
1318 return ariaSelectedTextRange(); | 1318 return ariaSelectedTextRange(); |
1319 } | 1319 } |
1320 | 1320 |
1321 void AccessibilityRenderObject::setSelectedTextRange(const PlainTextRange& range
) | 1321 void AccessibilityRenderObject::setSelectedTextRange(const PlainTextRange& range
) |
1322 { | 1322 { |
1323 if (isNativeTextControl()) { | 1323 if (isNativeTextControl()) { |
1324 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | 1324 Handle<HTMLTextFormControlElement> textControl = toRenderTextControl(m_r
enderer)->textFormControlElement(); |
1325 textControl->setSelectionRange(range.start, range.start + range.length); | 1325 textControl->setSelectionRange(range.start, range.start + range.length); |
1326 return; | 1326 return; |
1327 } | 1327 } |
1328 | 1328 |
1329 Document* document = m_renderer->document(); | 1329 Document* document = m_renderer->document(); |
1330 if (!document) | 1330 if (!document) |
1331 return; | 1331 return; |
1332 Frame* frame = document->frame(); | 1332 Frame* frame = document->frame(); |
1333 if (!frame) | 1333 if (!frame) |
1334 return; | 1334 return; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 RefPtr<Range> range = Range::create(m_renderer->document()); | 1675 RefPtr<Range> range = Range::create(m_renderer->document()); |
1676 range->selectNodeContents(node, IGNORE_EXCEPTION); | 1676 range->selectNodeContents(node, IGNORE_EXCEPTION); |
1677 CharacterIterator it(range.get()); | 1677 CharacterIterator it(range.get()); |
1678 it.advance(index - 1); | 1678 it.advance(index - 1); |
1679 return VisiblePosition(Position(it.range()->endContainer(), it.range()->endO
ffset(), Position::PositionIsOffsetInAnchor), UPSTREAM); | 1679 return VisiblePosition(Position(it.range()->endContainer(), it.range()->endO
ffset(), Position::PositionIsOffsetInAnchor), UPSTREAM); |
1680 } | 1680 } |
1681 | 1681 |
1682 int AccessibilityRenderObject::indexForVisiblePosition(const VisiblePosition& po
s) const | 1682 int AccessibilityRenderObject::indexForVisiblePosition(const VisiblePosition& po
s) const |
1683 { | 1683 { |
1684 if (isNativeTextControl()) { | 1684 if (isNativeTextControl()) { |
1685 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | 1685 Handle<HTMLTextFormControlElement> textControl = toRenderTextControl(m_r
enderer)->textFormControlElement(); |
1686 return textControl->indexForVisiblePosition(pos); | 1686 return textControl->indexForVisiblePosition(pos); |
1687 } | 1687 } |
1688 | 1688 |
1689 if (!isTextControl()) | 1689 if (!isTextControl()) |
1690 return 0; | 1690 return 0; |
1691 | 1691 |
1692 Node* node = m_renderer->node(); | 1692 Node* node = m_renderer->node(); |
1693 if (!node) | 1693 if (!node) |
1694 return 0; | 1694 return 0; |
1695 | 1695 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 HitTestResult hitTestResult = HitTestResult(point); | 2010 HitTestResult hitTestResult = HitTestResult(point); |
2011 layer->hitTest(request, hitTestResult); | 2011 layer->hitTest(request, hitTestResult); |
2012 if (!hitTestResult.innerNode()) | 2012 if (!hitTestResult.innerNode()) |
2013 return 0; | 2013 return 0; |
2014 Node* node = hitTestResult.innerNode()->deprecatedShadowAncestorNode(); | 2014 Node* node = hitTestResult.innerNode()->deprecatedShadowAncestorNode(); |
2015 | 2015 |
2016 if (node->hasTagName(areaTag)) | 2016 if (node->hasTagName(areaTag)) |
2017 return accessibilityImageMapHitTest(static_cast<HTMLAreaElement*>(node),
point); | 2017 return accessibilityImageMapHitTest(static_cast<HTMLAreaElement*>(node),
point); |
2018 | 2018 |
2019 if (node->hasTagName(optionTag)) | 2019 if (node->hasTagName(optionTag)) |
2020 node = static_cast<HTMLOptionElement*>(node)->ownerSelectElement(); | 2020 node = Handle<HTMLSelectElement>(static_cast<HTMLOptionElement*>(node)->
ownerSelectElement()).raw(); |
2021 | 2021 |
2022 RenderObject* obj = node->renderer(); | 2022 RenderObject* obj = node->renderer(); |
2023 if (!obj) | 2023 if (!obj) |
2024 return 0; | 2024 return 0; |
2025 | 2025 |
2026 AccessibilityObject* result = obj->document()->axObjectCache()->getOrCreate(
obj); | 2026 AccessibilityObject* result = obj->document()->axObjectCache()->getOrCreate(
obj); |
2027 result->updateChildrenIfNecessary(); | 2027 result->updateChildrenIfNecessary(); |
2028 | 2028 |
2029 // Allow the element to perform any hit-testing it might need to do to reach
non-render children. | 2029 // Allow the element to perform any hit-testing it might need to do to reach
non-render children. |
2030 result = result->elementAccessibilityHitTest(point); | 2030 result = result->elementAccessibilityHitTest(point); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2273 return WebAreaRole; | 2273 return WebAreaRole; |
2274 } | 2274 } |
2275 | 2275 |
2276 if (cssBox && cssBox->isTextField()) | 2276 if (cssBox && cssBox->isTextField()) |
2277 return TextFieldRole; | 2277 return TextFieldRole; |
2278 | 2278 |
2279 if (cssBox && cssBox->isTextArea()) | 2279 if (cssBox && cssBox->isTextArea()) |
2280 return TextAreaRole; | 2280 return TextAreaRole; |
2281 | 2281 |
2282 if (node && node->hasTagName(inputTag)) { | 2282 if (node && node->hasTagName(inputTag)) { |
2283 HTMLInputElement* input = static_cast<HTMLInputElement*>(node); | 2283 Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(node)); |
2284 if (input->isCheckbox()) | 2284 if (input->isCheckbox()) |
2285 return CheckBoxRole; | 2285 return CheckBoxRole; |
2286 if (input->isRadioButton()) | 2286 if (input->isRadioButton()) |
2287 return RadioButtonRole; | 2287 return RadioButtonRole; |
2288 if (input->isTextButton()) | 2288 if (input->isTextButton()) |
2289 return buttonRoleType(); | 2289 return buttonRoleType(); |
2290 | 2290 |
2291 #if ENABLE(INPUT_TYPE_COLOR) | 2291 #if ENABLE(INPUT_TYPE_COLOR) |
2292 const AtomicString& type = input->getAttribute(typeAttr); | 2292 const AtomicString& type = input->getAttribute(typeAttr); |
2293 if (equalIgnoringCase(type, "color")) | 2293 if (equalIgnoringCase(type, "color")) |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2552 | 2552 |
2553 AccessibilityObject::updateChildrenIfNecessary(); | 2553 AccessibilityObject::updateChildrenIfNecessary(); |
2554 } | 2554 } |
2555 | 2555 |
2556 void AccessibilityRenderObject::addTextFieldChildren() | 2556 void AccessibilityRenderObject::addTextFieldChildren() |
2557 { | 2557 { |
2558 Node* node = this->node(); | 2558 Node* node = this->node(); |
2559 if (!node || !node->hasTagName(inputTag)) | 2559 if (!node || !node->hasTagName(inputTag)) |
2560 return; | 2560 return; |
2561 | 2561 |
2562 HTMLInputElement* input = static_cast<HTMLInputElement*>(node); | 2562 Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(node)); |
2563 HTMLElement* spinButtonElement = input->innerSpinButtonElement(); | 2563 HTMLElement* spinButtonElement = input->innerSpinButtonElement(); |
2564 if (!spinButtonElement || !spinButtonElement->isSpinButtonElement()) | 2564 if (!spinButtonElement || !spinButtonElement->isSpinButtonElement()) |
2565 return; | 2565 return; |
2566 | 2566 |
2567 AccessibilitySpinButton* axSpinButton = static_cast<AccessibilitySpinButton*
>(axObjectCache()->getOrCreate(SpinButtonRole)); | 2567 AccessibilitySpinButton* axSpinButton = static_cast<AccessibilitySpinButton*
>(axObjectCache()->getOrCreate(SpinButtonRole)); |
2568 axSpinButton->setSpinButtonElement(static_cast<SpinButtonElement*>(spinButto
nElement)); | 2568 axSpinButton->setSpinButtonElement(static_cast<SpinButtonElement*>(spinButto
nElement)); |
2569 axSpinButton->setParent(this); | 2569 axSpinButton->setParent(this); |
2570 m_children.append(axSpinButton); | 2570 m_children.append(axSpinButton); |
2571 } | 2571 } |
2572 | 2572 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3052 | 3052 |
3053 RenderBox* box = toRenderBox(m_renderer); | 3053 RenderBox* box = toRenderBox(m_renderer); |
3054 if (!box->canBeScrolledAndHasScrollableArea()) | 3054 if (!box->canBeScrolledAndHasScrollableArea()) |
3055 return; | 3055 return; |
3056 | 3056 |
3057 RenderLayer* layer = box->layer(); | 3057 RenderLayer* layer = box->layer(); |
3058 layer->scrollToOffset(toIntSize(point), RenderLayer::ScrollOffsetClamped); | 3058 layer->scrollToOffset(toIntSize(point), RenderLayer::ScrollOffsetClamped); |
3059 } | 3059 } |
3060 | 3060 |
3061 } // namespace WebCore | 3061 } // namespace WebCore |
OLD | NEW |