Bug 691267 - Remove nsHTMLButtonAccessible duplication, r=surkov

--HG--
rename : accessible/tests/mochitest/actions/test_inputs.html => accessible/tests/mochitest/actions/test_controls.html
This commit is contained in:
Andrew Quartey 2012-02-22 20:33:37 +09:00
Родитель ad87cc26c2
Коммит 61bb7df447
10 изменённых файлов: 31 добавлений и 132 удалений

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

@ -90,10 +90,6 @@ public:
*/
virtual already_AddRefed<nsAccessible>
CreateHTMLBRAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
virtual already_AddRefed<nsAccessible>
CreateHTML4ButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
virtual already_AddRefed<nsAccessible>
CreateHTMLButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
virtual already_AddRefed<nsAccessible>
CreateHTMLCaptionAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
virtual already_AddRefed<nsAccessible>

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

@ -217,17 +217,6 @@ nsAccessibilityService::CreateOuterDocAccessible(nsIContent* aContent,
return accessible;
}
already_AddRefed<nsAccessible>
nsAccessibilityService::CreateHTML4ButtonAccessible(nsIContent* aContent,
nsIPresShell* aPresShell)
{
nsAccessible* accessible =
new nsHTML4ButtonAccessible(aContent,
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible);
return accessible;
}
already_AddRefed<nsAccessible>
nsAccessibilityService::CreateHTMLButtonAccessible(nsIContent* aContent,
nsIPresShell* aPresShell)

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

@ -89,13 +89,10 @@ public:
// nsIAccessibilityService
virtual nsAccessible* GetRootDocumentAccessible(nsIPresShell* aPresShell,
bool aCanCreate);
already_AddRefed<nsAccessible>
CreateHTMLButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
virtual already_AddRefed<nsAccessible>
CreateHTMLBRAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
virtual already_AddRefed<nsAccessible>
CreateHTML4ButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
virtual already_AddRefed<nsAccessible>
CreateHTMLButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
already_AddRefed<nsAccessible>
CreateHTMLCanvasAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
virtual already_AddRefed<nsAccessible>

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

