本文整理汇总了C++中Accessible::Role方法的典型用法代码示例。如果您正苦于以下问题:C++ Accessible::Role方法的具体用法?C++ Accessible::Role怎么用?C++ Accessible::Role使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Accessible
的用法示例。
在下文中一共展示了Accessible::Role方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Table
void
XULListCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aCells)
{
TableAccessible* table = Table();
NS_ASSERTION(table, "cell not in a table!");
if (!table)
return;
// Get column header cell from XUL listhead.
Accessible* list = nullptr;
Accessible* tableAcc = table->AsAccessible();
uint32_t tableChildCount = tableAcc->ChildCount();
for (uint32_t childIdx = 0; childIdx < tableChildCount; childIdx++) {
Accessible* child = tableAcc->GetChildAt(childIdx);
if (child->Role() == roles::LIST) {
list = child;
break;
}
}
if (list) {
Accessible* headerCell = list->GetChildAt(ColIdx());
if (headerCell) {
aCells->AppendElement(headerCell);
return;
}
}
// No column header cell from XUL markup, try to get it from ARIA markup.
TableCellAccessible::ColHeaderCells(aCells);
}
示例2: Parent
NS_IMETHODIMP
ARIAGridCellAccessible::GetColumnIndex(int32_t* aColumnIndex)
{
NS_ENSURE_ARG_POINTER(aColumnIndex);
*aColumnIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
Accessible* row = Parent();
if (!row)
return NS_OK;
*aColumnIndex = 0;
int32_t indexInRow = IndexInParent();
for (int32_t idx = 0; idx < indexInRow; idx++) {
Accessible* cell = row->GetChildAt(idx);
roles::Role role = cell->Role();
if (role == roles::GRID_CELL || role == roles::ROWHEADER ||
role == roles::COLUMNHEADER)
(*aColumnIndex)++;
}
return NS_OK;
}
示例3: AccStateChangeEvent
nsresult
HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
{
nsresult rv = HyperTextAccessibleWrap::HandleAccEvent(aEvent);
NS_ENSURE_SUCCESS(rv, rv);
// Redirect state change events for inherited states to child controls. Note,
// unavailable state is not redirected. That's a standard for unavailable
// state handling.
AccStateChangeEvent* event = downcast_accEvent(aEvent);
if (event &&
(event->GetState() == states::BUSY ||
event->GetState() == states::REQUIRED ||
event->GetState() == states::HASPOPUP ||
event->GetState() == states::INVALID)) {
Accessible* button = GetChildAt(0);
if (button && button->Role() == roles::PUSHBUTTON) {
RefPtr<AccStateChangeEvent> childEvent =
new AccStateChangeEvent(button, event->GetState(),
event->IsStateEnabled(), event->FromUserInput());
nsEventShell::FireEvent(childEvent);
}
}
return NS_OK;
}
示例4: GetAtkObject
static AtkObject*
getRowHeaderCB(AtkTable *aTable, gint aRowIdx)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (!accWrap)
return nullptr;
Accessible* cell = accWrap->AsTable()->CellAt(aRowIdx, 0);
if (!cell)
return nullptr;
// If the cell at the first column is row header then assume it is row
// header for all columns,
if (cell->Role() == roles::ROWHEADER)
return AccessibleWrap::GetAtkObject(cell);
// otherwise get row header for the data cell at the first column.
TableCellAccessible* tableCell = cell->AsTableCell();
if (!tableCell)
return nullptr;
nsAutoTArray<Accessible*, 10> headerCells;
tableCell->RowHeaderCells(&headerCells);
if (headerCells.IsEmpty())
return nullptr;
return AccessibleWrap::GetAtkObject(headerCells[0]);
}
示例5: itemContent
void
XULListboxAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
{
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
do_QueryInterface(mContent);
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
nsCOMPtr<nsIDOMNodeList> selectedItems;
control->GetSelectedItems(getter_AddRefs(selectedItems));
if (!selectedItems)
return;
uint32_t selectedItemsCount = 0;
DebugOnly<nsresult> rv = selectedItems->GetLength(&selectedItemsCount);
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLength() Shouldn't fail!");
for (uint32_t index = 0; index < selectedItemsCount; index++) {
nsCOMPtr<nsIDOMNode> itemNode;
selectedItems->Item(index, getter_AddRefs(itemNode));
nsCOMPtr<nsIContent> itemContent(do_QueryInterface(itemNode));
Accessible* item = mDoc->GetAccessible(itemContent);
if (item) {
uint32_t cellCount = item->ChildCount();
for (uint32_t cellIdx = 0; cellIdx < cellCount; cellIdx++) {
Accessible* cell = mChildren[cellIdx];
if (cell->Role() == roles::CELL)
aCells->AppendElement(cell);
}
}
}
}
示例6: ChildCount
Relation
XULGroupboxAccessible::RelationByType(RelationType aType)
{
Relation rel = AccessibleWrap::RelationByType(aType);
if (aType != RelationType::LABELLED_BY)
return rel;
// The label for xul:groupbox is generated from xul:label that is
// inside the anonymous content of the xul:caption.
// The xul:label has an accessible object but the xul:caption does not
uint32_t childCount = ChildCount();
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
Accessible* childAcc = GetChildAt(childIdx);
if (childAcc->Role() == roles::LABEL) {
// Ensure that it's our label
Relation reverseRel = childAcc->RelationByType(RelationType::LABEL_FOR);
Accessible* testGroupbox = nullptr;
while ((testGroupbox = reverseRel.Next()))
if (testGroupbox == this) {
// The <label> points back to this groupbox
rel.AppendTarget(childAcc);
}
}
}
return rel;
}
示例7: RelationByType
Relation HTMLLegendAccessible::RelationByType(RelationType aType) const {
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
if (aType != RelationType::LABEL_FOR) return rel;
Accessible* groupbox = Parent();
if (groupbox && groupbox->Role() == roles::GROUPING)
rel.AppendTarget(groupbox);
return rel;
}
示例8: walker
void
XULButtonAccessible::CacheChildren()
{
// In general XUL button has not accessible children. Nevertheless menu
// buttons can have button (@type="menu-button") and popup accessibles
// (@type="menu-button" or @type="menu").
// XXX: no children until the button is menu button. Probably it's not
// totally correct but in general AT wants to have leaf buttons.
bool isMenu = mContent->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::type,
nsGkAtoms::menu,
eCaseMatters);
bool isMenuButton = isMenu ?
false :
mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::menuButton, eCaseMatters);
NS_ENSURE_TRUE(mDoc,);
if (!isMenu && !isMenuButton)
return;
Accessible* menupopup = nsnull;
Accessible* button = nsnull;
nsAccTreeWalker walker(mDoc, mContent, true);
Accessible* child = nsnull;
while ((child = walker.NextChild())) {
roles::Role role = child->Role();
if (role == roles::MENUPOPUP) {
// Get an accessible for menupopup or panel elements.
menupopup = child;
} else if (isMenuButton && role == roles::PUSHBUTTON) {
// Button type="menu-button" contains a real button. Get an accessible
// for it. Ignore dropmarker button which is placed as a last child.
button = child;
break;
} else {
// Unbind rejected accessible from document.
Document()->UnbindFromDocument(child);
}
}
if (!menupopup)
return;
AppendChild(menupopup);
if (button)
AppendChild(button);
}
示例9: Parent
NS_IMETHODIMP
nsXULListCellAccessible::GetTable(nsIAccessibleTable **aTable)
{
NS_ENSURE_ARG_POINTER(aTable);
*aTable = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
Accessible* thisRow = Parent();
if (!thisRow || thisRow->Role() != roles::ROW)
return NS_OK;
Accessible* table = thisRow->Parent();
if (!table || table->Role() != roles::TABLE)
return NS_OK;
CallQueryInterface(table, aTable);
return NS_OK;
}
示例10: return
Accessible*
nsAccUtils::TableFor(Accessible* aRow)
{
if (aRow) {
Accessible* table = aRow->Parent();
if (table) {
roles::Role tableRole = table->Role();
if (tableRole == roles::GROUPING) { // if there's a rowgroup.
table = table->Parent();
if (table)
tableRole = table->Role();
}
return (tableRole == roles::TABLE || tableRole == roles::TREE_TABLE ||
tableRole == roles::MATHML_TABLE) ? table : nullptr;
}
}
return nullptr;
}
示例11:
Accessible*
AccGroupInfo::FirstItemOf(Accessible* aContainer)
{
// ARIA tree can be arranged by ARIA groups case #1 (previous sibling of a
// group is a parent) or by aria-level.
a11y::role containerRole = aContainer->Role();
Accessible* item = aContainer->NextSibling();
if (item) {
if (containerRole == roles::OUTLINEITEM && item->Role() == roles::GROUPING)
item = item->FirstChild();
if (item) {
AccGroupInfo* itemGroupInfo = item->GetGroupInfo();
if (itemGroupInfo && itemGroupInfo->ConceptualParent() == aContainer)
return item;
}
}
// ARIA list and tree can be arranged by ARIA groups case #2 (group is
// a child of an item).
item = aContainer->LastChild();
if (!item)
return nullptr;
if (item->Role() == roles::GROUPING &&
(containerRole == roles::LISTITEM || containerRole == roles::OUTLINEITEM)) {
item = item->FirstChild();
if (item) {
AccGroupInfo* itemGroupInfo = item->GetGroupInfo();
if (itemGroupInfo && itemGroupInfo->ConceptualParent() == aContainer)
return item;
}
}
// Otherwise, it can be a direct child if the container is a list or tree.
item = aContainer->FirstChild();
if (ShouldReportRelations(item->Role(), containerRole))
return item;
return nullptr;
}
示例12: while
TableAccessible*
HTMLTableCellAccessible::Table() const
{
Accessible* parent = const_cast<HTMLTableCellAccessible*>(this);
while ((parent = parent->Parent())) {
roles::Role role = parent->Role();
if (role == roles::TABLE || role == roles::TREE_TABLE)
return parent->AsTable();
}
return nullptr;
}
示例13: Parent
Relation
HTMLLegendAccessible::RelationByType(uint32_t aType)
{
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
if (aType != nsIAccessibleRelation::RELATION_LABEL_FOR)
return rel;
Accessible* groupbox = Parent();
if (groupbox && groupbox->Role() == roles::GROUPING)
rel.AppendTarget(groupbox);
return rel;
}
示例14: itemContent
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedCells(nsIArray **aCells)
{
NS_ENSURE_ARG_POINTER(aCells);
*aCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> selCells =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
do_QueryInterface(mContent);
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
nsCOMPtr<nsIDOMNodeList> selectedItems;
control->GetSelectedItems(getter_AddRefs(selectedItems));
if (!selectedItems)
return NS_OK;
PRUint32 selectedItemsCount = 0;
rv = selectedItems->GetLength(&selectedItemsCount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(mDoc, NS_ERROR_FAILURE);
PRUint32 index = 0;
for (; index < selectedItemsCount; index++) {
nsCOMPtr<nsIDOMNode> itemNode;
selectedItems->Item(index, getter_AddRefs(itemNode));
nsCOMPtr<nsIContent> itemContent(do_QueryInterface(itemNode));
Accessible* item = mDoc->GetAccessible(itemContent);
if (item) {
PRUint32 cellCount = item->ChildCount();
for (PRUint32 cellIdx = 0; cellIdx < cellCount; cellIdx++) {
Accessible* cell = mChildren[cellIdx];
if (cell->Role() == roles::CELL)
selCells->AppendElement(static_cast<nsIAccessible*>(cell), false);
}
}
}
NS_ADDREF(*aCells = selCells);
return NS_OK;
}
示例15: while
already_AddRefed<nsIAccessibleTable>
nsHTMLTableCellAccessible::GetTableAccessible()
{
Accessible* parent = this;
while ((parent = parent->Parent())) {
roles::Role role = parent->Role();
if (role == roles::TABLE || role == roles::TREE_TABLE) {
nsIAccessibleTable* tableAcc = nsnull;
CallQueryInterface(parent, &tableAcc);
return tableAcc;
}
}
return nsnull;
}