gecko-dev/accessible/atk/nsMaiInterfaceDocument.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

145 строки
4.5 KiB
C++
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
Bug 653086 - clean up editor configuration in a11y files r=fernando From 4a69f14cec60e25aca096b75b1be265b11a31244 Mon Sep 17 00:00:00 2001 --- accessible/src/atk/AtkSocketAccessible.cpp | 3 +-- accessible/src/atk/AtkSocketAccessible.h | 3 +-- accessible/src/atk/nsARIAGridAccessibleWrap.h | 2 +- accessible/src/atk/nsAccessNodeWrap.cpp | 2 +- accessible/src/atk/nsAccessNodeWrap.h | 2 +- accessible/src/atk/nsAccessibleRelationWrap.h | 2 +- accessible/src/atk/nsAccessibleWrap.cpp | 2 +- accessible/src/atk/nsAccessibleWrap.h | 2 +- accessible/src/atk/nsApplicationAccessibleWrap.cpp | 2 +- accessible/src/atk/nsApplicationAccessibleWrap.h | 2 +- accessible/src/atk/nsDocAccessibleWrap.cpp | 2 +- accessible/src/atk/nsDocAccessibleWrap.h | 2 +- accessible/src/atk/nsHTMLImageAccessibleWrap.h | 2 +- accessible/src/atk/nsHTMLTableAccessibleWrap.h | 2 +- accessible/src/atk/nsHyperTextAccessibleWrap.h | 2 +- accessible/src/atk/nsMai.h | 2 +- accessible/src/atk/nsMaiHyperlink.cpp | 2 +- accessible/src/atk/nsMaiHyperlink.h | 2 +- accessible/src/atk/nsMaiInterfaceAction.cpp | 2 +- accessible/src/atk/nsMaiInterfaceAction.h | 2 +- accessible/src/atk/nsMaiInterfaceComponent.cpp | 3 +-- accessible/src/atk/nsMaiInterfaceComponent.h | 3 +-- accessible/src/atk/nsMaiInterfaceDocument.cpp | 2 +- accessible/src/atk/nsMaiInterfaceDocument.h | 2 +- accessible/src/atk/nsMaiInterfaceEditableText.cpp | 2 +- accessible/src/atk/nsMaiInterfaceEditableText.h | 2 +- accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp | 2 +- accessible/src/atk/nsMaiInterfaceHyperlinkImpl.h | 2 +- accessible/src/atk/nsMaiInterfaceHypertext.cpp | 2 +- accessible/src/atk/nsMaiInterfaceHypertext.h | 2 +- accessible/src/atk/nsMaiInterfaceImage.cpp | 2 +- accessible/src/atk/nsMaiInterfaceImage.h | 2 +- accessible/src/atk/nsMaiInterfaceSelection.cpp | 2 +- accessible/src/atk/nsMaiInterfaceSelection.h | 2 +- accessible/src/atk/nsMaiInterfaceTable.cpp | 2 +- accessible/src/atk/nsMaiInterfaceTable.h | 2 +- accessible/src/atk/nsMaiInterfaceText.cpp | 2 +- accessible/src/atk/nsMaiInterfaceText.h | 2 +- accessible/src/atk/nsMaiInterfaceValue.cpp | 2 +- accessible/src/atk/nsMaiInterfaceValue.h | 2 +- accessible/src/atk/nsRoleMap.h | 2 +- accessible/src/atk/nsRootAccessibleWrap.cpp | 2 +- accessible/src/atk/nsRootAccessibleWrap.h | 2 +- accessible/src/atk/nsStateMap.h | 2 +- accessible/src/atk/nsTextAccessibleWrap.h | 2 +- accessible/src/atk/nsXULListboxAccessibleWrap.h | 2 +- accessible/src/atk/nsXULMenuAccessibleWrap.h | 2 +- accessible/src/atk/nsXULTreeGridAccessibleWrap.h | 2 +- 48 files changed, 48 insertions(+), 52 deletions(-)
2011-05-28 02:37:24 +04:00
/* vim: set ts=2 et sw=2 tw=80: */
2012-05-21 15:12:37 +04:00
/* 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/. */
#include "InterfaceInitFuncs.h"
#include "LocalAccessible-inl.h"
#include "AccessibleWrap.h"
#include "DocAccessible.h"
#include "nsMai.h"
#include "RemoteAccessible.h"
#include "mozilla/a11y/DocAccessibleParent.h"
#include "mozilla/Likely.h"
using namespace mozilla::a11y;
static const char* const kDocTypeName = "W3C-doctype";
static const char* const kDocUrlName = "DocURL";
static const char* const kMimeTypeName = "MimeType";
// below functions are vfuncs on an ATK interface so they need to be C call
extern "C" {
static const gchar* getDocumentLocaleCB(AtkDocument* aDocument);
static AtkAttributeSet* getDocumentAttributesCB(AtkDocument* aDocument);
static const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
const gchar* aAttrName);
void documentInterfaceInitCB(AtkDocumentIface* aIface) {
NS_ASSERTION(aIface, "Invalid Interface");
if (MOZ_UNLIKELY(!aIface)) return;
/*
* We don't support get_document or set_attribute right now.
* get_document_type is deprecated, we return DocType in
* get_document_attribute_value and get_document_attributes instead.
*/
aIface->get_document_attributes = getDocumentAttributesCB;
aIface->get_document_attribute_value = getDocumentAttributeValueCB;
aIface->get_document_locale = getDocumentLocaleCB;
}
const gchar* getDocumentLocaleCB(AtkDocument* aDocument) {
nsAutoString locale;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
if (accWrap) {
accWrap->Language(locale);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aDocument))) {
proxy->Language(locale);
}
return locale.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(locale);
}
static inline GSList* prependToList(GSList* aList, const char* const aName,
const nsAutoString& aValue) {
if (aValue.IsEmpty()) {
return aList;
}
// libspi will free these
AtkAttribute* atkAttr = (AtkAttribute*)g_malloc(sizeof(AtkAttribute));
atkAttr->name = g_strdup(aName);
atkAttr->value = g_strdup(NS_ConvertUTF16toUTF8(aValue).get());
return g_slist_prepend(aList, atkAttr);
}
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 (RemoteAccessible* 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;
}
const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
const gchar* aAttrName) {
RemoteAccessible* proxy = nullptr;
DocAccessible* document = nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
if (accWrap) {
if (!accWrap->IsDoc()) {
return nullptr;
}
document = accWrap->AsDoc();
} else {
proxy = GetProxy(ATK_OBJECT(aDocument));
if (!proxy) {
return nullptr;
}
MOZ_ASSERT(proxy->IsDoc());
}
nsAutoString attrValue;
if (!strcasecmp(aAttrName, kDocTypeName)) {
if (document) {
document->DocType(attrValue);
} else {
proxy->DocType(attrValue);
}
} else if (!strcasecmp(aAttrName, kDocUrlName)) {
if (document) {
document->URL(attrValue);
} else {
proxy->AsDoc()->URL(attrValue);
}
} else if (!strcasecmp(aAttrName, kMimeTypeName)) {
if (document) {
document->MimeType(attrValue);
} else {
proxy->MimeType(attrValue);
}
} else {
return nullptr;
}
return attrValue.IsEmpty() ? nullptr
: AccessibleWrap::ReturnString(attrValue);
}
}