本文整理汇总了C++中DocAccessible类的典型用法代码示例。如果您正苦于以下问题:C++ DocAccessible类的具体用法?C++ DocAccessible怎么用?C++ DocAccessible使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DocAccessible类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NS_ENSURE_ARG
NS_IMETHODIMP
SelectionManager::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
nsISelection* aSelection,
int16_t aReason)
{
NS_ENSURE_ARG(aDOMDocument);
nsCOMPtr<nsIDocument> documentNode(do_QueryInterface(aDOMDocument));
DocAccessible* document = GetAccService()->GetDocAccessible(documentNode);
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eSelection))
logging::SelChange(aSelection, document);
#endif
// Don't fire events until document is loaded.
if (document && document->IsContentLoaded()) {
// Selection manager has longer lifetime than any document accessible,
// so that we are guaranteed that the notification is processed before
// the selection manager is destroyed.
document->HandleNotification<SelectionManager, nsISelection>
(this, &SelectionManager::ProcessSelectionChanged, aSelection);
}
return NS_OK;
}
示例2: Document
Accessible*
XULMenupopupAccessible::ContainerWidget() const
{
DocAccessible* document = Document();
nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(GetFrame());
while (menuPopupFrame) {
Accessible* menuPopup =
document->GetAccessible(menuPopupFrame->GetContent());
if (!menuPopup) // shouldn't be a real case
return nullptr;
nsMenuFrame* menuFrame = do_QueryFrame(menuPopupFrame->GetParent());
if (!menuFrame) // context menu or popups
return nullptr;
nsMenuParent* menuParent = menuFrame->GetMenuParent();
if (!menuParent) // menulist or menubutton
return menuPopup->Parent();
if (menuParent->IsMenuBar()) { // menubar menu
nsMenuBarFrame* menuBarFrame = static_cast<nsMenuBarFrame*>(menuParent);
return document->GetAccessible(menuBarFrame->GetContent());
}
// different kind of popups like panel or tooltip
if (!menuParent->IsMenu())
return nullptr;
menuPopupFrame = static_cast<nsMenuPopupFrame*>(menuParent);
}
MOZ_ASSERT_UNREACHABLE("Shouldn't be a real case.");
return nullptr;
}
示例3: AccTextChangeEvent
void
NotificationController::CreateTextChangeEventFor(AccMutationEvent* aEvent)
{
DocAccessible* document = aEvent->GetDocAccessible();
Accessible* container = document->GetContainerAccessible(aEvent->mNode);
if (!container)
return;
HyperTextAccessible* textAccessible = container->AsHyperText();
if (!textAccessible)
return;
// Don't fire event for the first html:br in an editor.
if (aEvent->mAccessible->Role() == roles::WHITESPACE) {
nsCOMPtr<nsIEditor> editor = textAccessible->GetEditor();
if (editor) {
bool isEmpty = false;
editor->GetDocumentIsEmpty(&isEmpty);
if (isEmpty)
return;
}
}
int32_t offset = textAccessible->GetChildOffset(aEvent->mAccessible);
nsAutoString text;
aEvent->mAccessible->AppendTextTo(text);
if (text.IsEmpty())
return;
aEvent->mTextChangeEvent =
new AccTextChangeEvent(textAccessible, offset, text, aEvent->IsShow(),
aEvent->mIsFromUserInput ? eFromUserInput : eNoUserInput);
}
示例4: get_unclippedSubstringBounds
STDMETHODIMP
sdnTextAccessible::get_clippedSubstringBounds(
unsigned int aStartIndex, unsigned int aEndIndex, int __RPC_FAR* aX,
int __RPC_FAR* aY, int __RPC_FAR* aWidth, int __RPC_FAR* aHeight) {
nscoord x = 0, y = 0, width = 0, height = 0;
HRESULT rv = get_unclippedSubstringBounds(aStartIndex, aEndIndex, &x, &y,
&width, &height);
if (FAILED(rv)) return rv;
DocAccessible* document = mAccessible->Document();
NS_ASSERTION(
document,
"There must always be a doc accessible, but there isn't. Crash!");
nsIntRect docRect = document->Bounds();
nsIntRect unclippedRect(x, y, width, height);
nsIntRect clippedRect;
clippedRect.IntersectRect(unclippedRect, docRect);
*aX = clippedRect.X();
*aY = clippedRect.Y();
*aWidth = clippedRect.Width();
*aHeight = clippedRect.Height();
return S_OK;
}
示例5: while
void
DocManager::ClearDocCache()
{
while (mDocAccessibleCache.Count() > 0) {
auto iter = mDocAccessibleCache.Iter();
MOZ_ASSERT(!iter.Done());
DocAccessible* docAcc = iter.UserData();
NS_ASSERTION(docAcc,
"No doc accessible for the object in doc accessible cache!");
if (docAcc) {
docAcc->Shutdown();
}
iter.Remove();
}
// Ensure that all xpcom accessible documents are shut down as well.
while (mXPCDocumentCache.Count() > 0) {
auto iter = mXPCDocumentCache.Iter();
MOZ_ASSERT(!iter.Done());
xpcAccessibleDocument* xpcDoc = iter.UserData();
NS_ASSERTION(xpcDoc, "No xpc doc for the object in xpc doc cache!");
if (xpcDoc) {
xpcDoc->Shutdown();
}
iter.Remove();
}
}
示例6: do_QueryInterface
Accessible*
XULSelectControlAccessible::CurrentItem()
{
if (!mSelectControl)
return nullptr;
nsCOMPtr<nsIDOMXULSelectControlItemElement> currentItemElm;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
do_QueryInterface(mSelectControl);
if (multiSelectControl)
multiSelectControl->GetCurrentItem(getter_AddRefs(currentItemElm));
else
mSelectControl->GetSelectedItem(getter_AddRefs(currentItemElm));
nsCOMPtr<nsINode> DOMNode;
if (currentItemElm)
DOMNode = do_QueryInterface(currentItemElm);
if (DOMNode) {
DocAccessible* document = Document();
if (document)
return document->GetAccessible(DOMNode);
}
return nullptr;
}
示例7: NS_NOTREACHED
void
HTMLLIAccessible::UpdateBullet(bool aHasBullet)
{
if (aHasBullet == !!mBullet) {
NS_NOTREACHED("Bullet and accessible are in sync already!");
return;
}
RefPtr<AccReorderEvent> reorderEvent = new AccReorderEvent(this);
AutoTreeMutation mt(this);
DocAccessible* document = Document();
if (aHasBullet) {
mBullet = new HTMLListBulletAccessible(mContent, mDoc);
document->BindToDocument(mBullet, nullptr);
InsertChildAt(0, mBullet);
mt.AfterInsertion(mBullet);
RefPtr<AccShowEvent> event = new AccShowEvent(mBullet);
mDoc->FireDelayedEvent(event);
reorderEvent->AddSubMutationEvent(event);
} else {
RefPtr<AccHideEvent> event = new AccHideEvent(mBullet, mBullet->GetContent());
mDoc->FireDelayedEvent(event);
reorderEvent->AddSubMutationEvent(event);
mt.BeforeRemoval(mBullet);
RemoveChild(mBullet);
mBullet = nullptr;
}
mt.Done();
mDoc->FireDelayedEvent(reorderEvent);
}
示例8: GetAccService
void
logging::AccessibleNNode(const char* aDescr, nsINode* aNode)
{
DocAccessible* document =
GetAccService()->GetDocAccessible(aNode->OwnerDoc());
if (document) {
Accessible* accessible = document->GetAccessible(aNode);
if (accessible) {
AccessibleNNode(aDescr, accessible);
return;
}
}
nsAutoCString nodeDescr("[not accessible] ");
nodeDescr.Append(aDescr);
Node(nodeDescr.get(), aNode);
if (document) {
Document(document);
return;
}
printf(" [contained by not accessible document]:\n");
LogDocInfo(aNode->OwnerDoc(), document);
printf("\n");
}
示例9: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP
xpcAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
nsIAccessible **aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
*aAccessible = nullptr;
if (!aNode) {
return NS_OK;
}
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
if (!node) {
return NS_ERROR_INVALID_ARG;
}
nsAccessibilityService* accService = GetAccService();
if (!accService) {
return NS_ERROR_SERVICE_NOT_AVAILABLE;
}
DocAccessible* document = accService->GetDocAccessible(node->OwnerDoc());
if (document) {
NS_IF_ADDREF(*aAccessible = ToXPC(document->GetAccessible(node)));
}
return NS_OK;
}
示例10: A11YDEBUG_FOCUS_NOTIFICATION_SUPPORTSTARGET
void
FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
{
A11YDEBUG_FOCUS_NOTIFICATION_SUPPORTSTARGET("DOM focus", "DOM focus target",
aTarget)
mActiveItem = nullptr;
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
if (targetNode) {
DocAccessible* document =
GetAccService()->GetDocAccessible(targetNode->OwnerDoc());
if (document) {
// Set selection listener for focused element.
if (targetNode->IsElement()) {
RootAccessible* root = document->RootAccessible();
nsCaretAccessible* caretAcc = root->GetCaretAccessible();
caretAcc->SetControlSelectionListener(targetNode->AsElement());
}
document->HandleNotification<FocusManager, nsINode>
(this, &FocusManager::ProcessDOMFocus, targetNode);
}
}
}
示例11: getDocumentAttributesCB
AtkAttributeSet *
getDocumentAttributesCB(AtkDocument *aDocument)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
if (!accWrap || !accWrap->IsDoc())
return nullptr;
// according to atkobject.h, AtkAttributeSet is a GSList
GSList* attributes = nullptr;
DocAccessible* document = accWrap->AsDoc();
nsAutoString aURL;
nsresult rv = document->GetURL(aURL);
if (NS_SUCCEEDED(rv))
attributes = prependToList(attributes, kDocUrlName, aURL);
nsAutoString aW3CDocType;
rv = document->GetDocType(aW3CDocType);
if (NS_SUCCEEDED(rv))
attributes = prependToList(attributes, kDocTypeName, aW3CDocType);
nsAutoString aMimeType;
rv = document->GetMimeType(aMimeType);
if (NS_SUCCEEDED(rv))
attributes = prependToList(attributes, kMimeTypeName, aMimeType);
return attributes;
}
示例12: GetAccService
void
FocusManager::ProcessDOMFocus(nsINode* aTarget)
{
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("process DOM focus", "Target", aTarget);
#endif
DocAccessible* document =
GetAccService()->GetDocAccessible(aTarget->OwnerDoc());
if (!document)
return;
Accessible* target = document->GetAccessibleEvenIfNotInMapOrContainer(aTarget);
if (target) {
// Check if still focused. Otherwise we can end up with storing the active
// item for control that isn't focused anymore.
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;
}
DispatchFocusEvent(document, target);
}
}
示例13: NS_ENSURE_ARG
NS_IMETHODIMP
nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
nsISelection* aSelection,
int16_t aReason)
{
NS_ENSURE_ARG(aDOMDocument);
NS_ENSURE_STATE(mRootAccessible);
nsCOMPtr<nsIDocument> documentNode(do_QueryInterface(aDOMDocument));
DocAccessible* document = GetAccService()->GetDocAccessible(documentNode);
#ifdef DEBUG
if (logging::IsEnabled(logging::eSelection))
logging::SelChange(aSelection, document);
#endif
// Don't fire events until document is loaded.
if (document && document->IsContentLoaded()) {
// The caret accessible has the same lifetime as the root accessible, and
// this outlives all its descendant document accessibles, so that we are
// guaranteed that the notification is processed before the caret accessible
// is destroyed.
document->HandleNotification<nsCaretAccessible, nsISelection>
(this, &nsCaretAccessible::ProcessSelectionChanged, aSelection);
}
return NS_OK;
}
示例14: getDocumentAttributesCB
AtkAttributeSet *
getDocumentAttributesCB(AtkDocument *aDocument)
{
nsAutoString url;
nsAutoString w3cDocType;
nsAutoString mimeType;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
if (accWrap) {
if (!accWrap->IsDoc()) {
return nullptr;
}
DocAccessible* document = accWrap->AsDoc();
document->URL(url);
document->DocType(w3cDocType);
document->MimeType(mimeType);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aDocument))) {
proxy->URLDocTypeMimeType(url, w3cDocType, mimeType);
} else {
return nullptr;
}
// according to atkobject.h, AtkAttributeSet is a GSList
GSList* attributes = nullptr;
attributes = prependToList(attributes, kDocUrlName, url);
attributes = prependToList(attributes, kDocTypeName, w3cDocType);
attributes = prependToList(attributes, kMimeTypeName, mimeType);
return attributes;
}
示例15: document
NS_IMETHODIMP
nsAccDocManager::HandleEvent(nsIDOMEvent *aEvent)
{
nsAutoString type;
aEvent->GetType(type);
nsCOMPtr<nsIDOMEventTarget> target;
aEvent->GetTarget(getter_AddRefs(target));
nsCOMPtr<nsIDocument> document(do_QueryInterface(target));
NS_ASSERTION(document, "pagehide or DOMContentLoaded for non document!");
if (!document)
return NS_OK;
if (type.EqualsLiteral("pagehide")) {
// 'pagehide' event is registered on every DOM document we create an
// accessible for, process the event for the target. This document
// accessible and all its sub document accessible are shutdown as result of
// processing.
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy))
logging::DocDestroy("received 'pagehide' event", document);
#endif
// Ignore 'pagehide' on temporary documents since we ignore them entirely in
// accessibility.
if (document->IsInitialDocument())
return NS_OK;
// Shutdown this one and sub document accessibles.
// We're allowed to not remove listeners when accessible document is
// shutdown since we don't keep strong reference on chrome event target and
// listeners are removed automatically when chrome event target goes away.
DocAccessible* docAccessible = mDocAccessibleCache.GetWeak(document);
if (docAccessible)
docAccessible->Shutdown();
return NS_OK;
}
// XXX: handle error pages loading separately since they get neither
// webprogress notifications nor 'pageshow' event.
if (type.EqualsLiteral("DOMContentLoaded") &&
nsCoreUtils::IsErrorPage(document)) {
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocLoad))
logging::DocLoad("handled 'DOMContentLoaded' event", document);
#endif
HandleDOMDocumentLoad(document,
nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE);
}
return NS_OK;
}