/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:expandtab:shiftwidth=2:tabstop=2:
*/ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
MARKUPMAP(
a,
[](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { // An anchor element without an href attribute and without a click // listener should be a generic. if (!aElement->HasAttr(nsGkAtoms::href) &&
!nsCoreUtils::HasClickListener(aElement)) { returnnew HyperTextAccessible(aElement, aContext->Document());
} // Only some roles truly enjoy life as HTMLLinkAccessibles, for // details see closed bug 494807. const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement); if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
roleMapEntry->role != roles::LINK) { returnnew HyperTextAccessible(aElement, aContext->Document());
}
MARKUPMAP(
div,
[](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { // Never create an accessible if we're part of an anonymous // subtree. if (aElement->IsInNativeAnonymousSubtree()) { return nullptr;
} // Always create an accessible if the div has an id. if (aElement->HasAttr(nsGkAtoms::id)) { returnnew HyperTextAccessible(aElement, aContext->Document());
} // Never create an accessible if the div is not display:block; or // display:inline-block or the like.
nsIFrame* f = aElement->GetPrimaryFrame(); if (!f || !f->IsBlockFrameOrSubclass()) { return nullptr;
} // Check for various conditions to determine if this is a block // break and needs to be rendered. // If its previous sibling is an inline element, we probably want // to break, so render. // FIXME: This looks extremely incorrect in presence of shadow DOM, // display: contents, and what not.
nsIContent* prevSibling = aElement->GetPreviousSibling(); if (prevSibling) {
nsIFrame* prevSiblingFrame = prevSibling->GetPrimaryFrame(); if (prevSiblingFrame && prevSiblingFrame->IsInlineOutside()) { returnnew HyperTextAccessible(aElement, aContext->Document());
}
} // Now, check the children.
nsIContent* firstChild = aElement->GetFirstChild(); if (firstChild) {
nsIFrame* firstChildFrame = firstChild->GetPrimaryFrame(); if (!firstChildFrame) { // The first child is invisible, but this might be due to an // invisible text node. Try the next.
firstChild = firstChild->GetNextSibling(); if (!firstChild) { // If there's no next sibling, there's only one child, so there's // nothing more we can do. return nullptr;
}
firstChildFrame = firstChild->GetPrimaryFrame();
} // Check to see if first child has an inline frame. if (firstChildFrame && firstChildFrame->IsInlineOutside()) { returnnew HyperTextAccessible(aElement, aContext->Document());
}
nsIContent* lastChild = aElement->GetLastChild();
MOZ_ASSERT(lastChild); if (lastChild != firstChild) {
nsIFrame* lastChildFrame = lastChild->GetPrimaryFrame(); if (!lastChildFrame) { // The last child is invisible, but this might be due to an // invisible text node. Try the next.
lastChild = lastChild->GetPreviousSibling();
MOZ_ASSERT(lastChild); if (lastChild == firstChild) { return nullptr;
}
lastChildFrame = lastChild->GetPrimaryFrame();
} // Check to see if last child has an inline frame. if (lastChildFrame && lastChildFrame->IsInlineOutside()) { returnnew HyperTextAccessible(aElement, aContext->Document());
}
}
} return nullptr;
},
roles::SECTION)
MARKUPMAP(
li,
[](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { // If list item is a child of accessible list then create an // accessible for it unconditionally by tag name. nsBlockFrame // creates the list item accessible for other elements styled as // list items. if (aContext->IsList() &&
aContext->GetContent() == aElement->GetParent()) { returnnew HTMLLIAccessible(aElement, aContext->Document());
}
MARKUPMAP(
tr,
[](Element* aElement, LocalAccessible* aContext) -> LocalAccessible* { if (aContext->IsTableRow()) { // A <tr> within a row isn't valid. return nullptr;
} const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement); if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
roleMapEntry->role != roles::ROW) { // There is a valid ARIA role which isn't "row". Don't treat this as an // HTML table row. return nullptr;
} // Check if this <tr> is within a table. We check the grandparent because // it might be inside a rowgroup. We don't specifically check for an HTML // table because there are cases where there is a <tr> inside a // <div role="table"> such as Monorail. if (aContext->IsTable() ||
(aContext->LocalParent() && aContext->LocalParent()->IsTable())) { returnnew HTMLTableRowAccessible(aElement, aContext->Document());
} return nullptr;
},
roles::ROW)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.