зеркало из https://github.com/mozilla/pjs.git
Bug 506616 - remove all the code in #ifdef COMBO_BOX_WITH_THREE_CHILDREN, r=davidb
This commit is contained in:
Родитель
fa04e04dde
Коммит
76e687b770
|
@ -61,14 +61,8 @@
|
|||
*
|
||||
* Comboboxes:
|
||||
* - nsHTMLComboboxAccessible
|
||||
* - nsHTMLComboboxTextFieldAccessible (#ifdef COMBO_BOX_WITH_THREE_CHILDREN)
|
||||
* - nsHTMLComboboxButtonAccessible (#ifdef COMBO_BOX_WITH_THREE_CHILDREN)
|
||||
* - nsHTMLComboboxListAccessible [ inserted in accessible tree ]
|
||||
* - nsHTMLSelectOptionAccessible(s)
|
||||
*
|
||||
* XXX COMBO_BOX_WITH_THREE_CHILDREN is not currently defined.
|
||||
* If we start using it again, we should pass the correct frame into those accessibles.
|
||||
* They share a DOM node with the parent combobox.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -982,30 +976,6 @@ void nsHTMLComboboxAccessible::CacheChildren()
|
|||
|
||||
if (mAccChildCount == eChildCountUninitialized) {
|
||||
mAccChildCount = 0;
|
||||
#ifdef COMBO_BOX_WITH_THREE_CHILDREN
|
||||
// We no longer create textfield and button accessible, in order to have
|
||||
// harmonization between IAccessible2, ATK/AT-SPI and OS X
|
||||
nsHTMLComboboxTextFieldAccessible* textFieldAccessible =
|
||||
new nsHTMLComboboxTextFieldAccessible(this, mDOMNode, mWeakShell);
|
||||
SetFirstChild(textFieldAccessible);
|
||||
if (!textFieldAccessible) {
|
||||
return;
|
||||
}
|
||||
textFieldAccessible->SetParent(this);
|
||||
textFieldAccessible->Init();
|
||||
mAccChildCount = 1; // Textfield accessible child successfully added
|
||||
|
||||
nsHTMLComboboxButtonAccessible* buttonAccessible =
|
||||
new nsHTMLComboboxButtonAccessible(mParent, mDOMNode, mWeakShell);
|
||||
textFieldAccessible->SetNextSibling(buttonAccessible);
|
||||
if (!buttonAccessible) {
|
||||
return;
|
||||
}
|
||||
|
||||
buttonAccessible->SetParent(this);
|
||||
buttonAccessible->Init();
|
||||
mAccChildCount = 2; // Button accessible child successfully added
|
||||
#endif
|
||||
|
||||
nsIFrame *frame = GetFrame();
|
||||
if (!frame) {
|
||||
|
@ -1029,11 +999,7 @@ void nsHTMLComboboxAccessible::CacheChildren()
|
|||
mListAccessible->Init();
|
||||
}
|
||||
|
||||
#ifdef COMBO_BOX_WITH_THREE_CHILDREN
|
||||
buttonAccessible->SetNextSibling(mListAccessible);
|
||||
#else
|
||||
SetFirstChild(mListAccessible);
|
||||
#endif
|
||||
|
||||
mListAccessible->SetParent(this);
|
||||
mListAccessible->SetNextSibling(nsnull);
|
||||
|
@ -1188,222 +1154,9 @@ NS_IMETHODIMP nsHTMLComboboxAccessible::GetActionName(PRUint8 aIndex, nsAString&
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifdef COMBO_BOX_WITH_THREE_CHILDREN
|
||||
/** ----- nsHTMLComboboxTextFieldAccessible ----- */
|
||||
|
||||
/** Constructor */
|
||||
nsHTMLComboboxTextFieldAccessible::nsHTMLComboboxTextFieldAccessible(nsIAccessible* aParent,
|
||||
nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell):
|
||||
nsHTMLTextFieldAccessible(aDOMNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLComboboxTextFieldAccessible::GetUniqueID(void **aUniqueID)
|
||||
{
|
||||
// Since mDOMNode is same as for our parent, use |this| pointer as the unique Id
|
||||
*aUniqueID = static_cast<void*>(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bounds for the BlockFrame.
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
void nsHTMLComboboxTextFieldAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame)
|
||||
{
|
||||
// get our first child's frame
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
frame = frame->GetFirstChild(nsnull);
|
||||
*aBoundingFrame = frame;
|
||||
|
||||
aBounds = frame->GetRect();
|
||||
}
|
||||
|
||||
void nsHTMLComboboxTextFieldAccessible::CacheChildren()
|
||||
{
|
||||
// Allow single text anonymous child, so that nsHyperTextAccessible can operate correctly
|
||||
// We must override this otherwise we get the dropdown button as a child of the textfield,
|
||||
// and at least for now we want to keep it as a sibling
|
||||
if (!mWeakShell) {
|
||||
// This node has been shut down
|
||||
mAccChildCount = eChildCountUninitialized;
|
||||
return;
|
||||
}
|
||||
|
||||
// Allows only 1 child
|
||||
if (mAccChildCount == eChildCountUninitialized) {
|
||||
mAccChildCount = 0; // Prevent reentry
|
||||
nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, PR_TRUE);
|
||||
// Seed the frame hint early while we're still on a container node.
|
||||
// This is better than doing the GetPrimaryFrameFor() later on
|
||||
// a text node, because text nodes aren't in the frame map.
|
||||
walker.mState.frame = GetFrame();
|
||||
|
||||
walker.GetFirstChild();
|
||||
SetFirstChild(walker.mState.accessible);
|
||||
nsRefPtr<nsAccessible> child =
|
||||
nsAccUtils::QueryAccessible(walker.mState.accessible);
|
||||
child->SetParent(this);
|
||||
child->SetNextSibling(nsnull);
|
||||
mAccChildCount = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/** -----ComboboxButtonAccessible ----- */
|
||||
|
||||
/** Constructor -- cache our parent */
|
||||
nsHTMLComboboxButtonAccessible::nsHTMLComboboxButtonAccessible(nsIAccessible* aParent,
|
||||
nsIDOMNode* aDOMNode,
|
||||
nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aDOMNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
/** Just one action ( click ). */
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetNumActions(PRUint8 *aNumActions)
|
||||
{
|
||||
*aNumActions = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmaticaly click on the button, causing either the display or
|
||||
* the hiding of the drop down box ( window ).
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::DoAction(PRUint8 aIndex)
|
||||
{
|
||||
nsIFrame* frame = nsAccessible::GetBoundsFrame();
|
||||
nsPresContext *context = GetPresContext();
|
||||
if (!frame || !context)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
frame = frame->GetFirstChild(nsnull)->GetNextSibling();
|
||||
|
||||
// We only have one action, click. Any other index is meaningless(wrong)
|
||||
if (aIndex == eAction_Click) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement>
|
||||
element(do_QueryInterface(frame->GetContent()));
|
||||
if (element)
|
||||
{
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our action name is the reverse of our state:
|
||||
* if we are closed -> open is our name.
|
||||
* if we are open -> closed is our name.
|
||||
* Uses the frame to get the state, updated on every click
|
||||
*/
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
||||
{
|
||||
nsIFrame *boundsFrame = GetBoundsFrame();
|
||||
nsIComboboxControlFrame* comboFrame;
|
||||
boundsFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame);
|
||||
if (!comboFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (comboFrame->IsDroppedDown())
|
||||
aName.AssignLiteral("close");
|
||||
else
|
||||
aName.AssignLiteral("open");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetUniqueID(void **aUniqueID)
|
||||
{
|
||||
// Since mDOMNode is same for all tree item, use |this| pointer as the unique Id
|
||||
*aUniqueID = static_cast<void*>(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bounds for the gfxButtonControlFrame.
|
||||
* Walks the Frame tree and checks for proper frames.
|
||||
*/
|
||||
void nsHTMLComboboxButtonAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame)
|
||||
{
|
||||
// get our second child's frame
|
||||
// bounding frame is the ComboboxControlFrame
|
||||
nsIFrame *frame = nsAccessible::GetBoundsFrame();
|
||||
*aBoundingFrame = frame;
|
||||
nsPresContext *context = GetPresContext();
|
||||
if (!frame || !context)
|
||||
return;
|
||||
|
||||
aBounds = frame->GetFirstChild(nsnull)->GetNextSibling()->GetRect();
|
||||
// sibling frame is for the button
|
||||
}
|
||||
|
||||
/** We are a button. */
|
||||
nsresult
|
||||
nsHTMLComboboxButtonAccessible::GetRoleInternal(PRUint32 *aRole)
|
||||
{
|
||||
*aRole = nsIAccessibleRole::ROLE_PUSHBUTTON;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Return our cached parent */
|
||||
NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetParent(nsIAccessible **aParent)
|
||||
{
|
||||
NS_IF_ADDREF(*aParent = mParent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLComboboxButtonAccessible::GetName(nsAString& aName)
|
||||
{
|
||||
// Native anonymous content, no way to use ARIA here.
|
||||
aName.Truncate();
|
||||
return GetActionName(eAction_Click, aName);
|
||||
}
|
||||
|
||||
/**
|
||||
* As a nsHTMLComboboxButtonAccessible we can have the following states:
|
||||
* STATE_PRESSED
|
||||
* STATE_FOCUSED
|
||||
* STATE_FOCUSABLE
|
||||
* STATE_INVISIBLE
|
||||
*/
|
||||
nsresult
|
||||
nsHTMLComboboxButtonAccessible::GetStateInternal(PRUint32 *aState,
|
||||
PRUint32 *aExtraState)
|
||||
{
|
||||
// Get focus status from base class
|
||||
nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState);
|
||||
NS_ENSURE_A11Y_SUCCESS(rv, rv);
|
||||
|
||||
nsIFrame *boundsFrame = GetBoundsFrame();
|
||||
nsIComboboxControlFrame* comboFrame = nsnull;
|
||||
if (boundsFrame)
|
||||
boundsFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame);
|
||||
|
||||
if (!comboFrame) {
|
||||
*aState |= nsIAccessibleStates::STATE_INVISIBLE;
|
||||
}
|
||||
else {
|
||||
*aState |= nsIAccessibleStates::STATE_FOCUSABLE;
|
||||
if (comboFrame->IsDroppedDown()) {
|
||||
*aState |= nsIAccessibleStates::STATE_PRESSED;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** ----- nsHTMLComboboxListAccessible ----- */
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsHTMLComboboxListAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsHTMLComboboxListAccessible::nsHTMLComboboxListAccessible(nsIAccessible *aParent,
|
||||
nsIDOMNode* aDOMNode,
|
||||
|
|
|
@ -244,59 +244,6 @@ private:
|
|||
nsRefPtr<nsHTMLComboboxListAccessible> mListAccessible;
|
||||
};
|
||||
|
||||
#ifdef COMBO_BOX_WITH_THREE_CHILDREN
|
||||
/*
|
||||
* A class the represents the text field in the Select to the left
|
||||
* of the drop down button
|
||||
*/
|
||||
class nsHTMLComboboxTextFieldAccessible : public nsHTMLTextFieldAccessible
|
||||
{
|
||||
public:
|
||||
|
||||
nsHTMLComboboxTextFieldAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLComboboxTextFieldAccessible() {}
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetUniqueID(void **aUniqueID);
|
||||
|
||||
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
|
||||
protected:
|
||||
void CacheChildren();
|
||||
};
|
||||
|
||||
/**
|
||||
* A class that represents the button inside the Select to the
|
||||
* right of the text field
|
||||
*/
|
||||
class nsHTMLComboboxButtonAccessible : public nsLeafAccessible
|
||||
{
|
||||
public:
|
||||
enum { eAction_Click = 0 };
|
||||
|
||||
nsHTMLComboboxButtonAccessible(nsIAccessible* aParent, nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLComboboxButtonAccessible() {}
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD DoAction(PRUint8 index);
|
||||
NS_IMETHOD GetNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
|
||||
NS_IMETHOD GetParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetName(nsAString& aName);
|
||||
|
||||
// nsIAccessNode
|
||||
NS_IMETHOD GetUniqueID(void **aUniqueID);
|
||||
|
||||
// nsAccessible
|
||||
virtual nsresult GetRoleInternal(PRUint32 *aRole);
|
||||
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
|
||||
|
||||
protected:
|
||||
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A class that represents the window that lives to the right
|
||||
* of the drop down button inside the Select. This is the window
|
||||
|
|
|
@ -91,6 +91,7 @@ _TEST_FILES =\
|
|||
test_elm_listbox.xul \
|
||||
$(warning test_elm_media.html temporarily disabled) \
|
||||
test_elm_plugin.html \
|
||||
test_elm_select.html \
|
||||
test_elm_tree.xul \
|
||||
test_elm_txtcntnr.html \
|
||||
test_events_caretmove.html \
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML select control tests</title>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
var accTree = {
|
||||
role: ROLE_LISTBOX,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_HEADING
|
||||
},
|
||||
{
|
||||
role: ROLE_OPTION,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_TEXT_LEAF
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: ROLE_OPTION,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_TEXT_LEAF
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: ROLE_OPTION,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_TEXT_LEAF
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
testAccessibleTree("listbox", accTree);
|
||||
|
||||
accTree = {
|
||||
role: ROLE_COMBOBOX,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_COMBOBOX_LIST,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_HEADING
|
||||
},
|
||||
{
|
||||
role: ROLE_COMBOBOX_OPTION,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_TEXT_LEAF
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: ROLE_COMBOBOX_OPTION,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_TEXT_LEAF
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
role: ROLE_COMBOBOX_OPTION,
|
||||
children: [
|
||||
{
|
||||
role: ROLE_TEXT_LEAF
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
testAccessibleTree("combobox", accTree);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
title="remove all the code in #ifdef COMBO_BOX_WITH_THREE_CHILDREN"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=506616">
|
||||
Mozilla Bug 506616
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<select id="listbox" size="4">
|
||||
<optgroup label="Colors">
|
||||
<option>Red</option>
|
||||
<option>Blue</option>
|
||||
</optgroup>
|
||||
<option>Animal</option>
|
||||
</select>
|
||||
|
||||
<select id="combobox">
|
||||
<optgroup label="Colors">
|
||||
<option>Red</option>
|
||||
<option>Blue</option>
|
||||
</optgroup>
|
||||
<option>Animal</option>
|
||||
</select>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче