Bug 604391 - Expose placeholder as name if name is otherwise empty. r=surkov,marcoz a=davidb

This commit is contained in:
David Bolter 2010-11-08 08:33:25 -05:00
Родитель 4a22706dfd
Коммит 8a583f6f32
3 изменённых файлов: 43 добавлений и 8 удалений

Просмотреть файл

@ -196,6 +196,7 @@ ACCESSIBILITY_ATOM(multiline, "multiline") // XUL
ACCESSIBILITY_ATOM(name, "name")
ACCESSIBILITY_ATOM(onclick, "onclick")
ACCESSIBILITY_ATOM(popup, "popup")
ACCESSIBILITY_ATOM(placeholder, "placeholder")
ACCESSIBILITY_ATOM(readonly, "readonly")
ACCESSIBILITY_ATOM(scope, "scope") // HTML table
ACCESSIBILITY_ATOM(seltype, "seltype") // XUL listbox

Просмотреть файл

@ -412,16 +412,24 @@ nsHTMLTextFieldAccessible::GetNameInternal(nsAString& aName)
if (!aName.IsEmpty())
return NS_OK;
if (!mContent->GetBindingParent())
if (mContent->GetBindingParent())
{
// XXX: bug 459640
// There's a binding parent.
// This means we're part of another control, so use parent accessible for name.
// This ensures that a textbox inside of a XUL widget gets
// an accessible name.
nsAccessible* parent = GetParent();
parent->GetName(aName);
}
if (!aName.IsEmpty())
return NS_OK;
// XXX: bug 459640
// There's a binding parent.
// This means we're part of another control, so use parent accessible for name.
// This ensures that a textbox inside of a XUL widget gets
// an accessible name.
nsAccessible* parent = GetParent();
return parent ? parent->GetName(aName) : NS_OK;
// text inputs and textareas might have useful placeholder text
mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::placeholder, aName);
return NS_OK;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetValue(nsAString& _retval)

Просмотреть файл

@ -176,6 +176,14 @@
testName("textboxinend", "This day was sunny");
testName("textbox2", "This day was");
// placeholder
testName("ph_password", "a placeholder");
testName("ph_text", "a placeholder");
testName("ph_textarea", "a placeholder");
testName("ph_text2", "a label");
testName("ph_textarea2", "a label");
testName("ph_text3", "a label");
SimpleTest.finish();
}
@ -196,6 +204,11 @@
href="https://bugzilla.mozilla.org/show_bug.cgi?id=530081"
title="Clean up our tree walker ">
Mozilla Bug 530081
</a><br>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=604391"
title="Use placeholder as name if name is otherwise empty">
Mozilla Bug 604391
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -421,5 +434,18 @@
</label>
</form>
<!-- placeholder -->
<input id="ph_password" type="password" value="" placeholder="a placeholder" />
<input id="ph_text" type="text" placeholder="a placeholder" />
<textarea id="ph_textarea" cols="5" placeholder="a placeholder"></textarea>
<!-- placeholder does not win -->
<input id="ph_text2" type="text" aria-label="a label" placeholder="meh" />
<textarea id="ph_textarea2" cols="5" aria-labelledby="ph_text2"
placeholder="meh"></textarea>
<label for="ph_text3">a label</label>
<input id="ph_text3" placeholder="meh" />
</body>
</html>