AX: Meter: [Mac] Content in label element should be used as AXTitle or AXDescription
https://bugs.webkit.org/show_bug.cgi?id=162586

Reviewed by Chris Fleizach.

Source/WebCore:

Exposed the label element's text as AXDescription for meter elements.
Also refactored the code for fetching the label element's text and taken care of
the case where aria-label and aria-labelledby attributes are used on label elements.

Test: accessibility/mac/meter-with-label-element.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isLabelable):
(WebCore::AccessibilityNodeObject::textForLabelElement):
(WebCore::AccessibilityNodeObject::titleElementText):
(WebCore::AccessibilityNodeObject::title):
(WebCore::AccessibilityNodeObject::usesAltTagForTextComputation): Deleted.
* accessibility/AccessibilityNodeObject.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::exposesTitleUIElement):

LayoutTests:

* accessibility/mac/aria-label-on-label-element-expected.txt:
* accessibility/mac/aria-label-on-label-element.html:
* accessibility/mac/meter-with-label-element-expected.txt: Added.
* accessibility/mac/meter-with-label-element.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@206581 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/accessibility/mac/aria-label-on-label-element.html b/LayoutTests/accessibility/mac/aria-label-on-label-element.html
index 5a91181..e8c3908 100644
--- a/LayoutTests/accessibility/mac/aria-label-on-label-element.html
+++ b/LayoutTests/accessibility/mac/aria-label-on-label-element.html
@@ -14,6 +14,11 @@
 <label id="label3" for="input3" hidden aria-label="hidden aria label">hidden text</label>
 <input id="input3" type="text">
 
+<p id="p1">aria</p>
+<p id="p2">labelledby</p>
+<label for="input4" aria-labelledby="p1 p2">Some text</label>
+<input id="input4" type="text" size=20>
+
 <p id="description"></p>
 <div id="console"></div>
 
@@ -37,6 +42,10 @@
         // Make sure when the input element has no rendered label, it won't cause crash.
         var input3 = accessibilityController.accessibleElementById("input3");
         shouldBe("input3.title", "'AXTitle: hidden aria label'");
+        
+        // aria-labelledby also works.
+        var input4 = accessibilityController.accessibleElementById("input4");
+        shouldBe("input4.title", "'AXTitle: aria labelledby'");
     }
 
 </script>