@ -314,7 +314,7 @@ nsresult
nsHTMLButtonAccessible::GetNameInternal(nsAString& aName)
{
nsAccessible::GetNameInternal(aName);
if (!aName.IsEmpty())
if (!aName.IsEmpty() || mContent->Tag() != nsGkAtoms::input)
return NS_OK;
// No name from HTML or ARIA
@ -353,71 +353,6 @@ nsHTMLButtonAccessible::IsWidget() const
}
////////////////////////////////////////////////////////////////////////////////
// nsHTML4ButtonAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTML4ButtonAccessible::
nsHTML4ButtonAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
nsHyperTextAccessibleWrap(aContent, aDoc)
{
}
PRUint8
nsHTML4ButtonAccessible::ActionCount()
{
return 1;
}
NS_IMETHODIMP nsHTML4ButtonAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
{
if (aIndex == eAction_Click) {
aName.AssignLiteral("press");
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsHTML4ButtonAccessible::DoAction(PRUint8 aIndex)
{
if (aIndex != 0)
return NS_ERROR_INVALID_ARG;
DoCommand();
return NS_OK;
}
role
nsHTML4ButtonAccessible::NativeRole()
{
return roles::PUSHBUTTON;
}
PRUint64
nsHTML4ButtonAccessible::NativeState()
{
PRUint64 state = nsHyperTextAccessibleWrap::NativeState();
state |= states::FOCUSABLE;
nsEventStates elmState = mContent->AsElement()->State();
if (elmState.HasState(NS_EVENT_STATE_DEFAULT))
state |= states::DEFAULT;
return state;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTML4ButtonAccessible: Widgets
bool
nsHTML4ButtonAccessible::IsWidget() const
{
return true;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLTextFieldAccessible
////////////////////////////////////////////////////////////////////////////////

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

@ -92,7 +92,7 @@ public:
/**
* Accessible for HTML input@type="button", @type="submit", @type="image"
* elements.
* and HTML button elements.
*/
class nsHTMLButtonAccessible : public nsHyperTextAccessibleWrap
{
@ -120,33 +120,6 @@ public:
};
/**
* Accessible for HTML button element.
*/
class nsHTML4ButtonAccessible : public nsHyperTextAccessibleWrap
{
public:
enum { eAction_Click = 0 };
nsHTML4ButtonAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 index);
// nsAccessible
virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState();
// ActionAccessible
virtual PRUint8 ActionCount();
// Widgets
virtual bool IsWidget() const;
};
/**
* Accessible for HTML input@type="text" element.
*/

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

@ -50,7 +50,7 @@ _TEST_FILES =\
test_aria.html \
test_general.html \
test_general.xul \
test_inputs.html \
test_controls.html \
test_keys_menu.xul \
test_keys.html \
test_link.html \

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

@ -25,6 +25,11 @@
actionName: "press",
events: CLICK_EVENTS
},
{
ID: "input_button",
actionName: "press",
events: CLICK_EVENTS
},
{
ID: "checkbox_unchecked",
actionName: "check",
@ -68,7 +73,9 @@
<pre id="test">
</pre>
<button id="button" value="button">Button</button>
<button id="button">Button</button>
<input id="input_button" type="button" value="normal">
<input id="checkbox_unchecked" type="checkbox">Checkbox</input>

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

@ -17,14 +17,16 @@
function doTest()
{
// Default state.
testStates("f1_image", STATE_DEFAULT);
testStates("f2_submit", STATE_DEFAULT);
testStates("f3_submitbutton", STATE_DEFAULT);
testStates("f4_button", 0, 0, STATE_DEFAULT);
testStates("f4_image1", STATE_DEFAULT);
testStates("f4_image2", 0, 0, STATE_DEFAULT);
testStates("f4_submit", 0, 0, STATE_DEFAULT);
testStates("f4_submitbutton", 0, 0, STATE_DEFAULT);
testStates("f1_image", STATE_DEFAULT | STATE_FOCUSABLE);
testStates("f2_submit", STATE_DEFAULT | STATE_FOCUSABLE);
testStates("f3_submitbutton", STATE_DEFAULT | STATE_FOCUSABLE);
testStates("f3_disabled_reset", STATE_UNAVAILABLE, 0, STATE_FOCUSABLE, 0);
testStates("f4_button", STATE_FOCUSABLE, 0, STATE_DEFAULT);
testStates("f4_disabled_button", STATE_UNAVAILABLE, 0, STATE_FOCUSABLE, 0);
testStates("f4_image1", STATE_DEFAULT | STATE_FOCUSABLE);
testStates("f4_image2", STATE_FOCUSABLE, 0, STATE_DEFAULT);
testStates("f4_submit", STATE_FOCUSABLE, 0, STATE_DEFAULT);
testStates("f4_submitbutton", STATE_FOCUSABLE, 0, STATE_DEFAULT);
SimpleTest.finish();
}
@ -62,6 +64,7 @@
<form name="form3" method="get">
<input type="text" name="hi">
<button id="f3_submitbutton" type="submit">submit</button>
<button id="f3_disabled_reset" type="reset" disabled>reset</button>
</form>
<p>A form with normal button, two image buttons, submit button,
@ -69,6 +72,7 @@
<form name="form4" method="get">
<input type="text" name="hi">
<input id="f4_button" type="button" value="normal" name="normal-button">
<input id="f4_disabled_button" type="button" value="disabled" name="disabled-button" disabled>
<input id="f4_image1" type="image" value="image-button1" name="image-button1">
<input id="f4_image2" type="image" value="image-button2" name="image-button2">
<input id="f4_submit" type="submit" value="real-submit" name="real-submit">

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

@ -115,9 +115,8 @@ nsHTMLButtonControlFrame::CreateAccessible()
{
nsAccessibilityService* accService = nsIPresShell::AccService();
if (accService) {
return IsInput() ?
accService->CreateHTMLButtonAccessible(mContent, PresContext()->PresShell()) :
accService->CreateHTML4ButtonAccessible(mContent, PresContext()->PresShell());
return accService->CreateHTMLButtonAccessible(mContent,
PresContext()->PresShell());
}
return nsnull;

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

@ -166,11 +166,10 @@ nsImageControlFrame::CreateAccessible()
{
nsAccessibilityService* accService = nsIPresShell::AccService();
if (accService) {
if (mContent->Tag() == nsGkAtoms::button) {
return accService->CreateHTML4ButtonAccessible(mContent, PresContext()->PresShell());
}
else if (mContent->Tag() == nsGkAtoms::input) {
return accService->CreateHTMLButtonAccessible(mContent, PresContext()->PresShell());
if (mContent->Tag() == nsGkAtoms::button ||
mContent->Tag() == nsGkAtoms::input) {
return accService->CreateHTMLButtonAccessible(mContent,
PresContext()->PresShell());
}
}