| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/accessibility/AXNodeObject.h" | 30 #include "core/accessibility/AXNodeObject.h" |
| 31 | 31 |
| 32 #include "core/InputTypeNames.h" |
| 32 #include "core/accessibility/AXObjectCache.h" | 33 #include "core/accessibility/AXObjectCache.h" |
| 33 #include "core/dom/NodeTraversal.h" | 34 #include "core/dom/NodeTraversal.h" |
| 34 #include "core/dom/Text.h" | 35 #include "core/dom/Text.h" |
| 35 #include "core/html/HTMLFieldSetElement.h" | 36 #include "core/html/HTMLFieldSetElement.h" |
| 36 #include "core/html/HTMLFrameElementBase.h" | 37 #include "core/html/HTMLFrameElementBase.h" |
| 37 #include "core/html/HTMLInputElement.h" | 38 #include "core/html/HTMLInputElement.h" |
| 38 #include "core/html/HTMLLabelElement.h" | 39 #include "core/html/HTMLLabelElement.h" |
| 39 #include "core/html/HTMLLegendElement.h" | 40 #include "core/html/HTMLLegendElement.h" |
| 40 #include "core/html/HTMLPlugInElement.h" | 41 #include "core/html/HTMLPlugInElement.h" |
| 41 #include "core/html/HTMLSelectElement.h" | 42 #include "core/html/HTMLSelectElement.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return ariaRole; | 186 return ariaRole; |
| 186 | 187 |
| 187 if (node()->isLink()) | 188 if (node()->isLink()) |
| 188 return LinkRole; | 189 return LinkRole; |
| 189 if (node()->isTextNode()) | 190 if (node()->isTextNode()) |
| 190 return StaticTextRole; | 191 return StaticTextRole; |
| 191 if (isHTMLButtonElement(*node())) | 192 if (isHTMLButtonElement(*node())) |
| 192 return buttonRoleType(); | 193 return buttonRoleType(); |
| 193 if (isHTMLInputElement(*node())) { | 194 if (isHTMLInputElement(*node())) { |
| 194 HTMLInputElement& input = toHTMLInputElement(*node()); | 195 HTMLInputElement& input = toHTMLInputElement(*node()); |
| 195 if (input.isCheckbox()) | 196 const AtomicString& type = input.type(); |
| 197 if (type == InputTypeNames::checkbox) |
| 196 return CheckBoxRole; | 198 return CheckBoxRole; |
| 197 if (input.isRadioButton()) | 199 if (type == InputTypeNames::radio) |
| 198 return RadioButtonRole; | 200 return RadioButtonRole; |
| 199 if (input.isTextButton()) | 201 if (input.isTextButton()) |
| 200 return buttonRoleType(); | 202 return buttonRoleType(); |
| 201 if (input.isRangeControl()) | 203 if (type == InputTypeNames::range) |
| 202 return SliderRole; | 204 return SliderRole; |
| 203 | 205 if (type == InputTypeNames::color) |
| 204 const AtomicString& type = input.getAttribute(typeAttr); | |
| 205 if (equalIgnoringCase(type, "color")) | |
| 206 return ColorWellRole; | 206 return ColorWellRole; |
| 207 | |
| 208 return TextFieldRole; | 207 return TextFieldRole; |
| 209 } | 208 } |
| 210 if (isHTMLSelectElement(*node())) { | 209 if (isHTMLSelectElement(*node())) { |
| 211 HTMLSelectElement& selectElement = toHTMLSelectElement(*node()); | 210 HTMLSelectElement& selectElement = toHTMLSelectElement(*node()); |
| 212 return selectElement.multiple() ? ListBoxRole : PopUpButtonRole; | 211 return selectElement.multiple() ? ListBoxRole : PopUpButtonRole; |
| 213 } | 212 } |
| 214 if (isHTMLTextAreaElement(*node())) | 213 if (isHTMLTextAreaElement(*node())) |
| 215 return TextAreaRole; | 214 return TextAreaRole; |
| 216 if (headingLevel()) | 215 if (headingLevel()) |
| 217 return HeadingRole; | 216 return HeadingRole; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 505 |
| 507 bool AXNodeObject::isImageButton() const | 506 bool AXNodeObject::isImageButton() const |
| 508 { | 507 { |
| 509 return isNativeImage() && isButton(); | 508 return isNativeImage() && isButton(); |
| 510 } | 509 } |
| 511 | 510 |
| 512 bool AXNodeObject::isInputImage() const | 511 bool AXNodeObject::isInputImage() const |
| 513 { | 512 { |
| 514 Node* node = this->node(); | 513 Node* node = this->node(); |
| 515 if (roleValue() == ButtonRole && isHTMLInputElement(node)) | 514 if (roleValue() == ButtonRole && isHTMLInputElement(node)) |
| 516 return toHTMLInputElement(*node).isImageButton(); | 515 return toHTMLInputElement(*node).type() == InputTypeNames::image; |
| 517 | 516 |
| 518 return false; | 517 return false; |
| 519 } | 518 } |
| 520 | 519 |
| 521 bool AXNodeObject::isLink() const | 520 bool AXNodeObject::isLink() const |
| 522 { | 521 { |
| 523 return roleValue() == LinkRole; | 522 return roleValue() == LinkRole; |
| 524 } | 523 } |
| 525 | 524 |
| 526 bool AXNodeObject::isMenu() const | 525 bool AXNodeObject::isMenu() const |
| (...skipping 17 matching lines...) Expand all Loading... |
| 544 return isHTMLSelectElement(node()) && toHTMLSelectElement(*node()).multiple(
); | 543 return isHTMLSelectElement(node()) && toHTMLSelectElement(*node()).multiple(
); |
| 545 } | 544 } |
| 546 | 545 |
| 547 bool AXNodeObject::isNativeCheckboxOrRadio() const | 546 bool AXNodeObject::isNativeCheckboxOrRadio() const |
| 548 { | 547 { |
| 549 Node* node = this->node(); | 548 Node* node = this->node(); |
| 550 if (!isHTMLInputElement(node)) | 549 if (!isHTMLInputElement(node)) |
| 551 return false; | 550 return false; |
| 552 | 551 |
| 553 HTMLInputElement* input = toHTMLInputElement(node); | 552 HTMLInputElement* input = toHTMLInputElement(node); |
| 554 return input->isCheckbox() || input->isRadioButton(); | 553 return input->type() == InputTypeNames::checkbox || input->type() == InputTy
peNames::radio; |
| 555 } | 554 } |
| 556 | 555 |
| 557 bool AXNodeObject::isNativeImage() const | 556 bool AXNodeObject::isNativeImage() const |
| 558 { | 557 { |
| 559 Node* node = this->node(); | 558 Node* node = this->node(); |
| 560 if (!node) | 559 if (!node) |
| 561 return false; | 560 return false; |
| 562 | 561 |
| 563 if (isHTMLImageElement(*node)) | 562 if (isHTMLImageElement(*node)) |
| 564 return true; | 563 return true; |
| 565 | 564 |
| 566 if (isHTMLPlugInElement(*node)) | 565 if (isHTMLPlugInElement(*node)) |
| 567 return true; | 566 return true; |
| 568 | 567 |
| 569 if (isHTMLInputElement(*node)) | 568 if (isHTMLInputElement(*node)) |
| 570 return toHTMLInputElement(*node).isImageButton(); | 569 return toHTMLInputElement(*node).type() == InputTypeNames::image; |
| 571 | 570 |
| 572 return false; | 571 return false; |
| 573 } | 572 } |
| 574 | 573 |
| 575 bool AXNodeObject::isNativeTextControl() const | 574 bool AXNodeObject::isNativeTextControl() const |
| 576 { | 575 { |
| 577 Node* node = this->node(); | 576 Node* node = this->node(); |
| 578 if (!node) | 577 if (!node) |
| 579 return false; | 578 return false; |
| 580 | 579 |
| 581 if (isHTMLTextAreaElement(*node)) | 580 if (isHTMLTextAreaElement(*node)) |
| 582 return true; | 581 return true; |
| 583 | 582 |
| 584 if (isHTMLInputElement(*node)) { | 583 if (isHTMLInputElement(*node)) { |
| 585 HTMLInputElement* input = toHTMLInputElement(node); | 584 HTMLInputElement* input = toHTMLInputElement(node); |
| 586 return input->isText() || input->isNumberField(); | 585 return input->isText() || input->type() == InputTypeNames::number; |
| 587 } | 586 } |
| 588 | 587 |
| 589 return false; | 588 return false; |
| 590 } | 589 } |
| 591 | 590 |
| 592 bool AXNodeObject::isNonNativeTextControl() const | 591 bool AXNodeObject::isNonNativeTextControl() const |
| 593 { | 592 { |
| 594 if (isNativeTextControl()) | 593 if (isNativeTextControl()) |
| 595 return false; | 594 return false; |
| 596 | 595 |
| 597 if (hasContentEditableAttributeSet()) | 596 if (hasContentEditableAttributeSet()) |
| 598 return true; | 597 return true; |
| 599 | 598 |
| 600 if (isARIATextControl()) | 599 if (isARIATextControl()) |
| 601 return true; | 600 return true; |
| 602 | 601 |
| 603 return false; | 602 return false; |
| 604 } | 603 } |
| 605 | 604 |
| 606 bool AXNodeObject::isPasswordField() const | 605 bool AXNodeObject::isPasswordField() const |
| 607 { | 606 { |
| 608 Node* node = this->node(); | 607 Node* node = this->node(); |
| 609 if (!isHTMLInputElement(node)) | 608 if (!isHTMLInputElement(node)) |
| 610 return false; | 609 return false; |
| 611 | 610 |
| 612 if (ariaRoleAttribute() != UnknownRole) | 611 if (ariaRoleAttribute() != UnknownRole) |
| 613 return false; | 612 return false; |
| 614 | 613 |
| 615 return toHTMLInputElement(node)->isPasswordField(); | 614 return toHTMLInputElement(node)->type() == InputTypeNames::password; |
| 616 } | 615 } |
| 617 | 616 |
| 618 bool AXNodeObject::isProgressIndicator() const | 617 bool AXNodeObject::isProgressIndicator() const |
| 619 { | 618 { |
| 620 return roleValue() == ProgressIndicatorRole; | 619 return roleValue() == ProgressIndicatorRole; |
| 621 } | 620 } |
| 622 | 621 |
| 623 bool AXNodeObject::isSlider() const | 622 bool AXNodeObject::isSlider() const |
| 624 { | 623 { |
| 625 return roleValue() == SliderRole; | 624 return roleValue() == SliderRole; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 return getAttribute(aria_valuetextAttr).string(); | 948 return getAttribute(aria_valuetextAttr).string(); |
| 950 } | 949 } |
| 951 | 950 |
| 952 float AXNodeObject::valueForRange() const | 951 float AXNodeObject::valueForRange() const |
| 953 { | 952 { |
| 954 if (hasAttribute(aria_valuenowAttr)) | 953 if (hasAttribute(aria_valuenowAttr)) |
| 955 return getAttribute(aria_valuenowAttr).toFloat(); | 954 return getAttribute(aria_valuenowAttr).toFloat(); |
| 956 | 955 |
| 957 if (isHTMLInputElement(node())) { | 956 if (isHTMLInputElement(node())) { |
| 958 HTMLInputElement& input = toHTMLInputElement(*node()); | 957 HTMLInputElement& input = toHTMLInputElement(*node()); |
| 959 if (input.isRangeControl()) | 958 if (input.type() == InputTypeNames::range) |
| 960 return input.valueAsNumber(); | 959 return input.valueAsNumber(); |
| 961 } | 960 } |
| 962 | 961 |
| 963 return 0.0; | 962 return 0.0; |
| 964 } | 963 } |
| 965 | 964 |
| 966 float AXNodeObject::maxValueForRange() const | 965 float AXNodeObject::maxValueForRange() const |
| 967 { | 966 { |
| 968 if (hasAttribute(aria_valuemaxAttr)) | 967 if (hasAttribute(aria_valuemaxAttr)) |
| 969 return getAttribute(aria_valuemaxAttr).toFloat(); | 968 return getAttribute(aria_valuemaxAttr).toFloat(); |
| 970 | 969 |
| 971 if (isHTMLInputElement(node())) { | 970 if (isHTMLInputElement(node())) { |
| 972 HTMLInputElement& input = toHTMLInputElement(*node()); | 971 HTMLInputElement& input = toHTMLInputElement(*node()); |
| 973 if (input.isRangeControl()) | 972 if (input.type() == InputTypeNames::range) |
| 974 return input.maximum(); | 973 return input.maximum(); |
| 975 } | 974 } |
| 976 | 975 |
| 977 return 0.0; | 976 return 0.0; |
| 978 } | 977 } |
| 979 | 978 |
| 980 float AXNodeObject::minValueForRange() const | 979 float AXNodeObject::minValueForRange() const |
| 981 { | 980 { |
| 982 if (hasAttribute(aria_valueminAttr)) | 981 if (hasAttribute(aria_valueminAttr)) |
| 983 return getAttribute(aria_valueminAttr).toFloat(); | 982 return getAttribute(aria_valueminAttr).toFloat(); |
| 984 | 983 |
| 985 if (isHTMLInputElement(node())) { | 984 if (isHTMLInputElement(node())) { |
| 986 HTMLInputElement& input = toHTMLInputElement(*node()); | 985 HTMLInputElement& input = toHTMLInputElement(*node()); |
| 987 if (input.isRangeControl()) | 986 if (input.type() == InputTypeNames::range) |
| 988 return input.minimum(); | 987 return input.minimum(); |
| 989 } | 988 } |
| 990 | 989 |
| 991 return 0.0; | 990 return 0.0; |
| 992 } | 991 } |
| 993 | 992 |
| 994 float AXNodeObject::stepValueForRange() const | 993 float AXNodeObject::stepValueForRange() const |
| 995 { | 994 { |
| 996 return getAttribute(stepAttr).toFloat(); | 995 return getAttribute(stepAttr).toFloat(); |
| 997 } | 996 } |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 float range = maxValueForRange() - minValueForRange(); | 1698 float range = maxValueForRange() - minValueForRange(); |
| 1700 float value = valueForRange(); | 1699 float value = valueForRange(); |
| 1701 | 1700 |
| 1702 value += range * (percentChange / 100); | 1701 value += range * (percentChange / 100); |
| 1703 setValue(String::number(value)); | 1702 setValue(String::number(value)); |
| 1704 | 1703 |
| 1705 axObjectCache()->postNotification(node(), AXObjectCache::AXValueChanged, tru
e); | 1704 axObjectCache()->postNotification(node(), AXObjectCache::AXValueChanged, tru
e); |
| 1706 } | 1705 } |
| 1707 | 1706 |
| 1708 } // namespace blink | 1707 } // namespace blink |
| OLD | NEW |