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

@@ -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);
}
}
@@ -129,11 +130,9 @@ 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(),
sessionAcc->SendTextChangedEvent(
accessible, event->ModifiedText(), event->GetStartOffset(),
event->GetLength(), event->IsTextInserted(),
event->IsFromUserInput());
break;
}
@@ -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,11 +271,8 @@ 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 =
@@ -310,38 +290,30 @@ 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) \
int32_t AccessibleWrap::GetAndroidClass(role aRole) {
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, \
androidClass, nameRule) \
case roles::geckoRole: \
return androidClass;
@@ -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",
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",
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,25 +32,20 @@ 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());
}
@@ -61,8 +55,7 @@ public:
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,22 +66,22 @@ 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());
}

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,9 +101,7 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
nsRect scrollPort = sf ? sf->GetScrollPortRect() : rootFrame->GetRect();
nsLayoutUtils::GetFramesForArea(
presShell->GetRootFrame(),
scrollPort,
frames,
presShell->GetRootFrame(), scrollPort, frames,
nsLayoutUtils::FrameForPointFlags::ONLY_VISIBLE);
AccessibleHashtable inViewAccs;
for (size_t i = 0; i < frames.Length(); i++) {
@@ -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
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>(),
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,15 +157,11 @@ 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
@@ -185,9 +169,10 @@ DocAccessibleWrap::CacheViewport()
}
}
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,16 +180,15 @@ 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
auto uid = acc->IsDoc() && acc->AsDoc()->IPCDoc()
? 0
: reinterpret_cast<uint64_t>(acc->UniqueID());
nsAutoString name;
acc->Name(name);
@@ -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
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>()));
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();

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,9 +31,7 @@ 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());
@@ -57,9 +47,7 @@ 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);
if (!sessionAcc) {
@@ -73,11 +61,8 @@ 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);
@@ -98,9 +83,7 @@ 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);
@@ -109,29 +92,21 @@ a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t 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);
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);
if (sessionAcc) {
@@ -139,23 +114,14 @@ a11y::ProxyShowHideEvent(ProxyAccessible* aTarget,
}
}
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;
}
@@ -176,36 +142,28 @@ 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);
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,
void a11y::ProxyBatch(ProxyAccessible* aDocument, const uint64_t aBatchType,
const nsTArray<ProxyAccessible*>& aAccessibles,
const nsTArray<BatchData>& aData)
{
const nsTArray<BatchData>& aData) {
SessionAccessibility* sessionAcc =
SessionAccessibility::GetInstanceFor(aDocument);
if (!sessionAcc) {

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;
@@ -34,9 +33,7 @@ ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
}
}
void
ProxyAccessibleWrap::Shutdown()
{
void ProxyAccessibleWrap::Shutdown() {
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
Proxy()->Document()->GetWrapper());
if (mID && doc) {
@@ -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,8 +104,7 @@ 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*>(
@@ -118,23 +114,21 @@ public:
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) {
@@ -63,10 +57,8 @@ RootAccessibleWrap::FindAccessibleById(int32_t 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) {
@@ -81,9 +73,8 @@ 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) {

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();

View File

@@ -29,18 +29,16 @@
} while (0)
#endif
template<>
template <>
const char nsWindow::NativePtr<mozilla::a11y::SessionAccessibility>::sName[] =
"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,10 +47,8 @@ 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",
@@ -68,17 +64,13 @@ SessionAccessibility::SetAttached(bool aAttached,
}
}
void
SessionAccessibility::Init()
{
void SessionAccessibility::Init() {
java::SessionAccessibility::NativeProvider::Natives<
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);
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);
}
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) {
@@ -184,13 +165,11 @@ SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible)
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
}
void
SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
void SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
int32_t aScrollX,
int32_t aScrollY,
int32_t aMaxScrollX,
int32_t aMaxScrollY)
{
int32_t aMaxScrollY) {
int32_t virtualViewId = aAccessible->VirtualViewID();
if (virtualViewId != AccessibleWrap::kNoID) {
@@ -201,8 +180,10 @@ 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(
@@ -212,17 +193,15 @@ SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
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);
}
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) {
@@ -234,10 +213,8 @@ SessionAccessibility::SendWindowStateChangedEvent(AccessibleWrap* aAccessible)
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,8 +223,10 @@ 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(
@@ -255,14 +234,11 @@ SessionAccessibility::SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
}
void
SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
void SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
const nsString& aStr,
int32_t aStart,
uint32_t aLen,
int32_t aStart, uint32_t aLen,
bool aIsInsert,
bool aFromUser)
{
bool aFromUser) {
if (!aFromUser) {
// Only dispatch text change events from users, for now.
return;
@@ -280,8 +256,10 @@ 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(
@@ -289,18 +267,18 @@ SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
}
void
SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
void SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
int32_t aStartOffset,
int32_t aEndOffset)
{
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(
@@ -309,12 +287,12 @@ SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
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(
@@ -322,12 +300,12 @@ SessionAccessibility::SendClickedEvent(AccessibleWrap* aAccessible, bool aChecke
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(
@@ -335,10 +313,9 @@ SessionAccessibility::SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelec
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,10 +331,9 @@ 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);
@@ -365,16 +341,10 @@ SessionAccessibility::ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAc
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);
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

@@ -27,8 +27,7 @@
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++) { \
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)); \
} \
@@ -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,
nsWindow::NativePtr<SessionAccessibility>* aPtr, nsWindow* aWindow,
java::SessionAccessibility::NativeProvider::Param aSessionAccessibility)
: mWindow(aPtr, aWindow)
, mSessionAccessibility(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,18 +97,21 @@ public:
void SendWindowStateChangedEvent(AccessibleWrap* aAccessible);
// Cache methods
void ReplaceViewportCache(const nsTArray<AccessibleWrap*>& aAccessibles,
void ReplaceViewportCache(
const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
void ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAccessibles,
void ReplaceFocusPathCache(
const nsTArray<AccessibleWrap*>& aAccessibles,
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
void UpdateCachedBounds(const nsTArray<AccessibleWrap*>& aAccessibles,
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);

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),
AccessibleNode::AccessibleNode(nsINode* aNode)
: mDoubleProperties(3),
mIntProperties(3),
mUIntProperties(6),
mBooleanProperties(0),
mRelationProperties(3),
mStringProperties(16),
mDOMNode(aNode)
{
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,
void AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv)
{
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,65 +27,56 @@ 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__)) \
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__)) \
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__)) \
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) \
{ \
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); \
@@ -94,19 +85,17 @@ struct ParentObject;
} \
\
void SetProperty(AOM##typeName##Property aProperty, \
const dom::Nullable<type>& aValue) \
{ \
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()); \
} \
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,14 +164,14 @@ 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 =
(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

File diff suppressed because it is too large Load Diff

View File

@@ -32,8 +32,8 @@ enum AtkProperty {
struct AtkPropertyChange {
int32_t type; // property type as listed above
void *oldvalue;
void *newvalue;
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,14 +74,14 @@ 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();
};

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,
gboolean toplevel_event_watcher(GSignalInvocationHint* ihint,
guint n_param_values,
const GValue* param_values,
gpointer data)
{
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,13 +90,12 @@ 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)
{
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);
@@ -125,11 +106,9 @@ gboolean fireRootAccessibleAddedCB(gpointer data)
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);
@@ -138,12 +117,12 @@ ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx, Accessible* aChild)
// Emit children_changed::add in a timeout
// to make sure aRootAccWrap is fully initialized.
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)
malloc(sizeof(AtkRootAccessibleAddedEvent));
AtkRootAccessibleAddedEvent* eventData =
(AtkRootAccessibleAddedEvent*)malloc(sizeof(AtkRootAccessibleAddedEvent));
if (eventData) {
eventData->app_accessible = mAtkObject;
eventData->root_accessible = atkAccessible;
eventData->index = count -1;
eventData->index = count - 1;
g_object_ref(mAtkObject);
g_object_ref(atkAccessible);
g_timeout_add(0, fireRootAccessibleAddedCB, eventData);
@@ -152,9 +131,7 @@ ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx, Accessible* aChild)
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();

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.
@@ -107,15 +90,11 @@ AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
}
}
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__

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.
@@ -33,10 +31,11 @@ AddBOMs(nsACString& aDest, const nsACString& aSource)
// 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"
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,16 +78,15 @@ 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)),
MOZ_ASSERT(
static_cast<int>(aStr.Length()) >= UTF8traits::bytes(aStr.CharAt(0)),
"The leading character should be complete");
// drop first character
@@ -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

View File

