本文整理汇总了C++中DocAccessible::AnchorJump方法的典型用法代码示例。如果您正苦于以下问题:C++ DocAccessible::AnchorJump方法的具体用法?C++ DocAccessible::AnchorJump怎么用?C++ DocAccessible::AnchorJump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocAccessible
的用法示例。
在下文中一共展示了DocAccessible::AnchorJump方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AccEvent
void
FocusManager::ProcessFocusEvent(AccEvent* aEvent)
{
NS_PRECONDITION(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
"Focus event is expected!");
// Emit focus event if event target is the active item. Otherwise then check
// if it's still focused and then update active item and emit focus event.
Accessible* target = aEvent->GetAccessible();
if (target != mActiveItem) {
// Check if still focused. Otherwise we can end up with storing the active
// item for control that isn't focused anymore.
DocAccessible* document = aEvent->GetDocAccessible();
nsINode* focusedNode = FocusedDOMNode();
if (!focusedNode)
return;
Accessible* DOMFocus =
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
if (target != DOMFocus)
return;
Accessible* activeItem = target->CurrentItem();
if (activeItem) {
mActiveItem = activeItem;
target = activeItem;
}
}
// Fire menu start/end events for ARIA menus.
if (target->IsARIARole(nsGkAtoms::menuitem)) {
// The focus was moved into menu.
Accessible* ARIAMenubar = nullptr;
for (Accessible* parent = target->Parent(); parent; parent = parent->Parent()) {
if (parent->IsARIARole(nsGkAtoms::menubar)) {
ARIAMenubar = parent;
break;
}
// Go up in the parent chain of the menu hierarchy.
if (!parent->IsARIARole(nsGkAtoms::menuitem) &&
!parent->IsARIARole(nsGkAtoms::menu)) {
break;
}
}
if (ARIAMenubar != mActiveARIAMenubar) {
// Leaving ARIA menu. Fire menu_end event on current menubar.
if (mActiveARIAMenubar) {
RefPtr<AccEvent> menuEndEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
aEvent->FromUserInput());
nsEventShell::FireEvent(menuEndEvent);
}
mActiveARIAMenubar = ARIAMenubar;
// Entering ARIA menu. Fire menu_start event.
if (mActiveARIAMenubar) {
RefPtr<AccEvent> menuStartEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_START,
mActiveARIAMenubar, aEvent->FromUserInput());
nsEventShell::FireEvent(menuStartEvent);
}
}
} else if (mActiveARIAMenubar) {
// Focus left a menu. Fire menu_end event.
RefPtr<AccEvent> menuEndEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
aEvent->FromUserInput());
nsEventShell::FireEvent(menuEndEvent);
mActiveARIAMenubar = nullptr;
}
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("fire focus event", "Target", target);
#endif
// Reset cached caret value. The cache will be updated upon processing the
// next caret move event. This ensures that we will return the correct caret
// offset before the caret move event is handled.
SelectionMgr()->ResetCaretOffset();
RefPtr<AccEvent> focusEvent =
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, target, aEvent->FromUserInput());
nsEventShell::FireEvent(focusEvent);
// Fire scrolling_start event when the document receives the focus if it has
// an anchor jump. If an accessible within the document receive the focus
// then null out the anchor jump because it no longer applies.
DocAccessible* targetDocument = target->Document();
Accessible* anchorJump = targetDocument->AnchorJump();
if (anchorJump) {
if (target == targetDocument) {
// XXX: bug 625699, note in some cases the node could go away before we
// we receive focus event, for example if the node is removed from DOM.
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
//.........这里部分代码省略.........
示例2: iter
//.........这里部分代码省略.........
Accessible* DOMFocus =
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
if (target != DOMFocus)
return;
Accessible* activeItem = target->CurrentItem();
if (activeItem) {
mActiveItem = activeItem;
target = activeItem;
}
}
// Fire menu start/end events for ARIA menus.
if (target->IsARIARole(nsGkAtoms::menuitem)) {
// The focus was moved into menu.
bool tryOwnsParent = true;
Accessible* ARIAMenubar = nullptr;
Accessible* child = target;
Accessible* parent = child->Parent();
while (parent) {
nsRoleMapEntry* roleMap = parent->ARIARoleMap();
if (roleMap) {
if (roleMap->Is(nsGkAtoms::menubar)) {
ARIAMenubar = parent;
break;
}
// Go up in the parent chain of the menu hierarchy.
if (roleMap->Is(nsGkAtoms::menuitem) || roleMap->Is(nsGkAtoms::menu)) {
child = parent;
parent = child->Parent();
tryOwnsParent = true;
continue;
}
}
// If no required context role then check aria-owns relation.
if (!tryOwnsParent)
break;
RelatedAccIterator iter(child->Document(), child->GetContent(),
nsGkAtoms::aria_owns);
parent = iter.Next();
tryOwnsParent = false;
}
if (ARIAMenubar != mActiveARIAMenubar) {
// Leaving ARIA menu. Fire menu_end event on current menubar.
if (mActiveARIAMenubar) {
nsRefPtr<AccEvent> menuEndEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
aEvent->FromUserInput());
nsEventShell::FireEvent(menuEndEvent);
}
mActiveARIAMenubar = ARIAMenubar;
// Entering ARIA menu. Fire menu_start event.
if (mActiveARIAMenubar) {
nsRefPtr<AccEvent> menuStartEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_START,
mActiveARIAMenubar, aEvent->FromUserInput());
nsEventShell::FireEvent(menuStartEvent);
}
}
} else if (mActiveARIAMenubar) {
// Focus left a menu. Fire menu_end event.
nsRefPtr<AccEvent> menuEndEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
aEvent->FromUserInput());
nsEventShell::FireEvent(menuEndEvent);
mActiveARIAMenubar = nullptr;
}
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("fire focus event", "Target", target);
#endif
nsRefPtr<AccEvent> focusEvent =
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, target, aEvent->FromUserInput());
nsEventShell::FireEvent(focusEvent);
// Fire scrolling_start event when the document receives the focus if it has
// an anchor jump. If an accessible within the document receive the focus
// then null out the anchor jump because it no longer applies.
DocAccessible* targetDocument = target->Document();
Accessible* anchorJump = targetDocument->AnchorJump();
if (anchorJump) {
if (target == targetDocument) {
// XXX: bug 625699, note in some cases the node could go away before we
// we receive focus event, for example if the node is removed from DOM.
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
anchorJump, aEvent->FromUserInput());
}
targetDocument->SetAnchorJump(nullptr);
}
}