本文整理汇总了C++中AXObjectCache类的典型用法代码示例。如果您正苦于以下问题:C++ AXObjectCache类的具体用法?C++ AXObjectCache怎么用?C++ AXObjectCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AXObjectCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: firstAccessibleObjectFromNode
AccessibilityObject* AccessibilityObject::firstAccessibleObjectFromNode(const Node* node)
{
if (!node)
return 0;
Document* document = node->document();
if (!document)
return 0;
AXObjectCache* cache = document->axObjectCache();
AccessibilityObject* accessibleObject = cache->getOrCreate(node->renderer());
while (accessibleObject && accessibleObject->accessibilityIsIgnored()) {
node = NodeTraversal::next(node);
while (node && !node->renderer())
node = NodeTraversal::nextSkippingChildren(node);
if (!node)
return 0;
accessibleObject = cache->getOrCreate(node->renderer());
}
return accessibleObject;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:26,代码来源:AccessibilityObject.cpp
示例2: HAVE
bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
{
#if HAVE(ACCESSIBILITY)
if (AXObjectCache::accessibilityEnabled()) {
if (parent() && parent()->isFrameView()) {
Document* document = static_cast<FrameView*>(parent())->frame()->document();
AXObjectCache* cache = document->axObjectCache();
AccessibilityScrollbar* axObject = static_cast<AccessibilityScrollbar*>(cache->getOrCreate(ScrollBarRole));
axObject->setScrollbar(this);
cache->postNotification(axObject, document, AXObjectCache::AXValueChanged, true);
}
}
#endif
// Ignore perpendicular scrolls.
if ((m_orientation == HorizontalScrollbar) ? (direction == ScrollUp || direction == ScrollDown) : (direction == ScrollLeft || direction == ScrollRight))
return false;
float step = 0;
switch (granularity) {
case ScrollByLine: step = m_lineStep; break;
case ScrollByPage: step = m_pageStep; break;
case ScrollByDocument: step = m_totalSize; break;
case ScrollByPixel: step = m_pixelStep; break;
}
if (direction == ScrollUp || direction == ScrollLeft)
multiplier = -multiplier;
if (client())
return client()->scroll(m_orientation, granularity, step, multiplier);
return setCurrentPos(max(min(m_currentPos + (step * multiplier), static_cast<float>(m_totalSize - m_visibleSize)), 0.0f), NotFromScrollAnimator);
}
示例3: accessibilityRootObjectWrapper
static AtkObject* accessibilityRootObjectWrapper(AtkObject* atkObject)
{
if (!AXObjectCache::accessibilityEnabled())
AXObjectCache::enableAccessibility();
WebPageAccessibilityObject* accessible = WEB_PAGE_ACCESSIBILITY_OBJECT(atkObject);
if (!accessible->m_page)
return 0;
Page* corePage = accessible->m_page->corePage();
if (!corePage)
return 0;
Frame& coreFrame = corePage->mainFrame();
if (!coreFrame.document())
return 0;
AXObjectCache* cache = coreFrame.document()->axObjectCache();
if (!cache)
return nullptr;
AccessibilityObject* coreRootObject = cache->rootObject();
if (!coreRootObject)
return 0;
AtkObject* rootObject = coreRootObject->wrapper();
if (!rootObject || !ATK_IS_OBJECT(rootObject))
return 0;
return rootObject;
}
示例4: notifyAccessibilityForSelectionChange
void FrameSelection::notifyAccessibilityForSelectionChange(const AXTextStateChangeIntent&)
{
if (!AXObjectCache::accessibilityEnabled())
return;
if (!m_selection.start().isNotNull() || !m_selection.end().isNotNull())
return;
RenderObject* focusedNode = m_selection.end().containerNode()->renderer();
AXObjectCache* cache = m_frame->document()->existingAXObjectCache();
if (!cache)
return;
AccessibilityObject* accessibilityObject = cache->getOrCreate(focusedNode);
if (!accessibilityObject)
return;
int offset;
RefPtr<AccessibilityObject> object = objectFocusedAndCaretOffsetUnignored(accessibilityObject, offset);
if (!object)
return;
emitTextSelectionChange(object.get(), m_selection, offset);
maybeEmitTextFocusChange(WTFMove(object));
}
示例5: memset
void AXObjectCache::textMarkerDataForVisiblePosition(TextMarkerData& textMarkerData, const VisiblePosition& visiblePos)
{
// This memory must be bzero'd so instances of TextMarkerData can be tested for byte-equivalence.
// This also allows callers to check for failure by looking at textMarkerData upon return.
memset(&textMarkerData, 0, sizeof(TextMarkerData));
if (visiblePos.isNull())
return;
Position deepPos = visiblePos.deepEquivalent();
Node* domNode = deepPos.deprecatedNode();
ASSERT(domNode);
if (!domNode)
return;
if (domNode->isHTMLElement()) {
HTMLInputElement* inputElement = domNode->toInputElement();
if (inputElement && inputElement->isPasswordField())
return;
}
// find or create an accessibility object for this node
AXObjectCache* cache = domNode->document()->axObjectCache();
RefPtr<AccessibilityObject> obj = cache->getOrCreate(domNode);
textMarkerData.axID = obj.get()->axObjectID();
textMarkerData.node = domNode;
textMarkerData.offset = deepPos.deprecatedEditingOffset();
textMarkerData.affinity = visiblePos.affinity();
cache->setNodeInUse(domNode);
}
示例6: axObjectCache
bool AXObject::accessibilityIsIgnored() const
{
AXObjectCache* cache = axObjectCache();
if (!cache)
return true;
AXComputedObjectAttributeCache* attributeCache = cache->computedObjectAttributeCache();
if (attributeCache) {
AXObjectInclusion ignored = attributeCache->getIgnored(axObjectID());
switch (ignored) {
case IgnoreObject:
return true;
case IncludeObject:
return false;
case DefaultBehavior:
break;
}
}
bool result = computeAccessibilityIsIgnored();
if (attributeCache)
attributeCache->setIgnored(axObjectID(), result ? IgnoreObject : IncludeObject);
return result;
}
示例7: ASSERT
void AccessibilityARIAGrid::addChildren()
{
ASSERT(!m_haveChildren);
if (!isAccessibilityTable()) {
AccessibilityRenderObject::addChildren();
return;
}
m_haveChildren = true;
if (!m_renderer)
return;
AXObjectCache* axCache = m_renderer->document().axObjectCache();
// add only rows that are labeled as aria rows
HashSet<AccessibilityObject*> appendedRows;
unsigned columnCount = 0;
for (RefPtr<AccessibilityObject> child = firstChild(); child; child = child->nextSibling())
addRowDescendant(child.get(), appendedRows, columnCount);
// make the columns based on the number of columns in the first body
for (unsigned i = 0; i < columnCount; ++i) {
AccessibilityTableColumn* column = toAccessibilityTableColumn(axCache->getOrCreate(ColumnRole));
column->setColumnIndex((int)i);
column->setParent(this);
m_columns.append(column);
if (!column->accessibilityIsIgnored())
m_children.append(column);
}
AccessibilityObject* headerContainerObject = headerContainer();
if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored())
m_children.append(headerContainerObject);
}
示例8: document
void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
{
Ref<Document> document(m_renderer->document());
AXObjectCache* cache = document->axObjectCache();
const auto& childObjects = children();
if (!childObjects.isEmpty()) {
ASSERT(childObjects.size() == 1);
ASSERT(childObjects[0]->isMenuListPopup());
// We might be calling this method in situations where the renderers for list items
// associated to the menu list have not been created (e.g. they might be rendered
// in the UI process, as it's the case in the GTK+ port, which uses GtkMenuItem).
// So, we need to make sure that the accessibility popup object has some children
// before asking it to update its active option, or it will read invalid memory.
// You can reproduce the issue in the GTK+ port by removing this check and running
// accessibility/insert-selected-option-into-select-causes-crash.html (will crash).
int popupChildrenSize = static_cast<int>(childObjects[0]->children().size());
if (childObjects[0]->isMenuListPopup() && optionIndex >= 0 && optionIndex < popupChildrenSize) {
if (AccessibilityMenuListPopup* popup = toAccessibilityMenuListPopup(childObjects[0].get()))
popup->didUpdateActiveOption(optionIndex);
}
}
cache->postNotification(this, &document.get(), AXObjectCache::AXMenuListValueChanged, TargetElement, PostSynchronously);
}
示例9: ASSERT
AccessibilityObject* AccessibilityObject::firstAccessibleObjectFromNode(const Node* node)
{
ASSERT(AXObjectCache::accessibilityEnabled());
if (!node)
return 0;
Document* document = node->document();
if (!document)
return 0;
AXObjectCache* cache = document->axObjectCache();
AccessibilityObject* accessibleObject = cache->getOrCreate(node->renderer());
while (accessibleObject && accessibleObject->accessibilityIsIgnored()) {
node = node->traverseNextNode();
while (node && !node->renderer())
node = node->traverseNextSibling();
if (!node)
return 0;
accessibleObject = cache->getOrCreate(node->renderer());
}
return accessibleObject;
}
示例10: document
void SimpleEditCommand::notifyAccessibilityForTextChange(Node* node, AXTextEditType type, const String& text, const VisiblePosition& position)
{
if (!AXObjectCache::accessibilityEnabled())
return;
AXObjectCache* cache = document().existingAXObjectCache();
if (!cache)
return;
cache->postTextStateChangeNotification(node, type, text, position);
}
示例11: ASSERT_ARG
void AccessibilityMenuListPopup::didUpdateActiveOption(int optionIndex)
{
ASSERT_ARG(optionIndex, optionIndex >= 0);
ASSERT_ARG(optionIndex, optionIndex < static_cast<int>(m_children.size()));
AXObjectCache* cache = axObjectCache();
RefPtr<AccessibilityObject> child = m_children[optionIndex].get();
cache->postNotification(child.get(), document(), AXObjectCache::AXFocusedUIElementChanged, TargetElement, PostSynchronously);
cache->postNotification(child.get(), document(), AXObjectCache::AXMenuListItemSelected, TargetElement, PostSynchronously);
}
示例12: document
void EditCommand::postTextStateChangeNotification(AXTextEditType type, const String& text, const VisiblePosition& position)
{
if (!AXObjectCache::accessibilityEnabled())
return;
if (!text.length())
return;
AXObjectCache* cache = document().existingAXObjectCache();
if (!cache)
return;
Node* node = highestEditableRoot(position.deepEquivalent(), HasEditableAXRole);
cache->postTextStateChangeNotification(node, type, text, position);
}
示例13: ASSERT
void AccessibilityARIAGrid::addChildren()
{
ASSERT(!m_haveChildren);
if (!isAccessibilityTable()) {
AccessibilityRenderObject::addChildren();
return;
}
m_haveChildren = true;
if (!m_renderer)
return;
AXObjectCache* axCache = m_renderer->document().axObjectCache();
// Add the children rows but be mindful in case there are footer sections in this table.
HashSet<AccessibilityObject*> appendedRows;
unsigned columnCount = 0;
AccessibilityChildrenVector footerSections;
for (RefPtr<AccessibilityObject> child = firstChild(); child; child = child->nextSibling()) {
bool footerSection = false;
if (RenderObject* childRenderer = child->renderer()) {
if (childRenderer->isTableSection()) {
if (RenderTableSection* childSection = toRenderTableSection(childRenderer)) {
if (childSection == childSection->table()->footer()) {
footerSections.append(child);
footerSection = true;
}
}
}
}
if (!footerSection)
addRowDescendant(child.get(), appendedRows, columnCount);
}
for (const auto& footerSection : footerSections)
addRowDescendant(footerSection.get(), appendedRows, columnCount);
// make the columns based on the number of columns in the first body
for (unsigned i = 0; i < columnCount; ++i) {
AccessibilityTableColumn* column = toAccessibilityTableColumn(axCache->getOrCreate(ColumnRole));
column->setColumnIndex((int)i);
column->setParent(this);
m_columns.append(column);
if (!column->accessibilityIsIgnored())
m_children.append(column);
}
AccessibilityObject* headerContainerObject = headerContainer();
if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored())
m_children.append(headerContainerObject);
}
示例14: ASSERT
void TreeScopeAdopter::moveTreeToNewScope(Node& root) const
{
ASSERT(needsScopeChange());
#if !ENABLE(OILPAN)
oldScope().guardRef();
#endif
// If an element is moved from a document and then eventually back again the collection cache for
// that element may contain stale data as changes made to it will have updated the DOMTreeVersion
// of the document it was moved to. By increasing the DOMTreeVersion of the donating document here
// we ensure that the collection cache will be invalidated as needed when the element is moved back.
Document& oldDocument = oldScope().document();
Document& newDocument = newScope().document();
bool willMoveToNewDocument = oldDocument != newDocument;
AXObjectCache* axObjectCache = oldDocument.existingAXObjectCache();
if (willMoveToNewDocument)
oldDocument.incDOMTreeVersion();
for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) {
updateTreeScope(node);
if (willMoveToNewDocument) {
if (axObjectCache)
axObjectCache->remove(&node);
moveNodeToNewDocument(node, oldDocument, newDocument);
} else if (node.hasRareData()) {
NodeRareData* rareData = node.rareData();
if (rareData->nodeLists())
rareData->nodeLists()->adoptTreeScope();
}
if (!node.isElementNode())
continue;
if (node.hasSyntheticAttrChildNodes()) {
WillBeHeapVector<RefPtrWillBeMember<Attr>>& attrs = *toElement(node).attrNodeList();
for (unsigned i = 0; i < attrs.size(); ++i)
moveTreeToNewScope(*attrs[i]);
}
for (ShadowRoot* shadow = node.youngestShadowRoot(); shadow; shadow = shadow->olderShadowRoot()) {
shadow->setParentTreeScope(newScope());
if (willMoveToNewDocument)
moveTreeToNewDocument(*shadow, oldDocument, newDocument);
}
}
#if !ENABLE(OILPAN)
oldScope().guardDeref();
#endif
}
示例15: axObjectCache
AccessibilityScrollbar* AccessibilityScrollView::addChildScrollbar(Scrollbar* scrollbar)
{
if (!scrollbar)
return nullptr;
AXObjectCache* cache = axObjectCache();
if (!cache)
return nullptr;
auto& scrollBarObject = downcast<AccessibilityScrollbar>(*cache->getOrCreate(scrollbar));
scrollBarObject.setParent(this);
m_children.append(&scrollBarObject);
return &scrollBarObject;
}