@@ -41,44 +41,45 @@
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);
gchar* Convert(const nsAString& aStr);
/**
/**
* Add a BOM after each non-BMP character.
*/
void AddBOMs(nsACString& aDest, const nsACString& aSource);
void AddBOMs(nsACString& aDest, const nsACString& aSource);
/**
/**
* Replace all characters with asterisks (e.g. for password fields).
*/
void ConvertTexttoAsterisks(nsAString& aString);
void ConvertTexttoAsterisks(nsAString& aString);
/**
/**
* Parameterize conversion.
*/
enum class AtkStringConvertFlags : uint32_t {
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 {
class ATKStringConverterHelper {
public:
ATKStringConverterHelper(void) :
ATKStringConverterHelper(void)
:
#ifdef DEBUG
mAdjusted (false),
mAdjusted(false),
#endif
mStartShifted (false),
mEndShifted (false) { }
mStartShifted(false),
mEndShifted(false) {
}
/**
* In order to properly get non-BMP values, offsets need to be changed
@@ -106,17 +107,15 @@ namespace DOMtoATK
#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)
{
template <class AccessibleOrProxy>
gchar* NewATKString(AccessibleOrProxy* aAccessible, gint aStartOffset,
gint aEndOffset, AtkStringConvertFlags aFlags) {
gint startOffset = aStartOffset, endOffset = aEndOffset;
ATKStringConverterHelper converter;
converter.AdjustOffsets(&startOffset, &endOffset,
@@ -126,15 +125,14 @@ namespace DOMtoATK
if (aFlags & AtkStringConvertFlags::ConvertTextToAsterisks)
ConvertTexttoAsterisks(str);
return converter.ConvertAdjusted(str);
}
}
/**
/**
* 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)
{
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));
@@ -145,7 +143,8 @@ namespace DOMtoATK
if (NS_IS_HIGH_SURROGATE(character)) {
// Heading surrogate, get the trailing surrogate and combine them.
gunichar characterLow = static_cast<gunichar>(aAccessible->CharAt(aOffset + 1));
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.
@@ -155,9 +154,9 @@ namespace DOMtoATK
}
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,9 +16,8 @@
namespace mozilla {
namespace a11y {
class DocAccessibleWrap : public DocAccessible
{
public:
class DocAccessibleWrap : public DocAccessible {
public:
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
virtual ~DocAccessibleWrap();

View File

@@ -20,4 +20,3 @@ typedef class HTMLTableHeaderCellAccessible HTMLTableHeaderCellAccessibleWrap;
} // namespace mozilla
#endif

View File

@@ -18,4 +18,3 @@ typedef class HyperTextAccessible HyperTextAccessibleWrap;
} // namespace mozilla
#endif

View File

@@ -18,4 +18,3 @@ typedef class ImageAccessible ImageAccessibleWrap;
} // namespace mozilla
#endif

View File

@@ -20,25 +20,24 @@ class AccessibleWrap;
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,
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_

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,9 +32,9 @@ 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;
@@ -49,13 +50,12 @@ 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;
struct GnomeAccessibilityModule {
const char* libName;
PRLibrary* lib;
const char* initName;
GnomeAccessibilityInit init;
const char *shutdownName;
const char* shutdownName;
GnomeAccessibilityShutdown shutdown;
};
@@ -66,17 +66,14 @@ static GnomeAccessibilityModule sAtkBridge = {
"libatk-bridge.so", nullptr,
#endif
"gnome_accessibility_module_init", nullptr,
"gnome_accessibility_module_shutdown", nullptr
};
"gnome_accessibility_module_shutdown", nullptr};
static nsresult
LoadGtkModule(GnomeAccessibilityModule& aModule)
{
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();
// 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");
@@ -97,22 +94,18 @@ LoadGtkModule(GnomeAccessibilityModule& aModule)
sub.AppendLiteral("/gtk-3.0/modules/");
sub.Append(aModule.libName);
aModule.lib = PR_LoadLibrary(sub.get());
if (aModule.lib)
break;
if (aModule.lib) break;
loc1 = loc2+1;
loc1 = loc2 + 1;
}
if (!aModule.lib)
return NS_ERROR_FAILURE;
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, :(
// 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;
@@ -120,37 +113,36 @@ LoadGtkModule(GnomeAccessibilityModule& aModule)
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;
}
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,22 +175,16 @@ 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()
{
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),
@@ -223,18 +209,15 @@ a11y::PlatformShutdown()
// }
}
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,14 +303,12 @@ 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 =

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,9 +20,8 @@ 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();
};
@@ -31,4 +30,3 @@ public:
} // namespace mozilla
#endif /* mozilla_a11y_Root_Accessible_Wrap_h__ */

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,17 +41,13 @@ 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)
{
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;
@@ -65,73 +60,60 @@ add_listener (GSignalEmissionHook listener,
rc = sListener_idx;
listener_info = (MaiUtilListenerInfo *)
g_malloc(sizeof(MaiUtilListenerInfo));
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->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);
g_hash_table_insert(sListener_list, &(listener_info->key), listener_info);
sListener_idx++;
}
else {
} else {
g_warning("Invalid signal type %s\n", signal);
}
}
else {
} 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)
{
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])) {
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);
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);
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);
}
return rc;
}
static void
mai_util_remove_global_event_listener(guint 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) {
if (gail_remove_global_event_listener && listener_info->gail_listenerid) {
gail_remove_global_event_listener(listener_info->gail_listenerid);
}
@@ -143,13 +125,11 @@ mai_util_remove_global_event_listener(guint remove_listener)
/* Remove the element from the hash */
g_hash_table_remove(sListener_list, &tmp_idx);
}
else {
} else {
g_warning("Invalid listener hook_id %ld or signal_id %d\n",
listener_info->hook_id, listener_info->signal_id);
}
}
else {
} else {
// atk-bridge is initialized with gail (e.g. yelp)
// try gail_remove_global_event_listener
if (gail_remove_global_event_listener) {
@@ -159,15 +139,12 @@ mai_util_remove_global_event_listener(guint remove_listener)
g_warning("No listener with the specified listener id %d",
remove_listener);
}
}
else {
} else {
g_warning("Invalid listener_id %d", remove_listener);
}
}
static AtkKeyEventStruct *
atk_key_event_from_gdk_event_key (GdkEventKey *key)
{
static AtkKeyEventStruct *atk_key_event_from_gdk_event_key(GdkEventKey *key) {
AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1);
switch (key->type) {
case GDK_KEY_PRESS:
@@ -177,20 +154,18 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key)
event->type = ATK_KEY_EVENT_RELEASE;
break;
default:
g_assert_not_reached ();
g_assert_not_reached();
return nullptr;
}
event->state = key->state;
event->keyval = key->keyval;
event->length = key->length;
if (key->string && key->string [0] &&
if (key->string && key->string[0] &&
(key->state & GDK_CONTROL_MASK ||
g_unichar_isgraph (g_utf8_get_char (key->string)))) {
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);
} 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;
@@ -198,50 +173,44 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key)
return event;
}
struct MaiKeyEventInfo
{
struct MaiKeyEventInfo {
AtkKeyEventStruct *key_event;
gpointer func_data;
};
union AtkKeySnoopFuncPointer
{
union AtkKeySnoopFuncPointer {
AtkKeySnoopFunc func_ptr;
gpointer data;
};
static gboolean
notify_hf(gpointer key, gpointer value, 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;
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)
{
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);
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);
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);
@@ -250,9 +219,8 @@ mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event, gpointer func_data)
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,82 +245,52 @@ mai_util_add_key_event_listener(AtkKeySnoopFunc listener, gpointer data)
return key;
}
static void
mai_util_remove_key_event_listener (guint 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));
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
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 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
UtilInterfaceInit(MaiUtilClass* klass)
{
static void UtilInterfaceInit(MaiUtilClass *klass) {
AtkUtilClass *atk_class;
gpointer data;
@@ -365,8 +303,7 @@ UtilInterfaceInit(MaiUtilClass* klass)
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->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;
@@ -378,15 +315,15 @@ UtilInterfaceInit(MaiUtilClass* klass)
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);
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()
{
GType mai_util_get_type() {
static GType type = 0;
if (!type) {
@@ -394,7 +331,7 @@ mai_util_get_type()
sizeof(MaiUtilClass),
(GBaseInitFunc) nullptr, /* base init */
(GBaseFinalizeFunc) nullptr, /* base finalize */
(GClassInitFunc) UtilInterfaceInit, /* class init */
(GClassInitFunc)UtilInterfaceInit, /* class init */
(GClassFinalizeFunc) nullptr, /* class finalize */
nullptr, /* class data */
sizeof(MaiUtil), /* instance size */
@@ -403,9 +340,8 @@ mai_util_get_type()
nullptr /* value table */
};
type = g_type_register_static(ATK_TYPE_UTIL,
"MaiUtil", &tinfo, GTypeFlags(0));
type =
g_type_register_static(ATK_TYPE_UTIL, "MaiUtil", &tinfo, GTypeFlags(0));
}
return type;
}

View File

@@ -19,4 +19,3 @@ typedef class XULTreeGridCellAccessible XULTreeGridCellAccessibleWrap;
} // 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,25 +12,26 @@ 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
{
struct MaiAtkHyperlink {
AtkHyperlink parent;
/*
@@ -40,8 +41,7 @@ struct MaiAtkHyperlink
MaiHyperlink *maiHyperlink;
};
struct MaiAtkHyperlinkClass
{
struct MaiAtkHyperlinkClass {
AtkHyperlinkClass parent_class;
};
@@ -63,71 +63,57 @@ G_END_DECLS
static gpointer parent_class = nullptr;
static MaiHyperlink*
GetMaiHyperlink(AtkHyperlink *aHyperlink)
{
static MaiHyperlink *GetMaiHyperlink(AtkHyperlink *aHyperlink) {
NS_ENSURE_TRUE(MAI_IS_ATK_HYPERLINK(aHyperlink), nullptr);
MaiHyperlink * maiHyperlink =
MAI_ATK_HYPERLINK(aHyperlink)->maiHyperlink;
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)
{
GType mai_atk_hyperlink_get_type(void) {
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo = {
sizeof(MaiAtkHyperlinkClass),
(GBaseInitFunc)nullptr,
(GBaseFinalizeFunc)nullptr,
(GBaseInitFunc) nullptr,
(GBaseFinalizeFunc) nullptr,
(GClassInitFunc)classInitCB,
(GClassFinalizeFunc)nullptr,
(GClassFinalizeFunc) nullptr,
nullptr, /* class data */
sizeof(MaiAtkHyperlink), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc)nullptr,
(GInstanceInitFunc) nullptr,
nullptr /* value table */
};
type = g_type_register_static(ATK_TYPE_HYPERLINK,
"MaiAtkHyperlink",
&tinfo, GTypeFlags(0));
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));
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;
if (!mMaiAtkHyperlink) return;
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)
{
void classInitCB(AtkHyperlinkClass *aClass) {
GObjectClass *gobject_class = G_OBJECT_CLASS(aClass);
parent_class = g_type_class_peek_parent(aClass);
@@ -142,33 +128,26 @@ classInitCB(AtkHyperlinkClass *aClass)
gobject_class->finalize = finalizeCB;
}
void
finalizeCB(GObject *aObj)
{
void finalizeCB(GObject *aObj) {
NS_ASSERTION(MAI_IS_ATK_HYPERLINK(aObj), "Invalid MaiAtkHyperlink");
if (!MAI_IS_ATK_HYPERLINK(aObj))
return;
if (!MAI_IS_ATK_HYPERLINK(aObj)) return;
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);
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

@@ -20,18 +20,15 @@ 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) {
@@ -44,7 +41,7 @@ public:
ProxyAccessible* Proxy() const { return mHyperlink.AsProxy(); }
protected:
protected:
AccessibleOrProxy mHyperlink;
AtkHyperlink* mMaiAtkHyperlink;
};

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)) {
@@ -112,8 +100,8 @@ refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
aY += winCoords.y;
}
Accessible* accAtPoint = accWrap->ChildAtPoint(aX, aY,
Accessible::eDirectChild);
Accessible* accAtPoint =
accWrap->ChildAtPoint(aX, aY, Accessible::eDirectChild);
if (!accAtPoint) {
return nullptr;
}
@@ -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,8 +138,7 @@ getExtentsHelper(AtkObject* aAtkObj,
}
nsIntRect screenRect = accWrap->Bounds();
if (screenRect.IsEmpty())
return;
if (screenRect.IsEmpty()) return;
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
@@ -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,12 +27,9 @@ static AtkAttributeSet* getDocumentAttributesCB(AtkDocument* aDocument);
static const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
const gchar* aAttrName);
void
documentInterfaceInitCB(AtkDocumentIface *aIface)
{
void documentInterfaceInitCB(AtkDocumentIface* aIface) {
NS_ASSERTION(aIface, "Invalid Interface");
if(MOZ_UNLIKELY(!aIface))
return;
if (MOZ_UNLIKELY(!aIface)) return;
/*
* We don't support get_document or set_attribute right now.
@@ -44,9 +41,7 @@ documentInterfaceInitCB(AtkDocumentIface *aIface)
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,8 +32,7 @@ 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);
}
@@ -45,9 +41,7 @@ getLinkCB(AtkHypertext *aText, gint aLinkIndex)
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()) {
@@ -64,12 +60,9 @@ getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
} // 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,9 +186,7 @@ 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 =
@@ -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,9 +216,7 @@ 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 =
@@ -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,9 +240,7 @@ 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;
@@ -283,8 +253,7 @@ getSelectedColumnsCB(AtkTable *aTable, gint** aSelected)
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,8 +68,7 @@ GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol)
return false;
}
static gboolean
GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
static gboolean GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
gint* aColExtent, gint* aRowExtent) {
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
TableCellAccessible* cellAcc = accWrap->AsTableCell();
@@ -102,9 +95,7 @@ GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
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,
void ConvertTextAttributeToAtkAttribute(const nsACString& aName,
const nsAString& aValue,
AtkAttributeSet** aAttributeSet)
{
AtkAttributeSet** aAttributeSet) {
// Handle attributes where atk has its own name.
const char* atkName = nullptr;
nsAutoString atkValue;
@@ -69,28 +67,24 @@ ConvertTextAttributeToAtkAttribute(const nsACString& aName,
}
}
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());
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,20 +130,18 @@ 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,
@@ -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,11 +178,9 @@ getCharTextAtOffset(AtkText* aText, gint aOffset,
return getTextCB(aText, aOffset, end);
}
static gchar*
getTextAfterOffsetCB(AtkText *aText, gint aOffset,
static gchar* getTextAfterOffsetCB(AtkText* aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
gint* aStartOffset, gint* aEndOffset) {
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
return getCharTextAtOffset(aText, aOffset + 1, aStartOffset, aEndOffset);
}
@@ -203,10 +190,10 @@ getTextAfterOffsetCB(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->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,
static gchar* getTextAtOffsetCB(AtkText* aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
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,
static gchar* getTextBeforeOffsetCB(AtkText* aText, gint aOffset,
AtkTextBoundary aBoundaryType,
gint *aStartOffset, gint *aEndOffset)
{
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;
@@ -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;

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,7 +81,7 @@ 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
@@ -101,9 +90,7 @@ getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
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

@@ -52,9 +52,11 @@ struct AtkStateMap {
EStateMapEntryType stateMapEntryType;
};
// Map array from cross platform states to ATK states
static const AtkStateMap gAtkStateMap[] = { // Cross Platform States
static const AtkStateMap
gAtkStateMap[] =
{
// Cross Platform States
// clang-format off
{ kNone, kMapOpposite }, // states::UNAVAILABLE = 1 << 0
{ ATK_STATE_SELECTED, kMapDirectly }, // states::SELECTED = 1 << 1
@@ -110,5 +112,6 @@ static const AtkStateMap gAtkStateMap[] = { // Cross Platfor
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,8 +35,7 @@ static const uint32_t kGenericAccType = 0;
* via the object attribute "xml-roles".
*/
static const nsRoleMapEntry sWAIRoleMaps[] =
{
static const nsRoleMapEntry sWAIRoleMaps[] = {
// clang-format off
{ // alert
nsGkAtoms::alert,
@@ -1245,26 +1244,12 @@ static const nsRoleMapEntry sWAIRoleMaps[] =
};
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,25 +1257,19 @@ nsRoleMapEntry aria::gEmptyRoleMap = {
* whether there is an ARIA role or not:
*/
static const EStateRule sWAIUnivStateMap[] = {
eARIABusy,
eARIACurrent,
eARIADisabled,
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,
eARIAInvalid, eARIAModal,
eARIARequired, // XXX not global, Bug 553117
eARIANone
};
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;
};
@@ -1340,8 +1319,7 @@ static const AttrCharacteristics gWAIUnivAttrMap[] = {
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,9 +1370,7 @@ 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) {
@@ -1413,20 +1382,15 @@ aria::GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMapEntry)
}
}
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,9 +1398,7 @@ 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,
@@ -1446,9 +1408,7 @@ aria::HasDefinedARIAHidden(nsIContent* aContent)
////////////////////////////////////////////////////////////////////////////////
// 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++;
@@ -1467,8 +1427,8 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
continue; // only expose token based attributes if they are defined
if ((attrFlags & ATTR_BYPASSOBJ_IF_FALSE) &&
mElement->AttrValueIs(kNameSpaceID_None, attrAtom,
nsGkAtoms::_false, eCaseMatters)) {
mElement->AttrValueIs(kNameSpaceID_None, attrAtom, nsGkAtoms::_false,
eCaseMatters)) {
continue; // only expose token based attribute if value is not 'false'.
}
@@ -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;
@@ -192,7 +181,6 @@ struct nsRoleMapEntry
mozilla::a11y::aria::EStateRule attributeMap4;
};
////////////////////////////////////////////////////////////////////////////////
// ARIA map
@@ -282,26 +270,23 @@ 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:
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;

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,8 +32,7 @@ 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
@@ -44,15 +42,14 @@ enum ETokenType
* 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,
{nsGkAtoms::inlinevalue, nsGkAtoms::list_, nsGkAtoms::both, nullptr},
{states::SUPPORTS_AUTOCOMPLETION,
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION,
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION }, 0
};
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::_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,
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,
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,
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::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,
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,
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,10 +311,8 @@ 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)) {

View File

@@ -21,8 +21,7 @@ namespace aria {
/**
* List of the ARIA state mapping rules.
*/
enum EStateRule
{
enum EStateRule {
eARIANone,
eARIAAutoComplete,
eARIABusy,

View File

@@ -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,68 +74,61 @@ 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,
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)
{
: 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,
int32_t aReason)
: AccEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED, aTarget,
eAutoDetect, eCoalesceTextSelChange),
mSel(aSelection), mReason(aReason) {}
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);
@@ -146,13 +138,14 @@ AccTextSelChangeEvent::IsCaretMoveOnly() const
// 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,
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,
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)
{
}
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 {
@@ -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,
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) { }
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,
EIsFromUserInput aIsFromUserInput = eAutoDetect)
: AccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aAccessible,
aIsFromUserInput),
mCaretOffset(aCaretOffset) { }
virtual ~AccCaretMoveEvent() { }
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.
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),
uint32_t aScrollX, uint32_t aScrollY, uint32_t aMaxScrollX,
uint32_t aMaxScrollY)
: AccEvent(aEventType, aAccessible),
mScrollX(aScrollX),
mScrollY(aScrollY),
mMaxScrollX(aMaxScrollX),
mMaxScrollY(aMaxScrollY) { }
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,29 +547,27 @@ 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

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 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;
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());
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
@@ -174,8 +157,7 @@ HTMLLabelIterator::Next()
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,55 +220,42 @@ 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()) {
@@ -312,8 +263,7 @@ IDRefsIterator::GetElem(const nsDependentSubstring& aID)
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);

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;

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), \
#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), \
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

