Bug 1445968 Accessible: factorize and optimize testing for password role r=surkov

--HG--
extra : rebase_source : 5f945bab6c2c86d059893082f9f04d6ac4492f73
This commit is contained in:
Samuel Thibault 2018-03-16 13:02:00 +02:00
Родитель 48957d62c0
Коммит 6f09cb80ba
5 изменённых файлов: 27 добавлений и 6 удалений

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

@ -130,7 +130,7 @@ static void
ConvertTexttoAsterisks(AccessibleWrap* accWrap, nsAString& aString) ConvertTexttoAsterisks(AccessibleWrap* accWrap, nsAString& aString)
{ {
// convert each char to "*" when it's "password text" // convert each char to "*" when it's "password text"
if (accWrap->NativeRole() == roles::PASSWORD_TEXT) { if (accWrap->IsPassword()) {
DOMtoATK::ConvertTexttoAsterisks(aString); DOMtoATK::ConvertTexttoAsterisks(aString);
} }
} }
@ -148,7 +148,7 @@ getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
return nullptr; return nullptr;
return DOMtoATK::NewATKString(text, aStartOffset, aEndOffset, return DOMtoATK::NewATKString(text, aStartOffset, aEndOffset,
accWrap->NativeRole() == roles::PASSWORD_TEXT ? accWrap->IsPassword() ?
DOMtoATK::AtkStringConvertFlags::ConvertTextToAsterisks : DOMtoATK::AtkStringConvertFlags::ConvertTextToAsterisks :
DOMtoATK::AtkStringConvertFlags::None); DOMtoATK::AtkStringConvertFlags::None);

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

@ -39,6 +39,7 @@ enum AccType {
eHTMLTableCellType, eHTMLTableCellType,
eHTMLTableRowType, eHTMLTableRowType,
eHTMLTextFieldType, eHTMLTextFieldType,
eHTMLTextPasswordFieldType,
eHyperTextType, eHyperTextType,
eImageType, eImageType,
eOuterDocType, eOuterDocType,

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

@ -649,7 +649,10 @@ public:
bool IsTableRow() const { return HasGenericType(eTableRow); } bool IsTableRow() const { return HasGenericType(eTableRow); }
bool IsTextField() const { return mType == eHTMLTextFieldType; } bool IsTextField() const { return mType == eHTMLTextFieldType ||
mType == eHTMLTextPasswordFieldType; }
bool IsPassword() const { return mType == eHTMLTextPasswordFieldType; }
bool IsText() const { return mGenericTypes & eText; } bool IsText() const { return mGenericTypes & eText; }

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

@ -282,14 +282,16 @@ HTMLTextFieldAccessible::
HTMLTextFieldAccessible(nsIContent* aContent, DocAccessible* aDoc) : HTMLTextFieldAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc) HyperTextAccessibleWrap(aContent, aDoc)
{ {
mType = eHTMLTextFieldType; mType = mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::password, eIgnoreCase) ?
eHTMLTextPasswordFieldType :
eHTMLTextFieldType;
} }
role role
HTMLTextFieldAccessible::NativeRole() HTMLTextFieldAccessible::NativeRole()
{ {
if (mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, if (mType == eHTMLTextPasswordFieldType) {
nsGkAtoms::password, eIgnoreCase)) {
return roles::PASSWORD_TEXT; return roles::PASSWORD_TEXT;
} }

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

@ -87,6 +87,14 @@
this.__proto__ = new changeAttr(aID, "aria-multiselectable", "true"); this.__proto__ = new changeAttr(aID, "aria-multiselectable", "true");
} }
function changeTypeToPassword(aID) {
this.__proto__ = new changeAttr(aID, "type", "password");
}
function changeTypeToText(aID) {
this.__proto__ = new changeAttr(aID, "type", "text");
}
// ////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////
// Test // Test
@ -113,6 +121,10 @@
// recreate an accessible by aria-multiselectable change // recreate an accessible by aria-multiselectable change
gQueue.push(new changeMultiselectable("div3")); gQueue.push(new changeMultiselectable("div3"));
// recreate an accessible by type
gQueue.push(new changeTypeToText("password"));
gQueue.push(new changeTypeToPassword("text"));
gQueue.invoke(); // SimpleTest.finish() will be called in the end gQueue.invoke(); // SimpleTest.finish() will be called in the end
} }
@ -139,5 +151,8 @@
<div id="div3" role="listbox">list</div> <div id="div3" role="listbox">list</div>
<div id="eventdump"></div> <div id="eventdump"></div>
<form><input type="password" id="password"/></form>
<form><input type="text" id="text"/></form>
</body> </body>
</html> </html>