Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format

# ignore-this-changeset
This commit is contained in:
Sylvestre Ledru
2018-11-30 11:46:48 +01:00
parent 93e0058268
commit e5a134f73a
10591 changed files with 1454100 additions and 1738928 deletions

48
.hg-format-source Normal file
View File

@@ -0,0 +1,48 @@
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:uriloader/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:media/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:docshell/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:netwerk/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:ipc/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:intl/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:taskcluster/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:servo/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:devtools/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:python/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:gfx/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:image/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:js/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:editor/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:parser/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:widget/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:mfbt/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:services/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:caps/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:chrome/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:extensions/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:view/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:xpfe/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:accessible/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:browser/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:toolkit/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:addon-sdk/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:config/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:embedding/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:security/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:dom/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:tools/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:gradle/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:storage/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:nsprpub/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:db/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:layout/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:xpcom/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:testing/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:other-licenses/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:modules/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:build/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:memory/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:mobile/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:startupcache/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:hal/**", "tool": "clang-format"}
{"configpaths": [".clang-format", ".clang-format-ignore"], "pattern": "glob:mozglue/**", "tool": "clang-format"}

View File

@@ -16,7 +16,7 @@ namespace a11y {
typedef class ARIAGridAccessible ARIAGridAccessibleWrap;
typedef class ARIAGridCellAccessible ARIAGridCellAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -29,8 +29,7 @@ IDSet sIDSet(31UL);
// construction
//-----------------------------------------------------
AccessibleWrap::AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc)
: Accessible(aContent, aDoc)
{
: Accessible(aContent, aDoc) {
if (aDoc) {
mID = AcquireID();
DocAccessibleWrap* doc = static_cast<DocAccessibleWrap*>(aDoc);
@@ -43,25 +42,27 @@ AccessibleWrap::AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc)
//-----------------------------------------------------
AccessibleWrap::~AccessibleWrap() {}
nsresult
AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
{
nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) {
auto accessible = static_cast<AccessibleWrap*>(aEvent->GetAccessible());
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
DocAccessibleWrap* doc = static_cast<DocAccessibleWrap*>(accessible->Document());
DocAccessibleWrap* doc =
static_cast<DocAccessibleWrap*>(accessible->Document());
if (doc) {
switch (aEvent->GetEventType()) {
case nsIAccessibleEvent::EVENT_FOCUS: {
if (DocAccessibleWrap* topContentDoc = doc->GetTopLevelContentDoc(accessible)) {
if (DocAccessibleWrap* topContentDoc =
doc->GetTopLevelContentDoc(accessible)) {
topContentDoc->CacheFocusPath(accessible);
}
break;
}
case nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED: {
AccVCChangeEvent* vcEvent = downcast_accEvent(aEvent);
auto newPosition = static_cast<AccessibleWrap*>(vcEvent->NewAccessible());
auto newPosition =
static_cast<AccessibleWrap*>(vcEvent->NewAccessible());
if (newPosition) {
if (DocAccessibleWrap* topContentDoc = doc->GetTopLevelContentDoc(accessible)) {
if (DocAccessibleWrap* topContentDoc =
doc->GetTopLevelContentDoc(accessible)) {
topContentDoc->CacheFocusPath(newPosition);
}
}
@@ -90,7 +91,7 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
}
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(accessible);
SessionAccessibility::GetInstanceFor(accessible);
if (!sessionAcc) {
return NS_OK;
}
@@ -115,7 +116,7 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
if (vcEvent->BoundaryType() != nsIAccessiblePivot::NO_BOUNDARY) {
sessionAcc->SendTextTraversedEvent(
newPosition, vcEvent->NewStartOffset(), vcEvent->NewEndOffset());
newPosition, vcEvent->NewStartOffset(), vcEvent->NewEndOffset());
}
}
break;
@@ -129,12 +130,10 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
case nsIAccessibleEvent::EVENT_TEXT_INSERTED:
case nsIAccessibleEvent::EVENT_TEXT_REMOVED: {
AccTextChangeEvent* event = downcast_accEvent(aEvent);
sessionAcc->SendTextChangedEvent(accessible,
event->ModifiedText(),
event->GetStartOffset(),
event->GetLength(),
event->IsTextInserted(),
event->IsFromUserInput());
sessionAcc->SendTextChangedEvent(
accessible, event->ModifiedText(), event->GetStartOffset(),
event->GetLength(), event->IsTextInserted(),
event->IsFromUserInput());
break;
}
case nsIAccessibleEvent::EVENT_STATE_CHANGE: {
@@ -155,10 +154,8 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
}
case nsIAccessibleEvent::EVENT_SCROLLING: {
AccScrollingEvent* event = downcast_accEvent(aEvent);
sessionAcc->SendScrollingEvent(accessible,
event->ScrollX(),
event->ScrollY(),
event->MaxScrollX(),
sessionAcc->SendScrollingEvent(accessible, event->ScrollX(),
event->ScrollY(), event->MaxScrollX(),
event->MaxScrollY());
break;
}
@@ -176,9 +173,7 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
return NS_OK;
}
void
AccessibleWrap::Shutdown()
{
void AccessibleWrap::Shutdown() {
if (mDoc) {
if (mID > 0) {
if (auto doc = static_cast<DocAccessibleWrap*>(mDoc.get())) {
@@ -192,27 +187,17 @@ AccessibleWrap::Shutdown()
Accessible::Shutdown();
}
int32_t
AccessibleWrap::AcquireID()
{
return sIDSet.GetID();
}
int32_t AccessibleWrap::AcquireID() { return sIDSet.GetID(); }
void
AccessibleWrap::ReleaseID(int32_t aID)
{
sIDSet.ReleaseID(aID);
}
void AccessibleWrap::ReleaseID(int32_t aID) { sIDSet.ReleaseID(aID); }
void
AccessibleWrap::SetTextContents(const nsAString& aText) {
void AccessibleWrap::SetTextContents(const nsAString& aText) {
if (IsHyperText()) {
AsHyperText()->ReplaceText(aText);
}
}
void
AccessibleWrap::GetTextContents(nsAString& aText) {
void AccessibleWrap::GetTextContents(nsAString& aText) {
// For now it is a simple wrapper for getting entire range of TextSubstring.
// In the future this may be smarter and retrieve a flattened string.
if (IsHyperText()) {
@@ -220,8 +205,8 @@ AccessibleWrap::GetTextContents(nsAString& aText) {
}
}
bool
AccessibleWrap::GetSelectionBounds(int32_t* aStartOffset, int32_t* aEndOffset) {
bool AccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
int32_t* aEndOffset) {
if (IsHyperText()) {
return AsHyperText()->SelectionBoundsAt(0, aStartOffset, aEndOffset);
}
@@ -229,9 +214,7 @@ AccessibleWrap::GetSelectionBounds(int32_t* aStartOffset, int32_t* aEndOffset) {
return false;
}
uint32_t
AccessibleWrap::GetFlags(role aRole, uint64_t aState)
{
uint32_t AccessibleWrap::GetFlags(role aRole, uint64_t aState) {
uint32_t flags = 0;
if (aState & states::CHECKABLE) {
flags |= java::SessionAccessibility::FLAG_CHECKABLE;
@@ -288,15 +271,12 @@ AccessibleWrap::GetFlags(role aRole, uint64_t aState)
return flags;
}
void
AccessibleWrap::GetRoleDescription(role aRole,
nsAString& aGeckoRole,
nsAString& aRoleDescription)
{
void AccessibleWrap::GetRoleDescription(role aRole, nsAString& aGeckoRole,
nsAString& aRoleDescription) {
nsresult rv = NS_OK;
nsCOMPtr<nsIStringBundleService> sbs =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to get string bundle service");
return;
@@ -310,39 +290,31 @@ AccessibleWrap::GetRoleDescription(role aRole,
}
GetAccService()->GetStringRole(aRole, aGeckoRole);
rv = bundle->GetStringFromName(NS_ConvertUTF16toUTF8(aGeckoRole).get(), aRoleDescription);
rv = bundle->GetStringFromName(NS_ConvertUTF16toUTF8(aGeckoRole).get(),
aRoleDescription);
if (NS_FAILED(rv)) {
aRoleDescription.AssignLiteral("");
}
}
already_AddRefed<nsIPersistentProperties>
AccessibleWrap::AttributeArrayToProperties(const nsTArray<Attribute>& aAttributes)
{
AccessibleWrap::AttributeArrayToProperties(
const nsTArray<Attribute>& aAttributes) {
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
nsAutoString unused;
for (size_t i = 0; i < aAttributes.Length(); i++) {
props->SetStringProperty(aAttributes.ElementAt(i).Name(),
aAttributes.ElementAt(i).Value(),
unused);
aAttributes.ElementAt(i).Value(), unused);
}
return props.forget();
}
int32_t
AccessibleWrap::GetAndroidClass(role aRole)
{
#define ROLE(geckoRole, \
stringRole, \
atkRole, \
macRole, \
msaaRole, \
ia2Role, \
androidClass, \
nameRule) \
case roles::geckoRole: \
int32_t AccessibleWrap::GetAndroidClass(role aRole) {
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, \
androidClass, nameRule) \
case roles::geckoRole: \
return androidClass;
switch (aRole) {
@@ -354,11 +326,10 @@ AccessibleWrap::GetAndroidClass(role aRole)
#undef ROLE
}
int32_t
AccessibleWrap::GetInputType(const nsString& aInputTypeAttr)
{
int32_t AccessibleWrap::GetInputType(const nsString& aInputTypeAttr) {
if (aInputTypeAttr.EqualsIgnoreCase("email")) {
return java::sdk::InputType::TYPE_CLASS_TEXT | java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
return java::sdk::InputType::TYPE_CLASS_TEXT |
java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
}
if (aInputTypeAttr.EqualsIgnoreCase("number")) {
@@ -366,7 +337,8 @@ AccessibleWrap::GetInputType(const nsString& aInputTypeAttr)
}
if (aInputTypeAttr.EqualsIgnoreCase("password")) {
return java::sdk::InputType::TYPE_CLASS_TEXT | java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_PASSWORD;
return java::sdk::InputType::TYPE_CLASS_TEXT |
java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_PASSWORD;
}
if (aInputTypeAttr.EqualsIgnoreCase("tel")) {
@@ -374,19 +346,19 @@ AccessibleWrap::GetInputType(const nsString& aInputTypeAttr)
}
if (aInputTypeAttr.EqualsIgnoreCase("text")) {
return java::sdk::InputType::TYPE_CLASS_TEXT | java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
return java::sdk::InputType::TYPE_CLASS_TEXT |
java::sdk::InputType::TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
}
if (aInputTypeAttr.EqualsIgnoreCase("url")) {
return java::sdk::InputType::TYPE_CLASS_TEXT | java::sdk::InputType::TYPE_TEXT_VARIATION_URI;
return java::sdk::InputType::TYPE_CLASS_TEXT |
java::sdk::InputType::TYPE_TEXT_VARIATION_URI;
}
return 0;
}
void
AccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID)
{
void AccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
if (mContent) {
nsAtom* id = mContent->GetID();
if (id) {
@@ -395,10 +367,8 @@ AccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID)
}
}
bool
AccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
double* aMaxVal, double* aStep)
{
bool AccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
double* aMaxVal, double* aStep) {
if (HasNumericValue()) {
*aCurVal = CurValue();
*aMinVal = MinValue();
@@ -410,9 +380,7 @@ AccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
return false;
}
mozilla::java::GeckoBundle::LocalRef
AccessibleWrap::ToBundle()
{
mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle() {
nsAutoString name;
Name(name);
nsAutoString textValue;
@@ -428,22 +396,15 @@ AccessibleWrap::ToBundle()
nsCOMPtr<nsIPersistentProperties> attributes = Attributes();
return ToBundle(State(), Bounds(), name, textValue, nodeID,
curValue, minValue, maxValue, step, attributes);
return ToBundle(State(), Bounds(), name, textValue, nodeID, curValue,
minValue, maxValue, step, attributes);
}
mozilla::java::GeckoBundle::LocalRef
AccessibleWrap::ToBundle(const uint64_t aState,
const nsIntRect& aBounds,
const nsString& aName,
const nsString& aTextValue,
const nsString& aDOMNodeID,
const double& aCurVal,
const double& aMinVal,
const double& aMaxVal,
const double& aStep,
nsIPersistentProperties* aAttributes)
{
mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
const uint64_t aState, const nsIntRect& aBounds, const nsString& aName,
const nsString& aTextValue, const nsString& aDOMNodeID,
const double& aCurVal, const double& aMinVal, const double& aMaxVal,
const double& aStep, nsIPersistentProperties* aAttributes) {
if (!IsProxy() && IsDefunct()) {
return nullptr;
}
@@ -452,13 +413,15 @@ AccessibleWrap::ToBundle(const uint64_t aState,
GECKOBUNDLE_PUT(nodeInfo, "id", java::sdk::Integer::ValueOf(VirtualViewID()));
AccessibleWrap* parent = WrapperParent();
GECKOBUNDLE_PUT(nodeInfo, "parentId",
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
GECKOBUNDLE_PUT(
nodeInfo, "parentId",
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
role role = WrapperRole();
uint32_t flags = GetFlags(role, aState);
GECKOBUNDLE_PUT(nodeInfo, "flags", java::sdk::Integer::ValueOf(flags));
GECKOBUNDLE_PUT(nodeInfo, "className", java::sdk::Integer::ValueOf(AndroidClass()));
GECKOBUNDLE_PUT(nodeInfo, "className",
java::sdk::Integer::ValueOf(AndroidClass()));
if (aState & states::EDITABLE) {
GECKOBUNDLE_PUT(nodeInfo, "hint", jni::StringParam(aName));
@@ -473,36 +436,35 @@ AccessibleWrap::ToBundle(const uint64_t aState,
GetRoleDescription(role, geckoRole, roleDescription);
}
GECKOBUNDLE_PUT(
nodeInfo, "roleDescription", jni::StringParam(roleDescription));
GECKOBUNDLE_PUT(nodeInfo, "roleDescription",
jni::StringParam(roleDescription));
GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
GECKOBUNDLE_PUT(
nodeInfo, "roleDescription", jni::StringParam(roleDescription));
GECKOBUNDLE_PUT(nodeInfo, "roleDescription",
jni::StringParam(roleDescription));
GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
if (!aDOMNodeID.IsEmpty()) {
GECKOBUNDLE_PUT(
nodeInfo, "viewIdResourceName", jni::StringParam(aDOMNodeID));
GECKOBUNDLE_PUT(nodeInfo, "viewIdResourceName",
jni::StringParam(aDOMNodeID));
}
nsIntRect bounds = Bounds();
const int32_t data[4] = {
bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height
};
const int32_t data[4] = {bounds.x, bounds.y, bounds.x + bounds.width,
bounds.y + bounds.height};
GECKOBUNDLE_PUT(nodeInfo, "bounds", jni::IntArray::New(data, 4));
if (HasNumericValue()) {
GECKOBUNDLE_START(rangeInfo);
if (aMaxVal == 1 && aMinVal == 0) {
GECKOBUNDLE_PUT(
rangeInfo, "type", java::sdk::Integer::ValueOf(2)); // percent
GECKOBUNDLE_PUT(rangeInfo, "type",
java::sdk::Integer::ValueOf(2)); // percent
} else if (std::round(aStep) != aStep) {
GECKOBUNDLE_PUT(
rangeInfo, "type", java::sdk::Integer::ValueOf(1)); // float
GECKOBUNDLE_PUT(rangeInfo, "type",
java::sdk::Integer::ValueOf(1)); // float
} else {
GECKOBUNDLE_PUT(
rangeInfo, "type", java::sdk::Integer::ValueOf(0)); // integer
GECKOBUNDLE_PUT(rangeInfo, "type",
java::sdk::Integer::ValueOf(0)); // integer
}
if (!IsNaN(aCurVal)) {
@@ -523,23 +485,25 @@ AccessibleWrap::ToBundle(const uint64_t aState,
nsAccUtils::GetAccAttr(aAttributes, nsGkAtoms::textInputType, inputTypeAttr);
int32_t inputType = GetInputType(inputTypeAttr);
if (inputType) {
GECKOBUNDLE_PUT(nodeInfo, "inputType", java::sdk::Integer::ValueOf(inputType));
GECKOBUNDLE_PUT(nodeInfo, "inputType",
java::sdk::Integer::ValueOf(inputType));
}
nsString posinset;
nsresult rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("posinset"), posinset);
nsresult rv =
aAttributes->GetStringProperty(NS_LITERAL_CSTRING("posinset"), posinset);
if (NS_SUCCEEDED(rv)) {
int32_t rowIndex;
if (sscanf(NS_ConvertUTF16toUTF8(posinset).get(), "%d", &rowIndex) > 0) {
GECKOBUNDLE_START(collectionItemInfo);
GECKOBUNDLE_PUT(
collectionItemInfo, "rowIndex", java::sdk::Integer::ValueOf(rowIndex));
GECKOBUNDLE_PUT(
collectionItemInfo, "columnIndex", java::sdk::Integer::ValueOf(0));
GECKOBUNDLE_PUT(
collectionItemInfo, "rowSpan", java::sdk::Integer::ValueOf(1));
GECKOBUNDLE_PUT(
collectionItemInfo, "columnSpan", java::sdk::Integer::ValueOf(1));
GECKOBUNDLE_PUT(collectionItemInfo, "rowIndex",
java::sdk::Integer::ValueOf(rowIndex));
GECKOBUNDLE_PUT(collectionItemInfo, "columnIndex",
java::sdk::Integer::ValueOf(0));
GECKOBUNDLE_PUT(collectionItemInfo, "rowSpan",
java::sdk::Integer::ValueOf(1));
GECKOBUNDLE_PUT(collectionItemInfo, "columnSpan",
java::sdk::Integer::ValueOf(1));
GECKOBUNDLE_FINISH(collectionItemInfo);
GECKOBUNDLE_PUT(nodeInfo, "collectionItemInfo", collectionItemInfo);
@@ -553,23 +517,22 @@ AccessibleWrap::ToBundle(const uint64_t aState,
int32_t rowCount;
if (sscanf(NS_ConvertUTF16toUTF8(colSize).get(), "%d", &rowCount) > 0) {
GECKOBUNDLE_START(collectionInfo);
GECKOBUNDLE_PUT(
collectionInfo, "rowCount", java::sdk::Integer::ValueOf(rowCount));
GECKOBUNDLE_PUT(
collectionInfo, "columnCount", java::sdk::Integer::ValueOf(1));
GECKOBUNDLE_PUT(collectionInfo, "rowCount",
java::sdk::Integer::ValueOf(rowCount));
GECKOBUNDLE_PUT(collectionInfo, "columnCount",
java::sdk::Integer::ValueOf(1));
nsString unused;
rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("hierarchical"),
unused);
if (NS_SUCCEEDED(rv)) {
GECKOBUNDLE_PUT(
collectionInfo, "isHierarchical", java::sdk::Boolean::TRUE());
GECKOBUNDLE_PUT(collectionInfo, "isHierarchical",
java::sdk::Boolean::TRUE());
}
if (IsSelect()) {
int32_t selectionMode = (aState & states::MULTISELECTABLE) ? 2 : 1;
GECKOBUNDLE_PUT(collectionInfo,
"selectionMode",
GECKOBUNDLE_PUT(collectionInfo, "selectionMode",
java::sdk::Integer::ValueOf(selectionMode));
}
GECKOBUNDLE_FINISH(collectionInfo);
@@ -585,37 +548,34 @@ AccessibleWrap::ToBundle(const uint64_t aState,
children.AppendElement(child->VirtualViewID());
}
GECKOBUNDLE_PUT(nodeInfo,
"children",
GECKOBUNDLE_PUT(nodeInfo, "children",
jni::IntArray::New(children.Elements(), children.Length()));
GECKOBUNDLE_FINISH(nodeInfo);
return nodeInfo;
}
mozilla::java::GeckoBundle::LocalRef
AccessibleWrap::ToSmallBundle()
{
mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToSmallBundle() {
return ToSmallBundle(State(), Bounds());
}
mozilla::java::GeckoBundle::LocalRef
AccessibleWrap::ToSmallBundle(const uint64_t aState, const nsIntRect& aBounds)
{
mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToSmallBundle(
const uint64_t aState, const nsIntRect& aBounds) {
GECKOBUNDLE_START(nodeInfo);
GECKOBUNDLE_PUT(nodeInfo, "id", java::sdk::Integer::ValueOf(VirtualViewID()));
AccessibleWrap* parent = WrapperParent();
GECKOBUNDLE_PUT(nodeInfo, "parentId",
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
GECKOBUNDLE_PUT(
nodeInfo, "parentId",
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
uint32_t flags = GetFlags(WrapperRole(), aState);
GECKOBUNDLE_PUT(nodeInfo, "flags", java::sdk::Integer::ValueOf(flags));
GECKOBUNDLE_PUT(nodeInfo, "className", java::sdk::Integer::ValueOf(AndroidClass()));
GECKOBUNDLE_PUT(nodeInfo, "className",
java::sdk::Integer::ValueOf(AndroidClass()));
const int32_t data[4] = {
aBounds.x, aBounds.y, aBounds.x + aBounds.width, aBounds.y + aBounds.height
};
const int32_t data[4] = {aBounds.x, aBounds.y, aBounds.x + aBounds.width,
aBounds.y + aBounds.height};
GECKOBUNDLE_PUT(nodeInfo, "bounds", jni::IntArray::New(data, 4));
auto childCount = ChildCount();
@@ -625,8 +585,7 @@ AccessibleWrap::ToSmallBundle(const uint64_t aState, const nsIntRect& aBounds)
children.AppendElement(child->VirtualViewID());
}
GECKOBUNDLE_PUT(nodeInfo,
"children",
GECKOBUNDLE_PUT(nodeInfo, "children",
jni::IntArray::New(children.Elements(), children.Length()));
GECKOBUNDLE_FINISH(nodeInfo);

View File

@@ -14,9 +14,8 @@
namespace mozilla {
namespace a11y {
class AccessibleWrap : public Accessible
{
public:
class AccessibleWrap : public Accessible {
public:
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
virtual ~AccessibleWrap();
@@ -33,36 +32,30 @@ public:
mozilla::java::GeckoBundle::LocalRef ToBundle();
mozilla::java::GeckoBundle::LocalRef ToBundle(const uint64_t aState,
const nsIntRect& aBounds,
const nsString& aName,
const nsString& aTextValue,
const nsString& aDOMNodeID,
const double& aCurVal,
const double& aMinVal,
const double& aMaxVal,
const double& aStep,
nsIPersistentProperties* aAttributes);
mozilla::java::GeckoBundle::LocalRef ToBundle(
const uint64_t aState, const nsIntRect& aBounds, const nsString& aName,
const nsString& aTextValue, const nsString& aDOMNodeID,
const double& aCurVal, const double& aMinVal, const double& aMaxVal,
const double& aStep, nsIPersistentProperties* aAttributes);
mozilla::java::GeckoBundle::LocalRef ToSmallBundle(const uint64_t aState, const nsIntRect& aBounds);
mozilla::java::GeckoBundle::LocalRef ToSmallBundle(const uint64_t aState,
const nsIntRect& aBounds);
mozilla::java::GeckoBundle::LocalRef ToSmallBundle();
virtual void WrapperDOMNodeID(nsString& aDOMNodeID);
int32_t AndroidClass()
{
int32_t AndroidClass() {
return mID == kNoID ? java::SessionAccessibility::CLASSNAME_WEBVIEW
: GetAndroidClass(WrapperRole());
}
static already_AddRefed<nsIPersistentProperties> AttributeArrayToProperties(
const nsTArray<Attribute>& aAttributes);
const nsTArray<Attribute>& aAttributes);
static const int32_t kNoID = -1;
protected:
protected:
// IDs should be a positive 32bit integer.
static int32_t AcquireID();
static void ReleaseID(int32_t aID);
@@ -73,26 +66,26 @@ protected:
int32_t mID;
private:
virtual AccessibleWrap* WrapperParent() { return static_cast<AccessibleWrap*>(Parent()); }
private:
virtual AccessibleWrap* WrapperParent() {
return static_cast<AccessibleWrap*>(Parent());
}
virtual bool WrapperRangeInfo(double* aCurVal, double* aMinVal, double* aMaxVal, double* aStep);
virtual bool WrapperRangeInfo(double* aCurVal, double* aMinVal,
double* aMaxVal, double* aStep);
virtual role WrapperRole() { return Role(); }
static void GetRoleDescription(role aRole,
nsAString& aGeckoRole,
static void GetRoleDescription(role aRole, nsAString& aGeckoRole,
nsAString& aRoleDescription);
static uint32_t GetFlags(role aRole, uint64_t aState);
};
static inline AccessibleWrap*
WrapperFor(const ProxyAccessible* aProxy)
{
static inline AccessibleWrap* WrapperFor(const ProxyAccessible* aProxy) {
return reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
}
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -14,7 +14,7 @@ namespace mozilla {
namespace a11y {
typedef ApplicationAccessible ApplicationAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -23,8 +23,7 @@ const uint32_t kCacheRefreshInterval = 500;
DocAccessibleWrap::DocAccessibleWrap(nsIDocument* aDocument,
nsIPresShell* aPresShell)
: DocAccessible(aDocument, aPresShell)
{
: DocAccessible(aDocument, aPresShell) {
nsCOMPtr<nsIDocShellTreeItem> treeItem(aDocument->GetDocShell());
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
@@ -42,9 +41,7 @@ DocAccessibleWrap::DocAccessibleWrap(nsIDocument* aDocument,
DocAccessibleWrap::~DocAccessibleWrap() {}
AccessibleWrap*
DocAccessibleWrap::GetAccessibleByID(int32_t aID) const
{
AccessibleWrap* DocAccessibleWrap::GetAccessibleByID(int32_t aID) const {
if (AccessibleWrap* acc = mIDToAccessibleMap.Get(aID)) {
return acc;
}
@@ -60,17 +57,13 @@ DocAccessibleWrap::GetAccessibleByID(int32_t aID) const
return nullptr;
}
void
DocAccessibleWrap::DoInitialUpdate()
{
void DocAccessibleWrap::DoInitialUpdate() {
DocAccessible::DoInitialUpdate();
CacheViewport();
}
nsresult
DocAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
{
switch(aEvent->GetEventType()) {
nsresult DocAccessibleWrap::HandleAccEvent(AccEvent* aEvent) {
switch (aEvent->GetEventType()) {
case nsIAccessibleEvent::EVENT_SHOW:
case nsIAccessibleEvent::EVENT_HIDE:
case nsIAccessibleEvent::EVENT_SCROLLING_END:
@@ -86,16 +79,15 @@ DocAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
return DocAccessible::HandleAccEvent(aEvent);
}
void
DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
{
RefPtr<DocAccessibleWrap> docAcc(dont_AddRef(
reinterpret_cast<DocAccessibleWrap*>(aDocAccParam)));
void DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer,
void* aDocAccParam) {
RefPtr<DocAccessibleWrap> docAcc(
dont_AddRef(reinterpret_cast<DocAccessibleWrap*>(aDocAccParam)));
if (!docAcc) {
return;
}
nsIPresShell *presShell = docAcc->PresShell();
nsIPresShell* presShell = docAcc->PresShell();
if (!presShell) {
return;
}
@@ -109,10 +101,8 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
nsRect scrollPort = sf ? sf->GetScrollPortRect() : rootFrame->GetRect();
nsLayoutUtils::GetFramesForArea(
presShell->GetRootFrame(),
scrollPort,
frames,
nsLayoutUtils::FrameForPointFlags::ONLY_VISIBLE);
presShell->GetRootFrame(), scrollPort, frames,
nsLayoutUtils::FrameForPointFlags::ONLY_VISIBLE);
AccessibleHashtable inViewAccs;
for (size_t i = 0; i < frames.Length(); i++) {
nsIContent* content = frames.ElementAt(i)->GetContent();
@@ -125,7 +115,8 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
continue;
}
for (Accessible* acc = visibleAcc; acc && acc != docAcc->Parent(); acc = acc->Parent()) {
for (Accessible* acc = visibleAcc; acc && acc != docAcc->Parent();
acc = acc->Parent()) {
if (inViewAccs.Contains(acc->UniqueID())) {
break;
}
@@ -138,27 +129,24 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
nsTArray<BatchData> cacheData(inViewAccs.Count());
for (auto iter = inViewAccs.Iter(); !iter.Done(); iter.Next()) {
Accessible* accessible = iter.Data();
auto uid = accessible->IsDoc() && accessible->AsDoc()->IPCDoc() ? 0
: reinterpret_cast<uint64_t>(accessible->UniqueID());
cacheData.AppendElement(BatchData(accessible->Document()->IPCDoc(),
uid,
accessible->State(),
accessible->Bounds(),
nsString(),
nsString(),
nsString(),
UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(),
nsTArray<Attribute>()));
auto uid = accessible->IsDoc() && accessible->AsDoc()->IPCDoc()
? 0
: reinterpret_cast<uint64_t>(accessible->UniqueID());
cacheData.AppendElement(
BatchData(accessible->Document()->IPCDoc(), uid, accessible->State(),
accessible->Bounds(), nsString(), nsString(), nsString(),
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
nsTArray<Attribute>()));
}
ipcDoc->SendBatch(eBatch_Viewport, cacheData);
} else if (SessionAccessibility* sessionAcc = SessionAccessibility::GetInstanceFor(docAcc)) {
} else if (SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(docAcc)) {
nsTArray<AccessibleWrap*> accessibles(inViewAccs.Count());
for (auto iter = inViewAccs.Iter(); !iter.Done(); iter.Next()) {
accessibles.AppendElement(static_cast<AccessibleWrap*>(iter.Data().get()));
accessibles.AppendElement(
static_cast<AccessibleWrap*>(iter.Data().get()));
}
sessionAcc->ReplaceViewportCache(accessibles);
@@ -169,25 +157,22 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
}
}
void
DocAccessibleWrap::CacheViewport()
{
void DocAccessibleWrap::CacheViewport() {
if (VirtualViewID() == kNoID && !mCacheRefreshTimer) {
NS_NewTimerWithFuncCallback(getter_AddRefs(mCacheRefreshTimer),
CacheViewportCallback,
this,
kCacheRefreshInterval,
nsITimer::TYPE_ONE_SHOT,
CacheViewportCallback, this,
kCacheRefreshInterval, nsITimer::TYPE_ONE_SHOT,
"a11y::DocAccessibleWrap::CacheViewport");
if (mCacheRefreshTimer) {
NS_ADDREF_THIS(); // Kung fu death grip
NS_ADDREF_THIS(); // Kung fu death grip
}
}
}
DocAccessibleWrap*
DocAccessibleWrap::GetTopLevelContentDoc(AccessibleWrap* aAccessible) {
DocAccessibleWrap* doc = static_cast<DocAccessibleWrap*>(aAccessible->Document());
DocAccessibleWrap* DocAccessibleWrap::GetTopLevelContentDoc(
AccessibleWrap* aAccessible) {
DocAccessibleWrap* doc =
static_cast<DocAccessibleWrap*>(aAccessible->Document());
while (doc && doc->VirtualViewID() != kNoID) {
doc = static_cast<DocAccessibleWrap*>(doc->ParentDocument());
}
@@ -195,17 +180,16 @@ DocAccessibleWrap::GetTopLevelContentDoc(AccessibleWrap* aAccessible) {
return doc;
}
void
DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible)
{
void DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible) {
mFocusPath.Clear();
if (IPCAccessibilityActive()) {
DocAccessibleChild* ipcDoc = IPCDoc();
nsTArray<BatchData> cacheData;
for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent();
acc = static_cast<AccessibleWrap*>(acc->Parent())) {
auto uid = acc->IsDoc() && acc->AsDoc()->IPCDoc() ? 0
: reinterpret_cast<uint64_t>(acc->UniqueID());
auto uid = acc->IsDoc() && acc->AsDoc()->IPCDoc()
? 0
: reinterpret_cast<uint64_t>(acc->UniqueID());
nsAutoString name;
acc->Name(name);
nsAutoString textValue;
@@ -215,23 +199,16 @@ DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible)
nsCOMPtr<nsIPersistentProperties> props = acc->Attributes();
nsTArray<Attribute> attributes;
nsAccUtils::PersistentPropertiesToArray(props, &attributes);
cacheData.AppendElement(BatchData(acc->Document()->IPCDoc(),
uid,
acc->State(),
acc->Bounds(),
name,
textValue,
nodeID,
acc->CurValue(),
acc->MinValue(),
acc->MaxValue(),
acc->Step(),
attributes));
cacheData.AppendElement(
BatchData(acc->Document()->IPCDoc(), uid, acc->State(), acc->Bounds(),
name, textValue, nodeID, acc->CurValue(), acc->MinValue(),
acc->MaxValue(), acc->Step(), attributes));
mFocusPath.Put(acc->UniqueID(), acc);
}
ipcDoc->SendBatch(eBatch_FocusPath, cacheData);
} else if (SessionAccessibility* sessionAcc = SessionAccessibility::GetInstanceFor(this)) {
} else if (SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(this)) {
nsTArray<AccessibleWrap*> accessibles;
for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent();
acc = static_cast<AccessibleWrap*>(acc->Parent())) {
@@ -242,9 +219,7 @@ DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible)
}
}
void
DocAccessibleWrap::UpdateFocusPathBounds()
{
void DocAccessibleWrap::UpdateFocusPathBounds() {
if (!mFocusPath.Count()) {
return;
}
@@ -254,27 +229,23 @@ DocAccessibleWrap::UpdateFocusPathBounds()
nsTArray<BatchData> boundsData(mFocusPath.Count());
for (auto iter = mFocusPath.Iter(); !iter.Done(); iter.Next()) {
Accessible* accessible = iter.Data();
auto uid = accessible->IsDoc() && accessible->AsDoc()->IPCDoc() ? 0
: reinterpret_cast<uint64_t>(accessible->UniqueID());
boundsData.AppendElement(BatchData(accessible->Document()->IPCDoc(),
uid,
0,
accessible->Bounds(),
nsString(),
nsString(),
nsString(),
UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(),
nsTArray<Attribute>()));
auto uid = accessible->IsDoc() && accessible->AsDoc()->IPCDoc()
? 0
: reinterpret_cast<uint64_t>(accessible->UniqueID());
boundsData.AppendElement(BatchData(
accessible->Document()->IPCDoc(), uid, 0, accessible->Bounds(),
nsString(), nsString(), nsString(), UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
UnspecifiedNaN<double>(), nsTArray<Attribute>()));
}
ipcDoc->SendBatch(eBatch_BoundsUpdate, boundsData);
} else if (SessionAccessibility* sessionAcc = SessionAccessibility::GetInstanceFor(this)) {
} else if (SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(this)) {
nsTArray<AccessibleWrap*> accessibles(mFocusPath.Count());
for (auto iter = mFocusPath.Iter(); !iter.Done(); iter.Next()) {
accessibles.AppendElement(static_cast<AccessibleWrap*>(iter.Data().get()));
accessibles.AppendElement(
static_cast<AccessibleWrap*>(iter.Data().get()));
}
sessionAcc->UpdateCachedBounds(accessibles);

View File

@@ -12,9 +12,8 @@
namespace mozilla {
namespace a11y {
class DocAccessibleWrap : public DocAccessible
{
public:
class DocAccessibleWrap : public DocAccessible {
public:
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
virtual ~DocAccessibleWrap();
@@ -23,8 +22,7 @@ public:
/**
* Manage the mapping from id to Accessible.
*/
void AddID(uint32_t aID, AccessibleWrap* aAcc)
{
void AddID(uint32_t aID, AccessibleWrap* aAcc) {
mIDToAccessibleMap.Put(aID, aAcc);
}
void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
@@ -40,7 +38,7 @@ public:
eBatch_BoundsUpdate = 2,
};
protected:
protected:
/*
* This provides a mapping from 32 bit id to accessible objects.
*/
@@ -48,7 +46,7 @@ protected:
virtual void DoInitialUpdate() override;
private:
private:
void CacheViewport();
void UpdateFocusPathBounds();
@@ -60,7 +58,7 @@ private:
AccessibleHashtable mFocusPath;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -17,7 +17,7 @@ typedef class HTMLTableAccessible HTMLTableAccessibleWrap;
typedef class HTMLTableCellAccessible HTMLTableCellAccessibleWrap;
typedef class HTMLTableHeaderCellAccessible HTMLTableHeaderCellAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -13,7 +13,7 @@ namespace a11y {
typedef class HyperTextAccessible HyperTextAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -15,7 +15,7 @@ namespace a11y {
typedef class ImageAccessible ImageAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -15,19 +15,11 @@
using namespace mozilla;
using namespace mozilla::a11y;
void
a11y::PlatformInit()
{
}
void a11y::PlatformInit() {}
void
a11y::PlatformShutdown()
{
}
void a11y::PlatformShutdown() {}
void
a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t aInterfaces)
{
void a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t aInterfaces) {
AccessibleWrap* wrapper = nullptr;
if (aProxy->IsDoc()) {
wrapper = new DocProxyAccessibleWrap(aProxy->AsDoc());
@@ -39,11 +31,9 @@ a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t aInterfaces)
aProxy->SetWrapper(reinterpret_cast<uintptr_t>(wrapper));
}
void
a11y::ProxyDestroyed(ProxyAccessible* aProxy)
{
void a11y::ProxyDestroyed(ProxyAccessible* aProxy) {
AccessibleWrap* wrapper =
reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
// If aProxy is a document that was created, but
// RecvPDocAccessibleConstructor failed then aProxy->GetWrapper() will be
@@ -57,11 +47,9 @@ a11y::ProxyDestroyed(ProxyAccessible* aProxy)
wrapper->Release();
}
void
a11y::ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType)
{
void a11y::ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType) {
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
SessionAccessibility::GetInstanceFor(aTarget);
if (!sessionAcc) {
return;
}
@@ -73,13 +61,10 @@ a11y::ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType)
}
}
void
a11y::ProxyStateChangeEvent(ProxyAccessible* aTarget,
uint64_t aState,
bool aEnabled)
{
void a11y::ProxyStateChangeEvent(ProxyAccessible* aTarget, uint64_t aState,
bool aEnabled) {
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
SessionAccessibility::GetInstanceFor(aTarget);
if (!sessionAcc) {
return;
@@ -98,70 +83,51 @@ a11y::ProxyStateChangeEvent(ProxyAccessible* aTarget,
}
}
void
a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset)
{
void a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset) {
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
SessionAccessibility::GetInstanceFor(aTarget);
if (sessionAcc) {
sessionAcc->SendTextSelectionChangedEvent(WrapperFor(aTarget), aOffset);
}
}
void
a11y::ProxyTextChangeEvent(ProxyAccessible* aTarget,
const nsString& aStr,
int32_t aStart,
uint32_t aLen,
bool aIsInsert,
bool aFromUser)
{
void a11y::ProxyTextChangeEvent(ProxyAccessible* aTarget, const nsString& aStr,
int32_t aStart, uint32_t aLen, bool aIsInsert,
bool aFromUser) {
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
SessionAccessibility::GetInstanceFor(aTarget);
if (sessionAcc) {
sessionAcc->SendTextChangedEvent(
WrapperFor(aTarget), aStr, aStart, aLen, aIsInsert, aFromUser);
sessionAcc->SendTextChangedEvent(WrapperFor(aTarget), aStr, aStart, aLen,
aIsInsert, aFromUser);
}
}
void
a11y::ProxyShowHideEvent(ProxyAccessible* aTarget,
ProxyAccessible* aParent,
bool aInsert,
bool aFromUser)
{
void a11y::ProxyShowHideEvent(ProxyAccessible* aTarget,
ProxyAccessible* aParent, bool aInsert,
bool aFromUser) {
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
SessionAccessibility::GetInstanceFor(aTarget);
if (sessionAcc) {
sessionAcc->SendWindowContentChangedEvent(WrapperFor(aParent));
}
}
void
a11y::ProxySelectionEvent(ProxyAccessible*, ProxyAccessible*, uint32_t)
{
}
void a11y::ProxySelectionEvent(ProxyAccessible*, ProxyAccessible*, uint32_t) {}
void
a11y::ProxyVirtualCursorChangeEvent(ProxyAccessible* aTarget,
ProxyAccessible* aOldPosition,
int32_t aOldStartOffset,
int32_t aOldEndOffset,
ProxyAccessible* aNewPosition,
int32_t aNewStartOffset,
int32_t aNewEndOffset,
int16_t aReason,
int16_t aBoundaryType,
bool aFromUser)
{
void a11y::ProxyVirtualCursorChangeEvent(
ProxyAccessible* aTarget, ProxyAccessible* aOldPosition,
int32_t aOldStartOffset, int32_t aOldEndOffset,
ProxyAccessible* aNewPosition, int32_t aNewStartOffset,
int32_t aNewEndOffset, int16_t aReason, int16_t aBoundaryType,
bool aFromUser) {
if (!aNewPosition) {
return;
}
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
SessionAccessibility::GetInstanceFor(aTarget);
if (!sessionAcc) {
return;
@@ -176,38 +142,30 @@ a11y::ProxyVirtualCursorChangeEvent(ProxyAccessible* aTarget,
}
if (aBoundaryType != nsIAccessiblePivot::NO_BOUNDARY) {
sessionAcc->SendTextTraversedEvent(
WrapperFor(aNewPosition), aNewStartOffset, aNewEndOffset);
sessionAcc->SendTextTraversedEvent(WrapperFor(aNewPosition),
aNewStartOffset, aNewEndOffset);
}
}
void
a11y::ProxyScrollingEvent(ProxyAccessible* aTarget,
uint32_t aEventType,
uint32_t aScrollX,
uint32_t aScrollY,
uint32_t aMaxScrollX,
uint32_t aMaxScrollY)
{
void a11y::ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType,
uint32_t aScrollX, uint32_t aScrollY,
uint32_t aMaxScrollX, uint32_t aMaxScrollY) {
if (aEventType == nsIAccessibleEvent::EVENT_SCROLLING) {
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
SessionAccessibility::GetInstanceFor(aTarget);
if (sessionAcc) {
sessionAcc->SendScrollingEvent(
WrapperFor(aTarget), aScrollX, aScrollY, aMaxScrollX, aMaxScrollY);
sessionAcc->SendScrollingEvent(WrapperFor(aTarget), aScrollX, aScrollY,
aMaxScrollX, aMaxScrollY);
}
}
}
void
a11y::ProxyBatch(ProxyAccessible* aDocument,
const uint64_t aBatchType,
const nsTArray<ProxyAccessible*>& aAccessibles,
const nsTArray<BatchData>& aData)
{
void a11y::ProxyBatch(ProxyAccessible* aDocument, const uint64_t aBatchType,
const nsTArray<ProxyAccessible*>& aAccessibles,
const nsTArray<BatchData>& aData) {
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aDocument);
SessionAccessibility::GetInstanceFor(aDocument);
if (!sessionAcc) {
return;
}

View File

@@ -9,8 +9,7 @@
using namespace mozilla::a11y;
ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
: AccessibleWrap(nullptr, nullptr)
{
: AccessibleWrap(nullptr, nullptr) {
mType = eProxyType;
mBits.proxy = aProxy;
@@ -27,18 +26,16 @@ ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
}
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
Proxy()->Document()->GetWrapper());
Proxy()->Document()->GetWrapper());
if (doc) {
mID = AcquireID();
doc->AddID(mID, this);
}
}
void
ProxyAccessibleWrap::Shutdown()
{
void ProxyAccessibleWrap::Shutdown() {
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
Proxy()->Document()->GetWrapper());
Proxy()->Document()->GetWrapper());
if (mID && doc) {
doc->RemoveID(mID);
ReleaseID(mID);
@@ -51,100 +48,64 @@ ProxyAccessibleWrap::Shutdown()
// Accessible
already_AddRefed<nsIPersistentProperties>
ProxyAccessibleWrap::Attributes()
{
already_AddRefed<nsIPersistentProperties> ProxyAccessibleWrap::Attributes() {
AutoTArray<Attribute, 10> attrs;
Proxy()->Attributes(&attrs);
return AttributeArrayToProperties(attrs);
}
uint32_t
ProxyAccessibleWrap::ChildCount() const
{
uint32_t ProxyAccessibleWrap::ChildCount() const {
return Proxy()->ChildrenCount();
}
Accessible*
ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const
{
Accessible* ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const {
ProxyAccessible* child = Proxy()->ChildAt(aIndex);
return child ? WrapperFor(child) : nullptr;
}
ENameValueFlag
ProxyAccessibleWrap::Name(nsString& aName) const
{
ENameValueFlag ProxyAccessibleWrap::Name(nsString& aName) const {
Proxy()->Name(aName);
return eNameOK;
}
void
ProxyAccessibleWrap::Value(nsString& aValue) const
{
void ProxyAccessibleWrap::Value(nsString& aValue) const {
Proxy()->Value(aValue);
}
uint64_t
ProxyAccessibleWrap::State()
{
return Proxy()->State();
}
uint64_t ProxyAccessibleWrap::State() { return Proxy()->State(); }
nsIntRect
ProxyAccessibleWrap::Bounds() const
{
return Proxy()->Bounds();
}
nsIntRect ProxyAccessibleWrap::Bounds() const { return Proxy()->Bounds(); }
void
ProxyAccessibleWrap::ScrollTo(uint32_t aHow) const
{
void ProxyAccessibleWrap::ScrollTo(uint32_t aHow) const {
Proxy()->ScrollTo(aHow);
}
// Other
void
ProxyAccessibleWrap::SetTextContents(const nsAString& aText)
{
void ProxyAccessibleWrap::SetTextContents(const nsAString& aText) {
Proxy()->ReplaceText(PromiseFlatString(aText));
}
void
ProxyAccessibleWrap::GetTextContents(nsAString& aText)
{
void ProxyAccessibleWrap::GetTextContents(nsAString& aText) {
nsAutoString text;
Proxy()->TextSubstring(0, -1, text);
aText.Assign(text);
}
bool
ProxyAccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
int32_t* aEndOffset)
{
bool ProxyAccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
int32_t* aEndOffset) {
nsAutoString unused;
return Proxy()->SelectionBoundsAt(0, unused, aStartOffset, aEndOffset);
}
role
ProxyAccessibleWrap::WrapperRole()
{
return Proxy()->Role();
}
role ProxyAccessibleWrap::WrapperRole() { return Proxy()->Role(); }
AccessibleWrap*
ProxyAccessibleWrap::WrapperParent()
{
AccessibleWrap* ProxyAccessibleWrap::WrapperParent() {
return Proxy()->Parent() ? WrapperFor(Proxy()->Parent()) : nullptr;
}
bool
ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal,
double* aMinVal,
double* aMaxVal,
double* aStep)
{
bool ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
double* aMaxVal, double* aStep) {
if (HasNumericValue()) {
ProxyAccessible* proxy = Proxy();
*aCurVal = proxy->CurValue();
@@ -157,8 +118,6 @@ ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal,
return false;
}
void
ProxyAccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID)
{
void ProxyAccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
Proxy()->DOMNodeID(aDOMNodeID);
}

View File

@@ -21,9 +21,8 @@ namespace a11y {
* to distinguish between a local or remote accessibles.
* NOTE: This shouldn't be regarded as a full Accessible implementation.
*/
class ProxyAccessibleWrap : public AccessibleWrap
{
public:
class ProxyAccessibleWrap : public AccessibleWrap {
public:
explicit ProxyAccessibleWrap(ProxyAccessible* aProxy);
virtual void Shutdown() override;
@@ -52,24 +51,24 @@ public:
virtual void GetTextContents(nsAString& aText) override;
virtual bool GetSelectionBounds(int32_t* aStartOffset, int32_t* aEndOffset) override;
virtual bool GetSelectionBounds(int32_t* aStartOffset,
int32_t* aEndOffset) override;
virtual void WrapperDOMNodeID(nsString& aDOMNodeID) override;
private:
private:
virtual role WrapperRole() override;
virtual AccessibleWrap* WrapperParent() override;
virtual bool WrapperRangeInfo(double* aCurVal, double* aMinVal, double* aMaxVal, double* aStep) override;
virtual bool WrapperRangeInfo(double* aCurVal, double* aMinVal,
double* aMaxVal, double* aStep) override;
};
class DocProxyAccessibleWrap : public ProxyAccessibleWrap
{
public:
class DocProxyAccessibleWrap : public ProxyAccessibleWrap {
public:
explicit DocProxyAccessibleWrap(DocAccessibleParent* aProxy)
: ProxyAccessibleWrap(aProxy)
{
: ProxyAccessibleWrap(aProxy) {
mGenericTypes |= eDocument;
if (auto parent = ParentDocument()) {
@@ -81,8 +80,7 @@ public:
}
}
virtual void Shutdown() override
{
virtual void Shutdown() override {
if (mID) {
auto parent = ParentDocument();
if (parent) {
@@ -96,8 +94,7 @@ public:
mStateFlags |= eIsDefunct;
}
DocProxyAccessibleWrap* ParentDocument()
{
DocProxyAccessibleWrap* ParentDocument() {
DocAccessibleParent* proxy = static_cast<DocAccessibleParent*>(Proxy());
MOZ_ASSERT(proxy);
if (DocAccessibleParent* parent = proxy->ParentDoc()) {
@@ -107,34 +104,31 @@ public:
return nullptr;
}
DocProxyAccessibleWrap* GetChildDocumentAt(uint32_t aIndex)
{
DocProxyAccessibleWrap* GetChildDocumentAt(uint32_t aIndex) {
auto doc = Proxy()->AsDoc();
if (doc && doc->ChildDocCount() > aIndex) {
return reinterpret_cast<DocProxyAccessibleWrap*>(
doc->ChildDocAt(aIndex)->GetWrapper());
doc->ChildDocAt(aIndex)->GetWrapper());
}
return nullptr;
}
void AddID(uint32_t aID, AccessibleWrap* aAcc)
{
void AddID(uint32_t aID, AccessibleWrap* aAcc) {
mIDToAccessibleMap.Put(aID, aAcc);
}
void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
AccessibleWrap* GetAccessibleByID(uint32_t aID) const
{
AccessibleWrap* GetAccessibleByID(uint32_t aID) const {
return mIDToAccessibleMap.Get(aID);
}
private:
private:
/*
* This provides a mapping from 32 bit id to accessible objects.
*/
nsDataHashtable<nsUint32HashKey, AccessibleWrap*> mIDToAccessibleMap;
};
}
}
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -15,15 +15,11 @@ using namespace mozilla::a11y;
RootAccessibleWrap::RootAccessibleWrap(nsIDocument* aDoc,
nsIPresShell* aPresShell)
: RootAccessible(aDoc, aPresShell)
{
}
: RootAccessible(aDoc, aPresShell) {}
RootAccessibleWrap::~RootAccessibleWrap() {}
AccessibleWrap*
RootAccessibleWrap::GetContentAccessible()
{
AccessibleWrap* RootAccessibleWrap::GetContentAccessible() {
if (ProxyAccessible* proxy = GetPrimaryRemoteTopLevelContentDoc()) {
return WrapperFor(proxy);
}
@@ -41,9 +37,7 @@ RootAccessibleWrap::GetContentAccessible()
return nullptr;
}
AccessibleWrap*
RootAccessibleWrap::FindAccessibleById(int32_t aID)
{
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(int32_t aID) {
AccessibleWrap* contentAcc = GetContentAccessible();
if (!contentAcc) {
@@ -60,18 +54,16 @@ RootAccessibleWrap::FindAccessibleById(int32_t aID)
}
return FindAccessibleById(
static_cast<DocAccessibleWrap*>(contentAcc->AsDoc()), aID);
static_cast<DocAccessibleWrap*>(contentAcc->AsDoc()), aID);
}
AccessibleWrap*
RootAccessibleWrap::FindAccessibleById(DocProxyAccessibleWrap* aDoc,
int32_t aID)
{
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(
DocProxyAccessibleWrap* aDoc, int32_t aID) {
AccessibleWrap* acc = aDoc->GetAccessibleByID(aID);
uint32_t index = 0;
while (!acc) {
auto child =
static_cast<DocProxyAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
static_cast<DocProxyAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
if (!child) {
break;
}
@@ -81,14 +73,13 @@ RootAccessibleWrap::FindAccessibleById(DocProxyAccessibleWrap* aDoc,
return acc;
}
AccessibleWrap*
RootAccessibleWrap::FindAccessibleById(DocAccessibleWrap* aDoc, int32_t aID)
{
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(DocAccessibleWrap* aDoc,
int32_t aID) {
AccessibleWrap* acc = aDoc->GetAccessibleByID(aID);
uint32_t index = 0;
while (!acc) {
auto child =
static_cast<DocAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
static_cast<DocAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
if (!child) {
break;
}

View File

@@ -13,9 +13,8 @@ namespace a11y {
class DocProxyAccessibleWrap;
class RootAccessibleWrap : public RootAccessible
{
public:
class RootAccessibleWrap : public RootAccessible {
public:
RootAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
virtual ~RootAccessibleWrap();
@@ -31,7 +30,7 @@ public:
int32_t aID);
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -21,26 +21,24 @@
#ifdef DEBUG
#include <android/log.h>
#define AALOG(args...) \
#define AALOG(args...) \
__android_log_print(ANDROID_LOG_INFO, "GeckoAccessibilityNative", ##args)
#else
#define AALOG(args...) \
do { \
#define AALOG(args...) \
do { \
} while (0)
#endif
template<>
template <>
const char nsWindow::NativePtr<mozilla::a11y::SessionAccessibility>::sName[] =
"SessionAccessibility";
"SessionAccessibility";
using namespace mozilla::a11y;
class Settings final
: public mozilla::java::SessionAccessibility::Settings::Natives<Settings>
{
public:
static void ToggleNativeAccessibility(bool aEnable)
{
: public mozilla::java::SessionAccessibility::Settings::Natives<Settings> {
public:
static void ToggleNativeAccessibility(bool aEnable) {
if (aEnable) {
GetOrCreateAccService();
} else {
@@ -49,36 +47,30 @@ public:
}
};
void
SessionAccessibility::SetAttached(bool aAttached,
already_AddRefed<Runnable> aRunnable)
{
void SessionAccessibility::SetAttached(bool aAttached,
already_AddRefed<Runnable> aRunnable) {
if (RefPtr<nsThread> uiThread = GetAndroidUiThread()) {
uiThread->Dispatch(NS_NewRunnableFunction(
"SessionAccessibility::Attach",
[aAttached,
sa = java::SessionAccessibility::NativeProvider::GlobalRef(
mSessionAccessibility),
runnable = RefPtr<Runnable>(aRunnable)] {
sa->SetAttached(aAttached);
if (runnable) {
runnable->Run();
}
}));
"SessionAccessibility::Attach",
[aAttached,
sa = java::SessionAccessibility::NativeProvider::GlobalRef(
mSessionAccessibility),
runnable = RefPtr<Runnable>(aRunnable)] {
sa->SetAttached(aAttached);
if (runnable) {
runnable->Run();
}
}));
}
}
void
SessionAccessibility::Init()
{
void SessionAccessibility::Init() {
java::SessionAccessibility::NativeProvider::Natives<
SessionAccessibility>::Init();
SessionAccessibility>::Init();
Settings::Init();
}
mozilla::jni::Object::LocalRef
SessionAccessibility::GetNodeInfo(int32_t aID)
{
mozilla::jni::Object::LocalRef SessionAccessibility::GetNodeInfo(int32_t aID) {
java::GeckoBundle::GlobalRef ret = nullptr;
RefPtr<SessionAccessibility> self(this);
nsAppShell::SyncRunEvent([this, self, aID, &ret] {
@@ -95,9 +87,7 @@ SessionAccessibility::GetNodeInfo(int32_t aID)
return mozilla::jni::Object::Ref::From(ret);
}
RootAccessibleWrap*
SessionAccessibility::GetRoot()
{
RootAccessibleWrap* SessionAccessibility::GetRoot() {
if (!mWindow) {
return nullptr;
}
@@ -105,9 +95,7 @@ SessionAccessibility::GetRoot()
return static_cast<RootAccessibleWrap*>(mWindow->GetRootAccessible());
}
void
SessionAccessibility::SetText(int32_t aID, jni::String::Param aText)
{
void SessionAccessibility::SetText(int32_t aID, jni::String::Param aText) {
if (RootAccessibleWrap* rootAcc = GetRoot()) {
AccessibleWrap* acc = rootAcc->FindAccessibleById(aID);
if (!acc) {
@@ -118,9 +106,8 @@ SessionAccessibility::SetText(int32_t aID, jni::String::Param aText)
}
}
SessionAccessibility*
SessionAccessibility::GetInstanceFor(ProxyAccessible* aAccessible)
{
SessionAccessibility* SessionAccessibility::GetInstanceFor(
ProxyAccessible* aAccessible) {
auto tab = static_cast<dom::TabParent*>(aAccessible->Document()->Manager());
dom::Element* frame = tab->GetOwnerElement();
MOZ_ASSERT(frame);
@@ -132,9 +119,8 @@ SessionAccessibility::GetInstanceFor(ProxyAccessible* aAccessible)
return chromeDoc ? GetInstanceFor(chromeDoc) : nullptr;
}
SessionAccessibility*
SessionAccessibility::GetInstanceFor(Accessible* aAccessible)
{
SessionAccessibility* SessionAccessibility::GetInstanceFor(
Accessible* aAccessible) {
RootAccessible* rootAcc = aAccessible->RootAccessible();
nsIPresShell* shell = rootAcc->PresShell();
nsViewManager* vm = shell->GetViewManager();
@@ -153,26 +139,21 @@ SessionAccessibility::GetInstanceFor(Accessible* aAccessible)
return nullptr;
}
void
SessionAccessibility::SendAccessibilityFocusedEvent(AccessibleWrap* aAccessible)
{
void SessionAccessibility::SendAccessibilityFocusedEvent(
AccessibleWrap* aAccessible) {
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_ACCESSIBILITY_FOCUSED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
java::sdk::AccessibilityEvent::TYPE_VIEW_ACCESSIBILITY_FOCUSED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
aAccessible->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
}
void
SessionAccessibility::SendHoverEnterEvent(AccessibleWrap* aAccessible)
{
void SessionAccessibility::SendHoverEnterEvent(AccessibleWrap* aAccessible) {
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_HOVER_ENTER,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
java::sdk::AccessibilityEvent::TYPE_VIEW_HOVER_ENTER,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
}
void
SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible)
{
void SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible) {
// Suppress focus events from about:blank pages.
// This is important for tests.
if (aAccessible->IsDoc() && aAccessible->ChildCount() == 0) {
@@ -180,17 +161,15 @@ SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible)
}
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_FOCUSED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
java::sdk::AccessibilityEvent::TYPE_VIEW_FOCUSED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
}
void
SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
int32_t aScrollX,
int32_t aScrollY,
int32_t aMaxScrollX,
int32_t aMaxScrollY)
{
void SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
int32_t aScrollX,
int32_t aScrollY,
int32_t aMaxScrollX,
int32_t aMaxScrollY) {
int32_t virtualViewId = aAccessible->VirtualViewID();
if (virtualViewId != AccessibleWrap::kNoID) {
@@ -201,28 +180,28 @@ SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
GECKOBUNDLE_START(eventInfo);
GECKOBUNDLE_PUT(eventInfo, "scrollX", java::sdk::Integer::ValueOf(aScrollX));
GECKOBUNDLE_PUT(eventInfo, "scrollY", java::sdk::Integer::ValueOf(aScrollY));
GECKOBUNDLE_PUT(eventInfo, "maxScrollX", java::sdk::Integer::ValueOf(aMaxScrollX));
GECKOBUNDLE_PUT(eventInfo, "maxScrollY", java::sdk::Integer::ValueOf(aMaxScrollY));
GECKOBUNDLE_PUT(eventInfo, "maxScrollX",
java::sdk::Integer::ValueOf(aMaxScrollX));
GECKOBUNDLE_PUT(eventInfo, "maxScrollY",
java::sdk::Integer::ValueOf(aMaxScrollY));
GECKOBUNDLE_FINISH(eventInfo);
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_SCROLLED, virtualViewId,
aAccessible->AndroidClass(), eventInfo);
java::sdk::AccessibilityEvent::TYPE_VIEW_SCROLLED, virtualViewId,
aAccessible->AndroidClass(), eventInfo);
SendWindowContentChangedEvent(aAccessible);
}
void
SessionAccessibility::SendWindowContentChangedEvent(AccessibleWrap* aAccessible)
{
void SessionAccessibility::SendWindowContentChangedEvent(
AccessibleWrap* aAccessible) {
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_WINDOW_CONTENT_CHANGED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
java::sdk::AccessibilityEvent::TYPE_WINDOW_CONTENT_CHANGED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
}
void
SessionAccessibility::SendWindowStateChangedEvent(AccessibleWrap* aAccessible)
{
void SessionAccessibility::SendWindowStateChangedEvent(
AccessibleWrap* aAccessible) {
// Suppress window state changed events from about:blank pages.
// This is important for tests.
if (aAccessible->IsDoc() && aAccessible->ChildCount() == 0) {
@@ -230,14 +209,12 @@ SessionAccessibility::SendWindowStateChangedEvent(AccessibleWrap* aAccessible)
}
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_WINDOW_STATE_CHANGED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
java::sdk::AccessibilityEvent::TYPE_WINDOW_STATE_CHANGED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
}
void
SessionAccessibility::SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
int32_t aCaretOffset)
{
void SessionAccessibility::SendTextSelectionChangedEvent(
AccessibleWrap* aAccessible, int32_t aCaretOffset) {
int32_t fromIndex = aCaretOffset;
int32_t startSel = -1;
int32_t endSel = -1;
@@ -246,23 +223,22 @@ SessionAccessibility::SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
}
GECKOBUNDLE_START(eventInfo);
GECKOBUNDLE_PUT(eventInfo, "fromIndex", java::sdk::Integer::ValueOf(fromIndex));
GECKOBUNDLE_PUT(eventInfo, "toIndex", java::sdk::Integer::ValueOf(aCaretOffset));
GECKOBUNDLE_PUT(eventInfo, "fromIndex",
java::sdk::Integer::ValueOf(fromIndex));
GECKOBUNDLE_PUT(eventInfo, "toIndex",
java::sdk::Integer::ValueOf(aCaretOffset));
GECKOBUNDLE_FINISH(eventInfo);
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_SELECTION_CHANGED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_SELECTION_CHANGED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
}
void
SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
const nsString& aStr,
int32_t aStart,
uint32_t aLen,
bool aIsInsert,
bool aFromUser)
{
void SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
const nsString& aStr,
int32_t aStart, uint32_t aLen,
bool aIsInsert,
bool aFromUser) {
if (!aFromUser) {
// Only dispatch text change events from users, for now.
return;
@@ -280,65 +256,66 @@ SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
GECKOBUNDLE_START(eventInfo);
GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(text));
GECKOBUNDLE_PUT(eventInfo, "beforeText", jni::StringParam(beforeText));
GECKOBUNDLE_PUT(eventInfo, "addedCount", java::sdk::Integer::ValueOf(aIsInsert ? aLen : 0));
GECKOBUNDLE_PUT(eventInfo, "removedCount", java::sdk::Integer::ValueOf(aIsInsert ? 0 : aLen));
GECKOBUNDLE_PUT(eventInfo, "addedCount",
java::sdk::Integer::ValueOf(aIsInsert ? aLen : 0));
GECKOBUNDLE_PUT(eventInfo, "removedCount",
java::sdk::Integer::ValueOf(aIsInsert ? 0 : aLen));
GECKOBUNDLE_FINISH(eventInfo);
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_CHANGED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_CHANGED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
}
void
SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
int32_t aStartOffset,
int32_t aEndOffset)
{
void SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
int32_t aStartOffset,
int32_t aEndOffset) {
nsAutoString text;
aAccessible->GetTextContents(text);
GECKOBUNDLE_START(eventInfo);
GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(text));
GECKOBUNDLE_PUT(eventInfo, "fromIndex", java::sdk::Integer::ValueOf(aStartOffset));
GECKOBUNDLE_PUT(eventInfo, "toIndex", java::sdk::Integer::ValueOf(aEndOffset));
GECKOBUNDLE_PUT(eventInfo, "fromIndex",
java::sdk::Integer::ValueOf(aStartOffset));
GECKOBUNDLE_PUT(eventInfo, "toIndex",
java::sdk::Integer::ValueOf(aEndOffset));
GECKOBUNDLE_FINISH(eventInfo);
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::
TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
java::sdk::AccessibilityEvent::
TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
}
void
SessionAccessibility::SendClickedEvent(AccessibleWrap* aAccessible, bool aChecked)
{
void SessionAccessibility::SendClickedEvent(AccessibleWrap* aAccessible,
bool aChecked) {
GECKOBUNDLE_START(eventInfo);
// Boolean::FALSE/TRUE gets clobbered by a macro, so ugh.
GECKOBUNDLE_PUT(eventInfo, "checked", java::sdk::Integer::ValueOf(aChecked ? 1 : 0));
GECKOBUNDLE_PUT(eventInfo, "checked",
java::sdk::Integer::ValueOf(aChecked ? 1 : 0));
GECKOBUNDLE_FINISH(eventInfo);
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_CLICKED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
java::sdk::AccessibilityEvent::TYPE_VIEW_CLICKED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
}
void
SessionAccessibility::SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelected)
{
void SessionAccessibility::SendSelectedEvent(AccessibleWrap* aAccessible,
bool aSelected) {
GECKOBUNDLE_START(eventInfo);
// Boolean::FALSE/TRUE gets clobbered by a macro, so ugh.
GECKOBUNDLE_PUT(eventInfo, "selected", java::sdk::Integer::ValueOf(aSelected ? 1 : 0));
GECKOBUNDLE_PUT(eventInfo, "selected",
java::sdk::Integer::ValueOf(aSelected ? 1 : 0));
GECKOBUNDLE_FINISH(eventInfo);
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_SELECTED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
java::sdk::AccessibilityEvent::TYPE_VIEW_SELECTED,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
}
void
SessionAccessibility::ReplaceViewportCache(const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData)
{
void SessionAccessibility::ReplaceViewportCache(
const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData) {
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
for (size_t i = 0; i < aAccessibles.Length(); i++) {
AccessibleWrap* acc = aAccessibles.ElementAt(i);
@@ -354,27 +331,20 @@ SessionAccessibility::ReplaceViewportCache(const nsTArray<AccessibleWrap*>& aAcc
mSessionAccessibility->ReplaceViewportCache(infos);
}
void
SessionAccessibility::ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData)
{
void SessionAccessibility::ReplaceFocusPathCache(
const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData) {
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
for (size_t i = 0; i < aAccessibles.Length(); i++) {
AccessibleWrap* acc = aAccessibles.ElementAt(i);
if (aData.Length() == aAccessibles.Length()) {
const BatchData& data = aData.ElementAt(i);
nsCOMPtr<nsIPersistentProperties> props =
AccessibleWrap::AttributeArrayToProperties(data.Attributes());
auto bundle = acc->ToBundle(data.State(),
data.Bounds(),
data.Name(),
data.TextValue(),
data.DOMNodeID(),
data.CurValue(),
data.MinValue(),
data.MaxValue(),
data.Step(),
props);
AccessibleWrap::AttributeArrayToProperties(data.Attributes());
auto bundle =
acc->ToBundle(data.State(), data.Bounds(), data.Name(),
data.TextValue(), data.DOMNodeID(), data.CurValue(),
data.MinValue(), data.MaxValue(), data.Step(), props);
infos->SetElement(i, bundle);
} else {
infos->SetElement(i, acc->ToBundle());
@@ -384,10 +354,9 @@ SessionAccessibility::ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAc
mSessionAccessibility->ReplaceFocusPathCache(infos);
}
void
SessionAccessibility::UpdateCachedBounds(const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData)
{
void SessionAccessibility::UpdateCachedBounds(
const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData) {
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
for (size_t i = 0; i < aAccessibles.Length(); i++) {
AccessibleWrap* acc = aAccessibles.ElementAt(i);

View File

@@ -12,28 +12,27 @@
#include "nsThreadUtils.h"
#include "nsWindow.h"
#define GECKOBUNDLE_START(name) \
nsTArray<jni::String::LocalRef> _##name##_keys; \
#define GECKOBUNDLE_START(name) \
nsTArray<jni::String::LocalRef> _##name##_keys; \
nsTArray<jni::Object::LocalRef> _##name##_values;
#define GECKOBUNDLE_PUT(name, key, value) \
_##name##_keys.AppendElement(jni::StringParam(NS_LITERAL_STRING(key))); \
#define GECKOBUNDLE_PUT(name, key, value) \
_##name##_keys.AppendElement(jni::StringParam(NS_LITERAL_STRING(key))); \
_##name##_values.AppendElement(value);
#define GECKOBUNDLE_FINISH(name) \
MOZ_ASSERT(_##name##_keys.Length() == _##name##_values.Length()); \
auto _##name##_jkeys = \
jni::ObjectArray::New<jni::String>(_##name##_keys.Length()); \
auto _##name##_jvalues = \
jni::ObjectArray::New<jni::Object>(_##name##_values.Length()); \
for (size_t i = 0; \
i < _##name##_keys.Length() && i < _##name##_values.Length(); \
i++) { \
_##name##_jkeys->SetElement(i, _##name##_keys.ElementAt(i)); \
_##name##_jvalues->SetElement(i, _##name##_values.ElementAt(i)); \
} \
auto name = \
mozilla::java::GeckoBundle::New(_##name##_jkeys, _##name##_jvalues);
#define GECKOBUNDLE_FINISH(name) \
MOZ_ASSERT(_##name##_keys.Length() == _##name##_values.Length()); \
auto _##name##_jkeys = \
jni::ObjectArray::New<jni::String>(_##name##_keys.Length()); \
auto _##name##_jvalues = \
jni::ObjectArray::New<jni::Object>(_##name##_values.Length()); \
for (size_t i = 0; \
i < _##name##_keys.Length() && i < _##name##_values.Length(); i++) { \
_##name##_jkeys->SetElement(i, _##name##_keys.ElementAt(i)); \
_##name##_jvalues->SetElement(i, _##name##_values.ElementAt(i)); \
} \
auto name = \
mozilla::java::GeckoBundle::New(_##name##_jkeys, _##name##_jvalues);
namespace mozilla {
namespace a11y {
@@ -44,28 +43,26 @@ class RootAccessibleWrap;
class BatchData;
class SessionAccessibility final
: public java::SessionAccessibility::NativeProvider::Natives<SessionAccessibility>
{
public:
typedef java::SessionAccessibility::NativeProvider::Natives<SessionAccessibility> Base;
: public java::SessionAccessibility::NativeProvider::Natives<
SessionAccessibility> {
public:
typedef java::SessionAccessibility::NativeProvider::Natives<
SessionAccessibility>
Base;
SessionAccessibility(
nsWindow::NativePtr<SessionAccessibility>* aPtr,
nsWindow* aWindow,
java::SessionAccessibility::NativeProvider::Param aSessionAccessibility)
: mWindow(aPtr, aWindow)
, mSessionAccessibility(aSessionAccessibility)
{
nsWindow::NativePtr<SessionAccessibility>* aPtr, nsWindow* aWindow,
java::SessionAccessibility::NativeProvider::Param aSessionAccessibility)
: mWindow(aPtr, aWindow), mSessionAccessibility(aSessionAccessibility) {
SetAttached(true, nullptr);
}
void OnDetach(already_AddRefed<Runnable> aDisposer)
{
void OnDetach(already_AddRefed<Runnable> aDisposer) {
SetAttached(false, std::move(aDisposer));
}
const java::SessionAccessibility::NativeProvider::Ref& GetJavaAccessibility()
{
const java::SessionAccessibility::NativeProvider::Ref&
GetJavaAccessibility() {
return mSessionAccessibility;
}
@@ -82,23 +79,17 @@ public:
// Event methods
void SendFocusEvent(AccessibleWrap* aAccessible);
void SendScrollingEvent(AccessibleWrap* aAccessible,
int32_t aScrollX,
int32_t aScrollY,
int32_t aMaxScrollX,
void SendScrollingEvent(AccessibleWrap* aAccessible, int32_t aScrollX,
int32_t aScrollY, int32_t aMaxScrollX,
int32_t aMaxScrollY);
void SendAccessibilityFocusedEvent(AccessibleWrap* aAccessible);
void SendHoverEnterEvent(AccessibleWrap* aAccessible);
void SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
int32_t aCaretOffset);
void SendTextTraversedEvent(AccessibleWrap* aAccessible,
int32_t aStartOffset,
void SendTextTraversedEvent(AccessibleWrap* aAccessible, int32_t aStartOffset,
int32_t aEndOffset);
void SendTextChangedEvent(AccessibleWrap* aAccessible,
const nsString& aStr,
int32_t aStart,
uint32_t aLen,
bool aIsInsert,
void SendTextChangedEvent(AccessibleWrap* aAccessible, const nsString& aStr,
int32_t aStart, uint32_t aLen, bool aIsInsert,
bool aFromUser);
void SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelected);
void SendClickedEvent(AccessibleWrap* aAccessible, bool aChecked);
@@ -106,28 +97,31 @@ public:
void SendWindowStateChangedEvent(AccessibleWrap* aAccessible);
// Cache methods
void ReplaceViewportCache(const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
void ReplaceViewportCache(
const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
void ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
void ReplaceFocusPathCache(
const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
void UpdateCachedBounds(const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
void UpdateCachedBounds(
const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SessionAccessibility)
private:
private:
~SessionAccessibility() {}
void SetAttached(bool aAttached, already_AddRefed<Runnable> aRunnable);
RootAccessibleWrap* GetRoot();
nsWindow::WindowPtr<SessionAccessibility> mWindow; // Parent only
nsWindow::WindowPtr<SessionAccessibility> mWindow; // Parent only
java::SessionAccessibility::NativeProvider::GlobalRef mSessionAccessibility;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -13,7 +13,7 @@ namespace a11y {
typedef class TextLeafAccessible TextLeafAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -14,7 +14,7 @@ namespace a11y {
typedef class XULListboxAccessible XULListboxAccessibleWrap;
typedef class XULListCellAccessible XULListCellAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -13,7 +13,7 @@ namespace a11y {
typedef class XULMenuitemAccessible XULMenuitemAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -14,7 +14,7 @@ namespace a11y {
typedef class XULTreeGridAccessible XULTreeGridAccessibleWrap;
typedef class XULTreeGridCellAccessible XULTreeGridCellAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -18,9 +18,7 @@ using namespace mozilla;
using namespace mozilla::a11y;
using namespace mozilla::dom;
bool
AccessibleNode::IsAOMEnabled(JSContext* aCx, JSObject* /*unused*/)
{
bool AccessibleNode::IsAOMEnabled(JSContext* aCx, JSObject* /*unused*/) {
static bool sPrefCached = false;
static bool sPrefCacheValue = false;
@@ -43,15 +41,14 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(AccessibleNode)
NS_IMPL_CYCLE_COLLECTING_RELEASE(AccessibleNode)
AccessibleNode::AccessibleNode(nsINode* aNode) :
mDoubleProperties(3),
mIntProperties(3),
mUIntProperties(6),
mBooleanProperties(0),
mRelationProperties(3),
mStringProperties(16),
mDOMNode(aNode)
{
AccessibleNode::AccessibleNode(nsINode* aNode)
: mDoubleProperties(3),
mIntProperties(3),
mUIntProperties(6),
mBooleanProperties(0),
mRelationProperties(3),
mStringProperties(16),
mDOMNode(aNode) {
nsAccessibilityService* accService = GetOrCreateAccService();
if (!accService) {
return;
@@ -63,25 +60,18 @@ AccessibleNode::AccessibleNode(nsINode* aNode) :
}
}
AccessibleNode::~AccessibleNode()
{
}
AccessibleNode::~AccessibleNode() {}
/* virtual */ JSObject*
AccessibleNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
/* virtual */ JSObject* AccessibleNode::WrapObject(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
return AccessibleNode_Binding::Wrap(aCx, this, aGivenProto);
}
/* virtual */ ParentObject
AccessibleNode::GetParentObject() const
{
/* virtual */ ParentObject AccessibleNode::GetParentObject() const {
return mDOMNode->GetParentObject();
}
void
AccessibleNode::GetComputedRole(nsAString& aRole)
{
void AccessibleNode::GetComputedRole(nsAString& aRole) {
if (mIntl) {
nsAccessibilityService* accService = GetOrCreateAccService();
if (accService) {
@@ -93,9 +83,7 @@ AccessibleNode::GetComputedRole(nsAString& aRole)
aRole.AssignLiteral("unknown");
}
void
AccessibleNode::GetStates(nsTArray<nsString>& aStates)
{
void AccessibleNode::GetStates(nsTArray<nsString>& aStates) {
nsAccessibilityService* accService = GetOrCreateAccService();
if (!mIntl || !accService) {
aStates.AppendElement(NS_LITERAL_STRING("defunct"));
@@ -111,9 +99,7 @@ AccessibleNode::GetStates(nsTArray<nsString>& aStates)
aStates = mStates->StringArray();
}
void
AccessibleNode::GetAttributes(nsTArray<nsString>& aAttributes)
{
void AccessibleNode::GetAttributes(nsTArray<nsString>& aAttributes) {
if (!mIntl) {
return;
}
@@ -136,13 +122,12 @@ AccessibleNode::GetAttributes(nsTArray<nsString>& aAttributes)
}
}
bool
AccessibleNode::Is(const Sequence<nsString>& aFlavors)
{
bool AccessibleNode::Is(const Sequence<nsString>& aFlavors) {
nsAccessibilityService* accService = GetOrCreateAccService();
if (!mIntl || !accService) {
for (const auto& flavor : aFlavors) {
if (!flavor.EqualsLiteral("unknown") && !flavor.EqualsLiteral("defunct")) {
if (!flavor.EqualsLiteral("unknown") &&
!flavor.EqualsLiteral("defunct")) {
return false;
}
}
@@ -164,9 +149,7 @@ AccessibleNode::Is(const Sequence<nsString>& aFlavors)
return true;
}
bool
AccessibleNode::Has(const Sequence<nsString>& aAttributes)
{
bool AccessibleNode::Has(const Sequence<nsString>& aAttributes) {
if (!mIntl) {
return false;
}
@@ -181,11 +164,9 @@ AccessibleNode::Has(const Sequence<nsString>& aAttributes)
return true;
}
void
AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv)
{
void AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv) {
if (!mIntl) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
@@ -204,8 +185,4 @@ AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
aValue.set(jsval);
}
nsINode*
AccessibleNode::GetDOMNode()
{
return mDOMNode;
}
nsINode* AccessibleNode::GetDOMNode() { return mDOMNode; }

View File

@@ -19,7 +19,7 @@ class nsINode;
namespace mozilla {
namespace a11y {
class Accessible;
class Accessible;
}
namespace dom {
@@ -27,86 +27,75 @@ namespace dom {
class DOMStringList;
struct ParentObject;
#define ANODE_ENUM(name) \
e##name,
#define ANODE_ENUM(name) e##name,
#define ANODE_FUNC(typeName, type, name) \
dom::Nullable<type> Get##name() \
{ \
dom::Nullable<type> Get##name() { \
return GetProperty(AOM##typeName##Property::e##name); \
} \
\
void Set##name(const dom::Nullable<type>& a##name) \
{ \
void Set##name(const dom::Nullable<type>& a##name) { \
SetProperty(AOM##typeName##Property::e##name, a##name); \
} \
}
#define ANODE_STRING_FUNC(name) \
void Get##name(nsAString& a##name) \
{ \
void Get##name(nsAString& a##name) { \
return GetProperty(AOMStringProperty::e##name, a##name); \
} \
\
void Set##name(const nsAString& a##name) \
{ \
void Set##name(const nsAString& a##name) { \
SetProperty(AOMStringProperty::e##name, a##name); \
} \
}
#define ANODE_RELATION_FUNC(name) \
already_AddRefed<AccessibleNode> Get##name() \
{ \
already_AddRefed<AccessibleNode> Get##name() { \
return GetProperty(AOMRelationProperty::e##name); \
} \
\
void Set##name(AccessibleNode* a##name) \
{ \
void Set##name(AccessibleNode* a##name) { \
SetProperty(AOMRelationProperty::e##name, a##name); \
} \
}
#define ANODE_PROPS(typeName, type, ...) \
enum class AOM##typeName##Property { \
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__)) \
}; \
MOZ_FOR_EACH(ANODE_FUNC, (typeName, type,), (__VA_ARGS__)) \
#define ANODE_PROPS(typeName, type, ...) \
enum class AOM##typeName##Property{ \
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__))}; \
MOZ_FOR_EACH(ANODE_FUNC, (typeName, type, ), (__VA_ARGS__))
#define ANODE_STRING_PROPS(...) \
enum class AOMStringProperty { \
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__)) \
}; \
MOZ_FOR_EACH(ANODE_STRING_FUNC, (), (__VA_ARGS__)) \
#define ANODE_STRING_PROPS(...) \
enum class AOMStringProperty { \
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__)) \
}; \
MOZ_FOR_EACH(ANODE_STRING_FUNC, (), (__VA_ARGS__))
#define ANODE_RELATION_PROPS(...) \
enum class AOMRelationProperty { \
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__)) \
}; \
MOZ_FOR_EACH(ANODE_RELATION_FUNC, (), (__VA_ARGS__)) \
#define ANODE_RELATION_PROPS(...) \
enum class AOMRelationProperty { \
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__)) \
}; \
MOZ_FOR_EACH(ANODE_RELATION_FUNC, (), (__VA_ARGS__))
#define ANODE_ACCESSOR_MUTATOR(typeName, type, defVal) \
nsDataHashtable<nsUint32HashKey, type> m##typeName##Properties; \
\
dom::Nullable<type> GetProperty(AOM##typeName##Property aProperty) \
{ \
type value = defVal; \
if (m##typeName##Properties.Get(static_cast<int>(aProperty), &value)) { \
return dom::Nullable<type>(value); \
} \
return dom::Nullable<type>(); \
} \
\
void SetProperty(AOM##typeName##Property aProperty, \
const dom::Nullable<type>& aValue) \
{ \
if (aValue.IsNull()) { \
m##typeName##Properties.Remove(static_cast<int>(aProperty)); \
} else { \
m##typeName##Properties.Put(static_cast<int>(aProperty), aValue.Value()); \
} \
} \
#define ANODE_ACCESSOR_MUTATOR(typeName, type, defVal) \
nsDataHashtable<nsUint32HashKey, type> m##typeName##Properties; \
\
dom::Nullable<type> GetProperty(AOM##typeName##Property aProperty) { \
type value = defVal; \
if (m##typeName##Properties.Get(static_cast<int>(aProperty), &value)) { \
return dom::Nullable<type>(value); \
} \
return dom::Nullable<type>(); \
} \
\
void SetProperty(AOM##typeName##Property aProperty, \
const dom::Nullable<type>& aValue) { \
if (aValue.IsNull()) { \
m##typeName##Properties.Remove(static_cast<int>(aProperty)); \
} else { \
m##typeName##Properties.Put(static_cast<int>(aProperty), \
aValue.Value()); \
} \
}
class AccessibleNode : public nsISupports,
public nsWrapperCache
{
public:
class AccessibleNode : public nsISupports, public nsWrapperCache {
public:
explicit AccessibleNode(nsINode* aNode);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS;
@@ -123,72 +112,27 @@ public:
bool Is(const Sequence<nsString>& aFlavors);
bool Has(const Sequence<nsString>& aAttributes);
void Get(JSContext* cx, const nsAString& aAttribute,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv);
JS::MutableHandle<JS::Value> aValue, ErrorResult& aRv);
static bool IsAOMEnabled(JSContext*, JSObject*);
ANODE_STRING_PROPS(
Autocomplete,
Checked,
Current,
HasPopUp,
Invalid,
KeyShortcuts,
Label,
Live,
Orientation,
Placeholder,
Pressed,
Relevant,
Role,
RoleDescription,
Sort,
ValueText
)
ANODE_STRING_PROPS(Autocomplete, Checked, Current, HasPopUp, Invalid,
KeyShortcuts, Label, Live, Orientation, Placeholder,
Pressed, Relevant, Role, RoleDescription, Sort, ValueText)
ANODE_PROPS(Boolean, bool,
Atomic,
Busy,
Disabled,
Expanded,
Hidden,
Modal,
Multiline,
Multiselectable,
ReadOnly,
Required,
Selected
)
ANODE_PROPS(Boolean, bool, Atomic, Busy, Disabled, Expanded, Hidden, Modal,
Multiline, Multiselectable, ReadOnly, Required, Selected)
ANODE_PROPS(UInt, uint32_t,
ColIndex,
ColSpan,
Level,
PosInSet,
RowIndex,
RowSpan
)
ANODE_PROPS(UInt, uint32_t, ColIndex, ColSpan, Level, PosInSet, RowIndex,
RowSpan)
ANODE_PROPS(Int, int32_t,
ColCount,
RowCount,
SetSize
)
ANODE_PROPS(Int, int32_t, ColCount, RowCount, SetSize)
ANODE_PROPS(Double, double,
ValueMax,
ValueMin,
ValueNow
)
ANODE_PROPS(Double, double, ValueMax, ValueMin, ValueNow)
ANODE_RELATION_PROPS(
ActiveDescendant,
Details,
ErrorMessage
)
ANODE_RELATION_PROPS(ActiveDescendant, Details, ErrorMessage)
protected:
protected:
AccessibleNode(const AccessibleNode& aCopy) = delete;
AccessibleNode& operator=(const AccessibleNode& aCopy) = delete;
virtual ~AccessibleNode();
@@ -210,8 +154,7 @@ protected:
}
}
dom::Nullable<bool> GetProperty(AOMBooleanProperty aProperty)
{
dom::Nullable<bool> GetProperty(AOMBooleanProperty aProperty) {
int num = static_cast<int>(aProperty);
if (mBooleanProperties & (1U << (2 * num))) {
bool data = static_cast<bool>(mBooleanProperties & (1U << (2 * num + 1)));
@@ -221,15 +164,15 @@ protected:
}
void SetProperty(AOMBooleanProperty aProperty,
const dom::Nullable<bool>& aValue)
{
const dom::Nullable<bool>& aValue) {
int num = static_cast<int>(aProperty);
if (aValue.IsNull()) {
mBooleanProperties &= ~(1U << (2 * num));
} else {
mBooleanProperties |= (1U << (2 * num));
mBooleanProperties = (aValue.Value() ? mBooleanProperties | (1U << (2 * num + 1))
: mBooleanProperties & ~(1U << (2 * num + 1)));
mBooleanProperties =
(aValue.Value() ? mBooleanProperties | (1U << (2 * num + 1))
: mBooleanProperties & ~(1U << (2 * num + 1)));
}
}
@@ -237,14 +180,11 @@ protected:
ANODE_ACCESSOR_MUTATOR(Int, int32_t, 0)
ANODE_ACCESSOR_MUTATOR(UInt, uint32_t, 0)
already_AddRefed<AccessibleNode> GetProperty(AOMRelationProperty aProperty)
{
already_AddRefed<AccessibleNode> GetProperty(AOMRelationProperty aProperty) {
return mRelationProperties.Get(static_cast<int>(aProperty));
}
void SetProperty(AOMRelationProperty aProperty,
AccessibleNode* aValue)
{
void SetProperty(AOMRelationProperty aProperty, AccessibleNode* aValue) {
if (!aValue) {
mRelationProperties.Remove(static_cast<int>(aProperty));
} else {
@@ -252,8 +192,8 @@ protected:
}
}
// The 2k'th bit indicates whether the k'th boolean property is used(1) or not(0)
// and 2k+1'th bit contains the property's value(1:true, 0:false)
// The 2k'th bit indicates whether the k'th boolean property is used(1) or
// not(0) and 2k+1'th bit contains the property's value(1:true, 0:false)
uint32_t mBooleanProperties;
nsRefPtrHashtable<nsUint32HashKey, AccessibleNode> mRelationProperties;
nsDataHashtable<nsUint32HashKey, nsString> mStringProperties;
@@ -263,8 +203,7 @@ protected:
RefPtr<dom::DOMStringList> mStates;
};
} // dom
} // mozilla
} // namespace dom
} // namespace mozilla
#endif // A11Y_JSAPI_ACCESSIBLENODE
#endif // A11Y_JSAPI_ACCESSIBLENODE

View File

@@ -15,7 +15,7 @@ namespace a11y {
typedef class ARIAGridAccessible ARIAGridAccessibleWrap;
typedef class ARIAGridCellAccessible ARIAGridCellAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -14,10 +14,10 @@ struct _AtkObject;
typedef struct _AtkObject AtkObject;
enum AtkProperty {
PROP_0, // gobject convention
PROP_0, // gobject convention
PROP_NAME,
PROP_DESCRIPTION,
PROP_PARENT, // ancestry has changed
PROP_PARENT, // ancestry has changed
PROP_ROLE,
PROP_LAYER,
PROP_MDI_ZORDER,
@@ -27,13 +27,13 @@ enum AtkProperty {
PROP_TABLE_ROW_DESCRIPTION,
PROP_TABLE_ROW_HEADER,
PROP_TABLE_SUMMARY,
PROP_LAST // gobject convention
PROP_LAST // gobject convention
};
struct AtkPropertyChange {
int32_t type; // property type as listed above
void *oldvalue;
void *newvalue;
int32_t type; // property type as listed above
void* oldvalue;
void* newvalue;
};
namespace mozilla {
@@ -45,9 +45,8 @@ class MaiHyperlink;
* AccessibleWrap, and its descendents in atk directory provide the
* implementation of AtkObject.
*/
class AccessibleWrap : public Accessible
{
public:
class AccessibleWrap : public Accessible {
public:
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
virtual ~AccessibleWrap();
void ShutdownAtkObject();
@@ -58,12 +57,12 @@ public:
virtual void GetNativeInterface(void** aOutAccessible) override;
virtual nsresult HandleAccEvent(AccEvent* aEvent) override;
AtkObject * GetAtkObject(void);
AtkObject* GetAtkObject(void);
static AtkObject* GetAtkObject(Accessible* aAccessible);
bool IsValidObject();
static const char * ReturnString(nsAString &aString) {
static const char* ReturnString(nsAString& aString) {
static nsCString returnedString;
returnedString = NS_ConvertUTF16toUTF8(aString);
return returnedString.get();
@@ -75,18 +74,18 @@ public:
int32_t aColIdx);
static Accessible* GetRowHeader(TableAccessible* aAccessible,
int32_t aRowIdx);
protected:
nsresult FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject *aObject);
nsresult FireAtkTextChangedEvent(AccEvent* aEvent, AtkObject *aObject);
protected:
nsresult FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject* aObject);
nsresult FireAtkTextChangedEvent(AccEvent* aEvent, AtkObject* aObject);
AtkObject *mAtkObject;
AtkObject* mAtkObject;
private:
private:
uint16_t CreateMaiInterfaces();
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif /* __NS_ACCESSIBLE_WRAP_H__ */

View File

@@ -16,70 +16,55 @@
using namespace mozilla;
using namespace mozilla::a11y;
// ApplicationAccessibleWrap
ApplicationAccessibleWrap::ApplicationAccessibleWrap():
ApplicationAccessible()
{
}
ApplicationAccessibleWrap::ApplicationAccessibleWrap()
: ApplicationAccessible() {}
ApplicationAccessibleWrap::~ApplicationAccessibleWrap()
{
ApplicationAccessibleWrap::~ApplicationAccessibleWrap() {
AccessibleWrap::ShutdownAtkObject();
}
gboolean
toplevel_event_watcher(GSignalInvocationHint* ihint,
guint n_param_values,
const GValue* param_values,
gpointer data)
{
gboolean toplevel_event_watcher(GSignalInvocationHint* ihint,
guint n_param_values,
const GValue* param_values, gpointer data) {
static GQuark sQuark_gecko_acc_obj = 0;
if (!sQuark_gecko_acc_obj)
sQuark_gecko_acc_obj = g_quark_from_static_string("GeckoAccObj");
if (nsAccessibilityService::IsShutdown())
return TRUE;
if (nsAccessibilityService::IsShutdown()) return TRUE;
GObject* object = reinterpret_cast<GObject*>(g_value_get_object(param_values));
if (!GTK_IS_WINDOW(object))
return TRUE;
GObject* object =
reinterpret_cast<GObject*>(g_value_get_object(param_values));
if (!GTK_IS_WINDOW(object)) return TRUE;
AtkObject* child = gtk_widget_get_accessible(GTK_WIDGET(object));
// GTK native dialog
if (!IS_MAI_OBJECT(child) &&
(atk_object_get_role(child) == ATK_ROLE_DIALOG)) {
if (data == reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW)) {
// Attach the dialog accessible to app accessible tree
Accessible* windowAcc = GetAccService()->AddNativeRootAccessible(child);
g_object_set_qdata(G_OBJECT(child), sQuark_gecko_acc_obj,
reinterpret_cast<gpointer>(windowAcc));
} else {
// Deattach the dialog accessible
Accessible* windowAcc =
reinterpret_cast<Accessible*>
(g_object_get_qdata(G_OBJECT(child), sQuark_gecko_acc_obj));
Accessible* windowAcc = reinterpret_cast<Accessible*>(
g_object_get_qdata(G_OBJECT(child), sQuark_gecko_acc_obj));
if (windowAcc) {
GetAccService()->RemoveNativeRootAccessible(windowAcc);
g_object_set_qdata(G_OBJECT(child), sQuark_gecko_acc_obj, nullptr);
}
}
}
return TRUE;
}
ENameValueFlag
ApplicationAccessibleWrap::Name(nsString& aName) const
{
ENameValueFlag ApplicationAccessibleWrap::Name(nsString& aName) const {
// ATK doesn't provide a way to obtain an application name (for example,
// Firefox or Thunderbird) like IA2 does. Thus let's return an application
// name as accessible name that was used to get a branding name (for example,
@@ -88,16 +73,13 @@ ApplicationAccessibleWrap::Name(nsString& aName) const
return eNameOK;
}
void
ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
void ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible) {
*aOutAccessible = nullptr;
if (!mAtkObject) {
mAtkObject =
reinterpret_cast<AtkObject*>(g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
if (!mAtkObject)
return;
mAtkObject = reinterpret_cast<AtkObject*>(
g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
if (!mAtkObject) return;
atk_object_initialize(mAtkObject, this);
mAtkObject->role = ATK_ROLE_INVALID;
@@ -108,53 +90,48 @@ ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible)
}
struct AtkRootAccessibleAddedEvent {
AtkObject *app_accessible;
AtkObject *root_accessible;
AtkObject* app_accessible;
AtkObject* root_accessible;
uint32_t index;
};
gboolean fireRootAccessibleAddedCB(gpointer data)
{
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)data;
g_signal_emit_by_name(eventData->app_accessible, "children_changed::add",
eventData->index, eventData->root_accessible, nullptr);
g_object_unref(eventData->app_accessible);
g_object_unref(eventData->root_accessible);
free(data);
gboolean fireRootAccessibleAddedCB(gpointer data) {
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)data;
g_signal_emit_by_name(eventData->app_accessible, "children_changed::add",
eventData->index, eventData->root_accessible, nullptr);
g_object_unref(eventData->app_accessible);
g_object_unref(eventData->root_accessible);
free(data);
return FALSE;
return FALSE;
}
bool
ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx, Accessible* aChild)
{
if (!ApplicationAccessible::InsertChildAt(aIdx, aChild))
return false;
bool ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx,
Accessible* aChild) {
if (!ApplicationAccessible::InsertChildAt(aIdx, aChild)) return false;
AtkObject* atkAccessible = AccessibleWrap::GetAtkObject(aChild);
atk_object_set_parent(atkAccessible, mAtkObject);
uint32_t count = mChildren.Length();
uint32_t count = mChildren.Length();
// Emit children_changed::add in a timeout
// to make sure aRootAccWrap is fully initialized.
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)
malloc(sizeof(AtkRootAccessibleAddedEvent));
if (eventData) {
eventData->app_accessible = mAtkObject;
eventData->root_accessible = atkAccessible;
eventData->index = count -1;
g_object_ref(mAtkObject);
g_object_ref(atkAccessible);
g_timeout_add(0, fireRootAccessibleAddedCB, eventData);
}
// Emit children_changed::add in a timeout
// to make sure aRootAccWrap is fully initialized.
AtkRootAccessibleAddedEvent* eventData =
(AtkRootAccessibleAddedEvent*)malloc(sizeof(AtkRootAccessibleAddedEvent));
if (eventData) {
eventData->app_accessible = mAtkObject;
eventData->root_accessible = atkAccessible;
eventData->index = count - 1;
g_object_ref(mAtkObject);
g_object_ref(atkAccessible);
g_timeout_add(0, fireRootAccessibleAddedCB, eventData);
}
return true;
return true;
}
bool
ApplicationAccessibleWrap::RemoveChild(Accessible* aChild)
{
bool ApplicationAccessibleWrap::RemoveChild(Accessible* aChild) {
int32_t index = aChild->IndexInParent();
AtkObject* atkAccessible = AccessibleWrap::GetAtkObject(aChild);
@@ -164,4 +141,3 @@ ApplicationAccessibleWrap::RemoveChild(Accessible* aChild)
return ApplicationAccessible::RemoveChild(aChild);
}

View File

@@ -12,9 +12,8 @@
namespace mozilla {
namespace a11y {
class ApplicationAccessibleWrap: public ApplicationAccessible
{
public:
class ApplicationAccessibleWrap : public ApplicationAccessible {
public:
ApplicationAccessibleWrap();
virtual ~ApplicationAccessibleWrap();
@@ -29,7 +28,7 @@ public:
virtual void GetNativeInterface(void** aOutAccessible) override;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif /* __NS_APP_ROOT_ACCESSIBLE_H__ */
#endif /* __NS_APP_ROOT_ACCESSIBLE_H__ */

View File

@@ -16,7 +16,8 @@ using namespace mozilla::a11y;
AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = nullptr;
GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID;
const char* AtkSocketAccessible::sATKSocketEmbedSymbol = "atk_socket_embed";
const char* AtkSocketAccessible::sATKSocketGetTypeSymbol = "atk_socket_get_type";
const char* AtkSocketAccessible::sATKSocketGetTypeSymbol =
"atk_socket_get_type";
bool AtkSocketAccessible::gCanEmbed = FALSE;
@@ -27,19 +28,11 @@ G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
mai_atk_component_iface_init))
void
mai_atk_socket_class_init(MaiAtkSocketClass* aAcc)
{
}
void mai_atk_socket_class_init(MaiAtkSocketClass* aAcc) {}
void
mai_atk_socket_init(MaiAtkSocket* aAcc)
{
}
void mai_atk_socket_init(MaiAtkSocket* aAcc) {}
static AtkObject*
mai_atk_socket_new(AccessibleWrap* aAccWrap)
{
static AtkObject* mai_atk_socket_new(AccessibleWrap* aAccWrap) {
NS_ENSURE_TRUE(aAccWrap, nullptr);
MaiAtkSocket* acc = nullptr;
@@ -51,36 +44,28 @@ mai_atk_socket_new(AccessibleWrap* aAccWrap)
}
extern "C" {
static AtkObject*
RefAccessibleAtPoint(AtkComponent* aComponent, gint aX, gint aY,
AtkCoordType aCoordType)
{
static AtkObject* RefAccessibleAtPoint(AtkComponent* aComponent, gint aX,
gint aY, AtkCoordType aCoordType) {
NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);
return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
aX, aY, aCoordType);
return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX,
aY, aCoordType);
}
static void
GetExtents(AtkComponent* aComponent, gint* aX, gint* aY, gint* aWidth,
gint* aHeight, AtkCoordType aCoordType)
{
static void GetExtents(AtkComponent* aComponent, gint* aX, gint* aY,
gint* aWidth, gint* aHeight, AtkCoordType aCoordType) {
*aX = *aY = *aWidth = *aHeight = 0;
if (!MAI_IS_ATK_SOCKET(aComponent))
return;
if (!MAI_IS_ATK_SOCKET(aComponent)) return;
getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
aX, aY, aWidth, aHeight, aCoordType);
getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX, aY, aWidth,
aHeight, aCoordType);
}
}
void
mai_atk_component_iface_init(AtkComponentIface* aIface)
{
void mai_atk_component_iface_init(AtkComponentIface* aIface) {
NS_ASSERTION(aIface, "Invalid Interface");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->ref_accessible_at_point = RefAccessibleAtPoint;
aIface->get_extents = GetExtents;
@@ -88,12 +73,10 @@ mai_atk_component_iface_init(AtkComponentIface* aIface)
AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
DocAccessible* aDoc,
const nsCString& aPlugId) :
AccessibleWrap(aContent, aDoc)
{
const nsCString& aPlugId)
: AccessibleWrap(aContent, aDoc) {
mAtkObject = mai_atk_socket_new(this);
if (!mAtkObject)
return;
if (!mAtkObject) return;
// Embeds the children of an AtkPlug, specified by plugId, as the children of
// this socket.
@@ -102,20 +85,16 @@ AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) &&
!aPlugId.IsVoid()) {
AtkSocket* accSocket =
G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
g_atk_socket_embed(accSocket, (gchar*)aPlugId.get());
}
}
void
AtkSocketAccessible::GetNativeInterface(void** aOutAccessible)
{
void AtkSocketAccessible::GetNativeInterface(void** aOutAccessible) {
*aOutAccessible = mAtkObject;
}
void
AtkSocketAccessible::Shutdown()
{
void AtkSocketAccessible::Shutdown() {
if (mAtkObject) {
if (MAI_IS_ATK_SOCKET(mAtkObject))
MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr;

View File

@@ -12,9 +12,9 @@
// This file gets included by nsAccessibilityService.cpp, which can't include
// atk.h (or glib.h), so we can't rely on it being included.
#ifdef __ATK_H__
extern "C" typedef void (*AtkSocketEmbedType) (AtkSocket*, gchar*);
extern "C" typedef void (*AtkSocketEmbedType)(AtkSocket*, gchar*);
#else
extern "C" typedef void (*AtkSocketEmbedType) (void*, void*);
extern "C" typedef void (*AtkSocketEmbedType)(void*, void*);
#endif
namespace mozilla {
@@ -24,10 +24,8 @@ namespace a11y {
* Provides a AccessibleWrap wrapper around AtkSocket for out-of-process
* accessibles.
*/
class AtkSocketAccessible : public AccessibleWrap
{
public:
class AtkSocketAccessible : public AccessibleWrap {
public:
// Soft references to AtkSocket
static AtkSocketEmbedType g_atk_socket_embed;
#ifdef __ATK_H__
@@ -50,7 +48,7 @@ public:
virtual void GetNativeInterface(void** aOutAccessible) override;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -12,13 +12,11 @@ namespace a11y {
namespace DOMtoATK {
void
AddBOMs(nsACString& aDest, const nsACString& aSource)
{
void AddBOMs(nsACString& aDest, const nsACString& aSource) {
uint32_t destlength = 0;
// First compute how much room we will need.
for (uint32_t srci = 0; srci < aSource.Length(); ) {
for (uint32_t srci = 0; srci < aSource.Length();) {
int bytes = UTF8traits::bytes(aSource[srci]);
if (bytes >= 4) {
// Non-BMP character, will add a BOM after it.
@@ -29,14 +27,15 @@ AddBOMs(nsACString& aDest, const nsACString& aSource)
destlength += bytes;
}
uint32_t desti = 0; // Index within aDest.
uint32_t desti = 0; // Index within aDest.
// Add BOMs after non-BMP characters.
aDest.SetLength(destlength);
for (uint32_t srci = 0; srci < aSource.Length(); ) {
for (uint32_t srci = 0; srci < aSource.Length();) {
uint32_t bytes = UTF8traits::bytes(aSource[srci]);
MOZ_ASSERT(bytes <= aSource.Length() - srci, "We should have the whole sequence");
MOZ_ASSERT(bytes <= aSource.Length() - srci,
"We should have the whole sequence");
// Copy whole sequence.
aDest.Replace(desti, bytes, Substring(aSource, srci, bytes));
@@ -53,15 +52,16 @@ AddBOMs(nsACString& aDest, const nsACString& aSource)
desti += 3;
}
}
MOZ_ASSERT(desti == destlength, "Incoherency between computed length"
"and actually translated length");
MOZ_ASSERT(desti == destlength,
"Incoherency between computed length"
"and actually translated length");
}
void
ATKStringConverterHelper::AdjustOffsets(gint* aStartOffset, gint* aEndOffset,
gint count)
{
MOZ_ASSERT(!mAdjusted, "DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be called only once");
void ATKStringConverterHelper::AdjustOffsets(gint* aStartOffset,
gint* aEndOffset, gint count) {
MOZ_ASSERT(!mAdjusted,
"DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be "
"called only once");
if (*aStartOffset > 0) {
(*aStartOffset)--;
@@ -78,17 +78,16 @@ ATKStringConverterHelper::AdjustOffsets(gint* aStartOffset, gint* aEndOffset,
#endif
}
gchar*
ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr)
{
gchar* ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr) {
int skip = 0;
if (mStartShifted) {
// AdjustOffsets added a leading character.
MOZ_ASSERT(aStr.Length() > 0, "There should be a leading character");
MOZ_ASSERT(static_cast<int>(aStr.Length()) >= UTF8traits::bytes(aStr.CharAt(0)),
"The leading character should be complete");
MOZ_ASSERT(
static_cast<int>(aStr.Length()) >= UTF8traits::bytes(aStr.CharAt(0)),
"The leading character should be complete");
// drop first character
skip = UTF8traits::bytes(aStr.CharAt(0));
@@ -108,7 +107,8 @@ ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr)
}
MOZ_ASSERT(trail >= 0,
"There should be at least a whole trailing character");
MOZ_ASSERT(trail + UTF8traits::bytes(aStr.CharAt(trail)) == static_cast<int>(aStr.Length()),
MOZ_ASSERT(trail + UTF8traits::bytes(aStr.CharAt(trail)) ==
static_cast<int>(aStr.Length()),
"The trailing character should be complete");
// Drop the last character.
@@ -119,10 +119,10 @@ ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr)
return g_strdup(aStr.get() + skip);
}
gchar*
ATKStringConverterHelper::ConvertAdjusted(const nsAString& aStr)
{
MOZ_ASSERT(mAdjusted, "DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be called before ATKStringConverterHelper::ConvertAdjusted");
gchar* ATKStringConverterHelper::ConvertAdjusted(const nsAString& aStr) {
MOZ_ASSERT(mAdjusted,
"DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be "
"called before ATKStringConverterHelper::ConvertAdjusted");
NS_ConvertUTF16toUTF8 cautoStr(aStr);
if (!cautoStr.get()) {
@@ -134,9 +134,7 @@ ATKStringConverterHelper::ConvertAdjusted(const nsAString& aStr)
return FinishUTF16toUTF8(cautoStrBOMs);
}
gchar*
Convert(const nsAString& aStr)
{
gchar* Convert(const nsAString& aStr) {
NS_ConvertUTF16toUTF8 cautoStr(aStr);
if (!cautoStr.get()) {
return nullptr;
@@ -147,15 +145,13 @@ Convert(const nsAString& aStr)
return g_strdup(cautoStrBOMs.get());
}
void
ConvertTexttoAsterisks(nsAString& aString)
{
void ConvertTexttoAsterisks(nsAString& aString) {
for (uint32_t i = 0; i < aString.Length(); i++) {
aString.ReplaceLiteral(i, 1, u"*");
}
}
}
} // namespace DOMtoATK
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla

View File

@@ -41,123 +41,122 @@
namespace mozilla {
namespace a11y {
namespace DOMtoATK
{
namespace DOMtoATK {
/**
* Converts a string of accessible text into ATK gchar* string (by adding
* BOMs). This can be used when offsets do not need to be adjusted because
* ends of the string can not fall between surrogates.
*/
gchar* Convert(const nsAString& aStr);
/**
* Converts a string of accessible text into ATK gchar* string (by adding
* BOMs). This can be used when offsets do not need to be adjusted because
* ends of the string can not fall between surrogates.
*/
gchar* Convert(const nsAString& aStr);
/**
* Add a BOM after each non-BMP character.
*/
void AddBOMs(nsACString& aDest, const nsACString& aSource);
/**
* Add a BOM after each non-BMP character.
*/
void AddBOMs(nsACString& aDest, const nsACString& aSource);
/**
* Replace all characters with asterisks (e.g. for password fields).
*/
void ConvertTexttoAsterisks(nsAString& aString);
/**
* Replace all characters with asterisks (e.g. for password fields).
*/
void ConvertTexttoAsterisks(nsAString& aString);
/**
* Parameterize conversion.
*/
enum class AtkStringConvertFlags : uint32_t {
None = 0,
ConvertTextToAsterisks = 1 << 0,
};
/**
* Parameterize conversion.
*/
enum class AtkStringConvertFlags : uint32_t {
None = 0,
ConvertTextToAsterisks = 1 << 0,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AtkStringConvertFlags)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AtkStringConvertFlags)
class ATKStringConverterHelper {
public:
ATKStringConverterHelper(void) :
class ATKStringConverterHelper {
public:
ATKStringConverterHelper(void)
:
#ifdef DEBUG
mAdjusted (false),
mAdjusted(false),
#endif
mStartShifted (false),
mEndShifted (false) { }
/**
* In order to properly get non-BMP values, offsets need to be changed
* to get one character more on each end, so that ConvertUTF16toUTF8 can
* convert surrogates even if the originally requested offsets fall between
* them.
*/
void AdjustOffsets(gint* aStartOffset, gint* aEndOffset, gint count);
/**
* Converts a string of accessible text with adjusted offsets into ATK
* gchar* string (by adding BOMs). Note, AdjustOffsets has to be called
* before getting the text passed to this.
*/
gchar* ConvertAdjusted(const nsAString& aStr);
private:
/**
* Remove the additional characters requested by PrepareUTF16toUTF8.
*/
gchar* FinishUTF16toUTF8(nsCString& aStr);
#ifdef DEBUG
bool mAdjusted;
#endif
bool mStartShifted;
bool mEndShifted;
};
/**
* Get text from aAccessible, using ATKStringConverterHelper to properly
* introduce appropriate BOMs.
*/
template <class AccessibleOrProxy>
gchar* NewATKString(AccessibleOrProxy* aAccessible,
gint aStartOffset, gint aEndOffset,
AtkStringConvertFlags aFlags)
{
gint startOffset = aStartOffset, endOffset = aEndOffset;
ATKStringConverterHelper converter;
converter.AdjustOffsets(&startOffset, &endOffset,
gint(aAccessible->CharacterCount()));
nsAutoString str;
aAccessible->TextSubstring(startOffset, endOffset, str);
if (aFlags & AtkStringConvertFlags::ConvertTextToAsterisks)
ConvertTexttoAsterisks(str);
return converter.ConvertAdjusted(str);
mStartShifted(false),
mEndShifted(false) {
}
/**
* Get a character from aAccessible, fetching more data as appropriate to
* properly get non-BMP characters or a BOM as appropriate.
* In order to properly get non-BMP values, offsets need to be changed
* to get one character more on each end, so that ConvertUTF16toUTF8 can
* convert surrogates even if the originally requested offsets fall between
* them.
*/
template <class AccessibleCharAt>
gunichar ATKCharacter(AccessibleCharAt* aAccessible, gint aOffset)
{
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
gunichar character = static_cast<gunichar>(aAccessible->CharAt(aOffset));
void AdjustOffsets(gint* aStartOffset, gint* aEndOffset, gint count);
if (NS_IS_LOW_SURROGATE(character)) {
// Trailing surrogate, return BOM instead.
return 0xFEFF;
}
/**
* Converts a string of accessible text with adjusted offsets into ATK
* gchar* string (by adding BOMs). Note, AdjustOffsets has to be called
* before getting the text passed to this.
*/
gchar* ConvertAdjusted(const nsAString& aStr);
if (NS_IS_HIGH_SURROGATE(character)) {
// Heading surrogate, get the trailing surrogate and combine them.
gunichar characterLow = static_cast<gunichar>(aAccessible->CharAt(aOffset + 1));
private:
/**
* Remove the additional characters requested by PrepareUTF16toUTF8.
*/
gchar* FinishUTF16toUTF8(nsCString& aStr);
if (!NS_IS_LOW_SURROGATE(characterLow)) {
// It should have been a trailing surrogate... Flag the error.
return 0xFFFD;
}
return SURROGATE_TO_UCS4(character, characterLow);
}
return character;
}
#ifdef DEBUG
bool mAdjusted;
#endif
bool mStartShifted;
bool mEndShifted;
};
/**
* Get text from aAccessible, using ATKStringConverterHelper to properly
* introduce appropriate BOMs.
*/
template <class AccessibleOrProxy>
gchar* NewATKString(AccessibleOrProxy* aAccessible, gint aStartOffset,
gint aEndOffset, AtkStringConvertFlags aFlags) {
gint startOffset = aStartOffset, endOffset = aEndOffset;
ATKStringConverterHelper converter;
converter.AdjustOffsets(&startOffset, &endOffset,
gint(aAccessible->CharacterCount()));
nsAutoString str;
aAccessible->TextSubstring(startOffset, endOffset, str);
if (aFlags & AtkStringConvertFlags::ConvertTextToAsterisks)
ConvertTexttoAsterisks(str);
return converter.ConvertAdjusted(str);
}
} // namespace a11y
} // namespace mozilla
/**
* Get a character from aAccessible, fetching more data as appropriate to
* properly get non-BMP characters or a BOM as appropriate.
*/
template <class AccessibleCharAt>
gunichar ATKCharacter(AccessibleCharAt* aAccessible, gint aOffset) {
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
gunichar character = static_cast<gunichar>(aAccessible->CharAt(aOffset));
if (NS_IS_LOW_SURROGATE(character)) {
// Trailing surrogate, return BOM instead.
return 0xFEFF;
}
if (NS_IS_HIGH_SURROGATE(character)) {
// Heading surrogate, get the trailing surrogate and combine them.
gunichar characterLow =
static_cast<gunichar>(aAccessible->CharAt(aOffset + 1));
if (!NS_IS_LOW_SURROGATE(characterLow)) {
// It should have been a trailing surrogate... Flag the error.
return 0xFFFD;
}
return SURROGATE_TO_UCS4(character, characterLow);
}
return character;
}
} // namespace DOMtoATK
} // namespace a11y
} // namespace mozilla

View File

@@ -13,13 +13,8 @@ using namespace mozilla::a11y;
// DocAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
DocAccessibleWrap::
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell) :
DocAccessible(aDocument, aPresShell), mActivated(false)
{
}
DocAccessibleWrap::~DocAccessibleWrap()
{
}
DocAccessibleWrap::DocAccessibleWrap(nsIDocument* aDocument,
nsIPresShell* aPresShell)
: DocAccessible(aDocument, aPresShell), mActivated(false) {}
DocAccessibleWrap::~DocAccessibleWrap() {}

View File

@@ -16,16 +16,15 @@
namespace mozilla {
namespace a11y {
class DocAccessibleWrap : public DocAccessible
{
public:
class DocAccessibleWrap : public DocAccessible {
public:
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
virtual ~DocAccessibleWrap();
bool mActivated;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -16,8 +16,7 @@ typedef class HTMLTableAccessible HTMLTableAccessibleWrap;
typedef class HTMLTableCellAccessible HTMLTableCellAccessibleWrap;
typedef class HTMLTableHeaderCellAccessible HTMLTableHeaderCellAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -14,8 +14,7 @@ namespace a11y {
typedef class HyperTextAccessible HyperTextAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -14,8 +14,7 @@ namespace a11y {
typedef class ImageAccessible ImageAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -14,31 +14,30 @@ namespace a11y {
class AccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
extern "C" {
void actionInterfaceInitCB(AtkActionIface* aIface);
void componentInterfaceInitCB(AtkComponentIface* aIface);
void documentInterfaceInitCB(AtkDocumentIface *aIface);
void documentInterfaceInitCB(AtkDocumentIface* aIface);
void editableTextInterfaceInitCB(AtkEditableTextIface* aIface);
void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface);
void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface* aIface);
void hypertextInterfaceInitCB(AtkHypertextIface* aIface);
void imageInterfaceInitCB(AtkImageIface* aIface);
void selectionInterfaceInitCB(AtkSelectionIface* aIface);
void tableInterfaceInitCB(AtkTableIface *aIface);
void tableCellInterfaceInitCB(AtkTableCellIface *aIface);
void tableInterfaceInitCB(AtkTableIface* aIface);
void tableCellInterfaceInitCB(AtkTableCellIface* aIface);
void textInterfaceInitCB(AtkTextIface* aIface);
void valueInterfaceInitCB(AtkValueIface *aIface);
void valueInterfaceInitCB(AtkValueIface* aIface);
}
/**
* XXX these should live in a file of utils for atk.
*/
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj,
gint aX, gint aY, AtkCoordType aCoordType);
void getExtentsHelper(AtkObject* aAtkObj,
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
AtkCoordType aCoordType);
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
AtkCoordType aCoordType);
void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
gint* aHeight, AtkCoordType aCoordType);
#endif // ATK_INTERFACE_INIT_FUNCS_H_
#endif // ATK_INTERFACE_INIT_FUNCS_H_

View File

@@ -20,7 +20,8 @@
#include <gtk/gtk.h>
#ifdef MOZ_WIDGET_GTK
extern "C" __attribute__((weak,visibility("default"))) int atk_bridge_adaptor_init(int*, char **[]);
extern "C" __attribute__((weak, visibility("default"))) int
atk_bridge_adaptor_init(int*, char**[]);
#endif
using namespace mozilla;
@@ -31,15 +32,15 @@ int atkMajorVersion = 1, atkMinorVersion = 12, atkMicroVersion = 0;
GType (*gAtkTableCellGetTypeFunc)();
extern "C" {
typedef GType (* AtkGetTypeType) (void);
typedef void (*GnomeAccessibilityInit) (void);
typedef void (*GnomeAccessibilityShutdown) (void);
typedef GType (*AtkGetTypeType)(void);
typedef void (*GnomeAccessibilityInit)(void);
typedef void (*GnomeAccessibilityShutdown)(void);
}
static PRLibrary* sATKLib = nullptr;
static const char sATKLibName[] = "libatk-1.0.so.0";
static const char sATKHyperlinkImplGetTypeSymbol[] =
"atk_hyperlink_impl_get_type";
"atk_hyperlink_impl_get_type";
gboolean toplevel_event_watcher(GSignalInvocationHint*, guint, const GValue*,
gpointer);
@@ -49,14 +50,13 @@ static gulong sToplevel_hide_hook = 0;
GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
struct GnomeAccessibilityModule
{
const char *libName;
PRLibrary *lib;
const char *initName;
GnomeAccessibilityInit init;
const char *shutdownName;
GnomeAccessibilityShutdown shutdown;
struct GnomeAccessibilityModule {
const char* libName;
PRLibrary* lib;
const char* initName;
GnomeAccessibilityInit init;
const char* shutdownName;
GnomeAccessibilityShutdown shutdown;
};
static GnomeAccessibilityModule sAtkBridge = {
@@ -65,92 +65,84 @@ static GnomeAccessibilityModule sAtkBridge = {
#else
"libatk-bridge.so", nullptr,
#endif
"gnome_accessibility_module_init", nullptr,
"gnome_accessibility_module_shutdown", nullptr
};
"gnome_accessibility_module_init", nullptr,
"gnome_accessibility_module_shutdown", nullptr};
static nsresult
LoadGtkModule(GnomeAccessibilityModule& aModule)
{
NS_ENSURE_ARG(aModule.libName);
static nsresult LoadGtkModule(GnomeAccessibilityModule& aModule) {
NS_ENSURE_ARG(aModule.libName);
if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) {
//try to load the module with "gtk-2.0/modules" appended
char *curLibPath = PR_GetLibraryPath();
nsAutoCString libPath(curLibPath);
if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) {
// try to load the module with "gtk-2.0/modules" appended
char* curLibPath = PR_GetLibraryPath();
nsAutoCString libPath(curLibPath);
#if defined(LINUX) && defined(__x86_64__)
libPath.AppendLiteral(":/usr/lib64:/usr/lib");
libPath.AppendLiteral(":/usr/lib64:/usr/lib");
#else
libPath.AppendLiteral(":/usr/lib");
libPath.AppendLiteral(":/usr/lib");
#endif
PR_FreeLibraryName(curLibPath);
PR_FreeLibraryName(curLibPath);
int16_t loc1 = 0, loc2 = 0;
int16_t subLen = 0;
while (loc2 >= 0) {
loc2 = libPath.FindChar(':', loc1);
if (loc2 < 0)
subLen = libPath.Length() - loc1;
else
subLen = loc2 - loc1;
nsAutoCString sub(Substring(libPath, loc1, subLen));
sub.AppendLiteral("/gtk-3.0/modules/");
sub.Append(aModule.libName);
aModule.lib = PR_LoadLibrary(sub.get());
if (aModule.lib)
break;
int16_t loc1 = 0, loc2 = 0;
int16_t subLen = 0;
while (loc2 >= 0) {
loc2 = libPath.FindChar(':', loc1);
if (loc2 < 0)
subLen = libPath.Length() - loc1;
else
subLen = loc2 - loc1;
nsAutoCString sub(Substring(libPath, loc1, subLen));
sub.AppendLiteral("/gtk-3.0/modules/");
sub.Append(aModule.libName);
aModule.lib = PR_LoadLibrary(sub.get());
if (aModule.lib) break;
loc1 = loc2+1;
}
if (!aModule.lib)
return NS_ERROR_FAILURE;
loc1 = loc2 + 1;
}
if (!aModule.lib) return NS_ERROR_FAILURE;
}
//we have loaded the library, try to get the function ptrs
if (!(aModule.init = PR_FindFunctionSymbol(aModule.lib,
aModule.initName)) ||
!(aModule.shutdown = PR_FindFunctionSymbol(aModule.lib,
aModule.shutdownName))) {
//fail, :(
PR_UnloadLibrary(aModule.lib);
aModule.lib = nullptr;
return NS_ERROR_FAILURE;
}
return NS_OK;
// we have loaded the library, try to get the function ptrs
if (!(aModule.init = PR_FindFunctionSymbol(aModule.lib, aModule.initName)) ||
!(aModule.shutdown =
PR_FindFunctionSymbol(aModule.lib, aModule.shutdownName))) {
// fail, :(
PR_UnloadLibrary(aModule.lib);
aModule.lib = nullptr;
return NS_ERROR_FAILURE;
}
return NS_OK;
}
void
a11y::PlatformInit()
{
if (!ShouldA11yBeEnabled())
return;
void a11y::PlatformInit() {
if (!ShouldA11yBeEnabled()) return;
sATKLib = PR_LoadLibrary(sATKLibName);
if (!sATKLib)
return;
if (!sATKLib) return;
AtkGetTypeType pfn_atk_hyperlink_impl_get_type =
(AtkGetTypeType) PR_FindFunctionSymbol(sATKLib, sATKHyperlinkImplGetTypeSymbol);
(AtkGetTypeType)PR_FindFunctionSymbol(sATKLib,
sATKHyperlinkImplGetTypeSymbol);
if (pfn_atk_hyperlink_impl_get_type)
g_atk_hyperlink_impl_type = pfn_atk_hyperlink_impl_get_type();
AtkGetTypeType pfn_atk_socket_get_type = (AtkGetTypeType)
PR_FindFunctionSymbol(sATKLib, AtkSocketAccessible::sATKSocketGetTypeSymbol);
AtkGetTypeType pfn_atk_socket_get_type =
(AtkGetTypeType)PR_FindFunctionSymbol(
sATKLib, AtkSocketAccessible::sATKSocketGetTypeSymbol);
if (pfn_atk_socket_get_type) {
AtkSocketAccessible::g_atk_socket_type = pfn_atk_socket_get_type();
AtkSocketAccessible::g_atk_socket_embed = (AtkSocketEmbedType)
PR_FindFunctionSymbol(sATKLib, AtkSocketAccessible ::sATKSocketEmbedSymbol);
AtkSocketAccessible::g_atk_socket_embed =
(AtkSocketEmbedType)PR_FindFunctionSymbol(
sATKLib, AtkSocketAccessible ::sATKSocketEmbedSymbol);
AtkSocketAccessible::gCanEmbed =
AtkSocketAccessible::g_atk_socket_type != G_TYPE_INVALID &&
AtkSocketAccessible::g_atk_socket_embed;
AtkSocketAccessible::g_atk_socket_type != G_TYPE_INVALID &&
AtkSocketAccessible::g_atk_socket_embed;
}
gAtkTableCellGetTypeFunc = (GType (*)())
PR_FindFunctionSymbol(sATKLib, "atk_table_cell_get_type");
gAtkTableCellGetTypeFunc =
(GType(*)())PR_FindFunctionSymbol(sATKLib, "atk_table_cell_get_type");
const char* (*atkGetVersion)() =
(const char* (*)()) PR_FindFunctionSymbol(sATKLib, "atk_get_version");
(const char* (*)())PR_FindFunctionSymbol(sATKLib, "atk_get_version");
if (atkGetVersion) {
const char* version = atkGetVersion();
if (version) {
@@ -183,58 +175,49 @@ a11y::PlatformInit()
if (!sToplevel_event_hook_added) {
sToplevel_event_hook_added = true;
sToplevel_show_hook =
g_signal_add_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
0, toplevel_event_watcher,
reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW),
nullptr);
sToplevel_hide_hook =
g_signal_add_emission_hook(g_signal_lookup("hide", GTK_TYPE_WINDOW), 0,
toplevel_event_watcher,
reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_HIDE),
nullptr);
sToplevel_show_hook = g_signal_add_emission_hook(
g_signal_lookup("show", GTK_TYPE_WINDOW), 0, toplevel_event_watcher,
reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW), nullptr);
sToplevel_hide_hook = g_signal_add_emission_hook(
g_signal_lookup("hide", GTK_TYPE_WINDOW), 0, toplevel_event_watcher,
reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_HIDE), nullptr);
}
}
void
a11y::PlatformShutdown()
{
if (sToplevel_event_hook_added) {
sToplevel_event_hook_added = false;
g_signal_remove_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
sToplevel_show_hook);
g_signal_remove_emission_hook(g_signal_lookup("hide", GTK_TYPE_WINDOW),
sToplevel_hide_hook);
}
void a11y::PlatformShutdown() {
if (sToplevel_event_hook_added) {
sToplevel_event_hook_added = false;
g_signal_remove_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
sToplevel_show_hook);
g_signal_remove_emission_hook(g_signal_lookup("hide", GTK_TYPE_WINDOW),
sToplevel_hide_hook);
}
if (sAtkBridge.lib) {
// Do not shutdown/unload atk-bridge,
// an exit function registered will take care of it
// if (sAtkBridge.shutdown)
// (*sAtkBridge.shutdown)();
// PR_UnloadLibrary(sAtkBridge.lib);
sAtkBridge.lib = nullptr;
sAtkBridge.init = nullptr;
sAtkBridge.shutdown = nullptr;
}
// if (sATKLib) {
// PR_UnloadLibrary(sATKLib);
// sATKLib = nullptr;
// }
if (sAtkBridge.lib) {
// Do not shutdown/unload atk-bridge,
// an exit function registered will take care of it
// if (sAtkBridge.shutdown)
// (*sAtkBridge.shutdown)();
// PR_UnloadLibrary(sAtkBridge.lib);
sAtkBridge.lib = nullptr;
sAtkBridge.init = nullptr;
sAtkBridge.shutdown = nullptr;
}
// if (sATKLib) {
// PR_UnloadLibrary(sATKLib);
// sATKLib = nullptr;
// }
}
static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
static const char sAccEnv[] = "GNOME_ACCESSIBILITY";
#ifdef MOZ_ENABLE_DBUS
static DBusPendingCall *sPendingCall = nullptr;
static DBusPendingCall* sPendingCall = nullptr;
#endif
void
a11y::PreInit()
{
void a11y::PreInit() {
#ifdef MOZ_ENABLE_DBUS
static bool sChecked = FALSE;
if (sChecked)
return;
if (sChecked) return;
sChecked = TRUE;
@@ -242,26 +225,23 @@ a11y::PreInit()
// also make sure that a session bus address is available to prevent dbus from
// starting a new one. Dbus confuses the test harness when it creates a new
// process (see bug 693343)
if (PR_GetEnv(sAccEnv) || !PR_GetEnv("DBUS_SESSION_BUS_ADDRESS"))
return;
if (PR_GetEnv(sAccEnv) || !PR_GetEnv("DBUS_SESSION_BUS_ADDRESS")) return;
DBusConnection* bus = dbus_bus_get(DBUS_BUS_SESSION, nullptr);
if (!bus)
return;
if (!bus) return;
dbus_connection_set_exit_on_disconnect(bus, FALSE);
static const char* iface = "org.a11y.Status";
static const char* member = "IsEnabled";
DBusMessage *message;
message = dbus_message_new_method_call("org.a11y.Bus", "/org/a11y/bus",
"org.freedesktop.DBus.Properties",
"Get");
if (!message)
goto dbus_done;
DBusMessage* message;
message =
dbus_message_new_method_call("org.a11y.Bus", "/org/a11y/bus",
"org.freedesktop.DBus.Properties", "Get");
if (!message) goto dbus_done;
dbus_message_append_args(message, DBUS_TYPE_STRING, &iface,
DBUS_TYPE_STRING, &member, DBUS_TYPE_INVALID);
dbus_message_append_args(message, DBUS_TYPE_STRING, &iface, DBUS_TYPE_STRING,
&member, DBUS_TYPE_INVALID);
dbus_connection_send_with_reply(bus, message, &sPendingCall, 1000);
dbus_message_unref(message);
@@ -270,30 +250,24 @@ dbus_done:
#endif
}
bool
a11y::ShouldA11yBeEnabled()
{
bool a11y::ShouldA11yBeEnabled() {
static bool sChecked = false, sShouldEnable = false;
if (sChecked)
return sShouldEnable;
if (sChecked) return sShouldEnable;
sChecked = true;
EPlatformDisabledState disabledState = PlatformDisabledState();
if (disabledState == ePlatformIsDisabled)
return sShouldEnable = false;
if (disabledState == ePlatformIsDisabled) return sShouldEnable = false;
// check if accessibility enabled/disabled by environment variable
const char* envValue = PR_GetEnv(sAccEnv);
if (envValue)
return sShouldEnable = !!atoi(envValue);
if (envValue) return sShouldEnable = !!atoi(envValue);
#ifdef MOZ_ENABLE_DBUS
PreInit();
bool dbusSuccess = false;
DBusMessage *reply = nullptr;
if (!sPendingCall)
goto dbus_done;
DBusMessage* reply = nullptr;
if (!sPendingCall) goto dbus_done;
dbus_pending_call_block(sPendingCall);
reply = dbus_pending_call_steal_reply(sPendingCall);
@@ -301,13 +275,13 @@ a11y::ShouldA11yBeEnabled()
sPendingCall = nullptr;
if (!reply ||
dbus_message_get_type(reply) != DBUS_MESSAGE_TYPE_METHOD_RETURN ||
strcmp(dbus_message_get_signature (reply), DBUS_TYPE_VARIANT_AS_STRING))
strcmp(dbus_message_get_signature(reply), DBUS_TYPE_VARIANT_AS_STRING))
goto dbus_done;
DBusMessageIter iter, iter_variant, iter_struct;
dbus_bool_t dResult;
dbus_message_iter_init(reply, &iter);
dbus_message_iter_recurse (&iter, &iter_variant);
dbus_message_iter_recurse(&iter, &iter_variant);
switch (dbus_message_iter_get_arg_type(&iter_variant)) {
case DBUS_TYPE_STRUCT:
// at-spi2-core 2.2.0-2.2.1 had a bug where it returned a struct
@@ -329,18 +303,16 @@ a11y::ShouldA11yBeEnabled()
}
dbus_done:
if (reply)
dbus_message_unref(reply);
if (reply) dbus_message_unref(reply);
if (dbusSuccess)
return sShouldEnable;
if (dbusSuccess) return sShouldEnable;
#endif
//check gconf-2 setting
// check gconf-2 setting
#define GCONF_A11Y_KEY "/desktop/gnome/interface/accessibility"
nsresult rv = NS_OK;
nsCOMPtr<nsIGConfService> gconf =
do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv);
do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && gconf)
gconf->GetBool(NS_LITERAL_CSTRING(GCONF_A11Y_KEY), &sShouldEnable);

View File

@@ -10,15 +10,13 @@
using namespace mozilla::a11y;
GtkWindowAccessible::GtkWindowAccessible(AtkObject* aAccessible) :
DummyAccessible()
{
GtkWindowAccessible::GtkWindowAccessible(AtkObject* aAccessible)
: DummyAccessible() {
g_object_ref(aAccessible);
mAtkObject = aAccessible;
}
GtkWindowAccessible::~GtkWindowAccessible()
{
GtkWindowAccessible::~GtkWindowAccessible() {
g_object_unref(mAtkObject);
mAtkObject = nullptr;
}

View File

@@ -20,15 +20,13 @@ typedef RootAccessible RootAccessibleWrap;
* It is added into root when the toplevel window is created, and removed
* from root when the toplevel window is destroyed.
*/
class GtkWindowAccessible final : public DummyAccessible
{
public:
class GtkWindowAccessible final : public DummyAccessible {
public:
explicit GtkWindowAccessible(AtkObject* aAccessible);
virtual ~GtkWindowAccessible();
};
} // namespace a11y
} // namespace mozilla
#endif /* mozilla_a11y_Root_Accessible_Wrap_h__ */
} // namespace a11y
} // namespace mozilla
#endif /* mozilla_a11y_Root_Accessible_Wrap_h__ */

View File

@@ -14,7 +14,7 @@ namespace a11y {
typedef class TextLeafAccessible TextLeafAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -24,14 +24,13 @@ typedef AtkUtilClass MaiUtilClass;
extern "C" {
static guint (*gail_add_global_event_listener)(GSignalEmissionHook listener,
const gchar* event_type);
static void (*gail_remove_global_event_listener) (guint remove_listener);
static void (*gail_remove_key_event_listener) (guint remove_listener);
static AtkObject* (*gail_get_root)();
const gchar *event_type);
static void (*gail_remove_global_event_listener)(guint remove_listener);
static void (*gail_remove_key_event_listener)(guint remove_listener);
static AtkObject *(*gail_get_root)();
}
struct MaiUtilListenerInfo
{
struct MaiUtilListenerInfo {
gint key;
guint signal_id;
gulong hook_id;
@@ -42,217 +41,186 @@ struct MaiUtilListenerInfo
guint gail_listenerid;
};
static GHashTable* sListener_list = nullptr;
static GHashTable *sListener_list = nullptr;
static gint sListener_idx = 1;
extern "C" {
static guint
add_listener (GSignalEmissionHook listener,
const gchar *object_type,
const gchar *signal,
const gchar *hook_data,
guint gail_listenerid = 0)
{
GType type;
guint signal_id;
gint rc = 0;
static guint add_listener(GSignalEmissionHook listener,
const gchar *object_type, const gchar *signal,
const gchar *hook_data, guint gail_listenerid = 0) {
GType type;
guint signal_id;
gint rc = 0;
type = g_type_from_name(object_type);
if (type) {
signal_id = g_signal_lookup(signal, type);
if (signal_id > 0) {
MaiUtilListenerInfo *listener_info;
type = g_type_from_name(object_type);
if (type) {
signal_id = g_signal_lookup(signal, type);
if (signal_id > 0) {
MaiUtilListenerInfo *listener_info;
rc = sListener_idx;
rc = sListener_idx;
listener_info = (MaiUtilListenerInfo *)
g_malloc(sizeof(MaiUtilListenerInfo));
listener_info->key = sListener_idx;
listener_info->hook_id =
g_signal_add_emission_hook(signal_id, 0, listener,
g_strdup(hook_data),
(GDestroyNotify)g_free);
listener_info->signal_id = signal_id;
listener_info->gail_listenerid = gail_listenerid;
listener_info =
(MaiUtilListenerInfo *)g_malloc(sizeof(MaiUtilListenerInfo));
listener_info->key = sListener_idx;
listener_info->hook_id = g_signal_add_emission_hook(
signal_id, 0, listener, g_strdup(hook_data), (GDestroyNotify)g_free);
listener_info->signal_id = signal_id;
listener_info->gail_listenerid = gail_listenerid;
g_hash_table_insert(sListener_list, &(listener_info->key),
listener_info);
sListener_idx++;
}
else {
g_warning("Invalid signal type %s\n", signal);
}
g_hash_table_insert(sListener_list, &(listener_info->key), listener_info);
sListener_idx++;
} else {
g_warning("Invalid signal type %s\n", signal);
}
else {
g_warning("Invalid object type %s\n", object_type);
}
return rc;
} else {
g_warning("Invalid object type %s\n", object_type);
}
return rc;
}
static guint
mai_util_add_global_event_listener(GSignalEmissionHook listener,
const gchar *event_type)
{
guint rc = 0;
gchar **split_string;
static guint mai_util_add_global_event_listener(GSignalEmissionHook listener,
const gchar *event_type) {
guint rc = 0;
gchar **split_string;
split_string = g_strsplit (event_type, ":", 3);
split_string = g_strsplit(event_type, ":", 3);
if (split_string) {
if (!strcmp ("window", split_string[0])) {
guint gail_listenerid = 0;
if (gail_add_global_event_listener) {
// call gail's function to track gtk native window events
gail_listenerid =
gail_add_global_event_listener(listener, event_type);
}
if (split_string) {
if (!strcmp("window", split_string[0])) {
guint gail_listenerid = 0;
if (gail_add_global_event_listener) {
// call gail's function to track gtk native window events
gail_listenerid = gail_add_global_event_listener(listener, event_type);
}
rc = add_listener (listener, "MaiAtkObject", split_string[1],
event_type, gail_listenerid);
}
else {
rc = add_listener (listener, split_string[1], split_string[2],
event_type);
}
g_strfreev(split_string);
rc = add_listener(listener, "MaiAtkObject", split_string[1], event_type,
gail_listenerid);
} else {
rc = add_listener(listener, split_string[1], split_string[2], event_type);
}
return rc;
g_strfreev(split_string);
}
return rc;
}
static void
mai_util_remove_global_event_listener(guint remove_listener)
{
if (remove_listener > 0) {
MaiUtilListenerInfo *listener_info;
gint tmp_idx = remove_listener;
static void mai_util_remove_global_event_listener(guint remove_listener) {
if (remove_listener > 0) {
MaiUtilListenerInfo *listener_info;
gint tmp_idx = remove_listener;
listener_info = (MaiUtilListenerInfo *)
g_hash_table_lookup(sListener_list, &tmp_idx);
listener_info =
(MaiUtilListenerInfo *)g_hash_table_lookup(sListener_list, &tmp_idx);
if (listener_info != nullptr) {
if (gail_remove_global_event_listener &&
listener_info->gail_listenerid) {
gail_remove_global_event_listener(listener_info->gail_listenerid);
}
if (listener_info != nullptr) {
if (gail_remove_global_event_listener && listener_info->gail_listenerid) {
gail_remove_global_event_listener(listener_info->gail_listenerid);
}
/* Hook id of 0 and signal id of 0 are invalid */
if (listener_info->hook_id != 0 && listener_info->signal_id != 0) {
/* Remove the emission hook */
g_signal_remove_emission_hook(listener_info->signal_id,
listener_info->hook_id);
/* Hook id of 0 and signal id of 0 are invalid */
if (listener_info->hook_id != 0 && listener_info->signal_id != 0) {
/* Remove the emission hook */
g_signal_remove_emission_hook(listener_info->signal_id,
listener_info->hook_id);
/* Remove the element from the hash */
g_hash_table_remove(sListener_list, &tmp_idx);
}
else {
g_warning("Invalid listener hook_id %ld or signal_id %d\n",
listener_info->hook_id, listener_info->signal_id);
}
}
else {
// atk-bridge is initialized with gail (e.g. yelp)
// try gail_remove_global_event_listener
if (gail_remove_global_event_listener) {
return gail_remove_global_event_listener(remove_listener);
}
/* Remove the element from the hash */
g_hash_table_remove(sListener_list, &tmp_idx);
} else {
g_warning("Invalid listener hook_id %ld or signal_id %d\n",
listener_info->hook_id, listener_info->signal_id);
}
} else {
// atk-bridge is initialized with gail (e.g. yelp)
// try gail_remove_global_event_listener
if (gail_remove_global_event_listener) {
return gail_remove_global_event_listener(remove_listener);
}
g_warning("No listener with the specified listener id %d",
remove_listener);
}
}
else {
g_warning("Invalid listener_id %d", remove_listener);
g_warning("No listener with the specified listener id %d",
remove_listener);
}
} else {
g_warning("Invalid listener_id %d", remove_listener);
}
}
static AtkKeyEventStruct *
atk_key_event_from_gdk_event_key (GdkEventKey *key)
{
AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1);
switch (key->type) {
static AtkKeyEventStruct *atk_key_event_from_gdk_event_key(GdkEventKey *key) {
AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1);
switch (key->type) {
case GDK_KEY_PRESS:
event->type = ATK_KEY_EVENT_PRESS;
break;
event->type = ATK_KEY_EVENT_PRESS;
break;
case GDK_KEY_RELEASE:
event->type = ATK_KEY_EVENT_RELEASE;
break;
event->type = ATK_KEY_EVENT_RELEASE;
break;
default:
g_assert_not_reached ();
return nullptr;
}
event->state = key->state;
event->keyval = key->keyval;
event->length = key->length;
if (key->string && key->string [0] &&
(key->state & GDK_CONTROL_MASK ||
g_unichar_isgraph (g_utf8_get_char (key->string)))) {
event->string = key->string;
}
else if (key->type == GDK_KEY_PRESS ||
key->type == GDK_KEY_RELEASE) {
event->string = gdk_keyval_name (key->keyval);
}
event->keycode = key->hardware_keycode;
event->timestamp = key->time;
g_assert_not_reached();
return nullptr;
}
event->state = key->state;
event->keyval = key->keyval;
event->length = key->length;
if (key->string && key->string[0] &&
(key->state & GDK_CONTROL_MASK ||
g_unichar_isgraph(g_utf8_get_char(key->string)))) {
event->string = key->string;
} else if (key->type == GDK_KEY_PRESS || key->type == GDK_KEY_RELEASE) {
event->string = gdk_keyval_name(key->keyval);
}
event->keycode = key->hardware_keycode;
event->timestamp = key->time;
return event;
return event;
}
struct MaiKeyEventInfo
{
AtkKeyEventStruct *key_event;
gpointer func_data;
struct MaiKeyEventInfo {
AtkKeyEventStruct *key_event;
gpointer func_data;
};
union AtkKeySnoopFuncPointer
{
AtkKeySnoopFunc func_ptr;
gpointer data;
union AtkKeySnoopFuncPointer {
AtkKeySnoopFunc func_ptr;
gpointer data;
};
static gboolean
notify_hf(gpointer key, gpointer value, gpointer data)
{
MaiKeyEventInfo *info = (MaiKeyEventInfo *)data;
AtkKeySnoopFuncPointer atkKeySnoop;
atkKeySnoop.data = value;
return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE : FALSE;
static gboolean notify_hf(gpointer key, gpointer value, gpointer data) {
MaiKeyEventInfo *info = (MaiKeyEventInfo *)data;
AtkKeySnoopFuncPointer atkKeySnoop;
atkKeySnoop.data = value;
return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE
: FALSE;
}
static void
insert_hf(gpointer key, gpointer value, gpointer data)
{
GHashTable *new_table = (GHashTable *) data;
g_hash_table_insert (new_table, key, value);
static void insert_hf(gpointer key, gpointer value, gpointer data) {
GHashTable *new_table = (GHashTable *)data;
g_hash_table_insert(new_table, key, value);
}
static GHashTable* sKey_listener_list = nullptr;
static GHashTable *sKey_listener_list = nullptr;
static gint
mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event, gpointer func_data)
{
/* notify each AtkKeySnoopFunc in turn... */
static gint mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event,
gpointer func_data) {
/* notify each AtkKeySnoopFunc in turn... */
MaiKeyEventInfo *info = g_new0(MaiKeyEventInfo, 1);
gint consumed = 0;
if (sKey_listener_list) {
GHashTable *new_hash = g_hash_table_new(nullptr, nullptr);
g_hash_table_foreach (sKey_listener_list, insert_hf, new_hash);
info->key_event = atk_key_event_from_gdk_event_key (event);
info->func_data = func_data;
consumed = g_hash_table_foreach_steal (new_hash, notify_hf, info);
g_hash_table_destroy (new_hash);
g_free(info->key_event);
}
g_free(info);
return (consumed ? 1 : 0);
MaiKeyEventInfo *info = g_new0(MaiKeyEventInfo, 1);
gint consumed = 0;
if (sKey_listener_list) {
GHashTable *new_hash = g_hash_table_new(nullptr, nullptr);
g_hash_table_foreach(sKey_listener_list, insert_hf, new_hash);
info->key_event = atk_key_event_from_gdk_event_key(event);
info->func_data = func_data;
consumed = g_hash_table_foreach_steal(new_hash, notify_hf, info);
g_hash_table_destroy(new_hash);
g_free(info->key_event);
}
g_free(info);
return (consumed ? 1 : 0);
}
static guint sKey_snooper_id = 0;
static guint
mai_util_add_key_event_listener(AtkKeySnoopFunc listener, gpointer data)
{
static guint mai_util_add_key_event_listener(AtkKeySnoopFunc listener,
gpointer data) {
if (MOZ_UNLIKELY(!listener)) {
return 0;
}
@@ -277,135 +245,103 @@ mai_util_add_key_event_listener(AtkKeySnoopFunc listener, gpointer data)
return key;
}
static void
mai_util_remove_key_event_listener (guint remove_listener)
{
if (!sKey_listener_list) {
// atk-bridge is initialized with gail (e.g. yelp)
// try gail_remove_key_event_listener
return gail_remove_key_event_listener(remove_listener);
}
static void mai_util_remove_key_event_listener(guint remove_listener) {
if (!sKey_listener_list) {
// atk-bridge is initialized with gail (e.g. yelp)
// try gail_remove_key_event_listener
return gail_remove_key_event_listener(remove_listener);
}
g_hash_table_remove(sKey_listener_list, GUINT_TO_POINTER (remove_listener));
if (g_hash_table_size(sKey_listener_list) == 0) {
gtk_key_snooper_remove(sKey_snooper_id);
}
g_hash_table_remove(sKey_listener_list, GUINT_TO_POINTER(remove_listener));
if (g_hash_table_size(sKey_listener_list) == 0) {
gtk_key_snooper_remove(sKey_snooper_id);
}
}
static AtkObject*
mai_util_get_root()
{
ApplicationAccessible* app = ApplicationAcc();
if (app)
return app->GetAtkObject();
static AtkObject *mai_util_get_root() {
ApplicationAccessible *app = ApplicationAcc();
if (app) return app->GetAtkObject();
// We've shutdown, try to use gail instead
// (to avoid assert in spi_atk_tidy_windows())
// XXX tbsaunde then why didn't we replace the gail atk_util impl?
if (gail_get_root)
return gail_get_root();
if (gail_get_root) return gail_get_root();
return nullptr;
}
static const gchar*
mai_util_get_toolkit_name()
{
return MAI_NAME;
static const gchar *mai_util_get_toolkit_name() { return MAI_NAME; }
static const gchar *mai_util_get_toolkit_version() { return MAI_VERSION; }
static void _listener_info_destroy(gpointer data) { g_free(data); }
static void window_added(AtkObject *atk_obj, guint index, AtkObject *child) {
if (!IS_MAI_OBJECT(child)) return;
static guint id = g_signal_lookup("create", MAI_TYPE_ATK_OBJECT);
g_signal_emit(child, id, 0);
}
static const gchar*
mai_util_get_toolkit_version()
{
return MAI_VERSION;
static void window_removed(AtkObject *atk_obj, guint index, AtkObject *child) {
if (!IS_MAI_OBJECT(child)) return;
static guint id = g_signal_lookup("destroy", MAI_TYPE_ATK_OBJECT);
g_signal_emit(child, id, 0);
}
static void
_listener_info_destroy(gpointer data)
{
g_free(data);
}
static void UtilInterfaceInit(MaiUtilClass *klass) {
AtkUtilClass *atk_class;
gpointer data;
static void
window_added (AtkObject *atk_obj,
guint index,
AtkObject *child)
{
if (!IS_MAI_OBJECT(child))
return;
data = g_type_class_peek(ATK_TYPE_UTIL);
atk_class = ATK_UTIL_CLASS(data);
static guint id = g_signal_lookup ("create", MAI_TYPE_ATK_OBJECT);
g_signal_emit (child, id, 0);
}
// save gail function pointer
gail_add_global_event_listener = atk_class->add_global_event_listener;
gail_remove_global_event_listener = atk_class->remove_global_event_listener;
gail_remove_key_event_listener = atk_class->remove_key_event_listener;
gail_get_root = atk_class->get_root;
static void
window_removed (AtkObject *atk_obj,
guint index,
AtkObject *child)
{
if (!IS_MAI_OBJECT(child))
return;
atk_class->add_global_event_listener = mai_util_add_global_event_listener;
atk_class->remove_global_event_listener =
mai_util_remove_global_event_listener;
atk_class->add_key_event_listener = mai_util_add_key_event_listener;
atk_class->remove_key_event_listener = mai_util_remove_key_event_listener;
atk_class->get_root = mai_util_get_root;
atk_class->get_toolkit_name = mai_util_get_toolkit_name;
atk_class->get_toolkit_version = mai_util_get_toolkit_version;
static guint id = g_signal_lookup ("destroy", MAI_TYPE_ATK_OBJECT);
g_signal_emit (child, id, 0);
}
static void
UtilInterfaceInit(MaiUtilClass* klass)
{
AtkUtilClass *atk_class;
gpointer data;
data = g_type_class_peek(ATK_TYPE_UTIL);
atk_class = ATK_UTIL_CLASS(data);
// save gail function pointer
gail_add_global_event_listener = atk_class->add_global_event_listener;
gail_remove_global_event_listener = atk_class->remove_global_event_listener;
gail_remove_key_event_listener = atk_class->remove_key_event_listener;
gail_get_root = atk_class->get_root;
atk_class->add_global_event_listener =
mai_util_add_global_event_listener;
atk_class->remove_global_event_listener =
mai_util_remove_global_event_listener;
atk_class->add_key_event_listener = mai_util_add_key_event_listener;
atk_class->remove_key_event_listener = mai_util_remove_key_event_listener;
atk_class->get_root = mai_util_get_root;
atk_class->get_toolkit_name = mai_util_get_toolkit_name;
atk_class->get_toolkit_version = mai_util_get_toolkit_version;
sListener_list = g_hash_table_new_full(g_int_hash, g_int_equal, nullptr,
_listener_info_destroy);
// Keep track of added/removed windows.
AtkObject *root = atk_get_root ();
g_signal_connect (root, "children-changed::add", (GCallback) window_added, nullptr);
g_signal_connect (root, "children-changed::remove", (GCallback) window_removed, nullptr);
sListener_list = g_hash_table_new_full(g_int_hash, g_int_equal, nullptr,
_listener_info_destroy);
// Keep track of added/removed windows.
AtkObject *root = atk_get_root();
g_signal_connect(root, "children-changed::add", (GCallback)window_added,
nullptr);
g_signal_connect(root, "children-changed::remove", (GCallback)window_removed,
nullptr);
}
}
GType
mai_util_get_type()
{
static GType type = 0;
GType mai_util_get_type() {
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo = {
sizeof(MaiUtilClass),
(GBaseInitFunc) nullptr, /* base init */
(GBaseFinalizeFunc) nullptr, /* base finalize */
(GClassInitFunc) UtilInterfaceInit, /* class init */
(GClassFinalizeFunc) nullptr, /* class finalize */
nullptr, /* class data */
sizeof(MaiUtil), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) nullptr, /* instance init */
nullptr /* value table */
};
if (!type) {
static const GTypeInfo tinfo = {
sizeof(MaiUtilClass),
(GBaseInitFunc) nullptr, /* base init */
(GBaseFinalizeFunc) nullptr, /* base finalize */
(GClassInitFunc)UtilInterfaceInit, /* class init */
(GClassFinalizeFunc) nullptr, /* class finalize */
nullptr, /* class data */
sizeof(MaiUtil), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) nullptr, /* instance init */
nullptr /* value table */
};
type = g_type_register_static(ATK_TYPE_UTIL,
"MaiUtil", &tinfo, GTypeFlags(0));
}
return type;
type =
g_type_register_static(ATK_TYPE_UTIL, "MaiUtil", &tinfo, GTypeFlags(0));
}
return type;
}

View File

@@ -14,7 +14,7 @@ namespace a11y {
typedef class XULListboxAccessible XULListboxAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -14,7 +14,7 @@ namespace a11y {
typedef class XULMenuitemAccessible XULMenuitemAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -15,8 +15,7 @@ namespace a11y {
typedef class XULTreeGridAccessible XULTreeGridAccessibleWrap;
typedef class XULTreeGridCellAccessible XULTreeGridCellAccessibleWrap;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -18,50 +18,44 @@ namespace mozilla {
namespace a11y {
class ProxyAccessible;
}
}
} // namespace mozilla
#define MAI_TYPE_ATK_OBJECT (mai_atk_object_get_type ())
#define MAI_ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
MAI_TYPE_ATK_OBJECT, MaiAtkObject))
#define MAI_ATK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
MAI_TYPE_ATK_OBJECT, \
MaiAtkObjectClass))
#define IS_MAI_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
MAI_TYPE_ATK_OBJECT))
#define IS_MAI_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
MAI_TYPE_ATK_OBJECT))
#define MAI_ATK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
MAI_TYPE_ATK_OBJECT, \
MaiAtkObjectClass))
#define MAI_TYPE_ATK_OBJECT (mai_atk_object_get_type())
#define MAI_ATK_OBJECT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), MAI_TYPE_ATK_OBJECT, MaiAtkObject))
#define MAI_ATK_OBJECT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), MAI_TYPE_ATK_OBJECT, MaiAtkObjectClass))
#define IS_MAI_OBJECT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), MAI_TYPE_ATK_OBJECT))
#define IS_MAI_OBJECT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), MAI_TYPE_ATK_OBJECT))
#define MAI_ATK_OBJECT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), MAI_TYPE_ATK_OBJECT, MaiAtkObjectClass))
GType mai_atk_object_get_type(void);
GType mai_util_get_type();
extern "C" GType mai_atk_socket_get_type(void);
/* MaiAtkSocket */
#define MAI_TYPE_ATK_SOCKET (mai_atk_socket_get_type ())
#define MAI_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
#define MAI_IS_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
#define MAI_IS_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
#define MAI_TYPE_ATK_SOCKET (mai_atk_socket_get_type())
#define MAI_ATK_SOCKET(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
#define MAI_IS_ATK_SOCKET(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), MAI_TYPE_ATK_SOCKET, MaiAtkSocketClass))
#define MAI_IS_ATK_SOCKET_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), MAI_TYPE_ATK_SOCKET, MaiAtkSocketClass))
typedef struct _MaiAtkSocket
{
typedef struct _MaiAtkSocket {
AtkSocket parent;
mozilla::a11y::AccessibleWrap* accWrap;
} MaiAtkSocket;
typedef struct _MaiAtkSocketClass
{
typedef struct _MaiAtkSocketClass {
AtkSocketClass parent_class;
} MaiAtkSocketClass;
@@ -81,9 +75,7 @@ extern int atkMajorVersion, atkMinorVersion, atkMicroVersion;
* Return true if the loaded version of libatk-1.0.so is at least
* aMajor.aMinor.aMicro.
*/
static inline bool
IsAtkVersionAtLeast(int aMajor, int aMinor, int aMicro=0)
{
static inline bool IsAtkVersionAtLeast(int aMajor, int aMinor, int aMicro = 0) {
return aMajor < atkMajorVersion ||
(aMajor == atkMajorVersion &&
(aMinor < atkMinorVersion ||
@@ -97,8 +89,7 @@ static const uintptr_t IS_PROXY = 1;
/**
* This MaiAtkObject is a thin wrapper, in the MAI namespace, for AtkObject
*/
struct MaiAtkObject
{
struct MaiAtkObject {
AtkObject parent;
/*
* The AccessibleWrap whose properties and features are exported
@@ -133,7 +124,7 @@ struct MaiAtkObject
*/
void FireAtkShowHideEvent(AtkObject* aParent, bool aIsAdded, bool aFromUser);
private:
private:
/*
* do we have text-remove and text-insert signals if not we need to use
* text-changed see AccessibleWrap::FireAtkTextChangedEvent() and

View File

@@ -12,37 +12,37 @@ using namespace mozilla::a11y;
/* MaiAtkHyperlink */
#define MAI_TYPE_ATK_HYPERLINK (mai_atk_hyperlink_get_type ())
#define MAI_ATK_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
MAI_TYPE_ATK_HYPERLINK, MaiAtkHyperlink))
#define MAI_ATK_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
MAI_TYPE_ATK_HYPERLINK, MaiAtkHyperlinkClass))
#define MAI_IS_ATK_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
MAI_TYPE_ATK_HYPERLINK))
#define MAI_IS_ATK_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
MAI_TYPE_ATK_HYPERLINK))
#define MAI_ATK_HYPERLINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
MAI_TYPE_ATK_HYPERLINK, MaiAtkHyperlinkClass))
#define MAI_TYPE_ATK_HYPERLINK (mai_atk_hyperlink_get_type())
#define MAI_ATK_HYPERLINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), MAI_TYPE_ATK_HYPERLINK, MaiAtkHyperlink))
#define MAI_ATK_HYPERLINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), MAI_TYPE_ATK_HYPERLINK, \
MaiAtkHyperlinkClass))
#define MAI_IS_ATK_HYPERLINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), MAI_TYPE_ATK_HYPERLINK))
#define MAI_IS_ATK_HYPERLINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), MAI_TYPE_ATK_HYPERLINK))
#define MAI_ATK_HYPERLINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), MAI_TYPE_ATK_HYPERLINK, \
MaiAtkHyperlinkClass))
/**
* This MaiAtkHyperlink is a thin wrapper, in the MAI namespace,
* for AtkHyperlink
*/
struct MaiAtkHyperlink
{
AtkHyperlink parent;
struct MaiAtkHyperlink {
AtkHyperlink parent;
/*
* The MaiHyperlink whose properties and features are exported via this
* hyperlink instance.
*/
MaiHyperlink *maiHyperlink;
/*
* The MaiHyperlink whose properties and features are exported via this
* hyperlink instance.
*/
MaiHyperlink *maiHyperlink;
};
struct MaiAtkHyperlinkClass
{
AtkHyperlinkClass parent_class;
struct MaiAtkHyperlinkClass {
AtkHyperlinkClass parent_class;
};
GType mai_atk_hyperlink_get_type(void);
@@ -63,112 +63,91 @@ G_END_DECLS
static gpointer parent_class = nullptr;
static MaiHyperlink*
GetMaiHyperlink(AtkHyperlink *aHyperlink)
{
NS_ENSURE_TRUE(MAI_IS_ATK_HYPERLINK(aHyperlink), nullptr);
MaiHyperlink * maiHyperlink =
MAI_ATK_HYPERLINK(aHyperlink)->maiHyperlink;
NS_ENSURE_TRUE(maiHyperlink != nullptr, nullptr);
NS_ENSURE_TRUE(maiHyperlink->GetAtkHyperlink() == aHyperlink, nullptr);
return maiHyperlink;
static MaiHyperlink *GetMaiHyperlink(AtkHyperlink *aHyperlink) {
NS_ENSURE_TRUE(MAI_IS_ATK_HYPERLINK(aHyperlink), nullptr);
MaiHyperlink *maiHyperlink = MAI_ATK_HYPERLINK(aHyperlink)->maiHyperlink;
NS_ENSURE_TRUE(maiHyperlink != nullptr, nullptr);
NS_ENSURE_TRUE(maiHyperlink->GetAtkHyperlink() == aHyperlink, nullptr);
return maiHyperlink;
}
GType
mai_atk_hyperlink_get_type(void)
{
static GType type = 0;
GType mai_atk_hyperlink_get_type(void) {
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo = {
sizeof(MaiAtkHyperlinkClass),
(GBaseInitFunc)nullptr,
(GBaseFinalizeFunc)nullptr,
(GClassInitFunc)classInitCB,
(GClassFinalizeFunc)nullptr,
nullptr, /* class data */
sizeof(MaiAtkHyperlink), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc)nullptr,
nullptr /* value table */
};
if (!type) {
static const GTypeInfo tinfo = {
sizeof(MaiAtkHyperlinkClass),
(GBaseInitFunc) nullptr,
(GBaseFinalizeFunc) nullptr,
(GClassInitFunc)classInitCB,
(GClassFinalizeFunc) nullptr,
nullptr, /* class data */
sizeof(MaiAtkHyperlink), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) nullptr,
nullptr /* value table */
};
type = g_type_register_static(ATK_TYPE_HYPERLINK,
"MaiAtkHyperlink",
&tinfo, GTypeFlags(0));
}
return type;
type = g_type_register_static(ATK_TYPE_HYPERLINK, "MaiAtkHyperlink", &tinfo,
GTypeFlags(0));
}
return type;
}
MaiHyperlink::MaiHyperlink(AccessibleOrProxy aHyperLink) :
mHyperlink(aHyperLink),
mMaiAtkHyperlink(nullptr)
{
mMaiAtkHyperlink =
reinterpret_cast<AtkHyperlink *>
(g_object_new(mai_atk_hyperlink_get_type(), nullptr));
NS_ASSERTION(mMaiAtkHyperlink, "OUT OF MEMORY");
if (!mMaiAtkHyperlink)
return;
MaiHyperlink::MaiHyperlink(AccessibleOrProxy aHyperLink)
: mHyperlink(aHyperLink), mMaiAtkHyperlink(nullptr) {
mMaiAtkHyperlink = reinterpret_cast<AtkHyperlink *>(
g_object_new(mai_atk_hyperlink_get_type(), nullptr));
NS_ASSERTION(mMaiAtkHyperlink, "OUT OF MEMORY");
if (!mMaiAtkHyperlink) return;
MAI_ATK_HYPERLINK(mMaiAtkHyperlink)->maiHyperlink = this;
MAI_ATK_HYPERLINK(mMaiAtkHyperlink)->maiHyperlink = this;
}
MaiHyperlink::~MaiHyperlink()
{
MaiHyperlink::~MaiHyperlink() {
if (mMaiAtkHyperlink) {
MAI_ATK_HYPERLINK(mMaiAtkHyperlink)->maiHyperlink = nullptr;
g_object_unref(mMaiAtkHyperlink);
}
}
/* static functions for ATK callbacks */
void
classInitCB(AtkHyperlinkClass *aClass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(aClass);
void classInitCB(AtkHyperlinkClass *aClass) {
GObjectClass *gobject_class = G_OBJECT_CLASS(aClass);
parent_class = g_type_class_peek_parent(aClass);
parent_class = g_type_class_peek_parent(aClass);
aClass->get_uri = getUriCB;
aClass->get_object = getObjectCB;
aClass->get_end_index = getEndIndexCB;
aClass->get_start_index = getStartIndexCB;
aClass->is_valid = isValidCB;
aClass->get_n_anchors = getAnchorCountCB;
aClass->get_uri = getUriCB;
aClass->get_object = getObjectCB;
aClass->get_end_index = getEndIndexCB;
aClass->get_start_index = getStartIndexCB;
aClass->is_valid = isValidCB;
aClass->get_n_anchors = getAnchorCountCB;
gobject_class->finalize = finalizeCB;
gobject_class->finalize = finalizeCB;
}
void
finalizeCB(GObject *aObj)
{
NS_ASSERTION(MAI_IS_ATK_HYPERLINK(aObj), "Invalid MaiAtkHyperlink");
if (!MAI_IS_ATK_HYPERLINK(aObj))
return;
void finalizeCB(GObject *aObj) {
NS_ASSERTION(MAI_IS_ATK_HYPERLINK(aObj), "Invalid MaiAtkHyperlink");
if (!MAI_IS_ATK_HYPERLINK(aObj)) return;
MaiAtkHyperlink *maiAtkHyperlink = MAI_ATK_HYPERLINK(aObj);
maiAtkHyperlink->maiHyperlink = nullptr;
MaiAtkHyperlink *maiAtkHyperlink = MAI_ATK_HYPERLINK(aObj);
maiAtkHyperlink->maiHyperlink = nullptr;
/* call parent finalize function */
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize(aObj);
/* call parent finalize function */
if (G_OBJECT_CLASS(parent_class)->finalize)
G_OBJECT_CLASS(parent_class)->finalize(aObj);
}
gchar *
getUriCB(AtkHyperlink *aLink, gint aLinkIndex)
{
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
if (!maiLink)
return nullptr;
gchar *getUriCB(AtkHyperlink *aLink, gint aLinkIndex) {
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
if (!maiLink) return nullptr;
nsAutoCString cautoStr;
if (Accessible* hyperlink = maiLink->GetAccHyperlink()) {
if (Accessible *hyperlink = maiLink->GetAccHyperlink()) {
nsCOMPtr<nsIURI> uri = hyperlink->AnchorURIAt(aLinkIndex);
if (!uri)
return nullptr;
if (!uri) return nullptr;
nsresult rv = uri->GetSpec(cautoStr);
NS_ENSURE_SUCCESS(rv, nullptr);
@@ -178,39 +157,33 @@ getUriCB(AtkHyperlink *aLink, gint aLinkIndex)
bool valid;
maiLink->Proxy()->AnchorURIAt(aLinkIndex, cautoStr, &valid);
if (!valid)
return nullptr;
if (!valid) return nullptr;
return g_strdup(cautoStr.get());
}
AtkObject *
getObjectCB(AtkHyperlink *aLink, gint aLinkIndex)
{
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
AtkObject *getObjectCB(AtkHyperlink *aLink, gint aLinkIndex) {
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
if (!maiLink) {
return nullptr;
}
if (Accessible* hyperlink = maiLink->GetAccHyperlink()) {
Accessible* anchor = hyperlink->AnchorAt(aLinkIndex);
if (Accessible *hyperlink = maiLink->GetAccHyperlink()) {
Accessible *anchor = hyperlink->AnchorAt(aLinkIndex);
NS_ENSURE_TRUE(anchor, nullptr);
return AccessibleWrap::GetAtkObject(anchor);
}
ProxyAccessible* anchor = maiLink->Proxy()->AnchorAt(aLinkIndex);
ProxyAccessible *anchor = maiLink->Proxy()->AnchorAt(aLinkIndex);
return anchor ? GetWrapperFor(anchor) : nullptr;
}
gint
getEndIndexCB(AtkHyperlink *aLink)
{
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
if (!maiLink)
return false;
gint getEndIndexCB(AtkHyperlink *aLink) {
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
if (!maiLink) return false;
if (Accessible* hyperlink = maiLink->GetAccHyperlink())
if (Accessible *hyperlink = maiLink->GetAccHyperlink())
return static_cast<gint>(hyperlink->EndOffset());
bool valid = false;
@@ -218,14 +191,11 @@ getEndIndexCB(AtkHyperlink *aLink)
return valid ? static_cast<gint>(endIdx) : -1;
}
gint
getStartIndexCB(AtkHyperlink *aLink)
{
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
if (!maiLink)
return -1;
gint getStartIndexCB(AtkHyperlink *aLink) {
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
if (!maiLink) return -1;
if (Accessible* hyperlink = maiLink->GetAccHyperlink())
if (Accessible *hyperlink = maiLink->GetAccHyperlink())
return static_cast<gint>(hyperlink->StartOffset());
bool valid = false;
@@ -233,27 +203,21 @@ getStartIndexCB(AtkHyperlink *aLink)
return valid ? static_cast<gint>(startIdx) : -1;
}
gboolean
isValidCB(AtkHyperlink *aLink)
{
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
if (!maiLink)
return false;
gboolean isValidCB(AtkHyperlink *aLink) {
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
if (!maiLink) return false;
if (Accessible* hyperlink = maiLink->GetAccHyperlink())
if (Accessible *hyperlink = maiLink->GetAccHyperlink())
return static_cast<gboolean>(hyperlink->IsLinkValid());
return static_cast<gboolean>(maiLink->Proxy()->IsLinkValid());
}
gint
getAnchorCountCB(AtkHyperlink *aLink)
{
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
if (!maiLink)
return -1;
gint getAnchorCountCB(AtkHyperlink *aLink) {
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
if (!maiLink) return -1;
if (Accessible* hyperlink = maiLink->GetAccHyperlink())
if (Accessible *hyperlink = maiLink->GetAccHyperlink())
return static_cast<gint>(hyperlink->AnchorCount());
bool valid = false;

View File

@@ -11,7 +11,7 @@
#include "Accessible.h"
struct _AtkHyperlink;
typedef struct _AtkHyperlink AtkHyperlink;
typedef struct _AtkHyperlink AtkHyperlink;
namespace mozilla {
namespace a11y {
@@ -20,36 +20,33 @@ namespace a11y {
* MaiHyperlink is a auxiliary class for MaiInterfaceHyperText.
*/
class MaiHyperlink
{
public:
class MaiHyperlink {
public:
explicit MaiHyperlink(AccessibleOrProxy aHyperLink);
~MaiHyperlink();
public:
public:
AtkHyperlink* GetAtkHyperlink() const { return mMaiAtkHyperlink; }
Accessible* GetAccHyperlink()
{
if (!mHyperlink.IsAccessible())
return nullptr;
Accessible* GetAccHyperlink() {
if (!mHyperlink.IsAccessible()) return nullptr;
Accessible* link = mHyperlink.AsAccessible();
if (!link) {
return nullptr;
}
NS_ASSERTION(link->IsLink(), "Why isn't it a link!");
return link;
Accessible* link = mHyperlink.AsAccessible();
if (!link) {
return nullptr;
}
NS_ASSERTION(link->IsLink(), "Why isn't it a link!");
return link;
}
ProxyAccessible* Proxy() const { return mHyperlink.AsProxy(); }
protected:
protected:
AccessibleOrProxy mHyperlink;
AtkHyperlink* mMaiAtkHyperlink;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif /* __MAI_HYPERLINK_H__ */

View File

@@ -17,9 +17,7 @@ using namespace mozilla::a11y;
extern "C" {
static gboolean
doActionCB(AtkAction *aAction, gint aActionIndex)
{
static gboolean doActionCB(AtkAction* aAction, gint aActionIndex) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
if (accWrap) {
return accWrap->DoAction(aActionIndex);
@@ -29,9 +27,7 @@ doActionCB(AtkAction *aAction, gint aActionIndex)
return proxy && proxy->DoAction(aActionIndex);
}
static gint
getActionCountCB(AtkAction *aAction)
{
static gint getActionCountCB(AtkAction* aAction) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
if (accWrap) {
return accWrap->ActionCount();
@@ -41,9 +37,8 @@ getActionCountCB(AtkAction *aAction)
return proxy ? proxy->ActionCount() : 0;
}
static const gchar*
getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
{
static const gchar* getActionDescriptionCB(AtkAction* aAction,
gint aActionIndex) {
nsAutoString description;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
if (accWrap) {
@@ -57,9 +52,7 @@ getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
return AccessibleWrap::ReturnString(description);
}
static const gchar*
getActionNameCB(AtkAction *aAction, gint aActionIndex)
{
static const gchar* getActionNameCB(AtkAction* aAction, gint aActionIndex) {
nsAutoString autoStr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
if (accWrap) {
@@ -73,9 +66,7 @@ getActionNameCB(AtkAction *aAction, gint aActionIndex)
return AccessibleWrap::ReturnString(autoStr);
}
static const gchar*
getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
{
static const gchar* getKeyBindingCB(AtkAction* aAction, gint aActionIndex) {
nsAutoString keyBindingsStr;
AccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction));
if (acc) {
@@ -90,12 +81,9 @@ getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
}
}
void
actionInterfaceInitCB(AtkActionIface* aIface)
{
void actionInterfaceInitCB(AtkActionIface* aIface) {
NS_ASSERTION(aIface, "Invalid aIface");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->do_action = doActionCB;
aIface->get_n_actions = getActionCountCB;

View File

@@ -18,25 +18,18 @@ using namespace mozilla::a11y;
extern "C" {
static AtkObject*
refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX, gint aAccY,
AtkCoordType aCoordType)
{
return refAccessibleAtPointHelper(ATK_OBJECT(aComponent),
aAccX, aAccY, aCoordType);
static AtkObject* refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX,
gint aAccY, AtkCoordType aCoordType) {
return refAccessibleAtPointHelper(ATK_OBJECT(aComponent), aAccX, aAccY,
aCoordType);
}
static void
getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
gint* aWidth, gint* aHeight, AtkCoordType aCoordType)
{
getExtentsHelper(ATK_OBJECT(aComponent),
aX, aY, aWidth, aHeight, aCoordType);
static void getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
gint* aWidth, gint* aHeight, AtkCoordType aCoordType) {
getExtentsHelper(ATK_OBJECT(aComponent), aX, aY, aWidth, aHeight, aCoordType);
}
static gboolean
grabFocusCB(AtkComponent* aComponent)
{
static gboolean grabFocusCB(AtkComponent* aComponent) {
AtkObject* atkObject = ATK_OBJECT(aComponent);
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
if (accWrap) {
@@ -54,9 +47,7 @@ grabFocusCB(AtkComponent* aComponent)
}
// ScrollType is compatible
static gboolean
scrollToCB(AtkComponent* aComponent, AtkScrollType type)
{
static gboolean scrollToCB(AtkComponent* aComponent, AtkScrollType type) {
AtkObject* atkObject = ATK_OBJECT(aComponent);
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
if (accWrap) {
@@ -74,9 +65,8 @@ scrollToCB(AtkComponent* aComponent, AtkScrollType type)
}
// CoordType is compatible
static gboolean
scrollToPointCB(AtkComponent* aComponent, AtkCoordType coords, gint x, gint y)
{
static gboolean scrollToPointCB(AtkComponent* aComponent, AtkCoordType coords,
gint x, gint y) {
AtkObject* atkObject = ATK_OBJECT(aComponent);
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
if (accWrap) {
@@ -94,10 +84,8 @@ scrollToPointCB(AtkComponent* aComponent, AtkCoordType coords, gint x, gint y)
}
}
AtkObject*
refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
AtkCoordType aCoordType)
{
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
AtkCoordType aCoordType) {
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (accWrap) {
if (accWrap->IsDefunct() || nsAccUtils::MustPrune(accWrap)) {
@@ -107,13 +95,13 @@ refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
// Accessible::ChildAtPoint(x,y) is in screen pixels.
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
aX += winCoords.x;
aY += winCoords.y;
}
Accessible* accAtPoint = accWrap->ChildAtPoint(aX, aY,
Accessible::eDirectChild);
Accessible* accAtPoint =
accWrap->ChildAtPoint(aX, aY, Accessible::eDirectChild);
if (!accAtPoint) {
return nullptr;
}
@@ -128,7 +116,7 @@ refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
ProxyAccessible* result =
proxy->AccessibleAtPoint(aX, aY, aCoordType == ATK_XY_WINDOW);
proxy->AccessibleAtPoint(aX, aY, aCoordType == ATK_XY_WINDOW);
AtkObject* atkObj = result ? GetWrapperFor(result) : nullptr;
if (atkObj) {
g_object_ref(atkObj);
@@ -139,11 +127,8 @@ refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
return nullptr;
}
void
getExtentsHelper(AtkObject* aAtkObj,
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
AtkCoordType aCoordType)
{
void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
gint* aHeight, AtkCoordType aCoordType) {
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
*aX = *aY = *aWidth = *aHeight = 0;
@@ -153,12 +138,11 @@ getExtentsHelper(AtkObject* aAtkObj,
}
nsIntRect screenRect = accWrap->Bounds();
if (screenRect.IsEmpty())
return;
if (screenRect.IsEmpty()) return;
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
screenRect.x -= winCoords.x;
screenRect.y -= winCoords.y;
}
@@ -175,12 +159,9 @@ getExtentsHelper(AtkObject* aAtkObj,
}
}
void
componentInterfaceInitCB(AtkComponentIface* aIface)
{
void componentInterfaceInitCB(AtkComponentIface* aIface) {
NS_ASSERTION(aIface, "Invalid Interface");
if(MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
/*
* Use default implementation in atk for contains, get_position,

View File

@@ -27,26 +27,21 @@ 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;
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;
/*
* 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)
{
const gchar* getDocumentLocaleCB(AtkDocument* aDocument) {
nsAutoString locale;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
if (accWrap) {
@@ -58,23 +53,20 @@ getDocumentLocaleCB(AtkDocument *aDocument)
return locale.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(locale);
}
static inline GSList *
prependToList(GSList *aList, const char *const aName, const nsAutoString &aValue)
{
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));
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)
{
AtkAttributeSet* getDocumentAttributesCB(AtkDocument* aDocument) {
nsAutoString url;
nsAutoString w3cDocType;
nsAutoString mimeType;
@@ -103,10 +95,8 @@ getDocumentAttributesCB(AtkDocument *aDocument)
return attributes;
}
const gchar *
getDocumentAttributeValueCB(AtkDocument *aDocument,
const gchar *aAttrName)
{
const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
const gchar* aAttrName) {
ProxyAccessible* proxy = nullptr;
DocAccessible* document = nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
@@ -146,6 +136,7 @@ getDocumentAttributeValueCB(AtkDocument *aDocument,
return nullptr;
}
return attrValue.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(attrValue);
return attrValue.IsEmpty() ? nullptr
: AccessibleWrap::ReturnString(attrValue);
}
}

View File

@@ -16,9 +16,7 @@
using namespace mozilla::a11y;
extern "C" {
static void
setTextContentsCB(AtkEditableText *aText, const gchar *aString)
{
static void setTextContentsCB(AtkEditableText* aText, const gchar* aString) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -34,10 +32,8 @@ setTextContentsCB(AtkEditableText *aText, const gchar *aString)
}
}
static void
insertTextCB(AtkEditableText *aText,
const gchar *aString, gint aLength, gint *aPosition)
{
static void insertTextCB(AtkEditableText* aText, const gchar* aString,
gint aLength, gint* aPosition) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -53,9 +49,7 @@ insertTextCB(AtkEditableText *aText,
}
}
static void
copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
{
static void copyTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -69,9 +63,7 @@ copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
}
}
static void
cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
{
static void cutTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -85,9 +77,7 @@ cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
}
}
static void
deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
{
static void deleteTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -101,9 +91,7 @@ deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
}
}
static void
pasteTextCB(AtkEditableText *aText, gint aPosition)
{
static void pasteTextCB(AtkEditableText* aText, gint aPosition) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -118,12 +106,9 @@ pasteTextCB(AtkEditableText *aText, gint aPosition)
}
}
void
editableTextInterfaceInitCB(AtkEditableTextIface* aIface)
{
void editableTextInterfaceInitCB(AtkEditableTextIface* aIface) {
NS_ASSERTION(aIface, "Invalid aIface");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->set_text_contents = setTextContentsCB;
aIface->insert_text = insertTextCB;

View File

@@ -12,26 +12,19 @@
using namespace mozilla::a11y;
extern "C" {
static AtkHyperlink*
getHyperlinkCB(AtkHyperlinkImpl* aImpl)
{
static AtkHyperlink* getHyperlinkCB(AtkHyperlinkImpl* aImpl) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImpl));
if (!accWrap && !GetProxy(ATK_OBJECT(aImpl)))
return nullptr;
if (!accWrap && !GetProxy(ATK_OBJECT(aImpl))) return nullptr;
if (accWrap)
NS_ASSERTION(accWrap->IsLink(), "why isn't it a link!");
if (accWrap) NS_ASSERTION(accWrap->IsLink(), "why isn't it a link!");
return MAI_ATK_OBJECT(aImpl)->GetAtkHyperlink();
}
}
void
hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface)
{
void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface* aIface) {
NS_ASSERTION(aIface, "no interface!");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->get_hyperlink = getHyperlinkCB;
}

View File

@@ -13,14 +13,11 @@
#include "ProxyAccessible.h"
#include "mozilla/Likely.h"
using namespace mozilla::a11y;
extern "C" {
static AtkHyperlink*
getLinkCB(AtkHypertext *aText, gint aLinkIndex)
{
static AtkHyperlink* getLinkCB(AtkHypertext* aText, gint aLinkIndex) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
AtkObject* atkHyperLink = nullptr;
if (accWrap) {
@@ -35,19 +32,16 @@ getLinkCB(AtkHypertext *aText, gint aLinkIndex)
atkHyperLink = AccessibleWrap::GetAtkObject(hyperLink);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
ProxyAccessible* proxyLink = proxy->LinkAt(aLinkIndex);
if (!proxyLink)
return nullptr;
if (!proxyLink) return nullptr;
atkHyperLink = GetWrapperFor(proxyLink);
}
NS_ENSURE_TRUE(IS_MAI_OBJECT(atkHyperLink), nullptr);
return MAI_ATK_OBJECT(atkHyperLink)->GetAtkHyperlink();
NS_ENSURE_TRUE(IS_MAI_OBJECT(atkHyperLink), nullptr);
return MAI_ATK_OBJECT(atkHyperLink)->GetAtkHyperlink();
}
static gint
getLinkCountCB(AtkHypertext *aText)
{
static gint getLinkCountCB(AtkHypertext* aText) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* hyperText = accWrap->AsHyperText();
@@ -62,9 +56,7 @@ getLinkCountCB(AtkHypertext *aText)
return -1;
}
static gint
getLinkIndexCB(AtkHypertext *aText, gint aCharIndex)
{
static gint getLinkIndexCB(AtkHypertext* aText, gint aCharIndex) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* hyperText = accWrap->AsHyperText();
@@ -81,12 +73,9 @@ getLinkIndexCB(AtkHypertext *aText, gint aCharIndex)
}
}
void
hypertextInterfaceInitCB(AtkHypertextIface* aIface)
{
void hypertextInterfaceInitCB(AtkHypertextIface* aIface) {
NS_ASSERTION(aIface, "no interface!");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->get_link = getLinkCB;
aIface->get_n_links = getLinkCountCB;

View File

@@ -20,14 +20,13 @@ using namespace mozilla::a11y;
extern "C" {
const gchar* getDescriptionCB(AtkObject* aAtkObj);
static void
getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
AtkCoordType aCoordType)
{
static void getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
AtkCoordType aCoordType) {
nsIntPoint pos;
uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
uint32_t geckoCoordType =
(aCoordType == ATK_XY_WINDOW)
? nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE
: nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (accWrap && accWrap->IsImage()) {
@@ -41,15 +40,12 @@ getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
*aAccY = pos.y;
}
static const gchar*
getImageDescriptionCB(AtkImage* aImage)
{
static const gchar* getImageDescriptionCB(AtkImage* aImage) {
return getDescriptionCB(ATK_OBJECT(aImage));
}
static void
getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
{
static void getImageSizeCB(AtkImage* aImage, gint* aAccWidth,
gint* aAccHeight) {
nsIntSize size;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (accWrap && accWrap->IsImage()) {
@@ -62,14 +58,11 @@ getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
*aAccHeight = size.height;
}
} // extern "C"
} // extern "C"
void
imageInterfaceInitCB(AtkImageIface* aIface)
{
void imageInterfaceInitCB(AtkImageIface* aIface) {
NS_ASSERTION(aIface, "no interface!");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->get_image_position = getImagePositionCB;
aIface->get_image_description = getImageDescriptionCB;

View File

@@ -18,9 +18,7 @@ using namespace mozilla::a11y;
extern "C" {
static gboolean
addSelectionCB(AtkSelection *aSelection, gint i)
{
static gboolean addSelectionCB(AtkSelection* aSelection, gint i) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (accWrap && accWrap->IsSelect()) {
return accWrap->AddItemToSelection(i);
@@ -33,9 +31,7 @@ addSelectionCB(AtkSelection *aSelection, gint i)
return FALSE;
}
static gboolean
clearSelectionCB(AtkSelection *aSelection)
{
static gboolean clearSelectionCB(AtkSelection* aSelection) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (accWrap && accWrap->IsSelect()) {
return accWrap->UnselectAll();
@@ -48,9 +44,7 @@ clearSelectionCB(AtkSelection *aSelection)
return FALSE;
}
static AtkObject*
refSelectionCB(AtkSelection *aSelection, gint i)
{
static AtkObject* refSelectionCB(AtkSelection* aSelection, gint i) {
AtkObject* atkObj = nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (accWrap && accWrap->IsSelect()) {
@@ -74,9 +68,7 @@ refSelectionCB(AtkSelection *aSelection, gint i)
return atkObj;
}
static gint
getSelectionCountCB(AtkSelection *aSelection)
{
static gint getSelectionCountCB(AtkSelection* aSelection) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (accWrap && accWrap->IsSelect()) {
return accWrap->SelectedItemCount();
@@ -89,9 +81,7 @@ getSelectionCountCB(AtkSelection *aSelection)
return -1;
}
static gboolean
isChildSelectedCB(AtkSelection *aSelection, gint i)
{
static gboolean isChildSelectedCB(AtkSelection* aSelection, gint i) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (accWrap && accWrap->IsSelect()) {
return accWrap->IsItemSelected(i);
@@ -104,9 +94,7 @@ isChildSelectedCB(AtkSelection *aSelection, gint i)
return FALSE;
}
static gboolean
removeSelectionCB(AtkSelection *aSelection, gint i)
{
static gboolean removeSelectionCB(AtkSelection* aSelection, gint i) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (accWrap && accWrap->IsSelect()) {
return accWrap->RemoveItemFromSelection(i);
@@ -119,9 +107,7 @@ removeSelectionCB(AtkSelection *aSelection, gint i)
return FALSE;
}
static gboolean
selectAllSelectionCB(AtkSelection *aSelection)
{
static gboolean selectAllSelectionCB(AtkSelection* aSelection) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
if (accWrap && accWrap->IsSelect()) {
return accWrap->SelectAll();
@@ -135,12 +121,9 @@ selectAllSelectionCB(AtkSelection *aSelection)
}
}
void
selectionInterfaceInitCB(AtkSelectionIface* aIface)
{
void selectionInterfaceInitCB(AtkSelectionIface* aIface) {
NS_ASSERTION(aIface, "Invalid aIface");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->add_selection = addSelectionCB;
aIface->clear_selection = clearSelectionCB;

View File

@@ -20,9 +20,7 @@
using namespace mozilla::a11y;
extern "C" {
static AtkObject*
refAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx)
{
static AtkObject* refAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
if (aRowIdx < 0 || aColIdx < 0) {
return nullptr;
}
@@ -52,9 +50,7 @@ refAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx)
return cellAtkObj;
}
static gint
getIndexAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx)
{
static gint getIndexAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
if (aRowIdx < 0 || aColIdx < 0) {
return -1;
}
@@ -71,9 +67,7 @@ getIndexAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx)
return -1;
}
static gint
getColumnAtIndexCB(AtkTable *aTable, gint aIdx)
{
static gint getColumnAtIndexCB(AtkTable* aTable, gint aIdx) {
if (aIdx < 0) {
return -1;
}
@@ -90,9 +84,7 @@ getColumnAtIndexCB(AtkTable *aTable, gint aIdx)
return -1;
}
static gint
getRowAtIndexCB(AtkTable *aTable, gint aIdx)
{
static gint getRowAtIndexCB(AtkTable* aTable, gint aIdx) {
if (aIdx < 0) {
return -1;
}
@@ -109,9 +101,7 @@ getRowAtIndexCB(AtkTable *aTable, gint aIdx)
return -1;
}
static gint
getColumnCountCB(AtkTable *aTable)
{
static gint getColumnCountCB(AtkTable* aTable) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
return static_cast<gint>(accWrap->AsTable()->ColCount());
@@ -124,9 +114,7 @@ getColumnCountCB(AtkTable *aTable)
return -1;
}
static gint
getRowCountCB(AtkTable *aTable)
{
static gint getRowCountCB(AtkTable* aTable) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
return static_cast<gint>(accWrap->AsTable()->RowCount());
@@ -139,9 +127,7 @@ getRowCountCB(AtkTable *aTable)
return -1;
}
static gint
getColumnExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
{
static gint getColumnExtentAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
if (aRowIdx < 0 || aColIdx < 0) {
return -1;
}
@@ -158,9 +144,7 @@ getColumnExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
return -1;
}
static gint
getRowExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
{
static gint getRowExtentAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
return static_cast<gint>(accWrap->AsTable()->RowExtentAt(aRowIdx, aColIdx));
@@ -173,9 +157,7 @@ getRowExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
return -1;
}
static AtkObject*
getCaptionCB(AtkTable* aTable)
{
static AtkObject* getCaptionCB(AtkTable* aTable) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
Accessible* caption = accWrap->AsTable()->Caption();
@@ -190,9 +172,7 @@ getCaptionCB(AtkTable* aTable)
return nullptr;
}
static const gchar*
getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
{
static const gchar* getColumnDescriptionCB(AtkTable* aTable, gint aColumn) {
nsAutoString autoStr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
@@ -206,13 +186,11 @@ getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
return AccessibleWrap::ReturnString(autoStr);
}
static AtkObject*
getColumnHeaderCB(AtkTable *aTable, gint aColIdx)
{
static AtkObject* getColumnHeaderCB(AtkTable* aTable, gint aColIdx) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
Accessible* header =
AccessibleWrap::GetColumnHeader(accWrap->AsTable(), aColIdx);
AccessibleWrap::GetColumnHeader(accWrap->AsTable(), aColIdx);
return header ? AccessibleWrap::GetAtkObject(header) : nullptr;
}
@@ -224,9 +202,7 @@ getColumnHeaderCB(AtkTable *aTable, gint aColIdx)
return nullptr;
}
static const gchar*
getRowDescriptionCB(AtkTable *aTable, gint aRow)
{
static const gchar* getRowDescriptionCB(AtkTable* aTable, gint aRow) {
nsAutoString autoStr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
@@ -240,13 +216,11 @@ getRowDescriptionCB(AtkTable *aTable, gint aRow)
return AccessibleWrap::ReturnString(autoStr);
}
static AtkObject*
getRowHeaderCB(AtkTable *aTable, gint aRowIdx)
{
static AtkObject* getRowHeaderCB(AtkTable* aTable, gint aRowIdx) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
Accessible* header =
AccessibleWrap::GetRowHeader(accWrap->AsTable(), aRowIdx);
AccessibleWrap::GetRowHeader(accWrap->AsTable(), aRowIdx);
return header ? AccessibleWrap::GetAtkObject(header) : nullptr;
}
@@ -258,9 +232,7 @@ getRowHeaderCB(AtkTable *aTable, gint aRowIdx)
return nullptr;
}
static AtkObject*
getSummaryCB(AtkTable *aTable)
{
static AtkObject* getSummaryCB(AtkTable* aTable) {
// Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
// link an accessible object to specify a summary. There is closes method
// in TableAccessible::summary to get a summary as a string which is not
@@ -268,23 +240,20 @@ getSummaryCB(AtkTable *aTable)
return nullptr;
}
static gint
getSelectedColumnsCB(AtkTable *aTable, gint** aSelected)
{
static gint getSelectedColumnsCB(AtkTable* aTable, gint** aSelected) {
*aSelected = nullptr;
AutoTArray<uint32_t, 10> cols;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
accWrap->AsTable()->SelectedColIndices(&cols);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) {
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) {
proxy->TableSelectedColumnIndices(&cols);
} else {
return 0;
}
if (cols.IsEmpty())
return 0;
if (cols.IsEmpty()) return 0;
gint* atkColumns = g_new(gint, cols.Length());
if (!atkColumns) {
@@ -297,9 +266,7 @@ getSelectedColumnsCB(AtkTable *aTable, gint** aSelected)
return cols.Length();
}
static gint
getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
{
static gint getSelectedRowsCB(AtkTable* aTable, gint** aSelected) {
AutoTArray<uint32_t, 10> rows;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
@@ -321,9 +288,7 @@ getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
return rows.Length();
}
static gboolean
isColumnSelectedCB(AtkTable *aTable, gint aColIdx)
{
static gboolean isColumnSelectedCB(AtkTable* aTable, gint aColIdx) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
return static_cast<gboolean>(accWrap->AsTable()->IsColSelected(aColIdx));
@@ -335,9 +300,7 @@ isColumnSelectedCB(AtkTable *aTable, gint aColIdx)
return FALSE;
}
static gboolean
isRowSelectedCB(AtkTable *aTable, gint aRowIdx)
{
static gboolean isRowSelectedCB(AtkTable* aTable, gint aRowIdx) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
return static_cast<gboolean>(accWrap->AsTable()->IsRowSelected(aRowIdx));
@@ -349,13 +312,11 @@ isRowSelectedCB(AtkTable *aTable, gint aRowIdx)
return FALSE;
}
static gboolean
isCellSelectedCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
{
static gboolean isCellSelectedCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
if (accWrap) {
return static_cast<gboolean>(accWrap->AsTable()->
IsCellSelected(aRowIdx, aColIdx));
return static_cast<gboolean>(
accWrap->AsTable()->IsCellSelected(aRowIdx, aColIdx));
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) {
return static_cast<gboolean>(proxy->TableCellSelected(aRowIdx, aColIdx));
@@ -365,12 +326,9 @@ isCellSelectedCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
}
}
void
tableInterfaceInitCB(AtkTableIface* aIface)
{
void tableInterfaceInitCB(AtkTableIface* aIface) {
NS_ASSERTION(aIface, "no interface!");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->ref_at = refAtCB;
aIface->get_index_at = getIndexAtCB;

View File

@@ -20,9 +20,7 @@
using namespace mozilla::a11y;
extern "C" {
static gint
GetColumnSpanCB(AtkTableCell* aCell)
{
static gint GetColumnSpanCB(AtkTableCell* aCell) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
if (accWrap) {
return accWrap->AsTableCell()->ColExtent();
@@ -35,9 +33,7 @@ GetColumnSpanCB(AtkTableCell* aCell)
return 0;
}
static gboolean
GetRowSpanCB(AtkTableCell* aCell)
{
static gboolean GetRowSpanCB(AtkTableCell* aCell) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
if (accWrap) {
return accWrap->AsTableCell()->RowExtent();
@@ -50,9 +46,7 @@ GetRowSpanCB(AtkTableCell* aCell)
return 0;
}
static gboolean
GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol)
{
static gboolean GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol) {
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
TableCellAccessible* cell = accWrap->AsTableCell();
if (!cell) {
@@ -74,9 +68,8 @@ GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol)
return false;
}
static gboolean
GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
gint* aColExtent, gint* aRowExtent) {
static gboolean GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
gint* aColExtent, gint* aRowExtent) {
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
TableCellAccessible* cellAcc = accWrap->AsTableCell();
if (!cellAcc) {
@@ -96,15 +89,13 @@ GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
*aRow = rowIdx;
*aColExtent = colExtent;
*aRowExtent = rowExtent;
return true;
return true;
}
return false;
}
static AtkObject*
GetTableCB(AtkTableCell* aTableCell)
{
static AtkObject* GetTableCB(AtkTableCell* aTableCell) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTableCell));
if (accWrap) {
TableAccessible* table = accWrap->AsTableCell()->Table();
@@ -124,9 +115,7 @@ GetTableCB(AtkTableCell* aTableCell)
return nullptr;
}
static GPtrArray*
GetColumnHeaderCellsCB(AtkTableCell* aCell)
{
static GPtrArray* GetColumnHeaderCellsCB(AtkTableCell* aCell) {
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
AutoTArray<Accessible*, 10> headers;
accWrap->AsTableCell()->ColHeaderCells(&headers);
@@ -135,7 +124,7 @@ GetColumnHeaderCellsCB(AtkTableCell* aCell)
}
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
for (Accessible* header: headers) {
for (Accessible* header : headers) {
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
g_object_ref(atkHeader);
g_ptr_array_add(atkHeaders, atkHeader);
@@ -152,7 +141,7 @@ GetColumnHeaderCellsCB(AtkTableCell* aCell)
}
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
for (ProxyAccessible* header: headers) {
for (ProxyAccessible* header : headers) {
AtkObject* atkHeader = GetWrapperFor(header);
g_object_ref(atkHeader);
g_ptr_array_add(atkHeaders, atkHeader);
@@ -164,9 +153,7 @@ GetColumnHeaderCellsCB(AtkTableCell* aCell)
return nullptr;
}
static GPtrArray*
GetRowHeaderCellsCB(AtkTableCell* aCell)
{
static GPtrArray* GetRowHeaderCellsCB(AtkTableCell* aCell) {
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
AutoTArray<Accessible*, 10> headers;
accWrap->AsTableCell()->RowHeaderCells(&headers);
@@ -175,7 +162,7 @@ GetRowHeaderCellsCB(AtkTableCell* aCell)
}
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
for (Accessible* header: headers) {
for (Accessible* header : headers) {
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
g_object_ref(atkHeader);
g_ptr_array_add(atkHeaders, atkHeader);
@@ -192,7 +179,7 @@ GetRowHeaderCellsCB(AtkTableCell* aCell)
}
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
for (ProxyAccessible* header: headers) {
for (ProxyAccessible* header : headers) {
AtkObject* atkHeader = GetWrapperFor(header);
g_object_ref(atkHeader);
g_ptr_array_add(atkHeaders, atkHeader);
@@ -205,12 +192,9 @@ GetRowHeaderCellsCB(AtkTableCell* aCell)
}
}
void
tableCellInterfaceInitCB(AtkTableCellIface* aIface)
{
void tableCellInterfaceInitCB(AtkTableCellIface* aIface) {
NS_ASSERTION(aIface, "no interface!");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->get_column_span = GetColumnSpanCB;
aIface->get_column_header_cells = GetColumnHeaderCellsCB;

View File

@@ -25,11 +25,9 @@ using namespace mozilla::a11y;
static const char* sAtkTextAttrNames[ATK_TEXT_ATTR_LAST_DEFINED];
void
ConvertTextAttributeToAtkAttribute(const nsACString& aName,
const nsAString& aValue,
AtkAttributeSet** aAttributeSet)
{
void ConvertTextAttributeToAtkAttribute(const nsACString& aName,
const nsAString& aValue,
AtkAttributeSet** aAttributeSet) {
// Handle attributes where atk has its own name.
const char* atkName = nullptr;
nsAutoString atkValue;
@@ -62,35 +60,31 @@ ConvertTextAttributeToAtkAttribute(const nsACString& aName,
if (atkName) {
AtkAttribute* objAttr =
static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
objAttr->name = g_strdup(atkName);
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(atkValue).get());
*aAttributeSet = g_slist_prepend(*aAttributeSet, objAttr);
}
}
static AtkAttributeSet*
ConvertToAtkTextAttributeSet(nsTArray<Attribute>& aAttributes)
{
static AtkAttributeSet* ConvertToAtkTextAttributeSet(
nsTArray<Attribute>& aAttributes) {
AtkAttributeSet* objAttributeSet = nullptr;
for (size_t i = 0; i < aAttributes.Length(); ++i) {
AtkAttribute* objAttr = (AtkAttribute *)g_malloc(sizeof(AtkAttribute));
AtkAttribute* objAttr = (AtkAttribute*)g_malloc(sizeof(AtkAttribute));
objAttr->name = g_strdup(aAttributes[i].Name().get());
objAttr->value =
g_strdup(NS_ConvertUTF16toUTF8(aAttributes[i].Value()).get());
g_strdup(NS_ConvertUTF16toUTF8(aAttributes[i].Value()).get());
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);
ConvertTextAttributeToAtkAttribute(aAttributes[i].Name(),
aAttributes[i].Value(),
&objAttributeSet);
ConvertTextAttributeToAtkAttribute(
aAttributes[i].Name(), aAttributes[i].Value(), &objAttributeSet);
}
return objAttributeSet;
}
static AtkAttributeSet*
ConvertToAtkTextAttributeSet(nsIPersistentProperties* aAttributes)
{
if (!aAttributes)
return nullptr;
static AtkAttributeSet* ConvertToAtkTextAttributeSet(
nsIPersistentProperties* aAttributes) {
if (!aAttributes) return nullptr;
AtkAttributeSet* objAttributeSet = nullptr;
nsCOMPtr<nsISimpleEnumerator> propEnum;
@@ -126,9 +120,8 @@ ConvertToAtkTextAttributeSet(nsIPersistentProperties* aAttributes)
return objAttributeSet;
}
static void
ConvertTexttoAsterisks(AccessibleWrap* accWrap, nsAString& aString)
{
static void ConvertTexttoAsterisks(AccessibleWrap* accWrap,
nsAString& aString) {
// convert each char to "*" when it's "password text"
if (accWrap->IsPassword()) {
DOMtoATK::ConvertTexttoAsterisks(aString);
@@ -137,24 +130,22 @@ ConvertTexttoAsterisks(AccessibleWrap* accWrap, nsAString& aString)
extern "C" {
static gchar*
getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
{
static gchar* getTextCB(AtkText* aText, gint aStartOffset, gint aEndOffset) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
nsAutoString autoStr;
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole() || text->IsDefunct())
return nullptr;
if (!text || !text->IsTextRole() || text->IsDefunct()) return nullptr;
return DOMtoATK::NewATKString(text, aStartOffset, aEndOffset,
accWrap->IsPassword() ?
DOMtoATK::AtkStringConvertFlags::ConvertTextToAsterisks :
DOMtoATK::AtkStringConvertFlags::None);
return DOMtoATK::NewATKString(
text, aStartOffset, aEndOffset,
accWrap->IsPassword()
? DOMtoATK::AtkStringConvertFlags::ConvertTextToAsterisks
: DOMtoATK::AtkStringConvertFlags::None);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
return DOMtoATK::NewATKString(proxy, aStartOffset, aEndOffset,
DOMtoATK::AtkStringConvertFlags::None);
DOMtoATK::AtkStringConvertFlags::None);
}
return nullptr;
@@ -164,10 +155,8 @@ static gint getCharacterCountCB(AtkText* aText);
// Note: this does not support magic offsets, which is fine for its callers
// which do not implement any.
static gchar*
getCharTextAtOffset(AtkText* aText, gint aOffset,
gint* aStartOffset, gint* aEndOffset)
{
static gchar* getCharTextAtOffset(AtkText* aText, gint aOffset,
gint* aStartOffset, gint* aEndOffset) {
gint end = aOffset + 1;
gint count = getCharacterCountCB(aText);
@@ -189,24 +178,22 @@ getCharTextAtOffset(AtkText* aText, gint aOffset,
return getTextCB(aText, aOffset, end);
}
static gchar*
getTextAfterOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
static gchar* getTextAfterOffsetCB(AtkText* aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint* aStartOffset, gint* aEndOffset) {
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
return getCharTextAtOffset(aText, aOffset + 1, aStartOffset, aEndOffset);
}
nsAutoString autoStr;
nsAutoString autoStr;
int32_t startOffset = 0, endOffset = 0;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
if (!text || !text->IsTextRole()) return nullptr;
text->TextAfterOffset(aOffset, aBoundaryType, &startOffset, &endOffset, autoStr);
text->TextAfterOffset(aOffset, aBoundaryType, &startOffset, &endOffset,
autoStr);
ConvertTexttoAsterisks(accWrap, autoStr);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->GetTextAfterOffset(aOffset, aBoundaryType, autoStr, &startOffset,
@@ -220,11 +207,9 @@ getTextAfterOffsetCB(AtkText *aText, gint aOffset,
return DOMtoATK::Convert(autoStr);
}
static gchar*
getTextAtOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
static gchar* getTextAtOffsetCB(AtkText* aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint* aStartOffset, gint* aEndOffset) {
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
return getCharTextAtOffset(aText, aOffset, aStartOffset, aEndOffset);
}
@@ -234,10 +219,10 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
if (!text || !text->IsTextRole()) return nullptr;
text->TextAtOffset(aOffset, aBoundaryType, &startOffset, &endOffset, autoStr);
text->TextAtOffset(aOffset, aBoundaryType, &startOffset, &endOffset,
autoStr);
ConvertTexttoAsterisks(accWrap, autoStr);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->GetTextAtOffset(aOffset, aBoundaryType, autoStr, &startOffset,
@@ -251,9 +236,7 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
return DOMtoATK::Convert(autoStr);
}
static gunichar
getCharacterAtOffsetCB(AtkText* aText, gint aOffset)
{
static gunichar getCharacterAtOffsetCB(AtkText* aText, gint aOffset) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -270,11 +253,9 @@ getCharacterAtOffsetCB(AtkText* aText, gint aOffset)
return 0;
}
static gchar*
getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
static gchar* getTextBeforeOffsetCB(AtkText* aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint* aStartOffset, gint* aEndOffset) {
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
return getCharTextAtOffset(aText, aOffset - 1, aStartOffset, aEndOffset);
}
@@ -284,11 +265,10 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole())
return nullptr;
if (!text || !text->IsTextRole()) return nullptr;
text->TextBeforeOffset(aOffset, aBoundaryType,
&startOffset, &endOffset, autoStr);
text->TextBeforeOffset(aOffset, aBoundaryType, &startOffset, &endOffset,
autoStr);
ConvertTexttoAsterisks(accWrap, autoStr);
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->GetTextBeforeOffset(aOffset, aBoundaryType, autoStr, &startOffset,
@@ -302,9 +282,7 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
return DOMtoATK::Convert(autoStr);
}
static gint
getCaretOffsetCB(AtkText *aText)
{
static gint getCaretOffsetCB(AtkText* aText) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -322,11 +300,9 @@ getCaretOffsetCB(AtkText *aText)
return 0;
}
static AtkAttributeSet*
getRunAttributesCB(AtkText *aText, gint aOffset,
gint *aStartOffset,
gint *aEndOffset)
{
static AtkAttributeSet* getRunAttributesCB(AtkText* aText, gint aOffset,
gint* aStartOffset,
gint* aEndOffset) {
*aStartOffset = -1;
*aEndOffset = -1;
int32_t startOffset = 0, endOffset = 0;
@@ -339,7 +315,7 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
}
nsCOMPtr<nsIPersistentProperties> attributes =
text->TextAttributes(false, aOffset, &startOffset, &endOffset);
text->TextAttributes(false, aOffset, &startOffset, &endOffset);
*aStartOffset = startOffset;
*aEndOffset = endOffset;
@@ -359,9 +335,7 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
return ConvertToAtkTextAttributeSet(attrs);
}
static AtkAttributeSet*
getDefaultAttributesCB(AtkText *aText)
{
static AtkAttributeSet* getDefaultAttributesCB(AtkText* aText) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -369,7 +343,8 @@ getDefaultAttributesCB(AtkText *aText)
return nullptr;
}
nsCOMPtr<nsIPersistentProperties> attributes = text->DefaultTextAttributes();
nsCOMPtr<nsIPersistentProperties> attributes =
text->DefaultTextAttributes();
return ConvertToAtkTextAttributeSet(attributes);
}
@@ -383,13 +358,10 @@ getDefaultAttributesCB(AtkText *aText)
return ConvertToAtkTextAttributeSet(attrs);
}
static void
getCharacterExtentsCB(AtkText *aText, gint aOffset,
gint *aX, gint *aY,
gint *aWidth, gint *aHeight,
AtkCoordType aCoords)
{
if(!aX || !aY || !aWidth || !aHeight) {
static void getCharacterExtentsCB(AtkText* aText, gint aOffset, gint* aX,
gint* aY, gint* aWidth, gint* aHeight,
AtkCoordType aCoords) {
if (!aX || !aY || !aWidth || !aHeight) {
return;
}
@@ -421,10 +393,9 @@ getCharacterExtentsCB(AtkText *aText, gint aOffset,
*aHeight = rect.height;
}
static void
getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
AtkCoordType aCoords, AtkTextRectangle *aRect)
{
static void getRangeExtentsCB(AtkText* aText, gint aStartOffset,
gint aEndOffset, AtkCoordType aCoords,
AtkTextRectangle* aRect) {
if (!aRect) {
return;
}
@@ -438,7 +409,7 @@ getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
}
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if(accWrap) {
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
return;
@@ -457,14 +428,13 @@ getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
aRect->height = rect.height;
}
static gint
getCharacterCountCB(AtkText *aText)
{
static gint getCharacterCountCB(AtkText* aText) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* textAcc = accWrap->AsHyperText();
return !textAcc || textAcc->IsDefunct() ?
0 : static_cast<gint>(textAcc->CharacterCount());
return !textAcc || textAcc->IsDefunct()
? 0
: static_cast<gint>(textAcc->CharacterCount());
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
@@ -474,11 +444,8 @@ getCharacterCountCB(AtkText *aText)
return 0;
}
static gint
getOffsetAtPointCB(AtkText *aText,
gint aX, gint aY,
AtkCoordType aCoords)
{
static gint getOffsetAtPointCB(AtkText* aText, gint aX, gint aY,
AtkCoordType aCoords) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -486,27 +453,25 @@ getOffsetAtPointCB(AtkText *aText,
return -1;
}
return static_cast<gint>(
text->OffsetAtPoint(aX, aY,
(aCoords == ATK_XY_SCREEN ?
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
return static_cast<gint>(text->OffsetAtPoint(
aX, aY,
(aCoords == ATK_XY_SCREEN
? nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE
: nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
return static_cast<gint>(
proxy->OffsetAtPoint(aX, aY,
(aCoords == ATK_XY_SCREEN ?
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
return static_cast<gint>(proxy->OffsetAtPoint(
aX, aY,
(aCoords == ATK_XY_SCREEN
? nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE
: nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
}
return -1;
}
static gint
getTextSelectionCountCB(AtkText *aText)
{
static gint getTextSelectionCountCB(AtkText* aText) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -524,10 +489,8 @@ getTextSelectionCountCB(AtkText *aText)
return 0;
}
static gchar*
getTextSelectionCB(AtkText *aText, gint aSelectionNum,
gint *aStartOffset, gint *aEndOffset)
{
static gchar* getTextSelectionCB(AtkText* aText, gint aSelectionNum,
gint* aStartOffset, gint* aEndOffset) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
int32_t startOffset = 0, endOffset = 0;
if (accWrap) {
@@ -555,11 +518,8 @@ getTextSelectionCB(AtkText *aText, gint aSelectionNum,
}
// set methods
static gboolean
addTextSelectionCB(AtkText *aText,
gint aStartOffset,
gint aEndOffset)
{
static gboolean addTextSelectionCB(AtkText* aText, gint aStartOffset,
gint aEndOffset) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -576,10 +536,7 @@ addTextSelectionCB(AtkText *aText,
return FALSE;
}
static gboolean
removeTextSelectionCB(AtkText *aText,
gint aSelectionNum)
{
static gboolean removeTextSelectionCB(AtkText* aText, gint aSelectionNum) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -596,10 +553,8 @@ removeTextSelectionCB(AtkText *aText,
return FALSE;
}
static gboolean
setTextSelectionCB(AtkText *aText, gint aSelectionNum,
gint aStartOffset, gint aEndOffset)
{
static gboolean setTextSelectionCB(AtkText* aText, gint aSelectionNum,
gint aStartOffset, gint aEndOffset) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -616,9 +571,7 @@ setTextSelectionCB(AtkText *aText, gint aSelectionNum,
return FALSE;
}
static gboolean
setCaretOffsetCB(AtkText *aText, gint aOffset)
{
static gboolean setCaretOffsetCB(AtkText* aText, gint aOffset) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
@@ -639,12 +592,9 @@ setCaretOffsetCB(AtkText *aText, gint aOffset)
}
}
void
textInterfaceInitCB(AtkTextIface* aIface)
{
void textInterfaceInitCB(AtkTextIface* aIface) {
NS_ASSERTION(aIface, "Invalid aIface");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->get_text = getTextCB;
aIface->get_text_after_offset = getTextAfterOffsetCB;
@@ -661,7 +611,7 @@ textInterfaceInitCB(AtkTextIface* aIface)
aIface->get_n_selections = getTextSelectionCountCB;
aIface->get_selection = getTextSelectionCB;
// set methods
// set methods
aIface->add_selection = addTextSelectionCB;
aIface->remove_selection = removeTextSelectionCB;
aIface->set_selection = setTextSelectionCB;
@@ -670,5 +620,5 @@ textInterfaceInitCB(AtkTextIface* aIface)
// Cache the string values of the atk text attribute names.
for (uint32_t i = 0; i < ArrayLength(sAtkTextAttrNames); i++)
sAtkTextAttrNames[i] =
atk_text_attribute_get_name(static_cast<AtkTextAttribute>(i));
atk_text_attribute_get_name(static_cast<AtkTextAttribute>(i));
}

View File

@@ -17,9 +17,7 @@ using namespace mozilla::a11y;
extern "C" {
static void
getCurrentValueCB(AtkValue *obj, GValue *value)
{
static void getCurrentValueCB(AtkValue* obj, GValue* value) {
ProxyAccessible* proxy = nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
if (!accWrap) {
@@ -29,18 +27,15 @@ getCurrentValueCB(AtkValue *obj, GValue *value)
}
}
memset (value, 0, sizeof (GValue));
memset(value, 0, sizeof(GValue));
double accValue = accWrap ? accWrap->CurValue() : proxy->CurValue();
if (IsNaN(accValue))
return;
if (IsNaN(accValue)) return;
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, accValue);
g_value_init(value, G_TYPE_DOUBLE);
g_value_set_double(value, accValue);
}
static void
getMaximumValueCB(AtkValue *obj, GValue *value)
{
static void getMaximumValueCB(AtkValue* obj, GValue* value) {
ProxyAccessible* proxy = nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
if (!accWrap) {
@@ -50,18 +45,15 @@ getMaximumValueCB(AtkValue *obj, GValue *value)
}
}
memset(value, 0, sizeof (GValue));
memset(value, 0, sizeof(GValue));
double accValue = accWrap ? accWrap->MaxValue() : proxy->MaxValue();
if (IsNaN(accValue))
return;
if (IsNaN(accValue)) return;
g_value_init(value, G_TYPE_DOUBLE);
g_value_set_double(value, accValue);
}
static void
getMinimumValueCB(AtkValue *obj, GValue *value)
{
static void getMinimumValueCB(AtkValue* obj, GValue* value) {
ProxyAccessible* proxy = nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
if (!accWrap) {
@@ -71,18 +63,15 @@ getMinimumValueCB(AtkValue *obj, GValue *value)
}
}
memset(value, 0, sizeof (GValue));
memset(value, 0, sizeof(GValue));
double accValue = accWrap ? accWrap->MinValue() : proxy->MinValue();
if (IsNaN(accValue))
return;
if (IsNaN(accValue)) return;
g_value_init(value, G_TYPE_DOUBLE);
g_value_set_double(value, accValue);
}
static void
getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
{
static void getMinimumIncrementCB(AtkValue* obj, GValue* minimumIncrement) {
ProxyAccessible* proxy = nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
if (!accWrap) {
@@ -92,18 +81,16 @@ getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
}
}
memset(minimumIncrement, 0, sizeof (GValue));
memset(minimumIncrement, 0, sizeof(GValue));
double accValue = accWrap ? accWrap->Step() : proxy->Step();
if (IsNaN(accValue))
accValue = 0; // zero if the minimum increment is undefined
accValue = 0; // zero if the minimum increment is undefined
g_value_init(minimumIncrement, G_TYPE_DOUBLE);
g_value_set_double(minimumIncrement, accValue);
}
static gboolean
setCurrentValueCB(AtkValue *obj, const GValue *value)
{
static gboolean setCurrentValueCB(AtkValue* obj, const GValue* value) {
ProxyAccessible* proxy = nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
if (!accWrap) {
@@ -113,17 +100,15 @@ setCurrentValueCB(AtkValue *obj, const GValue *value)
}
}
double accValue =g_value_get_double(value);
return accWrap ? accWrap->SetCurValue(accValue) : proxy->SetCurValue(accValue);
double accValue = g_value_get_double(value);
return accWrap ? accWrap->SetCurValue(accValue)
: proxy->SetCurValue(accValue);
}
}
void
valueInterfaceInitCB(AtkValueIface* aIface)
{
void valueInterfaceInitCB(AtkValueIface* aIface) {
NS_ASSERTION(aIface, "Invalid aIface");
if (MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
aIface->get_current_value = getCurrentValueCB;
aIface->get_maximum_value = getMaximumValueCB;

View File

@@ -41,8 +41,8 @@ The following ATK states are not supported:
enum EStateMapEntryType {
kMapDirectly,
kMapOpposite, // For example, UNAVAILABLE is the opposite of ENABLED
kNoStateChange, // Don't fire state change event
kMapOpposite, // For example, UNAVAILABLE is the opposite of ENABLED
kNoStateChange, // Don't fire state change event
};
const AtkStateType kNone = ATK_STATE_INVALID;
@@ -52,10 +52,12 @@ struct AtkStateMap {
EStateMapEntryType stateMapEntryType;
};
// Map array from cross platform states to ATK states
static const AtkStateMap gAtkStateMap[] = { // Cross Platform States
// clang-format off
static const AtkStateMap
gAtkStateMap[] =
{
// Cross Platform States
// clang-format off
{ kNone, kMapOpposite }, // states::UNAVAILABLE = 1 << 0
{ ATK_STATE_SELECTED, kMapDirectly }, // states::SELECTED = 1 << 1
{ ATK_STATE_FOCUSED, kMapDirectly }, // states::FOCUSED = 1 << 2
@@ -105,10 +107,11 @@ static const AtkStateMap gAtkStateMap[] = { // Cross Platfor
{ ATK_STATE_EXPANDABLE, kMapDirectly }, // states::EXPANDABLE = 1 << 46
{ kNone, kMapDirectly }, // states::PINNED = 1 << 47
{ ATK_STATE_ACTIVE, kMapDirectly } // states::CURRENT = 1 << 48
// clang-format on
// clang-format on
};
static const auto gAtkStateMapLen = std::extent<decltype(gAtkStateMap)>::value;
static_assert(((uint64_t) 0x1) << (gAtkStateMapLen - 1) == mozilla::a11y::states::LAST_ENTRY,
static_assert(((uint64_t)0x1) << (gAtkStateMapLen - 1) ==
mozilla::a11y::states::LAST_ENTRY,
"ATK states map is out of sync with internal states");

View File

@@ -26,8 +26,8 @@ static const uint32_t kGenericAccType = 0;
/**
* This list of WAI-defined roles are currently hardcoded.
* Eventually we will most likely be loading an RDF resource that contains this information
* Using RDF will also allow for role extensibility. See bug 280138.
* Eventually we will most likely be loading an RDF resource that contains this
* information Using RDF will also allow for role extensibility. See bug 280138.
*
* Definition of nsRoleMapEntry contains comments explaining this table.
*
@@ -35,9 +35,8 @@ static const uint32_t kGenericAccType = 0;
* via the object attribute "xml-roles".
*/
static const nsRoleMapEntry sWAIRoleMaps[] =
{
// clang-format off
static const nsRoleMapEntry sWAIRoleMaps[] = {
// clang-format off
{ // alert
nsGkAtoms::alert,
roles::ALERT,
@@ -1241,30 +1240,16 @@ static const nsRoleMapEntry sWAIRoleMaps[] =
eARIASelectable,
eARIACheckedMixed
}
// clang-format on
// clang-format on
};
static const nsRoleMapEntry sLandmarkRoleMap = {
nsGkAtoms::_empty,
roles::NOTHING,
kUseNativeRole,
eNoValue,
eNoAction,
eNoLiveAttr,
kGenericAccType,
kNoReqStates
};
nsGkAtoms::_empty, roles::NOTHING, kUseNativeRole, eNoValue,
eNoAction, eNoLiveAttr, kGenericAccType, kNoReqStates};
nsRoleMapEntry aria::gEmptyRoleMap = {
nsGkAtoms::_empty,
roles::NOTHING,
kUseMapRole,
eNoValue,
eNoAction,
eNoLiveAttr,
kGenericAccType,
kNoReqStates
};
nsGkAtoms::_empty, roles::NOTHING, kUseMapRole, eNoValue,
eNoAction, eNoLiveAttr, kGenericAccType, kNoReqStates};
/**
* Universal (Global) states:
@@ -1272,31 +1257,25 @@ nsRoleMapEntry aria::gEmptyRoleMap = {
* whether there is an ARIA role or not:
*/
static const EStateRule sWAIUnivStateMap[] = {
eARIABusy,
eARIACurrent,
eARIADisabled,
eARIAExpanded, // Currently under spec review but precedent exists
eARIAHasPopup, // Note this is a tokenised attribute starting in ARIA 1.1
eARIAInvalid,
eARIAModal,
eARIARequired, // XXX not global, Bug 553117
eARIANone
};
eARIABusy, eARIACurrent, eARIADisabled,
eARIAExpanded, // Currently under spec review but precedent exists
eARIAHasPopup, // Note this is a tokenised attribute starting in ARIA 1.1
eARIAInvalid, eARIAModal,
eARIARequired, // XXX not global, Bug 553117
eARIANone};
/**
* ARIA attribute map for attribute characteristics.
* @note ARIA attributes that don't have any flags are not included here.
*/
struct AttrCharacteristics
{
struct AttrCharacteristics {
const nsStaticAtom* const attributeName;
const uint8_t characteristics;
};
static const AttrCharacteristics gWAIUnivAttrMap[] = {
// clang-format off
// clang-format off
{nsGkAtoms::aria_activedescendant, ATTR_BYPASSOBJ },
{nsGkAtoms::aria_atomic, ATTR_BYPASSOBJ_IF_FALSE | ATTR_VALTOKEN | ATTR_GLOBAL },
{nsGkAtoms::aria_busy, ATTR_VALTOKEN | ATTR_GLOBAL },
@@ -1335,13 +1314,12 @@ static const AttrCharacteristics gWAIUnivAttrMap[] = {
{nsGkAtoms::aria_valuemin, ATTR_BYPASSOBJ },
{nsGkAtoms::aria_valuemax, ATTR_BYPASSOBJ },
{nsGkAtoms::aria_valuetext, ATTR_BYPASSOBJ }
// clang-format on
// clang-format on
};
namespace {
struct RoleComparator
{
struct RoleComparator {
const nsDependentSubstring& mRole;
explicit RoleComparator(const nsDependentSubstring& aRole) : mRole(aRole) {}
int operator()(const nsRoleMapEntry& aEntry) const {
@@ -1349,17 +1327,13 @@ struct RoleComparator
}
};
}
} // namespace
const nsRoleMapEntry*
aria::GetRoleMap(dom::Element* aEl)
{
const nsRoleMapEntry* aria::GetRoleMap(dom::Element* aEl) {
return GetRoleMapFromIndex(GetRoleMapIndex(aEl));
}
uint8_t
aria::GetRoleMapIndex(dom::Element* aEl)
{
uint8_t aria::GetRoleMapIndex(dom::Element* aEl) {
nsAutoString roles;
if (!aEl || !aEl->GetAttr(kNameSpaceID_None, nsGkAtoms::role, roles) ||
roles.IsEmpty()) {
@@ -1383,10 +1357,7 @@ aria::GetRoleMapIndex(dom::Element* aEl)
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
}
const nsRoleMapEntry*
aria::GetRoleMapFromIndex(uint8_t aRoleMapIndex)
{
const nsRoleMapEntry* aria::GetRoleMapFromIndex(uint8_t aRoleMapIndex) {
switch (aRoleMapIndex) {
case NO_ROLE_MAP_ENTRY_INDEX:
return nullptr;
@@ -1399,34 +1370,27 @@ aria::GetRoleMapFromIndex(uint8_t aRoleMapIndex)
}
}
uint8_t
aria::GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMapEntry)
{
uint8_t aria::GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMapEntry) {
if (aRoleMapEntry == nullptr) {
return NO_ROLE_MAP_ENTRY_INDEX;
} else if (aRoleMapEntry == &gEmptyRoleMap) {
return EMPTY_ROLE_MAP_ENTRY_INDEX;
} else if (aRoleMapEntry == &sLandmarkRoleMap) {
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
} else {
return aRoleMapEntry - sWAIRoleMaps;
}
}
uint64_t
aria::UniversalStatesFor(mozilla::dom::Element* aElement)
{
uint64_t aria::UniversalStatesFor(mozilla::dom::Element* aElement) {
uint64_t state = 0;
uint32_t index = 0;
while (MapToState(sWAIUnivStateMap[index], aElement, &state))
index++;
while (MapToState(sWAIUnivStateMap[index], aElement, &state)) index++;
return state;
}
uint8_t
aria::AttrCharacteristicsFor(nsAtom* aAtom)
{
uint8_t aria::AttrCharacteristicsFor(nsAtom* aAtom) {
for (uint32_t i = 0; i < ArrayLength(gWAIUnivAttrMap); i++)
if (gWAIUnivAttrMap[i].attributeName == aAtom)
return gWAIUnivAttrMap[i].characteristics;
@@ -1434,21 +1398,17 @@ aria::AttrCharacteristicsFor(nsAtom* aAtom)
return 0;
}
bool
aria::HasDefinedARIAHidden(nsIContent* aContent)
{
bool aria::HasDefinedARIAHidden(nsIContent* aContent) {
return aContent && aContent->IsElement() &&
aContent->AsElement()->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::aria_hidden,
nsGkAtoms::_true, eCaseMatters);
aContent->AsElement()->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::aria_hidden,
nsGkAtoms::_true, eCaseMatters);
}
////////////////////////////////////////////////////////////////////////////////
// AttrIterator class
bool
AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
{
bool AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue) {
while (mAttrIdx < mAttrCount) {
const nsAttrName* attr = mElement->GetAttrNameAt(mAttrIdx);
mAttrIdx++;
@@ -1456,20 +1416,20 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
nsAtom* attrAtom = attr->Atom();
nsDependentAtomString attrStr(attrAtom);
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
continue; // Not ARIA
continue; // Not ARIA
uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
if (attrFlags & ATTR_BYPASSOBJ)
continue; // No need to handle exposing as obj attribute here
continue; // No need to handle exposing as obj attribute here
if ((attrFlags & ATTR_VALTOKEN) &&
!nsAccUtils::HasDefinedARIAToken(mElement, attrAtom))
continue; // only expose token based attributes if they are defined
!nsAccUtils::HasDefinedARIAToken(mElement, attrAtom))
continue; // only expose token based attributes if they are defined
if ((attrFlags & ATTR_BYPASSOBJ_IF_FALSE) &&
mElement->AttrValueIs(kNameSpaceID_None, attrAtom,
nsGkAtoms::_false, eCaseMatters)) {
continue; // only expose token based attribute if value is not 'false'.
mElement->AttrValueIs(kNameSpaceID_None, attrAtom, nsGkAtoms::_false,
eCaseMatters)) {
continue; // only expose token based attribute if value is not 'false'.
}
nsAutoString value;
@@ -1477,7 +1437,7 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
aAttrName.Assign(Substring(attrStr, 5));
if (attrFlags & ATTR_VALTOKEN) {
nsAtom* normalizedValue =
nsAccUtils::NormalizeARIAToken(mElement, attrAtom);
nsAccUtils::NormalizeARIAToken(mElement, attrAtom);
if (normalizedValue) {
nsDependentAtomString normalizedValueStr(normalizedValue);
aAttrValue.Assign(normalizedValueStr);
@@ -1492,4 +1452,3 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
return false;
}

View File

@@ -24,8 +24,7 @@ class nsINode;
/**
* Used to define if role requires to expose Value interface.
*/
enum EValueRule
{
enum EValueRule {
/**
* Value interface isn't exposed.
*/
@@ -46,15 +45,13 @@ enum EValueRule
eHasValueMinMaxIfFocusable
};
////////////////////////////////////////////////////////////////////////////////
// Action constants
/**
* Used to define if the role requires to expose action.
*/
enum EActionRule
{
enum EActionRule {
eNoAction,
eActivateAction,
eClickAction,
@@ -68,20 +65,13 @@ enum EActionRule
eSwitchAction
};
////////////////////////////////////////////////////////////////////////////////
// Live region constants
/**
* Used to define if role exposes default value of aria-live attribute.
*/
enum ELiveAttrRule
{
eNoLiveAttr,
eOffLiveAttr,
ePoliteLiveAttr
};
enum ELiveAttrRule { eNoLiveAttr, eOffLiveAttr, ePoliteLiveAttr };
////////////////////////////////////////////////////////////////////////////////
// Role constants
@@ -96,7 +86,6 @@ const bool kUseMapRole = true;
*/
const bool kUseNativeRole = false;
////////////////////////////////////////////////////////////////////////////////
// ARIA attribute characteristic masks
@@ -110,8 +99,8 @@ const uint8_t ATTR_BYPASSOBJ = 0x1 << 0;
const uint8_t ATTR_BYPASSOBJ_IF_FALSE = 0x1 << 1;
/**
* This mask indicates the attribute is expected to have an NMTOKEN or bool value.
* (See for example usage in Accessible::Attributes())
* This mask indicates the attribute is expected to have an NMTOKEN or bool
* value. (See for example usage in Accessible::Attributes())
*/
const uint8_t ATTR_VALTOKEN = 0x1 << 2;
@@ -136,25 +125,25 @@ const uint8_t ATTR_GLOBAL = 0x1 << 3;
/**
* For each ARIA role, this maps the nsIAccessible information.
*/
struct nsRoleMapEntry
{
struct nsRoleMapEntry {
/**
* Return true if matches to the given ARIA role.
*/
bool Is(nsAtom* aARIARole) const
{ return roleAtom == aARIARole; }
bool Is(nsAtom* aARIARole) const { return roleAtom == aARIARole; }
/**
* Return true if ARIA role has the given accessible type.
*/
bool IsOfType(mozilla::a11y::AccGenericType aType) const
{ return accTypes & aType; }
bool IsOfType(mozilla::a11y::AccGenericType aType) const {
return accTypes & aType;
}
/**
* Return ARIA role.
*/
const nsDependentAtomString ARIARoleString() const
{ return nsDependentAtomString(roleAtom); }
const nsDependentAtomString ARIARoleString() const {
return nsDependentAtomString(roleAtom);
}
// ARIA role: string representation such as "button"
nsStaticAtom* const roleAtom;
@@ -179,7 +168,7 @@ struct nsRoleMapEntry
uint32_t accTypes;
// Automatic state mapping rule: always include in states
uint64_t state; // or kNoReqStates if no default state for this role
uint64_t state; // or kNoReqStates if no default state for this role
// ARIA properties supported for this role (in other words, the aria-foo
// attribute to accessible states mapping rules).
@@ -192,7 +181,6 @@ struct nsRoleMapEntry
mozilla::a11y::aria::EStateRule attributeMap4;
};
////////////////////////////////////////////////////////////////////////////////
// ARIA map
@@ -282,34 +270,31 @@ uint8_t AttrCharacteristicsFor(nsAtom* aAtom);
*/
bool HasDefinedARIAHidden(nsIContent* aContent);
/**
* Represents a simple enumerator for iterating through ARIA attributes
* exposed as object attributes on a given accessible.
*/
class AttrIterator
{
public:
/**
* Represents a simple enumerator for iterating through ARIA attributes
* exposed as object attributes on a given accessible.
*/
class AttrIterator {
public:
explicit AttrIterator(nsIContent* aContent)
: mElement(Element::FromNode(aContent))
, mAttrIdx(0)
{
: mElement(Element::FromNode(aContent)), mAttrIdx(0) {
mAttrCount = mElement ? mElement->GetAttrCount() : 0;
}
bool Next(nsAString& aAttrName, nsAString& aAttrValue);
private:
private:
AttrIterator() = delete;
AttrIterator(const AttrIterator&) = delete;
AttrIterator& operator= (const AttrIterator&) = delete;
AttrIterator& operator=(const AttrIterator&) = delete;
dom::Element* mElement;
uint32_t mAttrIdx;
uint32_t mAttrCount;
};
} // namespace aria
} // namespace a11y
} // namespace mozilla
} // namespace aria
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -17,8 +17,7 @@ using namespace mozilla::a11y::aria;
/**
* Used to store state map rule data for ARIA attribute of enum type.
*/
struct EnumTypeData
{
struct EnumTypeData {
// ARIA attribute name.
nsStaticAtom* const mAttrName;
@@ -33,26 +32,24 @@ struct EnumTypeData
const uint64_t mClearState;
};
enum ETokenType
{
enum ETokenType {
eBoolType = 0,
eMixedType = 1, // can take 'mixed' value
eDefinedIfAbsent = 2 // permanent and false state are applied if absent
eMixedType = 1, // can take 'mixed' value
eDefinedIfAbsent = 2 // permanent and false state are applied if absent
};
/**
* Used to store state map rule data for ARIA attribute of token type (including
* mixed value).
*/
struct TokenTypeData
{
TokenTypeData(nsAtom* aAttrName, uint32_t aType,
uint64_t aPermanentState,
uint64_t aTrueState,
uint64_t aFalseState = 0) :
mAttrName(aAttrName), mType(aType), mPermanentState(aPermanentState),
mTrueState(aTrueState), mFalseState(aFalseState)
{ }
struct TokenTypeData {
TokenTypeData(nsAtom* aAttrName, uint32_t aType, uint64_t aPermanentState,
uint64_t aTrueState, uint64_t aFalseState = 0)
: mAttrName(aAttrName),
mType(aType),
mPermanentState(aPermanentState),
mTrueState(aTrueState),
mFalseState(aFalseState) {}
// ARIA attribute name.
nsAtom* const mAttrName;
@@ -81,245 +78,201 @@ static void MapEnumType(dom::Element* aElement, uint64_t* aState,
static void MapTokenType(dom::Element* aContent, uint64_t* aState,
const TokenTypeData& aData);
bool
aria::MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState)
{
bool aria::MapToState(EStateRule aRule, dom::Element* aElement,
uint64_t* aState) {
switch (aRule) {
case eARIAAutoComplete:
{
case eARIAAutoComplete: {
static const EnumTypeData data = {
nsGkAtoms::aria_autocomplete,
{ nsGkAtoms::inlinevalue,
nsGkAtoms::list_,
nsGkAtoms::both, nullptr },
{ states::SUPPORTS_AUTOCOMPLETION,
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION,
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION }, 0
};
nsGkAtoms::aria_autocomplete,
{nsGkAtoms::inlinevalue, nsGkAtoms::list_, nsGkAtoms::both, nullptr},
{states::SUPPORTS_AUTOCOMPLETION,
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION,
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION},
0};
MapEnumType(aElement, aState, data);
return true;
}
case eARIABusy:
{
case eARIABusy: {
static const EnumTypeData data = {
nsGkAtoms::aria_busy,
{ nsGkAtoms::_true,
nsGkAtoms::error, nullptr },
{ states::BUSY,
states::INVALID }, 0
};
nsGkAtoms::aria_busy,
{nsGkAtoms::_true, nsGkAtoms::error, nullptr},
{states::BUSY, states::INVALID},
0};
MapEnumType(aElement, aState, data);
return true;
}
case eARIACheckableBool:
{
static const TokenTypeData data(
nsGkAtoms::aria_checked, eBoolType | eDefinedIfAbsent,
states::CHECKABLE, states::CHECKED);
case eARIACheckableBool: {
static const TokenTypeData data(nsGkAtoms::aria_checked,
eBoolType | eDefinedIfAbsent,
states::CHECKABLE, states::CHECKED);
MapTokenType(aElement, aState, data);
return true;
}
case eARIACheckableMixed:
{
static const TokenTypeData data(
nsGkAtoms::aria_checked, eMixedType | eDefinedIfAbsent,
states::CHECKABLE, states::CHECKED);
case eARIACheckableMixed: {
static const TokenTypeData data(nsGkAtoms::aria_checked,
eMixedType | eDefinedIfAbsent,
states::CHECKABLE, states::CHECKED);
MapTokenType(aElement, aState, data);
return true;
}
case eARIACheckedMixed:
{
static const TokenTypeData data(
nsGkAtoms::aria_checked, eMixedType,
states::CHECKABLE, states::CHECKED);
case eARIACheckedMixed: {
static const TokenTypeData data(nsGkAtoms::aria_checked, eMixedType,
states::CHECKABLE, states::CHECKED);
MapTokenType(aElement, aState, data);
return true;
}
case eARIACurrent:
{
static const TokenTypeData data(
nsGkAtoms::aria_current, eBoolType,
0, states::CURRENT);
case eARIACurrent: {
static const TokenTypeData data(nsGkAtoms::aria_current, eBoolType, 0,
states::CURRENT);
MapTokenType(aElement, aState, data);
return true;
}
case eARIADisabled:
{
static const TokenTypeData data(
nsGkAtoms::aria_disabled, eBoolType,
0, states::UNAVAILABLE);
case eARIADisabled: {
static const TokenTypeData data(nsGkAtoms::aria_disabled, eBoolType, 0,
states::UNAVAILABLE);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAExpanded:
{
static const TokenTypeData data(
nsGkAtoms::aria_expanded, eBoolType,
0, states::EXPANDED, states::COLLAPSED);
case eARIAExpanded: {
static const TokenTypeData data(nsGkAtoms::aria_expanded, eBoolType, 0,
states::EXPANDED, states::COLLAPSED);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAHasPopup:
{
static const TokenTypeData data(
nsGkAtoms::aria_haspopup, eBoolType,
0, states::HASPOPUP);
case eARIAHasPopup: {
static const TokenTypeData data(nsGkAtoms::aria_haspopup, eBoolType, 0,
states::HASPOPUP);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAInvalid:
{
static const TokenTypeData data(
nsGkAtoms::aria_invalid, eBoolType,
0, states::INVALID);
case eARIAInvalid: {
static const TokenTypeData data(nsGkAtoms::aria_invalid, eBoolType, 0,
states::INVALID);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAModal:
{
static const TokenTypeData data(
nsGkAtoms::aria_modal, eBoolType,
0, states::MODAL);
case eARIAModal: {
static const TokenTypeData data(nsGkAtoms::aria_modal, eBoolType, 0,
states::MODAL);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAMultiline:
{
static const TokenTypeData data(
nsGkAtoms::aria_multiline, eBoolType | eDefinedIfAbsent,
0, states::MULTI_LINE, states::SINGLE_LINE);
case eARIAMultiline: {
static const TokenTypeData data(nsGkAtoms::aria_multiline,
eBoolType | eDefinedIfAbsent, 0,
states::MULTI_LINE, states::SINGLE_LINE);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAMultiSelectable:
{
case eARIAMultiSelectable: {
static const TokenTypeData data(
nsGkAtoms::aria_multiselectable, eBoolType,
0, states::MULTISELECTABLE | states::EXTSELECTABLE);
nsGkAtoms::aria_multiselectable, eBoolType, 0,
states::MULTISELECTABLE | states::EXTSELECTABLE);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAOrientation:
{
case eARIAOrientation: {
static const EnumTypeData data = {
nsGkAtoms::aria_orientation,
{ nsGkAtoms::horizontal,
nsGkAtoms::vertical, nullptr },
{ states::HORIZONTAL,
states::VERTICAL },
states::HORIZONTAL | states::VERTICAL
};
nsGkAtoms::aria_orientation,
{nsGkAtoms::horizontal, nsGkAtoms::vertical, nullptr},
{states::HORIZONTAL, states::VERTICAL},
states::HORIZONTAL | states::VERTICAL};
MapEnumType(aElement, aState, data);
return true;
}
case eARIAPressed:
{
static const TokenTypeData data(
nsGkAtoms::aria_pressed, eMixedType,
0, states::PRESSED);
case eARIAPressed: {
static const TokenTypeData data(nsGkAtoms::aria_pressed, eMixedType, 0,
states::PRESSED);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAReadonly:
{
static const TokenTypeData data(
nsGkAtoms::aria_readonly, eBoolType,
0, states::READONLY);
case eARIAReadonly: {
static const TokenTypeData data(nsGkAtoms::aria_readonly, eBoolType, 0,
states::READONLY);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAReadonlyOrEditable:
{
static const TokenTypeData data(
nsGkAtoms::aria_readonly, eBoolType | eDefinedIfAbsent,
0, states::READONLY, states::EDITABLE);
case eARIAReadonlyOrEditable: {
static const TokenTypeData data(nsGkAtoms::aria_readonly,
eBoolType | eDefinedIfAbsent, 0,
states::READONLY, states::EDITABLE);
MapTokenType(aElement, aState, data);
return true;
}
case eARIAReadonlyOrEditableIfDefined:
{
static const TokenTypeData data(
nsGkAtoms::aria_readonly, eBoolType,
0, states::READONLY, states::EDITABLE);
case eARIAReadonlyOrEditableIfDefined: {
static const TokenTypeData data(nsGkAtoms::aria_readonly, eBoolType, 0,
states::READONLY, states::EDITABLE);
MapTokenType(aElement, aState, data);
return true;
}
case eARIARequired:
{
static const TokenTypeData data(
nsGkAtoms::aria_required, eBoolType,
0, states::REQUIRED);
case eARIARequired: {
static const TokenTypeData data(nsGkAtoms::aria_required, eBoolType, 0,
states::REQUIRED);
MapTokenType(aElement, aState, data);
return true;
}
case eARIASelectable:
{
static const TokenTypeData data(
nsGkAtoms::aria_selected, eBoolType | eDefinedIfAbsent,
states::SELECTABLE, states::SELECTED);
case eARIASelectable: {
static const TokenTypeData data(nsGkAtoms::aria_selected,
eBoolType | eDefinedIfAbsent,
states::SELECTABLE, states::SELECTED);
MapTokenType(aElement, aState, data);
return true;
}
case eARIASelectableIfDefined:
{
static const TokenTypeData data(
nsGkAtoms::aria_selected, eBoolType,
states::SELECTABLE, states::SELECTED);
case eARIASelectableIfDefined: {
static const TokenTypeData data(nsGkAtoms::aria_selected, eBoolType,
states::SELECTABLE, states::SELECTED);
MapTokenType(aElement, aState, data);
return true;
}
case eReadonlyUntilEditable:
{
if (!(*aState & states::EDITABLE))
*aState |= states::READONLY;
case eReadonlyUntilEditable: {
if (!(*aState & states::EDITABLE)) *aState |= states::READONLY;
return true;
}
case eIndeterminateIfNoValue:
{
case eIndeterminateIfNoValue: {
if (!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_valuenow) &&
!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_valuetext))
*aState |= states::MIXED;
@@ -327,9 +280,9 @@ aria::MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState)
return true;
}
case eFocusableUntilDisabled:
{
if (!nsAccUtils::HasDefinedARIAToken(aElement, nsGkAtoms::aria_disabled) ||
case eFocusableUntilDisabled: {
if (!nsAccUtils::HasDefinedARIAToken(aElement,
nsGkAtoms::aria_disabled) ||
aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_disabled,
nsGkAtoms::_false, eCaseMatters))
*aState |= states::FOCUSABLE;
@@ -342,9 +295,8 @@ aria::MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState)
}
}
static void
MapEnumType(dom::Element* aElement, uint64_t* aState, const EnumTypeData& aData)
{
static void MapEnumType(dom::Element* aElement, uint64_t* aState,
const EnumTypeData& aData) {
switch (aElement->FindAttrValueIn(kNameSpaceID_None, aData.mAttrName,
aData.mValues, eCaseMatters)) {
case 0:
@@ -359,16 +311,14 @@ MapEnumType(dom::Element* aElement, uint64_t* aState, const EnumTypeData& aData)
}
}
static void
MapTokenType(dom::Element* aElement, uint64_t* aState,
const TokenTypeData& aData)
{
static void MapTokenType(dom::Element* aElement, uint64_t* aState,
const TokenTypeData& aData) {
if (nsAccUtils::HasDefinedARIAToken(aElement, aData.mAttrName)) {
if (aElement->AttrValueIs(kNameSpaceID_None, aData.mAttrName,
nsGkAtoms::mixed, eCaseMatters)) {
if (aData.mType & eMixedType)
*aState |= aData.mPermanentState | states::MIXED;
else // unsupported use of 'mixed' is an authoring error
else // unsupported use of 'mixed' is an authoring error
*aState |= aData.mPermanentState | aData.mFalseState;
return;
}

View File

@@ -21,8 +21,7 @@ namespace aria {
/**
* List of the ARIA state mapping rules.
*/
enum EStateRule
{
enum EStateRule {
eARIANone,
eARIAAutoComplete,
eARIABusy,
@@ -61,8 +60,8 @@ enum EStateRule
*/
bool MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState);
} // namespace aria
} // namespace a11y
} // namespace mozilla
} // namespace aria
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -19,7 +19,7 @@ using namespace mozilla;
using namespace mozilla::a11y;
static_assert(static_cast<bool>(eNoUserInput) == false &&
static_cast<bool>(eFromUserInput) == true,
static_cast<bool>(eFromUserInput) == true,
"EIsFromUserInput cannot be casted to bool");
////////////////////////////////////////////////////////////////////////////////
@@ -30,9 +30,8 @@ static_assert(static_cast<bool>(eNoUserInput) == false &&
// AccEvent constructors
AccEvent::AccEvent(uint32_t aEventType, Accessible* aAccessible,
EIsFromUserInput aIsFromUserInput, EEventRule aEventRule) :
mEventType(aEventType), mEventRule(aEventRule), mAccessible(aAccessible)
{
EIsFromUserInput aIsFromUserInput, EEventRule aEventRule)
: mEventType(aEventType), mEventRule(aEventRule), mAccessible(aAccessible) {
if (aIsFromUserInput == eAutoDetect)
mIsFromUserInput = EventStateManager::IsHandlingUserInput();
else
@@ -75,84 +74,78 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AccEvent, Release)
// we are ready to fire the event and so we will no longer assert at that point
// if the node was removed from the document. Either way, the AT won't work with
// a defunct accessible so the behaviour should be equivalent.
AccTextChangeEvent::
AccTextChangeEvent(Accessible* aAccessible, int32_t aStart,
const nsAString& aModifiedText, bool aIsInserted,
EIsFromUserInput aIsFromUserInput)
: AccEvent(aIsInserted ?
static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_INSERTED) :
static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_REMOVED),
aAccessible, aIsFromUserInput, eAllowDupes)
, mStart(aStart)
, mIsInserted(aIsInserted)
, mModifiedText(aModifiedText)
{
AccTextChangeEvent::AccTextChangeEvent(Accessible* aAccessible, int32_t aStart,
const nsAString& aModifiedText,
bool aIsInserted,
EIsFromUserInput aIsFromUserInput)
: AccEvent(
aIsInserted
? static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_INSERTED)
: static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_REMOVED),
aAccessible, aIsFromUserInput, eAllowDupes),
mStart(aStart),
mIsInserted(aIsInserted),
mModifiedText(aModifiedText) {
// XXX We should use IsFromUserInput here, but that isn't always correct
// when the text change isn't related to content insertion or removal.
mIsFromUserInput = mAccessible->State() &
(states::FOCUSED | states::EDITABLE);
mIsFromUserInput =
mAccessible->State() & (states::FOCUSED | states::EDITABLE);
}
////////////////////////////////////////////////////////////////////////////////
// AccHideEvent
////////////////////////////////////////////////////////////////////////////////
AccHideEvent::
AccHideEvent(Accessible* aTarget, bool aNeedsShutdown) :
AccMutationEvent(::nsIAccessibleEvent::EVENT_HIDE, aTarget),
mNeedsShutdown(aNeedsShutdown)
{
AccHideEvent::AccHideEvent(Accessible* aTarget, bool aNeedsShutdown)
: AccMutationEvent(::nsIAccessibleEvent::EVENT_HIDE, aTarget),
mNeedsShutdown(aNeedsShutdown) {
mNextSibling = mAccessible->NextSibling();
mPrevSibling = mAccessible->PrevSibling();
}
////////////////////////////////////////////////////////////////////////////////
// AccShowEvent
////////////////////////////////////////////////////////////////////////////////
AccShowEvent::
AccShowEvent(Accessible* aTarget) :
AccMutationEvent(::nsIAccessibleEvent::EVENT_SHOW, aTarget)
{
AccShowEvent::AccShowEvent(Accessible* aTarget)
: AccMutationEvent(::nsIAccessibleEvent::EVENT_SHOW, aTarget) {
int32_t idx = aTarget->IndexInParent();
MOZ_ASSERT(idx >= 0);
mInsertionIndex = idx;
}
////////////////////////////////////////////////////////////////////////////////
// AccTextSelChangeEvent
////////////////////////////////////////////////////////////////////////////////
AccTextSelChangeEvent::AccTextSelChangeEvent(HyperTextAccessible* aTarget,
dom::Selection* aSelection,
int32_t aReason) :
AccEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED, aTarget,
eAutoDetect, eCoalesceTextSelChange),
mSel(aSelection), mReason(aReason) {}
int32_t aReason)
: AccEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED, aTarget,
eAutoDetect, eCoalesceTextSelChange),
mSel(aSelection),
mReason(aReason) {}
AccTextSelChangeEvent::~AccTextSelChangeEvent() { }
AccTextSelChangeEvent::~AccTextSelChangeEvent() {}
bool
AccTextSelChangeEvent::IsCaretMoveOnly() const
{
bool AccTextSelChangeEvent::IsCaretMoveOnly() const {
return mSel->RangeCount() == 1 && mSel->IsCollapsed() &&
((mReason & (nsISelectionListener::COLLAPSETOSTART_REASON |
nsISelectionListener::COLLAPSETOEND_REASON)) == 0);
((mReason & (nsISelectionListener::COLLAPSETOSTART_REASON |
nsISelectionListener::COLLAPSETOEND_REASON)) == 0);
}
////////////////////////////////////////////////////////////////////////////////
// AccSelChangeEvent
////////////////////////////////////////////////////////////////////////////////
AccSelChangeEvent::
AccSelChangeEvent(Accessible* aWidget, Accessible* aItem,
SelChangeType aSelChangeType) :
AccEvent(0, aItem, eAutoDetect, eCoalesceSelectionChange),
mWidget(aWidget), mItem(aItem), mSelChangeType(aSelChangeType),
mPreceedingCount(0), mPackedEvent(nullptr)
{
AccSelChangeEvent::AccSelChangeEvent(Accessible* aWidget, Accessible* aItem,
SelChangeType aSelChangeType)
: AccEvent(0, aItem, eAutoDetect, eCoalesceSelectionChange),
mWidget(aWidget),
mItem(aItem),
mSelChangeType(aSelChangeType),
mPreceedingCount(0),
mPackedEvent(nullptr) {
if (aSelChangeType == eSelectionAdd) {
if (mWidget->GetSelectedItem(1))
mEventType = nsIAccessibleEvent::EVENT_SELECTION_ADD;
@@ -163,44 +156,41 @@ AccSelChangeEvent::
}
}
////////////////////////////////////////////////////////////////////////////////
// AccTableChangeEvent
////////////////////////////////////////////////////////////////////////////////
AccTableChangeEvent::
AccTableChangeEvent(Accessible* aAccessible, uint32_t aEventType,
int32_t aRowOrColIndex, int32_t aNumRowsOrCols) :
AccEvent(aEventType, aAccessible),
mRowOrColIndex(aRowOrColIndex), mNumRowsOrCols(aNumRowsOrCols)
{
}
AccTableChangeEvent::AccTableChangeEvent(Accessible* aAccessible,
uint32_t aEventType,
int32_t aRowOrColIndex,
int32_t aNumRowsOrCols)
: AccEvent(aEventType, aAccessible),
mRowOrColIndex(aRowOrColIndex),
mNumRowsOrCols(aNumRowsOrCols) {}
////////////////////////////////////////////////////////////////////////////////
// AccVCChangeEvent
////////////////////////////////////////////////////////////////////////////////
AccVCChangeEvent::
AccVCChangeEvent(Accessible* aAccessible,
Accessible* aOldAccessible,
int32_t aOldStart, int32_t aOldEnd,
Accessible* aNewAccessible,
int32_t aNewStart, int32_t aNewEnd,
int16_t aReason, int16_t aBoundaryType,
EIsFromUserInput aIsFromUserInput) :
AccEvent(::nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED, aAccessible,
aIsFromUserInput),
mOldAccessible(aOldAccessible), mNewAccessible(aNewAccessible),
mOldStart(aOldStart), mNewStart(aNewStart),
mOldEnd(aOldEnd), mNewEnd(aNewEnd),
mReason(aReason), mBoundaryType(aBoundaryType)
{
}
AccVCChangeEvent::AccVCChangeEvent(Accessible* aAccessible,
Accessible* aOldAccessible,
int32_t aOldStart, int32_t aOldEnd,
Accessible* aNewAccessible,
int32_t aNewStart, int32_t aNewEnd,
int16_t aReason, int16_t aBoundaryType,
EIsFromUserInput aIsFromUserInput)
: AccEvent(::nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED, aAccessible,
aIsFromUserInput),
mOldAccessible(aOldAccessible),
mNewAccessible(aNewAccessible),
mOldStart(aOldStart),
mNewStart(aNewStart),
mOldEnd(aOldEnd),
mNewEnd(aNewEnd),
mReason(aReason),
mBoundaryType(aBoundaryType) {}
already_AddRefed<nsIAccessibleEvent>
a11y::MakeXPCEvent(AccEvent* aEvent)
{
already_AddRefed<nsIAccessibleEvent> a11y::MakeXPCEvent(AccEvent* aEvent) {
DocAccessible* doc = aEvent->Document();
Accessible* acc = aEvent->GetAccessible();
nsINode* node = acc->GetNode();
@@ -214,8 +204,8 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
bool extra = false;
uint32_t state = nsAccUtils::To32States(sc->GetState(), &extra);
xpEvent = new xpcAccStateChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
node, fromUser,
state, extra, sc->IsStateEnabled());
node, fromUser, state, extra,
sc->IsStateEnabled());
return xpEvent.forget();
}
@@ -223,18 +213,16 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
AccTextChangeEvent* tc = downcast_accEvent(aEvent);
nsString text;
tc->GetModifiedText(text);
xpEvent = new xpcAccTextChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
node, fromUser,
tc->GetStartOffset(), tc->GetLength(),
tc->IsTextInserted(), text);
xpEvent = new xpcAccTextChangeEvent(
type, ToXPC(acc), ToXPCDocument(doc), node, fromUser,
tc->GetStartOffset(), tc->GetLength(), tc->IsTextInserted(), text);
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eHideEvent)) {
AccHideEvent* hideEvent = downcast_accEvent(aEvent);
xpEvent = new xpcAccHideEvent(type, ToXPC(acc), ToXPCDocument(doc),
node, fromUser,
ToXPC(hideEvent->TargetParent()),
xpEvent = new xpcAccHideEvent(type, ToXPC(acc), ToXPCDocument(doc), node,
fromUser, ToXPC(hideEvent->TargetParent()),
ToXPC(hideEvent->TargetNextSibling()),
ToXPC(hideEvent->TargetPrevSibling()));
return xpEvent.forget();
@@ -243,24 +231,17 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
if (eventGroup & (1 << AccEvent::eCaretMoveEvent)) {
AccCaretMoveEvent* cm = downcast_accEvent(aEvent);
xpEvent = new xpcAccCaretMoveEvent(type, ToXPC(acc), ToXPCDocument(doc),
node, fromUser,
cm->GetCaretOffset());
node, fromUser, cm->GetCaretOffset());
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eVirtualCursorChangeEvent)) {
AccVCChangeEvent* vcc = downcast_accEvent(aEvent);
xpEvent = new xpcAccVirtualCursorChangeEvent(type,
ToXPC(acc), ToXPCDocument(doc),
node, fromUser,
ToXPC(vcc->OldAccessible()),
vcc->OldStartOffset(),
vcc->OldEndOffset(),
ToXPC(vcc->NewAccessible()),
vcc->NewStartOffset(),
vcc->NewEndOffset(),
vcc->Reason(),
vcc->BoundaryType());
xpEvent = new xpcAccVirtualCursorChangeEvent(
type, ToXPC(acc), ToXPCDocument(doc), node, fromUser,
ToXPC(vcc->OldAccessible()), vcc->OldStartOffset(), vcc->OldEndOffset(),
ToXPC(vcc->NewAccessible()), vcc->NewStartOffset(), vcc->NewEndOffset(),
vcc->Reason(), vcc->BoundaryType());
return xpEvent.forget();
}
@@ -268,21 +249,19 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
AccObjectAttrChangedEvent* oac = downcast_accEvent(aEvent);
nsString attribute;
oac->GetAttribute()->ToString(attribute);
xpEvent = new xpcAccObjectAttributeChangedEvent(type,
ToXPC(acc),
ToXPCDocument(doc), node,
fromUser,
attribute);
xpEvent = new xpcAccObjectAttributeChangedEvent(
type, ToXPC(acc), ToXPCDocument(doc), node, fromUser, attribute);
return xpEvent.forget();
}
if (eventGroup & (1 << AccEvent::eScrollingEvent)) {
AccScrollingEvent* sa = downcast_accEvent(aEvent);
xpEvent = new xpcAccScrollingEvent(type, ToXPC(acc), ToXPCDocument(doc), node,
fromUser, sa->ScrollX(), sa->ScrollY(),
sa->MaxScrollX(), sa->MaxScrollY());
xpEvent = new xpcAccScrollingEvent(
type, ToXPC(acc), ToXPCDocument(doc), node, fromUser, sa->ScrollX(),
sa->ScrollY(), sa->MaxScrollX(), sa->MaxScrollY());
}
xpEvent = new xpcAccEvent(type, ToXPC(acc), ToXPCDocument(doc), node, fromUser);
xpEvent =
new xpcAccEvent(type, ToXPC(acc), ToXPCDocument(doc), node, fromUser);
return xpEvent.forget();
}
}

View File

@@ -22,8 +22,7 @@ namespace a11y {
class DocAccessible;
// Constants used to point whether the event is from user input.
enum EIsFromUserInput
{
enum EIsFromUserInput {
// eNoUserInput: event is not from user input
eNoUserInput = 0,
// eFromUserInput: event is from user input
@@ -35,10 +34,8 @@ enum EIsFromUserInput
/**
* Generic accessible event.
*/
class AccEvent
{
public:
class AccEvent {
public:
// Rule for accessible events.
// The rule will be applied when flushing pending events.
enum EEventRule {
@@ -47,8 +44,8 @@ public:
// don't support coalescence.
eAllowDupes,
// eCoalesceReorder : For reorder events from the same subtree or the same
// node, only the umbrella event on the ancestor will be emitted.
// eCoalesceReorder : For reorder events from the same subtree or the same
// node, only the umbrella event on the ancestor will be emitted.
eCoalesceReorder,
// eCoalesceOfSameType : For events of the same type, only the newest event
@@ -64,11 +61,11 @@ public:
// eCoalesceTextSelChange: coalescence of text selection change events.
eCoalesceTextSelChange,
// eRemoveDupes : For repeat events, only the newest event in queue
// will be emitted.
// eRemoveDupes : For repeat events, only the newest event in queue
// will be emitted.
eRemoveDupes,
// eDoNotEmit : This event is confirmed as a duplicate, do not emit it.
// eDoNotEmit : This event is confirmed as a duplicate, do not emit it.
eDoNotEmit
};
@@ -81,8 +78,9 @@ public:
uint32_t GetEventType() const { return mEventType; }
EEventRule GetEventRule() const { return mEventRule; }
bool IsFromUserInput() const { return mIsFromUserInput; }
EIsFromUserInput FromUserInput() const
{ return static_cast<EIsFromUserInput>(mIsFromUserInput); }
EIsFromUserInput FromUserInput() const {
return static_cast<EIsFromUserInput>(mIsFromUserInput);
}
Accessible* GetAccessible() const { return mAccessible; }
DocAccessible* Document() const { return mAccessible->Document(); }
@@ -109,10 +107,7 @@ public:
};
static const EventGroup kEventGroup = eGenericEvent;
virtual unsigned int GetEventGroups() const
{
return 1U << eGenericEvent;
}
virtual unsigned int GetEventGroups() const { return 1U << eGenericEvent; }
/**
* Reference counting and cycle collection.
@@ -120,7 +115,7 @@ public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AccEvent)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(AccEvent)
protected:
protected:
virtual ~AccEvent() {}
bool mIsFromUserInput;
@@ -134,29 +129,28 @@ protected:
friend class NotificationController;
};
/**
* Accessible state change event.
*/
class AccStateChangeEvent: public AccEvent
{
public:
AccStateChangeEvent(Accessible* aAccessible, uint64_t aState,
bool aIsEnabled,
EIsFromUserInput aIsFromUserInput = eAutoDetect) :
AccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
aIsFromUserInput, eCoalesceStateChange),
mState(aState), mIsEnabled(aIsEnabled) { }
class AccStateChangeEvent : public AccEvent {
public:
AccStateChangeEvent(Accessible* aAccessible, uint64_t aState, bool aIsEnabled,
EIsFromUserInput aIsFromUserInput = eAutoDetect)
: AccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
aIsFromUserInput, eCoalesceStateChange),
mState(aState),
mIsEnabled(aIsEnabled) {}
AccStateChangeEvent(Accessible* aAccessible, uint64_t aState) :
AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
eAutoDetect, eCoalesceStateChange), mState(aState)
{ mIsEnabled = (mAccessible->State() & mState) != 0; }
AccStateChangeEvent(Accessible* aAccessible, uint64_t aState)
: AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
eAutoDetect, eCoalesceStateChange),
mState(aState) {
mIsEnabled = (mAccessible->State() & mState) != 0;
}
// AccEvent
static const EventGroup kEventGroup = eStateChangeEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eStateChangeEvent);
}
@@ -164,28 +158,25 @@ public:
uint64_t GetState() const { return mState; }
bool IsStateEnabled() const { return mIsEnabled; }
private:
private:
uint64_t mState;
bool mIsEnabled;
friend class EventQueue;
};
/**
* Accessible text change event.
*/
class AccTextChangeEvent: public AccEvent
{
public:
class AccTextChangeEvent : public AccEvent {
public:
AccTextChangeEvent(Accessible* aAccessible, int32_t aStart,
const nsAString& aModifiedText, bool aIsInserted,
EIsFromUserInput aIsFromUserInput = eAutoDetect);
// AccEvent
static const EventGroup kEventGroup = eTextChangeEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eTextChangeEvent);
}
@@ -193,11 +184,12 @@ public:
int32_t GetStartOffset() const { return mStart; }
uint32_t GetLength() const { return mModifiedText.Length(); }
bool IsTextInserted() const { return mIsInserted; }
void GetModifiedText(nsAString& aModifiedText)
{ aModifiedText = mModifiedText; }
void GetModifiedText(nsAString& aModifiedText) {
aModifiedText = mModifiedText;
}
const nsString& ModifiedText() const { return mModifiedText; }
private:
private:
int32_t mStart;
bool mIsInserted;
nsString mModifiedText;
@@ -210,16 +202,15 @@ private:
* A base class for events related to tree mutation, either an AccMutation
* event, or an AccReorderEvent.
*/
class AccTreeMutationEvent : public AccEvent
{
public:
AccTreeMutationEvent(uint32_t aEventType, Accessible* aTarget) :
AccEvent(aEventType, aTarget, eAutoDetect, eCoalesceReorder), mGeneration(0) {}
class AccTreeMutationEvent : public AccEvent {
public:
AccTreeMutationEvent(uint32_t aEventType, Accessible* aTarget)
: AccEvent(aEventType, aTarget, eAutoDetect, eCoalesceReorder),
mGeneration(0) {}
// Event
static const EventGroup kEventGroup = eTreeMutationEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eTreeMutationEvent);
}
@@ -234,7 +225,7 @@ public:
uint32_t EventGeneration() const { return mGeneration; }
void SetEventGeneration(uint32_t aGeneration) { mGeneration = aGeneration; }
private:
private:
RefPtr<AccTreeMutationEvent> mNextEvent;
RefPtr<AccTreeMutationEvent> mPrevEvent;
uint32_t mGeneration;
@@ -243,22 +234,19 @@ private:
/**
* Base class for show and hide accessible events.
*/
class AccMutationEvent: public AccTreeMutationEvent
{
public:
AccMutationEvent(uint32_t aEventType, Accessible* aTarget) :
AccTreeMutationEvent(aEventType, aTarget)
{
class AccMutationEvent : public AccTreeMutationEvent {
public:
AccMutationEvent(uint32_t aEventType, Accessible* aTarget)
: AccTreeMutationEvent(aEventType, aTarget) {
// Don't coalesce these since they are coalesced by reorder event. Coalesce
// contained text change events.
mParent = mAccessible->Parent();
}
virtual ~AccMutationEvent() { }
virtual ~AccMutationEvent() {}
// Event
static const EventGroup kEventGroup = eMutationEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccTreeMutationEvent::GetEventGroups() | (1U << eMutationEvent);
}
@@ -268,7 +256,7 @@ public:
Accessible* Parent() const { return mParent; }
protected:
protected:
nsCOMPtr<nsINode> mNode;
RefPtr<Accessible> mParent;
RefPtr<AccTextChangeEvent> mTextChangeEvent;
@@ -277,19 +265,16 @@ protected:
friend class NotificationController;
};
/**
* Accessible hide event.
*/
class AccHideEvent: public AccMutationEvent
{
public:
class AccHideEvent : public AccMutationEvent {
public:
explicit AccHideEvent(Accessible* aTarget, bool aNeedsShutdown = true);
// Event
static const EventGroup kEventGroup = eHideEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccMutationEvent::GetEventGroups() | (1U << eHideEvent);
}
@@ -299,7 +284,7 @@ public:
Accessible* TargetPrevSibling() const { return mPrevSibling; }
bool NeedsShutdown() const { return mNeedsShutdown; }
protected:
protected:
bool mNeedsShutdown;
RefPtr<Accessible> mNextSibling;
RefPtr<Accessible> mPrevSibling;
@@ -308,94 +293,81 @@ protected:
friend class NotificationController;
};
/**
* Accessible show event.
*/
class AccShowEvent: public AccMutationEvent
{
public:
class AccShowEvent : public AccMutationEvent {
public:
explicit AccShowEvent(Accessible* aTarget);
// Event
static const EventGroup kEventGroup = eShowEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccMutationEvent::GetEventGroups() | (1U << eShowEvent);
}
uint32_t InsertionIndex() const { return mInsertionIndex; }
private:
private:
nsTArray<RefPtr<AccHideEvent>> mPrecedingEvents;
uint32_t mInsertionIndex;
friend class EventTree;
};
/**
* Class for reorder accessible event. Takes care about
*/
class AccReorderEvent : public AccTreeMutationEvent
{
public:
explicit AccReorderEvent(Accessible* aTarget) :
AccTreeMutationEvent(::nsIAccessibleEvent::EVENT_REORDER, aTarget) { }
virtual ~AccReorderEvent() { }
class AccReorderEvent : public AccTreeMutationEvent {
public:
explicit AccReorderEvent(Accessible* aTarget)
: AccTreeMutationEvent(::nsIAccessibleEvent::EVENT_REORDER, aTarget) {}
virtual ~AccReorderEvent() {}
// Event
static const EventGroup kEventGroup = eReorderEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccTreeMutationEvent::GetEventGroups() | (1U << eReorderEvent);
}
};
/**
* Accessible caret move event.
*/
class AccCaretMoveEvent: public AccEvent
{
public:
class AccCaretMoveEvent : public AccEvent {
public:
AccCaretMoveEvent(Accessible* aAccessible, int32_t aCaretOffset,
EIsFromUserInput aIsFromUserInput = eAutoDetect) :
AccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aAccessible,
aIsFromUserInput),
mCaretOffset(aCaretOffset) { }
virtual ~AccCaretMoveEvent() { }
EIsFromUserInput aIsFromUserInput = eAutoDetect)
: AccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aAccessible,
aIsFromUserInput),
mCaretOffset(aCaretOffset) {}
virtual ~AccCaretMoveEvent() {}
// AccEvent
static const EventGroup kEventGroup = eCaretMoveEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eCaretMoveEvent);
}
// AccCaretMoveEvent
int32_t GetCaretOffset() const { return mCaretOffset; }
private:
private:
int32_t mCaretOffset;
};
/**
* Accessible text selection change event.
*/
class AccTextSelChangeEvent : public AccEvent
{
public:
class AccTextSelChangeEvent : public AccEvent {
public:
AccTextSelChangeEvent(HyperTextAccessible* aTarget,
dom::Selection* aSelection,
int32_t aReason);
dom::Selection* aSelection, int32_t aReason);
virtual ~AccTextSelChangeEvent();
// AccEvent
static const EventGroup kEventGroup = eTextSelChangeEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eTextSelChangeEvent);
}
@@ -406,7 +378,7 @@ public:
*/
bool IsCaretMoveOnly() const;
private:
private:
RefPtr<dom::Selection> mSel;
int32_t mReason;
@@ -414,34 +386,28 @@ private:
friend class SelectionManager;
};
/**
* Accessible widget selection change event.
*/
class AccSelChangeEvent : public AccEvent
{
public:
enum SelChangeType {
eSelectionAdd,
eSelectionRemove
};
class AccSelChangeEvent : public AccEvent {
public:
enum SelChangeType { eSelectionAdd, eSelectionRemove };
AccSelChangeEvent(Accessible* aWidget, Accessible* aItem,
SelChangeType aSelChangeType);
virtual ~AccSelChangeEvent() { }
virtual ~AccSelChangeEvent() {}
// AccEvent
static const EventGroup kEventGroup = eSelectionChangeEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eSelectionChangeEvent);
}
// AccSelChangeEvent
Accessible* Widget() const { return mWidget; }
private:
private:
RefPtr<Accessible> mWidget;
RefPtr<Accessible> mItem;
SelChangeType mSelChangeType;
@@ -451,20 +417,17 @@ private:
friend class EventQueue;
};
/**
* Accessible table change event.
*/
class AccTableChangeEvent : public AccEvent
{
public:
class AccTableChangeEvent : public AccEvent {
public:
AccTableChangeEvent(Accessible* aAccessible, uint32_t aEventType,
int32_t aRowOrColIndex, int32_t aNumRowsOrCols);
// AccEvent
static const EventGroup kEventGroup = eTableChangeEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eTableChangeEvent);
}
@@ -472,32 +435,28 @@ public:
uint32_t GetIndex() const { return mRowOrColIndex; }
uint32_t GetCount() const { return mNumRowsOrCols; }
private:
uint32_t mRowOrColIndex; // the start row/column after which the rows are inserted/deleted.
uint32_t mNumRowsOrCols; // the number of inserted/deleted rows/columns
private:
uint32_t mRowOrColIndex; // the start row/column after which the rows are
// inserted/deleted.
uint32_t mNumRowsOrCols; // the number of inserted/deleted rows/columns
};
/**
* Accessible virtual cursor change event.
*/
class AccVCChangeEvent : public AccEvent
{
public:
AccVCChangeEvent(Accessible* aAccessible,
Accessible* aOldAccessible,
class AccVCChangeEvent : public AccEvent {
public:
AccVCChangeEvent(Accessible* aAccessible, Accessible* aOldAccessible,
int32_t aOldStart, int32_t aOldEnd,
Accessible* aNewAccessible,
int32_t aNewStart, int32_t aNewEnd,
int16_t aReason,
int16_t aBoundaryType,
Accessible* aNewAccessible, int32_t aNewStart,
int32_t aNewEnd, int16_t aReason, int16_t aBoundaryType,
EIsFromUserInput aIsFromUserInput = eFromUserInput);
virtual ~AccVCChangeEvent() { }
virtual ~AccVCChangeEvent() {}
// AccEvent
static const EventGroup kEventGroup = eVirtualCursorChangeEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eVirtualCursorChangeEvent);
}
@@ -511,7 +470,7 @@ public:
int32_t Reason() const { return mReason; }
int32_t BoundaryType() const { return mBoundaryType; }
private:
private:
RefPtr<Accessible> mOldAccessible;
RefPtr<Accessible> mNewAccessible;
int32_t mOldStart;
@@ -525,50 +484,47 @@ private:
/**
* Accessible object attribute changed event.
*/
class AccObjectAttrChangedEvent: public AccEvent
{
public:
AccObjectAttrChangedEvent(Accessible* aAccessible, nsAtom* aAttribute) :
AccEvent(::nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED, aAccessible),
mAttribute(aAttribute) { }
class AccObjectAttrChangedEvent : public AccEvent {
public:
AccObjectAttrChangedEvent(Accessible* aAccessible, nsAtom* aAttribute)
: AccEvent(::nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
aAccessible),
mAttribute(aAttribute) {}
// AccEvent
static const EventGroup kEventGroup = eObjectAttrChangedEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eObjectAttrChangedEvent);
}
// AccObjectAttrChangedEvent
nsAtom* GetAttribute() const { return mAttribute; }
private:
private:
RefPtr<nsAtom> mAttribute;
virtual ~AccObjectAttrChangedEvent() { }
virtual ~AccObjectAttrChangedEvent() {}
};
/**
* Accessible scroll event.
*/
class AccScrollingEvent : public AccEvent
{
public:
class AccScrollingEvent : public AccEvent {
public:
AccScrollingEvent(uint32_t aEventType, Accessible* aAccessible,
uint32_t aScrollX, uint32_t aScrollY,
uint32_t aMaxScrollX, uint32_t aMaxScrollY) :
AccEvent(aEventType, aAccessible),
mScrollX(aScrollX),
mScrollY(aScrollY),
mMaxScrollX(aMaxScrollX),
mMaxScrollY(aMaxScrollY) { }
uint32_t aScrollX, uint32_t aScrollY, uint32_t aMaxScrollX,
uint32_t aMaxScrollY)
: AccEvent(aEventType, aAccessible),
mScrollX(aScrollX),
mScrollY(aScrollY),
mMaxScrollX(aMaxScrollX),
mMaxScrollY(aMaxScrollY) {}
virtual ~AccScrollingEvent() { }
virtual ~AccScrollingEvent() {}
// AccEvent
static const EventGroup kEventGroup = eScrollingEvent;
virtual unsigned int GetEventGroups() const override
{
virtual unsigned int GetEventGroups() const override {
return AccEvent::GetEventGroups() | (1U << eScrollingEvent);
}
@@ -581,7 +537,7 @@ public:
// The max Y offset of the container.
uint32_t MaxScrollY() { return mMaxScrollY; }
private:
private:
uint32_t mScrollX;
uint32_t mScrollY;
uint32_t mMaxScrollX;
@@ -591,31 +547,29 @@ private:
/**
* Downcast the generic accessible event object to derived type.
*/
class downcast_accEvent
{
public:
explicit downcast_accEvent(AccEvent* e) : mRawPtr(e) { }
class downcast_accEvent {
public:
explicit downcast_accEvent(AccEvent* e) : mRawPtr(e) {}
template<class Destination>
template <class Destination>
operator Destination*() {
if (!mRawPtr)
return nullptr;
if (!mRawPtr) return nullptr;
return mRawPtr->GetEventGroups() & (1U << Destination::kEventGroup) ?
static_cast<Destination*>(mRawPtr) : nullptr;
return mRawPtr->GetEventGroups() & (1U << Destination::kEventGroup)
? static_cast<Destination*>(mRawPtr)
: nullptr;
}
private:
private:
AccEvent* mRawPtr;
};
/**
* Return a new xpcom accessible event for the given internal one.
*/
already_AddRefed<nsIAccessibleEvent>
MakeXPCEvent(AccEvent* aEvent);
already_AddRefed<nsIAccessibleEvent> MakeXPCEvent(AccEvent* aEvent);
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -11,19 +11,15 @@
using namespace mozilla::a11y;
AccGroupInfo::AccGroupInfo(const Accessible* aItem, role aRole) :
mPosInSet(0), mSetSize(0), mParent(nullptr), mItem(aItem), mRole(aRole)
{
AccGroupInfo::AccGroupInfo(const Accessible* aItem, role aRole)
: mPosInSet(0), mSetSize(0), mParent(nullptr), mItem(aItem), mRole(aRole) {
MOZ_COUNT_CTOR(AccGroupInfo);
Update();
}
void
AccGroupInfo::Update()
{
void AccGroupInfo::Update() {
Accessible* parent = mItem->Parent();
if (!parent)
return;
if (!parent) return;
int32_t indexInParent = mItem->IndexInParent();
uint32_t siblingCount = parent->ChildCount();
@@ -37,13 +33,12 @@ AccGroupInfo::Update()
// Compute position in set.
mPosInSet = 1;
for (int32_t idx = indexInParent - 1; idx >= 0 ; idx--) {
for (int32_t idx = indexInParent - 1; idx >= 0; idx--) {
Accessible* sibling = parent->GetChildAt(idx);
roles::Role siblingRole = sibling->Role();
// If the sibling is separator then the group is ended.
if (siblingRole == roles::SEPARATOR)
break;
if (siblingRole == roles::SEPARATOR) break;
// If sibling is not visible and hasn't the same base role.
if (BaseRole(siblingRole) != mRole || sibling->State() & states::INVISIBLE)
@@ -60,8 +55,7 @@ AccGroupInfo::Update()
}
// Skip subset.
if (siblingLevel > level)
continue;
if (siblingLevel > level) continue;
// If the previous item in the group has calculated group information then
// build group information for this item based on found one.
@@ -84,8 +78,7 @@ AccGroupInfo::Update()
roles::Role siblingRole = sibling->Role();
// If the sibling is separator then the group is ended.
if (siblingRole == roles::SEPARATOR)
break;
if (siblingRole == roles::SEPARATOR) break;
// If sibling is visible and has the same base role
if (BaseRole(siblingRole) != mRole || sibling->State() & states::INVISIBLE)
@@ -93,12 +86,10 @@ AccGroupInfo::Update()
// and check if it's hierarchical flatten structure.
int32_t siblingLevel = nsAccUtils::GetARIAOrDefaultLevel(sibling);
if (siblingLevel < level)
break;
if (siblingLevel < level) break;
// Skip subset.
if (siblingLevel > level)
continue;
if (siblingLevel > level) continue;
// If the next item in the group has calculated group information then
// build group information for this item based on found one.
@@ -111,16 +102,13 @@ AccGroupInfo::Update()
mSetSize++;
}
if (mParent)
return;
if (mParent) return;
roles::Role parentRole = parent->Role();
if (ShouldReportRelations(mRole, parentRole))
mParent = parent;
if (ShouldReportRelations(mRole, parentRole)) mParent = parent;
// ARIA tree and list can be arranged by using ARIA groups to organize levels.
if (parentRole != roles::GROUPING)
return;
if (parentRole != roles::GROUPING) return;
// Way #1 for ARIA tree (not ARIA treegrid): previous sibling of a group is a
// parent. In other words the parent of the tree item will be a group and
@@ -139,14 +127,11 @@ AccGroupInfo::Update()
// a conceptual parent of the item.
if (mRole == roles::LISTITEM || mRole == roles::OUTLINEITEM) {
Accessible* grandParent = parent->Parent();
if (grandParent && grandParent->Role() == mRole)
mParent = grandParent;
if (grandParent && grandParent->Role() == mRole) mParent = grandParent;
}
}
Accessible*
AccGroupInfo::FirstItemOf(const Accessible* aContainer)
{
Accessible* AccGroupInfo::FirstItemOf(const Accessible* aContainer) {
// ARIA tree can be arranged by ARIA groups case #1 (previous sibling of a
// group is a parent) or by aria-level.
a11y::role containerRole = aContainer->Role();
@@ -165,11 +150,11 @@ AccGroupInfo::FirstItemOf(const Accessible* aContainer)
// ARIA list and tree can be arranged by ARIA groups case #2 (group is
// a child of an item).
item = aContainer->LastChild();
if (!item)
return nullptr;
if (!item) return nullptr;
if (item->Role() == roles::GROUPING &&
(containerRole == roles::LISTITEM || containerRole == roles::OUTLINEITEM)) {
(containerRole == roles::LISTITEM ||
containerRole == roles::OUTLINEITEM)) {
item = item->FirstChild();
if (item) {
AccGroupInfo* itemGroupInfo = item->GetGroupInfo();
@@ -180,15 +165,13 @@ AccGroupInfo::FirstItemOf(const Accessible* aContainer)
// Otherwise, it can be a direct child if the container is a list or tree.
item = aContainer->FirstChild();
if (ShouldReportRelations(item->Role(), containerRole))
return item;
if (ShouldReportRelations(item->Role(), containerRole)) return item;
return nullptr;
}
uint32_t
AccGroupInfo::TotalItemCount(Accessible* aContainer, bool* aIsHierarchical)
{
uint32_t AccGroupInfo::TotalItemCount(Accessible* aContainer,
bool* aIsHierarchical) {
uint32_t itemCount = 0;
switch (aContainer->Role()) {
case roles::TABLE:
@@ -255,16 +238,12 @@ AccGroupInfo::TotalItemCount(Accessible* aContainer, bool* aIsHierarchical)
return itemCount;
}
Accessible*
AccGroupInfo::NextItemTo(Accessible* aItem)
{
Accessible* AccGroupInfo::NextItemTo(Accessible* aItem) {
AccGroupInfo* groupInfo = aItem->GetGroupInfo();
if (!groupInfo)
return nullptr;
if (!groupInfo) return nullptr;
// If the item in middle of the group then search next item in siblings.
if (groupInfo->PosInSet() >= groupInfo->SetSize())
return nullptr;
if (groupInfo->PosInSet() >= groupInfo->SetSize()) return nullptr;
Accessible* parent = aItem->Parent();
uint32_t childCount = parent->ChildCount();
@@ -277,21 +256,17 @@ AccGroupInfo::NextItemTo(Accessible* aItem)
}
}
MOZ_ASSERT_UNREACHABLE("Item in the middle of the group but there's no next item!");
MOZ_ASSERT_UNREACHABLE(
"Item in the middle of the group but there's no next item!");
return nullptr;
}
bool
AccGroupInfo::ShouldReportRelations(role aRole, role aParentRole)
{
bool AccGroupInfo::ShouldReportRelations(role aRole, role aParentRole) {
// We only want to report hierarchy-based node relations for items in tree or
// list form. ARIA level/owns relations are always reported.
if (aParentRole == roles::OUTLINE && aRole == roles::OUTLINEITEM)
return true;
if (aParentRole == roles::TREE_TABLE && aRole == roles::ROW)
return true;
if (aParentRole == roles::LIST && aRole == roles::LISTITEM)
return true;
if (aParentRole == roles::OUTLINE && aRole == roles::OUTLINEITEM) return true;
if (aParentRole == roles::TREE_TABLE && aRole == roles::ROW) return true;
if (aParentRole == roles::LIST && aRole == roles::LISTITEM) return true;
return false;
}

View File

@@ -13,9 +13,8 @@ namespace a11y {
/**
* Calculate and store group information.
*/
class AccGroupInfo
{
public:
class AccGroupInfo {
public:
~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); }
/**
@@ -42,8 +41,7 @@ public:
/**
* Create group info.
*/
static AccGroupInfo* CreateGroupInfo(const Accessible* aAccessible)
{
static AccGroupInfo* CreateGroupInfo(const Accessible* aAccessible) {
mozilla::a11y::role role = aAccessible->Role();
if (role != mozilla::a11y::roles::ROW &&
role != mozilla::a11y::roles::OUTLINEITEM &&
@@ -70,7 +68,8 @@ public:
static Accessible* FirstItemOf(const Accessible* aContainer);
/**
* Return total number of items in container, and if it is has nested collections.
* Return total number of items in container, and if it is has nested
* collections.
*/
static uint32_t TotalItemCount(Accessible* aContainer, bool* aIsHierarchical);
@@ -79,16 +78,15 @@ public:
*/
static Accessible* NextItemTo(Accessible* aItem);
protected:
protected:
AccGroupInfo(const Accessible* aItem, a11y::role aRole);
private:
private:
AccGroupInfo() = delete;
AccGroupInfo(const AccGroupInfo&) = delete;
AccGroupInfo& operator =(const AccGroupInfo&) = delete;
AccGroupInfo& operator=(const AccGroupInfo&) = delete;
static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole)
{
static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole) {
if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM ||
aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
@@ -113,7 +111,7 @@ private:
a11y::role mRole;
};
} // namespace mozilla
} // namespace a11y
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -19,24 +19,20 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
AccIterator::AccIterator(const Accessible* aAccessible,
filters::FilterFuncPtr aFilterFunc) :
mFilterFunc(aFilterFunc)
{
filters::FilterFuncPtr aFilterFunc)
: mFilterFunc(aFilterFunc) {
mState = new IteratorState(aAccessible);
}
AccIterator::~AccIterator()
{
AccIterator::~AccIterator() {
while (mState) {
IteratorState *tmp = mState;
IteratorState* tmp = mState;
mState = tmp->mParentState;
delete tmp;
}
}
Accessible*
AccIterator::Next()
{
Accessible* AccIterator::Next() {
while (mState) {
Accessible* child = mState->mParent->GetChildAt(mState->mIndex++);
if (!child) {
@@ -48,8 +44,7 @@ AccIterator::Next()
}
uint32_t result = mFilterFunc(child);
if (result & filters::eMatch)
return child;
if (result & filters::eMatch) return child;
if (!(result & filters::eSkipSubtree)) {
IteratorState* childState = new IteratorState(child, mState);
@@ -64,26 +59,25 @@ AccIterator::Next()
// nsAccIterator::IteratorState
AccIterator::IteratorState::IteratorState(const Accessible* aParent,
IteratorState *mParentState) :
mParent(aParent), mIndex(0), mParentState(mParentState)
{
}
IteratorState* mParentState)
: mParent(aParent), mIndex(0), mParentState(mParentState) {}
////////////////////////////////////////////////////////////////////////////////
// RelatedAccIterator
////////////////////////////////////////////////////////////////////////////////
RelatedAccIterator::
RelatedAccIterator(DocAccessible* aDocument, nsIContent* aDependentContent,
nsAtom* aRelAttr) :
mDocument(aDocument), mRelAttr(aRelAttr), mProviders(nullptr),
mBindingParent(nullptr), mIndex(0)
{
mBindingParent = aDependentContent->IsInAnonymousSubtree() ?
aDependentContent->GetBindingParent() : nullptr;
nsAtom* IDAttr = mBindingParent ?
nsGkAtoms::anonid : nsGkAtoms::id;
RelatedAccIterator::RelatedAccIterator(DocAccessible* aDocument,
nsIContent* aDependentContent,
nsAtom* aRelAttr)
: mDocument(aDocument),
mRelAttr(aRelAttr),
mProviders(nullptr),
mBindingParent(nullptr),
mIndex(0) {
mBindingParent = aDependentContent->IsInAnonymousSubtree()
? aDependentContent->GetBindingParent()
: nullptr;
nsAtom* IDAttr = mBindingParent ? nsGkAtoms::anonid : nsGkAtoms::id;
nsAutoString id;
if (aDependentContent->IsElement() &&
@@ -92,11 +86,8 @@ RelatedAccIterator::
}
}
Accessible*
RelatedAccIterator::Next()
{
if (!mProviders)
return nullptr;
Accessible* RelatedAccIterator::Next() {
if (!mProviders) return nullptr;
while (mIndex < mProviders->Length()) {
DocAccessible::AttrRelProvider* provider = (*mProviders)[mIndex++];
@@ -104,20 +95,19 @@ RelatedAccIterator::Next()
// Return related accessible for the given attribute and if the provider
// content is in the same binding in the case of XBL usage.
if (provider->mRelAttr == mRelAttr) {
nsIContent* bindingParent = provider->mContent->IsInAnonymousSubtree() ?
provider->mContent->GetBindingParent() : nullptr;
nsIContent* bindingParent = provider->mContent->IsInAnonymousSubtree()
? provider->mContent->GetBindingParent()
: nullptr;
bool inScope = mBindingParent == bindingParent ||
mBindingParent == provider->mContent;
mBindingParent == provider->mContent;
if (inScope) {
Accessible* related = mDocument->GetAccessible(provider->mContent);
if (related)
return related;
if (related) return related;
// If the document content is pointed by relation then return the document
// itself.
if (provider->mContent == mDocument->GetContent())
return mDocument;
// If the document content is pointed by relation then return the
// document itself.
if (provider->mContent == mDocument->GetContent()) return mDocument;
}
}
}
@@ -125,30 +115,24 @@ RelatedAccIterator::Next()
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLLabelIterator
////////////////////////////////////////////////////////////////////////////////
HTMLLabelIterator::
HTMLLabelIterator(DocAccessible* aDocument, const Accessible* aAccessible,
LabelFilter aFilter) :
mRelIter(aDocument, aAccessible->GetContent(), nsGkAtoms::_for),
mAcc(aAccessible), mLabelFilter(aFilter)
{
}
HTMLLabelIterator::HTMLLabelIterator(DocAccessible* aDocument,
const Accessible* aAccessible,
LabelFilter aFilter)
: mRelIter(aDocument, aAccessible->GetContent(), nsGkAtoms::_for),
mAcc(aAccessible),
mLabelFilter(aFilter) {}
bool
HTMLLabelIterator::IsLabel(Accessible* aLabel)
{
bool HTMLLabelIterator::IsLabel(Accessible* aLabel) {
dom::HTMLLabelElement* labelEl =
dom::HTMLLabelElement::FromNode(aLabel->GetContent());
dom::HTMLLabelElement::FromNode(aLabel->GetContent());
return labelEl && labelEl->GetControl() == mAcc->GetContent();
}
Accessible*
HTMLLabelIterator::Next()
{
Accessible* HTMLLabelIterator::Next() {
// Get either <label for="[id]"> element which explicitly points to given
// element, or <label> ancestor which implicitly point to it.
Accessible* label = nullptr;
@@ -159,8 +143,7 @@ HTMLLabelIterator::Next()
}
// Ignore ancestor label on not widget accessible.
if (mLabelFilter == eSkipAncestorLabel || !mAcc->IsWidget())
return nullptr;
if (mLabelFilter == eSkipAncestorLabel || !mAcc->IsWidget()) return nullptr;
// Go up tree to get a name of ancestor label if there is one (an ancestor
// <label> implicitly points to us). Don't go up farther than form or
@@ -170,12 +153,11 @@ HTMLLabelIterator::Next()
nsIContent* walkUpEl = walkUp->GetContent();
if (IsLabel(walkUp) &&
!walkUpEl->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
return walkUp;
}
if (walkUpEl->IsHTMLElement(nsGkAtoms::form))
break;
if (walkUpEl->IsHTMLElement(nsGkAtoms::form)) break;
walkUp = walkUp->Parent();
}
@@ -183,70 +165,52 @@ HTMLLabelIterator::Next()
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLOutputIterator
////////////////////////////////////////////////////////////////////////////////
HTMLOutputIterator::
HTMLOutputIterator(DocAccessible* aDocument, nsIContent* aElement) :
mRelIter(aDocument, aElement, nsGkAtoms::_for)
{
}
HTMLOutputIterator::HTMLOutputIterator(DocAccessible* aDocument,
nsIContent* aElement)
: mRelIter(aDocument, aElement, nsGkAtoms::_for) {}
Accessible*
HTMLOutputIterator::Next()
{
Accessible* HTMLOutputIterator::Next() {
Accessible* output = nullptr;
while ((output = mRelIter.Next())) {
if (output->GetContent()->IsHTMLElement(nsGkAtoms::output))
return output;
if (output->GetContent()->IsHTMLElement(nsGkAtoms::output)) return output;
}
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// XULLabelIterator
////////////////////////////////////////////////////////////////////////////////
XULLabelIterator::
XULLabelIterator(DocAccessible* aDocument, nsIContent* aElement) :
mRelIter(aDocument, aElement, nsGkAtoms::control)
{
}
XULLabelIterator::XULLabelIterator(DocAccessible* aDocument,
nsIContent* aElement)
: mRelIter(aDocument, aElement, nsGkAtoms::control) {}
Accessible*
XULLabelIterator::Next()
{
Accessible* XULLabelIterator::Next() {
Accessible* label = nullptr;
while ((label = mRelIter.Next())) {
if (label->GetContent()->IsXULElement(nsGkAtoms::label))
return label;
if (label->GetContent()->IsXULElement(nsGkAtoms::label)) return label;
}
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// XULDescriptionIterator
////////////////////////////////////////////////////////////////////////////////
XULDescriptionIterator::
XULDescriptionIterator(DocAccessible* aDocument, nsIContent* aElement) :
mRelIter(aDocument, aElement, nsGkAtoms::control)
{
}
XULDescriptionIterator::XULDescriptionIterator(DocAccessible* aDocument,
nsIContent* aElement)
: mRelIter(aDocument, aElement, nsGkAtoms::control) {}
Accessible*
XULDescriptionIterator::Next()
{
Accessible* XULDescriptionIterator::Next() {
Accessible* descr = nullptr;
while ((descr = mRelIter.Next())) {
if (descr->GetContent()->IsXULElement(nsGkAtoms::description))
return descr;
if (descr->GetContent()->IsXULElement(nsGkAtoms::description)) return descr;
}
return nullptr;
@@ -256,64 +220,50 @@ XULDescriptionIterator::Next()
// IDRefsIterator
////////////////////////////////////////////////////////////////////////////////
IDRefsIterator::
IDRefsIterator(DocAccessible* aDoc, nsIContent* aContent,
nsAtom* aIDRefsAttr) :
mContent(aContent), mDoc(aDoc), mCurrIdx(0)
{
IDRefsIterator::IDRefsIterator(DocAccessible* aDoc, nsIContent* aContent,
nsAtom* aIDRefsAttr)
: mContent(aContent), mDoc(aDoc), mCurrIdx(0) {
if (mContent->IsElement()) {
mContent->AsElement()->GetAttr(kNameSpaceID_None, aIDRefsAttr, mIDs);
}
}
const nsDependentSubstring
IDRefsIterator::NextID()
{
const nsDependentSubstring IDRefsIterator::NextID() {
for (; mCurrIdx < mIDs.Length(); mCurrIdx++) {
if (!NS_IsAsciiWhitespace(mIDs[mCurrIdx]))
break;
if (!NS_IsAsciiWhitespace(mIDs[mCurrIdx])) break;
}
if (mCurrIdx >= mIDs.Length())
return nsDependentSubstring();
if (mCurrIdx >= mIDs.Length()) return nsDependentSubstring();
nsAString::index_type idStartIdx = mCurrIdx;
while (++mCurrIdx < mIDs.Length()) {
if (NS_IsAsciiWhitespace(mIDs[mCurrIdx]))
break;
if (NS_IsAsciiWhitespace(mIDs[mCurrIdx])) break;
}
return Substring(mIDs, idStartIdx, mCurrIdx++ - idStartIdx);
}
nsIContent*
IDRefsIterator::NextElem()
{
nsIContent* IDRefsIterator::NextElem() {
while (true) {
const nsDependentSubstring id = NextID();
if (id.IsEmpty())
break;
if (id.IsEmpty()) break;
nsIContent* refContent = GetElem(id);
if (refContent)
return refContent;
if (refContent) return refContent;
}
return nullptr;
}
nsIContent*
IDRefsIterator::GetElem(const nsDependentSubstring& aID)
{
nsIContent* IDRefsIterator::GetElem(const nsDependentSubstring& aID) {
// Get elements in DOM tree by ID attribute if this is an explicit content.
// In case of bound element check its anonymous subtree.
if (!mContent->IsInAnonymousSubtree()) {
dom::DocumentOrShadowRoot* docOrShadowRoot =
mContent->GetUncomposedDocOrConnectedShadowRoot();
mContent->GetUncomposedDocOrConnectedShadowRoot();
if (docOrShadowRoot) {
dom::Element* refElm = docOrShadowRoot->GetElementById(aID);
if (refElm || !mContent->GetXBLBinding())
return refElm;
if (refElm || !mContent->GetXBLBinding()) return refElm;
}
}
@@ -323,25 +273,23 @@ IDRefsIterator::GetElem(const nsDependentSubstring& aID)
// Check inside the binding the element is contained in.
nsIContent* bindingParent = mContent->GetBindingParent();
if (bindingParent) {
nsIContent* refElm = bindingParent->OwnerDoc()->
GetAnonymousElementByAttribute(bindingParent, nsGkAtoms::anonid, aID);
nsIContent* refElm =
bindingParent->OwnerDoc()->GetAnonymousElementByAttribute(
bindingParent, nsGkAtoms::anonid, aID);
if (refElm)
return refElm;
if (refElm) return refElm;
}
// Check inside the binding of the element.
if (mContent->GetXBLBinding()) {
return mContent->OwnerDoc()->
GetAnonymousElementByAttribute(mContent, nsGkAtoms::anonid, aID);
return mContent->OwnerDoc()->GetAnonymousElementByAttribute(
mContent, nsGkAtoms::anonid, aID);
}
return nullptr;
}
Accessible*
IDRefsIterator::Next()
{
Accessible* IDRefsIterator::Next() {
nsIContent* nextEl = nullptr;
while ((nextEl = NextElem())) {
Accessible* acc = mDoc->GetAccessible(nextEl);
@@ -352,14 +300,11 @@ IDRefsIterator::Next()
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// SingleAccIterator
////////////////////////////////////////////////////////////////////////////////
Accessible*
SingleAccIterator::Next()
{
Accessible* SingleAccIterator::Next() {
RefPtr<Accessible> nextAcc;
mAcc.swap(nextAcc);
if (!nextAcc || nextAcc->IsDefunct()) {
@@ -368,14 +313,11 @@ SingleAccIterator::Next()
return nextAcc;
}
////////////////////////////////////////////////////////////////////////////////
// ItemIterator
////////////////////////////////////////////////////////////////////////////////
Accessible*
ItemIterator::Next()
{
Accessible* ItemIterator::Next() {
if (mContainer) {
mAnchor = AccGroupInfo::FirstItemOf(mContainer);
mContainer = nullptr;
@@ -385,25 +327,23 @@ ItemIterator::Next()
return mAnchor ? (mAnchor = AccGroupInfo::NextItemTo(mAnchor)) : nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// XULTreeItemIterator
////////////////////////////////////////////////////////////////////////////////
XULTreeItemIterator::XULTreeItemIterator(const XULTreeAccessible* aXULTree,
nsITreeView* aTreeView,
int32_t aRowIdx) :
mXULTree(aXULTree), mTreeView(aTreeView), mRowCount(-1),
mContainerLevel(-1), mCurrRowIdx(aRowIdx + 1)
{
int32_t aRowIdx)
: mXULTree(aXULTree),
mTreeView(aTreeView),
mRowCount(-1),
mContainerLevel(-1),
mCurrRowIdx(aRowIdx + 1) {
mTreeView->GetRowCount(&mRowCount);
if (aRowIdx != -1)
mTreeView->GetLevel(aRowIdx, &mContainerLevel);
if (aRowIdx != -1) mTreeView->GetLevel(aRowIdx, &mContainerLevel);
}
Accessible*
XULTreeItemIterator::Next()
{
Accessible* XULTreeItemIterator::Next() {
while (mCurrRowIdx < mRowCount) {
int32_t level = 0;
mTreeView->GetLevel(mCurrRowIdx, &level);
@@ -411,7 +351,7 @@ XULTreeItemIterator::Next()
if (level == mContainerLevel + 1)
return mXULTree->GetTreeItemAccessible(mCurrRowIdx++);
if (level <= mContainerLevel) { // got level up
if (level <= mContainerLevel) { // got level up
mCurrRowIdx = mRowCount;
break;
}

View File

@@ -20,13 +20,12 @@ namespace a11y {
/**
* AccIterable is a basic interface for iterators over accessibles.
*/
class AccIterable
{
public:
virtual ~AccIterable() { }
class AccIterable {
public:
virtual ~AccIterable() {}
virtual Accessible* Next() = 0;
private:
private:
friend class Relation;
std::unique_ptr<AccIterable> mNextIter;
};
@@ -35,9 +34,8 @@ private:
* Allows to iterate through accessible children or subtree complying with
* filter function.
*/
class AccIterator : public AccIterable
{
public:
class AccIterator : public AccIterable {
public:
AccIterator(const Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
virtual ~AccIterator();
@@ -47,14 +45,14 @@ public:
*/
virtual Accessible* Next() override;
private:
private:
AccIterator();
AccIterator(const AccIterator&);
AccIterator& operator =(const AccIterator&);
AccIterator& operator=(const AccIterator&);
struct IteratorState
{
explicit IteratorState(const Accessible* aParent, IteratorState* mParentState = nullptr);
struct IteratorState {
explicit IteratorState(const Accessible* aParent,
IteratorState* mParentState = nullptr);
const Accessible* mParent;
int32_t mIndex;
@@ -65,14 +63,12 @@ private:
IteratorState* mState;
};
/**
* Allows to traverse through related accessibles that are pointing to the given
* dependent accessible by relation attribute.
*/
class RelatedAccIterator : public AccIterable
{
public:
class RelatedAccIterator : public AccIterable {
public:
/**
* Constructor.
*
@@ -86,17 +82,17 @@ public:
RelatedAccIterator(DocAccessible* aDocument, nsIContent* aDependentContent,
nsAtom* aRelAttr);
virtual ~RelatedAccIterator() { }
virtual ~RelatedAccIterator() {}
/**
* Return next related accessible for the given dependent accessible.
*/
virtual Accessible* Next() override;
private:
private:
RelatedAccIterator();
RelatedAccIterator(const RelatedAccIterator&);
RelatedAccIterator& operator = (const RelatedAccIterator&);
RelatedAccIterator& operator=(const RelatedAccIterator&);
DocAccessible* mDocument;
nsAtom* mRelAttr;
@@ -105,32 +101,27 @@ private:
uint32_t mIndex;
};
/**
* Used to iterate through HTML labels associated with the given accessible.
*/
class HTMLLabelIterator : public AccIterable
{
public:
enum LabelFilter {
eAllLabels,
eSkipAncestorLabel
};
class HTMLLabelIterator : public AccIterable {
public:
enum LabelFilter { eAllLabels, eSkipAncestorLabel };
HTMLLabelIterator(DocAccessible* aDocument, const Accessible* aAccessible,
LabelFilter aFilter = eAllLabels);
virtual ~HTMLLabelIterator() { }
virtual ~HTMLLabelIterator() {}
/**
* Return next label accessible associated with the given element.
*/
virtual Accessible* Next() override;
private:
private:
HTMLLabelIterator();
HTMLLabelIterator(const HTMLLabelIterator&);
HTMLLabelIterator& operator = (const HTMLLabelIterator&);
HTMLLabelIterator& operator=(const HTMLLabelIterator&);
bool IsLabel(Accessible* aLabel);
@@ -141,71 +132,65 @@ private:
LabelFilter mLabelFilter;
};
/**
* Used to iterate through HTML outputs associated with the given element.
*/
class HTMLOutputIterator : public AccIterable
{
public:
class HTMLOutputIterator : public AccIterable {
public:
HTMLOutputIterator(DocAccessible* aDocument, nsIContent* aElement);
virtual ~HTMLOutputIterator() { }
virtual ~HTMLOutputIterator() {}
/**
* Return next output accessible associated with the given element.
*/
virtual Accessible* Next() override;
private:
private:
HTMLOutputIterator();
HTMLOutputIterator(const HTMLOutputIterator&);
HTMLOutputIterator& operator = (const HTMLOutputIterator&);
HTMLOutputIterator& operator=(const HTMLOutputIterator&);
RelatedAccIterator mRelIter;
};
/**
* Used to iterate through XUL labels associated with the given element.
*/
class XULLabelIterator : public AccIterable
{
public:
class XULLabelIterator : public AccIterable {
public:
XULLabelIterator(DocAccessible* aDocument, nsIContent* aElement);
virtual ~XULLabelIterator() { }
virtual ~XULLabelIterator() {}
/**
* Return next label accessible associated with the given element.
*/
virtual Accessible* Next() override;
private:
private:
XULLabelIterator();
XULLabelIterator(const XULLabelIterator&);
XULLabelIterator& operator = (const XULLabelIterator&);
XULLabelIterator& operator=(const XULLabelIterator&);
RelatedAccIterator mRelIter;
};
/**
* Used to iterate through XUL descriptions associated with the given element.
*/
class XULDescriptionIterator : public AccIterable
{
public:
class XULDescriptionIterator : public AccIterable {
public:
XULDescriptionIterator(DocAccessible* aDocument, nsIContent* aElement);
virtual ~XULDescriptionIterator() { }
virtual ~XULDescriptionIterator() {}
/**
* Return next description accessible associated with the given element.
*/
virtual Accessible* Next() override;
private:
private:
XULDescriptionIterator();
XULDescriptionIterator(const XULDescriptionIterator&);
XULDescriptionIterator& operator = (const XULDescriptionIterator&);
XULDescriptionIterator& operator=(const XULDescriptionIterator&);
RelatedAccIterator mRelIter;
};
@@ -215,12 +200,11 @@ private:
* attribute. Note, any method used to iterate through IDs, elements, or
* accessibles moves iterator to next position.
*/
class IDRefsIterator : public AccIterable
{
public:
class IDRefsIterator : public AccIterable {
public:
IDRefsIterator(DocAccessible* aDoc, nsIContent* aContent,
nsAtom* aIDRefsAttr);
virtual ~IDRefsIterator() { }
virtual ~IDRefsIterator() {}
/**
* Return next ID.
@@ -240,10 +224,10 @@ public:
// AccIterable
virtual Accessible* Next() override;
private:
private:
IDRefsIterator();
IDRefsIterator(const IDRefsIterator&);
IDRefsIterator operator = (const IDRefsIterator&);
IDRefsIterator operator=(const IDRefsIterator&);
nsString mIDs;
nsIContent* mContent;
@@ -251,66 +235,60 @@ private:
nsAString::index_type mCurrIdx;
};
/**
* Iterator that points to a single accessible returning it on the first call
* to Next().
*/
class SingleAccIterator : public AccIterable
{
public:
explicit SingleAccIterator(Accessible* aTarget): mAcc(aTarget) { }
virtual ~SingleAccIterator() { }
class SingleAccIterator : public AccIterable {
public:
explicit SingleAccIterator(Accessible* aTarget) : mAcc(aTarget) {}
virtual ~SingleAccIterator() {}
virtual Accessible* Next() override;
private:
private:
SingleAccIterator();
SingleAccIterator(const SingleAccIterator&);
SingleAccIterator& operator = (const SingleAccIterator&);
SingleAccIterator& operator=(const SingleAccIterator&);
RefPtr<Accessible> mAcc;
};
/**
* Used to iterate items of the given item container.
*/
class ItemIterator : public AccIterable
{
public:
explicit ItemIterator(const Accessible* aItemContainer) :
mContainer(aItemContainer), mAnchor(nullptr) { }
virtual ~ItemIterator() { }
class ItemIterator : public AccIterable {
public:
explicit ItemIterator(const Accessible* aItemContainer)
: mContainer(aItemContainer), mAnchor(nullptr) {}
virtual ~ItemIterator() {}
virtual Accessible* Next() override;
private:
private:
ItemIterator() = delete;
ItemIterator(const ItemIterator&) = delete;
ItemIterator& operator = (const ItemIterator&) = delete;
ItemIterator& operator=(const ItemIterator&) = delete;
const Accessible* mContainer;
Accessible* mAnchor;
};
/**
* Used to iterate through XUL tree items of the same level.
*/
class XULTreeItemIterator : public AccIterable
{
public:
class XULTreeItemIterator : public AccIterable {
public:
XULTreeItemIterator(const XULTreeAccessible* aXULTree, nsITreeView* aTreeView,
int32_t aRowIdx);
virtual ~XULTreeItemIterator() { }
virtual ~XULTreeItemIterator() {}
virtual Accessible* Next() override;
private:
private:
XULTreeItemIterator() = delete;
XULTreeItemIterator(const XULTreeItemIterator&) = delete;
XULTreeItemIterator& operator = (const XULTreeItemIterator&) = delete;
XULTreeItemIterator& operator=(const XULTreeItemIterator&) = delete;
const XULTreeAccessible* mXULTree;
nsITreeView* mTreeView;
@@ -319,7 +297,7 @@ private:
int32_t mCurrRowIdx;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -89,7 +89,7 @@ enum AccGenericType {
eLastAccGenericType = eText
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif // mozilla_a11y_AccTypes_h
#endif // mozilla_a11y_AccTypes_h

View File

@@ -9,9 +9,7 @@
namespace mozilla {
namespace a11y {
AccessibleOrProxy
AccessibleOrProxy::Parent() const
{
AccessibleOrProxy AccessibleOrProxy::Parent() const {
if (IsAccessible()) {
return AsAccessible()->Parent();
}
@@ -29,5 +27,5 @@ AccessibleOrProxy::Parent() const
return proxy->OuterDocOfRemoteBrowser();
}
}
}
} // namespace a11y
} // namespace mozilla

View File

@@ -20,18 +20,16 @@ namespace a11y {
* This class stores an Accessible* or a ProxyAccessible* in a safe manner
* with size sizeof(void*).
*/
class AccessibleOrProxy
{
public:
MOZ_IMPLICIT AccessibleOrProxy(Accessible* aAcc) :
mBits(reinterpret_cast<uintptr_t>(aAcc)) {}
MOZ_IMPLICIT AccessibleOrProxy(ProxyAccessible* aProxy) :
mBits(aProxy ? (reinterpret_cast<uintptr_t>(aProxy) | IS_PROXY) : 0) {}
class AccessibleOrProxy {
public:
MOZ_IMPLICIT AccessibleOrProxy(Accessible* aAcc)
: mBits(reinterpret_cast<uintptr_t>(aAcc)) {}
MOZ_IMPLICIT AccessibleOrProxy(ProxyAccessible* aProxy)
: mBits(aProxy ? (reinterpret_cast<uintptr_t>(aProxy) | IS_PROXY) : 0) {}
MOZ_IMPLICIT AccessibleOrProxy(decltype(nullptr)) : mBits(0) {}
bool IsProxy() const { return mBits & IS_PROXY; }
ProxyAccessible* AsProxy() const
{
ProxyAccessible* AsProxy() const {
if (IsProxy()) {
return reinterpret_cast<ProxyAccessible*>(mBits & ~IS_PROXY);
}
@@ -40,8 +38,7 @@ public:
}
bool IsAccessible() const { return !IsProxy(); }
Accessible* AsAccessible() const
{
Accessible* AsAccessible() const {
if (IsAccessible()) {
return reinterpret_cast<Accessible*>(mBits);
}
@@ -51,8 +48,7 @@ public:
bool IsNull() const { return mBits == 0; }
uint32_t ChildCount() const
{
uint32_t ChildCount() const {
if (IsProxy()) {
return AsProxy()->ChildrenCount();
}
@@ -64,8 +60,7 @@ public:
* Return the child object either an accessible or a proxied accessible at
* the given index.
*/
AccessibleOrProxy ChildAt(uint32_t aIdx)
{
AccessibleOrProxy ChildAt(uint32_t aIdx) {
if (IsProxy()) {
return AsProxy()->ChildAt(aIdx);
}
@@ -76,8 +71,7 @@ public:
/**
* Return the first child object.
*/
AccessibleOrProxy FirstChild()
{
AccessibleOrProxy FirstChild() {
if (IsProxy()) {
return AsProxy()->FirstChild();
}
@@ -88,8 +82,7 @@ public:
/**
* Return the first child object.
*/
AccessibleOrProxy LastChild()
{
AccessibleOrProxy LastChild() {
if (IsProxy()) {
return AsProxy()->LastChild();
}
@@ -97,8 +90,7 @@ public:
return AsAccessible()->LastChild();
}
role Role() const
{
role Role() const {
if (IsProxy()) {
return AsProxy()->Role();
}
@@ -112,12 +104,12 @@ public:
uintptr_t Bits() const { return mBits; }
void SetBits(uintptr_t aBits) { mBits = aBits; }
private:
private:
uintptr_t mBits;
static const uintptr_t IS_PROXY = 0x1;
};
}
}
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -11,16 +11,19 @@
using namespace mozilla::a11y;
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, androidClass, nameRule) \
static_assert(static_cast<uint32_t>(roles::geckoRole) \
== static_cast<uint32_t>(nsIAccessibleRole::ROLE_ ## geckoRole), \
"internal and xpcom roles differ!");
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, \
androidClass, nameRule) \
static_assert( \
static_cast<uint32_t>(roles::geckoRole) == \
static_cast<uint32_t>(nsIAccessibleRole::ROLE_##geckoRole), \
"internal and xpcom roles differ!");
#include "RoleMap.h"
#undef ROLE
#define RELATIONTYPE(geckoType, stringType, atkType, msaaType, ia2Type) \
static_assert(static_cast<uint32_t>(RelationType::geckoType) \
== static_cast<uint32_t>(nsIAccessibleRelation::RELATION_ ## geckoType), \
"internal and xpcom relations differ!");
#define RELATIONTYPE(geckoType, stringType, atkType, msaaType, ia2Type) \
static_assert( \
static_cast<uint32_t>(RelationType::geckoType) == \
static_cast<uint32_t>(nsIAccessibleRelation::RELATION_##geckoType), \
"internal and xpcom relations differ!");
#include "RelationTypeMap.h"
#undef RELATIONTYPE

View File

@@ -21,7 +21,7 @@
#endif
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/Event.h" // for Event
#include "mozilla/dom/Event.h" // for Event
#include "nsContentUtils.h"
#include "nsCURILoader.h"
#include "nsDocShellLoadTypes.h"
@@ -39,37 +39,29 @@ using namespace mozilla::a11y;
using namespace mozilla::dom;
StaticAutoPtr<nsTArray<DocAccessibleParent*>> DocManager::sRemoteDocuments;
nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>, xpcAccessibleDocument>*
DocManager::sRemoteXPCDocumentCache = nullptr;
nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>,
xpcAccessibleDocument>* DocManager::sRemoteXPCDocumentCache =
nullptr;
////////////////////////////////////////////////////////////////////////////////
// DocManager
////////////////////////////////////////////////////////////////////////////////
DocManager::DocManager()
: mDocAccessibleCache(2), mXPCDocumentCache(0)
{
}
DocManager::DocManager() : mDocAccessibleCache(2), mXPCDocumentCache(0) {}
////////////////////////////////////////////////////////////////////////////////
// DocManager public
DocAccessible*
DocManager::GetDocAccessible(nsIDocument* aDocument)
{
if (!aDocument)
return nullptr;
DocAccessible* DocManager::GetDocAccessible(nsIDocument* aDocument) {
if (!aDocument) return nullptr;
DocAccessible* docAcc = GetExistingDocAccessible(aDocument);
if (docAcc)
return docAcc;
if (docAcc) return docAcc;
return CreateDocOrRootAccessible(aDocument);
}
Accessible*
DocManager::FindAccessibleInCache(nsINode* aNode) const
{
Accessible* DocManager::FindAccessibleInCache(nsINode* aNode) const {
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
DocAccessible* docAccessible = iter.UserData();
NS_ASSERTION(docAccessible,
@@ -85,9 +77,7 @@ DocManager::FindAccessibleInCache(nsINode* aNode) const
return nullptr;
}
void
DocManager::RemoveFromXPCDocumentCache(DocAccessible* aDocument)
{
void DocManager::RemoveFromXPCDocumentCache(DocAccessible* aDocument) {
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
if (xpcDoc) {
xpcDoc->Shutdown();
@@ -99,10 +89,8 @@ DocManager::RemoveFromXPCDocumentCache(DocAccessible* aDocument)
}
}
void
DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
nsIDocument* aDOMDocument)
{
void DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
nsIDocument* aDOMDocument) {
// We need to remove listeners in both cases, when document is being shutdown
// or when accessibility service is being shut down as well.
RemoveListeners(aDOMDocument);
@@ -117,9 +105,7 @@ DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
mDocAccessibleCache.Remove(aDOMDocument);
}
void
DocManager::RemoveFromRemoteXPCDocumentCache(DocAccessibleParent* aDoc)
{
void DocManager::RemoveFromRemoteXPCDocumentCache(DocAccessibleParent* aDoc) {
xpcAccessibleDocument* doc = GetCachedXPCDocument(aDoc);
if (doc) {
doc->Shutdown();
@@ -131,17 +117,12 @@ DocManager::RemoveFromRemoteXPCDocumentCache(DocAccessibleParent* aDoc)
}
}
void
DocManager::NotifyOfRemoteDocShutdown(DocAccessibleParent* aDoc)
{
void DocManager::NotifyOfRemoteDocShutdown(DocAccessibleParent* aDoc) {
RemoveFromRemoteXPCDocumentCache(aDoc);
}
xpcAccessibleDocument*
DocManager::GetXPCDocument(DocAccessible* aDocument)
{
if (!aDocument)
return nullptr;
xpcAccessibleDocument* DocManager::GetXPCDocument(DocAccessible* aDocument) {
if (!aDocument) return nullptr;
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
if (!xpcDoc) {
@@ -151,9 +132,7 @@ DocManager::GetXPCDocument(DocAccessible* aDocument)
return xpcDoc;
}
xpcAccessibleDocument*
DocManager::GetXPCDocument(DocAccessibleParent* aDoc)
{
xpcAccessibleDocument* DocManager::GetXPCDocument(DocAccessibleParent* aDoc) {
xpcAccessibleDocument* doc = GetCachedXPCDocument(aDoc);
if (doc) {
return doc;
@@ -161,20 +140,19 @@ DocManager::GetXPCDocument(DocAccessibleParent* aDoc)
if (!sRemoteXPCDocumentCache) {
sRemoteXPCDocumentCache =
new nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>, xpcAccessibleDocument>;
new nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>,
xpcAccessibleDocument>;
}
doc =
new xpcAccessibleDocument(aDoc, Interfaces::DOCUMENT | Interfaces::HYPERTEXT);
doc = new xpcAccessibleDocument(aDoc,
Interfaces::DOCUMENT | Interfaces::HYPERTEXT);
sRemoteXPCDocumentCache->Put(aDoc, doc);
return doc;
}
#ifdef DEBUG
bool
DocManager::IsProcessingRefreshDriverNotification() const
{
bool DocManager::IsProcessingRefreshDriverNotification() const {
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
DocAccessible* docAccessible = iter.UserData();
NS_ASSERTION(docAccessible,
@@ -189,18 +167,14 @@ DocManager::IsProcessingRefreshDriverNotification() const
}
#endif
////////////////////////////////////////////////////////////////////////////////
// DocManager protected
bool
DocManager::Init()
{
bool DocManager::Init() {
nsCOMPtr<nsIWebProgress> progress =
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
if (!progress)
return false;
if (!progress) return false;
progress->AddProgressListener(static_cast<nsIWebProgressListener*>(this),
nsIWebProgress::NOTIFY_STATE_DOCUMENT);
@@ -208,14 +182,13 @@ DocManager::Init()
return true;
}
void
DocManager::Shutdown()
{
void DocManager::Shutdown() {
nsCOMPtr<nsIWebProgress> progress =
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
if (progress)
progress->RemoveProgressListener(static_cast<nsIWebProgressListener*>(this));
progress->RemoveProgressListener(
static_cast<nsIWebProgressListener*>(this));
ClearDocCache();
}
@@ -223,19 +196,15 @@ DocManager::Shutdown()
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS(DocManager,
nsIWebProgressListener,
nsIDOMEventListener,
NS_IMPL_ISUPPORTS(DocManager, nsIWebProgressListener, nsIDOMEventListener,
nsISupportsWeakReference)
////////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener
NS_IMETHODIMP
DocManager::OnStateChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest, uint32_t aStateFlags,
nsresult aStatus)
{
DocManager::OnStateChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
uint32_t aStateFlags, nsresult aStatus) {
NS_ASSERTION(aStateFlags & STATE_IS_DOCUMENT, "Other notifications excluded");
if (nsAccessibilityService::IsShutdown() || !aWebProgress ||
@@ -274,8 +243,7 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
if (aRequest) {
uint32_t loadFlags = 0;
aRequest->GetLoadFlags(&loadFlags);
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
eventType = 0;
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) eventType = 0;
}
HandleDOMDocumentLoad(document, eventType);
@@ -285,12 +253,12 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
// Document loading was started.
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocLoad))
logging::DocLoad("start document loading", aWebProgress, aRequest, aStateFlags);
logging::DocLoad("start document loading", aWebProgress, aRequest,
aStateFlags);
#endif
DocAccessible* docAcc = GetExistingDocAccessible(document);
if (!docAcc)
return NS_OK;
if (!docAcc) return NS_OK;
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(DOMWindow));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
@@ -299,8 +267,7 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
bool isReloading = false;
uint32_t loadType;
docShell->GetLoadType(&loadType);
if (loadType == LOAD_RELOAD_NORMAL ||
loadType == LOAD_RELOAD_BYPASS_CACHE ||
if (loadType == LOAD_RELOAD_NORMAL || loadType == LOAD_RELOAD_BYPASS_CACHE ||
loadType == LOAD_RELOAD_BYPASS_PROXY ||
loadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE ||
loadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
@@ -312,42 +279,32 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
}
NS_IMETHODIMP
DocManager::OnProgressChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
int32_t aCurSelfProgress,
int32_t aMaxSelfProgress,
DocManager::OnProgressChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
int32_t aCurSelfProgress, int32_t aMaxSelfProgress,
int32_t aCurTotalProgress,
int32_t aMaxTotalProgress)
{
int32_t aMaxTotalProgress) {
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
return NS_OK;
}
NS_IMETHODIMP
DocManager::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest, nsIURI* aLocation,
uint32_t aFlags)
{
DocManager::OnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
nsIURI* aLocation, uint32_t aFlags) {
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
return NS_OK;
}
NS_IMETHODIMP
DocManager::OnStatusChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest, nsresult aStatus,
const char16_t* aMessage)
{
DocManager::OnStatusChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
nsresult aStatus, const char16_t* aMessage) {
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
return NS_OK;
}
NS_IMETHODIMP
DocManager::OnSecurityChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
uint32_t aOldState,
uint32_t aState,
const nsAString& aContentBlockingLogJSON)
{
DocManager::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
uint32_t aOldState, uint32_t aState,
const nsAString& aContentBlockingLogJSON) {
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
return NS_OK;
}
@@ -356,15 +313,13 @@ DocManager::OnSecurityChange(nsIWebProgress* aWebProgress,
// nsIDOMEventListener
NS_IMETHODIMP
DocManager::HandleEvent(Event* aEvent)
{
DocManager::HandleEvent(Event* aEvent) {
nsAutoString type;
aEvent->GetType(type);
nsCOMPtr<nsIDocument> document = do_QueryInterface(aEvent->GetTarget());
NS_ASSERTION(document, "pagehide or DOMContentLoaded for non document!");
if (!document)
return NS_OK;
if (!document) return NS_OK;
if (type.EqualsLiteral("pagehide")) {
// 'pagehide' event is registered on every DOM document we create an
@@ -383,8 +338,7 @@ DocManager::HandleEvent(Event* aEvent)
// 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 = GetExistingDocAccessible(document);
if (docAccessible)
docAccessible->Shutdown();
if (docAccessible) docAccessible->Shutdown();
return NS_OK;
}
@@ -408,26 +362,21 @@ DocManager::HandleEvent(Event* aEvent)
////////////////////////////////////////////////////////////////////////////////
// DocManager private
void
DocManager::HandleDOMDocumentLoad(nsIDocument* aDocument,
uint32_t aLoadEventType)
{
void DocManager::HandleDOMDocumentLoad(nsIDocument* aDocument,
uint32_t aLoadEventType) {
// Document accessible can be created before we were notified the DOM document
// was loaded completely. However if it's not created yet then create it.
DocAccessible* docAcc = GetExistingDocAccessible(aDocument);
if (!docAcc) {
docAcc = CreateDocOrRootAccessible(aDocument);
if (!docAcc)
return;
if (!docAcc) return;
}
docAcc->NotifyOfLoad(aLoadEventType);
}
void
DocManager::AddListeners(nsIDocument* aDocument,
bool aAddDOMContentLoadedListener)
{
void DocManager::AddListeners(nsIDocument* aDocument,
bool aAddDOMContentLoadedListener) {
nsPIDOMWindowOuter* window = aDocument->GetWindow();
EventTarget* target = window->GetChromeEventHandler();
EventListenerManager* elm = target->GetOrCreateListenerManager();
@@ -449,16 +398,12 @@ DocManager::AddListeners(nsIDocument* aDocument,
}
}
void
DocManager::RemoveListeners(nsIDocument* aDocument)
{
void DocManager::RemoveListeners(nsIDocument* aDocument) {
nsPIDOMWindowOuter* window = aDocument->GetWindow();
if (!window)
return;
if (!window) return;
EventTarget* target = window->GetChromeEventHandler();
if (!target)
return;
if (!target) return;
EventListenerManager* elm = target->GetOrCreateListenerManager();
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
@@ -468,9 +413,7 @@ DocManager::RemoveListeners(nsIDocument* aDocument)
TrustedEventsAtCapture());
}
DocAccessible*
DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
{
DocAccessible* DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument) {
// Ignore hidden documents, resource documents, static clone
// (printing) documents and documents without a docshell.
if (!aDocument->IsVisibleConsideringAncestors() ||
@@ -491,8 +434,7 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
// Ignore documents without presshell and not having root frame.
nsIPresShell* presShell = aDocument->GetShell();
if (!presShell || presShell->IsDestroying())
return nullptr;
if (!presShell || presShell->IsDestroying()) return nullptr;
bool isRootDoc = nsCoreUtils::IsRootDocument(aDocument);
@@ -501,17 +443,15 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
// XXXaaronl: ideally we would traverse the presshell chain. Since there's
// no easy way to do that, we cheat and use the document hierarchy.
parentDocAcc = GetDocAccessible(aDocument->GetParentDocument());
NS_ASSERTION(parentDocAcc,
"Can't create an accessible for the document!");
if (!parentDocAcc)
return nullptr;
NS_ASSERTION(parentDocAcc, "Can't create an accessible for the document!");
if (!parentDocAcc) return nullptr;
}
// We only create root accessibles for the true root, otherwise create a
// doc accessible.
RefPtr<DocAccessible> docAcc = isRootDoc ?
new RootAccessibleWrap(aDocument, presShell) :
new DocAccessibleWrap(aDocument, presShell);
RefPtr<DocAccessible> docAcc =
isRootDoc ? new RootAccessibleWrap(aDocument, presShell)
: new DocAccessibleWrap(aDocument, presShell);
// Cache the document accessible into document cache.
mDocAccessibleCache.Put(aDocument, docAcc);
@@ -553,9 +493,7 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
////////////////////////////////////////////////////////////////////////////////
// DocManager static
void
DocManager::ClearDocCache()
{
void DocManager::ClearDocCache() {
while (mDocAccessibleCache.Count() > 0) {
auto iter = mDocAccessibleCache.Iter();
MOZ_ASSERT(!iter.Done());
@@ -581,19 +519,17 @@ DocManager::ClearDocCache()
}
iter.Remove();
}
}
}
void
DocManager::RemoteDocAdded(DocAccessibleParent* aDoc)
{
void DocManager::RemoteDocAdded(DocAccessibleParent* aDoc) {
if (!sRemoteDocuments) {
sRemoteDocuments = new nsTArray<DocAccessibleParent*>;
ClearOnShutdown(&sRemoteDocuments);
}
MOZ_ASSERT(!sRemoteDocuments->Contains(aDoc),
"How did we already have the doc!");
"How did we already have the doc!");
sRemoteDocuments->AppendElement(aDoc);
ProxyCreated(aDoc, Interfaces::DOCUMENT | Interfaces::HYPERTEXT);
}

View File

@@ -27,9 +27,8 @@ class DocAccessibleParent;
*/
class DocManager : public nsIWebProgressListener,
public nsIDOMEventListener,
public nsSupportsWeakReference
{
public:
public nsSupportsWeakReference {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIDOMEVENTLISTENER
@@ -42,14 +41,11 @@ public:
/**
* Return document accessible for the given presshell.
*/
DocAccessible* GetDocAccessible(const nsIPresShell* aPresShell)
{
if (!aPresShell)
return nullptr;
DocAccessible* GetDocAccessible(const nsIPresShell* aPresShell) {
if (!aPresShell) return nullptr;
DocAccessible* doc = aPresShell->GetDocAccessible();
if (doc)
return doc;
if (doc) return doc;
return GetDocAccessible(aPresShell->GetDocument());
}
@@ -72,14 +68,14 @@ public:
* Return XPCOM accessible document.
*/
xpcAccessibleDocument* GetXPCDocument(DocAccessible* aDocument);
xpcAccessibleDocument* GetCachedXPCDocument(DocAccessible* aDocument) const
{ return mXPCDocumentCache.GetWeak(aDocument); }
xpcAccessibleDocument* GetCachedXPCDocument(DocAccessible* aDocument) const {
return mXPCDocumentCache.GetWeak(aDocument);
}
/*
* Notification that a top level document in a content process has gone away.
*/
static void RemoteDocShutdown(DocAccessibleParent* aDoc)
{
static void RemoteDocShutdown(DocAccessibleParent* aDoc) {
DebugOnly<bool> result = sRemoteDocuments->RemoveElement(aDoc);
MOZ_ASSERT(result, "Why didn't we find the document!");
}
@@ -89,8 +85,9 @@ public:
*/
static void RemoteDocAdded(DocAccessibleParent* aDoc);
static const nsTArray<DocAccessibleParent*>* TopLevelRemoteDocs()
{ return sRemoteDocuments; }
static const nsTArray<DocAccessibleParent*>* TopLevelRemoteDocs() {
return sRemoteDocuments;
}
/**
* Remove the xpc document for a remote document if there is one.
@@ -103,19 +100,19 @@ public:
* Get a XPC document for a remote document.
*/
static xpcAccessibleDocument* GetXPCDocument(DocAccessibleParent* aDoc);
static xpcAccessibleDocument* GetCachedXPCDocument(const DocAccessibleParent* aDoc)
{
static xpcAccessibleDocument* GetCachedXPCDocument(
const DocAccessibleParent* aDoc) {
return sRemoteXPCDocumentCache ? sRemoteXPCDocumentCache->GetWeak(aDoc)
: nullptr;
: nullptr;
}
#ifdef DEBUG
bool IsProcessingRefreshDriverNotification() const;
#endif
protected:
protected:
DocManager();
virtual ~DocManager() { }
virtual ~DocManager() {}
/**
* Initialize the manager.
@@ -127,17 +124,16 @@ protected:
*/
void Shutdown();
bool HasXPCDocuments()
{
bool HasXPCDocuments() {
return mXPCDocumentCache.Count() > 0 ||
(sRemoteXPCDocumentCache && sRemoteXPCDocumentCache->Count() > 0);
}
private:
private:
DocManager(const DocManager&);
DocManager& operator =(const DocManager&);
DocManager& operator=(const DocManager&);
private:
private:
/**
* Create an accessible document if it was't created and fire accessibility
* events if needed.
@@ -146,13 +142,12 @@ private:
* @param aLoadEventType [in] specifies the event type to fire load event,
* if 0 then no event is fired
*/
void HandleDOMDocumentLoad(nsIDocument* aDocument,
uint32_t aLoadEventType);
void HandleDOMDocumentLoad(nsIDocument* aDocument, uint32_t aLoadEventType);
/**
* Add/remove 'pagehide' and 'DOMContentLoaded' event listeners.
*/
void AddListeners(nsIDocument *aDocument, bool aAddPageShowListener);
void AddListeners(nsIDocument* aDocument, bool aAddPageShowListener);
void RemoveListeners(nsIDocument* aDocument);
/**
@@ -166,14 +161,15 @@ private:
void ClearDocCache();
typedef nsRefPtrHashtable<nsPtrHashKey<const nsIDocument>, DocAccessible>
DocAccessibleHashtable;
DocAccessibleHashtable;
DocAccessibleHashtable mDocAccessibleCache;
typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>, xpcAccessibleDocument>
XPCDocumentHashtable;
typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>,
xpcAccessibleDocument>
XPCDocumentHashtable;
XPCDocumentHashtable mXPCDocumentCache;
static nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>, xpcAccessibleDocument>*
sRemoteXPCDocumentCache;
static nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>,
xpcAccessibleDocument>* sRemoteXPCDocumentCache;
/*
* The list of remote top level documents.
@@ -186,14 +182,12 @@ private:
* Note this returns the doc accessible for the primary pres shell if there is
* more than one.
*/
inline DocAccessible*
GetExistingDocAccessible(const nsIDocument* aDocument)
{
inline DocAccessible* GetExistingDocAccessible(const nsIDocument* aDocument) {
nsIPresShell* ps = aDocument->GetShell();
return ps ? ps->GetDocAccessible() : nullptr;
}
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif // mozilla_a11_DocManager_h_
#endif // mozilla_a11_DocManager_h_

View File

@@ -8,73 +8,55 @@
using namespace mozilla::a11y;
uint32_t
EmbeddedObjCollector::Count()
{
uint32_t EmbeddedObjCollector::Count() {
EnsureNGetIndex(nullptr);
return mObjects.Length();
}
Accessible*
EmbeddedObjCollector::GetAccessibleAt(uint32_t aIndex)
{
Accessible* EmbeddedObjCollector::GetAccessibleAt(uint32_t aIndex) {
Accessible* accessible = mObjects.SafeElementAt(aIndex, nullptr);
if (accessible)
return accessible;
if (accessible) return accessible;
return EnsureNGetObject(aIndex);
}
Accessible*
EmbeddedObjCollector::EnsureNGetObject(uint32_t aIndex)
{
Accessible* EmbeddedObjCollector::EnsureNGetObject(uint32_t aIndex) {
uint32_t childCount = mRoot->ChildCount();
while (mRootChildIdx < childCount) {
Accessible* child = mRoot->GetChildAt(mRootChildIdx++);
if (child->IsText())
continue;
if (child->IsText()) continue;
AppendObject(child);
if (mObjects.Length() - 1 == aIndex)
return mObjects[aIndex];
if (mObjects.Length() - 1 == aIndex) return mObjects[aIndex];
}
return nullptr;
}
int32_t
EmbeddedObjCollector::EnsureNGetIndex(Accessible* aAccessible)
{
int32_t EmbeddedObjCollector::EnsureNGetIndex(Accessible* aAccessible) {
uint32_t childCount = mRoot->ChildCount();
while (mRootChildIdx < childCount) {
Accessible* child = mRoot->GetChildAt(mRootChildIdx++);
if (child->IsText())
continue;
if (child->IsText()) continue;
AppendObject(child);
if (child == aAccessible)
return mObjects.Length() - 1;
if (child == aAccessible) return mObjects.Length() - 1;
}
return -1;
}
int32_t
EmbeddedObjCollector::GetIndexAt(Accessible* aAccessible)
{
if (aAccessible->mParent != mRoot)
return -1;
int32_t EmbeddedObjCollector::GetIndexAt(Accessible* aAccessible) {
if (aAccessible->mParent != mRoot) return -1;
MOZ_ASSERT(!aAccessible->IsProxy());
if (aAccessible->mInt.mIndexOfEmbeddedChild != -1)
return aAccessible->mInt.mIndexOfEmbeddedChild;
return !aAccessible->IsText() ? EnsureNGetIndex(aAccessible) : -1;
return !aAccessible->IsText() ? EnsureNGetIndex(aAccessible) : -1;
}
void
EmbeddedObjCollector::AppendObject(Accessible* aAccessible)
{
void EmbeddedObjCollector::AppendObject(Accessible* aAccessible) {
MOZ_ASSERT(!aAccessible->IsProxy());
aAccessible->mInt.mIndexOfEmbeddedChild = mObjects.Length();
mObjects.AppendElement(aAccessible);

View File

@@ -16,10 +16,9 @@ class Accessible;
* Collect embedded objects. Provide quick access to accessible by index and
* vice versa.
*/
class EmbeddedObjCollector final
{
public:
~EmbeddedObjCollector() { }
class EmbeddedObjCollector final {
public:
~EmbeddedObjCollector() {}
/**
* Return index of the given accessible within the collection.
@@ -36,7 +35,7 @@ public:
*/
Accessible* GetAccessibleAt(uint32_t aIndex);
protected:
protected:
/**
* Ensure accessible at the given index is stored and return it.
*/
@@ -48,8 +47,8 @@ protected:
int32_t EnsureNGetIndex(Accessible* aAccessible);
// Make sure it's used by Accessible class only.
explicit EmbeddedObjCollector(Accessible* aRoot) :
mRoot(aRoot), mRootChildIdx(0) {}
explicit EmbeddedObjCollector(Accessible* aRoot)
: mRoot(aRoot), mRootChildIdx(0) {}
/**
* Append the object to collection.
@@ -63,7 +62,7 @@ protected:
nsTArray<Accessible*> mObjects;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -26,15 +26,12 @@ const unsigned int kSelChangeCountToPack = 5;
// EventQueue
////////////////////////////////////////////////////////////////////////////////
bool
EventQueue::PushEvent(AccEvent* aEvent)
{
bool EventQueue::PushEvent(AccEvent* aEvent) {
NS_ASSERTION((aEvent->mAccessible && aEvent->mAccessible->IsApplication()) ||
aEvent->Document() == mDocument,
aEvent->Document() == mDocument,
"Queued event belongs to another document!");
if (!mEvents.AppendElement(aEvent))
return false;
if (!mEvents.AppendElement(aEvent)) return false;
// Filter events.
CoalesceEvents();
@@ -48,9 +45,7 @@ EventQueue::PushEvent(AccEvent* aEvent)
return true;
}
bool
EventQueue::PushNameChange(Accessible* aTarget)
{
bool EventQueue::PushNameChange(Accessible* aTarget) {
// Fire name change event on parent given that this event hasn't been
// coalesced, the parent's name was calculated from its subtree, and the
// subtree was changed.
@@ -67,7 +62,7 @@ EventQueue::PushNameChange(Accessible* aTarget)
// If name is obtained from subtree, fire name change event.
if (nameFlag == eNameFromSubtree) {
RefPtr<AccEvent> nameChangeEvent =
new AccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, parent);
new AccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, parent);
return PushEvent(nameChangeEvent);
}
break;
@@ -81,60 +76,55 @@ EventQueue::PushNameChange(Accessible* aTarget)
////////////////////////////////////////////////////////////////////////////////
// EventQueue: private
void
EventQueue::CoalesceEvents()
{
void EventQueue::CoalesceEvents() {
NS_ASSERTION(mEvents.Length(), "There should be at least one pending event!");
uint32_t tail = mEvents.Length() - 1;
AccEvent* tailEvent = mEvents[tail];
switch(tailEvent->mEventRule) {
case AccEvent::eCoalesceReorder:
{
switch (tailEvent->mEventRule) {
case AccEvent::eCoalesceReorder: {
DebugOnly<Accessible*> target = tailEvent->mAccessible.get();
MOZ_ASSERT(target->IsApplication() ||
target->IsOuterDoc() ||
target->IsXULTree(),
"Only app or outerdoc accessible reorder events are in the queue");
MOZ_ASSERT(tailEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER, "only reorder events should be queued");
break; // case eCoalesceReorder
MOZ_ASSERT(
target->IsApplication() || target->IsOuterDoc() ||
target->IsXULTree(),
"Only app or outerdoc accessible reorder events are in the queue");
MOZ_ASSERT(tailEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER,
"only reorder events should be queued");
break; // case eCoalesceReorder
}
case AccEvent::eCoalesceOfSameType:
{
case AccEvent::eCoalesceOfSameType: {
// Coalesce old events by newer event.
for (uint32_t index = tail - 1; index < tail; index--) {
AccEvent* accEvent = mEvents[index];
if (accEvent->mEventType == tailEvent->mEventType &&
accEvent->mEventRule == tailEvent->mEventRule) {
accEvent->mEventRule == tailEvent->mEventRule) {
accEvent->mEventRule = AccEvent::eDoNotEmit;
return;
}
}
break; // case eCoalesceOfSameType
break; // case eCoalesceOfSameType
}
case AccEvent::eCoalesceSelectionChange:
{
case AccEvent::eCoalesceSelectionChange: {
AccSelChangeEvent* tailSelChangeEvent = downcast_accEvent(tailEvent);
for (uint32_t index = tail - 1; index < tail; index--) {
AccEvent* thisEvent = mEvents[index];
if (thisEvent->mEventRule == tailEvent->mEventRule) {
AccSelChangeEvent* thisSelChangeEvent =
downcast_accEvent(thisEvent);
AccSelChangeEvent* thisSelChangeEvent = downcast_accEvent(thisEvent);
// Coalesce selection change events within same control.
if (tailSelChangeEvent->mWidget == thisSelChangeEvent->mWidget) {
CoalesceSelChangeEvents(tailSelChangeEvent, thisSelChangeEvent, index);
CoalesceSelChangeEvents(tailSelChangeEvent, thisSelChangeEvent,
index);
return;
}
}
}
break; // eCoalesceSelectionChange
break; // eCoalesceSelectionChange
}
case AccEvent::eCoalesceStateChange:
{
case AccEvent::eCoalesceStateChange: {
// If state change event is duped then ignore previous event. If state
// change event is opposite to previous event then no event is emitted
// (accessible state wasn't changed).
@@ -152,11 +142,10 @@ EventQueue::CoalesceEvents()
}
}
}
break; // eCoalesceStateChange
break; // eCoalesceStateChange
}
case AccEvent::eCoalesceTextSelChange:
{
case AccEvent::eCoalesceTextSelChange: {
// Coalesce older event by newer event for the same selection or target.
// Events for same selection may have different targets and vice versa one
// target may be pointed by different selections (for latter see
@@ -171,37 +160,33 @@ EventQueue::CoalesceEvents()
thisEvent->mAccessible == tailEvent->mAccessible)
thisEvent->mEventRule = AccEvent::eDoNotEmit;
}
}
break; // eCoalesceTextSelChange
break; // eCoalesceTextSelChange
}
case AccEvent::eRemoveDupes:
{
case AccEvent::eRemoveDupes: {
// Check for repeat events, coalesce newly appended event by more older
// event.
for (uint32_t index = tail - 1; index < tail; index--) {
AccEvent* accEvent = mEvents[index];
if (accEvent->mEventType == tailEvent->mEventType &&
accEvent->mEventRule == tailEvent->mEventRule &&
accEvent->mAccessible == tailEvent->mAccessible) {
accEvent->mEventRule == tailEvent->mEventRule &&
accEvent->mAccessible == tailEvent->mAccessible) {
tailEvent->mEventRule = AccEvent::eDoNotEmit;
return;
}
}
break; // case eRemoveDupes
break; // case eRemoveDupes
}
default:
break; // case eAllowDupes, eDoNotEmit
} // switch
break; // case eAllowDupes, eDoNotEmit
} // switch
}
void
EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
AccSelChangeEvent* aThisEvent,
uint32_t aThisIndex)
{
void EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
AccSelChangeEvent* aThisEvent,
uint32_t aThisIndex) {
aTailEvent->mPreceedingCount = aThisEvent->mPreceedingCount + 1;
// Pack all preceding events into single selection within event
@@ -217,8 +202,7 @@ EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
for (uint32_t jdx = aThisIndex - 1; jdx < aThisIndex; jdx--) {
AccEvent* prevEvent = mEvents[jdx];
if (prevEvent->mEventRule == aTailEvent->mEventRule) {
AccSelChangeEvent* prevSelChangeEvent =
downcast_accEvent(prevEvent);
AccSelChangeEvent* prevSelChangeEvent = downcast_accEvent(prevEvent);
if (prevSelChangeEvent->mWidget == aTailEvent->mWidget)
prevSelChangeEvent->mEventRule = AccEvent::eDoNotEmit;
}
@@ -253,20 +237,20 @@ EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
if (aThisEvent->mEventType == nsIAccessibleEvent::EVENT_SELECTION) {
if (aThisEvent->mPackedEvent) {
aThisEvent->mPackedEvent->mEventType =
aThisEvent->mPackedEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd ?
nsIAccessibleEvent::EVENT_SELECTION_ADD :
nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
aThisEvent->mPackedEvent->mSelChangeType ==
AccSelChangeEvent::eSelectionAdd
? nsIAccessibleEvent::EVENT_SELECTION_ADD
: nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
aThisEvent->mPackedEvent->mEventRule =
AccEvent::eCoalesceSelectionChange;
aThisEvent->mPackedEvent->mEventRule = AccEvent::eCoalesceSelectionChange;
aThisEvent->mPackedEvent = nullptr;
}
aThisEvent->mEventType =
aThisEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd ?
nsIAccessibleEvent::EVENT_SELECTION_ADD :
nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
aThisEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd
? nsIAccessibleEvent::EVENT_SELECTION_ADD
: nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
return;
}
@@ -280,9 +264,7 @@ EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
////////////////////////////////////////////////////////////////////////////////
// EventQueue: event queue
void
EventQueue::ProcessEventQueue()
{
void EventQueue::ProcessEventQueue() {
// Process only currently queued events.
nsTArray<RefPtr<AccEvent> > events;
events.SwapElements(mEvents);
@@ -300,8 +282,7 @@ EventQueue::ProcessEventQueue()
AccEvent* event = events[idx];
if (event->mEventRule != AccEvent::eDoNotEmit) {
Accessible* target = event->GetAccessible();
if (!target || target->IsDefunct())
continue;
if (!target || target->IsDefunct()) continue;
// Dispatch the focus event if target is still focused.
if (event->mEventType == nsIAccessibleEvent::EVENT_FOCUS) {
@@ -310,38 +291,41 @@ EventQueue::ProcessEventQueue()
}
// Dispatch caret moved and text selection change events.
if (event->mEventType == nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED) {
if (event->mEventType ==
nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED) {
SelectionMgr()->ProcessTextSelChangeEvent(event);
continue;
}
// Fire selected state change events in support to selection events.
if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION_ADD) {
nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
true, event->mIsFromUserInput);
nsEventShell::FireEvent(event->mAccessible, states::SELECTED, true,
event->mIsFromUserInput);
} else if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION_REMOVE) {
nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
false, event->mIsFromUserInput);
} else if (event->mEventType ==
nsIAccessibleEvent::EVENT_SELECTION_REMOVE) {
nsEventShell::FireEvent(event->mAccessible, states::SELECTED, false,
event->mIsFromUserInput);
} else if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION) {
AccSelChangeEvent* selChangeEvent = downcast_accEvent(event);
nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
(selChangeEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd),
(selChangeEvent->mSelChangeType ==
AccSelChangeEvent::eSelectionAdd),
event->mIsFromUserInput);
if (selChangeEvent->mPackedEvent) {
nsEventShell::FireEvent(selChangeEvent->mPackedEvent->mAccessible,
states::SELECTED,
(selChangeEvent->mPackedEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd),
selChangeEvent->mPackedEvent->mIsFromUserInput);
nsEventShell::FireEvent(
selChangeEvent->mPackedEvent->mAccessible, states::SELECTED,
(selChangeEvent->mPackedEvent->mSelChangeType ==
AccSelChangeEvent::eSelectionAdd),
selChangeEvent->mPackedEvent->mIsFromUserInput);
}
}
nsEventShell::FireEvent(event);
}
if (!mDocument)
return;
if (!mDocument) return;
}
}

View File

@@ -16,10 +16,9 @@ class DocAccessible;
/**
* Used to organize and coalesce pending events.
*/
class EventQueue
{
protected:
explicit EventQueue(DocAccessible* aDocument) : mDocument(aDocument) { }
class EventQueue {
protected:
explicit EventQueue(DocAccessible* aDocument) : mDocument(aDocument) {}
/**
* Put an accessible event into the queue to process it later.
@@ -36,9 +35,9 @@ protected:
*/
void ProcessEventQueue();
private:
private:
EventQueue(const EventQueue&) = delete;
EventQueue& operator = (const EventQueue&) = delete;
EventQueue& operator=(const EventQueue&) = delete;
// Event queue processing
/**
@@ -58,7 +57,7 @@ private:
AccSelChangeEvent* aThisEvent,
uint32_t aThisIndex);
protected:
protected:
/**
* The document accessible reference owning this queue.
*/
@@ -71,7 +70,7 @@ protected:
nsTArray<RefPtr<AccEvent>> mEvents;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif // mozilla_a11y_EventQueue_h_
#endif // mozilla_a11y_EventQueue_h_

View File

@@ -24,11 +24,11 @@ using namespace mozilla::a11y;
EventTree* const TreeMutation::kNoEventTree = reinterpret_cast<EventTree*>(-1);
TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents) :
mParent(aParent), mStartIdx(UINT32_MAX),
mStateFlagsCopy(mParent->mStateFlags),
mQueueEvents(!aNoEvents)
{
TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents)
: mParent(aParent),
mStartIdx(UINT32_MAX),
mStateFlagsCopy(mParent->mStateFlags),
mQueueEvents(!aNoEvents) {
#ifdef DEBUG
mIsDone = false;
#endif
@@ -50,14 +50,11 @@ TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents) :
mParent->mStateFlags |= Accessible::eKidsMutating;
}
TreeMutation::~TreeMutation()
{
TreeMutation::~TreeMutation() {
MOZ_ASSERT(mIsDone, "Done() must be called explicitly");
}
void
TreeMutation::AfterInsertion(Accessible* aChild)
{
void TreeMutation::AfterInsertion(Accessible* aChild) {
MOZ_ASSERT(aChild->Parent() == mParent);
if (static_cast<uint32_t>(aChild->mIndexInParent) < mStartIdx) {
@@ -74,9 +71,7 @@ TreeMutation::AfterInsertion(Accessible* aChild)
aChild->SetShowEventTarget(true);
}
void
TreeMutation::BeforeRemoval(Accessible* aChild, bool aNoShutdown)
{
void TreeMutation::BeforeRemoval(Accessible* aChild, bool aNoShutdown) {
MOZ_ASSERT(aChild->Parent() == mParent);
if (static_cast<uint32_t>(aChild->mIndexInParent) < mStartIdx) {
@@ -93,17 +88,16 @@ TreeMutation::BeforeRemoval(Accessible* aChild, bool aNoShutdown)
}
}
void
TreeMutation::Done()
{
void TreeMutation::Done() {
MOZ_ASSERT(mParent->mStateFlags & Accessible::eKidsMutating);
mParent->mStateFlags &= ~Accessible::eKidsMutating;
uint32_t length = mParent->mChildren.Length();
#ifdef DEBUG
for (uint32_t idx = 0; idx < mStartIdx && idx < length; idx++) {
MOZ_ASSERT(mParent->mChildren[idx]->mIndexInParent == static_cast<int32_t>(idx),
"Wrong index detected");
MOZ_ASSERT(
mParent->mChildren[idx]->mIndexInParent == static_cast<int32_t>(idx),
"Wrong index detected");
}
#endif
@@ -130,9 +124,7 @@ TreeMutation::Done()
}
#ifdef A11Y_LOG
const char*
TreeMutation::PrefixLog(void* aData, Accessible* aAcc)
{
const char* TreeMutation::PrefixLog(void* aData, Accessible* aAcc) {
TreeMutation* thisObj = reinterpret_cast<TreeMutation*>(aData);
if (thisObj->mParent == aAcc) {
return "_X_";
@@ -145,21 +137,16 @@ TreeMutation::PrefixLog(void* aData, Accessible* aAcc)
}
#endif
////////////////////////////////////////////////////////////////////////////////
// EventTree
void
EventTree::Shown(Accessible* aChild)
{
void EventTree::Shown(Accessible* aChild) {
RefPtr<AccShowEvent> ev = new AccShowEvent(aChild);
Controller(aChild)->WithdrawPrecedingEvents(&ev->mPrecedingEvents);
Mutated(ev);
}
void
EventTree::Hidden(Accessible* aChild, bool aNeedsShutdown)
{
void EventTree::Hidden(Accessible* aChild, bool aNeedsShutdown) {
RefPtr<AccHideEvent> ev = new AccHideEvent(aChild, aNeedsShutdown);
if (!aNeedsShutdown) {
Controller(aChild)->StorePrecedingEvent(ev);
@@ -167,9 +154,7 @@ EventTree::Hidden(Accessible* aChild, bool aNeedsShutdown)
Mutated(ev);
}
void
EventTree::Process(const RefPtr<DocAccessible>& aDeathGrip)
{
void EventTree::Process(const RefPtr<DocAccessible>& aDeathGrip) {
while (mFirst) {
// Skip a node and its subtree if its container is not in the document.
if (mFirst->mContainer->IsInDocument()) {
@@ -250,9 +235,7 @@ EventTree::Process(const RefPtr<DocAccessible>& aDeathGrip)
mDependentEvents.Clear();
}
EventTree*
EventTree::FindOrInsert(Accessible* aContainer)
{
EventTree* EventTree::FindOrInsert(Accessible* aContainer) {
if (!mFirst) {
mFirst.reset(new EventTree(aContainer, mDependentEvents.IsEmpty()));
return mFirst.get();
@@ -263,7 +246,8 @@ EventTree::FindOrInsert(Accessible* aContainer)
do {
MOZ_ASSERT(!node->mContainer->IsApplication(),
"No event for application accessible is expected here");
MOZ_ASSERT(!node->mContainer->IsDefunct(), "An event target has to be alive");
MOZ_ASSERT(!node->mContainer->IsDefunct(),
"An event target has to be alive");
// Case of same target.
if (node->mContainer == aContainer) {
@@ -289,7 +273,7 @@ EventTree::FindOrInsert(Accessible* aContainer)
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eEventTree)) {
logging::MsgBegin("EVENTS_TREE",
"Rejecting node contained by show/hide");
"Rejecting node contained by show/hide");
logging::AccessibleInfo("Node", aContainer);
logging::MsgEnd();
}
@@ -298,8 +282,8 @@ EventTree::FindOrInsert(Accessible* aContainer)
// on stack, and if so, then connect it to the parent show event.
if (ev->IsShow()) {
AccShowEvent* showEv = downcast_accEvent(ev);
Controller(aContainer)->
WithdrawPrecedingEvents(&showEv->mPrecedingEvents);
Controller(aContainer)
->WithdrawPrecedingEvents(&showEv->mPrecedingEvents);
}
return nullptr;
}
@@ -314,8 +298,8 @@ EventTree::FindOrInsert(Accessible* aContainer)
// If the given container contains a current node
// then
// if show or hide of the given node contains a grand parent of the current node
// then ignore the current node and its show and hide events
// if show or hide of the given node contains a grand parent of the
// current node then ignore the current node and its show and hide events
// otherwise ignore the current node, but not its show and hide events
Accessible* curParent = node->mContainer;
while (curParent && !curParent->IsDoc()) {
@@ -328,7 +312,8 @@ EventTree::FindOrInsert(Accessible* aContainer)
// its parent.
node->mFireReorder = false;
UniquePtr<EventTree>& nodeOwnerRef = prevNode ? prevNode->mNext : mFirst;
UniquePtr<EventTree> newNode(new EventTree(aContainer, mDependentEvents.IsEmpty()));
UniquePtr<EventTree> newNode(
new EventTree(aContainer, mDependentEvents.IsEmpty()));
newNode->mFirst = std::move(nodeOwnerRef);
nodeOwnerRef = std::move(newNode);
nodeOwnerRef->mNext = std::move(node->mNext);
@@ -381,9 +366,7 @@ EventTree::FindOrInsert(Accessible* aContainer)
return prevNode->mNext.get();
}
void
EventTree::Clear()
{
void EventTree::Clear() {
mFirst = nullptr;
mNext = nullptr;
mContainer = nullptr;
@@ -399,9 +382,7 @@ EventTree::Clear()
mDependentEvents.Clear();
}
const EventTree*
EventTree::Find(const Accessible* aContainer) const
{
const EventTree* EventTree::Find(const Accessible* aContainer) const {
const EventTree* et = this;
while (et) {
if (et->mContainer == aContainer) {
@@ -427,9 +408,7 @@ EventTree::Find(const Accessible* aContainer) const
}
#ifdef A11Y_LOG
void
EventTree::Log(uint32_t aLevel) const
{
void EventTree::Log(uint32_t aLevel) const {
if (aLevel == UINT32_MAX) {
if (mFirst) {
mFirst->Log(0);
@@ -458,8 +437,7 @@ EventTree::Log(uint32_t aLevel) const
logging::AccessibleInfo("preceding",
showEv->mPrecedingEvents[i]->mAccessible);
}
}
else {
} else {
for (uint32_t i = 0; i < aLevel + 1; i++) {
printf(" ");
}
@@ -477,9 +455,7 @@ EventTree::Log(uint32_t aLevel) const
}
#endif
void
EventTree::Mutated(AccMutationEvent* aEv)
{
void EventTree::Mutated(AccMutationEvent* aEv) {
// If shown or hidden node is a root of previously mutated subtree, then
// discard those subtree mutations as we are no longer interested in them.
UniquePtr<EventTree>* node = &mFirst;
@@ -507,8 +483,9 @@ EventTree::Mutated(AccMutationEvent* aEv)
if (childEv->IsShow()) {
AccShowEvent* childShowEv = downcast_accEvent(childEv);
if (childShowEv->mPrecedingEvents.Length() > 0) {
Controller(mContainer)->StorePrecedingEvents(
std::move(childShowEv->mPrecedingEvents));
Controller(mContainer)
->StorePrecedingEvents(
std::move(childShowEv->mPrecedingEvents));
}
}
}
@@ -527,14 +504,17 @@ EventTree::Mutated(AccMutationEvent* aEv)
if (logging::IsEnabled(logging::eEventTree)) {
logging::MsgBegin("EVENTS_TREE", "Adopt preceding events");
logging::AccessibleInfo("Parent", aEv->mAccessible);
for (uint32_t j = 0; j < showChildEv->mPrecedingEvents.Length(); j++) {
logging::AccessibleInfo("Adoptee",
showChildEv->mPrecedingEvents[i]->mAccessible);
for (uint32_t j = 0;
j < showChildEv->mPrecedingEvents.Length(); j++) {
logging::AccessibleInfo(
"Adoptee",
showChildEv->mPrecedingEvents[i]->mAccessible);
}
logging::MsgEnd();
}
#endif
showEv->mPrecedingEvents.AppendElements(showChildEv->mPrecedingEvents);
showEv->mPrecedingEvents.AppendElements(
showChildEv->mPrecedingEvents);
}
}
}
@@ -566,8 +546,7 @@ EventTree::Mutated(AccMutationEvent* aEv)
if (prevHideEvent->mNextSibling == hideEvent->mAccessible) {
hideEvent->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
}
else if (prevHideEvent->mPrevSibling == hideEvent->mAccessible) {
} else if (prevHideEvent->mPrevSibling == hideEvent->mAccessible) {
uint32_t oldLen = prevTextEvent->GetLength();
hideEvent->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
prevTextEvent->mStart -= prevTextEvent->GetLength() - oldLen;
@@ -575,23 +554,22 @@ EventTree::Mutated(AccMutationEvent* aEv)
hideEvent->mTextChangeEvent.swap(prevEvent->mTextChangeEvent);
}
}
else {
} else {
AccTextChangeEvent* prevTextEvent = prevEvent->mTextChangeEvent;
if (prevTextEvent) {
if (aEv->mAccessible->IndexInParent() ==
prevEvent->mAccessible->IndexInParent() + 1) {
// If tail target was inserted after this target, i.e. tail target is next
// sibling of this target.
// If tail target was inserted after this target, i.e. tail target is
// next sibling of this target.
aEv->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
}
else if (aEv->mAccessible->IndexInParent() ==
prevEvent->mAccessible->IndexInParent() - 1) {
} else if (aEv->mAccessible->IndexInParent() ==
prevEvent->mAccessible->IndexInParent() - 1) {
// If tail target was inserted before this target, i.e. tail target is
// previous sibling of this target.
nsAutoString startText;
aEv->mAccessible->AppendTextTo(startText);
prevTextEvent->mModifiedText = startText + prevTextEvent->mModifiedText;
prevTextEvent->mModifiedText =
startText + prevTextEvent->mModifiedText;
prevTextEvent->mStart -= startText.Length();
}
@@ -614,7 +592,7 @@ EventTree::Mutated(AccMutationEvent* aEv)
}
int32_t offset = mContainer->AsHyperText()->GetChildOffset(aEv->mAccessible);
aEv->mTextChangeEvent =
new AccTextChangeEvent(mContainer, offset, text, aEv->IsShow(),
aEv->mIsFromUserInput ? eFromUserInput : eNoUserInput);
aEv->mTextChangeEvent = new AccTextChangeEvent(
mContainer, offset, text, aEv->IsShow(),
aEv->mIsFromUserInput ? eFromUserInput : eNoUserInput);
}

View File

@@ -24,9 +24,8 @@ class NotificationController;
* have an object of this class on the stack when calling methods that mutate
* the accessible tree.
*/
class TreeMutation final
{
public:
class TreeMutation final {
public:
static const bool kNoEvents = true;
static const bool kNoShutdown = true;
@@ -37,9 +36,10 @@ public:
void BeforeRemoval(Accessible* aChild, bool aNoShutdown = false);
void Done();
private:
NotificationController* Controller() const
{ return mParent->Document()->Controller(); }
private:
NotificationController* Controller() const {
return mParent->Document()->Controller();
}
static EventTree* const kNoEventTree;
@@ -61,17 +61,21 @@ private:
#endif
};
/**
* A mutation events coalescence structure.
*/
class EventTree final {
public:
EventTree() :
mFirst(nullptr), mNext(nullptr), mContainer(nullptr), mFireReorder(false) { }
explicit EventTree(Accessible* aContainer, bool aFireReorder) :
mFirst(nullptr), mNext(nullptr), mContainer(aContainer),
mFireReorder(aFireReorder) { }
public:
EventTree()
: mFirst(nullptr),
mNext(nullptr),
mContainer(nullptr),
mFireReorder(false) {}
explicit EventTree(Accessible* aContainer, bool aFireReorder)
: mFirst(nullptr),
mNext(nullptr),
mContainer(aContainer),
mFireReorder(aFireReorder) {}
~EventTree() { Clear(); }
void Shown(Accessible* aTarget);
@@ -91,7 +95,7 @@ public:
void Log(uint32_t aLevel = UINT32_MAX) const;
#endif
private:
private:
/**
* Processes the event queue and fires events.
*/
@@ -111,14 +115,14 @@ private:
nsTArray<RefPtr<AccMutationEvent>> mDependentEvents;
bool mFireReorder;
static NotificationController* Controller(Accessible* aAcc)
{ return aAcc->Document()->Controller(); }
static NotificationController* Controller(Accessible* aAcc) {
return aAcc->Document()->Controller();
}
friend class NotificationController;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif // mozilla_a11y_EventQueue_h_
#endif // mozilla_a11y_EventQueue_h_

View File

@@ -12,40 +12,29 @@
using namespace mozilla::a11y;
using namespace mozilla::a11y::filters;
uint32_t
filters::GetSelected(Accessible* aAccessible)
{
if (aAccessible->State() & states::SELECTED)
return eMatch | eSkipSubtree;
uint32_t filters::GetSelected(Accessible* aAccessible) {
if (aAccessible->State() & states::SELECTED) return eMatch | eSkipSubtree;
return eSkip;
}
uint32_t
filters::GetSelectable(Accessible* aAccessible)
{
uint32_t filters::GetSelectable(Accessible* aAccessible) {
if (aAccessible->InteractiveState() & states::SELECTABLE)
return eMatch | eSkipSubtree;
return eSkip;
}
uint32_t
filters::GetRow(Accessible* aAccessible)
{
if (aAccessible->IsTableRow())
return eMatch | eSkipSubtree;
uint32_t filters::GetRow(Accessible* aAccessible) {
if (aAccessible->IsTableRow()) return eMatch | eSkipSubtree;
// Look for rows inside rowgroup.
a11y::role role = aAccessible->Role();
if (role == roles::GROUPING)
return eSkip;
if (role == roles::GROUPING) return eSkip;
return eSkipSubtree;
}
uint32_t
filters::GetCell(Accessible* aAccessible)
{
uint32_t filters::GetCell(Accessible* aAccessible) {
return aAccessible->IsTableCell() ? eMatch : eSkipSubtree;
}

View File

@@ -17,16 +17,12 @@ class Accessible;
namespace filters {
enum EResult {
eSkip = 0,
eMatch = 1,
eSkipSubtree = 2
};
enum EResult { eSkip = 0, eMatch = 1, eSkipSubtree = 2 };
/**
* Return true if the traversed accessible complies with filter.
*/
typedef uint32_t (*FilterFuncPtr) (Accessible*);
typedef uint32_t (*FilterFuncPtr)(Accessible*);
/**
* Matches selected/selectable accessibles in subtree.
@@ -43,8 +39,8 @@ uint32_t GetRow(Accessible* aAccessible);
* Matches cell accessibles in children.
*/
uint32_t GetCell(Accessible* aAccessible);
} // namespace filters
} // namespace a11y
} // namespace mozilla
} // namespace filters
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -22,35 +22,26 @@
namespace mozilla {
namespace a11y {
FocusManager::FocusManager()
{
}
FocusManager::FocusManager() {}
FocusManager::~FocusManager()
{
}
FocusManager::~FocusManager() {}
Accessible*
FocusManager::FocusedAccessible() const
{
if (mActiveItem)
return mActiveItem;
Accessible* FocusManager::FocusedAccessible() const {
if (mActiveItem) return mActiveItem;
nsINode* focusedNode = FocusedDOMNode();
if (focusedNode) {
DocAccessible* doc =
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
return doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr;
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
return doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode)
: nullptr;
}
return nullptr;
}
bool
FocusManager::IsFocused(const Accessible* aAccessible) const
{
if (mActiveItem)
return mActiveItem == aAccessible;
bool FocusManager::IsFocused(const Accessible* aAccessible) const {
if (mActiveItem) return mActiveItem == aAccessible;
nsINode* focusedNode = FocusedDOMNode();
if (focusedNode) {
@@ -62,43 +53,37 @@ FocusManager::IsFocused(const Accessible* aAccessible) const
// bug 638465.
if (focusedNode->OwnerDoc() == aAccessible->GetNode()->OwnerDoc()) {
DocAccessible* doc =
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
return aAccessible ==
(doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr);
(doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode)
: nullptr);
}
}
return false;
}
bool
FocusManager::IsFocusWithin(const Accessible* aContainer) const
{
bool FocusManager::IsFocusWithin(const Accessible* aContainer) const {
Accessible* child = FocusedAccessible();
while (child) {
if (child == aContainer)
return true;
if (child == aContainer) return true;
child = child->Parent();
}
return false;
}
FocusManager::FocusDisposition
FocusManager::IsInOrContainsFocus(const Accessible* aAccessible) const
{
FocusManager::FocusDisposition FocusManager::IsInOrContainsFocus(
const Accessible* aAccessible) const {
Accessible* focus = FocusedAccessible();
if (!focus)
return eNone;
if (!focus) return eNone;
// If focused.
if (focus == aAccessible)
return eFocused;
if (focus == aAccessible) return eFocused;
// If contains the focus.
Accessible* child = focus->Parent();
while (child) {
if (child == aAccessible)
return eContainsFocus;
if (child == aAccessible) return eContainsFocus;
child = child->Parent();
}
@@ -106,8 +91,7 @@ FocusManager::IsInOrContainsFocus(const Accessible* aAccessible) const
// If contained by focus.
child = aAccessible->Parent();
while (child) {
if (child == focus)
return eContainedByFocus;
if (child == focus) return eContainedByFocus;
child = child->Parent();
}
@@ -115,9 +99,7 @@ FocusManager::IsInOrContainsFocus(const Accessible* aAccessible) const
return eNone;
}
void
FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
{
void FocusManager::NotifyOfDOMFocus(nsISupports* aTarget) {
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("DOM focus", "Target", aTarget);
@@ -128,21 +110,19 @@ FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
if (targetNode) {
DocAccessible* document =
GetAccService()->GetDocAccessible(targetNode->OwnerDoc());
GetAccService()->GetDocAccessible(targetNode->OwnerDoc());
if (document) {
// Set selection listener for focused element.
if (targetNode->IsElement())
SelectionMgr()->SetControlSelectionListener(targetNode->AsElement());
document->HandleNotification<FocusManager, nsINode>
(this, &FocusManager::ProcessDOMFocus, targetNode);
document->HandleNotification<FocusManager, nsINode>(
this, &FocusManager::ProcessDOMFocus, targetNode);
}
}
}
void
FocusManager::NotifyOfDOMBlur(nsISupports* aTarget)
{
void FocusManager::NotifyOfDOMBlur(nsISupports* aTarget) {
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("DOM blur", "Target", aTarget);
@@ -155,38 +135,33 @@ FocusManager::NotifyOfDOMBlur(nsISupports* aTarget)
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
if (targetNode && targetNode->OwnerDoc() == FocusedDOMDocument()) {
nsIDocument* DOMDoc = targetNode->OwnerDoc();
DocAccessible* document =
GetAccService()->GetDocAccessible(DOMDoc);
DocAccessible* document = GetAccService()->GetDocAccessible(DOMDoc);
if (document) {
// Clear selection listener for previously focused element.
if (targetNode->IsElement())
SelectionMgr()->ClearControlSelectionListener();
document->HandleNotification<FocusManager, nsINode>
(this, &FocusManager::ProcessDOMFocus, DOMDoc);
document->HandleNotification<FocusManager, nsINode>(
this, &FocusManager::ProcessDOMFocus, DOMDoc);
}
}
}
void
FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
{
void FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive) {
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("active item changed", "Item", aItem);
#endif
// Nothing changed, happens for XUL trees and HTML selects.
if (aItem && aItem == mActiveItem)
return;
if (aItem && aItem == mActiveItem) return;
mActiveItem = nullptr;
if (aItem && aCheckIfActive) {
Accessible* widget = aItem->ContainerWidget();
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveWidget(widget);
if (logging::IsEnabled(logging::eFocus)) logging::ActiveWidget(widget);
#endif
if (!widget || !widget->IsActiveWidget() || !widget->AreItemsOperable())
return;
@@ -221,63 +196,54 @@ FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
}
}
void
FocusManager::ForceFocusEvent()
{
void FocusManager::ForceFocusEvent() {
nsINode* focusedNode = FocusedDOMNode();
if (focusedNode) {
DocAccessible* document =
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
if (document) {
document->HandleNotification<FocusManager, nsINode>
(this, &FocusManager::ProcessDOMFocus, focusedNode);
document->HandleNotification<FocusManager, nsINode>(
this, &FocusManager::ProcessDOMFocus, focusedNode);
}
}
}
void
FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
Accessible* aTarget)
{
void FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
Accessible* aTarget) {
MOZ_ASSERT(aDocument, "No document for focused accessible!");
if (aDocument) {
RefPtr<AccEvent> event =
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget,
eAutoDetect, AccEvent::eCoalesceOfSameType);
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget, eAutoDetect,
AccEvent::eCoalesceOfSameType);
aDocument->FireDelayedEvent(event);
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusDispatched(aTarget);
if (logging::IsEnabled(logging::eFocus)) logging::FocusDispatched(aTarget);
#endif
}
}
void
FocusManager::ProcessDOMFocus(nsINode* aTarget)
{
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;
GetAccService()->GetDocAccessible(aTarget->OwnerDoc());
if (!document) return;
Accessible* target = document->GetAccessibleEvenIfNotInMapOrContainer(aTarget);
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;
if (!focusedNode) return;
Accessible* DOMFocus =
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
if (target != DOMFocus)
return;
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
if (target != DOMFocus) return;
Accessible* activeItem = target->CurrentItem();
if (activeItem) {
@@ -289,9 +255,7 @@ FocusManager::ProcessDOMFocus(nsINode* aTarget)
}
}
void
FocusManager::ProcessFocusEvent(AccEvent* aEvent)
{
void FocusManager::ProcessFocusEvent(AccEvent* aEvent) {
MOZ_ASSERT(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
"Focus event is expected!");
@@ -299,18 +263,15 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
// 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->Document();
nsINode* focusedNode = FocusedDOMNode();
if (!focusedNode)
return;
if (!focusedNode) return;
Accessible* DOMFocus =
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
if (target != DOMFocus)
return;
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
if (target != DOMFocus) return;
Accessible* activeItem = target->CurrentItem();
if (activeItem) {
@@ -323,7 +284,8 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
if (target->IsARIARole(nsGkAtoms::menuitem)) {
// The focus was moved into menu.
Accessible* ARIAMenubar = nullptr;
for (Accessible* parent = target->Parent(); parent; parent = parent->Parent()) {
for (Accessible* parent = target->Parent(); parent;
parent = parent->Parent()) {
if (parent->IsARIARole(nsGkAtoms::menubar)) {
ARIAMenubar = parent;
break;
@@ -340,8 +302,8 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
// Leaving ARIA menu. Fire menu_end event on current menubar.
if (mActiveARIAMenubar) {
RefPtr<AccEvent> menuEndEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
aEvent->FromUserInput());
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
aEvent->FromUserInput());
nsEventShell::FireEvent(menuEndEvent);
}
@@ -350,16 +312,16 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
// Entering ARIA menu. Fire menu_start event.
if (mActiveARIAMenubar) {
RefPtr<AccEvent> menuStartEvent =
new AccEvent(nsIAccessibleEvent::EVENT_MENU_START,
mActiveARIAMenubar, aEvent->FromUserInput());
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());
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
aEvent->FromUserInput());
nsEventShell::FireEvent(menuEndEvent);
mActiveARIAMenubar = nullptr;
@@ -375,8 +337,8 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
// offset before the caret move event is handled.
SelectionMgr()->ResetCaretOffset();
RefPtr<AccEvent> focusEvent =
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, target, aEvent->FromUserInput());
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
@@ -395,9 +357,7 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
}
}
nsINode*
FocusManager::FocusedDOMNode() const
{
nsINode* FocusManager::FocusedDOMNode() const {
nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
nsIContent* focusedElm = DOMFocusManager->GetFocusedElement();
@@ -416,12 +376,10 @@ FocusManager::FocusedDOMNode() const
return focusedWnd ? focusedWnd->GetExtantDoc() : nullptr;
}
nsIDocument*
FocusManager::FocusedDOMDocument() const
{
nsIDocument* FocusManager::FocusedDOMDocument() const {
nsINode* focusedNode = FocusedDOMNode();
return focusedNode ? focusedNode->OwnerDoc() : nullptr;
}
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla

View File

@@ -21,9 +21,8 @@ class DocAccessible;
/**
* Manage the accessible focus. Used to fire and process accessible events.
*/
class FocusManager
{
public:
class FocusManager {
public:
virtual ~FocusManager();
/**
@@ -40,8 +39,9 @@ public:
* Return true if the given accessible is an active item, i.e. an item that
* is current within the active widget.
*/
inline bool IsActiveItem(const Accessible* aAccessible)
{ return aAccessible == mActiveItem; }
inline bool IsActiveItem(const Accessible* aAccessible) {
return aAccessible == mActiveItem;
}
/**
* Return DOM node having DOM focus.
@@ -51,8 +51,9 @@ public:
/**
* Return true if given DOM node has DOM focus.
*/
inline bool HasDOMFocus(const nsINode* aNode) const
{ return aNode == FocusedDOMNode(); }
inline bool HasDOMFocus(const nsINode* aNode) const {
return aNode == FocusedDOMNode();
}
/**
* Return true if focused accessible is within the given container.
@@ -63,12 +64,7 @@ public:
* Return whether the given accessible is focused or contains the focus or
* contained by focused accessible.
*/
enum FocusDisposition {
eNone,
eFocused,
eContainsFocus,
eContainedByFocus
};
enum FocusDisposition { eNone, eFocused, eContainsFocus, eContainedByFocus };
FocusDisposition IsInOrContainsFocus(const Accessible* aAccessible) const;
//////////////////////////////////////////////////////////////////////////////
@@ -111,24 +107,24 @@ public:
*/
void ProcessFocusEvent(AccEvent* aEvent);
protected:
protected:
FocusManager();
private:
private:
FocusManager(const FocusManager&);
FocusManager& operator =(const FocusManager&);
FocusManager& operator=(const FocusManager&);
/**
* Return DOM document having DOM focus.
*/
nsIDocument* FocusedDOMDocument() const;
private:
private:
RefPtr<Accessible> mActiveItem;
RefPtr<Accessible> mActiveARIAMenubar;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -32,22 +32,18 @@ namespace a11y {
* decoration on the ID generated by IDSet.
* @see mozilla::a11y::MsaaIdGenerator
*/
class IDSet
{
public:
class IDSet {
public:
constexpr explicit IDSet(const uint32_t aMaxIdBits)
: mBitSet()
, mIdx(0)
, mMaxId((1UL << aMaxIdBits) - 1UL)
, mMaxIdx(mMaxId / bitsPerElt)
{
}
: mBitSet(),
mIdx(0),
mMaxId((1UL << aMaxIdBits) - 1UL),
mMaxIdx(mMaxId / bitsPerElt) {}
/**
* Return a new unique id.
*/
uint32_t GetID()
{
uint32_t GetID() {
uint32_t idx = mIdx;
while (true) {
BitSetElt* elt = mBitSet.findOrInsert(BitSetElt(idx));
@@ -81,8 +77,7 @@ public:
/**
* Free a no longer required id so it may be allocated again.
*/
void ReleaseID(uint32_t aID)
{
void ReleaseID(uint32_t aID) {
MOZ_ASSERT(aID < mMaxId);
uint32_t idx = aID / bitsPerElt;
@@ -97,22 +92,20 @@ public:
}
}
private:
private:
static const unsigned int wordsPerElt = 2;
static const unsigned int bitsPerWord = 64;
static const unsigned int bitsPerElt = wordsPerElt * bitsPerWord;
struct BitSetElt : mozilla::SplayTreeNode<BitSetElt>
{
explicit BitSetElt(uint32_t aIdx) :
mIdx(aIdx)
{ mBitvec[0] = mBitvec[1] = 0; }
struct BitSetElt : mozilla::SplayTreeNode<BitSetElt> {
explicit BitSetElt(uint32_t aIdx) : mIdx(aIdx) {
mBitvec[0] = mBitvec[1] = 0;
}
uint64_t mBitvec[wordsPerElt];
uint32_t mIdx;
static int compare(const BitSetElt& a, const BitSetElt& b)
{
static int compare(const BitSetElt& a, const BitSetElt& b) {
if (a.mIdx == b.mIdx) {
return 0;
}
@@ -130,7 +123,7 @@ private:
const uint32_t mMaxIdx;
};
}
}
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -39,33 +39,28 @@ struct ModuleRep {
logging::EModules mModule;
};
static ModuleRep sModuleMap[] = {
{ "docload", logging::eDocLoad },
{ "doccreate", logging::eDocCreate },
{ "docdestroy", logging::eDocDestroy },
{ "doclifecycle", logging::eDocLifeCycle },
static ModuleRep sModuleMap[] = {{"docload", logging::eDocLoad},
{"doccreate", logging::eDocCreate},
{"docdestroy", logging::eDocDestroy},
{"doclifecycle", logging::eDocLifeCycle},
{ "events", logging::eEvents },
{ "eventTree", logging::eEventTree },
{ "platforms", logging::ePlatforms },
{ "text", logging::eText },
{ "tree", logging::eTree },
{"events", logging::eEvents},
{"eventTree", logging::eEventTree},
{"platforms", logging::ePlatforms},
{"text", logging::eText},
{"tree", logging::eTree},
{ "DOMEvents", logging::eDOMEvents },
{ "focus", logging::eFocus },
{ "selection", logging::eSelection },
{ "notifications", logging::eNotifications },
{"DOMEvents", logging::eDOMEvents},
{"focus", logging::eFocus},
{"selection", logging::eSelection},
{"notifications", logging::eNotifications},
{ "stack", logging::eStack },
{ "verbose", logging::eVerbose }
};
{"stack", logging::eStack},
{"verbose", logging::eVerbose}};
static void
EnableLogging(const char* aModulesStr)
{
static void EnableLogging(const char* aModulesStr) {
sModules = 0;
if (!aModulesStr)
return;
if (!aModulesStr) return;
const char* token = aModulesStr;
while (*token != '\0') {
@@ -74,8 +69,7 @@ EnableLogging(const char* aModulesStr)
if (strncmp(token, sModuleMap[idx].mStr, tokenLen) == 0) {
#if !defined(MOZ_PROFILING) && (!defined(DEBUG) || defined(MOZ_OPTIMIZE))
// Stack tracing on profiling enabled or debug not optimized builds.
if (strncmp(token, "stack", tokenLen) == 0)
break;
if (strncmp(token, "stack", tokenLen) == 0) break;
#endif
sModules |= sModuleMap[idx].mModule;
printf("\n\nmodule enabled: %s\n", sModuleMap[idx].mStr);
@@ -84,20 +78,15 @@ EnableLogging(const char* aModulesStr)
}
token += tokenLen;
if (*token == ',')
token++; // skip ',' char
if (*token == ',') token++; // skip ',' char
}
}
static void
LogDocURI(nsIDocument* aDocumentNode)
{
static void LogDocURI(nsIDocument* aDocumentNode) {
printf("uri: %s", aDocumentNode->GetDocumentURI()->GetSpecOrDefault().get());
}
static void
LogDocShellState(nsIDocument* aDocumentNode)
{
static void LogDocShellState(nsIDocument* aDocumentNode) {
printf("docshell busy: ");
nsAutoCString docShellBusy;
@@ -118,20 +107,16 @@ LogDocShellState(nsIDocument* aDocumentNode)
}
}
static void
LogDocType(nsIDocument* aDocumentNode)
{
static void LogDocType(nsIDocument* aDocumentNode) {
if (aDocumentNode->IsActive()) {
bool isContent = nsCoreUtils::IsContentDocument(aDocumentNode);
printf("%s document", (isContent ? "content" : "chrome"));
} else {
printf("document type: [failed]");\
printf("document type: [failed]");
}
}
static void
LogDocShellTree(nsIDocument* aDocumentNode)
{
static void LogDocShellTree(nsIDocument* aDocumentNode) {
if (aDocumentNode->IsActive()) {
nsCOMPtr<nsIDocShellTreeItem> treeItem(aDocumentNode->GetDocShell());
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
@@ -144,14 +129,12 @@ LogDocShellTree(nsIDocument* aDocumentNode)
}
}
static void
LogDocState(nsIDocument* aDocumentNode)
{
static void LogDocState(nsIDocument* aDocumentNode) {
const char* docState = nullptr;
nsIDocument::ReadyState docStateFlag = aDocumentNode->GetReadyStateEnum();
switch (docStateFlag) {
case nsIDocument::READYSTATE_UNINITIALIZED:
docState = "uninitialized";
docState = "uninitialized";
break;
case nsIDocument::READYSTATE_LOADING:
docState = "loading";
@@ -168,7 +151,8 @@ LogDocState(nsIDocument* aDocumentNode)
printf(", %sinitial", aDocumentNode->IsInitialDocument() ? "" : "not ");
printf(", %sshowing", aDocumentNode->IsShowing() ? "" : "not ");
printf(", %svisible", aDocumentNode->IsVisible() ? "" : "not ");
printf(", %svisible considering ancestors", aDocumentNode->IsVisibleConsideringAncestors() ? "" : "not ");
printf(", %svisible considering ancestors",
aDocumentNode->IsVisibleConsideringAncestors() ? "" : "not ");
printf(", %sactive", aDocumentNode->IsActive() ? "" : "not ");
printf(", %sresource", aDocumentNode->IsResourceDoc() ? "" : "not ");
@@ -179,9 +163,7 @@ LogDocState(nsIDocument* aDocumentNode)
printf(", has %srole content", rootEl ? "" : "no ");
}
static void
LogPresShell(nsIDocument* aDocumentNode)
{
static void LogPresShell(nsIDocument* aDocumentNode) {
nsIPresShell* ps = aDocumentNode->GetShell();
printf("presshell: %p", static_cast<void*>(ps));
@@ -193,16 +175,12 @@ LogPresShell(nsIDocument* aDocumentNode)
printf(", root scroll frame: %p", static_cast<void*>(sf));
}
static void
LogDocLoadGroup(nsIDocument* aDocumentNode)
{
static void LogDocLoadGroup(nsIDocument* aDocumentNode) {
nsCOMPtr<nsILoadGroup> loadGroup = aDocumentNode->GetDocumentLoadGroup();
printf("load group: %p", static_cast<void*>(loadGroup));
}
static void
LogDocParent(nsIDocument* aDocumentNode)
{
static void LogDocParent(nsIDocument* aDocumentNode) {
nsIDocument* parentDoc = aDocumentNode->GetParentDocument();
printf("parent DOM document: %p", static_cast<void*>(parentDoc));
if (parentDoc) {
@@ -214,9 +192,7 @@ LogDocParent(nsIDocument* aDocumentNode)
}
}
static void
LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument)
{
static void LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument) {
printf(" DOM document: %p, acc document: %p\n ",
static_cast<void*>(aDocumentNode), static_cast<void*>(aDocument));
@@ -241,9 +217,7 @@ LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument)
}
}
static void
LogShellLoadType(nsIDocShell* aDocShell)
{
static void LogShellLoadType(nsIDocShell* aDocShell) {
printf("load type: ");
uint32_t loadType = 0;
@@ -320,9 +294,7 @@ LogShellLoadType(nsIDocShell* aDocShell)
}
}
static void
LogRequest(nsIRequest* aRequest)
{
static void LogRequest(nsIRequest* aRequest) {
if (aRequest) {
nsAutoCString name;
aRequest->GetName(name);
@@ -330,28 +302,22 @@ LogRequest(nsIRequest* aRequest)
uint32_t loadFlags = 0;
aRequest->GetLoadFlags(&loadFlags);
printf(" request load flags: %x; ", loadFlags);
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI)
printf("document uri; ");
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) printf("document uri; ");
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
printf("retargeted document uri; ");
if (loadFlags & nsIChannel::LOAD_REPLACE)
printf("replace; ");
if (loadFlags & nsIChannel::LOAD_REPLACE) printf("replace; ");
if (loadFlags & nsIChannel::LOAD_INITIAL_DOCUMENT_URI)
printf("initial document uri; ");
if (loadFlags & nsIChannel::LOAD_TARGETED)
printf("targeted; ");
if (loadFlags & nsIChannel::LOAD_TARGETED) printf("targeted; ");
if (loadFlags & nsIChannel::LOAD_CALL_CONTENT_SNIFFERS)
printf("call content sniffers; ");
if (loadFlags & nsIChannel::LOAD_CLASSIFY_URI)
printf("classify uri; ");
if (loadFlags & nsIChannel::LOAD_CLASSIFY_URI) printf("classify uri; ");
} else {
printf(" no request");
}
}
static void
LogDocAccState(DocAccessible* aDocument)
{
static void LogDocAccState(DocAccessible* aDocument) {
printf("document acc state: ");
if (aDocument->HasLoadState(DocAccessible::eCompletelyLoaded))
printf("completely loaded;");
@@ -363,9 +329,7 @@ LogDocAccState(DocAccessible* aDocument)
printf("tree constructed;");
}
static void
GetDocLoadEventType(AccEvent* aEvent, nsACString& aEventType)
{
static void GetDocLoadEventType(AccEvent* aEvent, nsACString& aEventType) {
uint32_t type = aEvent->GetEventType();
if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED) {
aEventType.AssignLiteral("load stopped");
@@ -394,10 +358,8 @@ static const char* sDocDestroyTitle = "DOCDESTROY";
static const char* sDocEventTitle = "DOCEVENT";
static const char* sFocusTitle = "FOCUS";
void
logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
nsIRequest* aRequest, uint32_t aStateFlags)
{
void logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
nsIRequest* aRequest, uint32_t aStateFlags) {
MsgBegin(sDocLoadTitle, "%s", aMsg);
nsCOMPtr<mozIDOMWindowProxy> DOMWindow;
@@ -432,9 +394,7 @@ logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
MsgEnd();
}
void
logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode)
{
void logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode) {
MsgBegin(sDocLoadTitle, "%s", aMsg);
DocAccessible* document = GetExistingDocAccessible(aDocumentNode);
@@ -443,9 +403,8 @@ logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode)
MsgEnd();
}
void
logging::DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget)
{
void logging::DocCompleteLoad(DocAccessible* aDocument,
bool aIsLoadEventTarget) {
MsgBegin(sDocLoadTitle, "document loaded *completely*");
printf(" DOM document: %p, acc document: %p\n",
@@ -466,86 +425,70 @@ logging::DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget)
MsgEnd();
}
void
logging::DocLoadEventFired(AccEvent* aEvent)
{
void logging::DocLoadEventFired(AccEvent* aEvent) {
nsAutoCString strEventType;
GetDocLoadEventType(aEvent, strEventType);
if (!strEventType.IsEmpty())
printf(" fire: %s\n", strEventType.get());
if (!strEventType.IsEmpty()) printf(" fire: %s\n", strEventType.get());
}
void
logging::DocLoadEventHandled(AccEvent* aEvent)
{
void logging::DocLoadEventHandled(AccEvent* aEvent) {
nsAutoCString strEventType;
GetDocLoadEventType(aEvent, strEventType);
if (strEventType.IsEmpty())
return;
if (strEventType.IsEmpty()) return;
MsgBegin(sDocEventTitle, "handled '%s' event", strEventType.get());
DocAccessible* document = aEvent->GetAccessible()->AsDoc();
if (document)
LogDocInfo(document->DocumentNode(), document);
if (document) LogDocInfo(document->DocumentNode(), document);
MsgEnd();
}
void
logging::DocCreate(const char* aMsg, nsIDocument* aDocumentNode,
DocAccessible* aDocument)
{
DocAccessible* document = aDocument ?
aDocument : GetExistingDocAccessible(aDocumentNode);
void logging::DocCreate(const char* aMsg, nsIDocument* aDocumentNode,
DocAccessible* aDocument) {
DocAccessible* document =
aDocument ? aDocument : GetExistingDocAccessible(aDocumentNode);
MsgBegin(sDocCreateTitle, "%s", aMsg);
LogDocInfo(aDocumentNode, document);
MsgEnd();
}
void
logging::DocDestroy(const char* aMsg, nsIDocument* aDocumentNode,
DocAccessible* aDocument)
{
DocAccessible* document = aDocument ?
aDocument : GetExistingDocAccessible(aDocumentNode);
void logging::DocDestroy(const char* aMsg, nsIDocument* aDocumentNode,
DocAccessible* aDocument) {
DocAccessible* document =
aDocument ? aDocument : GetExistingDocAccessible(aDocumentNode);
MsgBegin(sDocDestroyTitle, "%s", aMsg);
LogDocInfo(aDocumentNode, document);
MsgEnd();
}
void
logging::OuterDocDestroy(OuterDocAccessible* aOuterDoc)
{
void logging::OuterDocDestroy(OuterDocAccessible* aOuterDoc) {
MsgBegin(sDocDestroyTitle, "outerdoc shutdown");
logging::Address("outerdoc", aOuterDoc);
MsgEnd();
}
void
logging::FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
Accessible* aTarget)
{
void logging::FocusNotificationTarget(const char* aMsg,
const char* aTargetDescr,
Accessible* aTarget) {
MsgBegin(sFocusTitle, "%s", aMsg);
AccessibleNNode(aTargetDescr, aTarget);
MsgEnd();
}
void
logging::FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
nsINode* aTargetNode)
{
void logging::FocusNotificationTarget(const char* aMsg,
const char* aTargetDescr,
nsINode* aTargetNode) {
MsgBegin(sFocusTitle, "%s", aMsg);
Node(aTargetDescr, aTargetNode);
MsgEnd();
}
void
logging::FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
nsISupports* aTargetThing)
{
void logging::FocusNotificationTarget(const char* aMsg,
const char* aTargetDescr,
nsISupports* aTargetThing) {
MsgBegin(sFocusTitle, "%s", aMsg);
if (aTargetThing) {
@@ -560,18 +503,15 @@ logging::FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
MsgEnd();
}
void
logging::ActiveItemChangeCausedBy(const char* aCause, Accessible* aTarget)
{
void logging::ActiveItemChangeCausedBy(const char* aCause,
Accessible* aTarget) {
SubMsgBegin();
printf(" Caused by: %s\n", aCause);
AccessibleNNode("Item", aTarget);
SubMsgEnd();
}
void
logging::ActiveWidget(Accessible* aWidget)
{
void logging::ActiveWidget(Accessible* aWidget) {
SubMsgBegin();
AccessibleNNode("Widget", aWidget);
@@ -582,18 +522,14 @@ logging::ActiveWidget(Accessible* aWidget)
SubMsgEnd();
}
void
logging::FocusDispatched(Accessible* aTarget)
{
void logging::FocusDispatched(Accessible* aTarget) {
SubMsgBegin();
AccessibleNNode("A11y target", aTarget);
SubMsgEnd();
}
void
logging::SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
int16_t aReason)
{
void logging::SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
int16_t aReason) {
SelectionType type = aSelection->GetType();
const char* strType = 0;
@@ -605,15 +541,14 @@ logging::SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
strType = "unknown";
bool isIgnored = !aDocument || !aDocument->IsContentLoaded();
printf("\nSelection changed, selection type: %s, notification %s, reason: %d\n",
strType, (isIgnored ? "ignored" : "pending"), aReason);
printf(
"\nSelection changed, selection type: %s, notification %s, reason: %d\n",
strType, (isIgnored ? "ignored" : "pending"), aReason);
Stack();
}
void
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...)
{
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...) {
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
va_list vl;
va_start(vl, aExtraFlags);
@@ -625,8 +560,7 @@ logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...)
while ((descr = va_arg(vl, const char*))) {
AccessibleInfo(descr, va_arg(vl, Accessible*));
}
}
else {
} else {
MsgBegin("TREE", "%s", aMsg);
}
va_end(vl);
@@ -638,29 +572,24 @@ logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...)
}
}
void
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
const char* aMsg1, Accessible* aAcc,
const char* aMsg2, nsINode* aNode)
{
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
const char* aMsg1, Accessible* aAcc, const char* aMsg2,
nsINode* aNode) {
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
MsgBegin("TREE", "%s; doc: %p", aMsg, aAcc ? aAcc->Document() : nullptr);
AccessibleInfo(aMsg1, aAcc);
Accessible* acc = aAcc ? aAcc->Document()->GetAccessible(aNode) : nullptr;
if (acc) {
AccessibleInfo(aMsg2, acc);
}
else {
} else {
Node(aMsg2, aNode);
}
MsgEnd();
}
}
void
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent)
{
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
Accessible* aParent) {
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
MsgBegin("TREE", "%s; doc: %p", aMsg, aParent->Document());
AccessibleInfo("container", aParent);
@@ -671,17 +600,15 @@ logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent)
}
}
void
logging::Tree(const char* aTitle, const char* aMsgText,
Accessible* aRoot, GetTreePrefix aPrefixFunc,
void* aGetTreePrefixData)
{
void logging::Tree(const char* aTitle, const char* aMsgText, Accessible* aRoot,
GetTreePrefix aPrefixFunc, void* aGetTreePrefixData) {
logging::MsgBegin(aTitle, "%s", aMsgText);
nsAutoString level;
Accessible* root = aRoot;
do {
const char* prefix = aPrefixFunc ? aPrefixFunc(aGetTreePrefixData, root) : "";
const char* prefix =
aPrefixFunc ? aPrefixFunc(aGetTreePrefixData, root) : "";
printf("%s", NS_ConvertUTF16toUTF8(level).get());
logging::AccessibleInfo(prefix, root);
if (root->FirstChild() && !root->FirstChild()->IsDoc()) {
@@ -689,33 +616,34 @@ logging::Tree(const char* aTitle, const char* aMsgText,
root = root->FirstChild();
continue;
}
int32_t idxInParent = root != aRoot && root->mParent ?
root->mParent->mChildren.IndexOf(root) : -1;
int32_t idxInParent = root != aRoot && root->mParent
? root->mParent->mChildren.IndexOf(root)
: -1;
if (idxInParent != -1 &&
idxInParent < static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
idxInParent <
static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
continue;
}
while (root != aRoot && (root = root->Parent())) {
level.Cut(0, 2);
int32_t idxInParent = !root->IsDoc() && root->mParent ?
root->mParent->mChildren.IndexOf(root) : -1;
int32_t idxInParent = !root->IsDoc() && root->mParent
? root->mParent->mChildren.IndexOf(root)
: -1;
if (idxInParent != -1 &&
idxInParent < static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
idxInParent <
static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
break;
}
}
}
while (root && root != aRoot);
} while (root && root != aRoot);
logging::MsgEnd();
}
void
logging::DOMTree(const char* aTitle, const char* aMsgText,
DocAccessible* aDocument)
{
void logging::DOMTree(const char* aTitle, const char* aMsgText,
DocAccessible* aDocument) {
logging::MsgBegin(aTitle, "%s", aMsgText);
nsAutoString level;
nsINode* root = aDocument->DocumentNode();
@@ -738,14 +666,11 @@ logging::DOMTree(const char* aTitle, const char* aMsgText,
break;
}
}
}
while (root);
} while (root);
logging::MsgEnd();
}
void
logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
{
void logging::MsgBegin(const char* aTitle, const char* aMsgText, ...) {
printf("\nA11Y %s: ", aTitle);
va_list argptr;
@@ -762,27 +687,13 @@ logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
printf("\n {\n");
}
void
logging::MsgEnd()
{
printf(" }\n");
}
void logging::MsgEnd() { printf(" }\n"); }
void
logging::SubMsgBegin()
{
printf(" {\n");
}
void logging::SubMsgBegin() { printf(" {\n"); }
void
logging::SubMsgEnd()
{
printf(" }\n");
}
void logging::SubMsgEnd() { printf(" }\n"); }
void
logging::MsgEntry(const char* aEntryText, ...)
{
void logging::MsgEntry(const char* aEntryText, ...) {
printf(" ");
va_list argptr;
@@ -793,15 +704,9 @@ logging::MsgEntry(const char* aEntryText, ...)
printf("\n");
}
void
logging::Text(const char* aText)
{
printf(" %s\n", aText);
}
void logging::Text(const char* aText) { printf(" %s\n", aText); }
void
logging::Address(const char* aDescr, Accessible* aAcc)
{
void logging::Address(const char* aDescr, Accessible* aAcc) {
if (!aAcc->IsDoc()) {
printf(" %s accessible: %p, node: %p\n", aDescr,
static_cast<void*>(aAcc), static_cast<void*>(aAcc->GetNode()));
@@ -809,17 +714,15 @@ logging::Address(const char* aDescr, Accessible* aAcc)
DocAccessible* doc = aAcc->Document();
nsIDocument* docNode = doc->DocumentNode();
printf(" document: %p, node: %p\n",
static_cast<void*>(doc), static_cast<void*>(docNode));
printf(" document: %p, node: %p\n", static_cast<void*>(doc),
static_cast<void*>(docNode));
printf(" ");
LogDocURI(docNode);
printf("\n");
}
void
logging::Node(const char* aDescr, nsINode* aNode)
{
void logging::Node(const char* aDescr, nsINode* aNode) {
printf(" ");
if (!aNode) {
@@ -833,17 +736,17 @@ logging::Node(const char* aDescr, nsINode* aNode)
}
nsINode* parentNode = aNode->GetParentNode();
int32_t idxInParent = parentNode ? parentNode->ComputeIndexOf(aNode) : - 1;
int32_t idxInParent = parentNode ? parentNode->ComputeIndexOf(aNode) : -1;
if (aNode->IsText()) {
printf("%s: %p, text node, idx in parent: %d\n",
aDescr, static_cast<void*>(aNode), idxInParent);
printf("%s: %p, text node, idx in parent: %d\n", aDescr,
static_cast<void*>(aNode), idxInParent);
return;
}
if (!aNode->IsElement()) {
printf("%s: %p, not accessible node type, idx in parent: %d\n",
aDescr, static_cast<void*>(aNode), idxInParent);
printf("%s: %p, not accessible node type, idx in parent: %d\n", aDescr,
static_cast<void*>(aNode), idxInParent);
return;
}
@@ -854,18 +757,14 @@ logging::Node(const char* aDescr, nsINode* aNode)
nsAtom* idAtom = elm->GetID();
nsAutoCString id;
if (idAtom)
idAtom->ToUTF8String(id);
if (idAtom) idAtom->ToUTF8String(id);
printf("%s: %p, %s@id='%s', idx in parent: %d\n",
aDescr, static_cast<void*>(elm), tag.get(), id.get(), idxInParent);
printf("%s: %p, %s@id='%s', idx in parent: %d\n", aDescr,
static_cast<void*>(elm), tag.get(), id.get(), idxInParent);
}
void
logging::Document(DocAccessible* aDocument)
{
printf(" Document: %p, document node: %p\n",
static_cast<void*>(aDocument),
void logging::Document(DocAccessible* aDocument) {
printf(" Document: %p, document node: %p\n", static_cast<void*>(aDocument),
static_cast<void*>(aDocument->DocumentNode()));
printf(" Document ");
@@ -873,9 +772,7 @@ logging::Document(DocAccessible* aDocument)
printf("\n");
}
void
logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible)
{
void logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible) {
printf(" %s: %p; ", aDescr, static_cast<void*>(aAccessible));
if (!aAccessible) {
printf("\n");
@@ -905,14 +802,11 @@ logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible)
nsINode* node = aAccessible->GetNode();
if (!node) {
printf(", node: null\n");
}
else if (node->IsDocument()) {
} else if (node->IsDocument()) {
printf(", document node: %p\n", static_cast<void*>(node));
}
else if (node->IsText()) {
} else if (node->IsText()) {
printf(", text node: %p\n", static_cast<void*>(node));
}
else if (node->IsElement()) {
} else if (node->IsElement()) {
dom::Element* el = node->AsElement();
nsAutoCString tag;
@@ -924,17 +818,14 @@ logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible)
idAtom->ToUTF8String(id);
}
printf(", element node: %p, %s@id='%s'\n",
static_cast<void*>(el), tag.get(), id.get());
printf(", element node: %p, %s@id='%s'\n", static_cast<void*>(el),
tag.get(), id.get());
}
}
void
logging::AccessibleNNode(const char* aDescr, Accessible* aAccessible)
{
void logging::AccessibleNNode(const char* aDescr, Accessible* aAccessible) {
printf(" %s: %p; ", aDescr, static_cast<void*>(aAccessible));
if (!aAccessible)
return;
if (!aAccessible) return;
nsAutoString role;
GetAccService()->GetStringRole(aAccessible->Role(), role);
@@ -951,11 +842,9 @@ logging::AccessibleNNode(const char* aDescr, Accessible* aAccessible)
Document(aAccessible->Document());
}
void
logging::AccessibleNNode(const char* aDescr, nsINode* aNode)
{
void logging::AccessibleNNode(const char* aDescr, nsINode* aNode) {
DocAccessible* document =
GetAccService()->GetDocAccessible(aNode->OwnerDoc());
GetAccService()->GetDocAccessible(aNode->OwnerDoc());
if (document) {
Accessible* accessible = document->GetAccessible(aNode);
@@ -979,19 +868,15 @@ logging::AccessibleNNode(const char* aDescr, nsINode* aNode)
printf("\n");
}
void
logging::DOMEvent(const char* aDescr, nsINode* aOrigTarget,
const nsAString& aEventType)
{
void logging::DOMEvent(const char* aDescr, nsINode* aOrigTarget,
const nsAString& aEventType) {
logging::MsgBegin("DOMEvents", "event '%s' %s",
NS_ConvertUTF16toUTF8(aEventType).get(), aDescr);
logging::AccessibleNNode("Target", aOrigTarget);
logging::MsgEnd();
}
void
logging::Stack()
{
void logging::Stack() {
if (IsEnabled(eStack)) {
printf(" stack: \n");
nsTraceRefcnt::WalkTheStack(stdout);
@@ -1001,21 +886,13 @@ logging::Stack()
////////////////////////////////////////////////////////////////////////////////
// namespace logging:: initialization
bool
logging::IsEnabled(uint32_t aModules)
{
return sModules & aModules;
}
bool logging::IsEnabled(uint32_t aModules) { return sModules & aModules; }
bool
logging::IsEnabledAll(uint32_t aModules)
{
bool logging::IsEnabledAll(uint32_t aModules) {
return (sModules & aModules) == aModules;
}
bool
logging::IsEnabled(const nsAString& aModuleStr)
{
bool logging::IsEnabled(const nsAString& aModuleStr) {
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
if (aModuleStr.EqualsASCII(sModuleMap[idx].mStr))
return sModules & sModuleMap[idx].mModule;
@@ -1024,15 +901,8 @@ logging::IsEnabled(const nsAString& aModuleStr)
return false;
}
void
logging::Enable(const nsCString& aModules)
{
void logging::Enable(const nsCString& aModules) {
EnableLogging(aModules.get());
}
void
logging::CheckEnv()
{
EnableLogging(PR_GetEnv("A11YLOG"));
}
void logging::CheckEnv() { EnableLogging(PR_GetEnv("A11YLOG")); }

View File

@@ -21,7 +21,7 @@ namespace mozilla {
namespace dom {
class Selection;
} // namespace dom
} // namespace dom
namespace a11y {
@@ -139,9 +139,8 @@ void SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
* Log the given accessible elements info.
*/
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...);
void TreeInfo(const char* aMsg, uint32_t aExtraFlags,
const char* aMsg1, Accessible* aAcc,
const char* aMsg2, nsINode* aNode);
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, const char* aMsg1,
Accessible* aAcc, const char* aMsg2, nsINode* aNode);
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
/**
@@ -149,7 +148,8 @@ void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
*/
typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
void Tree(const char* aTitle, const char* aMsgText, Accessible* aRoot,
GetTreePrefix aPrefixFunc = nullptr, void* aGetTreePrefixData = nullptr);
GetTreePrefix aPrefixFunc = nullptr,
void* aGetTreePrefixData = nullptr);
void DOMTree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc);
/**
@@ -157,7 +157,8 @@ void DOMTree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc);
* boundaries of the message body designated by '{' and '}' (2 spaces indent for
* body).
*/
void MsgBegin(const char* aTitle, const char* aMsgText, ...) MOZ_FORMAT_PRINTF(2, 3);
void MsgBegin(const char* aTitle, const char* aMsgText, ...)
MOZ_FORMAT_PRINTF(2, 3);
void MsgEnd();
/**
@@ -221,10 +222,9 @@ void Enable(const nsCString& aModules);
*/
void CheckEnv();
} // namespace logging
} // namespace logging
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -5,586 +5,424 @@
* 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, Accessible* aContext) -> Accessible* {
// 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) {
return new HyperTextAccessibleWrap(aElement, aContext->Document());
}
MARKUPMAP(a,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// 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) {
return new HyperTextAccessibleWrap(aElement,
aContext->Document());
}
return new HTMLLinkAccessible(aElement, aContext->Document());
},
roles::LINK
)
return new HTMLLinkAccessible(aElement, aContext->Document());
},
roles::LINK)
MARKUPMAP(abbr,
New_HyperText,
MARKUPMAP(abbr, New_HyperText, 0)
MARKUPMAP(acronym, New_HyperText, 0)
MARKUPMAP(article, New_HyperText, roles::ARTICLE, Attr(xmlroles, article))
MARKUPMAP(aside, New_HyperText, roles::LANDMARK)
MARKUPMAP(blockquote, New_HyperText, roles::BLOCKQUOTE)
MARKUPMAP(button,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLButtonAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(acronym,
New_HyperText,
MARKUPMAP(caption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTable()) {
dom::HTMLTableElement* tableEl =
dom::HTMLTableElement::FromNode(aContext->GetContent());
if (tableEl && tableEl == aElement->GetParent() &&
tableEl->GetCaption() == aElement) {
return new HTMLCaptionAccessible(aElement,
aContext->Document());
}
}
return nullptr;
},
0)
MARKUPMAP(article,
New_HyperText,
roles::ARTICLE,
Attr(xmlroles, article))
MARKUPMAP(dd, New_HTMLDtOrDd<HyperTextAccessibleWrap>, roles::DEFINITION)
MARKUPMAP(aside,
New_HyperText,
roles::LANDMARK)
MARKUPMAP(del, New_HyperText, roles::CONTENT_DELETION)
MARKUPMAP(blockquote,
New_HyperText,
roles::BLOCKQUOTE)
MARKUPMAP(details, New_HyperText, roles::DETAILS)
MARKUPMAP(
button,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLButtonAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(div, nullptr, roles::SECTION)
MARKUPMAP(
caption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTable()) {
dom::HTMLTableElement* tableEl =
dom::HTMLTableElement::FromNode(aContext->GetContent());
if (tableEl && tableEl == aElement->GetParent() &&
tableEl->GetCaption() == aElement) {
return new HTMLCaptionAccessible(aElement, aContext->Document());
}
}
return nullptr;
},
0
)
MARKUPMAP(dl,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::DEFINITION_LIST)
MARKUPMAP(dd,
New_HTMLDtOrDd<HyperTextAccessibleWrap>,
roles::DEFINITION)
MARKUPMAP(dt, New_HTMLDtOrDd<HTMLLIAccessible>, roles::TERM)
MARKUPMAP(del,
New_HyperText,
roles::CONTENT_DELETION)
MARKUPMAP(figcaption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
},
roles::CAPTION)
MARKUPMAP(details,
New_HyperText,
roles::DETAILS)
MARKUPMAP(figure,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigureAccessible(aElement, aContext->Document());
},
roles::FIGURE, Attr(xmlroles, figure))
MARKUPMAP(div,
nullptr,
roles::SECTION)
MARKUPMAP(fieldset,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLGroupboxAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(
dl,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::DEFINITION_LIST
)
MARKUPMAP(form,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFormAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(dt,
New_HTMLDtOrDd<HTMLLIAccessible>,
roles::TERM)
MARKUPMAP(footer,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement,
aContext->Document());
},
0)
MARKUPMAP(
figcaption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
},
roles::CAPTION
)
MARKUPMAP(header,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement,
aContext->Document());
},
0)
MARKUPMAP(
figure,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigureAccessible(aElement, aContext->Document());
},
roles::FIGURE,
Attr(xmlroles, figure)
)
MARKUPMAP(h1, New_HyperText, roles::HEADING)
MARKUPMAP(
fieldset,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLGroupboxAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(h2, New_HyperText, roles::HEADING)
MARKUPMAP(
form,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFormAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(h3, New_HyperText, roles::HEADING)
MARKUPMAP(
footer,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(h4, New_HyperText, roles::HEADING)
MARKUPMAP(
header,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(h5, New_HyperText, roles::HEADING)
MARKUPMAP(h1,
New_HyperText,
roles::HEADING)
MARKUPMAP(h6, New_HyperText, roles::HEADING)
MARKUPMAP(h2,
New_HyperText,
roles::HEADING)
MARKUPMAP(hr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHRAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(h3,
New_HyperText,
roles::HEADING)
MARKUPMAP(input,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::checkbox, eIgnoreCase)) {
return new CheckboxAccessible(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::radio, eIgnoreCase)) {
return new HTMLRadioButtonAccessible(aElement,
aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::time, eIgnoreCase)) {
return new EnumRoleAccessible<roles::GROUPING>(
aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::date, eIgnoreCase)) {
return new EnumRoleAccessible<roles::DATE_EDITOR>(
aElement, aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(h4,
New_HyperText,
roles::HEADING)
MARKUPMAP(ins, New_HyperText, roles::CONTENT_INSERTION)
MARKUPMAP(h5,
New_HyperText,
roles::HEADING)
MARKUPMAP(label,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLabelAccessible(aElement, aContext->Document());
},
roles::LABEL)
MARKUPMAP(h6,
New_HyperText,
roles::HEADING)
MARKUPMAP(legend,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLegendAccessible(aElement, aContext->Document());
},
roles::LABEL)
MARKUPMAP(
hr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHRAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(li,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// 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()) {
return new HTMLLIAccessible(aElement, aContext->Document());
}
MARKUPMAP(
input,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::checkbox, eIgnoreCase)) {
return new CheckboxAccessible(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::radio, eIgnoreCase)) {
return new HTMLRadioButtonAccessible(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::time, eIgnoreCase)) {
return new EnumRoleAccessible<roles::GROUPING>(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::date, eIgnoreCase)) {
return new EnumRoleAccessible<roles::DATE_EDITOR>(aElement, aContext->Document());
}
return nullptr;
},
0
)
return nullptr;
},
0)
MARKUPMAP(ins,
New_HyperText,
roles::CONTENT_INSERTION)
MARKUPMAP(main, New_HyperText, roles::LANDMARK)
MARKUPMAP(
label,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLabelAccessible(aElement, aContext->Document());
},
roles::LABEL
)
MARKUPMAP(map, nullptr, roles::TEXT_CONTAINER)
MARKUPMAP(
legend,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLegendAccessible(aElement, aContext->Document());
},
roles::LABEL
)
MARKUPMAP(math, New_HyperText, roles::MATHML_MATH)
MARKUPMAP(
li,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// 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()) {
return new HTMLLIAccessible(aElement, aContext->Document());
}
MARKUPMAP(mi_, New_HyperText, roles::MATHML_IDENTIFIER)
return nullptr;
},
0
)
MARKUPMAP(mn_, New_HyperText, roles::MATHML_NUMBER)
MARKUPMAP(main,
New_HyperText,
roles::LANDMARK)
MARKUPMAP(mo_, New_HyperText, roles::MATHML_OPERATOR,
AttrFromDOM(accent_, accent_), AttrFromDOM(fence_, fence_),
AttrFromDOM(separator_, separator_), AttrFromDOM(largeop_, largeop_))
MARKUPMAP(map,
nullptr,
roles::TEXT_CONTAINER)
MARKUPMAP(mtext_, New_HyperText, roles::MATHML_TEXT)
MARKUPMAP(math,
New_HyperText,
roles::MATHML_MATH)
MARKUPMAP(ms_, New_HyperText, roles::MATHML_STRING_LITERAL)
MARKUPMAP(mi_,
New_HyperText,
roles::MATHML_IDENTIFIER)
MARKUPMAP(mglyph_, New_HyperText, roles::MATHML_GLYPH)
MARKUPMAP(mn_,
New_HyperText,
roles::MATHML_NUMBER)
MARKUPMAP(mrow_, New_HyperText, roles::MATHML_ROW)
MARKUPMAP(mo_,
New_HyperText,
roles::MATHML_OPERATOR,
AttrFromDOM(accent_, accent_),
AttrFromDOM(fence_, fence_),
AttrFromDOM(separator_, separator_),
AttrFromDOM(largeop_, largeop_))
MARKUPMAP(mtext_,
New_HyperText,
roles::MATHML_TEXT)
MARKUPMAP(ms_,
New_HyperText,
roles::MATHML_STRING_LITERAL)
MARKUPMAP(mglyph_,
New_HyperText,
roles::MATHML_GLYPH)
MARKUPMAP(mrow_,
New_HyperText,
roles::MATHML_ROW)
MARKUPMAP(mfrac_,
New_HyperText,
roles::MATHML_FRACTION,
MARKUPMAP(mfrac_, New_HyperText, roles::MATHML_FRACTION,
AttrFromDOM(bevelled_, bevelled_),
AttrFromDOM(linethickness_, linethickness_))
MARKUPMAP(msqrt_,
New_HyperText,
roles::MATHML_SQUARE_ROOT)
MARKUPMAP(msqrt_, New_HyperText, roles::MATHML_SQUARE_ROOT)
MARKUPMAP(mroot_,
New_HyperText,
roles::MATHML_ROOT)
MARKUPMAP(mroot_, New_HyperText, roles::MATHML_ROOT)
MARKUPMAP(mfenced_,
New_HyperText,
roles::MATHML_FENCED,
AttrFromDOM(close, close),
AttrFromDOM(open, open),
MARKUPMAP(mfenced_, New_HyperText, roles::MATHML_FENCED,
AttrFromDOM(close, close), AttrFromDOM(open, open),
AttrFromDOM(separators_, separators_))
MARKUPMAP(menclose_,
New_HyperText,
roles::MATHML_ENCLOSED,
MARKUPMAP(menclose_, New_HyperText, roles::MATHML_ENCLOSED,
AttrFromDOM(notation_, notation_))
MARKUPMAP(mstyle_,
New_HyperText,
roles::MATHML_STYLE)
MARKUPMAP(mstyle_, New_HyperText, roles::MATHML_STYLE)
MARKUPMAP(msub_,
New_HyperText,
roles::MATHML_SUB)
MARKUPMAP(msub_, New_HyperText, roles::MATHML_SUB)
MARKUPMAP(msup_,
New_HyperText,
roles::MATHML_SUP)
MARKUPMAP(msup_, New_HyperText, roles::MATHML_SUP)
MARKUPMAP(msubsup_,
New_HyperText,
roles::MATHML_SUB_SUP)
MARKUPMAP(msubsup_, New_HyperText, roles::MATHML_SUB_SUP)
MARKUPMAP(munder_,
New_HyperText,
roles::MATHML_UNDER,
AttrFromDOM(accentunder_, accentunder_),
AttrFromDOM(align, align))
MARKUPMAP(munder_, New_HyperText, roles::MATHML_UNDER,
AttrFromDOM(accentunder_, accentunder_), AttrFromDOM(align, align))
MARKUPMAP(mover_,
New_HyperText,
roles::MATHML_OVER,
MARKUPMAP(mover_, New_HyperText, roles::MATHML_OVER,
AttrFromDOM(accent_, accent_), AttrFromDOM(align, align))
MARKUPMAP(munderover_, New_HyperText, roles::MATHML_UNDER_OVER,
AttrFromDOM(accent_, accent_),
AttrFromDOM(align, align))
AttrFromDOM(accentunder_, accentunder_), AttrFromDOM(align, align))
MARKUPMAP(munderover_,
New_HyperText,
roles::MATHML_UNDER_OVER,
AttrFromDOM(accent_, accent_),
AttrFromDOM(accentunder_, accentunder_),
AttrFromDOM(align, align))
MARKUPMAP(mmultiscripts_, New_HyperText, roles::MATHML_MULTISCRIPTS)
MARKUPMAP(mmultiscripts_,
New_HyperText,
roles::MATHML_MULTISCRIPTS)
MARKUPMAP(mtable_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE, AttrFromDOM(align, align),
AttrFromDOM(columnlines_, columnlines_),
AttrFromDOM(rowlines_, rowlines_))
MARKUPMAP(
mtable_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE,
AttrFromDOM(align, align),
AttrFromDOM(columnlines_, columnlines_),
AttrFromDOM(rowlines_, rowlines_)
)
MARKUPMAP(mlabeledtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_LABELED_ROW)
MARKUPMAP(
mlabeledtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_LABELED_ROW
)
MARKUPMAP(mtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE_ROW)
MARKUPMAP(
mtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE_ROW
)
MARKUPMAP(mtd_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableCellAccessible(aElement, aContext->Document());
},
roles::MATHML_CELL)
MARKUPMAP(
mtd_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableCellAccessible(aElement, aContext->Document());
},
roles::MATHML_CELL
)
MARKUPMAP(maction_,
New_HyperText,
roles::MATHML_ACTION,
MARKUPMAP(maction_, New_HyperText, roles::MATHML_ACTION,
AttrFromDOM(actiontype_, actiontype_),
AttrFromDOM(selection_, selection_))
MARKUPMAP(merror_,
New_HyperText,
roles::MATHML_ERROR)
MARKUPMAP(merror_, New_HyperText, roles::MATHML_ERROR)
MARKUPMAP(mstack_,
New_HyperText,
roles::MATHML_STACK,
AttrFromDOM(align, align),
AttrFromDOM(position, position))
MARKUPMAP(mstack_, New_HyperText, roles::MATHML_STACK,
AttrFromDOM(align, align), AttrFromDOM(position, position))
MARKUPMAP(mlongdiv_,
New_HyperText,
roles::MATHML_LONG_DIVISION,
MARKUPMAP(mlongdiv_, New_HyperText, roles::MATHML_LONG_DIVISION,
AttrFromDOM(longdivstyle_, longdivstyle_))
MARKUPMAP(msgroup_,
New_HyperText,
roles::MATHML_STACK_GROUP,
AttrFromDOM(position, position),
AttrFromDOM(shift_, shift_))
MARKUPMAP(msgroup_, New_HyperText, roles::MATHML_STACK_GROUP,
AttrFromDOM(position, position), AttrFromDOM(shift_, shift_))
MARKUPMAP(msrow_,
New_HyperText,
roles::MATHML_STACK_ROW,
MARKUPMAP(msrow_, New_HyperText, roles::MATHML_STACK_ROW,
AttrFromDOM(position, position))
MARKUPMAP(mscarries_,
New_HyperText,
roles::MATHML_STACK_CARRIES,
AttrFromDOM(location_, location_),
AttrFromDOM(position, position))
MARKUPMAP(mscarries_, New_HyperText, roles::MATHML_STACK_CARRIES,
AttrFromDOM(location_, location_), AttrFromDOM(position, position))
MARKUPMAP(mscarry_,
New_HyperText,
roles::MATHML_STACK_CARRY,
MARKUPMAP(mscarry_, New_HyperText, roles::MATHML_STACK_CARRY,
AttrFromDOM(crossout_, crossout_))
MARKUPMAP(msline_,
New_HyperText,
roles::MATHML_STACK_LINE,
MARKUPMAP(msline_, New_HyperText, roles::MATHML_STACK_LINE,
AttrFromDOM(position, position))
MARKUPMAP(nav,
New_HyperText,
roles::LANDMARK)
MARKUPMAP(nav, New_HyperText, roles::LANDMARK)
MARKUPMAP(
ol,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST
)
MARKUPMAP(ol,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST)
MARKUPMAP(
option,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptionAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(
optgroup,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptGroupAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(
output,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLOutputAccessible(aElement, aContext->Document());
},
roles::SECTION,
Attr(live, polite)
)
MARKUPMAP(p,
nullptr,
roles::PARAGRAPH)
MARKUPMAP(
progress,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLProgressAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(q,
New_HyperText,
MARKUPMAP(option,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptionAccessible(aElement,
aContext->Document());
},
0)
MARKUPMAP(
section,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSectionAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(optgroup,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptGroupAccessible(aElement,
aContext->Document());
},
0)
MARKUPMAP(
summary,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSummaryAccessible(aElement, aContext->Document());
},
roles::SUMMARY
)
MARKUPMAP(output,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLOutputAccessible(aElement, aContext->Document());
},
roles::SECTION, Attr(live, polite))
MARKUPMAP(
table,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableType) {
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
}
return nullptr;
},
0
)
MARKUPMAP(p, nullptr, roles::PARAGRAPH)
MARKUPMAP(time,
New_HyperText,
0,
Attr(xmlroles, time),
MARKUPMAP(progress,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLProgressAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(q, New_HyperText, 0)
MARKUPMAP(section,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSectionAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(summary,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSummaryAccessible(aElement, aContext->Document());
},
roles::SUMMARY)
MARKUPMAP(table,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableType) {
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(time, New_HyperText, 0, Attr(xmlroles, time),
AttrFromDOM(datetime, datetime))
MARKUPMAP(
td,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() && aContext->GetContent() == aElement->GetParent()) {
// If HTML:td element is part of its HTML:table, which has CSS
// display style other than 'table', then create a generic table cell
// accessible, because there's no underlying table layout and thus native
// HTML table cell class doesn't work.
// The same is true if the cell itself has CSS display:block;.
if (!aContext->IsHTMLTableRow() ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableCellType)) {
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
}
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
return new HTMLTableHeaderCellAccessibleWrap(aElement, aContext->Document());
}
}
return nullptr;
},
0
)
MARKUPMAP(td,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() &&
aContext->GetContent() == aElement->GetParent()) {
// If HTML:td element is part of its HTML:table, which has CSS
// display style other than 'table', then create a generic table
// cell accessible, because there's no underlying table layout and
// thus native HTML table cell class doesn't work. The same is
// true if the cell itself has CSS display:block;.
if (!aContext->IsHTMLTableRow() ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableCellType)) {
return new ARIAGridCellAccessibleWrap(aElement,
aContext->Document());
}
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
return new HTMLTableHeaderCellAccessibleWrap(
aElement, aContext->Document());
}
}
return nullptr;
},
0)
MARKUPMAP(
th,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() && aContext->GetContent() == aElement->GetParent()) {
if (!aContext->IsHTMLTableRow()) {
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
}
return new HTMLTableHeaderCellAccessibleWrap(aElement, aContext->Document());
}
return nullptr;
},
0
)
MARKUPMAP(th,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() &&
aContext->GetContent() == aElement->GetParent()) {
if (!aContext->IsHTMLTableRow()) {
return new ARIAGridCellAccessibleWrap(aElement,
aContext->Document());
}
return new HTMLTableHeaderCellAccessibleWrap(
aElement, aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(
tr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// If HTML:tr element is part of its HTML:table, which has CSS
// display style other than 'table', then create a generic table row
// accessible, because there's no underlying table layout and thus native
// HTML table row class doesn't work. Refer to
// CreateAccessibleByFrameType dual logic.
Accessible* table = aContext->IsTable() ? aContext : nullptr;
if (!table && aContext->Parent() && aContext->Parent()->IsTable()) {
table = aContext->Parent();
}
if (table) {
nsIContent* parentContent = aElement->GetParent();
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
if (parentFrame && !parentFrame->IsTableWrapperFrame()) {
parentContent = parentContent->GetParent();
parentFrame = parentContent->GetPrimaryFrame();
if (table->GetContent() == parentContent &&
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableRowType))) {
return new ARIARowAccessible(aElement, aContext->Document());
}
}
}
return nullptr;
},
0
)
MARKUPMAP(tr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// If HTML:tr element is part of its HTML:table, which has CSS
// display style other than 'table', then create a generic table row
// accessible, because there's no underlying table layout and thus
// native HTML table row class doesn't work. Refer to
// CreateAccessibleByFrameType dual logic.
Accessible* table = aContext->IsTable() ? aContext : nullptr;
if (!table && aContext->Parent() && aContext->Parent()->IsTable()) {
table = aContext->Parent();
}
if (table) {
nsIContent* parentContent = aElement->GetParent();
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
if (parentFrame && !parentFrame->IsTableWrapperFrame()) {
parentContent = parentContent->GetParent();
parentFrame = parentContent->GetPrimaryFrame();
if (table->GetContent() == parentContent &&
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableRowType))) {
return new ARIARowAccessible(aElement, aContext->Document());
}
}
}
return nullptr;
},
0)
MARKUPMAP(
ul,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST
)
MARKUPMAP(ul,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST)

View File

@@ -24,10 +24,11 @@ using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
NotificationController::NotificationController(DocAccessible* aDocument,
nsIPresShell* aPresShell) :
EventQueue(aDocument), mObservingState(eNotObservingRefresh),
mPresShell(aPresShell), mEventGeneration(0)
{
nsIPresShell* aPresShell)
: EventQueue(aDocument),
mObservingState(eNotObservingRefresh),
mPresShell(aPresShell),
mEventGeneration(0) {
#ifdef DEBUG
mMoveGuardOnStack = false;
#endif
@@ -36,11 +37,9 @@ NotificationController::NotificationController(DocAccessible* aDocument,
ScheduleProcessing();
}
NotificationController::~NotificationController()
{
NotificationController::~NotificationController() {
NS_ASSERTION(!mDocument, "Controller wasn't shutdown properly!");
if (mDocument)
Shutdown();
if (mDocument) Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
@@ -52,8 +51,7 @@ NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE(NotificationController)
NS_IMPL_CYCLE_COLLECTION_CLASS(NotificationController)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(NotificationController)
if (tmp->mDocument)
tmp->Shutdown();
if (tmp->mDocument) tmp->Shutdown();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NotificationController)
@@ -63,8 +61,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NotificationController)
cb.NoteXPCOMChild(it.Key());
nsTArray<nsCOMPtr<nsIContent>>* list = it.UserData();
for (uint32_t i = 0; i < list->Length(); i++) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
"mContentInsertions value item");
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mContentInsertions value item");
cb.NoteXPCOMChild(list->ElementAt(i));
}
}
@@ -78,9 +75,7 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(NotificationController, Release)
////////////////////////////////////////////////////////////////////////////////
// NotificationCollector: public
void
NotificationController::Shutdown()
{
void NotificationController::Shutdown() {
if (mObservingState != eNotObservingRefresh &&
mPresShell->RemoveRefreshObserver(this, FlushType::Display)) {
mObservingState = eNotObservingRefresh;
@@ -106,9 +101,7 @@ NotificationController::Shutdown()
mEventTree.Clear();
}
EventTree*
NotificationController::QueueMutation(Accessible* aContainer)
{
EventTree* NotificationController::QueueMutation(Accessible* aContainer) {
EventTree* tree = mEventTree.FindOrInsert(aContainer);
if (tree) {
ScheduleProcessing();
@@ -116,15 +109,14 @@ NotificationController::QueueMutation(Accessible* aContainer)
return tree;
}
bool
NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
{
bool NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent) {
// We have to allow there to be a hide and then a show event for a target
// because of targets getting moved. However we need to coalesce a show and
// then a hide for a target which means we need to check for that here.
if (aEvent->GetEventType() == nsIAccessibleEvent::EVENT_HIDE &&
if (aEvent->GetEventType() == nsIAccessibleEvent::EVENT_HIDE &&
aEvent->GetAccessible()->ShowEventTarget()) {
AccTreeMutationEvent* showEvent = mMutationMap.GetEvent(aEvent->GetAccessible(), EventMap::ShowEvent);
AccTreeMutationEvent* showEvent =
mMutationMap.GetEvent(aEvent->GetAccessible(), EventMap::ShowEvent);
DropMutationEvent(showEvent);
return false;
}
@@ -139,7 +131,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
}
if (mLastMutationEvent) {
NS_ASSERTION(!mLastMutationEvent->NextEvent(), "why isn't the last event the end?");
NS_ASSERTION(!mLastMutationEvent->NextEvent(),
"why isn't the last event the end?");
mLastMutationEvent->SetNextEvent(aEvent);
}
@@ -162,8 +155,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
}
}
// We need to fire a reorder event after all of the events targeted at shown or
// hidden children of a container. So either queue a new one, or move an
// We need to fire a reorder event after all of the events targeted at shown
// or hidden children of a container. So either queue a new one, or move an
// existing one to the end of the queue if the container already has a
// reorder event.
Accessible* target = aEvent->GetAccessible();
@@ -178,7 +171,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
// container may be changing.
QueueNameChange(target);
} else {
AccReorderEvent* event = downcast_accEvent(mMutationMap.GetEvent(container, EventMap::ReorderEvent));
AccReorderEvent* event = downcast_accEvent(
mMutationMap.GetEvent(container, EventMap::ReorderEvent));
reorder = event;
if (mFirstMutationEvent == event) {
mFirstMutationEvent = event->NextEvent();
@@ -186,8 +180,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
event->PrevEvent()->SetNextEvent(event->NextEvent());
}
event->NextEvent()->SetPrevEvent(event->PrevEvent());
event->SetNextEvent(nullptr);
event->NextEvent()->SetPrevEvent(event->PrevEvent());
event->SetNextEvent(nullptr);
}
reorder->SetEventGeneration(mEventGeneration);
@@ -211,11 +205,13 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
int32_t offset = container->AsHyperText()->GetChildOffset(target);
AccTreeMutationEvent* prevEvent = aEvent->PrevEvent();
while (prevEvent && prevEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER) {
while (prevEvent &&
prevEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER) {
prevEvent = prevEvent->PrevEvent();
}
if (prevEvent && prevEvent->GetEventType() == nsIAccessibleEvent::EVENT_HIDE &&
if (prevEvent &&
prevEvent->GetEventType() == nsIAccessibleEvent::EVENT_HIDE &&
mutEvent->IsHide()) {
AccHideEvent* prevHide = downcast_accEvent(prevEvent);
AccTextChangeEvent* prevTextChange = prevHide->mTextChangeEvent;
@@ -228,7 +224,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
target->AppendTextTo(temp);
uint32_t extraLen = temp.Length();
temp += prevTextChange->mModifiedText;;
temp += prevTextChange->mModifiedText;
;
prevTextChange->mModifiedText = temp;
prevTextChange->mStart -= extraLen;
prevHide->mTextChangeEvent.swap(mutEvent->mTextChangeEvent);
@@ -256,17 +253,15 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
}
if (!mutEvent->mTextChangeEvent) {
mutEvent->mTextChangeEvent =
new AccTextChangeEvent(container, offset, text, mutEvent->IsShow(),
aEvent->mIsFromUserInput ? eFromUserInput : eNoUserInput);
mutEvent->mTextChangeEvent = new AccTextChangeEvent(
container, offset, text, mutEvent->IsShow(),
aEvent->mIsFromUserInput ? eFromUserInput : eNoUserInput);
}
return true;
}
void
NotificationController::DropMutationEvent(AccTreeMutationEvent* aEvent)
{
void NotificationController::DropMutationEvent(AccTreeMutationEvent* aEvent) {
// unset the event bits since the event isn't being fired any more.
if (aEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER) {
aEvent->GetAccessible()->SetReorderEventTarget(false);
@@ -301,9 +296,7 @@ NotificationController::DropMutationEvent(AccTreeMutationEvent* aEvent)
mMutationMap.RemoveEvent(aEvent);
}
void
NotificationController::CoalesceMutationEvents()
{
void NotificationController::CoalesceMutationEvents() {
AccTreeMutationEvent* event = mFirstMutationEvent;
while (event) {
AccTreeMutationEvent* nextEvent = event->NextEvent();
@@ -325,14 +318,16 @@ NotificationController::CoalesceMutationEvents()
Accessible* parent = acc->Parent();
if (parent->ReorderEventTarget()) {
AccReorderEvent* reorder = downcast_accEvent(mMutationMap.GetEvent(parent, EventMap::ReorderEvent));
AccReorderEvent* reorder = downcast_accEvent(
mMutationMap.GetEvent(parent, EventMap::ReorderEvent));
// We want to make sure that a reorder event comes after any show or
// hide events targeted at the children of its target. We keep the
// invariant that event generation goes up as you are farther in the
// queue, so we want to use the spot of the event with the higher
// generation number, and keep that generation number.
if (reorder && reorder->EventGeneration() < event->EventGeneration()) {
if (reorder &&
reorder->EventGeneration() < event->EventGeneration()) {
reorder->SetEventGeneration(event->EventGeneration());
// It may be true that reorder was before event, and we coalesced
@@ -378,7 +373,8 @@ NotificationController::CoalesceMutationEvents()
parent = parent->Parent();
}
} else {
MOZ_ASSERT(eventType == nsIAccessibleEvent::EVENT_HIDE, "mutation event list has an invalid event");
MOZ_ASSERT(eventType == nsIAccessibleEvent::EVENT_HIDE,
"mutation event list has an invalid event");
AccHideEvent* hideEvent = downcast_accEvent(event);
Accessible* parent = hideEvent->Parent();
@@ -393,7 +389,8 @@ NotificationController::CoalesceMutationEvents()
}
if (parent->ShowEventTarget()) {
AccShowEvent* showEvent = downcast_accEvent(mMutationMap.GetEvent(parent, EventMap::ShowEvent));
AccShowEvent* showEvent = downcast_accEvent(
mMutationMap.GetEvent(parent, EventMap::ShowEvent));
if (showEvent->EventGeneration() < hideEvent->EventGeneration()) {
DropMutationEvent(hideEvent);
break;
@@ -408,18 +405,14 @@ NotificationController::CoalesceMutationEvents()
}
}
void
NotificationController::ScheduleChildDocBinding(DocAccessible* aDocument)
{
void NotificationController::ScheduleChildDocBinding(DocAccessible* aDocument) {
// Schedule child document binding to the tree.
mHangingChildDocuments.AppendElement(aDocument);
ScheduleProcessing();
}
void
NotificationController::ScheduleContentInsertion(nsIContent* aStartChildNode,
nsIContent* aEndChildNode)
{
void NotificationController::ScheduleContentInsertion(
nsIContent* aStartChildNode, nsIContent* aEndChildNode) {
// The frame constructor guarantees that only ranges with the same parent
// arrive here in presence of dynamic changes to the page, see
// nsCSSFrameConstructor::IssueSingleInsertNotifications' callers.
@@ -434,8 +427,7 @@ NotificationController::ScheduleContentInsertion(nsIContent* aStartChildNode,
}
AutoTArray<nsCOMPtr<nsIContent>, 10> list;
for (nsIContent* node = aStartChildNode;
node != aEndChildNode;
for (nsIContent* node = aStartChildNode; node != aEndChildNode;
node = node->GetNextSibling()) {
MOZ_ASSERT(parent == node->GetFlattenedTreeParentNode());
// Notification triggers for content insertion even if no content was
@@ -453,9 +445,7 @@ NotificationController::ScheduleContentInsertion(nsIContent* aStartChildNode,
}
}
void
NotificationController::ScheduleProcessing()
{
void NotificationController::ScheduleProcessing() {
// If notification flush isn't planed yet start notification flush
// asynchronously (after style and layout).
if (mObservingState == eNotObservingRefresh) {
@@ -467,20 +457,15 @@ NotificationController::ScheduleProcessing()
////////////////////////////////////////////////////////////////////////////////
// NotificationCollector: protected
bool
NotificationController::IsUpdatePending()
{
bool NotificationController::IsUpdatePending() {
return mPresShell->IsLayoutFlushObserver() ||
mObservingState == eRefreshProcessingForUpdate ||
WaitingForParent() ||
mContentInsertions.Count() != 0 || mNotifications.Length() != 0 ||
mTextHash.Count() != 0 ||
!mDocument->HasLoadState(DocAccessible::eTreeConstructed);
mObservingState == eRefreshProcessingForUpdate || WaitingForParent() ||
mContentInsertions.Count() != 0 || mNotifications.Length() != 0 ||
mTextHash.Count() != 0 ||
!mDocument->HasLoadState(DocAccessible::eTreeConstructed);
}
bool
NotificationController::WaitingForParent()
{
bool NotificationController::WaitingForParent() {
DocAccessible* parentdoc = mDocument->ParentDocument();
if (!parentdoc) {
return false;
@@ -497,17 +482,15 @@ NotificationController::WaitingForParent()
parent->mNotifications.Length() != 0;
}
void
NotificationController::ProcessMutationEvents()
{
void NotificationController::ProcessMutationEvents() {
// there is no reason to fire a hide event for a child of a show event
// target. That can happen if something is inserted into the tree and
// removed before the next refresh driver tick, but it should not be
// observable outside gecko so it should be safe to coalesce away any such
// events. This means that it should be fine to fire all of the hide events
// first, and then deal with any shown subtrees.
for (AccTreeMutationEvent* event = mFirstMutationEvent;
event; event = event->NextEvent()) {
for (AccTreeMutationEvent* event = mFirstMutationEvent; event;
event = event->NextEvent()) {
if (event->GetEventType() != nsIAccessibleEvent::EVENT_HIDE) {
continue;
}
@@ -549,9 +532,10 @@ NotificationController::ProcessMutationEvents()
}
// Group the show events by the parent of their target.
nsDataHashtable<nsPtrHashKey<Accessible>, nsTArray<AccTreeMutationEvent*>> showEvents;
for (AccTreeMutationEvent* event = mFirstMutationEvent;
event; event = event->NextEvent()) {
nsDataHashtable<nsPtrHashKey<Accessible>, nsTArray<AccTreeMutationEvent*>>
showEvents;
for (AccTreeMutationEvent* event = mFirstMutationEvent; event;
event = event->NextEvent()) {
if (event->GetEventType() != nsIAccessibleEvent::EVENT_SHOW) {
continue;
}
@@ -565,15 +549,15 @@ NotificationController::ProcessMutationEvents()
// container by the index of their target.
for (auto iter = showEvents.Iter(); !iter.Done(); iter.Next()) {
struct AccIdxComparator {
bool LessThan(const AccTreeMutationEvent* a, const AccTreeMutationEvent* b) const
{
bool LessThan(const AccTreeMutationEvent* a,
const AccTreeMutationEvent* b) const {
int32_t aIdx = a->GetAccessible()->IndexInParent();
int32_t bIdx = b->GetAccessible()->IndexInParent();
MOZ_ASSERT(aIdx >= 0 && bIdx >= 0 && aIdx != bIdx);
return aIdx < bIdx;
}
bool Equals(const AccTreeMutationEvent* a, const AccTreeMutationEvent* b) const
{
bool Equals(const AccTreeMutationEvent* a,
const AccTreeMutationEvent* b) const {
DebugOnly<int32_t> aIdx = a->GetAccessible()->IndexInParent();
DebugOnly<int32_t> bIdx = b->GetAccessible()->IndexInParent();
MOZ_ASSERT(aIdx >= 0 && bIdx >= 0 && aIdx != bIdx);
@@ -583,7 +567,7 @@ NotificationController::ProcessMutationEvents()
nsTArray<AccTreeMutationEvent*>& events = iter.Data();
events.Sort(AccIdxComparator());
for (AccTreeMutationEvent* event: events) {
for (AccTreeMutationEvent* event : events) {
nsEventShell::FireEvent(event);
if (!mDocument) {
return;
@@ -600,8 +584,8 @@ NotificationController::ProcessMutationEvents()
}
// Now we can fire the reorder events after all the show and hide events.
for (AccTreeMutationEvent* event = mFirstMutationEvent;
event; event = event->NextEvent()) {
for (AccTreeMutationEvent* event = mFirstMutationEvent; event;
event = event->NextEvent()) {
if (event->GetEventType() != nsIAccessibleEvent::EVENT_REORDER) {
continue;
}
@@ -622,19 +606,17 @@ NotificationController::ProcessMutationEvents()
////////////////////////////////////////////////////////////////////////////////
// NotificationCollector: private
void
NotificationController::WillRefresh(mozilla::TimeStamp aTime)
{
void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
Telemetry::AutoTimer<Telemetry::A11Y_TREE_UPDATE_TIMING_MS> timer;
AUTO_PROFILER_LABEL("NotificationController::WillRefresh", OTHER);
// If the document accessible that notification collector was created for is
// now shut down, don't process notifications anymore.
NS_ASSERTION(mDocument,
"The document was shut down while refresh observer is attached!");
if (!mDocument)
return;
NS_ASSERTION(
mDocument,
"The document was shut down while refresh observer is attached!");
if (!mDocument) return;
// Wait until an update, we have started, or an interruptible reflow is
// finished.
@@ -677,7 +659,8 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
mDocument->DoInitialUpdate();
NS_ASSERTION(mContentInsertions.Count() == 0,
"Pending content insertions while initial accessible tree isn't created!");
"Pending content insertions while initial accessible tree "
"isn't created!");
}
// Initialize scroll support if needed.
@@ -707,44 +690,46 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
continue;
}
#ifdef A11Y_LOG
nsIContent* containerElm = containerNode->IsElement() ?
containerNode->AsElement() : nullptr;
#endif
#ifdef A11Y_LOG
nsIContent* containerElm =
containerNode->IsElement() ? containerNode->AsElement() : nullptr;
#endif
nsIFrame::RenderedText text = textFrame->GetRenderedText(0,
UINT32_MAX, nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
nsIFrame::RenderedText text = textFrame->GetRenderedText(
0, UINT32_MAX, nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE);
// Remove text accessible if rendered text is empty.
if (textAcc) {
if (text.mString.IsEmpty()) {
#ifdef A11Y_LOG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree | logging::eText)) {
logging::MsgBegin("TREE", "text node lost its content; doc: %p", mDocument);
logging::MsgBegin("TREE", "text node lost its content; doc: %p",
mDocument);
logging::Node("container", containerElm);
logging::Node("content", textNode);
logging::MsgEnd();
}
#endif
#endif
mDocument->ContentRemoved(textAcc);
continue;
}
// Update text of the accessible and fire text change events.
#ifdef A11Y_LOG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eText)) {
logging::MsgBegin("TEXT", "text may be changed; doc: %p", mDocument);
logging::Node("container", containerElm);
logging::Node("content", textNode);
logging::MsgEntry("old text '%s'",
NS_ConvertUTF16toUTF8(textAcc->AsTextLeaf()->Text()).get());
logging::MsgEntry(
"old text '%s'",
NS_ConvertUTF16toUTF8(textAcc->AsTextLeaf()->Text()).get());
logging::MsgEntry("new text: '%s'",
NS_ConvertUTF16toUTF8(text.mString).get());
logging::MsgEnd();
}
#endif
#endif
TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text.mString);
continue;
@@ -752,23 +737,24 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
// Append an accessible if rendered text is not empty.
if (!text.mString.IsEmpty()) {
#ifdef A11Y_LOG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree | logging::eText)) {
logging::MsgBegin("TREE", "text node gains new content; doc: %p", mDocument);
logging::MsgBegin("TREE", "text node gains new content; doc: %p",
mDocument);
logging::Node("container", containerElm);
logging::Node("content", textNode);
logging::MsgEnd();
}
#endif
#endif
MOZ_ASSERT(mDocument->AccessibleOrTrueContainer(containerNode),
"Text node having rendered text hasn't accessible document!");
Accessible* container = mDocument->AccessibleOrTrueContainer(
containerNode, DocAccessible::eNoContainerIfARIAHidden);
containerNode, DocAccessible::eNoContainerIfARIAHidden);
if (container) {
nsTArray<nsCOMPtr<nsIContent>>* list =
mContentInsertions.LookupOrAdd(container);
mContentInsertions.LookupOrAdd(container);
list->AppendElement(textNode);
}
}
@@ -791,16 +777,16 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
nsTArray<RefPtr<DocAccessible>> newChildDocs;
for (uint32_t idx = 0; idx < hangingDocCnt; idx++) {
DocAccessible* childDoc = mHangingChildDocuments[idx];
if (childDoc->IsDefunct())
continue;
if (childDoc->IsDefunct()) continue;
if (IPCAccessibilityActive() && !mDocument->IPCDoc()) {
childDoc->Shutdown();
continue;
}
nsIContent* ownerContent = mDocument->DocumentNode()->
FindContentForSubDocument(childDoc->DocumentNode());
nsIContent* ownerContent =
mDocument->DocumentNode()->FindContentForSubDocument(
childDoc->DocumentNode());
if (ownerContent) {
Accessible* outerDocAcc = mDocument->GetAccessible(ownerContent);
if (outerDocAcc && outerDocAcc->AppendChild(childDoc)) {
@@ -832,26 +818,23 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
uint32_t childDocCnt = mDocument->ChildDocumentCount(), childDocIdx = 0;
for (; childDocIdx < childDocCnt; childDocIdx++) {
DocAccessible* childDoc = mDocument->GetChildDocumentAt(childDocIdx);
if (!childDoc->HasLoadState(DocAccessible::eCompletelyLoaded))
break;
if (!childDoc->HasLoadState(DocAccessible::eCompletelyLoaded)) break;
}
if (childDocIdx == childDocCnt) {
mDocument->ProcessLoad();
if (!mDocument)
return;
if (!mDocument) return;
}
}
// Process only currently queued generic notifications.
nsTArray < RefPtr<Notification> > notifications;
nsTArray<RefPtr<Notification>> notifications;
notifications.SwapElements(mNotifications);
uint32_t notificationCount = notifications.Length();
for (uint32_t idx = 0; idx < notificationCount; idx++) {
notifications[idx]->Process();
if (!mDocument)
return;
if (!mDocument) return;
}
// Process invalidation list of the document after all accessible tree
@@ -860,8 +843,10 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
// Process relocation list.
for (uint32_t idx = 0; idx < mRelocations.Length(); idx++) {
// owner should be in a document and have na associated DOM node (docs sometimes don't)
if (mRelocations[idx]->IsInDocument() && mRelocations[idx]->HasOwnContent()) {
// owner should be in a document and have na associated DOM node (docs
// sometimes don't)
if (mRelocations[idx]->IsInDocument() &&
mRelocations[idx]->HasOwnContent()) {
mDocument->DoARIAOwnsRelocation(mRelocations[idx]);
}
}
@@ -931,22 +916,21 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
childDoc->SetIPCDoc(ipcDoc);
#if defined(XP_WIN)
parentIPCDoc->ConstructChildDocInParentProcess(ipcDoc, id,
AccessibleWrap::GetChildIDFor(childDoc));
parentIPCDoc->ConstructChildDocInParentProcess(
ipcDoc, id, AccessibleWrap::GetChildIDFor(childDoc));
#else
nsCOMPtr<nsITabChild> tabChild =
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
if (tabChild) {
static_cast<TabChild*>(tabChild.get())->
SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id, 0, 0);
static_cast<TabChild*>(tabChild.get())
->SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id, 0, 0);
}
#endif
}
}
mObservingState = eRefreshObserving;
if (!mDocument)
return;
if (!mDocument) return;
// Stop further processing if there are no new notifications of any kind or
// events and document load is processed.
@@ -959,9 +943,7 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
}
}
void
NotificationController::EventMap::PutEvent(AccTreeMutationEvent* aEvent)
{
void NotificationController::EventMap::PutEvent(AccTreeMutationEvent* aEvent) {
EventType type = GetEventType(aEvent);
uint64_t addr = reinterpret_cast<uintptr_t>(aEvent->GetAccessible());
MOZ_ASSERT((addr & 0x3) == 0, "accessible is not 4 byte aligned");
@@ -969,9 +951,8 @@ NotificationController::EventMap::PutEvent(AccTreeMutationEvent* aEvent)
mTable.Put(addr, aEvent);
}
AccTreeMutationEvent*
NotificationController::EventMap::GetEvent(Accessible* aTarget, EventType aType)
{
AccTreeMutationEvent* NotificationController::EventMap::GetEvent(
Accessible* aTarget, EventType aType) {
uint64_t addr = reinterpret_cast<uintptr_t>(aTarget);
MOZ_ASSERT((addr & 0x3) == 0, "target is not 4 byte aligned");
@@ -979,9 +960,8 @@ NotificationController::EventMap::GetEvent(Accessible* aTarget, EventType aType)
return mTable.GetWeak(addr);
}
void
NotificationController::EventMap::RemoveEvent(AccTreeMutationEvent* aEvent)
{
void NotificationController::EventMap::RemoveEvent(
AccTreeMutationEvent* aEvent) {
EventType type = GetEventType(aEvent);
uint64_t addr = reinterpret_cast<uintptr_t>(aEvent->GetAccessible());
MOZ_ASSERT((addr & 0x3) == 0, "accessible is not 4 byte aligned");
@@ -991,11 +971,9 @@ NotificationController::EventMap::RemoveEvent(AccTreeMutationEvent* aEvent)
mTable.Remove(addr);
}
NotificationController::EventMap::EventType
NotificationController::EventMap::GetEventType(AccTreeMutationEvent* aEvent)
{
switch(aEvent->GetEventType())
{
NotificationController::EventMap::EventType
NotificationController::EventMap::GetEventType(AccTreeMutationEvent* aEvent) {
switch (aEvent->GetEventType()) {
case nsIAccessibleEvent::EVENT_SHOW:
return ShowEvent;
case nsIAccessibleEvent::EVENT_HIDE:

View File

@@ -27,9 +27,8 @@ class DocAccessible;
/**
* Notification interface.
*/
class Notification
{
public:
class Notification {
public:
NS_INLINE_DECL_REFCOUNTING(mozilla::a11y::Notification)
/**
@@ -37,20 +36,19 @@ public:
*/
virtual void Process() = 0;
protected:
Notification() { }
protected:
Notification() {}
/**
* Protected destructor, to discourage deletion outside of Release():
*/
virtual ~Notification() { }
virtual ~Notification() {}
private:
private:
Notification(const Notification&);
Notification& operator = (const Notification&);
Notification& operator=(const Notification&);
};
/**
* Template class for generic notification.
*
@@ -58,41 +56,39 @@ private:
* longer than the document accessible owning the notification controller
* that this notification is processed by.
*/
template<class Class, class ... Args>
class TNotification : public Notification
{
public:
typedef void (Class::*Callback)(Args* ...);
template <class Class, class... Args>
class TNotification : public Notification {
public:
typedef void (Class::*Callback)(Args*...);
TNotification(Class* aInstance, Callback aCallback, Args* ... aArgs) :
mInstance(aInstance), mCallback(aCallback), mArgs(aArgs...) { }
TNotification(Class* aInstance, Callback aCallback, Args*... aArgs)
: mInstance(aInstance), mCallback(aCallback), mArgs(aArgs...) {}
virtual ~TNotification() { mInstance = nullptr; }
virtual void Process() override
{ ProcessHelper(std::index_sequence_for<Args...>{}); }
virtual void Process() override {
ProcessHelper(std::index_sequence_for<Args...>{});
}
private:
private:
TNotification(const TNotification&);
TNotification& operator = (const TNotification&);
TNotification& operator=(const TNotification&);
template <size_t... Indices>
void ProcessHelper(std::index_sequence<Indices...>)
{
(mInstance->*mCallback)(Get<Indices>(mArgs)...);
void ProcessHelper(std::index_sequence<Indices...>) {
(mInstance->*mCallback)(Get<Indices>(mArgs)...);
}
Class* mInstance;
Callback mCallback;
Tuple<RefPtr<Args> ...> mArgs;
Tuple<RefPtr<Args>...> mArgs;
};
/**
* Used to process notifications from core for the document accessible.
*/
class NotificationController final : public EventQueue,
public nsARefreshObserver
{
public:
public nsARefreshObserver {
public:
NotificationController(DocAccessible* aDocument, nsIPresShell* aPresShell);
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
@@ -108,8 +104,7 @@ public:
/**
* Add an accessible event into the queue to process it later.
*/
void QueueEvent(AccEvent* aEvent)
{
void QueueEvent(AccEvent* aEvent) {
if (PushEvent(aEvent)) {
ScheduleProcessing();
}
@@ -120,8 +115,7 @@ public:
* the given accessible, if the accessible is a part of name computation of
* the container.
*/
void QueueNameChange(Accessible* aChangeTarget)
{
void QueueNameChange(Accessible* aChangeTarget) {
if (PushNameChange(aChangeTarget)) {
ScheduleProcessing();
}
@@ -134,10 +128,9 @@ public:
EventTree* QueueMutation(Accessible* aContainer);
class MoveGuard final {
public:
explicit MoveGuard(NotificationController* aController) :
mController(aController)
{
public:
explicit MoveGuard(NotificationController* aController)
: mController(aController) {
#ifdef DEBUG
MOZ_ASSERT(!mController->mMoveGuardOnStack,
"Move guard is on stack already!");
@@ -152,7 +145,7 @@ public:
mController->mPrecedingEvents.Clear();
}
private:
private:
NotificationController* mController;
};
@@ -179,12 +172,12 @@ public:
/**
* Schedule the accessible tree update because of rendered text changes.
*/
inline void ScheduleTextUpdate(nsIContent* aTextNode)
{
inline void ScheduleTextUpdate(nsIContent* aTextNode) {
// Make sure we are not called with a node that is not in the DOM tree or
// not visible.
MOZ_ASSERT(aTextNode->GetParentNode(), "A text node is not in DOM");
MOZ_ASSERT(aTextNode->GetPrimaryFrame(), "A text node doesn't have a frame");
MOZ_ASSERT(aTextNode->GetPrimaryFrame(),
"A text node doesn't have a frame");
MOZ_ASSERT(aTextNode->GetPrimaryFrame()->StyleVisibility()->IsVisible(),
"A text node is not visible");
@@ -201,8 +194,7 @@ public:
/**
* Pend an accessible subtree relocation.
*/
void ScheduleRelocation(Accessible* aOwner)
{
void ScheduleRelocation(Accessible* aOwner) {
if (!mRelocations.Contains(aOwner) && mRelocations.AppendElement(aOwner)) {
ScheduleProcessing();
}
@@ -222,14 +214,14 @@ public:
* @note The caller must guarantee that the given instance still exists when
* the notification is processed.
*/
template<class Class, class Arg>
inline void HandleNotification(Class* aInstance,
typename TNotification<Class, Arg>::Callback aMethod,
Arg* aArg)
{
template <class Class, class Arg>
inline void HandleNotification(
Class* aInstance, typename TNotification<Class, Arg>::Callback aMethod,
Arg* aArg) {
if (!IsUpdatePending()) {
#ifdef A11Y_LOG
if (mozilla::a11y::logging::IsEnabled(mozilla::a11y::logging::eNotifications))
if (mozilla::a11y::logging::IsEnabled(
mozilla::a11y::logging::eNotifications))
mozilla::a11y::logging::Text("sync notification processing");
#endif
(aInstance->*aMethod)(aArg);
@@ -237,7 +229,7 @@ public:
}
RefPtr<Notification> notification =
new TNotification<Class, Arg>(aInstance, aMethod, aArg);
new TNotification<Class, Arg>(aInstance, aMethod, aArg);
if (notification && mNotifications.AppendElement(notification))
ScheduleProcessing();
}
@@ -248,34 +240,33 @@ public:
* @note The caller must guarantee that the given instance still exists when
* the notification is processed.
*/
template<class Class>
inline void ScheduleNotification(Class* aInstance,
typename TNotification<Class>::Callback aMethod)
{
template <class Class>
inline void ScheduleNotification(
Class* aInstance, typename TNotification<Class>::Callback aMethod) {
RefPtr<Notification> notification =
new TNotification<Class>(aInstance, aMethod);
new TNotification<Class>(aInstance, aMethod);
if (notification && mNotifications.AppendElement(notification))
ScheduleProcessing();
}
template<class Class, class Arg>
inline void ScheduleNotification(Class* aInstance,
typename TNotification<Class, Arg>::Callback aMethod,
Arg* aArg)
{
template <class Class, class Arg>
inline void ScheduleNotification(
Class* aInstance, typename TNotification<Class, Arg>::Callback aMethod,
Arg* aArg) {
RefPtr<Notification> notification =
new TNotification<Class, Arg>(aInstance, aMethod, aArg);
new TNotification<Class, Arg>(aInstance, aMethod, aArg);
if (notification && mNotifications.AppendElement(notification)) {
ScheduleProcessing();
}
}
#ifdef DEBUG
bool IsUpdating() const
{ return mObservingState == eRefreshProcessingForUpdate; }
bool IsUpdating() const {
return mObservingState == eRefreshProcessingForUpdate;
}
#endif
protected:
protected:
virtual ~NotificationController();
nsCycleCollectingAutoRefCnt mRefCnt;
@@ -292,9 +283,9 @@ protected:
*/
bool WaitingForParent();
private:
private:
NotificationController(const NotificationController&);
NotificationController& operator = (const NotificationController&);
NotificationController& operator=(const NotificationController&);
// nsARefreshObserver
virtual void WillRefresh(mozilla::TimeStamp aTime) override;
@@ -302,24 +293,21 @@ private:
/**
* Set and returns a hide event, paired with a show event, for the move.
*/
void WithdrawPrecedingEvents(nsTArray<RefPtr<AccHideEvent>>* aEvs)
{
void WithdrawPrecedingEvents(nsTArray<RefPtr<AccHideEvent>>* aEvs) {
if (mPrecedingEvents.Length() > 0) {
aEvs->AppendElements(std::move(mPrecedingEvents));
}
}
void StorePrecedingEvent(AccHideEvent* aEv)
{
void StorePrecedingEvent(AccHideEvent* aEv) {
MOZ_ASSERT(mMoveGuardOnStack, "No move guard on stack!");
mPrecedingEvents.AppendElement(aEv);
}
void StorePrecedingEvents(nsTArray<RefPtr<AccHideEvent>>&& aEvs)
{
void StorePrecedingEvents(nsTArray<RefPtr<AccHideEvent>>&& aEvs) {
MOZ_ASSERT(mMoveGuardOnStack, "No move guard on stack!");
mPrecedingEvents.InsertElementsAt(0, aEvs);
}
private:
private:
/**
* get rid of a mutation event that is no longer necessary.
*/
@@ -350,56 +338,54 @@ private:
/**
* Child documents that needs to be bound to the tree.
*/
nsTArray<RefPtr<DocAccessible> > mHangingChildDocuments;
nsTArray<RefPtr<DocAccessible>> mHangingChildDocuments;
/**
* Pending accessible tree update notifications for content insertions.
*/
nsClassHashtable<nsRefPtrHashKey<Accessible>,
nsTArray<nsCOMPtr<nsIContent>>> mContentInsertions;
nsClassHashtable<nsRefPtrHashKey<Accessible>, nsTArray<nsCOMPtr<nsIContent>>>
mContentInsertions;
template<class T>
class nsCOMPtrHashKey : public PLDHashEntryHdr
{
public:
template <class T>
class nsCOMPtrHashKey : public PLDHashEntryHdr {
public:
typedef T* KeyType;
typedef const T* KeyTypePointer;
explicit nsCOMPtrHashKey(const T* aKey) : mKey(const_cast<T*>(aKey)) {}
nsCOMPtrHashKey(nsCOMPtrHashKey<T>&& aOther)
: PLDHashEntryHdr(std::move(aOther))
, mKey(std::move(aOther.mKey))
{}
~nsCOMPtrHashKey() { }
: PLDHashEntryHdr(std::move(aOther)), mKey(std::move(aOther.mKey)) {}
~nsCOMPtrHashKey() {}
KeyType GetKey() const { return mKey; }
bool KeyEquals(KeyTypePointer aKey) const { return aKey == mKey; }
static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
static PLDHashNumber HashKey(KeyTypePointer aKey)
{ return NS_PTR_TO_INT32(aKey) >> 2; }
static PLDHashNumber HashKey(KeyTypePointer aKey) {
return NS_PTR_TO_INT32(aKey) >> 2;
}
enum { ALLOW_MEMMOVE = true };
protected:
nsCOMPtr<T> mKey;
nsCOMPtr<T> mKey;
};
/**
* Pending accessible tree update notifications for rendered text changes.
*/
nsTHashtable<nsCOMPtrHashKey<nsIContent> > mTextHash;
nsTHashtable<nsCOMPtrHashKey<nsIContent>> mTextHash;
/**
* Other notifications like DOM events. Don't make this an AutoTArray; we
* use SwapElements() on it.
*/
nsTArray<RefPtr<Notification> > mNotifications;
nsTArray<RefPtr<Notification>> mNotifications;
/**
* Holds all scheduled relocations.
*/
nsTArray<RefPtr<Accessible> > mRelocations;
nsTArray<RefPtr<Accessible>> mRelocations;
/**
* Holds all mutation events.
@@ -429,11 +415,9 @@ private:
/**
* A class to map an accessible and event type to an event.
*/
class EventMap
{
public:
enum EventType
{
class EventMap {
public:
enum EventType {
ShowEvent = 0x0,
HideEvent = 0x1,
ReorderEvent = 0x2,
@@ -444,7 +428,7 @@ private:
void RemoveEvent(AccTreeMutationEvent* aEvent);
void Clear() { mTable.Clear(); }
private:
private:
EventType GetEventType(AccTreeMutationEvent* aEvent);
nsRefPtrHashtable<nsUint64HashKey, AccTreeMutationEvent> mTable;
@@ -454,7 +438,7 @@ private:
uint32_t mEventGeneration;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif // mozilla_a11y_NotificationController_h_
#endif // mozilla_a11y_NotificationController_h_

View File

@@ -115,9 +115,8 @@ void ProxyVirtualCursorChangeEvent(ProxyAccessible* aTarget,
int32_t aOldEndOffset,
ProxyAccessible* aNewPosition,
int32_t aNewStartOffset,
int32_t aNewEndOffset,
int16_t aReason, int16_t aBoundaryType,
bool aFromUser);
int32_t aNewEndOffset, int16_t aReason,
int16_t aBoundaryType, bool aFromUser);
void ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType,
uint32_t aScrollX, uint32_t aScrollY,
@@ -125,13 +124,12 @@ void ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType,
class BatchData;
void ProxyBatch(ProxyAccessible* aDocument,
const uint64_t aBatchType,
void ProxyBatch(ProxyAccessible* aDocument, const uint64_t aBatchType,
const nsTArray<ProxyAccessible*>& aAccessibles,
const nsTArray<BatchData>& aData);
#endif
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif // mozilla_a11y_Platform_h
#endif // mozilla_a11y_Platform_h

View File

@@ -18,38 +18,35 @@ namespace a11y {
* A collection of relation targets of a certain type. Targets are computed
* lazily while enumerating.
*/
class Relation
{
public:
Relation() : mFirstIter(nullptr), mLastIter(nullptr) { }
class Relation {
public:
Relation() : mFirstIter(nullptr), mLastIter(nullptr) {}
explicit Relation(AccIterable* aIter) :
mFirstIter(aIter), mLastIter(aIter) { }
explicit Relation(AccIterable* aIter) : mFirstIter(aIter), mLastIter(aIter) {}
explicit Relation(Accessible* aAcc) :
mFirstIter(nullptr), mLastIter(nullptr)
{ AppendTarget(aAcc); }
explicit Relation(Accessible* aAcc)
: mFirstIter(nullptr), mLastIter(nullptr) {
AppendTarget(aAcc);
}
Relation(DocAccessible* aDocument, nsIContent* aContent) :
mFirstIter(nullptr), mLastIter(nullptr)
{ AppendTarget(aDocument, aContent); }
Relation(DocAccessible* aDocument, nsIContent* aContent)
: mFirstIter(nullptr), mLastIter(nullptr) {
AppendTarget(aDocument, aContent);
}
Relation(Relation&& aOther) :
mFirstIter(std::move(aOther.mFirstIter)), mLastIter(aOther.mLastIter)
{
Relation(Relation&& aOther)
: mFirstIter(std::move(aOther.mFirstIter)), mLastIter(aOther.mLastIter) {
aOther.mLastIter = nullptr;
}
Relation& operator = (Relation&& aRH)
{
Relation& operator=(Relation&& aRH) {
mFirstIter = std::move(aRH.mFirstIter);
mLastIter = aRH.mLastIter;
aRH.mLastIter = nullptr;
return *this;
}
inline void AppendIter(AccIterable* aIter)
{
inline void AppendIter(AccIterable* aIter) {
if (mLastIter)
mLastIter->mNextIter.reset(aIter);
else
@@ -61,48 +58,41 @@ public:
/**
* Append the given accessible to the set of related accessibles.
*/
inline void AppendTarget(Accessible* aAcc)
{
if (aAcc)
AppendIter(new SingleAccIterator(aAcc));
inline void AppendTarget(Accessible* aAcc) {
if (aAcc) AppendIter(new SingleAccIterator(aAcc));
}
/**
* Append the one accessible for this content node to the set of related
* accessibles.
*/
void AppendTarget(DocAccessible* aDocument, nsIContent* aContent)
{
if (aContent)
AppendTarget(aDocument->GetAccessible(aContent));
void AppendTarget(DocAccessible* aDocument, nsIContent* aContent) {
if (aContent) AppendTarget(aDocument->GetAccessible(aContent));
}
/**
* compute and return the next related accessible.
*/
inline Accessible* Next()
{
inline Accessible* Next() {
Accessible* target = nullptr;
while (mFirstIter && !(target = mFirstIter->Next()))
mFirstIter = std::move(mFirstIter->mNextIter);
if (!mFirstIter)
mLastIter = nullptr;
if (!mFirstIter) mLastIter = nullptr;
return target;
}
private:
Relation& operator = (const Relation&) = delete;
private:
Relation& operator=(const Relation&) = delete;
Relation(const Relation&) = delete;
std::unique_ptr<AccIterable> mFirstIter;
AccIterable* mLastIter;
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -113,7 +113,8 @@ enum class RelationType {
CONTAINING_DOCUMENT = 0x11,
/**
* The target object is the topmost containing document object in the tab pane.
* The target object is the topmost containing document object in the tab
* pane.
*/
CONTAINING_TAB_PANE = 0x12,
@@ -127,7 +128,6 @@ enum class RelationType {
*/
CONTAINING_APPLICATION = 0x14,
/**
* The target object provides the detailed, extended description for this
* object. It provides more detailed information than would normally be
@@ -157,7 +157,7 @@ enum class RelationType {
LAST = ERRORMSG_FOR
};
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -9,152 +9,79 @@
* RELATIONTYPE(geckoType, geckoTypeName, atkType, msaaType, ia2Type)
*/
RELATIONTYPE(LABELLED_BY,
"labelled by",
ATK_RELATION_LABELLED_BY,
NAVRELATION_LABELLED_BY,
IA2_RELATION_LABELLED_BY)
RELATIONTYPE(LABELLED_BY, "labelled by", ATK_RELATION_LABELLED_BY,
NAVRELATION_LABELLED_BY, IA2_RELATION_LABELLED_BY)
RELATIONTYPE(LABEL_FOR,
"label for",
ATK_RELATION_LABEL_FOR,
NAVRELATION_LABEL_FOR,
IA2_RELATION_LABEL_FOR)
RELATIONTYPE(LABEL_FOR, "label for", ATK_RELATION_LABEL_FOR,
NAVRELATION_LABEL_FOR, IA2_RELATION_LABEL_FOR)
RELATIONTYPE(DESCRIBED_BY,
"described by",
ATK_RELATION_DESCRIBED_BY,
NAVRELATION_DESCRIBED_BY,
IA2_RELATION_DESCRIBED_BY)
RELATIONTYPE(DESCRIBED_BY, "described by", ATK_RELATION_DESCRIBED_BY,
NAVRELATION_DESCRIBED_BY, IA2_RELATION_DESCRIBED_BY)
RELATIONTYPE(DESCRIPTION_FOR,
"description for",
ATK_RELATION_DESCRIPTION_FOR,
NAVRELATION_DESCRIPTION_FOR,
IA2_RELATION_DESCRIPTION_FOR)
RELATIONTYPE(DESCRIPTION_FOR, "description for", ATK_RELATION_DESCRIPTION_FOR,
NAVRELATION_DESCRIPTION_FOR, IA2_RELATION_DESCRIPTION_FOR)
RELATIONTYPE(NODE_CHILD_OF,
"node child of",
ATK_RELATION_NODE_CHILD_OF,
NAVRELATION_NODE_CHILD_OF,
IA2_RELATION_NODE_CHILD_OF)
RELATIONTYPE(NODE_CHILD_OF, "node child of", ATK_RELATION_NODE_CHILD_OF,
NAVRELATION_NODE_CHILD_OF, IA2_RELATION_NODE_CHILD_OF)
RELATIONTYPE(NODE_PARENT_OF,
"node parent of",
ATK_RELATION_NODE_PARENT_OF,
NAVRELATION_NODE_PARENT_OF,
IA2_RELATION_NODE_PARENT_OF)
RELATIONTYPE(NODE_PARENT_OF, "node parent of", ATK_RELATION_NODE_PARENT_OF,
NAVRELATION_NODE_PARENT_OF, IA2_RELATION_NODE_PARENT_OF)
RELATIONTYPE(CONTROLLED_BY,
"controlled by",
ATK_RELATION_CONTROLLED_BY,
NAVRELATION_CONTROLLED_BY,
IA2_RELATION_CONTROLLED_BY)
RELATIONTYPE(CONTROLLED_BY, "controlled by", ATK_RELATION_CONTROLLED_BY,
NAVRELATION_CONTROLLED_BY, IA2_RELATION_CONTROLLED_BY)
RELATIONTYPE(CONTROLLER_FOR,
"controller for",
ATK_RELATION_CONTROLLER_FOR,
NAVRELATION_CONTROLLER_FOR,
IA2_RELATION_CONTROLLER_FOR)
RELATIONTYPE(CONTROLLER_FOR, "controller for", ATK_RELATION_CONTROLLER_FOR,
NAVRELATION_CONTROLLER_FOR, IA2_RELATION_CONTROLLER_FOR)
RELATIONTYPE(FLOWS_TO,
"flows to",
ATK_RELATION_FLOWS_TO,
NAVRELATION_FLOWS_TO,
RELATIONTYPE(FLOWS_TO, "flows to", ATK_RELATION_FLOWS_TO, NAVRELATION_FLOWS_TO,
IA2_RELATION_FLOWS_TO)
RELATIONTYPE(FLOWS_FROM,
"flows from",
ATK_RELATION_FLOWS_FROM,
NAVRELATION_FLOWS_FROM,
IA2_RELATION_FLOWS_FROM)
RELATIONTYPE(FLOWS_FROM, "flows from", ATK_RELATION_FLOWS_FROM,
NAVRELATION_FLOWS_FROM, IA2_RELATION_FLOWS_FROM)
RELATIONTYPE(MEMBER_OF,
"member of",
ATK_RELATION_MEMBER_OF,
NAVRELATION_MEMBER_OF,
IA2_RELATION_MEMBER_OF)
RELATIONTYPE(MEMBER_OF, "member of", ATK_RELATION_MEMBER_OF,
NAVRELATION_MEMBER_OF, IA2_RELATION_MEMBER_OF)
RELATIONTYPE(SUBWINDOW_OF,
"subwindow of",
ATK_RELATION_SUBWINDOW_OF,
NAVRELATION_SUBWINDOW_OF,
IA2_RELATION_SUBWINDOW_OF)
RELATIONTYPE(SUBWINDOW_OF, "subwindow of", ATK_RELATION_SUBWINDOW_OF,
NAVRELATION_SUBWINDOW_OF, IA2_RELATION_SUBWINDOW_OF)
RELATIONTYPE(EMBEDS,
"embeds",
ATK_RELATION_EMBEDS,
NAVRELATION_EMBEDS,
RELATIONTYPE(EMBEDS, "embeds", ATK_RELATION_EMBEDS, NAVRELATION_EMBEDS,
IA2_RELATION_EMBEDS)
RELATIONTYPE(EMBEDDED_BY,
"embedded by",
ATK_RELATION_EMBEDDED_BY,
NAVRELATION_EMBEDDED_BY,
IA2_RELATION_EMBEDDED_BY)
RELATIONTYPE(EMBEDDED_BY, "embedded by", ATK_RELATION_EMBEDDED_BY,
NAVRELATION_EMBEDDED_BY, IA2_RELATION_EMBEDDED_BY)
RELATIONTYPE(POPUP_FOR,
"popup for",
ATK_RELATION_POPUP_FOR,
NAVRELATION_POPUP_FOR,
IA2_RELATION_POPUP_FOR)
RELATIONTYPE(POPUP_FOR, "popup for", ATK_RELATION_POPUP_FOR,
NAVRELATION_POPUP_FOR, IA2_RELATION_POPUP_FOR)
RELATIONTYPE(PARENT_WINDOW_OF,
"parent window of",
ATK_RELATION_PARENT_WINDOW_OF,
NAVRELATION_PARENT_WINDOW_OF,
RELATIONTYPE(PARENT_WINDOW_OF, "parent window of",
ATK_RELATION_PARENT_WINDOW_OF, NAVRELATION_PARENT_WINDOW_OF,
IA2_RELATION_PARENT_WINDOW_OF)
RELATIONTYPE(DEFAULT_BUTTON,
"default button",
ATK_RELATION_NULL,
NAVRELATION_DEFAULT_BUTTON,
IA2_RELATION_NULL)
RELATIONTYPE(DEFAULT_BUTTON, "default button", ATK_RELATION_NULL,
NAVRELATION_DEFAULT_BUTTON, IA2_RELATION_NULL)
RELATIONTYPE(CONTAINING_DOCUMENT,
"containing document",
ATK_RELATION_NULL,
NAVRELATION_CONTAINING_DOCUMENT,
IA2_RELATION_CONTAINING_DOCUMENT)
RELATIONTYPE(CONTAINING_DOCUMENT, "containing document", ATK_RELATION_NULL,
NAVRELATION_CONTAINING_DOCUMENT, IA2_RELATION_CONTAINING_DOCUMENT)
RELATIONTYPE(CONTAINING_TAB_PANE,
"containing tab pane",
ATK_RELATION_NULL,
NAVRELATION_CONTAINING_TAB_PANE,
IA2_RELATION_CONTAINING_TAB_PANE)
RELATIONTYPE(CONTAINING_TAB_PANE, "containing tab pane", ATK_RELATION_NULL,
NAVRELATION_CONTAINING_TAB_PANE, IA2_RELATION_CONTAINING_TAB_PANE)
RELATIONTYPE(CONTAINING_WINDOW,
"containing window",
ATK_RELATION_NULL,
NAVRELATION_CONTAINING_WINDOW,
IA2_RELATION_CONTAINING_WINDOW)
RELATIONTYPE(CONTAINING_WINDOW, "containing window", ATK_RELATION_NULL,
NAVRELATION_CONTAINING_WINDOW, IA2_RELATION_CONTAINING_WINDOW)
RELATIONTYPE(CONTAINING_APPLICATION,
"containing application",
ATK_RELATION_NULL,
NAVRELATION_CONTAINING_APPLICATION,
RELATIONTYPE(CONTAINING_APPLICATION, "containing application",
ATK_RELATION_NULL, NAVRELATION_CONTAINING_APPLICATION,
IA2_RELATION_CONTAINING_APPLICATION)
RELATIONTYPE(DETAILS,
"details",
ATK_RELATION_DETAILS,
NAVRELATION_DETAILS,
RELATIONTYPE(DETAILS, "details", ATK_RELATION_DETAILS, NAVRELATION_DETAILS,
IA2_RELATION_DETAILS)
RELATIONTYPE(DETAILS_FOR,
"details for",
ATK_RELATION_DETAILS_FOR,
NAVRELATION_DETAILS_FOR,
IA2_RELATION_DETAILS_FOR)
RELATIONTYPE(DETAILS_FOR, "details for", ATK_RELATION_DETAILS_FOR,
NAVRELATION_DETAILS_FOR, IA2_RELATION_DETAILS_FOR)
RELATIONTYPE(ERRORMSG,
"error",
ATK_RELATION_ERROR_MESSAGE,
NAVRELATION_ERROR,
RELATIONTYPE(ERRORMSG, "error", ATK_RELATION_ERROR_MESSAGE, NAVRELATION_ERROR,
IA2_RELATION_ERROR)
RELATIONTYPE(ERRORMSG_FOR,
"error for",
ATK_RELATION_ERROR_FOR,
NAVRELATION_ERROR_FOR,
IA2_RELATION_ERROR_FOR)
RELATIONTYPE(ERRORMSG_FOR, "error for", ATK_RELATION_ERROR_FOR,
NAVRELATION_ERROR_FOR, IA2_RELATION_ERROR_FOR)

View File

@@ -362,7 +362,8 @@ enum Role {
/**
* Represents a mathematical equation. It is used by MATHML, where there is a
* rich DOM subtree for an equation. Use FLAT_EQUATION for <img role="math" alt="[TeX]"/>
* rich DOM subtree for an equation. Use FLAT_EQUATION for <img role="math"
* alt="[TeX]"/>
*/
EQUATION = 55,
@@ -418,7 +419,7 @@ enum Role {
/**
* Represents an arrow in one of the four cardinal directions.
*/
ARROW = 65,
ARROW = 65,
/**
* Represents a control that can be drawn into and is used to trap events.
@@ -434,7 +435,7 @@ enum Role {
/**
* Represents a specialized dialog that lets the user choose a color.
*/
COLOR_CHOOSER = 68,
COLOR_CHOOSER = 68,
/**
* Represents control whose purpose is to allow a user to edit a date.
@@ -1047,11 +1048,11 @@ enum Role {
LAST_ROLE = FORM_LANDMARK
};
} // namespace role
} // namespace roles
typedef enum mozilla::a11y::roles::Role role;
} // namespace a11y
} // namespace mozilla
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -24,30 +24,23 @@ using namespace mozilla;
using namespace mozilla::a11y;
using mozilla::dom::Selection;
struct mozilla::a11y::SelData final
{
SelData(Selection* aSel, int32_t aReason) :
mSel(aSel), mReason(aReason) {}
struct mozilla::a11y::SelData final {
SelData(Selection* aSel, int32_t aReason) : mSel(aSel), mReason(aReason) {}
RefPtr<Selection> mSel;
int16_t mReason;
NS_INLINE_DECL_REFCOUNTING(SelData)
private:
private:
// Private destructor, to discourage deletion outside of Release():
~SelData() {}
};
SelectionManager::SelectionManager() :
mCaretOffset(-1), mAccWithCaret(nullptr)
{
SelectionManager::SelectionManager()
: mCaretOffset(-1), mAccWithCaret(nullptr) {}
}
void
SelectionManager::ClearControlSelectionListener()
{
void SelectionManager::ClearControlSelectionListener() {
// Remove 'this' registered as selection listener for the normal selection.
if (mCurrCtrlNormalSel) {
mCurrCtrlNormalSel->RemoveSelectionListener(this);
@@ -62,22 +55,18 @@ SelectionManager::ClearControlSelectionListener()
}
}
void
SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
{
void SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm) {
// When focus moves such that the caret is part of a new frame selection
// this removes the old selection listener and attaches a new one for
// the current focus.
ClearControlSelectionListener();
nsIFrame* controlFrame = aFocusedElm->GetPrimaryFrame();
if (!controlFrame)
return;
if (!controlFrame) return;
const nsFrameSelection* frameSel = controlFrame->GetConstFrameSelection();
NS_ASSERTION(frameSel, "No frame selection for focused element!");
if (!frameSel)
return;
if (!frameSel) return;
// Register 'this' as selection listener for the normal selection.
Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal);
@@ -90,9 +79,7 @@ SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
mCurrCtrlSpellSel = spellSel;
}
void
SelectionManager::AddDocSelectionListener(nsIPresShell* aPresShell)
{
void SelectionManager::AddDocSelectionListener(nsIPresShell* aPresShell) {
const nsFrameSelection* frameSel = aPresShell->ConstFrameSelection();
// Register 'this' as selection listener for the normal selection.
@@ -104,9 +91,7 @@ SelectionManager::AddDocSelectionListener(nsIPresShell* aPresShell)
spellSel->AddSelectionListener(this);
}
void
SelectionManager::RemoveDocSelectionListener(nsIPresShell* aPresShell)
{
void SelectionManager::RemoveDocSelectionListener(nsIPresShell* aPresShell) {
const nsFrameSelection* frameSel = aPresShell->ConstFrameSelection();
// Remove 'this' registered as selection listener for the normal selection.
@@ -119,41 +104,35 @@ SelectionManager::RemoveDocSelectionListener(nsIPresShell* aPresShell)
spellSel->RemoveSelectionListener(this);
}
void
SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent)
{
void SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent) {
// Fire selection change event if it's not pure caret-move selection change,
// i.e. the accessible has or had not collapsed selection.
AccTextSelChangeEvent* event = downcast_accEvent(aEvent);
if (!event->IsCaretMoveOnly())
nsEventShell::FireEvent(aEvent);
if (!event->IsCaretMoveOnly()) nsEventShell::FireEvent(aEvent);
// Fire caret move event if there's a caret in the selection.
nsINode* caretCntrNode =
nsCoreUtils::GetDOMNodeFromDOMPoint(event->mSel->GetFocusNode(),
event->mSel->FocusOffset());
if (!caretCntrNode)
return;
nsINode* caretCntrNode = nsCoreUtils::GetDOMNodeFromDOMPoint(
event->mSel->GetFocusNode(), event->mSel->FocusOffset());
if (!caretCntrNode) return;
HyperTextAccessible* caretCntr = nsAccUtils::GetTextContainer(caretCntrNode);
NS_ASSERTION(caretCntr,
"No text container for focus while there's one for common ancestor?!");
if (!caretCntr)
return;
NS_ASSERTION(
caretCntr,
"No text container for focus while there's one for common ancestor?!");
if (!caretCntr) return;
Selection* selection = caretCntr->DOMSelection();
// XXX Sometimes we can't get a selection for caretCntr, in that case assume
// event->mSel is correct.
if (!selection)
selection = event->mSel;
if (!selection) selection = event->mSel;
mCaretOffset = caretCntr->DOMPointToOffset(selection->GetFocusNode(),
selection->FocusOffset());
mAccWithCaret = caretCntr;
if (mCaretOffset != -1) {
RefPtr<AccCaretMoveEvent> caretMoveEvent =
new AccCaretMoveEvent(caretCntr, mCaretOffset, aEvent->FromUserInput());
new AccCaretMoveEvent(caretCntr, mCaretOffset, aEvent->FromUserInput());
nsEventShell::FireEvent(caretMoveEvent);
}
}
@@ -161,8 +140,7 @@ SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent)
NS_IMETHODIMP
SelectionManager::NotifySelectionChanged(nsIDocument* aDocument,
Selection* aSelection,
int16_t aReason)
{
int16_t aReason) {
if (NS_WARN_IF(!aDocument) || NS_WARN_IF(!aSelection)) {
return NS_ERROR_INVALID_ARG;
}
@@ -179,30 +157,27 @@ SelectionManager::NotifySelectionChanged(nsIDocument* aDocument,
// so that we are guaranteed that the notification is processed before
// the selection manager is destroyed.
RefPtr<SelData> selData = new SelData(aSelection, aReason);
document->HandleNotification<SelectionManager, SelData>
(this, &SelectionManager::ProcessSelectionChanged, selData);
document->HandleNotification<SelectionManager, SelData>(
this, &SelectionManager::ProcessSelectionChanged, selData);
}
return NS_OK;
}
void
SelectionManager::ProcessSelectionChanged(SelData* aSelData)
{
void SelectionManager::ProcessSelectionChanged(SelData* aSelData) {
Selection* selection = aSelData->mSel;
if (!selection->GetPresShell())
return;
if (!selection->GetPresShell()) return;
const nsRange* range = selection->GetAnchorFocusRange();
nsINode* cntrNode = nullptr;
if (range)
cntrNode = range->GetCommonAncestor();
if (range) cntrNode = range->GetCommonAncestor();
if (!cntrNode) {
cntrNode = selection->GetFrameSelection()->GetAncestorLimiter();
if (!cntrNode) {
cntrNode = selection->GetPresShell()->GetDocument();
NS_ASSERTION(aSelData->mSel->GetPresShell()->ConstFrameSelection() == selection->GetFrameSelection(),
NS_ASSERTION(aSelData->mSel->GetPresShell()->ConstFrameSelection() ==
selection->GetFrameSelection(),
"Wrong selection container was used!");
}
}
@@ -216,13 +191,13 @@ SelectionManager::ProcessSelectionChanged(SelData* aSelData)
if (selection->GetType() == SelectionType::eNormal) {
RefPtr<AccEvent> event =
new AccTextSelChangeEvent(text, selection, aSelData->mReason);
new AccTextSelChangeEvent(text, selection, aSelData->mReason);
text->Document()->FireDelayedEvent(event);
} else if (selection->GetType() == SelectionType::eSpellCheck) {
// XXX: fire an event for container accessible of the focus/anchor range
// of the spelcheck selection.
text->Document()->FireDelayedEvent(nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED,
text);
text->Document()->FireDelayedEvent(
nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED, text);
}
}

Some files were not shown because too many files have changed in this diff Show More