@@ -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);
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);
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());
@@ -584,9 +522,7 @@ DocManager::ClearDocCache()
}
}
void
DocManager::RemoteDocAdded(DocAccessibleParent* aDoc)
{
void DocManager::RemoteDocAdded(DocAccessibleParent* aDoc) {
if (!sRemoteDocuments) {
sRemoteDocuments = new nsTArray<DocAccessibleParent*>;
ClearOnShutdown(&sRemoteDocuments);

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,8 +100,8 @@ 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;
}
@@ -113,9 +110,9 @@ public:
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);
/**
@@ -169,11 +164,12 @@ private:
DocAccessibleHashtable;
DocAccessibleHashtable mDocAccessibleCache;
typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>, xpcAccessibleDocument>
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,9 +182,7 @@ 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;
}

View File

@@ -8,62 +8,46 @@
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)
@@ -72,9 +56,7 @@ EmbeddedObjCollector::GetIndexAt(Accessible* aAccessible)
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.

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,
"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.
@@ -81,27 +76,24 @@ 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() ||
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");
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];
@@ -114,18 +106,17 @@ EventQueue::CoalesceEvents()
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;
}
}
@@ -133,8 +124,7 @@ EventQueue::CoalesceEvents()
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).
@@ -155,8 +145,7 @@ EventQueue::CoalesceEvents()
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,13 +160,11 @@ EventQueue::CoalesceEvents()
thisEvent->mAccessible == tailEvent->mAccessible)
thisEvent->mEventRule = AccEvent::eDoNotEmit;
}
}
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--) {
@@ -197,11 +184,9 @@ EventQueue::CoalesceEvents()
} // switch
}
void
EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
void EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
AccSelChangeEvent* aThisEvent,
uint32_t aThisIndex)
{
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,30 +291,34 @@ 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),
nsEventShell::FireEvent(
selChangeEvent->mPackedEvent->mAccessible, states::SELECTED,
(selChangeEvent->mPackedEvent->mSelChangeType ==
AccSelChangeEvent::eSelectionAdd),
selChangeEvent->mPackedEvent->mIsFromUserInput);
}
}
@@ -341,7 +326,6 @@ EventQueue::ProcessEventQueue()
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.
*/

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),
TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents)
: mParent(aParent),
mStartIdx(UINT32_MAX),
mStateFlagsCopy(mParent->mStateFlags),
mQueueEvents(!aNoEvents)
{
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,16 +88,15 @@ 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),
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) {
@@ -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,7 +483,8 @@ EventTree::Mutated(AccMutationEvent* aEv)
if (childEv->IsShow()) {
AccShowEvent* childShowEv = downcast_accEvent(childEv);
if (childShowEv->mPrecedingEvents.Length() > 0) {
Controller(mContainer)->StorePrecedingEvents(
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",
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() ==
} 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->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,13 +115,13 @@ 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

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.

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;
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) {
@@ -64,41 +55,35 @@ FocusManager::IsFocused(const Accessible* aAccessible) const
DocAccessible* doc =
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);
@@ -134,15 +116,13 @@ FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
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,41 +196,34 @@ FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
}
}
void
FocusManager::ForceFocusEvent()
{
void FocusManager::ForceFocusEvent() {
nsINode* focusedNode = FocusedDOMNode();
if (focusedNode) {
DocAccessible* document =
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);
@@ -263,21 +231,19 @@ FocusManager::ProcessDOMFocus(nsINode* aTarget)
DocAccessible* document =
GetAccService()->GetDocAccessible(aTarget->OwnerDoc());
if (!document)
return;
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;
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;
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;
@@ -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,9 +376,7 @@ FocusManager::FocusedDOMNode() const
return focusedWnd ? focusedWnd->GetExtantDoc() : nullptr;
}
nsIDocument*
FocusManager::FocusedDOMDocument() const
{
nsIDocument* FocusManager::FocusedDOMDocument() const {
nsINode* focusedNode = FocusedDOMNode();
return focusedNode ? focusedNode->OwnerDoc() : nullptr;
}

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,19 +107,19 @@ 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;
};

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,9 +129,7 @@ LogDocShellTree(nsIDocument* aDocumentNode)
}
}
static void
LogDocState(nsIDocument* aDocumentNode)
{
static void LogDocState(nsIDocument* aDocumentNode) {
const char* docState = nullptr;
nsIDocument::ReadyState docStateFlag = aDocumentNode->GetReadyStateEnum();
switch (docStateFlag) {
@@ -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",
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,9 +842,7 @@ 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());
@@ -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

@@ -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();
/**
@@ -227,4 +228,3 @@ void CheckEnv();
} // namespace mozilla
#endif

View File

@@ -5,178 +5,125 @@
* 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,
MARKUPMAP(a,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Only some roles truly enjoy life as HTMLLinkAccessibles, for details
// see closed bug 494807.
// 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 HyperTextAccessibleWrap(aElement,
aContext->Document());
}
return new HTMLLinkAccessible(aElement, aContext->Document());
},
roles::LINK
)
roles::LINK)
MARKUPMAP(abbr,
New_HyperText,
0)
MARKUPMAP(abbr, New_HyperText, 0)
MARKUPMAP(acronym,
New_HyperText,
0)
MARKUPMAP(acronym, New_HyperText, 0)
MARKUPMAP(article,
New_HyperText,
roles::ARTICLE,
Attr(xmlroles, article))
MARKUPMAP(article, New_HyperText, roles::ARTICLE, Attr(xmlroles, article))
MARKUPMAP(aside,
New_HyperText,
roles::LANDMARK)
MARKUPMAP(aside, New_HyperText, roles::LANDMARK)
MARKUPMAP(blockquote,
New_HyperText,
roles::BLOCKQUOTE)
MARKUPMAP(blockquote, New_HyperText, roles::BLOCKQUOTE)
MARKUPMAP(
button,
MARKUPMAP(button,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLButtonAccessible(aElement, aContext->Document());
},
0
)
0)
MARKUPMAP(
caption,
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 new HTMLCaptionAccessible(aElement,
aContext->Document());
}
}
return nullptr;
},
0
)
0)
MARKUPMAP(dd,
New_HTMLDtOrDd<HyperTextAccessibleWrap>,
roles::DEFINITION)
MARKUPMAP(dd, New_HTMLDtOrDd<HyperTextAccessibleWrap>, roles::DEFINITION)
MARKUPMAP(del,
New_HyperText,
roles::CONTENT_DELETION)
MARKUPMAP(del, New_HyperText, roles::CONTENT_DELETION)
MARKUPMAP(details,
New_HyperText,
roles::DETAILS)
MARKUPMAP(details, New_HyperText, roles::DETAILS)
MARKUPMAP(div,
nullptr,
roles::SECTION)
MARKUPMAP(div, nullptr, roles::SECTION)
MARKUPMAP(
dl,
MARKUPMAP(dl,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::DEFINITION_LIST
)
roles::DEFINITION_LIST)
MARKUPMAP(dt,
New_HTMLDtOrDd<HTMLLIAccessible>,
roles::TERM)
MARKUPMAP(dt, New_HTMLDtOrDd<HTMLLIAccessible>, roles::TERM)
MARKUPMAP(
figcaption,
MARKUPMAP(figcaption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
},
roles::CAPTION
)
roles::CAPTION)
MARKUPMAP(
figure,
MARKUPMAP(figure,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigureAccessible(aElement, aContext->Document());
},
roles::FIGURE,
Attr(xmlroles, figure)
)
roles::FIGURE, Attr(xmlroles, figure))
MARKUPMAP(
fieldset,
MARKUPMAP(fieldset,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLGroupboxAccessible(aElement, aContext->Document());
},
0
)
0)
MARKUPMAP(
form,
MARKUPMAP(form,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFormAccessible(aElement, aContext->Document());
},
0
)
0)
MARKUPMAP(
footer,
MARKUPMAP(footer,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
return new HTMLHeaderOrFooterAccessible(aElement,
aContext->Document());
},
0
)
0)
MARKUPMAP(
header,
MARKUPMAP(header,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
return new HTMLHeaderOrFooterAccessible(aElement,
aContext->Document());
},
0
)
0)
MARKUPMAP(h1,
New_HyperText,
roles::HEADING)
MARKUPMAP(h1, New_HyperText, roles::HEADING)
MARKUPMAP(h2,
New_HyperText,
roles::HEADING)
MARKUPMAP(h2, New_HyperText, roles::HEADING)
MARKUPMAP(h3,
New_HyperText,
roles::HEADING)
MARKUPMAP(h3, New_HyperText, roles::HEADING)
MARKUPMAP(h4,
New_HyperText,
roles::HEADING)
MARKUPMAP(h4, New_HyperText, roles::HEADING)
MARKUPMAP(h5,
New_HyperText,
roles::HEADING)
MARKUPMAP(h5, New_HyperText, roles::HEADING)
MARKUPMAP(h6,
New_HyperText,
roles::HEADING)
MARKUPMAP(h6, New_HyperText, roles::HEADING)
MARKUPMAP(
hr,
MARKUPMAP(hr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHRAccessible(aElement, aContext->Document());
},
0
)
0)
MARKUPMAP(
input,
MARKUPMAP(input,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::checkbox, eIgnoreCase)) {
@@ -184,379 +131,272 @@ MARKUPMAP(
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::radio, eIgnoreCase)) {
return new HTMLRadioButtonAccessible(aElement, aContext->Document());
return new HTMLRadioButtonAccessible(aElement,
aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::time, eIgnoreCase)) {
return new EnumRoleAccessible<roles::GROUPING>(aElement, aContext->Document());
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 new EnumRoleAccessible<roles::DATE_EDITOR>(
aElement, aContext->Document());
}
return nullptr;
},
0
)
0)
MARKUPMAP(ins,
New_HyperText,
roles::CONTENT_INSERTION)
MARKUPMAP(ins, New_HyperText, roles::CONTENT_INSERTION)
MARKUPMAP(
label,
MARKUPMAP(label,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLabelAccessible(aElement, aContext->Document());
},
roles::LABEL
)
roles::LABEL)
MARKUPMAP(
legend,
MARKUPMAP(legend,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLegendAccessible(aElement, aContext->Document());
},
roles::LABEL
)
roles::LABEL)
MARKUPMAP(
li,
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()) {
// 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());
}
return nullptr;
},
0
)
0)
MARKUPMAP(main,
New_HyperText,
roles::LANDMARK)
MARKUPMAP(main, New_HyperText, roles::LANDMARK)
MARKUPMAP(map,
nullptr,
roles::TEXT_CONTAINER)
MARKUPMAP(map, nullptr, roles::TEXT_CONTAINER)
MARKUPMAP(math,
New_HyperText,
roles::MATHML_MATH)
MARKUPMAP(math, New_HyperText, roles::MATHML_MATH)
MARKUPMAP(mi_,
New_HyperText,
roles::MATHML_IDENTIFIER)
MARKUPMAP(mi_, New_HyperText, roles::MATHML_IDENTIFIER)
MARKUPMAP(mn_,
New_HyperText,
roles::MATHML_NUMBER)
MARKUPMAP(mn_, New_HyperText, roles::MATHML_NUMBER)
MARKUPMAP(mo_,
New_HyperText,
roles::MATHML_OPERATOR,
AttrFromDOM(accent_, accent_),
AttrFromDOM(fence_, fence_),
AttrFromDOM(separator_, separator_),
AttrFromDOM(largeop_, largeop_))
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(mtext_, New_HyperText, roles::MATHML_TEXT)
MARKUPMAP(ms_,
New_HyperText,
roles::MATHML_STRING_LITERAL)
MARKUPMAP(ms_, New_HyperText, roles::MATHML_STRING_LITERAL)
MARKUPMAP(mglyph_,
New_HyperText,
roles::MATHML_GLYPH)
MARKUPMAP(mglyph_, New_HyperText, roles::MATHML_GLYPH)
MARKUPMAP(mrow_,
New_HyperText,
roles::MATHML_ROW)
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_,
MARKUPMAP(mtable_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE,
AttrFromDOM(align, align),
roles::MATHML_TABLE, AttrFromDOM(align, align),
AttrFromDOM(columnlines_, columnlines_),
AttrFromDOM(rowlines_, rowlines_)
)
AttrFromDOM(rowlines_, rowlines_))
MARKUPMAP(
mlabeledtr_,
MARKUPMAP(mlabeledtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_LABELED_ROW
)
roles::MATHML_LABELED_ROW)
MARKUPMAP(
mtr_,
MARKUPMAP(mtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE_ROW
)
roles::MATHML_TABLE_ROW)
MARKUPMAP(
mtd_,
MARKUPMAP(mtd_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableCellAccessible(aElement, aContext->Document());
},
roles::MATHML_CELL
)
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,
MARKUPMAP(ol,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST
)
roles::LIST)
MARKUPMAP(
option,
MARKUPMAP(option,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptionAccessible(aElement, aContext->Document());
return new HTMLSelectOptionAccessible(aElement,
aContext->Document());
},
0
)
0)
MARKUPMAP(
optgroup,
MARKUPMAP(optgroup,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptGroupAccessible(aElement, aContext->Document());
return new HTMLSelectOptGroupAccessible(aElement,
aContext->Document());
},
0
)
0)
MARKUPMAP(
output,
MARKUPMAP(output,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLOutputAccessible(aElement, aContext->Document());
},
roles::SECTION,
Attr(live, polite)
)
roles::SECTION, Attr(live, polite))
MARKUPMAP(p,
nullptr,
roles::PARAGRAPH)
MARKUPMAP(p, nullptr, roles::PARAGRAPH)
MARKUPMAP(
progress,
MARKUPMAP(progress,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLProgressAccessible(aElement, aContext->Document());
},
0
)
MARKUPMAP(q,
New_HyperText,
0)
MARKUPMAP(
section,
MARKUPMAP(q, New_HyperText, 0)
MARKUPMAP(section,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSectionAccessible(aElement, aContext->Document());
},
0
)
0)
MARKUPMAP(
summary,
MARKUPMAP(summary,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSummaryAccessible(aElement, aContext->Document());
},
roles::SUMMARY
)
roles::SUMMARY)
MARKUPMAP(
table,
MARKUPMAP(table,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableType) {
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableType) {
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
}
return nullptr;
},
0
)
0)
MARKUPMAP(time,
New_HyperText,
0,
Attr(xmlroles, time),
MARKUPMAP(time, New_HyperText, 0, Attr(xmlroles, time),
AttrFromDOM(datetime, datetime))
MARKUPMAP(
td,
MARKUPMAP(td,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() && aContext->GetContent() == aElement->GetParent()) {
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;.
// 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());
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableCellType)) {
return new ARIAGridCellAccessibleWrap(aElement,
aContext->Document());
}
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
return new HTMLTableHeaderCellAccessibleWrap(aElement, aContext->Document());
return new HTMLTableHeaderCellAccessibleWrap(
aElement, aContext->Document());
}
}
return nullptr;
},
0
)
0)
MARKUPMAP(
th,
MARKUPMAP(th,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() && aContext->GetContent() == aElement->GetParent()) {
if (aContext->IsTableRow() &&
aContext->GetContent() == aElement->GetParent()) {
if (!aContext->IsHTMLTableRow()) {
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
return new ARIAGridCellAccessibleWrap(aElement,
aContext->Document());
}
return new HTMLTableHeaderCellAccessibleWrap(aElement, aContext->Document());
return new HTMLTableHeaderCellAccessibleWrap(
aElement, aContext->Document());
}
return nullptr;
},
0
)
0)
MARKUPMAP(
tr,
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
// 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()) {
@@ -571,20 +411,18 @@ MARKUPMAP(
if (table->GetContent() == parentContent &&
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableRowType))) {
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableRowType))) {
return new ARIARowAccessible(aElement, aContext->Document());
}
}
}
return nullptr;
},
0
)
0)
MARKUPMAP(
ul,
MARKUPMAP(ul,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST
)
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 &&
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();
@@ -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(),
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() ||
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,
NS_ASSERTION(
mDocument,
"The document was shut down while refresh observer is attached!");
if (!mDocument)
return;
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'",
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,14 +737,15 @@ 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!");
@@ -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());
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...>)
{
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();
}
@@ -135,9 +129,8 @@ public:
class MoveGuard final {
public:
explicit MoveGuard(NotificationController* aController) :
mController(aController)
{
explicit MoveGuard(NotificationController* aController)
: mController(aController) {
#ifdef DEBUG
MOZ_ASSERT(!mController->mMoveGuardOnStack,
"Move guard is on stack already!");
@@ -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);
@@ -248,21 +240,19 @@ 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);
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);
if (notification && mNotifications.AppendElement(notification)) {
@@ -271,11 +261,12 @@ public:
}
#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,34 +338,32 @@ 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
{
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 };
@@ -388,18 +374,18 @@ private:
/**
* 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
{
class EventMap {
public:
enum EventType
{
enum EventType {
ShowEvent = 0x0,
HideEvent = 0x1,
ReorderEvent = 0x2,

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,8 +124,7 @@ 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

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,40 +58,34 @@ 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;
@@ -105,4 +96,3 @@ private:
} // 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

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,
@@ -1047,7 +1048,7 @@ enum Role {
LAST_ROLE = FORM_LANDMARK
};
} // namespace role
} // namespace roles
typedef enum mozilla::a11y::roles::Role role;

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,34 +104,28 @@ 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,
NS_ASSERTION(
caretCntr,
"No text container for focus while there's one for common ancestor?!");
if (!caretCntr)
return;
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());
@@ -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!");
}
}
@@ -222,7 +197,7 @@ SelectionManager::ProcessSelectionChanged(SelData* aSelData)
} 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);
}
}

View File

@@ -17,7 +17,7 @@ namespace mozilla {
namespace dom {
class Element;
class Selection;
}
} // namespace dom
namespace a11y {
@@ -43,9 +43,8 @@ class HyperTextAccessible;
struct SelData;
class SelectionManager : public nsISelectionListener
{
public:
class SelectionManager : public nsISelectionListener {
public:
// nsISupports
// implemented by derived nsAccessibilityService
@@ -89,10 +88,8 @@ public:
* current pair, then returns -1 for the offset and a nullptr for the
* accessible.
*/
inline HyperTextAccessible* AccessibleWithCaret(int32_t* aCaret)
{
if (aCaret)
*aCaret = mCaretOffset;
inline HyperTextAccessible* AccessibleWithCaret(int32_t* aCaret) {
if (aCaret) *aCaret = mCaretOffset;
return mAccWithCaret;
}
@@ -100,20 +97,17 @@ public:
/**
* Update caret offset when it doesn't go through a caret move event.
*/
inline void UpdateCaretOffset(HyperTextAccessible* aItem, int32_t aOffset)
{
inline void UpdateCaretOffset(HyperTextAccessible* aItem, int32_t aOffset) {
mAccWithCaret = aItem;
mCaretOffset = aOffset;
}
inline void ResetCaretOffset()
{
inline void ResetCaretOffset() {
mCaretOffset = -1;
mAccWithCaret = nullptr;
}
protected:
protected:
SelectionManager();
/**
@@ -121,7 +115,7 @@ protected:
*/
void ProcessSelectionChanged(SelData* aSelData);
private:
private:
// Currently focused control.
int32_t mCaretOffset;
HyperTextAccessible* mAccWithCaret;

View File

@@ -13,284 +13,285 @@ namespace mozilla {
namespace a11y {
namespace states {
/**
/**
* The object is disabled, opposite to enabled and sensitive.
*/
const uint64_t UNAVAILABLE = ((uint64_t) 0x1) << 0;
const uint64_t UNAVAILABLE = ((uint64_t)0x1) << 0;
/**
/**
* The object is selected.
*/
const uint64_t SELECTED = ((uint64_t) 0x1) << 1;
const uint64_t SELECTED = ((uint64_t)0x1) << 1;
/**
/**
* The object has the keyboard focus.
*/
const uint64_t FOCUSED = ((uint64_t) 0x1) << 2;
const uint64_t FOCUSED = ((uint64_t)0x1) << 2;
/**
/**
* The object is pressed.
*/
const uint64_t PRESSED = ((uint64_t) 0x1) << 3;
const uint64_t PRESSED = ((uint64_t)0x1) << 3;
/**
/**
* The checkable object is checked, applied to check box controls,
* @see CHECKABLE and MIXED states.
*/
const uint64_t CHECKED = ((uint64_t) 0x1) << 4;
const uint64_t CHECKED = ((uint64_t)0x1) << 4;
/**
/**
* Indicates that the state of a three-state check box or tool bar button is
* undetermined. The check box is neither checked or unchecked, and is
* in the third or mixed state.
*/
const uint64_t MIXED = ((uint64_t) 0x1) << 5;
const uint64_t MIXED = ((uint64_t)0x1) << 5;
/**
/**
* The object is designated read-only, so it can't be edited.
*/
const uint64_t READONLY = ((uint64_t) 0x1) << 6;
const uint64_t READONLY = ((uint64_t)0x1) << 6;
/**
/**
* The object is hot-tracked by the mouse, which means that its appearance
* has changed to indicate that the mouse pointer is located over it.
*
* This is currently unused.
*/
const uint64_t HOTTRACKED = ((uint64_t) 0x1) << 7;
const uint64_t HOTTRACKED = ((uint64_t)0x1) << 7;
/**
/**
* This object is the default button in a window.
*/
const uint64_t DEFAULT = ((uint64_t) 0x1) << 8;
const uint64_t DEFAULT = ((uint64_t)0x1) << 8;
/**
/**
* The expandable object's children are displayed, the opposite of collapsed,
* applied to trees, list and other controls.
* @see COLLAPSED state
*/
const uint64_t EXPANDED = ((uint64_t) 0x1) << 9;
const uint64_t EXPANDED = ((uint64_t)0x1) << 9;
/**
/**
* The expandable object's children are not displayed, the opposite of
* expanded, applied to tree lists and other controls,
* @see EXPANDED state.
*/
const uint64_t COLLAPSED = ((uint64_t) 0x1) << 10;
const uint64_t COLLAPSED = ((uint64_t)0x1) << 10;
/**
/**
* The control or document can not accept input at this time.
*/
const uint64_t BUSY = ((uint64_t) 0x1) << 11;
const uint64_t BUSY = ((uint64_t)0x1) << 11;
/**
/**
* The object is out of normal flow, may be outside of boundaries of its
* parent.
*/
const uint64_t FLOATING = ((uint64_t) 0x1) << 12;
const uint64_t FLOATING = ((uint64_t)0x1) << 12;
/**
/**
* The object can be checked.
*/
const uint64_t CHECKABLE = ((uint64_t) 0x1) << 13;
const uint64_t CHECKABLE = ((uint64_t)0x1) << 13;
/**
/**
* This object is a graphic which is rapidly changing appearance.
*/
const uint64_t ANIMATED = ((uint64_t) 0x1) << 14;
const uint64_t ANIMATED = ((uint64_t)0x1) << 14;
/**
/**
* The object is programmatically hidden.
* So user action like scrolling or switching tabs won't make this visible.
*/
const uint64_t INVISIBLE = ((uint64_t) 0x1) << 15;
const uint64_t INVISIBLE = ((uint64_t)0x1) << 15;
/**
/**
* The object is scrolled off screen.
* User action such as scrolling or changing tab may make the object
* visible.
*/
const uint64_t OFFSCREEN = ((uint64_t) 0x1) << 16;
const uint64_t OFFSCREEN = ((uint64_t)0x1) << 16;
/**
/**
* The object can be resized.
*/
const uint64_t SIZEABLE = ((uint64_t) 0x1) << 17;
const uint64_t SIZEABLE = ((uint64_t)0x1) << 17;
/**
/**
* The object can be moved to a different position.
*/
const uint64_t MOVEABLE = ((uint64_t) 0x1) << 18;
const uint64_t MOVEABLE = ((uint64_t)0x1) << 18;
/**
/**
* The object describes itself with speech.
* Other speech related assistive technology may want to avoid speaking
* information about this object, because the object is already doing this.
*/
const uint64_t SELFVOICING = ((uint64_t) 0x1) << 19;
const uint64_t SELFVOICING = ((uint64_t)0x1) << 19;
/**
/**
* The object can have the focus and become focused.
*/
const uint64_t FOCUSABLE = ((uint64_t) 0x1) << 20;
const uint64_t FOCUSABLE = ((uint64_t)0x1) << 20;
/**
/**
* The object can be selected.
*/
const uint64_t SELECTABLE = ((uint64_t) 0x1) << 21;
const uint64_t SELECTABLE = ((uint64_t)0x1) << 21;
/**
/**
* This object is a link.
*/
const uint64_t LINKED = ((uint64_t) 0x1) << 22;
const uint64_t LINKED = ((uint64_t)0x1) << 22;
/**
/**
* This is used for links that have been traversed
* i.e. the linked page has been visited.
*/
const uint64_t TRAVERSED = ((uint64_t) 0x1) << 23;
const uint64_t TRAVERSED = ((uint64_t)0x1) << 23;
/**
/**
* Supports multiple selection.
*/
const uint64_t MULTISELECTABLE = ((uint64_t) 0x1) << 24;
const uint64_t MULTISELECTABLE = ((uint64_t)0x1) << 24;
/**
/**
* Supports extended selection.
* All objects supporting this are also multipselectable.
* This only makes sense for msaa see bug 635690.
*/
const uint64_t EXTSELECTABLE = ((uint64_t) 0x1) << 25;
const uint64_t EXTSELECTABLE = ((uint64_t)0x1) << 25;
/**
/**
* The user is required to interact with this object.
*/
const uint64_t REQUIRED = ((uint64_t) 0x1) << 26;
const uint64_t REQUIRED = ((uint64_t)0x1) << 26;
/**
/**
* The object is an alert, notifying the user of something important.
*/
const uint64_t ALERT = ((uint64_t) 0x1) << 27;
const uint64_t ALERT = ((uint64_t)0x1) << 27;
/**
/**
* Used for text fields containing invalid values.
*/
const uint64_t INVALID = ((uint64_t) 0x1) << 28;
const uint64_t INVALID = ((uint64_t)0x1) << 28;
/**
/**
* The controls value can not be obtained, and is returned as a set of "*"s.
*/
const uint64_t PROTECTED = ((uint64_t) 0x1) << 29;
const uint64_t PROTECTED = ((uint64_t)0x1) << 29;
/**
/**
* The object can be invoked to show a pop up menu or window.
*/
const uint64_t HASPOPUP = ((uint64_t) 0x1) << 30;
const uint64_t HASPOPUP = ((uint64_t)0x1) << 30;
/**
/**
* The editable area has some kind of autocompletion.
*/
const uint64_t SUPPORTS_AUTOCOMPLETION = ((uint64_t) 0x1) << 31;
const uint64_t SUPPORTS_AUTOCOMPLETION = ((uint64_t)0x1) << 31;
/**
/**
* The object is no longer available to be queried.
*/
const uint64_t DEFUNCT = ((uint64_t) 0x1) << 32;
const uint64_t DEFUNCT = ((uint64_t)0x1) << 32;
/**
/**
* The text is selectable, the object must implement the text interface.
*/
const uint64_t SELECTABLE_TEXT = ((uint64_t) 0x1) << 33;
const uint64_t SELECTABLE_TEXT = ((uint64_t)0x1) << 33;
/**
/**
* The text in this object can be edited.
*/
const uint64_t EDITABLE = ((uint64_t) 0x1) << 34;
const uint64_t EDITABLE = ((uint64_t)0x1) << 34;
/**
/**
* This window is currently the active window.
*/
const uint64_t ACTIVE = ((uint64_t) 0x1) << 35;
const uint64_t ACTIVE = ((uint64_t)0x1) << 35;
/**
/**
* Indicates that the object is modal. Modal objects have the behavior
* that something must be done with the object before the user can
* interact with an object in a different window.
*/
const uint64_t MODAL = ((uint64_t) 0x1) << 36;
const uint64_t MODAL = ((uint64_t)0x1) << 36;
/**
/**
* Edit control that can take multiple lines.
*/
const uint64_t MULTI_LINE = ((uint64_t) 0x1) << 37;
const uint64_t MULTI_LINE = ((uint64_t)0x1) << 37;
/**
/**
* Uses horizontal layout.
*/
const uint64_t HORIZONTAL = ((uint64_t) 0x1) << 38;
const uint64_t HORIZONTAL = ((uint64_t)0x1) << 38;
/**
/**
* Indicates this object paints every pixel within its rectangular region.
*/
const uint64_t OPAQUE1 = ((uint64_t) 0x1) << 39;
const uint64_t OPAQUE1 = ((uint64_t)0x1) << 39;
/**
/**
* This text object can only contain 1 line of text.
*/
const uint64_t SINGLE_LINE = ((uint64_t) 0x1) << 40;
const uint64_t SINGLE_LINE = ((uint64_t)0x1) << 40;
/**
/**
* The parent object manages descendants, and this object may only exist
* while it is visible or has focus.
* For example the focused cell of a table or the current element of a list box may have this state.
* For example the focused cell of a table or the current element of a list box
* may have this state.
*/
const uint64_t TRANSIENT = ((uint64_t) 0x1) << 41;
const uint64_t TRANSIENT = ((uint64_t)0x1) << 41;
/**
/**
* Uses vertical layout.
* Especially used for sliders and scrollbars.
*/
const uint64_t VERTICAL = ((uint64_t) 0x1) << 42;
const uint64_t VERTICAL = ((uint64_t)0x1) << 42;
/**
/**
* Object not dead, but not up-to-date either.
*/
const uint64_t STALE = ((uint64_t) 0x1) << 43;
const uint64_t STALE = ((uint64_t)0x1) << 43;
/**
/**
* A widget that is not unavailable.
*/
const uint64_t ENABLED = ((uint64_t) 0x1) << 44;
const uint64_t ENABLED = ((uint64_t)0x1) << 44;
/**
/**
* Same as ENABLED state for now see bug 636158
*/
const uint64_t SENSITIVE = ((uint64_t) 0x1) << 45;
const uint64_t SENSITIVE = ((uint64_t)0x1) << 45;
/**
/**
* The object is expandable, provides a UI to expand/collapse its children
* @see EXPANDED and COLLAPSED states.
*/
const uint64_t EXPANDABLE = ((uint64_t) 0x1) << 46;
const uint64_t EXPANDABLE = ((uint64_t)0x1) << 46;
/**
* The object is pinned, usually indicating it is fixed in place and has permanence.
/**
* The object is pinned, usually indicating it is fixed in place and has
* permanence.
*/
const uint64_t PINNED = ((uint64_t) 0x1) << 47;
const uint64_t PINNED = ((uint64_t)0x1) << 47;
/**
/**
* The object is the current item within a container or set of related elements.
*/
const uint64_t CURRENT = ((uint64_t) 0x1) << 48;
const uint64_t CURRENT = ((uint64_t)0x1) << 48;
/**
/**
* Not a real state, used for static assertions.
*/
const uint64_t LAST_ENTRY = CURRENT;
const uint64_t LAST_ENTRY = CURRENT;
} // namespace states
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -13,27 +13,30 @@ namespace mozilla {
namespace a11y {
namespace statistics {
inline void A11yInitialized()
{ Telemetry::Accumulate(Telemetry::A11Y_INSTANTIATED_FLAG, true); }
inline void A11yInitialized() {
Telemetry::Accumulate(Telemetry::A11Y_INSTANTIATED_FLAG, true);
}
inline void A11yConsumers(uint32_t aConsumer)
{ Telemetry::Accumulate(Telemetry::A11Y_CONSUMERS, aConsumer); }
inline void A11yConsumers(uint32_t aConsumer) {
Telemetry::Accumulate(Telemetry::A11Y_CONSUMERS, aConsumer);
}
/**
/**
* Report that ISimpleDOM* has been used.
*/
inline void ISimpleDOMUsed()
{ Telemetry::Accumulate(Telemetry::A11Y_ISIMPLEDOM_USAGE_FLAG, true); }
inline void ISimpleDOMUsed() {
Telemetry::Accumulate(Telemetry::A11Y_ISIMPLEDOM_USAGE_FLAG, true);
}
/**
/**
* Report that IAccessibleTable has been used.
*/
inline void IAccessibleTableUsed()
{ Telemetry::Accumulate(Telemetry::A11Y_IATABLE_USAGE_FLAG, true); }
inline void IAccessibleTableUsed() {
Telemetry::Accumulate(Telemetry::A11Y_IATABLE_USAGE_FLAG, true);
}
} // namespace statistics
} // namespace a11y
} // namespace mozilla
#endif

View File

@@ -14,38 +14,31 @@
using namespace mozilla;
using namespace mozilla::a11y;
StyleInfo::StyleInfo(dom::Element* aElement) :
mElement(aElement)
{
StyleInfo::StyleInfo(dom::Element* aElement) : mElement(aElement) {
mComputedStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement, nullptr);
}
void
StyleInfo::Display(nsAString& aValue)
{
void StyleInfo::Display(nsAString& aValue) {
aValue.Truncate();
AppendASCIItoUTF16(
nsCSSProps::ValueToKeyword(mComputedStyle->StyleDisplay()->mDisplay,
nsCSSProps::kDisplayKTable), aValue);
nsCSSProps::kDisplayKTable),
aValue);
}
void
StyleInfo::TextAlign(nsAString& aValue)
{
void StyleInfo::TextAlign(nsAString& aValue) {
aValue.Truncate();
AppendASCIItoUTF16(
nsCSSProps::ValueToKeyword(mComputedStyle->StyleText()->mTextAlign,
nsCSSProps::kTextAlignKTable), aValue);
nsCSSProps::kTextAlignKTable),
aValue);
}
void
StyleInfo::TextIndent(nsAString& aValue)
{
void StyleInfo::TextIndent(nsAString& aValue) {
aValue.Truncate();
const nsStyleCoord& styleCoord =
mComputedStyle->StyleText()->mTextIndent;
const nsStyleCoord& styleCoord = mComputedStyle->StyleText()->mTextIndent;
nscoord coordVal = 0;
switch (styleCoord.GetUnit()) {
@@ -75,10 +68,9 @@ StyleInfo::TextIndent(nsAString& aValue)
}
}
void
StyleInfo::Margin(Side aSide, nsAString& aValue)
{
MOZ_ASSERT(mElement->GetPrimaryFrame(), " mElement->GetPrimaryFrame() needs to be valid pointer");
void StyleInfo::Margin(Side aSide, nsAString& aValue) {
MOZ_ASSERT(mElement->GetPrimaryFrame(),
" mElement->GetPrimaryFrame() needs to be valid pointer");
aValue.Truncate();
nscoord coordVal = mElement->GetPrimaryFrame()->GetUsedMargin().Side(aSide);
@@ -86,9 +78,7 @@ StyleInfo::Margin(Side aSide, nsAString& aValue)
aValue.AppendLiteral("px");
}
void
StyleInfo::FormatColor(const nscolor& aValue, nsString& aFormattedValue)
{
void StyleInfo::FormatColor(const nscolor& aValue, nsString& aFormattedValue) {
// Combine the string like rgb(R, G, B) from nscolor.
aFormattedValue.AppendLiteral("rgb(");
aFormattedValue.AppendInt(NS_GET_R(aValue));
@@ -99,11 +89,9 @@ StyleInfo::FormatColor(const nscolor& aValue, nsString& aFormattedValue)
aFormattedValue.Append(')');
}
void
StyleInfo::FormatTextDecorationStyle(uint8_t aValue, nsAString& aFormattedValue)
{
nsCSSKeyword keyword =
nsCSSProps::ValueToKeywordEnum(aValue,
nsCSSProps::kTextDecorationStyleKTable);
void StyleInfo::FormatTextDecorationStyle(uint8_t aValue,
nsAString& aFormattedValue) {
nsCSSKeyword keyword = nsCSSProps::ValueToKeywordEnum(
aValue, nsCSSProps::kTextDecorationStyleKTable);
AppendUTF8toUTF16(nsCSSKeywords::GetStringValue(keyword), aFormattedValue);
}

View File

@@ -16,11 +16,10 @@ class Element;
} // namespace dom
namespace a11y {
class StyleInfo
{
public:
class StyleInfo {
public:
explicit StyleInfo(dom::Element* aElement);
~StyleInfo() { }
~StyleInfo() {}
void Display(nsAString& aValue);
void TextAlign(nsAString& aValue);
@@ -31,12 +30,13 @@ public:
void MarginBottom(nsAString& aValue) { Margin(eSideBottom, aValue); }
static void FormatColor(const nscolor& aValue, nsString& aFormattedValue);
static void FormatTextDecorationStyle(uint8_t aValue, nsAString& aFormattedValue);
static void FormatTextDecorationStyle(uint8_t aValue,
nsAString& aFormattedValue);
private:
private:
StyleInfo() = delete;
StyleInfo(const StyleInfo&) = delete;
StyleInfo& operator = (const StyleInfo&) = delete;
StyleInfo& operator=(const StyleInfo&) = delete;
void Margin(Side aSide, nsAString& aValue);

View File

@@ -26,31 +26,26 @@ using namespace mozilla::a11y;
// TextAttrsMgr
////////////////////////////////////////////////////////////////////////////////
void
TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
uint32_t* aStartOffset,
uint32_t* aEndOffset)
{
void TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
uint32_t* aStartOffset, uint32_t* aEndOffset) {
// 1. Hyper text accessible must be specified always.
// 2. Offset accessible and result hyper text offsets must be specified in
// the case of text attributes.
// 3. Offset accessible and result hyper text offsets must not be specified
// but include default text attributes flag and attributes list must be
// specified in the case of default text attributes.
MOZ_ASSERT(mHyperTextAcc &&
((mOffsetAcc && mOffsetAccIdx != -1 &&
aStartOffset && aEndOffset) ||
(!mOffsetAcc && mOffsetAccIdx == -1 &&
!aStartOffset && !aEndOffset &&
mIncludeDefAttrs && aAttributes)),
MOZ_ASSERT(
mHyperTextAcc &&
((mOffsetAcc && mOffsetAccIdx != -1 && aStartOffset && aEndOffset) ||
(!mOffsetAcc && mOffsetAccIdx == -1 && !aStartOffset &&
!aEndOffset && mIncludeDefAttrs && aAttributes)),
"Wrong usage of TextAttrsMgr!");
// Embedded objects are combined into own range with empty attributes set.
if (mOffsetAcc && !mOffsetAcc->IsText()) {
for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
if (currAcc->IsText())
break;
if (currAcc->IsText()) break;
(*aStartOffset)--;
}
@@ -59,8 +54,7 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childCount;
childIdx++) {
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
if (currAcc->IsText())
break;
if (currAcc->IsText()) break;
(*aEndOffset)++;
}
@@ -76,17 +70,15 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
nsIFrame* rootFrame = mHyperTextAcc->GetFrame();
MOZ_ASSERT(rootFrame, "No frame for accessible!");
if (!rootFrame)
return;
if (!rootFrame) return;
nsIContent *offsetNode = nullptr, *offsetElm = nullptr;
nsIFrame *frame = nullptr;
nsIFrame* frame = nullptr;
if (mOffsetAcc) {
offsetNode = mOffsetAcc->GetContent();
offsetElm = nsCoreUtils::GetDOMElementFor(offsetNode);
MOZ_ASSERT(offsetElm, "No element for offset accessible!");
if (!offsetElm)
return;
if (!offsetElm) return;
frame = offsetElm->GetPrimaryFrame();
}
@@ -124,20 +116,11 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
// "text-position" text attribute
TextPosTextAttr textPosTextAttr(rootFrame, frame);
TextAttr* attrArray[] =
{
&langTextAttr,
&invalidTextAttr,
&bgColorTextAttr,
&colorTextAttr,
&fontFamilyTextAttr,
&fontSizeTextAttr,
&fontStyleTextAttr,
&fontWeightTextAttr,
&autoGenTextAttr,
&textDecorTextAttr,
&textPosTextAttr
};
TextAttr* attrArray[] = {
&langTextAttr, &invalidTextAttr, &bgColorTextAttr,
&colorTextAttr, &fontFamilyTextAttr, &fontSizeTextAttr,
&fontStyleTextAttr, &fontWeightTextAttr, &autoGenTextAttr,
&textDecorTextAttr, &textPosTextAttr};
// Expose text attributes if applicable.
if (aAttributes) {
@@ -150,18 +133,15 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
GetRange(attrArray, ArrayLength(attrArray), aStartOffset, aEndOffset);
}
void
TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
uint32_t* aStartOffset, uint32_t* aEndOffset)
{
void TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
uint32_t* aStartOffset, uint32_t* aEndOffset) {
// Navigate backward from anchor accessible to find start offset.
for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
// Stop on embedded accessible since embedded accessibles are combined into
// own range.
if (!currAcc->IsText())
break;
if (!currAcc->IsText()) break;
MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()),
"Text accessible has to have an associated DOM element");
@@ -175,8 +155,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
}
}
if (offsetFound)
break;
if (offsetFound) break;
*(aStartOffset) -= nsAccUtils::TextLength(currAcc);
}
@@ -185,8 +164,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
uint32_t childLen = mHyperTextAcc->ChildCount();
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
if (!currAcc->IsText())
break;
if (!currAcc->IsText()) break;
MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()),
"Text accessible has to have an associated DOM element");
@@ -203,23 +181,19 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
}
}
if (offsetFound)
break;
if (offsetFound) break;
(*aEndOffset) += nsAccUtils::TextLength(currAcc);
}
}
////////////////////////////////////////////////////////////////////////////////
// LangTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::LangTextAttr::
LangTextAttr(HyperTextAccessible* aRoot,
nsIContent* aRootElm, nsIContent* aElm) :
TTextAttr<nsString>(!aElm), mRootContent(aRootElm)
{
TextAttrsMgr::LangTextAttr::LangTextAttr(HyperTextAccessible* aRoot,
nsIContent* aRootElm, nsIContent* aElm)
: TTextAttr<nsString>(!aElm), mRootContent(aRootElm) {
aRoot->Language(mRootNativeValue);
mIsRootDefined = !mRootNativeValue.IsEmpty();
@@ -229,21 +203,16 @@ TextAttrsMgr::LangTextAttr::
}
}
TextAttrsMgr::LangTextAttr::
~LangTextAttr() {}
TextAttrsMgr::LangTextAttr::~LangTextAttr() {}
bool
TextAttrsMgr::LangTextAttr::
GetValueFor(Accessible* aAccessible, nsString* aValue)
{
bool TextAttrsMgr::LangTextAttr::GetValueFor(Accessible* aAccessible,
nsString* aValue) {
nsCoreUtils::GetLanguageFor(aAccessible->GetContent(), mRootContent, *aValue);
return !aValue->IsEmpty();
}
void
TextAttrsMgr::LangTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const nsString& aValue)
{
void TextAttrsMgr::LangTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nsString& aValue) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::language, aValue);
}
@@ -251,27 +220,21 @@ TextAttrsMgr::LangTextAttr::
// InvalidTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::InvalidTextAttr::
InvalidTextAttr(nsIContent* aRootElm, nsIContent* aElm) :
TTextAttr<uint32_t>(!aElm), mRootElm(aRootElm)
{
TextAttrsMgr::InvalidTextAttr::InvalidTextAttr(nsIContent* aRootElm,
nsIContent* aElm)
: TTextAttr<uint32_t>(!aElm), mRootElm(aRootElm) {
mIsRootDefined = GetValue(mRootElm, &mRootNativeValue);
if (aElm)
mIsDefined = GetValue(aElm, &mNativeValue);
if (aElm) mIsDefined = GetValue(aElm, &mNativeValue);
}
bool
TextAttrsMgr::InvalidTextAttr::
GetValueFor(Accessible* aAccessible, uint32_t* aValue)
{
bool TextAttrsMgr::InvalidTextAttr::GetValueFor(Accessible* aAccessible,
uint32_t* aValue) {
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
return elm ? GetValue(elm, aValue) : false;
}
void
TextAttrsMgr::InvalidTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const uint32_t& aValue)
{
void TextAttrsMgr::InvalidTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const uint32_t& aValue) {
switch (aValue) {
case eFalse:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
@@ -295,20 +258,16 @@ TextAttrsMgr::InvalidTextAttr::
}
}
bool
TextAttrsMgr::InvalidTextAttr::
GetValue(nsIContent* aElm, uint32_t* aValue)
{
bool TextAttrsMgr::InvalidTextAttr::GetValue(nsIContent* aElm,
uint32_t* aValue) {
nsIContent* elm = aElm;
do {
if (nsAccUtils::HasDefinedARIAToken(elm, nsGkAtoms::aria_invalid)) {
static Element::AttrValuesArray tokens[] =
{ nsGkAtoms::_false, nsGkAtoms::grammar, nsGkAtoms::spelling,
nullptr };
static Element::AttrValuesArray tokens[] = {
nsGkAtoms::_false, nsGkAtoms::grammar, nsGkAtoms::spelling, nullptr};
int32_t idx = elm->AsElement()->FindAttrValueIn(kNameSpaceID_None,
nsGkAtoms::aria_invalid,
tokens, eCaseMatters);
int32_t idx = elm->AsElement()->FindAttrValueIn(
kNameSpaceID_None, nsGkAtoms::aria_invalid, tokens, eCaseMatters);
switch (idx) {
case 0:
*aValue = eFalse;
@@ -329,24 +288,19 @@ TextAttrsMgr::InvalidTextAttr::
return false;
}
////////////////////////////////////////////////////////////////////////////////
// BGColorTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::BGColorTextAttr::
BGColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
TTextAttr<nscolor>(!aFrame), mRootFrame(aRootFrame)
{
TextAttrsMgr::BGColorTextAttr::BGColorTextAttr(nsIFrame* aRootFrame,
nsIFrame* aFrame)
: TTextAttr<nscolor>(!aFrame), mRootFrame(aRootFrame) {
mIsRootDefined = GetColor(mRootFrame, &mRootNativeValue);
if (aFrame)
mIsDefined = GetColor(aFrame, &mNativeValue);
if (aFrame) mIsDefined = GetColor(aFrame, &mNativeValue);
}
bool
TextAttrsMgr::BGColorTextAttr::
GetValueFor(Accessible* aAccessible, nscolor* aValue)
{
bool TextAttrsMgr::BGColorTextAttr::GetValueFor(Accessible* aAccessible,
nscolor* aValue) {
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
if (elm) {
nsIFrame* frame = elm->GetPrimaryFrame();
@@ -357,27 +311,23 @@ TextAttrsMgr::BGColorTextAttr::
return false;
}
void
TextAttrsMgr::BGColorTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const nscolor& aValue)
{
void TextAttrsMgr::BGColorTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nscolor& aValue) {
nsAutoString formattedValue;
StyleInfo::FormatColor(aValue, formattedValue);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::backgroundColor,
formattedValue);
}
bool
TextAttrsMgr::BGColorTextAttr::
GetColor(nsIFrame* aFrame, nscolor* aColor)
{
bool TextAttrsMgr::BGColorTextAttr::GetColor(nsIFrame* aFrame,
nscolor* aColor) {
nscolor backgroundColor = aFrame->StyleBackground()->BackgroundColor(aFrame);
if (NS_GET_A(backgroundColor) > 0) {
*aColor = backgroundColor;
return true;
}
nsContainerFrame *parentFrame = aFrame->GetParent();
nsContainerFrame* parentFrame = aFrame->GetParent();
if (!parentFrame) {
*aColor = aFrame->PresContext()->DefaultBackgroundColor();
return true;
@@ -386,21 +336,18 @@ TextAttrsMgr::BGColorTextAttr::
// Each frame of parents chain for the initially passed 'aFrame' has
// transparent background color. So background color isn't changed from
// 'mRootFrame' to initially passed 'aFrame'.
if (parentFrame == mRootFrame)
return false;
if (parentFrame == mRootFrame) return false;
return GetColor(parentFrame, aColor);
}
////////////////////////////////////////////////////////////////////////////////
// ColorTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::ColorTextAttr::
ColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
TTextAttr<nscolor>(!aFrame)
{
TextAttrsMgr::ColorTextAttr::ColorTextAttr(nsIFrame* aRootFrame,
nsIFrame* aFrame)
: TTextAttr<nscolor>(!aFrame) {
mRootNativeValue = aRootFrame->StyleColor()->mColor;
mIsRootDefined = true;
@@ -410,10 +357,8 @@ TextAttrsMgr::ColorTextAttr::
}
}
bool
TextAttrsMgr::ColorTextAttr::
GetValueFor(Accessible* aAccessible, nscolor* aValue)
{
bool TextAttrsMgr::ColorTextAttr::GetValueFor(Accessible* aAccessible,
nscolor* aValue) {
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
if (elm) {
nsIFrame* frame = elm->GetPrimaryFrame();
@@ -425,34 +370,27 @@ TextAttrsMgr::ColorTextAttr::
return false;
}
void
TextAttrsMgr::ColorTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const nscolor& aValue)
{
void TextAttrsMgr::ColorTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nscolor& aValue) {
nsAutoString formattedValue;
StyleInfo::FormatColor(aValue, formattedValue);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::color, formattedValue);
}
////////////////////////////////////////////////////////////////////////////////
// FontFamilyTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::FontFamilyTextAttr::
FontFamilyTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
TTextAttr<nsString>(!aFrame)
{
TextAttrsMgr::FontFamilyTextAttr::FontFamilyTextAttr(nsIFrame* aRootFrame,
nsIFrame* aFrame)
: TTextAttr<nsString>(!aFrame) {
mIsRootDefined = GetFontFamily(aRootFrame, mRootNativeValue);
if (aFrame)
mIsDefined = GetFontFamily(aFrame, mNativeValue);
if (aFrame) mIsDefined = GetFontFamily(aFrame, mNativeValue);
}
bool
TextAttrsMgr::FontFamilyTextAttr::
GetValueFor(Accessible* aAccessible, nsString* aValue)
{
bool TextAttrsMgr::FontFamilyTextAttr::GetValueFor(Accessible* aAccessible,
nsString* aValue) {
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
if (elm) {
nsIFrame* frame = elm->GetPrimaryFrame();
@@ -463,17 +401,13 @@ TextAttrsMgr::FontFamilyTextAttr::
return false;
}
void
TextAttrsMgr::FontFamilyTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const nsString& aValue)
{
void TextAttrsMgr::FontFamilyTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nsString& aValue) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_family, aValue);
}
bool
TextAttrsMgr::FontFamilyTextAttr::
GetFontFamily(nsIFrame* aFrame, nsString& aFamily)
{
bool TextAttrsMgr::FontFamilyTextAttr::GetFontFamily(nsIFrame* aFrame,
nsString& aFamily) {
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
@@ -484,15 +418,13 @@ TextAttrsMgr::FontFamilyTextAttr::
return true;
}
////////////////////////////////////////////////////////////////////////////////
// FontSizeTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::FontSizeTextAttr::
FontSizeTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
TTextAttr<nscoord>(!aFrame)
{
TextAttrsMgr::FontSizeTextAttr::FontSizeTextAttr(nsIFrame* aRootFrame,
nsIFrame* aFrame)
: TTextAttr<nscoord>(!aFrame) {
mDC = aRootFrame->PresContext()->DeviceContext();
mRootNativeValue = aRootFrame->StyleFont()->mSize;
@@ -504,10 +436,8 @@ TextAttrsMgr::FontSizeTextAttr::
}
}
bool
TextAttrsMgr::FontSizeTextAttr::
GetValueFor(Accessible* aAccessible, nscoord* aValue)
{
bool TextAttrsMgr::FontSizeTextAttr::GetValueFor(Accessible* aAccessible,
nscoord* aValue) {
nsIContent* el = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
if (el) {
nsIFrame* frame = el->GetPrimaryFrame();
@@ -519,10 +449,8 @@ TextAttrsMgr::FontSizeTextAttr::
return false;
}
void
TextAttrsMgr::FontSizeTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const nscoord& aValue)
{
void TextAttrsMgr::FontSizeTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nscoord& aValue) {
// Convert from nscoord to pt.
//
// Note: according to IA2, "The conversion doesn't have to be exact.
@@ -531,10 +459,9 @@ TextAttrsMgr::FontSizeTextAttr::
// ATK does not specify a unit and will likely follow IA2 here.
//
// XXX todo: consider sharing this code with layout module? (bug 474621)
float px =
NSAppUnitsToFloatPixels(aValue, mozilla::AppUnitsPerCSSPixel());
float px = NSAppUnitsToFloatPixels(aValue, mozilla::AppUnitsPerCSSPixel());
// Each pt is 4/3 of a CSS pixel.
int pts = NS_lround(px*3/4);
int pts = NS_lround(px * 3 / 4);
nsAutoString value;
value.AppendInt(pts);
@@ -543,15 +470,13 @@ TextAttrsMgr::FontSizeTextAttr::
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_size, value);
}
////////////////////////////////////////////////////////////////////////////////
// FontStyleTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::FontStyleTextAttr::
FontStyleTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
TTextAttr<FontSlantStyle>(!aFrame)
{
TextAttrsMgr::FontStyleTextAttr::FontStyleTextAttr(nsIFrame* aRootFrame,
nsIFrame* aFrame)
: TTextAttr<FontSlantStyle>(!aFrame) {
mRootNativeValue = aRootFrame->StyleFont()->mFont.style;
mIsRootDefined = true;
@@ -561,10 +486,8 @@ TextAttrsMgr::FontStyleTextAttr::
}
}
bool
TextAttrsMgr::FontStyleTextAttr::
GetValueFor(Accessible* aAccessible, FontSlantStyle* aValue)
{
bool TextAttrsMgr::FontStyleTextAttr::GetValueFor(Accessible* aAccessible,
FontSlantStyle* aValue) {
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
if (elm) {
nsIFrame* frame = elm->GetPrimaryFrame();
@@ -576,25 +499,20 @@ TextAttrsMgr::FontStyleTextAttr::
return false;
}
void
TextAttrsMgr::FontStyleTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes,
const FontSlantStyle& aValue)
{
void TextAttrsMgr::FontStyleTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const FontSlantStyle& aValue) {
nsAutoString string;
nsStyleUtil::AppendFontSlantStyle(aValue, string);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_style, string);
}
////////////////////////////////////////////////////////////////////////////////
// FontWeightTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::FontWeightTextAttr::
FontWeightTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
TTextAttr<FontWeight>(!aFrame)
{
TextAttrsMgr::FontWeightTextAttr::FontWeightTextAttr(nsIFrame* aRootFrame,
nsIFrame* aFrame)
: TTextAttr<FontWeight>(!aFrame) {
mRootNativeValue = GetFontWeight(aRootFrame);
mIsRootDefined = true;
@@ -604,10 +522,8 @@ TextAttrsMgr::FontWeightTextAttr::
}
}
bool
TextAttrsMgr::FontWeightTextAttr::
GetValueFor(Accessible* aAccessible, FontWeight* aValue)
{
bool TextAttrsMgr::FontWeightTextAttr::GetValueFor(Accessible* aAccessible,
FontWeight* aValue) {
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
if (elm) {
nsIFrame* frame = elm->GetPrimaryFrame();
@@ -619,28 +535,22 @@ TextAttrsMgr::FontWeightTextAttr::
return false;
}
void
TextAttrsMgr::FontWeightTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes,
const FontWeight& aValue)
{
void TextAttrsMgr::FontWeightTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const FontWeight& aValue) {
nsAutoString formattedValue;
formattedValue.AppendFloat(aValue.ToFloat());
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::fontWeight, formattedValue);
}
FontWeight
TextAttrsMgr::FontWeightTextAttr::
GetFontWeight(nsIFrame* aFrame)
{
FontWeight TextAttrsMgr::FontWeightTextAttr::GetFontWeight(nsIFrame* aFrame) {
// nsFont::width isn't suitable here because it's necessary to expose real
// value of font weight (used font might not have some font weight values).
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
gfxFontGroup *fontGroup = fm->GetThebesFontGroup();
gfxFont *font = fontGroup->GetFirstValidFont();
gfxFontGroup* fontGroup = fm->GetThebesFontGroup();
gfxFont* font = fontGroup->GetFirstValidFont();
// When there doesn't exist a bold font in the family and so the rendering of
// a non-bold font face is changed so that the user sees what looks like a
@@ -658,48 +568,41 @@ TextAttrsMgr::FontWeightTextAttr::
// number as getComputedStyle(). fontEntry->Weight() will give the weight
// range supported by the font face used, so we clamp the weight that was
// requested by style to what is actually supported by the font.
gfxFontEntry *fontEntry = font->GetFontEntry();
gfxFontEntry* fontEntry = font->GetFontEntry();
return fontEntry->Weight().Clamp(font->GetStyle()->weight);
}
////////////////////////////////////////////////////////////////////////////////
// AutoGeneratedTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::AutoGeneratedTextAttr::
AutoGeneratedTextAttr(HyperTextAccessible* aHyperTextAcc,
Accessible* aAccessible) :
TTextAttr<bool>(!aAccessible)
{
TextAttrsMgr::AutoGeneratedTextAttr::AutoGeneratedTextAttr(
HyperTextAccessible* aHyperTextAcc, Accessible* aAccessible)
: TTextAttr<bool>(!aAccessible) {
mRootNativeValue = false;
mIsRootDefined = false;
if (aAccessible)
mIsDefined = mNativeValue = (aAccessible->NativeRole() == roles::STATICTEXT);
mIsDefined = mNativeValue =
(aAccessible->NativeRole() == roles::STATICTEXT);
}
bool
TextAttrsMgr::AutoGeneratedTextAttr::
GetValueFor(Accessible* aAccessible, bool* aValue)
{
bool TextAttrsMgr::AutoGeneratedTextAttr::GetValueFor(Accessible* aAccessible,
bool* aValue) {
return *aValue = (aAccessible->NativeRole() == roles::STATICTEXT);
}
void
TextAttrsMgr::AutoGeneratedTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const bool& aValue)
{
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::auto_generated,
void TextAttrsMgr::AutoGeneratedTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const bool& aValue) {
nsAccUtils::SetAccAttr(
aAttributes, nsGkAtoms::auto_generated,
aValue ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"));
}
////////////////////////////////////////////////////////////////////////////////
// TextDecorTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::TextDecorValue::
TextDecorValue(nsIFrame* aFrame)
{
TextAttrsMgr::TextDecorValue::TextDecorValue(nsIFrame* aFrame) {
const nsStyleTextReset* textReset = aFrame->StyleTextReset();
mStyle = textReset->mTextDecorationStyle;
mColor = textReset->mTextDecorationColor.CalcColor(aFrame);
@@ -708,10 +611,9 @@ TextAttrsMgr::TextDecorValue::
NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH);
}
TextAttrsMgr::TextDecorTextAttr::
TextDecorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
TTextAttr<TextDecorValue>(!aFrame)
{
TextAttrsMgr::TextDecorTextAttr::TextDecorTextAttr(nsIFrame* aRootFrame,
nsIFrame* aFrame)
: TTextAttr<TextDecorValue>(!aFrame) {
mRootNativeValue = TextDecorValue(aRootFrame);
mIsRootDefined = mRootNativeValue.IsDefined();
@@ -721,10 +623,8 @@ TextAttrsMgr::TextDecorTextAttr::
}
}
bool
TextAttrsMgr::TextDecorTextAttr::
GetValueFor(Accessible* aAccessible, TextDecorValue* aValue)
{
bool TextAttrsMgr::TextDecorTextAttr::GetValueFor(Accessible* aAccessible,
TextDecorValue* aValue) {
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
if (elm) {
nsIFrame* frame = elm->GetPrimaryFrame();
@@ -736,15 +636,12 @@ TextAttrsMgr::TextDecorTextAttr::
return false;
}
void
TextAttrsMgr::TextDecorTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const TextDecorValue& aValue)
{
void TextAttrsMgr::TextDecorTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const TextDecorValue& aValue) {
if (aValue.IsUnderline()) {
nsAutoString formattedStyle;
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
nsAccUtils::SetAccAttr(aAttributes,
nsGkAtoms::textUnderlineStyle,
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textUnderlineStyle,
formattedStyle);
nsAutoString formattedColor;
@@ -757,8 +654,7 @@ TextAttrsMgr::TextDecorTextAttr::
if (aValue.IsLineThrough()) {
nsAutoString formattedStyle;
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
nsAccUtils::SetAccAttr(aAttributes,
nsGkAtoms::textLineThroughStyle,
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textLineThroughStyle,
formattedStyle);
nsAutoString formattedColor;
@@ -772,10 +668,9 @@ TextAttrsMgr::TextDecorTextAttr::
// TextPosTextAttr
////////////////////////////////////////////////////////////////////////////////
TextAttrsMgr::TextPosTextAttr::
TextPosTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
TTextAttr<TextPosValue>(!aFrame)
{
TextAttrsMgr::TextPosTextAttr::TextPosTextAttr(nsIFrame* aRootFrame,
nsIFrame* aFrame)
: TTextAttr<TextPosValue>(!aFrame) {
mRootNativeValue = GetTextPosValue(aRootFrame);
mIsRootDefined = mRootNativeValue != eTextPosNone;
@@ -785,10 +680,8 @@ TextAttrsMgr::TextPosTextAttr::
}
}
bool
TextAttrsMgr::TextPosTextAttr::
GetValueFor(Accessible* aAccessible, TextPosValue* aValue)
{
bool TextAttrsMgr::TextPosTextAttr::GetValueFor(Accessible* aAccessible,
TextPosValue* aValue) {
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
if (elm) {
nsIFrame* frame = elm->GetPrimaryFrame();
@@ -800,10 +693,8 @@ TextAttrsMgr::TextPosTextAttr::
return false;
}
void
TextAttrsMgr::TextPosTextAttr::
ExposeValue(nsIPersistentProperties* aAttributes, const TextPosValue& aValue)
{
void TextAttrsMgr::TextPosTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const TextPosValue& aValue) {
switch (aValue) {
case eTextPosBaseline:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition,
@@ -825,10 +716,8 @@ TextAttrsMgr::TextPosTextAttr::
}
}
TextAttrsMgr::TextPosValue
TextAttrsMgr::TextPosTextAttr::
GetTextPosValue(nsIFrame* aFrame) const
{
TextAttrsMgr::TextPosValue TextAttrsMgr::TextPosTextAttr::GetTextPosValue(
nsIFrame* aFrame) const {
const nsStyleCoord& styleCoord = aFrame->StyleDisplay()->mVerticalAlign;
switch (styleCoord.GetUnit()) {
case eStyleUnit_Enumerated:
@@ -854,20 +743,17 @@ TextAttrsMgr::TextPosTextAttr::
}
return eTextPosNone;
case eStyleUnit_Percent:
{
case eStyleUnit_Percent: {
float percentValue = styleCoord.GetPercentValue();
return percentValue > 0 ?
eTextPosSuper :
(percentValue < 0 ? eTextPosSub : eTextPosBaseline);
return percentValue > 0
? eTextPosSuper
: (percentValue < 0 ? eTextPosSub : eTextPosBaseline);
}
case eStyleUnit_Coord:
{
case eStyleUnit_Coord: {
nscoord coordValue = styleCoord.GetCoordValue();
return coordValue > 0 ?
eTextPosSuper :
(coordValue < 0 ? eTextPosSub : eTextPosBaseline);
return coordValue > 0 ? eTextPosSuper
: (coordValue < 0 ? eTextPosSub : eTextPosBaseline);
}
case eStyleUnit_Null:
@@ -884,10 +770,8 @@ TextAttrsMgr::TextPosTextAttr::
const nsIContent* content = aFrame->GetContent();
if (content) {
if (content->IsHTMLElement(nsGkAtoms::sup))
return eTextPosSuper;
if (content->IsHTMLElement(nsGkAtoms::sub))
return eTextPosSub;
if (content->IsHTMLElement(nsGkAtoms::sup)) return eTextPosSuper;
if (content->IsHTMLElement(nsGkAtoms::sub)) return eTextPosSub;
}
return eTextPosNone;

View File

@@ -30,15 +30,16 @@ class HyperTextAccessible;
* @note "invalid: spelling" text attribute is implemented entirely in
* HyperTextAccessible class.
*/
class TextAttrsMgr
{
public:
class TextAttrsMgr {
public:
/**
* Constructor. Used to expose default text attributes.
*/
explicit TextAttrsMgr(HyperTextAccessible* aHyperTextAcc) :
mOffsetAcc(nullptr), mHyperTextAcc(aHyperTextAcc),
mOffsetAccIdx(-1), mIncludeDefAttrs(true) { }
explicit TextAttrsMgr(HyperTextAccessible* aHyperTextAcc)
: mOffsetAcc(nullptr),
mHyperTextAcc(aHyperTextAcc),
mOffsetAccIdx(-1),
mIncludeDefAttrs(true) {}
/**
* Constructor. Used to expose text attributes at the given offset.
@@ -52,12 +53,12 @@ public:
* should be calculated for
* @param oOffsetAccIdx [optional] index in parent of offset accessible
*/
TextAttrsMgr(HyperTextAccessible* aHyperTextAcc,
bool aIncludeDefAttrs,
Accessible* aOffsetAcc,
int32_t aOffsetAccIdx) :
mOffsetAcc(aOffsetAcc), mHyperTextAcc(aHyperTextAcc),
mOffsetAccIdx(aOffsetAccIdx), mIncludeDefAttrs(aIncludeDefAttrs) { }
TextAttrsMgr(HyperTextAccessible* aHyperTextAcc, bool aIncludeDefAttrs,
Accessible* aOffsetAcc, int32_t aOffsetAccIdx)
: mOffsetAcc(aOffsetAcc),
mHyperTextAcc(aHyperTextAcc),
mOffsetAccIdx(aOffsetAccIdx),
mIncludeDefAttrs(aIncludeDefAttrs) {}
/*
* Return text attributes and hyper text offsets where these attributes are
@@ -74,7 +75,7 @@ public:
uint32_t* aStartHTOffset = nullptr,
uint32_t* aEndHTOffset = nullptr);
protected:
protected:
/**
* Calculates range (start and end offsets) of text where the text attributes
* are stretched. New offsets may be smaller if one of text attributes changes
@@ -89,19 +90,17 @@ protected:
void GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
uint32_t* aStartOffset, uint32_t* aEndOffset);
private:
private:
Accessible* mOffsetAcc;
HyperTextAccessible* mHyperTextAcc;
int32_t mOffsetAccIdx;
bool mIncludeDefAttrs;
protected:
protected:
/**
* Interface class of text attribute class implementations.
*/
class TextAttr
{
class TextAttr {
public:
/**
* Expose the text attribute to the given attribute set.
@@ -120,23 +119,19 @@ protected:
virtual bool Equal(Accessible* aAccessible) = 0;
};
/**
* Base class to work with text attributes. See derived classes below.
*/
template<class T>
class TTextAttr : public TextAttr
{
template <class T>
class TTextAttr : public TextAttr {
public:
explicit TTextAttr(bool aGetRootValue) : mGetRootValue(aGetRootValue) {}
// TextAttr
virtual void Expose(nsIPersistentProperties* aAttributes,
bool aIncludeDefAttrValue) override
{
bool aIncludeDefAttrValue) override {
if (mGetRootValue) {
if (mIsRootDefined)
ExposeValue(aAttributes, mRootNativeValue);
if (mIsRootDefined) ExposeValue(aAttributes, mRootNativeValue);
return;
}
@@ -150,25 +145,20 @@ protected:
ExposeValue(aAttributes, mRootNativeValue);
}
virtual bool Equal(Accessible* aAccessible) override
{
virtual bool Equal(Accessible* aAccessible) override {
T nativeValue;
bool isDefined = GetValueFor(aAccessible, &nativeValue);
if (!mIsDefined && !isDefined)
return true;
if (!mIsDefined && !isDefined) return true;
if (mIsDefined && isDefined)
return nativeValue == mNativeValue;
if (mIsDefined && isDefined) return nativeValue == mNativeValue;
if (mIsDefined)
return mNativeValue == mRootNativeValue;
if (mIsDefined) return mNativeValue == mRootNativeValue;
return nativeValue == mRootNativeValue;
}
protected:
// Expose the text attribute with the given value to attribute set.
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const T& aValue) = 0;
@@ -185,27 +175,25 @@ protected:
MOZ_INIT_OUTSIDE_CTOR T mNativeValue;
MOZ_INIT_OUTSIDE_CTOR bool mIsDefined;
// Native root value and flag indicating if the value is defined (initialized
// in derived classes).
// Native root value and flag indicating if the value is defined
// (initialized in derived classes).
MOZ_INIT_OUTSIDE_CTOR T mRootNativeValue;
MOZ_INIT_OUTSIDE_CTOR bool mIsRootDefined;
};
/**
* Class is used for the work with 'language' text attribute.
*/
class LangTextAttr : public TTextAttr<nsString>
{
class LangTextAttr : public TTextAttr<nsString> {
public:
LangTextAttr(HyperTextAccessible* aRoot, nsIContent* aRootElm,
nsIContent* aElm);
virtual ~LangTextAttr();
protected:
// TextAttr
virtual bool GetValueFor(Accessible* aAccessible, nsString* aValue) override;
virtual bool GetValueFor(Accessible* aAccessible,
nsString* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const nsString& aValue) override;
@@ -213,30 +201,23 @@ protected:
nsCOMPtr<nsIContent> mRootContent;
};
/**
* Class is used for the 'invalid' text attribute. Note, it calculated
* the attribute from aria-invalid attribute only; invalid:spelling attribute
* calculated from misspelled text in the editor is managed by
* HyperTextAccessible and applied on top of the value from aria-invalid.
*/
class InvalidTextAttr : public TTextAttr<uint32_t>
{
class InvalidTextAttr : public TTextAttr<uint32_t> {
public:
InvalidTextAttr(nsIContent* aRootElm, nsIContent* aElm);
virtual ~InvalidTextAttr() { };
virtual ~InvalidTextAttr(){};
protected:
enum {
eFalse,
eGrammar,
eSpelling,
eTrue
};
enum { eFalse, eGrammar, eSpelling, eTrue };
// TextAttr
virtual bool GetValueFor(Accessible* aAccessible, uint32_t* aValue) override;
virtual bool GetValueFor(Accessible* aAccessible,
uint32_t* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const uint32_t& aValue) override;
@@ -245,21 +226,17 @@ protected:
nsIContent* mRootElm;
};
/**
* Class is used for the work with 'background-color' text attribute.
*/
class BGColorTextAttr : public TTextAttr<nscolor>
{
class BGColorTextAttr : public TTextAttr<nscolor> {
public:
BGColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
virtual ~BGColorTextAttr() { }
virtual ~BGColorTextAttr() {}
protected:
// TextAttr
virtual bool GetValueFor(Accessible* aAccessible, nscolor* aValue)
override;
virtual bool GetValueFor(Accessible* aAccessible, nscolor* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const nscolor& aValue) override;
@@ -268,63 +245,51 @@ protected:
nsIFrame* mRootFrame;
};
/**
* Class is used for the work with 'color' text attribute.
*/
class ColorTextAttr : public TTextAttr<nscolor>
{
class ColorTextAttr : public TTextAttr<nscolor> {
public:
ColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
virtual ~ColorTextAttr() { }
virtual ~ColorTextAttr() {}
protected:
// TTextAttr
virtual bool GetValueFor(Accessible* aAccessible, nscolor* aValue)
override;
virtual bool GetValueFor(Accessible* aAccessible, nscolor* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const nscolor& aValue) override;
};
/**
* Class is used for the work with "font-family" text attribute.
*/
class FontFamilyTextAttr : public TTextAttr<nsString>
{
class FontFamilyTextAttr : public TTextAttr<nsString> {
public:
FontFamilyTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
virtual ~FontFamilyTextAttr() { }
virtual ~FontFamilyTextAttr() {}
protected:
// TTextAttr
virtual bool GetValueFor(Accessible* aAccessible, nsString* aValue)
override;
virtual bool GetValueFor(Accessible* aAccessible,
nsString* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const nsString& aValue) override;
private:
bool GetFontFamily(nsIFrame* aFrame, nsString& aFamily);
};
/**
* Class is used for the work with "font-size" text attribute.
*/
class FontSizeTextAttr : public TTextAttr<nscoord>
{
class FontSizeTextAttr : public TTextAttr<nscoord> {
public:
FontSizeTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
virtual ~FontSizeTextAttr() { }
virtual ~FontSizeTextAttr() {}
protected:
// TTextAttr
virtual bool GetValueFor(Accessible* aAccessible, nscoord* aValue)
override;
virtual bool GetValueFor(Accessible* aAccessible, nscoord* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const nscoord& aValue) override;
@@ -332,41 +297,34 @@ protected:
nsDeviceContext* mDC;
};
/**
* Class is used for the work with "font-style" text attribute.
*/
class FontStyleTextAttr : public TTextAttr<mozilla::FontSlantStyle>
{
class FontStyleTextAttr : public TTextAttr<mozilla::FontSlantStyle> {
public:
FontStyleTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
virtual ~FontStyleTextAttr() { }
virtual ~FontStyleTextAttr() {}
protected:
// TTextAttr
virtual bool GetValueFor(Accessible* aContent, mozilla::FontSlantStyle* aValue)
override;
virtual bool GetValueFor(Accessible* aContent,
mozilla::FontSlantStyle* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const mozilla::FontSlantStyle& aValue) override;
};
/**
* Class is used for the work with "font-weight" text attribute.
*/
class FontWeightTextAttr : public TTextAttr<mozilla::FontWeight>
{
class FontWeightTextAttr : public TTextAttr<mozilla::FontWeight> {
public:
FontWeightTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
virtual ~FontWeightTextAttr() { }
virtual ~FontWeightTextAttr() {}
protected:
// TTextAttr
virtual bool GetValueFor(Accessible* aAccessible,
mozilla::FontWeight* aValue)
override;
mozilla::FontWeight* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const mozilla::FontWeight& aValue) override;
@@ -377,53 +335,49 @@ protected:
/**
* Class is used for the work with 'auto-generated' text attribute.
*/
class AutoGeneratedTextAttr : public TTextAttr<bool>
{
class AutoGeneratedTextAttr : public TTextAttr<bool> {
public:
AutoGeneratedTextAttr(HyperTextAccessible* aHyperTextAcc,
Accessible* aAccessible);
virtual ~AutoGeneratedTextAttr() { }
virtual ~AutoGeneratedTextAttr() {}
protected:
// TextAttr
virtual bool GetValueFor(Accessible* aAccessible, bool* aValue)
override;
virtual bool GetValueFor(Accessible* aAccessible, bool* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const bool& aValue) override;
};
/**
* TextDecorTextAttr class is used for the work with
* "text-line-through-style", "text-line-through-color",
* "text-underline-style" and "text-underline-color" text attributes.
*/
class TextDecorValue
{
class TextDecorValue {
public:
TextDecorValue() :
mColor{0}, mLine{NS_STYLE_TEXT_DECORATION_LINE_NONE},
mStyle{NS_STYLE_TEXT_DECORATION_STYLE_NONE} { }
TextDecorValue()
: mColor{0},
mLine{NS_STYLE_TEXT_DECORATION_LINE_NONE},
mStyle{NS_STYLE_TEXT_DECORATION_STYLE_NONE} {}
explicit TextDecorValue(nsIFrame* aFrame);
nscolor Color() const { return mColor; }
uint8_t Style() const { return mStyle; }
bool IsDefined() const
{ return IsUnderline() || IsLineThrough(); }
bool IsUnderline() const
{ return mLine & NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE; }
bool IsLineThrough() const
{ return mLine & NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH; }
bool IsDefined() const { return IsUnderline() || IsLineThrough(); }
bool IsUnderline() const {
return mLine & NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE;
}
bool IsLineThrough() const {
return mLine & NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH;
}
bool operator ==(const TextDecorValue& aValue)
{
bool operator==(const TextDecorValue& aValue) {
return mColor == aValue.mColor && mLine == aValue.mLine &&
mStyle == aValue.mStyle;
}
bool operator !=(const TextDecorValue& aValue)
{ return !(*this == aValue); }
bool operator!=(const TextDecorValue& aValue) { return !(*this == aValue); }
private:
nscolor mColor;
@@ -431,17 +385,15 @@ protected:
uint8_t mStyle;
};
class TextDecorTextAttr : public TTextAttr<TextDecorValue>
{
class TextDecorTextAttr : public TTextAttr<TextDecorValue> {
public:
TextDecorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
virtual ~TextDecorTextAttr() { }
virtual ~TextDecorTextAttr() {}
protected:
// TextAttr
virtual bool GetValueFor(Accessible* aAccessible, TextDecorValue* aValue)
override;
virtual bool GetValueFor(Accessible* aAccessible,
TextDecorValue* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const TextDecorValue& aValue) override;
};
@@ -457,17 +409,15 @@ protected:
eTextPosSuper
};
class TextPosTextAttr : public TTextAttr<TextPosValue>
{
class TextPosTextAttr : public TTextAttr<TextPosValue> {
public:
TextPosTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
virtual ~TextPosTextAttr() { }
virtual ~TextPosTextAttr() {}
protected:
// TextAttr
virtual bool GetValueFor(Accessible* aAccessible, TextPosValue* aValue)
override;
virtual bool GetValueFor(Accessible* aAccessible,
TextPosValue* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const TextPosValue& aValue) override;

View File

@@ -13,16 +13,13 @@
namespace mozilla {
namespace a11y {
inline Accessible*
TextRange::Container() const
{
inline Accessible* TextRange::Container() const {
uint32_t pos1 = 0, pos2 = 0;
AutoTArray<Accessible*, 30> parents1, parents2;
return CommonParent(mStartContainer, mEndContainer,
&parents1, &pos1, &parents2, &pos2);
return CommonParent(mStartContainer, mEndContainer, &parents1, &pos1,
&parents2, &pos2);
}
} // namespace a11y
} // namespace mozilla

View File

@@ -15,11 +15,8 @@ namespace a11y {
////////////////////////////////////////////////////////////////////////////////
// TextPoint
bool
TextPoint::operator <(const TextPoint& aPoint) const
{
if (mContainer == aPoint.mContainer)
return mOffset < aPoint.mOffset;
bool TextPoint::operator<(const TextPoint& aPoint) const {
if (mContainer == aPoint.mContainer) return mOffset < aPoint.mOffset;
// Build the chain of parents
Accessible* p1 = mContainer;
@@ -52,15 +49,14 @@ TextPoint::operator <(const TextPoint& aPoint) const
TextRange::TextRange(HyperTextAccessible* aRoot,
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
HyperTextAccessible* aEndContainer, int32_t aEndOffset) :
mRoot(aRoot), mStartContainer(aStartContainer), mEndContainer(aEndContainer),
mStartOffset(aStartOffset), mEndOffset(aEndOffset)
{
}
HyperTextAccessible* aEndContainer, int32_t aEndOffset)
: mRoot(aRoot),
mStartContainer(aStartContainer),
mEndContainer(aEndContainer),
mStartOffset(aStartOffset),
mEndOffset(aEndOffset) {}
void
TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
{
void TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const {
if (mStartContainer == mEndContainer) {
int32_t startIdx = mStartContainer->GetChildIndexAtOffset(mStartOffset);
int32_t endIdx = mStartContainer->GetChildIndexAtOffset(mEndOffset);
@@ -86,7 +82,8 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
Accessible* parent = parents1[idx + 1];
Accessible* child = parents1[idx];
uint32_t childCount = parent->ChildCount();
for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount; childIdx++) {
for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount;
childIdx++) {
Accessible* next = parent->GetChildAt(childIdx);
if (!next->IsText()) {
aChildren->AppendElement(next);
@@ -118,37 +115,24 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
}
}
void
TextRange::Text(nsAString& aText) const
{
void TextRange::Text(nsAString& aText) const {
Accessible* current = mStartContainer->GetChildAtOffset(mStartOffset);
uint32_t startIntlOffset =
mStartOffset - mStartContainer->GetChildOffset(current);
while (current && TextInternal(aText, current, startIntlOffset)) {
current = current->Parent();
if (!current)
break;
if (!current) break;
current = current->NextSibling();
}
}
void
TextRange::Bounds(nsTArray<nsIntRect> aRects) const
{
void TextRange::Bounds(nsTArray<nsIntRect> aRects) const {}
}
void TextRange::Normalize(ETextUnit aUnit) {}
void
TextRange::Normalize(ETextUnit aUnit)
{
}
bool
TextRange::Crop(Accessible* aContainer)
{
bool TextRange::Crop(Accessible* aContainer) {
uint32_t boundaryPos = 0, containerPos = 0;
AutoTArray<Accessible*, 30> boundaryParents, containerParents;
@@ -163,15 +147,14 @@ TextRange::Crop(Accessible* aContainer)
if (containerPos != 0) {
// The container is contained by the start boundary, reduce the range to
// the point starting at the container.
aContainer->ToTextPoint(mStartContainer.StartAssignment(), &mStartOffset);
aContainer->ToTextPoint(mStartContainer.StartAssignment(),
&mStartOffset);
static_cast<Accessible*>(mStartContainer)->AddRef();
}
else {
} else {
// The start boundary and the container are siblings.
container = aContainer;
}
}
else if (containerPos != 0) {
} else if (containerPos != 0) {
// The container does not contain the start boundary.
boundary = boundaryParents[boundaryPos];
container = containerParents[containerPos];
@@ -186,7 +169,8 @@ TextRange::Crop(Accessible* aContainer)
// If the range starts before the container, then reduce the range to
// the point starting at the container.
if (boundary->IndexInParent() < container->IndexInParent()) {
container->ToTextPoint(mStartContainer.StartAssignment(), &mStartOffset);
container->ToTextPoint(mStartContainer.StartAssignment(),
&mStartOffset);
mStartContainer.get()->AddRef();
}
}
@@ -207,14 +191,13 @@ TextRange::Crop(Accessible* aContainer)
if (boundaryPos == 0) {
if (containerPos != 0) {
aContainer->ToTextPoint(mEndContainer.StartAssignment(), &mEndOffset, false);
aContainer->ToTextPoint(mEndContainer.StartAssignment(), &mEndOffset,
false);
static_cast<Accessible*>(mEndContainer)->AddRef();
}
else {
} else {
container = aContainer;
}
}
else if (containerPos != 0) {
} else if (containerPos != 0) {
boundary = boundaryParents[boundaryPos];
container = containerParents[containerPos];
}
@@ -235,51 +218,27 @@ TextRange::Crop(Accessible* aContainer)
return true;
}
void
TextRange::FindText(const nsAString& aText, EDirection aDirection,
nsCaseTreatment aCaseSensitive, TextRange* aFoundRange) const
{
void TextRange::FindText(const nsAString& aText, EDirection aDirection,
nsCaseTreatment aCaseSensitive,
TextRange* aFoundRange) const {}
}
void TextRange::FindAttr(EAttr aAttr, nsIVariant* aValue, EDirection aDirection,
TextRange* aFoundRange) const {}
void
TextRange::FindAttr(EAttr aAttr, nsIVariant* aValue, EDirection aDirection,
TextRange* aFoundRange) const
{
void TextRange::AddToSelection() const {}
}
void TextRange::RemoveFromSelection() const {}
void
TextRange::AddToSelection() const
{
void TextRange::Select() const {}
}
void
TextRange::RemoveFromSelection() const
{
}
void
TextRange::Select() const
{
}
void
TextRange::ScrollIntoView(EHowToAlign aHow) const
{
}
void TextRange::ScrollIntoView(EHowToAlign aHow) const {}
////////////////////////////////////////////////////////////////////////////////
// pivate
void
TextRange::Set(HyperTextAccessible* aRoot,
void TextRange::Set(HyperTextAccessible* aRoot,
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
HyperTextAccessible* aEndContainer, int32_t aEndOffset)
{
HyperTextAccessible* aEndContainer, int32_t aEndOffset) {
mRoot = aRoot;
mStartContainer = aStartContainer;
mEndContainer = aEndContainer;
@@ -287,19 +246,15 @@ TextRange::Set(HyperTextAccessible* aRoot,
mEndOffset = aEndOffset;
}
bool
TextRange::TextInternal(nsAString& aText, Accessible* aCurrent,
uint32_t aStartIntlOffset) const
{
bool TextRange::TextInternal(nsAString& aText, Accessible* aCurrent,
uint32_t aStartIntlOffset) const {
bool moveNext = true;
int32_t endIntlOffset = -1;
if (aCurrent->Parent() == mEndContainer &&
mEndContainer->GetChildAtOffset(mEndOffset) == aCurrent) {
uint32_t currentStartOffset = mEndContainer->GetChildOffset(aCurrent);
endIntlOffset = mEndOffset - currentStartOffset;
if (endIntlOffset == 0)
return false;
if (endIntlOffset == 0) return false;
moveNext = false;
}
@@ -307,39 +262,32 @@ TextRange::TextInternal(nsAString& aText, Accessible* aCurrent,
if (aCurrent->IsTextLeaf()) {
aCurrent->AppendTextTo(aText, aStartIntlOffset,
endIntlOffset - aStartIntlOffset);
if (!moveNext)
return false;
if (!moveNext) return false;
}
Accessible* next = aCurrent->FirstChild();
if (next) {
if (!TextInternal(aText, next, 0))
return false;
if (!TextInternal(aText, next, 0)) return false;
}
next = aCurrent->NextSibling();
if (next) {
if (!TextInternal(aText, next, 0))
return false;
if (!TextInternal(aText, next, 0)) return false;
}
return moveNext;
}
void
TextRange::MoveInternal(ETextUnit aUnit, int32_t aCount,
void TextRange::MoveInternal(ETextUnit aUnit, int32_t aCount,
HyperTextAccessible& aContainer, int32_t aOffset,
HyperTextAccessible* aStopContainer, int32_t aStopOffset)
{
HyperTextAccessible* aStopContainer,
int32_t aStopOffset) {}
}
Accessible*
TextRange::CommonParent(Accessible* aAcc1, Accessible* aAcc2,
nsTArray<Accessible*>* aParents1, uint32_t* aPos1,
nsTArray<Accessible*>* aParents2, uint32_t* aPos2) const
{
Accessible* TextRange::CommonParent(Accessible* aAcc1, Accessible* aAcc2,
nsTArray<Accessible*>* aParents1,
uint32_t* aPos1,
nsTArray<Accessible*>* aParents2,
uint32_t* aPos2) const {
if (aAcc1 == aAcc2) {
return aAcc1;
}
@@ -367,8 +315,7 @@ TextRange::CommonParent(Accessible* aAcc1, Accessible* aAcc2,
for (len = std::min(*aPos1, *aPos2); len > 0; --len) {
Accessible* child1 = aParents1->ElementAt(--(*aPos1));
Accessible* child2 = aParents2->ElementAt(--(*aPos2));
if (child1 != child2)
break;
if (child1 != child2) break;
parent = child1;
}

View File

@@ -12,7 +12,7 @@
#include "nsRect.h"
#include "nsTArray.h"
class nsIVariant;
class nsIVariant;
namespace mozilla {
namespace a11y {
@@ -23,39 +23,38 @@ class HyperTextAccessible;
/**
* A text point (hyper text + offset), represents a boundary of text range.
*/
struct TextPoint final
{
TextPoint(HyperTextAccessible* aContainer, int32_t aOffset) :
mContainer(aContainer), mOffset(aOffset) { }
TextPoint(const TextPoint& aPoint) :
mContainer(aPoint.mContainer), mOffset(aPoint.mOffset) { }
struct TextPoint final {
TextPoint(HyperTextAccessible* aContainer, int32_t aOffset)
: mContainer(aContainer), mOffset(aOffset) {}
TextPoint(const TextPoint& aPoint)
: mContainer(aPoint.mContainer), mOffset(aPoint.mOffset) {}
HyperTextAccessible* mContainer;
int32_t mOffset;
bool operator ==(const TextPoint& aPoint) const
{ return mContainer == aPoint.mContainer && mOffset == aPoint.mOffset; }
bool operator <(const TextPoint& aPoint) const;
bool operator==(const TextPoint& aPoint) const {
return mContainer == aPoint.mContainer && mOffset == aPoint.mOffset;
}
bool operator<(const TextPoint& aPoint) const;
};
/**
* Represents a text range within the text control or document.
*/
class TextRange final
{
public:
TextRange(HyperTextAccessible* aRoot,
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
HyperTextAccessible* aEndContainer, int32_t aEndOffset);
class TextRange final {
public:
TextRange(HyperTextAccessible* aRoot, HyperTextAccessible* aStartContainer,
int32_t aStartOffset, HyperTextAccessible* aEndContainer,
int32_t aEndOffset);
TextRange() : mStartOffset{0}, mEndOffset{0} {}
TextRange(TextRange&& aRange) :
mRoot(std::move(aRange.mRoot)),
TextRange(TextRange&& aRange)
: mRoot(std::move(aRange.mRoot)),
mStartContainer(std::move(aRange.mStartContainer)),
mEndContainer(std::move(aRange.mEndContainer)),
mStartOffset(aRange.mStartOffset), mEndOffset(aRange.mEndOffset) {}
mStartOffset(aRange.mStartOffset),
mEndOffset(aRange.mEndOffset) {}
TextRange& operator= (TextRange&& aRange)
{
TextRange& operator=(TextRange&& aRange) {
mRoot = std::move(aRange.mRoot);
mStartContainer = std::move(aRange.mStartContainer);
mEndContainer = std::move(aRange.mEndContainer);
@@ -69,14 +68,16 @@ public:
HyperTextAccessible* EndContainer() const { return mEndContainer; }
int32_t EndOffset() const { return mEndOffset; }
bool operator ==(const TextRange& aRange) const
{
bool operator==(const TextRange& aRange) const {
return mStartContainer == aRange.mStartContainer &&
mStartOffset == aRange.mStartOffset &&
mEndContainer == aRange.mEndContainer && mEndOffset == aRange.mEndOffset;
mEndContainer == aRange.mEndContainer &&
mEndOffset == aRange.mEndOffset;
}
TextPoint StartPoint() const { return TextPoint(mStartContainer, mStartOffset); }
TextPoint StartPoint() const {
return TextPoint(mStartContainer, mStartOffset);
}
TextPoint EndPoint() const { return TextPoint(mEndContainer, mEndOffset); }
/**
@@ -100,30 +101,22 @@ public:
*/
void Bounds(nsTArray<nsIntRect> aRects) const;
enum ETextUnit {
eFormat,
eWord,
eLine,
eParagraph,
ePage,
eDocument
};
enum ETextUnit { eFormat, eWord, eLine, eParagraph, ePage, eDocument };
/**
* Move the range or its points on specified amount of given units.
*/
void Move(ETextUnit aUnit, int32_t aCount)
{
void Move(ETextUnit aUnit, int32_t aCount) {
MoveEnd(aUnit, aCount);
MoveStart(aUnit, aCount);
}
void MoveStart(ETextUnit aUnit, int32_t aCount)
{
MoveInternal(aUnit, aCount, *mStartContainer, mStartOffset,
mEndContainer, mEndOffset);
void MoveStart(ETextUnit aUnit, int32_t aCount) {
MoveInternal(aUnit, aCount, *mStartContainer, mStartOffset, mEndContainer,
mEndOffset);
}
void MoveEnd(ETextUnit aUnit, int32_t aCount) {
MoveInternal(aUnit, aCount, *mEndContainer, mEndOffset);
}
void MoveEnd(ETextUnit aUnit, int32_t aCount)
{ MoveInternal(aUnit, aCount, *mEndContainer, mEndOffset); }
/**
* Move the range points to the closest unit boundaries.
@@ -136,10 +129,7 @@ public:
*/
bool Crop(Accessible* aContainer);
enum EDirection {
eBackward,
eForward
};
enum EDirection { eBackward, eForward };
/**
* Return range enclosing the found text.
@@ -206,10 +196,7 @@ public:
/**
* Scroll the text range into view.
*/
enum EHowToAlign {
eAlignToTop,
eAlignToBottom
};
enum EHowToAlign { eAlignToTop, eAlignToBottom };
void ScrollIntoView(EHowToAlign aHow) const;
/**
@@ -217,21 +204,25 @@ public:
*/
bool IsValid() const { return mRoot; }
void SetStartPoint(HyperTextAccessible* aContainer, int32_t aOffset)
{ mStartContainer = aContainer; mStartOffset = aOffset; }
void SetEndPoint(HyperTextAccessible* aContainer, int32_t aOffset)
{ mStartContainer = aContainer; mStartOffset = aOffset; }
void SetStartPoint(HyperTextAccessible* aContainer, int32_t aOffset) {
mStartContainer = aContainer;
mStartOffset = aOffset;
}
void SetEndPoint(HyperTextAccessible* aContainer, int32_t aOffset) {
mStartContainer = aContainer;
mStartOffset = aOffset;
}
private:
private:
TextRange(const TextRange& aRange) = delete;
TextRange& operator=(const TextRange& aRange) = delete;
friend class HyperTextAccessible;
friend class xpcAccessibleTextRange;
void Set(HyperTextAccessible* aRoot,
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
HyperTextAccessible* aEndContainer, int32_t aEndOffset);
void Set(HyperTextAccessible* aRoot, HyperTextAccessible* aStartContainer,
int32_t aStartOffset, HyperTextAccessible* aEndContainer,
int32_t aEndOffset);
/**
* Text() method helper.
@@ -254,7 +245,8 @@ private:
*/
Accessible* CommonParent(Accessible* aAcc1, Accessible* aAcc2,
nsTArray<Accessible*>* aParents1, uint32_t* aPos1,
nsTArray<Accessible*>* aParents2, uint32_t* aPos2) const;
nsTArray<Accessible*>* aParents2,
uint32_t* aPos2) const;
RefPtr<HyperTextAccessible> mRoot;
RefPtr<HyperTextAccessible> mStartContainer;
@@ -263,7 +255,6 @@ private:
int32_t mEndOffset;
};
} // namespace a11y
} // namespace mozilla

View File

@@ -12,10 +12,8 @@
using namespace mozilla::a11y;
void
TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
const nsAString& aNewText)
{
void TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
const nsAString& aNewText) {
NS_ASSERTION(aTextLeaf, "No text leaf accessible?");
const nsString& oldText = aTextLeaf->Text();
@@ -25,8 +23,7 @@ TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
// Skip coinciding begin substrings.
uint32_t skipStart = 0;
for (; skipStart < minLen; skipStart++) {
if (aNewText[skipStart] != oldText[skipStart])
break;
if (aNewText[skipStart] != oldText[skipStart]) break;
}
// The text was changed. Do update.
@@ -36,13 +33,10 @@ TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
}
}
void
TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
uint32_t aSkipStart)
{
void TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
uint32_t aSkipStart) {
Accessible* parent = mTextLeaf->Parent();
if (!parent)
return;
if (!parent) return;
mHyperText = parent->AsHyperText();
if (!mHyperText) {
@@ -52,8 +46,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
// Get the text leaf accessible offset and invalidate cached offsets after it.
mTextOffset = mHyperText->GetChildOffset(mTextLeaf, true);
NS_ASSERTION(mTextOffset != -1,
"Text leaf hasn't offset within hyper text!");
NS_ASSERTION(mTextOffset != -1, "Text leaf hasn't offset within hyper text!");
uint32_t oldLen = aOldText.Length(), newLen = aNewText.Length();
uint32_t minLen = std::min(oldLen, newLen);
@@ -77,8 +70,8 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
// It could be single insertion or removal or the case of long strings. Do not
// calculate the difference between long strings and prefer to fire pair of
// insert/remove events as the old string was replaced on the new one.
if (strLen1 == 0 || strLen2 == 0 ||
strLen1 > kMaxStrLen || strLen2 > kMaxStrLen) {
if (strLen1 == 0 || strLen2 == 0 || strLen1 > kMaxStrLen ||
strLen2 > kMaxStrLen) {
if (strLen1 > 0) {
// Fire text change event for removal.
RefPtr<AccEvent> textRemoveEvent =
@@ -108,8 +101,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
uint32_t len1 = strLen1 + 1, len2 = strLen2 + 1;
uint32_t* entries = new uint32_t[len1 * len2];
for (uint32_t colIdx = 0; colIdx < len1; colIdx++)
entries[colIdx] = colIdx;
for (uint32_t colIdx = 0; colIdx < len1; colIdx++) entries[colIdx] = colIdx;
uint32_t* row = entries;
for (uint32_t rowIdx = 1; rowIdx < len2; rowIdx++) {
@@ -132,7 +124,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
nsTArray<RefPtr<AccEvent> > events;
ComputeTextChangeEvents(str1, str2, entries, events);
delete [] entries;
delete[] entries;
// Fire events.
for (int32_t idx = events.Length() - 1; idx >= 0; idx--)
@@ -144,12 +136,9 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
mTextLeaf->SetText(aNewText);
}
void
TextUpdater::ComputeTextChangeEvents(const nsAString& aStr1,
const nsAString& aStr2,
uint32_t* aEntries,
nsTArray<RefPtr<AccEvent> >& aEvents)
{
void TextUpdater::ComputeTextChangeEvents(
const nsAString& aStr1, const nsAString& aStr2, uint32_t* aEntries,
nsTArray<RefPtr<AccEvent> >& aEvents) {
int32_t colIdx = aStr1.Length(), rowIdx = aStr2.Length();
// Point at which strings last matched.
@@ -162,12 +151,12 @@ TextUpdater::ComputeTextChangeEvents(const nsAString& aStr1,
while (rowIdx && colIdx) { // stop when we can't move diagonally
if (aStr1[colIdx - 1] == aStr2[rowIdx - 1]) { // match
if (rowIdx < rowEnd) { // deal with any pending insertion
FireInsertEvent(Substring(aStr2, rowIdx, rowEnd - rowIdx),
rowIdx, aEvents);
FireInsertEvent(Substring(aStr2, rowIdx, rowEnd - rowIdx), rowIdx,
aEvents);
}
if (colIdx < colEnd) { // deal with any pending deletion
FireDeleteEvent(Substring(aStr1, colIdx, colEnd - colIdx),
rowIdx, aEvents);
FireDeleteEvent(Substring(aStr1, colIdx, colEnd - colIdx), rowIdx,
aEvents);
}
colEnd = --colIdx; // reset the match point
@@ -195,8 +184,6 @@ TextUpdater::ComputeTextChangeEvents(const nsAString& aStr1,
return;
}
if (rowEnd)
FireInsertEvent(Substring(aStr2, 0, rowEnd), 0, aEvents);
if (colEnd)
FireDeleteEvent(Substring(aStr1, 0, colEnd), 0, aEvents);
if (rowEnd) FireInsertEvent(Substring(aStr2, 0, rowEnd), 0, aEvents);
if (colEnd) FireDeleteEvent(Substring(aStr1, 0, colEnd), 0, aEvents);
}

View File

@@ -16,22 +16,26 @@ namespace a11y {
* Used to find a difference between old and new text and fire text change
* events.
*/
class TextUpdater
{
public:
class TextUpdater {
public:
/**
* Start text of the text leaf update.
*/
static void Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
const nsAString& aNewText);
private:
TextUpdater(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf) :
mDocument(aDocument), mTextLeaf(aTextLeaf), mHyperText(nullptr),
mTextOffset(-1) { }
private:
TextUpdater(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf)
: mDocument(aDocument),
mTextLeaf(aTextLeaf),
mHyperText(nullptr),
mTextOffset(-1) {}
~TextUpdater()
{ mDocument = nullptr; mTextLeaf = nullptr; mHyperText = nullptr; }
~TextUpdater() {
mDocument = nullptr;
mTextLeaf = nullptr;
mHyperText = nullptr;
}
/**
* Update text of the text leaf accessible, fire text change and value change
@@ -40,7 +44,7 @@ private:
void DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
uint32_t aSkipStart);
private:
private:
TextUpdater();
TextUpdater(const TextUpdater&);
TextUpdater& operator=(const TextUpdater&);
@@ -48,8 +52,7 @@ private:
/**
* Fire text change events based on difference between strings.
*/
void ComputeTextChangeEvents(const nsAString& aStr1,
const nsAString& aStr2,
void ComputeTextChangeEvents(const nsAString& aStr1, const nsAString& aStr2,
uint32_t* aEntries,
nsTArray<RefPtr<AccEvent> >& aEvents);
@@ -57,11 +60,9 @@ private:
* Helper to create text change events for inserted text.
*/
inline void FireInsertEvent(const nsAString& aText, uint32_t aAddlOffset,
nsTArray<RefPtr<AccEvent> >& aEvents)
{
RefPtr<AccEvent> event =
new AccTextChangeEvent(mHyperText, mTextOffset + aAddlOffset,
aText, true);
nsTArray<RefPtr<AccEvent> >& aEvents) {
RefPtr<AccEvent> event = new AccTextChangeEvent(
mHyperText, mTextOffset + aAddlOffset, aText, true);
aEvents.AppendElement(event);
}
@@ -69,11 +70,9 @@ private:
* Helper to create text change events for removed text.
*/
inline void FireDeleteEvent(const nsAString& aText, uint32_t aAddlOffset,
nsTArray<RefPtr<AccEvent> >& aEvents)
{
RefPtr<AccEvent> event =
new AccTextChangeEvent(mHyperText, mTextOffset + aAddlOffset,
aText, false);
nsTArray<RefPtr<AccEvent> >& aEvents) {
RefPtr<AccEvent> event = new AccTextChangeEvent(
mHyperText, mTextOffset + aAddlOffset, aText, false);
aEvents.AppendElement(event);
}
@@ -83,7 +82,7 @@ private:
*/
const static uint32_t kMaxStrLen = 1 << 6;
private:
private:
DocAccessible* mDocument;
TextLeafAccessible* mTextLeaf;
HyperTextAccessible* mHyperText;

View File

@@ -20,58 +20,58 @@ using namespace mozilla::a11y;
// TreeWalker
////////////////////////////////////////////////////////////////////////////////
TreeWalker::
TreeWalker(Accessible* aContext) :
mDoc(aContext->Document()), mContext(aContext), mAnchorNode(nullptr),
TreeWalker::TreeWalker(Accessible* aContext)
: mDoc(aContext->Document()),
mContext(aContext),
mAnchorNode(nullptr),
mARIAOwnsIdx(0),
mChildFilter(nsIContent::eSkipPlaceholderContent), mFlags(0),
mPhase(eAtStart)
{
mChildFilter |= mContext->NoXBLKids() ?
nsIContent::eAllButXBL : nsIContent::eAllChildren;
mChildFilter(nsIContent::eSkipPlaceholderContent),
mFlags(0),
mPhase(eAtStart) {
mChildFilter |=
mContext->NoXBLKids() ? nsIContent::eAllButXBL : nsIContent::eAllChildren;
mAnchorNode = mContext->IsDoc() ?
mDoc->DocumentNode()->GetRootElement() : mContext->GetContent();
mAnchorNode = mContext->IsDoc() ? mDoc->DocumentNode()->GetRootElement()
: mContext->GetContent();
MOZ_COUNT_CTOR(TreeWalker);
}
TreeWalker::
TreeWalker(Accessible* aContext, nsIContent* aAnchorNode, uint32_t aFlags) :
mDoc(aContext->Document()), mContext(aContext), mAnchorNode(aAnchorNode),
TreeWalker::TreeWalker(Accessible* aContext, nsIContent* aAnchorNode,
uint32_t aFlags)
: mDoc(aContext->Document()),
mContext(aContext),
mAnchorNode(aAnchorNode),
mARIAOwnsIdx(0),
mChildFilter(nsIContent::eSkipPlaceholderContent), mFlags(aFlags),
mPhase(eAtStart)
{
MOZ_ASSERT(mFlags & eWalkCache, "This constructor cannot be used for tree creation");
mChildFilter(nsIContent::eSkipPlaceholderContent),
mFlags(aFlags),
mPhase(eAtStart) {
MOZ_ASSERT(mFlags & eWalkCache,
"This constructor cannot be used for tree creation");
MOZ_ASSERT(aAnchorNode, "No anchor node for the accessible tree walker");
mChildFilter |= mContext->NoXBLKids() ?
nsIContent::eAllButXBL : nsIContent::eAllChildren;
mChildFilter |=
mContext->NoXBLKids() ? nsIContent::eAllButXBL : nsIContent::eAllChildren;
MOZ_COUNT_CTOR(TreeWalker);
}
TreeWalker::
TreeWalker(DocAccessible* aDocument, nsIContent* aAnchorNode) :
mDoc(aDocument), mContext(nullptr), mAnchorNode(aAnchorNode),
TreeWalker::TreeWalker(DocAccessible* aDocument, nsIContent* aAnchorNode)
: mDoc(aDocument),
mContext(nullptr),
mAnchorNode(aAnchorNode),
mARIAOwnsIdx(0),
mChildFilter(nsIContent::eSkipPlaceholderContent | nsIContent::eAllChildren),
mChildFilter(nsIContent::eSkipPlaceholderContent |
nsIContent::eAllChildren),
mFlags(eWalkCache),
mPhase(eAtStart)
{
mPhase(eAtStart) {
MOZ_ASSERT(aAnchorNode, "No anchor node for the accessible tree walker");
MOZ_COUNT_CTOR(TreeWalker);
}
TreeWalker::~TreeWalker()
{
MOZ_COUNT_DTOR(TreeWalker);
}
TreeWalker::~TreeWalker() { MOZ_COUNT_DTOR(TreeWalker); }
Accessible*
TreeWalker::Scope(nsIContent* aAnchorNode)
{
Accessible* TreeWalker::Scope(nsIContent* aAnchorNode) {
Reset();
mAnchorNode = aAnchorNode;
@@ -88,9 +88,7 @@ TreeWalker::Scope(nsIContent* aAnchorNode)
return skipSubtree ? nullptr : Next();
}
bool
TreeWalker::Seek(nsIContent* aChildNode)
{
bool TreeWalker::Seek(nsIContent* aChildNode) {
MOZ_ASSERT(aChildNode, "Child cannot be null");
Reset();
@@ -104,8 +102,9 @@ TreeWalker::Seek(nsIContent* aChildNode)
do {
childNode = parentNode->AsContent();
parentNode = childNode->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) &&
(mChildFilter & nsIContent::eAllButXBL) ?
childNode->GetParentNode() : childNode->GetFlattenedTreeParent();
(mChildFilter & nsIContent::eAllButXBL)
? childNode->GetParentNode()
: childNode->GetFlattenedTreeParent();
if (!parentNode || !parentNode->IsElement()) {
return false;
@@ -114,7 +113,8 @@ TreeWalker::Seek(nsIContent* aChildNode)
// If ARIA owned child.
Accessible* child = mDoc->GetAccessible(childNode);
if (child && child->IsRelocated()) {
MOZ_ASSERT(!(mFlags & eScoped),
MOZ_ASSERT(
!(mFlags & eScoped),
"Walker should not be scoped when seeking into relocated children");
if (child->Parent() != mContext) {
return false;
@@ -122,7 +122,8 @@ TreeWalker::Seek(nsIContent* aChildNode)
Accessible* ownedChild = nullptr;
while ((ownedChild = mDoc->ARIAOwnedAt(mContext, mARIAOwnsIdx++)) &&
ownedChild != child);
ownedChild != child)
;
MOZ_ASSERT(ownedChild, "A child has to be in ARIA owned elements");
mPhase = eAtARIAOwns;
@@ -130,7 +131,8 @@ TreeWalker::Seek(nsIContent* aChildNode)
}
// Look in DOM.
dom::AllChildrenIterator* iter = PrependState(parentNode->AsElement(), true);
dom::AllChildrenIterator* iter =
PrependState(parentNode->AsElement(), true);
if (!iter->Seek(childNode)) {
return false;
}
@@ -144,9 +146,7 @@ TreeWalker::Seek(nsIContent* aChildNode)
return false;
}
Accessible*
TreeWalker::Next()
{
Accessible* TreeWalker::Next() {
if (mStateStack.IsEmpty()) {
if (mPhase == eAtEnd) {
return nullptr;
@@ -208,8 +208,7 @@ TreeWalker::Next()
nsINode* contextNode = mContext->GetNode();
while (mAnchorNode != contextNode) {
nsINode* parentNode = mAnchorNode->GetFlattenedTreeParent();
if (!parentNode || !parentNode->IsElement())
return nullptr;
if (!parentNode || !parentNode->IsElement()) return nullptr;
nsIContent* parent = parentNode->AsElement();
top = PushState(parent, true);
@@ -228,9 +227,7 @@ TreeWalker::Next()
return Next();
}
Accessible*
TreeWalker::Prev()
{
Accessible* TreeWalker::Prev() {
if (mStateStack.IsEmpty()) {
if (mPhase == eAtStart || mPhase == eAtDOM) {
mPhase = eAtStart;
@@ -309,9 +306,8 @@ TreeWalker::Prev()
return nullptr;
}
Accessible*
TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags, bool* aSkipSubtree)
{
Accessible* TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags,
bool* aSkipSubtree) {
// Ignore the accessible and its subtree if it was repositioned by means
// of aria-owns.
Accessible* child = mDoc->GetAccessible(aNode);
@@ -342,9 +338,7 @@ TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags, bool* aSkipSubtree
return nullptr;
}
dom::AllChildrenIterator*
TreeWalker::PopState()
{
dom::AllChildrenIterator* TreeWalker::PopState() {
mStateStack.RemoveLastElement();
return mStateStack.IsEmpty() ? nullptr : &mStateStack.LastElement();
}

View File

@@ -22,9 +22,8 @@ class DocAccessible;
/**
* This class is used to walk the DOM tree to create accessible tree.
*/
class TreeWalker final
{
public:
class TreeWalker final {
public:
enum {
// used to walk the existing tree of the given node
eWalkCache = 1,
@@ -46,7 +45,8 @@ public:
* @param aAnchorNode [in] the node the search will be prepared relative to
* @param aFlags [in] flags (see enum above)
*/
TreeWalker(Accessible* aContext, nsIContent* aAnchorNode, uint32_t aFlags = eWalkCache);
TreeWalker(Accessible* aContext, nsIContent* aAnchorNode,
uint32_t aFlags = eWalkCache);
/**
* Navigates the accessible children within the anchor node subtree.
@@ -64,8 +64,7 @@ public:
/**
* Resets the walker state.
*/
void Reset()
{
void Reset() {
mPhase = eAtStart;
mStateStack.Clear();
mARIAOwnsIdx = 0;
@@ -89,10 +88,10 @@ public:
Accessible* Context() const { return mContext; }
DocAccessible* Document() const { return mDoc; }
private:
private:
TreeWalker();
TreeWalker(const TreeWalker&);
TreeWalker& operator =(const TreeWalker&);
TreeWalker& operator=(const TreeWalker&);
/**
* Return an accessible for the given node if any.
@@ -108,16 +107,14 @@ private:
* accessible children search.
*/
dom::AllChildrenIterator* PushState(nsIContent* aContent,
bool aStartAtBeginning)
{
bool aStartAtBeginning) {
return mStateStack.AppendElement(
dom::AllChildrenIterator(aContent, mChildFilter, aStartAtBeginning));
}
dom::AllChildrenIterator* PrependState(nsIContent* aContent,
bool aStartAtBeginning)
{
return mStateStack.InsertElementAt(0,
dom::AllChildrenIterator(aContent, mChildFilter, aStartAtBeginning));
bool aStartAtBeginning) {
return mStateStack.InsertElementAt(
0, dom::AllChildrenIterator(aContent, mChildFilter, aStartAtBeginning));
}
/**
@@ -135,12 +132,7 @@ private:
int32_t mChildFilter;
uint32_t mFlags;
enum Phase {
eAtStart,
eAtDOM,
eAtARIAOwns,
eAtEnd
};
enum Phase { eAtStart, eAtDOM, eAtARIAOwns, eAtEnd };
Phase mPhase;
};

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