| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "core/html/HTMLMeterElement.h" | 48 #include "core/html/HTMLMeterElement.h" |
| 49 #include "core/html/HTMLPlugInElement.h" | 49 #include "core/html/HTMLPlugInElement.h" |
| 50 #include "core/html/HTMLSelectElement.h" | 50 #include "core/html/HTMLSelectElement.h" |
| 51 #include "core/html/HTMLTableCaptionElement.h" | 51 #include "core/html/HTMLTableCaptionElement.h" |
| 52 #include "core/html/HTMLTableCellElement.h" | 52 #include "core/html/HTMLTableCellElement.h" |
| 53 #include "core/html/HTMLTableElement.h" | 53 #include "core/html/HTMLTableElement.h" |
| 54 #include "core/html/HTMLTableRowElement.h" | 54 #include "core/html/HTMLTableRowElement.h" |
| 55 #include "core/html/HTMLTableSectionElement.h" | 55 #include "core/html/HTMLTableSectionElement.h" |
| 56 #include "core/html/HTMLTextAreaElement.h" | 56 #include "core/html/HTMLTextAreaElement.h" |
| 57 #include "core/html/LabelsNodeList.h" | 57 #include "core/html/LabelsNodeList.h" |
| 58 #include "core/html/TextControlElement.h" |
| 58 #include "core/html/parser/HTMLParserIdioms.h" | 59 #include "core/html/parser/HTMLParserIdioms.h" |
| 59 #include "core/html/shadow/MediaControlElements.h" | 60 #include "core/html/shadow/MediaControlElements.h" |
| 60 #include "core/layout/LayoutBlockFlow.h" | 61 #include "core/layout/LayoutBlockFlow.h" |
| 61 #include "core/layout/LayoutObject.h" | 62 #include "core/layout/LayoutObject.h" |
| 62 #include "core/svg/SVGElement.h" | 63 #include "core/svg/SVGElement.h" |
| 63 #include "modules/accessibility/AXObjectCacheImpl.h" | 64 #include "modules/accessibility/AXObjectCacheImpl.h" |
| 64 #include "platform/UserGestureIndicator.h" | 65 #include "platform/UserGestureIndicator.h" |
| 65 #include "platform/text/PlatformLocale.h" | 66 #include "platform/text/PlatformLocale.h" |
| 66 #include "wtf/text/StringBuilder.h" | 67 #include "wtf/text/StringBuilder.h" |
| 67 | 68 |
| (...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 } | 2363 } |
| 2363 | 2364 |
| 2364 // 5.1 Text inputs - step 3 (placeholder attribute) | 2365 // 5.1 Text inputs - step 3 (placeholder attribute) |
| 2365 if (htmlElement && htmlElement->isTextControl()) { | 2366 if (htmlElement && htmlElement->isTextControl()) { |
| 2366 nameFrom = AXNameFromPlaceholder; | 2367 nameFrom = AXNameFromPlaceholder; |
| 2367 if (nameSources) { | 2368 if (nameSources) { |
| 2368 nameSources->append(NameSource(*foundTextAlternative, placeholderAttr)); | 2369 nameSources->append(NameSource(*foundTextAlternative, placeholderAttr)); |
| 2369 NameSource& source = nameSources->back(); | 2370 NameSource& source = nameSources->back(); |
| 2370 source.type = nameFrom; | 2371 source.type = nameFrom; |
| 2371 } | 2372 } |
| 2372 HTMLElement* element = toHTMLElement(getNode()); | 2373 const String placeholder = placeholderFromNativeAttribute(); |
| 2373 const AtomicString& placeholder = | |
| 2374 element->fastGetAttribute(placeholderAttr); | |
| 2375 if (!placeholder.isEmpty()) { | 2374 if (!placeholder.isEmpty()) { |
| 2376 textAlternative = placeholder; | 2375 textAlternative = placeholder; |
| 2377 if (nameSources) { | 2376 if (nameSources) { |
| 2378 NameSource& source = nameSources->back(); | 2377 NameSource& source = nameSources->back(); |
| 2379 source.text = textAlternative; | 2378 source.text = textAlternative; |
| 2380 source.attributeValue = placeholder; | 2379 source.attributeValue = htmlElement->fastGetAttribute(placeholderAttr); |
| 2380 *foundTextAlternative = true; |
| 2381 } else { | 2381 } else { |
| 2382 return textAlternative; | 2382 return textAlternative; |
| 2383 } | 2383 } |
| 2384 } | 2384 } |
| 2385 |
| 2386 // Also check for aria-placeholder. |
| 2387 nameFrom = AXNameFromPlaceholder; |
| 2388 if (nameSources) { |
| 2389 nameSources->append( |
| 2390 NameSource(*foundTextAlternative, aria_placeholderAttr)); |
| 2391 NameSource& source = nameSources->back(); |
| 2392 source.type = nameFrom; |
| 2393 } |
| 2394 const AtomicString& ariaPlaceholder = |
| 2395 htmlElement->fastGetAttribute(aria_placeholderAttr); |
| 2396 if (!ariaPlaceholder.isEmpty()) { |
| 2397 textAlternative = ariaPlaceholder; |
| 2398 if (nameSources) { |
| 2399 NameSource& source = nameSources->back(); |
| 2400 source.text = textAlternative; |
| 2401 source.attributeValue = ariaPlaceholder; |
| 2402 *foundTextAlternative = true; |
| 2403 } else { |
| 2404 return textAlternative; |
| 2405 } |
| 2406 } |
| 2407 |
| 2385 return textAlternative; | 2408 return textAlternative; |
| 2386 } | 2409 } |
| 2387 | 2410 |
| 2388 // 5.7 figure and figcaption Elements | 2411 // 5.7 figure and figcaption Elements |
| 2389 if (getNode()->hasTagName(figureTag)) { | 2412 if (getNode()->hasTagName(figureTag)) { |
| 2390 // figcaption | 2413 // figcaption |
| 2391 nameFrom = AXNameFromRelatedElement; | 2414 nameFrom = AXNameFromRelatedElement; |
| 2392 if (nameSources) { | 2415 if (nameSources) { |
| 2393 nameSources->append(NameSource(*foundTextAlternative)); | 2416 nameSources->append(NameSource(*foundTextAlternative)); |
| 2394 nameSources->back().type = nameFrom; | 2417 nameSources->back().type = nameFrom; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2694 source.text = description; | 2717 source.text = description; |
| 2695 foundDescription = true; | 2718 foundDescription = true; |
| 2696 } else { | 2719 } else { |
| 2697 return description; | 2720 return description; |
| 2698 } | 2721 } |
| 2699 } else if (descriptionSources) { | 2722 } else if (descriptionSources) { |
| 2700 descriptionSources->back().invalid = true; | 2723 descriptionSources->back().invalid = true; |
| 2701 } | 2724 } |
| 2702 } | 2725 } |
| 2703 | 2726 |
| 2704 HTMLElement* htmlElement = nullptr; | |
| 2705 if (getNode()->isHTMLElement()) | |
| 2706 htmlElement = toHTMLElement(getNode()); | |
| 2707 | |
| 2708 // placeholder, 5.1.2 from: | |
| 2709 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html | |
| 2710 if (nameFrom != AXNameFromPlaceholder && htmlElement && | |
| 2711 htmlElement->isTextControl()) { | |
| 2712 descriptionFrom = AXDescriptionFromPlaceholder; | |
| 2713 if (descriptionSources) { | |
| 2714 descriptionSources->append( | |
| 2715 DescriptionSource(foundDescription, placeholderAttr)); | |
| 2716 DescriptionSource& source = descriptionSources->back(); | |
| 2717 source.type = descriptionFrom; | |
| 2718 } | |
| 2719 HTMLElement* element = toHTMLElement(getNode()); | |
| 2720 const AtomicString& placeholder = | |
| 2721 element->fastGetAttribute(placeholderAttr); | |
| 2722 if (!placeholder.isEmpty()) { | |
| 2723 description = placeholder; | |
| 2724 if (descriptionSources) { | |
| 2725 DescriptionSource& source = descriptionSources->back(); | |
| 2726 source.text = description; | |
| 2727 source.attributeValue = placeholder; | |
| 2728 foundDescription = true; | |
| 2729 } else { | |
| 2730 return description; | |
| 2731 } | |
| 2732 } | |
| 2733 } | |
| 2734 | |
| 2735 const HTMLInputElement* inputElement = nullptr; | 2727 const HTMLInputElement* inputElement = nullptr; |
| 2736 if (isHTMLInputElement(getNode())) | 2728 if (isHTMLInputElement(getNode())) |
| 2737 inputElement = toHTMLInputElement(getNode()); | 2729 inputElement = toHTMLInputElement(getNode()); |
| 2738 | 2730 |
| 2739 // value, 5.2.2 from: http://rawgit.com/w3c/aria/master/html-aam/html-aam.html | 2731 // value, 5.2.2 from: http://rawgit.com/w3c/aria/master/html-aam/html-aam.html |
| 2740 if (nameFrom != AXNameFromValue && inputElement && | 2732 if (nameFrom != AXNameFromValue && inputElement && |
| 2741 inputElement->isTextButton()) { | 2733 inputElement->isTextButton()) { |
| 2742 descriptionFrom = AXDescriptionFromAttribute; | 2734 descriptionFrom = AXDescriptionFromAttribute; |
| 2743 if (descriptionSources) { | 2735 if (descriptionSources) { |
| 2744 descriptionSources->append( | 2736 descriptionSources->append( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2867 if (!descriptionSource.relatedObjects.isEmpty()) | 2859 if (!descriptionSource.relatedObjects.isEmpty()) |
| 2868 *relatedObjects = descriptionSource.relatedObjects; | 2860 *relatedObjects = descriptionSource.relatedObjects; |
| 2869 return descriptionSource.text; | 2861 return descriptionSource.text; |
| 2870 } | 2862 } |
| 2871 } | 2863 } |
| 2872 } | 2864 } |
| 2873 | 2865 |
| 2874 return String(); | 2866 return String(); |
| 2875 } | 2867 } |
| 2876 | 2868 |
| 2877 String AXNodeObject::placeholder(AXNameFrom nameFrom, | 2869 String AXNodeObject::placeholder(AXNameFrom nameFrom) const { |
| 2878 AXDescriptionFrom descriptionFrom) const { | |
| 2879 if (nameFrom == AXNameFromPlaceholder) | 2870 if (nameFrom == AXNameFromPlaceholder) |
| 2880 return String(); | 2871 return String(); |
| 2881 | 2872 |
| 2882 if (descriptionFrom == AXDescriptionFromPlaceholder) | 2873 Node* node = getNode(); |
| 2874 if (!node || !node->isHTMLElement()) |
| 2883 return String(); | 2875 return String(); |
| 2884 | 2876 |
| 2885 if (!getNode()) | 2877 String nativePlaceholder = placeholderFromNativeAttribute(); |
| 2878 if (!nativePlaceholder.isEmpty()) |
| 2879 return nativePlaceholder; |
| 2880 |
| 2881 const AtomicString& ariaPlaceholder = |
| 2882 toHTMLElement(node)->fastGetAttribute(aria_placeholderAttr); |
| 2883 if (!ariaPlaceholder.isEmpty()) |
| 2884 return ariaPlaceholder; |
| 2885 |
| 2886 return String(); |
| 2887 } |
| 2888 |
| 2889 String AXNodeObject::placeholderFromNativeAttribute() const { |
| 2890 Node* node = getNode(); |
| 2891 if (!node || !isTextControlElement(node)) |
| 2886 return String(); | 2892 return String(); |
| 2887 | 2893 return toTextControlElement(node)->strippedPlaceholder(); |
| 2888 String placeholder; | |
| 2889 if (isHTMLInputElement(*getNode())) { | |
| 2890 HTMLInputElement* inputElement = toHTMLInputElement(getNode()); | |
| 2891 placeholder = inputElement->strippedPlaceholder(); | |
| 2892 } else if (isHTMLTextAreaElement(*getNode())) { | |
| 2893 HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(getNode()); | |
| 2894 placeholder = textAreaElement->strippedPlaceholder(); | |
| 2895 } | |
| 2896 return placeholder; | |
| 2897 } | 2894 } |
| 2898 | 2895 |
| 2899 DEFINE_TRACE(AXNodeObject) { | 2896 DEFINE_TRACE(AXNodeObject) { |
| 2900 visitor->trace(m_node); | 2897 visitor->trace(m_node); |
| 2901 AXObject::trace(visitor); | 2898 AXObject::trace(visitor); |
| 2902 } | 2899 } |
| 2903 | 2900 |
| 2904 } // namespace blink | 2901 } // namespace blink |
| OLD | NEW |