Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset
This commit is contained in:
48
.hg-format-source
Normal file
48
.hg-format-source
Normal 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"}
|
||||||
@@ -16,7 +16,7 @@ namespace a11y {
|
|||||||
typedef class ARIAGridAccessible ARIAGridAccessibleWrap;
|
typedef class ARIAGridAccessible ARIAGridAccessibleWrap;
|
||||||
typedef class ARIAGridCellAccessible ARIAGridCellAccessibleWrap;
|
typedef class ARIAGridCellAccessible ARIAGridCellAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ IDSet sIDSet(31UL);
|
|||||||
// construction
|
// construction
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
AccessibleWrap::AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc)
|
AccessibleWrap::AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc)
|
||||||
: Accessible(aContent, aDoc)
|
: Accessible(aContent, aDoc) {
|
||||||
{
|
|
||||||
if (aDoc) {
|
if (aDoc) {
|
||||||
mID = AcquireID();
|
mID = AcquireID();
|
||||||
DocAccessibleWrap* doc = static_cast<DocAccessibleWrap*>(aDoc);
|
DocAccessibleWrap* doc = static_cast<DocAccessibleWrap*>(aDoc);
|
||||||
@@ -43,25 +42,27 @@ AccessibleWrap::AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc)
|
|||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
AccessibleWrap::~AccessibleWrap() {}
|
AccessibleWrap::~AccessibleWrap() {}
|
||||||
|
|
||||||
nsresult
|
nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) {
|
||||||
AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
|
||||||
{
|
|
||||||
auto accessible = static_cast<AccessibleWrap*>(aEvent->GetAccessible());
|
auto accessible = static_cast<AccessibleWrap*>(aEvent->GetAccessible());
|
||||||
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
|
||||||
DocAccessibleWrap* doc = static_cast<DocAccessibleWrap*>(accessible->Document());
|
DocAccessibleWrap* doc =
|
||||||
|
static_cast<DocAccessibleWrap*>(accessible->Document());
|
||||||
if (doc) {
|
if (doc) {
|
||||||
switch (aEvent->GetEventType()) {
|
switch (aEvent->GetEventType()) {
|
||||||
case nsIAccessibleEvent::EVENT_FOCUS: {
|
case nsIAccessibleEvent::EVENT_FOCUS: {
|
||||||
if (DocAccessibleWrap* topContentDoc = doc->GetTopLevelContentDoc(accessible)) {
|
if (DocAccessibleWrap* topContentDoc =
|
||||||
|
doc->GetTopLevelContentDoc(accessible)) {
|
||||||
topContentDoc->CacheFocusPath(accessible);
|
topContentDoc->CacheFocusPath(accessible);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED: {
|
case nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED: {
|
||||||
AccVCChangeEvent* vcEvent = downcast_accEvent(aEvent);
|
AccVCChangeEvent* vcEvent = downcast_accEvent(aEvent);
|
||||||
auto newPosition = static_cast<AccessibleWrap*>(vcEvent->NewAccessible());
|
auto newPosition =
|
||||||
|
static_cast<AccessibleWrap*>(vcEvent->NewAccessible());
|
||||||
if (newPosition) {
|
if (newPosition) {
|
||||||
if (DocAccessibleWrap* topContentDoc = doc->GetTopLevelContentDoc(accessible)) {
|
if (DocAccessibleWrap* topContentDoc =
|
||||||
|
doc->GetTopLevelContentDoc(accessible)) {
|
||||||
topContentDoc->CacheFocusPath(newPosition);
|
topContentDoc->CacheFocusPath(newPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +91,7 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(accessible);
|
SessionAccessibility::GetInstanceFor(accessible);
|
||||||
if (!sessionAcc) {
|
if (!sessionAcc) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -115,7 +116,7 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
|||||||
|
|
||||||
if (vcEvent->BoundaryType() != nsIAccessiblePivot::NO_BOUNDARY) {
|
if (vcEvent->BoundaryType() != nsIAccessiblePivot::NO_BOUNDARY) {
|
||||||
sessionAcc->SendTextTraversedEvent(
|
sessionAcc->SendTextTraversedEvent(
|
||||||
newPosition, vcEvent->NewStartOffset(), vcEvent->NewEndOffset());
|
newPosition, vcEvent->NewStartOffset(), vcEvent->NewEndOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -129,12 +130,10 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
|||||||
case nsIAccessibleEvent::EVENT_TEXT_INSERTED:
|
case nsIAccessibleEvent::EVENT_TEXT_INSERTED:
|
||||||
case nsIAccessibleEvent::EVENT_TEXT_REMOVED: {
|
case nsIAccessibleEvent::EVENT_TEXT_REMOVED: {
|
||||||
AccTextChangeEvent* event = downcast_accEvent(aEvent);
|
AccTextChangeEvent* event = downcast_accEvent(aEvent);
|
||||||
sessionAcc->SendTextChangedEvent(accessible,
|
sessionAcc->SendTextChangedEvent(
|
||||||
event->ModifiedText(),
|
accessible, event->ModifiedText(), event->GetStartOffset(),
|
||||||
event->GetStartOffset(),
|
event->GetLength(), event->IsTextInserted(),
|
||||||
event->GetLength(),
|
event->IsFromUserInput());
|
||||||
event->IsTextInserted(),
|
|
||||||
event->IsFromUserInput());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsIAccessibleEvent::EVENT_STATE_CHANGE: {
|
case nsIAccessibleEvent::EVENT_STATE_CHANGE: {
|
||||||
@@ -155,10 +154,8 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
|||||||
}
|
}
|
||||||
case nsIAccessibleEvent::EVENT_SCROLLING: {
|
case nsIAccessibleEvent::EVENT_SCROLLING: {
|
||||||
AccScrollingEvent* event = downcast_accEvent(aEvent);
|
AccScrollingEvent* event = downcast_accEvent(aEvent);
|
||||||
sessionAcc->SendScrollingEvent(accessible,
|
sessionAcc->SendScrollingEvent(accessible, event->ScrollX(),
|
||||||
event->ScrollX(),
|
event->ScrollY(), event->MaxScrollX(),
|
||||||
event->ScrollY(),
|
|
||||||
event->MaxScrollX(),
|
|
||||||
event->MaxScrollY());
|
event->MaxScrollY());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -176,9 +173,7 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccessibleWrap::Shutdown() {
|
||||||
AccessibleWrap::Shutdown()
|
|
||||||
{
|
|
||||||
if (mDoc) {
|
if (mDoc) {
|
||||||
if (mID > 0) {
|
if (mID > 0) {
|
||||||
if (auto doc = static_cast<DocAccessibleWrap*>(mDoc.get())) {
|
if (auto doc = static_cast<DocAccessibleWrap*>(mDoc.get())) {
|
||||||
@@ -192,27 +187,17 @@ AccessibleWrap::Shutdown()
|
|||||||
Accessible::Shutdown();
|
Accessible::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t AccessibleWrap::AcquireID() { return sIDSet.GetID(); }
|
||||||
AccessibleWrap::AcquireID()
|
|
||||||
{
|
|
||||||
return sIDSet.GetID();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void AccessibleWrap::ReleaseID(int32_t aID) { sIDSet.ReleaseID(aID); }
|
||||||
AccessibleWrap::ReleaseID(int32_t aID)
|
|
||||||
{
|
|
||||||
sIDSet.ReleaseID(aID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void AccessibleWrap::SetTextContents(const nsAString& aText) {
|
||||||
AccessibleWrap::SetTextContents(const nsAString& aText) {
|
|
||||||
if (IsHyperText()) {
|
if (IsHyperText()) {
|
||||||
AsHyperText()->ReplaceText(aText);
|
AsHyperText()->ReplaceText(aText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccessibleWrap::GetTextContents(nsAString& aText) {
|
||||||
AccessibleWrap::GetTextContents(nsAString& aText) {
|
|
||||||
// For now it is a simple wrapper for getting entire range of TextSubstring.
|
// 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.
|
// In the future this may be smarter and retrieve a flattened string.
|
||||||
if (IsHyperText()) {
|
if (IsHyperText()) {
|
||||||
@@ -220,8 +205,8 @@ AccessibleWrap::GetTextContents(nsAString& aText) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool AccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
|
||||||
AccessibleWrap::GetSelectionBounds(int32_t* aStartOffset, int32_t* aEndOffset) {
|
int32_t* aEndOffset) {
|
||||||
if (IsHyperText()) {
|
if (IsHyperText()) {
|
||||||
return AsHyperText()->SelectionBoundsAt(0, aStartOffset, aEndOffset);
|
return AsHyperText()->SelectionBoundsAt(0, aStartOffset, aEndOffset);
|
||||||
}
|
}
|
||||||
@@ -229,9 +214,7 @@ AccessibleWrap::GetSelectionBounds(int32_t* aStartOffset, int32_t* aEndOffset) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t AccessibleWrap::GetFlags(role aRole, uint64_t aState) {
|
||||||
AccessibleWrap::GetFlags(role aRole, uint64_t aState)
|
|
||||||
{
|
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
if (aState & states::CHECKABLE) {
|
if (aState & states::CHECKABLE) {
|
||||||
flags |= java::SessionAccessibility::FLAG_CHECKABLE;
|
flags |= java::SessionAccessibility::FLAG_CHECKABLE;
|
||||||
@@ -288,15 +271,12 @@ AccessibleWrap::GetFlags(role aRole, uint64_t aState)
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccessibleWrap::GetRoleDescription(role aRole, nsAString& aGeckoRole,
|
||||||
AccessibleWrap::GetRoleDescription(role aRole,
|
nsAString& aRoleDescription) {
|
||||||
nsAString& aGeckoRole,
|
|
||||||
nsAString& aRoleDescription)
|
|
||||||
{
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIStringBundleService> sbs =
|
nsCOMPtr<nsIStringBundleService> sbs =
|
||||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
|
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Failed to get string bundle service");
|
NS_WARNING("Failed to get string bundle service");
|
||||||
return;
|
return;
|
||||||
@@ -310,39 +290,31 @@ AccessibleWrap::GetRoleDescription(role aRole,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GetAccService()->GetStringRole(aRole, aGeckoRole);
|
GetAccService()->GetStringRole(aRole, aGeckoRole);
|
||||||
rv = bundle->GetStringFromName(NS_ConvertUTF16toUTF8(aGeckoRole).get(), aRoleDescription);
|
rv = bundle->GetStringFromName(NS_ConvertUTF16toUTF8(aGeckoRole).get(),
|
||||||
|
aRoleDescription);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
aRoleDescription.AssignLiteral("");
|
aRoleDescription.AssignLiteral("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIPersistentProperties>
|
already_AddRefed<nsIPersistentProperties>
|
||||||
AccessibleWrap::AttributeArrayToProperties(const nsTArray<Attribute>& aAttributes)
|
AccessibleWrap::AttributeArrayToProperties(
|
||||||
{
|
const nsTArray<Attribute>& aAttributes) {
|
||||||
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
|
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
|
||||||
nsAutoString unused;
|
nsAutoString unused;
|
||||||
|
|
||||||
for (size_t i = 0; i < aAttributes.Length(); i++) {
|
for (size_t i = 0; i < aAttributes.Length(); i++) {
|
||||||
props->SetStringProperty(aAttributes.ElementAt(i).Name(),
|
props->SetStringProperty(aAttributes.ElementAt(i).Name(),
|
||||||
aAttributes.ElementAt(i).Value(),
|
aAttributes.ElementAt(i).Value(), unused);
|
||||||
unused);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.forget();
|
return props.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t AccessibleWrap::GetAndroidClass(role aRole) {
|
||||||
AccessibleWrap::GetAndroidClass(role aRole)
|
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, \
|
||||||
{
|
androidClass, nameRule) \
|
||||||
#define ROLE(geckoRole, \
|
case roles::geckoRole: \
|
||||||
stringRole, \
|
|
||||||
atkRole, \
|
|
||||||
macRole, \
|
|
||||||
msaaRole, \
|
|
||||||
ia2Role, \
|
|
||||||
androidClass, \
|
|
||||||
nameRule) \
|
|
||||||
case roles::geckoRole: \
|
|
||||||
return androidClass;
|
return androidClass;
|
||||||
|
|
||||||
switch (aRole) {
|
switch (aRole) {
|
||||||
@@ -354,11 +326,10 @@ AccessibleWrap::GetAndroidClass(role aRole)
|
|||||||
#undef ROLE
|
#undef ROLE
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t AccessibleWrap::GetInputType(const nsString& aInputTypeAttr) {
|
||||||
AccessibleWrap::GetInputType(const nsString& aInputTypeAttr)
|
|
||||||
{
|
|
||||||
if (aInputTypeAttr.EqualsIgnoreCase("email")) {
|
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")) {
|
if (aInputTypeAttr.EqualsIgnoreCase("number")) {
|
||||||
@@ -366,7 +337,8 @@ AccessibleWrap::GetInputType(const nsString& aInputTypeAttr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aInputTypeAttr.EqualsIgnoreCase("password")) {
|
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")) {
|
if (aInputTypeAttr.EqualsIgnoreCase("tel")) {
|
||||||
@@ -374,19 +346,19 @@ AccessibleWrap::GetInputType(const nsString& aInputTypeAttr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aInputTypeAttr.EqualsIgnoreCase("text")) {
|
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")) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
|
||||||
AccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID)
|
|
||||||
{
|
|
||||||
if (mContent) {
|
if (mContent) {
|
||||||
nsAtom* id = mContent->GetID();
|
nsAtom* id = mContent->GetID();
|
||||||
if (id) {
|
if (id) {
|
||||||
@@ -395,10 +367,8 @@ AccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool AccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
|
||||||
AccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
|
double* aMaxVal, double* aStep) {
|
||||||
double* aMaxVal, double* aStep)
|
|
||||||
{
|
|
||||||
if (HasNumericValue()) {
|
if (HasNumericValue()) {
|
||||||
*aCurVal = CurValue();
|
*aCurVal = CurValue();
|
||||||
*aMinVal = MinValue();
|
*aMinVal = MinValue();
|
||||||
@@ -410,9 +380,7 @@ AccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::java::GeckoBundle::LocalRef
|
mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle() {
|
||||||
AccessibleWrap::ToBundle()
|
|
||||||
{
|
|
||||||
nsAutoString name;
|
nsAutoString name;
|
||||||
Name(name);
|
Name(name);
|
||||||
nsAutoString textValue;
|
nsAutoString textValue;
|
||||||
@@ -428,22 +396,15 @@ AccessibleWrap::ToBundle()
|
|||||||
|
|
||||||
nsCOMPtr<nsIPersistentProperties> attributes = Attributes();
|
nsCOMPtr<nsIPersistentProperties> attributes = Attributes();
|
||||||
|
|
||||||
return ToBundle(State(), Bounds(), name, textValue, nodeID,
|
return ToBundle(State(), Bounds(), name, textValue, nodeID, curValue,
|
||||||
curValue, minValue, maxValue, step, attributes);
|
minValue, maxValue, step, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::java::GeckoBundle::LocalRef
|
mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
|
||||||
AccessibleWrap::ToBundle(const uint64_t aState,
|
const uint64_t aState, const nsIntRect& aBounds, const nsString& aName,
|
||||||
const nsIntRect& aBounds,
|
const nsString& aTextValue, const nsString& aDOMNodeID,
|
||||||
const nsString& aName,
|
const double& aCurVal, const double& aMinVal, const double& aMaxVal,
|
||||||
const nsString& aTextValue,
|
const double& aStep, nsIPersistentProperties* aAttributes) {
|
||||||
const nsString& aDOMNodeID,
|
|
||||||
const double& aCurVal,
|
|
||||||
const double& aMinVal,
|
|
||||||
const double& aMaxVal,
|
|
||||||
const double& aStep,
|
|
||||||
nsIPersistentProperties* aAttributes)
|
|
||||||
{
|
|
||||||
if (!IsProxy() && IsDefunct()) {
|
if (!IsProxy() && IsDefunct()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -452,13 +413,15 @@ AccessibleWrap::ToBundle(const uint64_t aState,
|
|||||||
GECKOBUNDLE_PUT(nodeInfo, "id", java::sdk::Integer::ValueOf(VirtualViewID()));
|
GECKOBUNDLE_PUT(nodeInfo, "id", java::sdk::Integer::ValueOf(VirtualViewID()));
|
||||||
|
|
||||||
AccessibleWrap* parent = WrapperParent();
|
AccessibleWrap* parent = WrapperParent();
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "parentId",
|
GECKOBUNDLE_PUT(
|
||||||
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
|
nodeInfo, "parentId",
|
||||||
|
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
|
||||||
|
|
||||||
role role = WrapperRole();
|
role role = WrapperRole();
|
||||||
uint32_t flags = GetFlags(role, aState);
|
uint32_t flags = GetFlags(role, aState);
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "flags", java::sdk::Integer::ValueOf(flags));
|
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) {
|
if (aState & states::EDITABLE) {
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "hint", jni::StringParam(aName));
|
GECKOBUNDLE_PUT(nodeInfo, "hint", jni::StringParam(aName));
|
||||||
@@ -473,36 +436,35 @@ AccessibleWrap::ToBundle(const uint64_t aState,
|
|||||||
GetRoleDescription(role, geckoRole, roleDescription);
|
GetRoleDescription(role, geckoRole, roleDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(nodeInfo, "roleDescription",
|
||||||
nodeInfo, "roleDescription", jni::StringParam(roleDescription));
|
jni::StringParam(roleDescription));
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
|
GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
|
||||||
|
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(nodeInfo, "roleDescription",
|
||||||
nodeInfo, "roleDescription", jni::StringParam(roleDescription));
|
jni::StringParam(roleDescription));
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
|
GECKOBUNDLE_PUT(nodeInfo, "geckoRole", jni::StringParam(geckoRole));
|
||||||
|
|
||||||
if (!aDOMNodeID.IsEmpty()) {
|
if (!aDOMNodeID.IsEmpty()) {
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(nodeInfo, "viewIdResourceName",
|
||||||
nodeInfo, "viewIdResourceName", jni::StringParam(aDOMNodeID));
|
jni::StringParam(aDOMNodeID));
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIntRect bounds = Bounds();
|
nsIntRect bounds = Bounds();
|
||||||
const int32_t data[4] = {
|
const int32_t data[4] = {bounds.x, bounds.y, bounds.x + bounds.width,
|
||||||
bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height
|
bounds.y + bounds.height};
|
||||||
};
|
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "bounds", jni::IntArray::New(data, 4));
|
GECKOBUNDLE_PUT(nodeInfo, "bounds", jni::IntArray::New(data, 4));
|
||||||
|
|
||||||
if (HasNumericValue()) {
|
if (HasNumericValue()) {
|
||||||
GECKOBUNDLE_START(rangeInfo);
|
GECKOBUNDLE_START(rangeInfo);
|
||||||
if (aMaxVal == 1 && aMinVal == 0) {
|
if (aMaxVal == 1 && aMinVal == 0) {
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(rangeInfo, "type",
|
||||||
rangeInfo, "type", java::sdk::Integer::ValueOf(2)); // percent
|
java::sdk::Integer::ValueOf(2)); // percent
|
||||||
} else if (std::round(aStep) != aStep) {
|
} else if (std::round(aStep) != aStep) {
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(rangeInfo, "type",
|
||||||
rangeInfo, "type", java::sdk::Integer::ValueOf(1)); // float
|
java::sdk::Integer::ValueOf(1)); // float
|
||||||
} else {
|
} else {
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(rangeInfo, "type",
|
||||||
rangeInfo, "type", java::sdk::Integer::ValueOf(0)); // integer
|
java::sdk::Integer::ValueOf(0)); // integer
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsNaN(aCurVal)) {
|
if (!IsNaN(aCurVal)) {
|
||||||
@@ -523,23 +485,25 @@ AccessibleWrap::ToBundle(const uint64_t aState,
|
|||||||
nsAccUtils::GetAccAttr(aAttributes, nsGkAtoms::textInputType, inputTypeAttr);
|
nsAccUtils::GetAccAttr(aAttributes, nsGkAtoms::textInputType, inputTypeAttr);
|
||||||
int32_t inputType = GetInputType(inputTypeAttr);
|
int32_t inputType = GetInputType(inputTypeAttr);
|
||||||
if (inputType) {
|
if (inputType) {
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "inputType", java::sdk::Integer::ValueOf(inputType));
|
GECKOBUNDLE_PUT(nodeInfo, "inputType",
|
||||||
|
java::sdk::Integer::ValueOf(inputType));
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString posinset;
|
nsString posinset;
|
||||||
nsresult rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("posinset"), posinset);
|
nsresult rv =
|
||||||
|
aAttributes->GetStringProperty(NS_LITERAL_CSTRING("posinset"), posinset);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
int32_t rowIndex;
|
int32_t rowIndex;
|
||||||
if (sscanf(NS_ConvertUTF16toUTF8(posinset).get(), "%d", &rowIndex) > 0) {
|
if (sscanf(NS_ConvertUTF16toUTF8(posinset).get(), "%d", &rowIndex) > 0) {
|
||||||
GECKOBUNDLE_START(collectionItemInfo);
|
GECKOBUNDLE_START(collectionItemInfo);
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(collectionItemInfo, "rowIndex",
|
||||||
collectionItemInfo, "rowIndex", java::sdk::Integer::ValueOf(rowIndex));
|
java::sdk::Integer::ValueOf(rowIndex));
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(collectionItemInfo, "columnIndex",
|
||||||
collectionItemInfo, "columnIndex", java::sdk::Integer::ValueOf(0));
|
java::sdk::Integer::ValueOf(0));
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(collectionItemInfo, "rowSpan",
|
||||||
collectionItemInfo, "rowSpan", java::sdk::Integer::ValueOf(1));
|
java::sdk::Integer::ValueOf(1));
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(collectionItemInfo, "columnSpan",
|
||||||
collectionItemInfo, "columnSpan", java::sdk::Integer::ValueOf(1));
|
java::sdk::Integer::ValueOf(1));
|
||||||
GECKOBUNDLE_FINISH(collectionItemInfo);
|
GECKOBUNDLE_FINISH(collectionItemInfo);
|
||||||
|
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "collectionItemInfo", collectionItemInfo);
|
GECKOBUNDLE_PUT(nodeInfo, "collectionItemInfo", collectionItemInfo);
|
||||||
@@ -553,23 +517,22 @@ AccessibleWrap::ToBundle(const uint64_t aState,
|
|||||||
int32_t rowCount;
|
int32_t rowCount;
|
||||||
if (sscanf(NS_ConvertUTF16toUTF8(colSize).get(), "%d", &rowCount) > 0) {
|
if (sscanf(NS_ConvertUTF16toUTF8(colSize).get(), "%d", &rowCount) > 0) {
|
||||||
GECKOBUNDLE_START(collectionInfo);
|
GECKOBUNDLE_START(collectionInfo);
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(collectionInfo, "rowCount",
|
||||||
collectionInfo, "rowCount", java::sdk::Integer::ValueOf(rowCount));
|
java::sdk::Integer::ValueOf(rowCount));
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(collectionInfo, "columnCount",
|
||||||
collectionInfo, "columnCount", java::sdk::Integer::ValueOf(1));
|
java::sdk::Integer::ValueOf(1));
|
||||||
|
|
||||||
nsString unused;
|
nsString unused;
|
||||||
rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("hierarchical"),
|
rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("hierarchical"),
|
||||||
unused);
|
unused);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
GECKOBUNDLE_PUT(
|
GECKOBUNDLE_PUT(collectionInfo, "isHierarchical",
|
||||||
collectionInfo, "isHierarchical", java::sdk::Boolean::TRUE());
|
java::sdk::Boolean::TRUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSelect()) {
|
if (IsSelect()) {
|
||||||
int32_t selectionMode = (aState & states::MULTISELECTABLE) ? 2 : 1;
|
int32_t selectionMode = (aState & states::MULTISELECTABLE) ? 2 : 1;
|
||||||
GECKOBUNDLE_PUT(collectionInfo,
|
GECKOBUNDLE_PUT(collectionInfo, "selectionMode",
|
||||||
"selectionMode",
|
|
||||||
java::sdk::Integer::ValueOf(selectionMode));
|
java::sdk::Integer::ValueOf(selectionMode));
|
||||||
}
|
}
|
||||||
GECKOBUNDLE_FINISH(collectionInfo);
|
GECKOBUNDLE_FINISH(collectionInfo);
|
||||||
@@ -585,37 +548,34 @@ AccessibleWrap::ToBundle(const uint64_t aState,
|
|||||||
children.AppendElement(child->VirtualViewID());
|
children.AppendElement(child->VirtualViewID());
|
||||||
}
|
}
|
||||||
|
|
||||||
GECKOBUNDLE_PUT(nodeInfo,
|
GECKOBUNDLE_PUT(nodeInfo, "children",
|
||||||
"children",
|
|
||||||
jni::IntArray::New(children.Elements(), children.Length()));
|
jni::IntArray::New(children.Elements(), children.Length()));
|
||||||
GECKOBUNDLE_FINISH(nodeInfo);
|
GECKOBUNDLE_FINISH(nodeInfo);
|
||||||
|
|
||||||
return nodeInfo;
|
return nodeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::java::GeckoBundle::LocalRef
|
mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToSmallBundle() {
|
||||||
AccessibleWrap::ToSmallBundle()
|
|
||||||
{
|
|
||||||
return ToSmallBundle(State(), Bounds());
|
return ToSmallBundle(State(), Bounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::java::GeckoBundle::LocalRef
|
mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToSmallBundle(
|
||||||
AccessibleWrap::ToSmallBundle(const uint64_t aState, const nsIntRect& aBounds)
|
const uint64_t aState, const nsIntRect& aBounds) {
|
||||||
{
|
|
||||||
GECKOBUNDLE_START(nodeInfo);
|
GECKOBUNDLE_START(nodeInfo);
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "id", java::sdk::Integer::ValueOf(VirtualViewID()));
|
GECKOBUNDLE_PUT(nodeInfo, "id", java::sdk::Integer::ValueOf(VirtualViewID()));
|
||||||
|
|
||||||
AccessibleWrap* parent = WrapperParent();
|
AccessibleWrap* parent = WrapperParent();
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "parentId",
|
GECKOBUNDLE_PUT(
|
||||||
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
|
nodeInfo, "parentId",
|
||||||
|
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
|
||||||
|
|
||||||
uint32_t flags = GetFlags(WrapperRole(), aState);
|
uint32_t flags = GetFlags(WrapperRole(), aState);
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "flags", java::sdk::Integer::ValueOf(flags));
|
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] = {
|
const int32_t data[4] = {aBounds.x, aBounds.y, aBounds.x + aBounds.width,
|
||||||
aBounds.x, aBounds.y, aBounds.x + aBounds.width, aBounds.y + aBounds.height
|
aBounds.y + aBounds.height};
|
||||||
};
|
|
||||||
GECKOBUNDLE_PUT(nodeInfo, "bounds", jni::IntArray::New(data, 4));
|
GECKOBUNDLE_PUT(nodeInfo, "bounds", jni::IntArray::New(data, 4));
|
||||||
|
|
||||||
auto childCount = ChildCount();
|
auto childCount = ChildCount();
|
||||||
@@ -625,8 +585,7 @@ AccessibleWrap::ToSmallBundle(const uint64_t aState, const nsIntRect& aBounds)
|
|||||||
children.AppendElement(child->VirtualViewID());
|
children.AppendElement(child->VirtualViewID());
|
||||||
}
|
}
|
||||||
|
|
||||||
GECKOBUNDLE_PUT(nodeInfo,
|
GECKOBUNDLE_PUT(nodeInfo, "children",
|
||||||
"children",
|
|
||||||
jni::IntArray::New(children.Elements(), children.Length()));
|
jni::IntArray::New(children.Elements(), children.Length()));
|
||||||
|
|
||||||
GECKOBUNDLE_FINISH(nodeInfo);
|
GECKOBUNDLE_FINISH(nodeInfo);
|
||||||
|
|||||||
@@ -14,9 +14,8 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
class AccessibleWrap : public Accessible
|
class AccessibleWrap : public Accessible {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
|
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
|
||||||
virtual ~AccessibleWrap();
|
virtual ~AccessibleWrap();
|
||||||
|
|
||||||
@@ -33,36 +32,30 @@ public:
|
|||||||
|
|
||||||
mozilla::java::GeckoBundle::LocalRef ToBundle();
|
mozilla::java::GeckoBundle::LocalRef ToBundle();
|
||||||
|
|
||||||
mozilla::java::GeckoBundle::LocalRef ToBundle(const uint64_t aState,
|
mozilla::java::GeckoBundle::LocalRef ToBundle(
|
||||||
const nsIntRect& aBounds,
|
const uint64_t aState, const nsIntRect& aBounds, const nsString& aName,
|
||||||
const nsString& aName,
|
const nsString& aTextValue, const nsString& aDOMNodeID,
|
||||||
const nsString& aTextValue,
|
const double& aCurVal, const double& aMinVal, const double& aMaxVal,
|
||||||
const nsString& aDOMNodeID,
|
const double& aStep, nsIPersistentProperties* aAttributes);
|
||||||
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();
|
mozilla::java::GeckoBundle::LocalRef ToSmallBundle();
|
||||||
|
|
||||||
virtual void WrapperDOMNodeID(nsString& aDOMNodeID);
|
virtual void WrapperDOMNodeID(nsString& aDOMNodeID);
|
||||||
|
|
||||||
int32_t AndroidClass()
|
int32_t AndroidClass() {
|
||||||
{
|
|
||||||
return mID == kNoID ? java::SessionAccessibility::CLASSNAME_WEBVIEW
|
return mID == kNoID ? java::SessionAccessibility::CLASSNAME_WEBVIEW
|
||||||
: GetAndroidClass(WrapperRole());
|
: GetAndroidClass(WrapperRole());
|
||||||
}
|
}
|
||||||
|
|
||||||
static already_AddRefed<nsIPersistentProperties> AttributeArrayToProperties(
|
static already_AddRefed<nsIPersistentProperties> AttributeArrayToProperties(
|
||||||
const nsTArray<Attribute>& aAttributes);
|
const nsTArray<Attribute>& aAttributes);
|
||||||
|
|
||||||
static const int32_t kNoID = -1;
|
static const int32_t kNoID = -1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// IDs should be a positive 32bit integer.
|
// IDs should be a positive 32bit integer.
|
||||||
static int32_t AcquireID();
|
static int32_t AcquireID();
|
||||||
static void ReleaseID(int32_t aID);
|
static void ReleaseID(int32_t aID);
|
||||||
@@ -73,26 +66,26 @@ protected:
|
|||||||
|
|
||||||
int32_t mID;
|
int32_t mID;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual AccessibleWrap* WrapperParent() { return static_cast<AccessibleWrap*>(Parent()); }
|
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(); }
|
virtual role WrapperRole() { return Role(); }
|
||||||
|
|
||||||
static void GetRoleDescription(role aRole,
|
static void GetRoleDescription(role aRole, nsAString& aGeckoRole,
|
||||||
nsAString& aGeckoRole,
|
|
||||||
nsAString& aRoleDescription);
|
nsAString& aRoleDescription);
|
||||||
static uint32_t GetFlags(role aRole, uint64_t aState);
|
static uint32_t GetFlags(role aRole, uint64_t aState);
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline AccessibleWrap*
|
static inline AccessibleWrap* WrapperFor(const ProxyAccessible* aProxy) {
|
||||||
WrapperFor(const ProxyAccessible* aProxy)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
|
return reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace mozilla {
|
|||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
typedef ApplicationAccessible ApplicationAccessibleWrap;
|
typedef ApplicationAccessible ApplicationAccessibleWrap;
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ const uint32_t kCacheRefreshInterval = 500;
|
|||||||
|
|
||||||
DocAccessibleWrap::DocAccessibleWrap(nsIDocument* aDocument,
|
DocAccessibleWrap::DocAccessibleWrap(nsIDocument* aDocument,
|
||||||
nsIPresShell* aPresShell)
|
nsIPresShell* aPresShell)
|
||||||
: DocAccessible(aDocument, aPresShell)
|
: DocAccessible(aDocument, aPresShell) {
|
||||||
{
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(aDocument->GetDocShell());
|
nsCOMPtr<nsIDocShellTreeItem> treeItem(aDocument->GetDocShell());
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
||||||
@@ -42,9 +41,7 @@ DocAccessibleWrap::DocAccessibleWrap(nsIDocument* aDocument,
|
|||||||
|
|
||||||
DocAccessibleWrap::~DocAccessibleWrap() {}
|
DocAccessibleWrap::~DocAccessibleWrap() {}
|
||||||
|
|
||||||
AccessibleWrap*
|
AccessibleWrap* DocAccessibleWrap::GetAccessibleByID(int32_t aID) const {
|
||||||
DocAccessibleWrap::GetAccessibleByID(int32_t aID) const
|
|
||||||
{
|
|
||||||
if (AccessibleWrap* acc = mIDToAccessibleMap.Get(aID)) {
|
if (AccessibleWrap* acc = mIDToAccessibleMap.Get(aID)) {
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
@@ -60,17 +57,13 @@ DocAccessibleWrap::GetAccessibleByID(int32_t aID) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocAccessibleWrap::DoInitialUpdate() {
|
||||||
DocAccessibleWrap::DoInitialUpdate()
|
|
||||||
{
|
|
||||||
DocAccessible::DoInitialUpdate();
|
DocAccessible::DoInitialUpdate();
|
||||||
CacheViewport();
|
CacheViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult DocAccessibleWrap::HandleAccEvent(AccEvent* aEvent) {
|
||||||
DocAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
switch (aEvent->GetEventType()) {
|
||||||
{
|
|
||||||
switch(aEvent->GetEventType()) {
|
|
||||||
case nsIAccessibleEvent::EVENT_SHOW:
|
case nsIAccessibleEvent::EVENT_SHOW:
|
||||||
case nsIAccessibleEvent::EVENT_HIDE:
|
case nsIAccessibleEvent::EVENT_HIDE:
|
||||||
case nsIAccessibleEvent::EVENT_SCROLLING_END:
|
case nsIAccessibleEvent::EVENT_SCROLLING_END:
|
||||||
@@ -86,16 +79,15 @@ DocAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
|||||||
return DocAccessible::HandleAccEvent(aEvent);
|
return DocAccessible::HandleAccEvent(aEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer,
|
||||||
DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
|
void* aDocAccParam) {
|
||||||
{
|
RefPtr<DocAccessibleWrap> docAcc(
|
||||||
RefPtr<DocAccessibleWrap> docAcc(dont_AddRef(
|
dont_AddRef(reinterpret_cast<DocAccessibleWrap*>(aDocAccParam)));
|
||||||
reinterpret_cast<DocAccessibleWrap*>(aDocAccParam)));
|
|
||||||
if (!docAcc) {
|
if (!docAcc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIPresShell *presShell = docAcc->PresShell();
|
nsIPresShell* presShell = docAcc->PresShell();
|
||||||
if (!presShell) {
|
if (!presShell) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -109,10 +101,8 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
|
|||||||
nsRect scrollPort = sf ? sf->GetScrollPortRect() : rootFrame->GetRect();
|
nsRect scrollPort = sf ? sf->GetScrollPortRect() : rootFrame->GetRect();
|
||||||
|
|
||||||
nsLayoutUtils::GetFramesForArea(
|
nsLayoutUtils::GetFramesForArea(
|
||||||
presShell->GetRootFrame(),
|
presShell->GetRootFrame(), scrollPort, frames,
|
||||||
scrollPort,
|
nsLayoutUtils::FrameForPointFlags::ONLY_VISIBLE);
|
||||||
frames,
|
|
||||||
nsLayoutUtils::FrameForPointFlags::ONLY_VISIBLE);
|
|
||||||
AccessibleHashtable inViewAccs;
|
AccessibleHashtable inViewAccs;
|
||||||
for (size_t i = 0; i < frames.Length(); i++) {
|
for (size_t i = 0; i < frames.Length(); i++) {
|
||||||
nsIContent* content = frames.ElementAt(i)->GetContent();
|
nsIContent* content = frames.ElementAt(i)->GetContent();
|
||||||
@@ -125,7 +115,8 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
|
|||||||
continue;
|
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())) {
|
if (inViewAccs.Contains(acc->UniqueID())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -138,27 +129,24 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
|
|||||||
nsTArray<BatchData> cacheData(inViewAccs.Count());
|
nsTArray<BatchData> cacheData(inViewAccs.Count());
|
||||||
for (auto iter = inViewAccs.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = inViewAccs.Iter(); !iter.Done(); iter.Next()) {
|
||||||
Accessible* accessible = iter.Data();
|
Accessible* accessible = iter.Data();
|
||||||
auto uid = accessible->IsDoc() && accessible->AsDoc()->IPCDoc() ? 0
|
auto uid = accessible->IsDoc() && accessible->AsDoc()->IPCDoc()
|
||||||
: reinterpret_cast<uint64_t>(accessible->UniqueID());
|
? 0
|
||||||
cacheData.AppendElement(BatchData(accessible->Document()->IPCDoc(),
|
: reinterpret_cast<uint64_t>(accessible->UniqueID());
|
||||||
uid,
|
cacheData.AppendElement(
|
||||||
accessible->State(),
|
BatchData(accessible->Document()->IPCDoc(), uid, accessible->State(),
|
||||||
accessible->Bounds(),
|
accessible->Bounds(), nsString(), nsString(), nsString(),
|
||||||
nsString(),
|
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
|
||||||
nsString(),
|
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
|
||||||
nsString(),
|
nsTArray<Attribute>()));
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
nsTArray<Attribute>()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcDoc->SendBatch(eBatch_Viewport, cacheData);
|
ipcDoc->SendBatch(eBatch_Viewport, cacheData);
|
||||||
} else if (SessionAccessibility* sessionAcc = SessionAccessibility::GetInstanceFor(docAcc)) {
|
} else if (SessionAccessibility* sessionAcc =
|
||||||
|
SessionAccessibility::GetInstanceFor(docAcc)) {
|
||||||
nsTArray<AccessibleWrap*> accessibles(inViewAccs.Count());
|
nsTArray<AccessibleWrap*> accessibles(inViewAccs.Count());
|
||||||
for (auto iter = inViewAccs.Iter(); !iter.Done(); iter.Next()) {
|
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);
|
sessionAcc->ReplaceViewportCache(accessibles);
|
||||||
@@ -169,25 +157,22 @@ DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, void* aDocAccParam)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocAccessibleWrap::CacheViewport() {
|
||||||
DocAccessibleWrap::CacheViewport()
|
|
||||||
{
|
|
||||||
if (VirtualViewID() == kNoID && !mCacheRefreshTimer) {
|
if (VirtualViewID() == kNoID && !mCacheRefreshTimer) {
|
||||||
NS_NewTimerWithFuncCallback(getter_AddRefs(mCacheRefreshTimer),
|
NS_NewTimerWithFuncCallback(getter_AddRefs(mCacheRefreshTimer),
|
||||||
CacheViewportCallback,
|
CacheViewportCallback, this,
|
||||||
this,
|
kCacheRefreshInterval, nsITimer::TYPE_ONE_SHOT,
|
||||||
kCacheRefreshInterval,
|
|
||||||
nsITimer::TYPE_ONE_SHOT,
|
|
||||||
"a11y::DocAccessibleWrap::CacheViewport");
|
"a11y::DocAccessibleWrap::CacheViewport");
|
||||||
if (mCacheRefreshTimer) {
|
if (mCacheRefreshTimer) {
|
||||||
NS_ADDREF_THIS(); // Kung fu death grip
|
NS_ADDREF_THIS(); // Kung fu death grip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DocAccessibleWrap*
|
DocAccessibleWrap* DocAccessibleWrap::GetTopLevelContentDoc(
|
||||||
DocAccessibleWrap::GetTopLevelContentDoc(AccessibleWrap* aAccessible) {
|
AccessibleWrap* aAccessible) {
|
||||||
DocAccessibleWrap* doc = static_cast<DocAccessibleWrap*>(aAccessible->Document());
|
DocAccessibleWrap* doc =
|
||||||
|
static_cast<DocAccessibleWrap*>(aAccessible->Document());
|
||||||
while (doc && doc->VirtualViewID() != kNoID) {
|
while (doc && doc->VirtualViewID() != kNoID) {
|
||||||
doc = static_cast<DocAccessibleWrap*>(doc->ParentDocument());
|
doc = static_cast<DocAccessibleWrap*>(doc->ParentDocument());
|
||||||
}
|
}
|
||||||
@@ -195,17 +180,16 @@ DocAccessibleWrap::GetTopLevelContentDoc(AccessibleWrap* aAccessible) {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible) {
|
||||||
DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible)
|
|
||||||
{
|
|
||||||
mFocusPath.Clear();
|
mFocusPath.Clear();
|
||||||
if (IPCAccessibilityActive()) {
|
if (IPCAccessibilityActive()) {
|
||||||
DocAccessibleChild* ipcDoc = IPCDoc();
|
DocAccessibleChild* ipcDoc = IPCDoc();
|
||||||
nsTArray<BatchData> cacheData;
|
nsTArray<BatchData> cacheData;
|
||||||
for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent();
|
for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent();
|
||||||
acc = static_cast<AccessibleWrap*>(acc->Parent())) {
|
acc = static_cast<AccessibleWrap*>(acc->Parent())) {
|
||||||
auto uid = acc->IsDoc() && acc->AsDoc()->IPCDoc() ? 0
|
auto uid = acc->IsDoc() && acc->AsDoc()->IPCDoc()
|
||||||
: reinterpret_cast<uint64_t>(acc->UniqueID());
|
? 0
|
||||||
|
: reinterpret_cast<uint64_t>(acc->UniqueID());
|
||||||
nsAutoString name;
|
nsAutoString name;
|
||||||
acc->Name(name);
|
acc->Name(name);
|
||||||
nsAutoString textValue;
|
nsAutoString textValue;
|
||||||
@@ -215,23 +199,16 @@ DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible)
|
|||||||
nsCOMPtr<nsIPersistentProperties> props = acc->Attributes();
|
nsCOMPtr<nsIPersistentProperties> props = acc->Attributes();
|
||||||
nsTArray<Attribute> attributes;
|
nsTArray<Attribute> attributes;
|
||||||
nsAccUtils::PersistentPropertiesToArray(props, &attributes);
|
nsAccUtils::PersistentPropertiesToArray(props, &attributes);
|
||||||
cacheData.AppendElement(BatchData(acc->Document()->IPCDoc(),
|
cacheData.AppendElement(
|
||||||
uid,
|
BatchData(acc->Document()->IPCDoc(), uid, acc->State(), acc->Bounds(),
|
||||||
acc->State(),
|
name, textValue, nodeID, acc->CurValue(), acc->MinValue(),
|
||||||
acc->Bounds(),
|
acc->MaxValue(), acc->Step(), attributes));
|
||||||
name,
|
|
||||||
textValue,
|
|
||||||
nodeID,
|
|
||||||
acc->CurValue(),
|
|
||||||
acc->MinValue(),
|
|
||||||
acc->MaxValue(),
|
|
||||||
acc->Step(),
|
|
||||||
attributes));
|
|
||||||
mFocusPath.Put(acc->UniqueID(), acc);
|
mFocusPath.Put(acc->UniqueID(), acc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcDoc->SendBatch(eBatch_FocusPath, cacheData);
|
ipcDoc->SendBatch(eBatch_FocusPath, cacheData);
|
||||||
} else if (SessionAccessibility* sessionAcc = SessionAccessibility::GetInstanceFor(this)) {
|
} else if (SessionAccessibility* sessionAcc =
|
||||||
|
SessionAccessibility::GetInstanceFor(this)) {
|
||||||
nsTArray<AccessibleWrap*> accessibles;
|
nsTArray<AccessibleWrap*> accessibles;
|
||||||
for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent();
|
for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent();
|
||||||
acc = static_cast<AccessibleWrap*>(acc->Parent())) {
|
acc = static_cast<AccessibleWrap*>(acc->Parent())) {
|
||||||
@@ -242,9 +219,7 @@ DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocAccessibleWrap::UpdateFocusPathBounds() {
|
||||||
DocAccessibleWrap::UpdateFocusPathBounds()
|
|
||||||
{
|
|
||||||
if (!mFocusPath.Count()) {
|
if (!mFocusPath.Count()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -254,27 +229,23 @@ DocAccessibleWrap::UpdateFocusPathBounds()
|
|||||||
nsTArray<BatchData> boundsData(mFocusPath.Count());
|
nsTArray<BatchData> boundsData(mFocusPath.Count());
|
||||||
for (auto iter = mFocusPath.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mFocusPath.Iter(); !iter.Done(); iter.Next()) {
|
||||||
Accessible* accessible = iter.Data();
|
Accessible* accessible = iter.Data();
|
||||||
auto uid = accessible->IsDoc() && accessible->AsDoc()->IPCDoc() ? 0
|
auto uid = accessible->IsDoc() && accessible->AsDoc()->IPCDoc()
|
||||||
: reinterpret_cast<uint64_t>(accessible->UniqueID());
|
? 0
|
||||||
boundsData.AppendElement(BatchData(accessible->Document()->IPCDoc(),
|
: reinterpret_cast<uint64_t>(accessible->UniqueID());
|
||||||
uid,
|
boundsData.AppendElement(BatchData(
|
||||||
0,
|
accessible->Document()->IPCDoc(), uid, 0, accessible->Bounds(),
|
||||||
accessible->Bounds(),
|
nsString(), nsString(), nsString(), UnspecifiedNaN<double>(),
|
||||||
nsString(),
|
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
|
||||||
nsString(),
|
UnspecifiedNaN<double>(), nsTArray<Attribute>()));
|
||||||
nsString(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
nsTArray<Attribute>()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcDoc->SendBatch(eBatch_BoundsUpdate, boundsData);
|
ipcDoc->SendBatch(eBatch_BoundsUpdate, boundsData);
|
||||||
} else if (SessionAccessibility* sessionAcc = SessionAccessibility::GetInstanceFor(this)) {
|
} else if (SessionAccessibility* sessionAcc =
|
||||||
|
SessionAccessibility::GetInstanceFor(this)) {
|
||||||
nsTArray<AccessibleWrap*> accessibles(mFocusPath.Count());
|
nsTArray<AccessibleWrap*> accessibles(mFocusPath.Count());
|
||||||
for (auto iter = mFocusPath.Iter(); !iter.Done(); iter.Next()) {
|
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);
|
sessionAcc->UpdateCachedBounds(accessibles);
|
||||||
|
|||||||
@@ -12,9 +12,8 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
class DocAccessibleWrap : public DocAccessible
|
class DocAccessibleWrap : public DocAccessible {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
|
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
|
||||||
virtual ~DocAccessibleWrap();
|
virtual ~DocAccessibleWrap();
|
||||||
|
|
||||||
@@ -23,8 +22,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Manage the mapping from id to Accessible.
|
* 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);
|
mIDToAccessibleMap.Put(aID, aAcc);
|
||||||
}
|
}
|
||||||
void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
|
void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
|
||||||
@@ -40,7 +38,7 @@ public:
|
|||||||
eBatch_BoundsUpdate = 2,
|
eBatch_BoundsUpdate = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*
|
/*
|
||||||
* This provides a mapping from 32 bit id to accessible objects.
|
* This provides a mapping from 32 bit id to accessible objects.
|
||||||
*/
|
*/
|
||||||
@@ -48,7 +46,7 @@ protected:
|
|||||||
|
|
||||||
virtual void DoInitialUpdate() override;
|
virtual void DoInitialUpdate() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CacheViewport();
|
void CacheViewport();
|
||||||
|
|
||||||
void UpdateFocusPathBounds();
|
void UpdateFocusPathBounds();
|
||||||
@@ -60,7 +58,7 @@ private:
|
|||||||
AccessibleHashtable mFocusPath;
|
AccessibleHashtable mFocusPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ typedef class HTMLTableAccessible HTMLTableAccessibleWrap;
|
|||||||
typedef class HTMLTableCellAccessible HTMLTableCellAccessibleWrap;
|
typedef class HTMLTableCellAccessible HTMLTableCellAccessibleWrap;
|
||||||
typedef class HTMLTableHeaderCellAccessible HTMLTableHeaderCellAccessibleWrap;
|
typedef class HTMLTableHeaderCellAccessible HTMLTableHeaderCellAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class HyperTextAccessible HyperTextAccessibleWrap;
|
typedef class HyperTextAccessible HyperTextAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class ImageAccessible ImageAccessibleWrap;
|
typedef class ImageAccessible ImageAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,19 +15,11 @@
|
|||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
void
|
void a11y::PlatformInit() {}
|
||||||
a11y::PlatformInit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void a11y::PlatformShutdown() {}
|
||||||
a11y::PlatformShutdown()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t aInterfaces) {
|
||||||
a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t aInterfaces)
|
|
||||||
{
|
|
||||||
AccessibleWrap* wrapper = nullptr;
|
AccessibleWrap* wrapper = nullptr;
|
||||||
if (aProxy->IsDoc()) {
|
if (aProxy->IsDoc()) {
|
||||||
wrapper = new DocProxyAccessibleWrap(aProxy->AsDoc());
|
wrapper = new DocProxyAccessibleWrap(aProxy->AsDoc());
|
||||||
@@ -39,11 +31,9 @@ a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t aInterfaces)
|
|||||||
aProxy->SetWrapper(reinterpret_cast<uintptr_t>(wrapper));
|
aProxy->SetWrapper(reinterpret_cast<uintptr_t>(wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxyDestroyed(ProxyAccessible* aProxy) {
|
||||||
a11y::ProxyDestroyed(ProxyAccessible* aProxy)
|
|
||||||
{
|
|
||||||
AccessibleWrap* wrapper =
|
AccessibleWrap* wrapper =
|
||||||
reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
|
reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
|
||||||
|
|
||||||
// If aProxy is a document that was created, but
|
// If aProxy is a document that was created, but
|
||||||
// RecvPDocAccessibleConstructor failed then aProxy->GetWrapper() will be
|
// RecvPDocAccessibleConstructor failed then aProxy->GetWrapper() will be
|
||||||
@@ -57,11 +47,9 @@ a11y::ProxyDestroyed(ProxyAccessible* aProxy)
|
|||||||
wrapper->Release();
|
wrapper->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType) {
|
||||||
a11y::ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType)
|
|
||||||
{
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aTarget);
|
SessionAccessibility::GetInstanceFor(aTarget);
|
||||||
if (!sessionAcc) {
|
if (!sessionAcc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -73,13 +61,10 @@ a11y::ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxyStateChangeEvent(ProxyAccessible* aTarget, uint64_t aState,
|
||||||
a11y::ProxyStateChangeEvent(ProxyAccessible* aTarget,
|
bool aEnabled) {
|
||||||
uint64_t aState,
|
|
||||||
bool aEnabled)
|
|
||||||
{
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aTarget);
|
SessionAccessibility::GetInstanceFor(aTarget);
|
||||||
|
|
||||||
if (!sessionAcc) {
|
if (!sessionAcc) {
|
||||||
return;
|
return;
|
||||||
@@ -98,70 +83,51 @@ a11y::ProxyStateChangeEvent(ProxyAccessible* aTarget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset) {
|
||||||
a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset)
|
|
||||||
{
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aTarget);
|
SessionAccessibility::GetInstanceFor(aTarget);
|
||||||
|
|
||||||
if (sessionAcc) {
|
if (sessionAcc) {
|
||||||
sessionAcc->SendTextSelectionChangedEvent(WrapperFor(aTarget), aOffset);
|
sessionAcc->SendTextSelectionChangedEvent(WrapperFor(aTarget), aOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxyTextChangeEvent(ProxyAccessible* aTarget, const nsString& aStr,
|
||||||
a11y::ProxyTextChangeEvent(ProxyAccessible* aTarget,
|
int32_t aStart, uint32_t aLen, bool aIsInsert,
|
||||||
const nsString& aStr,
|
bool aFromUser) {
|
||||||
int32_t aStart,
|
|
||||||
uint32_t aLen,
|
|
||||||
bool aIsInsert,
|
|
||||||
bool aFromUser)
|
|
||||||
{
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aTarget);
|
SessionAccessibility::GetInstanceFor(aTarget);
|
||||||
|
|
||||||
if (sessionAcc) {
|
if (sessionAcc) {
|
||||||
sessionAcc->SendTextChangedEvent(
|
sessionAcc->SendTextChangedEvent(WrapperFor(aTarget), aStr, aStart, aLen,
|
||||||
WrapperFor(aTarget), aStr, aStart, aLen, aIsInsert, aFromUser);
|
aIsInsert, aFromUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxyShowHideEvent(ProxyAccessible* aTarget,
|
||||||
a11y::ProxyShowHideEvent(ProxyAccessible* aTarget,
|
ProxyAccessible* aParent, bool aInsert,
|
||||||
ProxyAccessible* aParent,
|
bool aFromUser) {
|
||||||
bool aInsert,
|
|
||||||
bool aFromUser)
|
|
||||||
{
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aTarget);
|
SessionAccessibility::GetInstanceFor(aTarget);
|
||||||
if (sessionAcc) {
|
if (sessionAcc) {
|
||||||
sessionAcc->SendWindowContentChangedEvent(WrapperFor(aParent));
|
sessionAcc->SendWindowContentChangedEvent(WrapperFor(aParent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxySelectionEvent(ProxyAccessible*, ProxyAccessible*, uint32_t) {}
|
||||||
a11y::ProxySelectionEvent(ProxyAccessible*, ProxyAccessible*, uint32_t)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void a11y::ProxyVirtualCursorChangeEvent(
|
||||||
a11y::ProxyVirtualCursorChangeEvent(ProxyAccessible* aTarget,
|
ProxyAccessible* aTarget, ProxyAccessible* aOldPosition,
|
||||||
ProxyAccessible* aOldPosition,
|
int32_t aOldStartOffset, int32_t aOldEndOffset,
|
||||||
int32_t aOldStartOffset,
|
ProxyAccessible* aNewPosition, int32_t aNewStartOffset,
|
||||||
int32_t aOldEndOffset,
|
int32_t aNewEndOffset, int16_t aReason, int16_t aBoundaryType,
|
||||||
ProxyAccessible* aNewPosition,
|
bool aFromUser) {
|
||||||
int32_t aNewStartOffset,
|
|
||||||
int32_t aNewEndOffset,
|
|
||||||
int16_t aReason,
|
|
||||||
int16_t aBoundaryType,
|
|
||||||
bool aFromUser)
|
|
||||||
{
|
|
||||||
if (!aNewPosition) {
|
if (!aNewPosition) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aTarget);
|
SessionAccessibility::GetInstanceFor(aTarget);
|
||||||
|
|
||||||
if (!sessionAcc) {
|
if (!sessionAcc) {
|
||||||
return;
|
return;
|
||||||
@@ -176,38 +142,30 @@ a11y::ProxyVirtualCursorChangeEvent(ProxyAccessible* aTarget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aBoundaryType != nsIAccessiblePivot::NO_BOUNDARY) {
|
if (aBoundaryType != nsIAccessiblePivot::NO_BOUNDARY) {
|
||||||
sessionAcc->SendTextTraversedEvent(
|
sessionAcc->SendTextTraversedEvent(WrapperFor(aNewPosition),
|
||||||
WrapperFor(aNewPosition), aNewStartOffset, aNewEndOffset);
|
aNewStartOffset, aNewEndOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType,
|
||||||
a11y::ProxyScrollingEvent(ProxyAccessible* aTarget,
|
uint32_t aScrollX, uint32_t aScrollY,
|
||||||
uint32_t aEventType,
|
uint32_t aMaxScrollX, uint32_t aMaxScrollY) {
|
||||||
uint32_t aScrollX,
|
|
||||||
uint32_t aScrollY,
|
|
||||||
uint32_t aMaxScrollX,
|
|
||||||
uint32_t aMaxScrollY)
|
|
||||||
{
|
|
||||||
if (aEventType == nsIAccessibleEvent::EVENT_SCROLLING) {
|
if (aEventType == nsIAccessibleEvent::EVENT_SCROLLING) {
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aTarget);
|
SessionAccessibility::GetInstanceFor(aTarget);
|
||||||
|
|
||||||
if (sessionAcc) {
|
if (sessionAcc) {
|
||||||
sessionAcc->SendScrollingEvent(
|
sessionAcc->SendScrollingEvent(WrapperFor(aTarget), aScrollX, aScrollY,
|
||||||
WrapperFor(aTarget), aScrollX, aScrollY, aMaxScrollX, aMaxScrollY);
|
aMaxScrollX, aMaxScrollY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::ProxyBatch(ProxyAccessible* aDocument, const uint64_t aBatchType,
|
||||||
a11y::ProxyBatch(ProxyAccessible* aDocument,
|
const nsTArray<ProxyAccessible*>& aAccessibles,
|
||||||
const uint64_t aBatchType,
|
const nsTArray<BatchData>& aData) {
|
||||||
const nsTArray<ProxyAccessible*>& aAccessibles,
|
|
||||||
const nsTArray<BatchData>& aData)
|
|
||||||
{
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aDocument);
|
SessionAccessibility::GetInstanceFor(aDocument);
|
||||||
if (!sessionAcc) {
|
if (!sessionAcc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
|
ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
|
||||||
: AccessibleWrap(nullptr, nullptr)
|
: AccessibleWrap(nullptr, nullptr) {
|
||||||
{
|
|
||||||
mType = eProxyType;
|
mType = eProxyType;
|
||||||
mBits.proxy = aProxy;
|
mBits.proxy = aProxy;
|
||||||
|
|
||||||
@@ -27,18 +26,16 @@ ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
|
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
|
||||||
Proxy()->Document()->GetWrapper());
|
Proxy()->Document()->GetWrapper());
|
||||||
if (doc) {
|
if (doc) {
|
||||||
mID = AcquireID();
|
mID = AcquireID();
|
||||||
doc->AddID(mID, this);
|
doc->AddID(mID, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ProxyAccessibleWrap::Shutdown() {
|
||||||
ProxyAccessibleWrap::Shutdown()
|
|
||||||
{
|
|
||||||
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
|
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
|
||||||
Proxy()->Document()->GetWrapper());
|
Proxy()->Document()->GetWrapper());
|
||||||
if (mID && doc) {
|
if (mID && doc) {
|
||||||
doc->RemoveID(mID);
|
doc->RemoveID(mID);
|
||||||
ReleaseID(mID);
|
ReleaseID(mID);
|
||||||
@@ -51,100 +48,64 @@ ProxyAccessibleWrap::Shutdown()
|
|||||||
|
|
||||||
// Accessible
|
// Accessible
|
||||||
|
|
||||||
already_AddRefed<nsIPersistentProperties>
|
already_AddRefed<nsIPersistentProperties> ProxyAccessibleWrap::Attributes() {
|
||||||
ProxyAccessibleWrap::Attributes()
|
|
||||||
{
|
|
||||||
AutoTArray<Attribute, 10> attrs;
|
AutoTArray<Attribute, 10> attrs;
|
||||||
Proxy()->Attributes(&attrs);
|
Proxy()->Attributes(&attrs);
|
||||||
return AttributeArrayToProperties(attrs);
|
return AttributeArrayToProperties(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t ProxyAccessibleWrap::ChildCount() const {
|
||||||
ProxyAccessibleWrap::ChildCount() const
|
|
||||||
{
|
|
||||||
return Proxy()->ChildrenCount();
|
return Proxy()->ChildrenCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const {
|
||||||
ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const
|
|
||||||
{
|
|
||||||
ProxyAccessible* child = Proxy()->ChildAt(aIndex);
|
ProxyAccessible* child = Proxy()->ChildAt(aIndex);
|
||||||
return child ? WrapperFor(child) : nullptr;
|
return child ? WrapperFor(child) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENameValueFlag
|
ENameValueFlag ProxyAccessibleWrap::Name(nsString& aName) const {
|
||||||
ProxyAccessibleWrap::Name(nsString& aName) const
|
|
||||||
{
|
|
||||||
Proxy()->Name(aName);
|
Proxy()->Name(aName);
|
||||||
return eNameOK;
|
return eNameOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ProxyAccessibleWrap::Value(nsString& aValue) const {
|
||||||
ProxyAccessibleWrap::Value(nsString& aValue) const
|
|
||||||
{
|
|
||||||
Proxy()->Value(aValue);
|
Proxy()->Value(aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t ProxyAccessibleWrap::State() { return Proxy()->State(); }
|
||||||
ProxyAccessibleWrap::State()
|
|
||||||
{
|
|
||||||
return Proxy()->State();
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIntRect
|
nsIntRect ProxyAccessibleWrap::Bounds() const { return Proxy()->Bounds(); }
|
||||||
ProxyAccessibleWrap::Bounds() const
|
|
||||||
{
|
|
||||||
return Proxy()->Bounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void ProxyAccessibleWrap::ScrollTo(uint32_t aHow) const {
|
||||||
ProxyAccessibleWrap::ScrollTo(uint32_t aHow) const
|
|
||||||
{
|
|
||||||
Proxy()->ScrollTo(aHow);
|
Proxy()->ScrollTo(aHow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
void
|
void ProxyAccessibleWrap::SetTextContents(const nsAString& aText) {
|
||||||
ProxyAccessibleWrap::SetTextContents(const nsAString& aText)
|
|
||||||
{
|
|
||||||
Proxy()->ReplaceText(PromiseFlatString(aText));
|
Proxy()->ReplaceText(PromiseFlatString(aText));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ProxyAccessibleWrap::GetTextContents(nsAString& aText) {
|
||||||
ProxyAccessibleWrap::GetTextContents(nsAString& aText)
|
|
||||||
{
|
|
||||||
nsAutoString text;
|
nsAutoString text;
|
||||||
Proxy()->TextSubstring(0, -1, text);
|
Proxy()->TextSubstring(0, -1, text);
|
||||||
aText.Assign(text);
|
aText.Assign(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool ProxyAccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
|
||||||
ProxyAccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
|
int32_t* aEndOffset) {
|
||||||
int32_t* aEndOffset)
|
|
||||||
{
|
|
||||||
nsAutoString unused;
|
nsAutoString unused;
|
||||||
return Proxy()->SelectionBoundsAt(0, unused, aStartOffset, aEndOffset);
|
return Proxy()->SelectionBoundsAt(0, unused, aStartOffset, aEndOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
role
|
role ProxyAccessibleWrap::WrapperRole() { return Proxy()->Role(); }
|
||||||
ProxyAccessibleWrap::WrapperRole()
|
|
||||||
{
|
|
||||||
return Proxy()->Role();
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessibleWrap*
|
AccessibleWrap* ProxyAccessibleWrap::WrapperParent() {
|
||||||
ProxyAccessibleWrap::WrapperParent()
|
|
||||||
{
|
|
||||||
return Proxy()->Parent() ? WrapperFor(Proxy()->Parent()) : nullptr;
|
return Proxy()->Parent() ? WrapperFor(Proxy()->Parent()) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
|
||||||
ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal,
|
double* aMaxVal, double* aStep) {
|
||||||
double* aMinVal,
|
|
||||||
double* aMaxVal,
|
|
||||||
double* aStep)
|
|
||||||
{
|
|
||||||
if (HasNumericValue()) {
|
if (HasNumericValue()) {
|
||||||
ProxyAccessible* proxy = Proxy();
|
ProxyAccessible* proxy = Proxy();
|
||||||
*aCurVal = proxy->CurValue();
|
*aCurVal = proxy->CurValue();
|
||||||
@@ -157,8 +118,6 @@ ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ProxyAccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
|
||||||
ProxyAccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID)
|
|
||||||
{
|
|
||||||
Proxy()->DOMNodeID(aDOMNodeID);
|
Proxy()->DOMNodeID(aDOMNodeID);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ namespace a11y {
|
|||||||
* to distinguish between a local or remote accessibles.
|
* to distinguish between a local or remote accessibles.
|
||||||
* NOTE: This shouldn't be regarded as a full Accessible implementation.
|
* NOTE: This shouldn't be regarded as a full Accessible implementation.
|
||||||
*/
|
*/
|
||||||
class ProxyAccessibleWrap : public AccessibleWrap
|
class ProxyAccessibleWrap : public AccessibleWrap {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit ProxyAccessibleWrap(ProxyAccessible* aProxy);
|
explicit ProxyAccessibleWrap(ProxyAccessible* aProxy);
|
||||||
|
|
||||||
virtual void Shutdown() override;
|
virtual void Shutdown() override;
|
||||||
@@ -52,24 +51,24 @@ public:
|
|||||||
|
|
||||||
virtual void GetTextContents(nsAString& aText) override;
|
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;
|
virtual void WrapperDOMNodeID(nsString& aDOMNodeID) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual role WrapperRole() override;
|
virtual role WrapperRole() override;
|
||||||
|
|
||||||
virtual AccessibleWrap* WrapperParent() 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
|
class DocProxyAccessibleWrap : public ProxyAccessibleWrap {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit DocProxyAccessibleWrap(DocAccessibleParent* aProxy)
|
explicit DocProxyAccessibleWrap(DocAccessibleParent* aProxy)
|
||||||
: ProxyAccessibleWrap(aProxy)
|
: ProxyAccessibleWrap(aProxy) {
|
||||||
{
|
|
||||||
mGenericTypes |= eDocument;
|
mGenericTypes |= eDocument;
|
||||||
|
|
||||||
if (auto parent = ParentDocument()) {
|
if (auto parent = ParentDocument()) {
|
||||||
@@ -81,8 +80,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Shutdown() override
|
virtual void Shutdown() override {
|
||||||
{
|
|
||||||
if (mID) {
|
if (mID) {
|
||||||
auto parent = ParentDocument();
|
auto parent = ParentDocument();
|
||||||
if (parent) {
|
if (parent) {
|
||||||
@@ -96,8 +94,7 @@ public:
|
|||||||
mStateFlags |= eIsDefunct;
|
mStateFlags |= eIsDefunct;
|
||||||
}
|
}
|
||||||
|
|
||||||
DocProxyAccessibleWrap* ParentDocument()
|
DocProxyAccessibleWrap* ParentDocument() {
|
||||||
{
|
|
||||||
DocAccessibleParent* proxy = static_cast<DocAccessibleParent*>(Proxy());
|
DocAccessibleParent* proxy = static_cast<DocAccessibleParent*>(Proxy());
|
||||||
MOZ_ASSERT(proxy);
|
MOZ_ASSERT(proxy);
|
||||||
if (DocAccessibleParent* parent = proxy->ParentDoc()) {
|
if (DocAccessibleParent* parent = proxy->ParentDoc()) {
|
||||||
@@ -107,34 +104,31 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DocProxyAccessibleWrap* GetChildDocumentAt(uint32_t aIndex)
|
DocProxyAccessibleWrap* GetChildDocumentAt(uint32_t aIndex) {
|
||||||
{
|
|
||||||
auto doc = Proxy()->AsDoc();
|
auto doc = Proxy()->AsDoc();
|
||||||
if (doc && doc->ChildDocCount() > aIndex) {
|
if (doc && doc->ChildDocCount() > aIndex) {
|
||||||
return reinterpret_cast<DocProxyAccessibleWrap*>(
|
return reinterpret_cast<DocProxyAccessibleWrap*>(
|
||||||
doc->ChildDocAt(aIndex)->GetWrapper());
|
doc->ChildDocAt(aIndex)->GetWrapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddID(uint32_t aID, AccessibleWrap* aAcc)
|
void AddID(uint32_t aID, AccessibleWrap* aAcc) {
|
||||||
{
|
|
||||||
mIDToAccessibleMap.Put(aID, aAcc);
|
mIDToAccessibleMap.Put(aID, aAcc);
|
||||||
}
|
}
|
||||||
void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
|
void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
|
||||||
AccessibleWrap* GetAccessibleByID(uint32_t aID) const
|
AccessibleWrap* GetAccessibleByID(uint32_t aID) const {
|
||||||
{
|
|
||||||
return mIDToAccessibleMap.Get(aID);
|
return mIDToAccessibleMap.Get(aID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
* This provides a mapping from 32 bit id to accessible objects.
|
* This provides a mapping from 32 bit id to accessible objects.
|
||||||
*/
|
*/
|
||||||
nsDataHashtable<nsUint32HashKey, AccessibleWrap*> mIDToAccessibleMap;
|
nsDataHashtable<nsUint32HashKey, AccessibleWrap*> mIDToAccessibleMap;
|
||||||
};
|
};
|
||||||
}
|
} // namespace a11y
|
||||||
}
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,15 +15,11 @@ using namespace mozilla::a11y;
|
|||||||
|
|
||||||
RootAccessibleWrap::RootAccessibleWrap(nsIDocument* aDoc,
|
RootAccessibleWrap::RootAccessibleWrap(nsIDocument* aDoc,
|
||||||
nsIPresShell* aPresShell)
|
nsIPresShell* aPresShell)
|
||||||
: RootAccessible(aDoc, aPresShell)
|
: RootAccessible(aDoc, aPresShell) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RootAccessibleWrap::~RootAccessibleWrap() {}
|
RootAccessibleWrap::~RootAccessibleWrap() {}
|
||||||
|
|
||||||
AccessibleWrap*
|
AccessibleWrap* RootAccessibleWrap::GetContentAccessible() {
|
||||||
RootAccessibleWrap::GetContentAccessible()
|
|
||||||
{
|
|
||||||
if (ProxyAccessible* proxy = GetPrimaryRemoteTopLevelContentDoc()) {
|
if (ProxyAccessible* proxy = GetPrimaryRemoteTopLevelContentDoc()) {
|
||||||
return WrapperFor(proxy);
|
return WrapperFor(proxy);
|
||||||
}
|
}
|
||||||
@@ -41,9 +37,7 @@ RootAccessibleWrap::GetContentAccessible()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessibleWrap*
|
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(int32_t aID) {
|
||||||
RootAccessibleWrap::FindAccessibleById(int32_t aID)
|
|
||||||
{
|
|
||||||
AccessibleWrap* contentAcc = GetContentAccessible();
|
AccessibleWrap* contentAcc = GetContentAccessible();
|
||||||
|
|
||||||
if (!contentAcc) {
|
if (!contentAcc) {
|
||||||
@@ -60,18 +54,16 @@ RootAccessibleWrap::FindAccessibleById(int32_t aID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return FindAccessibleById(
|
return FindAccessibleById(
|
||||||
static_cast<DocAccessibleWrap*>(contentAcc->AsDoc()), aID);
|
static_cast<DocAccessibleWrap*>(contentAcc->AsDoc()), aID);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessibleWrap*
|
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(
|
||||||
RootAccessibleWrap::FindAccessibleById(DocProxyAccessibleWrap* aDoc,
|
DocProxyAccessibleWrap* aDoc, int32_t aID) {
|
||||||
int32_t aID)
|
|
||||||
{
|
|
||||||
AccessibleWrap* acc = aDoc->GetAccessibleByID(aID);
|
AccessibleWrap* acc = aDoc->GetAccessibleByID(aID);
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
while (!acc) {
|
while (!acc) {
|
||||||
auto child =
|
auto child =
|
||||||
static_cast<DocProxyAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
|
static_cast<DocProxyAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
|
||||||
if (!child) {
|
if (!child) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -81,14 +73,13 @@ RootAccessibleWrap::FindAccessibleById(DocProxyAccessibleWrap* aDoc,
|
|||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessibleWrap*
|
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(DocAccessibleWrap* aDoc,
|
||||||
RootAccessibleWrap::FindAccessibleById(DocAccessibleWrap* aDoc, int32_t aID)
|
int32_t aID) {
|
||||||
{
|
|
||||||
AccessibleWrap* acc = aDoc->GetAccessibleByID(aID);
|
AccessibleWrap* acc = aDoc->GetAccessibleByID(aID);
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
while (!acc) {
|
while (!acc) {
|
||||||
auto child =
|
auto child =
|
||||||
static_cast<DocAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
|
static_cast<DocAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
|
||||||
if (!child) {
|
if (!child) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ namespace a11y {
|
|||||||
|
|
||||||
class DocProxyAccessibleWrap;
|
class DocProxyAccessibleWrap;
|
||||||
|
|
||||||
class RootAccessibleWrap : public RootAccessible
|
class RootAccessibleWrap : public RootAccessible {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
RootAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
|
RootAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
|
||||||
virtual ~RootAccessibleWrap();
|
virtual ~RootAccessibleWrap();
|
||||||
|
|
||||||
@@ -31,7 +30,7 @@ public:
|
|||||||
int32_t aID);
|
int32_t aID);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,26 +21,24 @@
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#define AALOG(args...) \
|
#define AALOG(args...) \
|
||||||
__android_log_print(ANDROID_LOG_INFO, "GeckoAccessibilityNative", ##args)
|
__android_log_print(ANDROID_LOG_INFO, "GeckoAccessibilityNative", ##args)
|
||||||
#else
|
#else
|
||||||
#define AALOG(args...) \
|
#define AALOG(args...) \
|
||||||
do { \
|
do { \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<>
|
template <>
|
||||||
const char nsWindow::NativePtr<mozilla::a11y::SessionAccessibility>::sName[] =
|
const char nsWindow::NativePtr<mozilla::a11y::SessionAccessibility>::sName[] =
|
||||||
"SessionAccessibility";
|
"SessionAccessibility";
|
||||||
|
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
class Settings final
|
class Settings final
|
||||||
: public mozilla::java::SessionAccessibility::Settings::Natives<Settings>
|
: public mozilla::java::SessionAccessibility::Settings::Natives<Settings> {
|
||||||
{
|
public:
|
||||||
public:
|
static void ToggleNativeAccessibility(bool aEnable) {
|
||||||
static void ToggleNativeAccessibility(bool aEnable)
|
|
||||||
{
|
|
||||||
if (aEnable) {
|
if (aEnable) {
|
||||||
GetOrCreateAccService();
|
GetOrCreateAccService();
|
||||||
} else {
|
} else {
|
||||||
@@ -49,36 +47,30 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SetAttached(bool aAttached,
|
||||||
SessionAccessibility::SetAttached(bool aAttached,
|
already_AddRefed<Runnable> aRunnable) {
|
||||||
already_AddRefed<Runnable> aRunnable)
|
|
||||||
{
|
|
||||||
if (RefPtr<nsThread> uiThread = GetAndroidUiThread()) {
|
if (RefPtr<nsThread> uiThread = GetAndroidUiThread()) {
|
||||||
uiThread->Dispatch(NS_NewRunnableFunction(
|
uiThread->Dispatch(NS_NewRunnableFunction(
|
||||||
"SessionAccessibility::Attach",
|
"SessionAccessibility::Attach",
|
||||||
[aAttached,
|
[aAttached,
|
||||||
sa = java::SessionAccessibility::NativeProvider::GlobalRef(
|
sa = java::SessionAccessibility::NativeProvider::GlobalRef(
|
||||||
mSessionAccessibility),
|
mSessionAccessibility),
|
||||||
runnable = RefPtr<Runnable>(aRunnable)] {
|
runnable = RefPtr<Runnable>(aRunnable)] {
|
||||||
sa->SetAttached(aAttached);
|
sa->SetAttached(aAttached);
|
||||||
if (runnable) {
|
if (runnable) {
|
||||||
runnable->Run();
|
runnable->Run();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::Init() {
|
||||||
SessionAccessibility::Init()
|
|
||||||
{
|
|
||||||
java::SessionAccessibility::NativeProvider::Natives<
|
java::SessionAccessibility::NativeProvider::Natives<
|
||||||
SessionAccessibility>::Init();
|
SessionAccessibility>::Init();
|
||||||
Settings::Init();
|
Settings::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::jni::Object::LocalRef
|
mozilla::jni::Object::LocalRef SessionAccessibility::GetNodeInfo(int32_t aID) {
|
||||||
SessionAccessibility::GetNodeInfo(int32_t aID)
|
|
||||||
{
|
|
||||||
java::GeckoBundle::GlobalRef ret = nullptr;
|
java::GeckoBundle::GlobalRef ret = nullptr;
|
||||||
RefPtr<SessionAccessibility> self(this);
|
RefPtr<SessionAccessibility> self(this);
|
||||||
nsAppShell::SyncRunEvent([this, self, aID, &ret] {
|
nsAppShell::SyncRunEvent([this, self, aID, &ret] {
|
||||||
@@ -95,9 +87,7 @@ SessionAccessibility::GetNodeInfo(int32_t aID)
|
|||||||
return mozilla::jni::Object::Ref::From(ret);
|
return mozilla::jni::Object::Ref::From(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
RootAccessibleWrap*
|
RootAccessibleWrap* SessionAccessibility::GetRoot() {
|
||||||
SessionAccessibility::GetRoot()
|
|
||||||
{
|
|
||||||
if (!mWindow) {
|
if (!mWindow) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -105,9 +95,7 @@ SessionAccessibility::GetRoot()
|
|||||||
return static_cast<RootAccessibleWrap*>(mWindow->GetRootAccessible());
|
return static_cast<RootAccessibleWrap*>(mWindow->GetRootAccessible());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SetText(int32_t aID, jni::String::Param aText) {
|
||||||
SessionAccessibility::SetText(int32_t aID, jni::String::Param aText)
|
|
||||||
{
|
|
||||||
if (RootAccessibleWrap* rootAcc = GetRoot()) {
|
if (RootAccessibleWrap* rootAcc = GetRoot()) {
|
||||||
AccessibleWrap* acc = rootAcc->FindAccessibleById(aID);
|
AccessibleWrap* acc = rootAcc->FindAccessibleById(aID);
|
||||||
if (!acc) {
|
if (!acc) {
|
||||||
@@ -118,9 +106,8 @@ SessionAccessibility::SetText(int32_t aID, jni::String::Param aText)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionAccessibility*
|
SessionAccessibility* SessionAccessibility::GetInstanceFor(
|
||||||
SessionAccessibility::GetInstanceFor(ProxyAccessible* aAccessible)
|
ProxyAccessible* aAccessible) {
|
||||||
{
|
|
||||||
auto tab = static_cast<dom::TabParent*>(aAccessible->Document()->Manager());
|
auto tab = static_cast<dom::TabParent*>(aAccessible->Document()->Manager());
|
||||||
dom::Element* frame = tab->GetOwnerElement();
|
dom::Element* frame = tab->GetOwnerElement();
|
||||||
MOZ_ASSERT(frame);
|
MOZ_ASSERT(frame);
|
||||||
@@ -132,9 +119,8 @@ SessionAccessibility::GetInstanceFor(ProxyAccessible* aAccessible)
|
|||||||
return chromeDoc ? GetInstanceFor(chromeDoc) : nullptr;
|
return chromeDoc ? GetInstanceFor(chromeDoc) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionAccessibility*
|
SessionAccessibility* SessionAccessibility::GetInstanceFor(
|
||||||
SessionAccessibility::GetInstanceFor(Accessible* aAccessible)
|
Accessible* aAccessible) {
|
||||||
{
|
|
||||||
RootAccessible* rootAcc = aAccessible->RootAccessible();
|
RootAccessible* rootAcc = aAccessible->RootAccessible();
|
||||||
nsIPresShell* shell = rootAcc->PresShell();
|
nsIPresShell* shell = rootAcc->PresShell();
|
||||||
nsViewManager* vm = shell->GetViewManager();
|
nsViewManager* vm = shell->GetViewManager();
|
||||||
@@ -153,26 +139,21 @@ SessionAccessibility::GetInstanceFor(Accessible* aAccessible)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendAccessibilityFocusedEvent(
|
||||||
SessionAccessibility::SendAccessibilityFocusedEvent(AccessibleWrap* aAccessible)
|
AccessibleWrap* aAccessible) {
|
||||||
{
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_VIEW_ACCESSIBILITY_FOCUSED,
|
java::sdk::AccessibilityEvent::TYPE_VIEW_ACCESSIBILITY_FOCUSED,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
||||||
aAccessible->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
|
aAccessible->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendHoverEnterEvent(AccessibleWrap* aAccessible) {
|
||||||
SessionAccessibility::SendHoverEnterEvent(AccessibleWrap* aAccessible)
|
|
||||||
{
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_VIEW_HOVER_ENTER,
|
java::sdk::AccessibilityEvent::TYPE_VIEW_HOVER_ENTER,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible) {
|
||||||
SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible)
|
|
||||||
{
|
|
||||||
// Suppress focus events from about:blank pages.
|
// Suppress focus events from about:blank pages.
|
||||||
// This is important for tests.
|
// This is important for tests.
|
||||||
if (aAccessible->IsDoc() && aAccessible->ChildCount() == 0) {
|
if (aAccessible->IsDoc() && aAccessible->ChildCount() == 0) {
|
||||||
@@ -180,17 +161,15 @@ SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_VIEW_FOCUSED,
|
java::sdk::AccessibilityEvent::TYPE_VIEW_FOCUSED,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
|
||||||
SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
|
int32_t aScrollX,
|
||||||
int32_t aScrollX,
|
int32_t aScrollY,
|
||||||
int32_t aScrollY,
|
int32_t aMaxScrollX,
|
||||||
int32_t aMaxScrollX,
|
int32_t aMaxScrollY) {
|
||||||
int32_t aMaxScrollY)
|
|
||||||
{
|
|
||||||
int32_t virtualViewId = aAccessible->VirtualViewID();
|
int32_t virtualViewId = aAccessible->VirtualViewID();
|
||||||
|
|
||||||
if (virtualViewId != AccessibleWrap::kNoID) {
|
if (virtualViewId != AccessibleWrap::kNoID) {
|
||||||
@@ -201,28 +180,28 @@ SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
|
|||||||
GECKOBUNDLE_START(eventInfo);
|
GECKOBUNDLE_START(eventInfo);
|
||||||
GECKOBUNDLE_PUT(eventInfo, "scrollX", java::sdk::Integer::ValueOf(aScrollX));
|
GECKOBUNDLE_PUT(eventInfo, "scrollX", java::sdk::Integer::ValueOf(aScrollX));
|
||||||
GECKOBUNDLE_PUT(eventInfo, "scrollY", java::sdk::Integer::ValueOf(aScrollY));
|
GECKOBUNDLE_PUT(eventInfo, "scrollY", java::sdk::Integer::ValueOf(aScrollY));
|
||||||
GECKOBUNDLE_PUT(eventInfo, "maxScrollX", java::sdk::Integer::ValueOf(aMaxScrollX));
|
GECKOBUNDLE_PUT(eventInfo, "maxScrollX",
|
||||||
GECKOBUNDLE_PUT(eventInfo, "maxScrollY", java::sdk::Integer::ValueOf(aMaxScrollY));
|
java::sdk::Integer::ValueOf(aMaxScrollX));
|
||||||
|
GECKOBUNDLE_PUT(eventInfo, "maxScrollY",
|
||||||
|
java::sdk::Integer::ValueOf(aMaxScrollY));
|
||||||
GECKOBUNDLE_FINISH(eventInfo);
|
GECKOBUNDLE_FINISH(eventInfo);
|
||||||
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_VIEW_SCROLLED, virtualViewId,
|
java::sdk::AccessibilityEvent::TYPE_VIEW_SCROLLED, virtualViewId,
|
||||||
aAccessible->AndroidClass(), eventInfo);
|
aAccessible->AndroidClass(), eventInfo);
|
||||||
|
|
||||||
SendWindowContentChangedEvent(aAccessible);
|
SendWindowContentChangedEvent(aAccessible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendWindowContentChangedEvent(
|
||||||
SessionAccessibility::SendWindowContentChangedEvent(AccessibleWrap* aAccessible)
|
AccessibleWrap* aAccessible) {
|
||||||
{
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_WINDOW_CONTENT_CHANGED,
|
java::sdk::AccessibilityEvent::TYPE_WINDOW_CONTENT_CHANGED,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendWindowStateChangedEvent(
|
||||||
SessionAccessibility::SendWindowStateChangedEvent(AccessibleWrap* aAccessible)
|
AccessibleWrap* aAccessible) {
|
||||||
{
|
|
||||||
// Suppress window state changed events from about:blank pages.
|
// Suppress window state changed events from about:blank pages.
|
||||||
// This is important for tests.
|
// This is important for tests.
|
||||||
if (aAccessible->IsDoc() && aAccessible->ChildCount() == 0) {
|
if (aAccessible->IsDoc() && aAccessible->ChildCount() == 0) {
|
||||||
@@ -230,14 +209,12 @@ SessionAccessibility::SendWindowStateChangedEvent(AccessibleWrap* aAccessible)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_WINDOW_STATE_CHANGED,
|
java::sdk::AccessibilityEvent::TYPE_WINDOW_STATE_CHANGED,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendTextSelectionChangedEvent(
|
||||||
SessionAccessibility::SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
|
AccessibleWrap* aAccessible, int32_t aCaretOffset) {
|
||||||
int32_t aCaretOffset)
|
|
||||||
{
|
|
||||||
int32_t fromIndex = aCaretOffset;
|
int32_t fromIndex = aCaretOffset;
|
||||||
int32_t startSel = -1;
|
int32_t startSel = -1;
|
||||||
int32_t endSel = -1;
|
int32_t endSel = -1;
|
||||||
@@ -246,23 +223,22 @@ SessionAccessibility::SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GECKOBUNDLE_START(eventInfo);
|
GECKOBUNDLE_START(eventInfo);
|
||||||
GECKOBUNDLE_PUT(eventInfo, "fromIndex", java::sdk::Integer::ValueOf(fromIndex));
|
GECKOBUNDLE_PUT(eventInfo, "fromIndex",
|
||||||
GECKOBUNDLE_PUT(eventInfo, "toIndex", java::sdk::Integer::ValueOf(aCaretOffset));
|
java::sdk::Integer::ValueOf(fromIndex));
|
||||||
|
GECKOBUNDLE_PUT(eventInfo, "toIndex",
|
||||||
|
java::sdk::Integer::ValueOf(aCaretOffset));
|
||||||
GECKOBUNDLE_FINISH(eventInfo);
|
GECKOBUNDLE_FINISH(eventInfo);
|
||||||
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_SELECTION_CHANGED,
|
java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_SELECTION_CHANGED,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
|
||||||
SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
|
const nsString& aStr,
|
||||||
const nsString& aStr,
|
int32_t aStart, uint32_t aLen,
|
||||||
int32_t aStart,
|
bool aIsInsert,
|
||||||
uint32_t aLen,
|
bool aFromUser) {
|
||||||
bool aIsInsert,
|
|
||||||
bool aFromUser)
|
|
||||||
{
|
|
||||||
if (!aFromUser) {
|
if (!aFromUser) {
|
||||||
// Only dispatch text change events from users, for now.
|
// Only dispatch text change events from users, for now.
|
||||||
return;
|
return;
|
||||||
@@ -280,65 +256,66 @@ SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
|
|||||||
GECKOBUNDLE_START(eventInfo);
|
GECKOBUNDLE_START(eventInfo);
|
||||||
GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(text));
|
GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(text));
|
||||||
GECKOBUNDLE_PUT(eventInfo, "beforeText", jni::StringParam(beforeText));
|
GECKOBUNDLE_PUT(eventInfo, "beforeText", jni::StringParam(beforeText));
|
||||||
GECKOBUNDLE_PUT(eventInfo, "addedCount", java::sdk::Integer::ValueOf(aIsInsert ? aLen : 0));
|
GECKOBUNDLE_PUT(eventInfo, "addedCount",
|
||||||
GECKOBUNDLE_PUT(eventInfo, "removedCount", java::sdk::Integer::ValueOf(aIsInsert ? 0 : aLen));
|
java::sdk::Integer::ValueOf(aIsInsert ? aLen : 0));
|
||||||
|
GECKOBUNDLE_PUT(eventInfo, "removedCount",
|
||||||
|
java::sdk::Integer::ValueOf(aIsInsert ? 0 : aLen));
|
||||||
GECKOBUNDLE_FINISH(eventInfo);
|
GECKOBUNDLE_FINISH(eventInfo);
|
||||||
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_CHANGED,
|
java::sdk::AccessibilityEvent::TYPE_VIEW_TEXT_CHANGED,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
|
||||||
SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
|
int32_t aStartOffset,
|
||||||
int32_t aStartOffset,
|
int32_t aEndOffset) {
|
||||||
int32_t aEndOffset)
|
|
||||||
{
|
|
||||||
nsAutoString text;
|
nsAutoString text;
|
||||||
aAccessible->GetTextContents(text);
|
aAccessible->GetTextContents(text);
|
||||||
|
|
||||||
GECKOBUNDLE_START(eventInfo);
|
GECKOBUNDLE_START(eventInfo);
|
||||||
GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(text));
|
GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(text));
|
||||||
GECKOBUNDLE_PUT(eventInfo, "fromIndex", java::sdk::Integer::ValueOf(aStartOffset));
|
GECKOBUNDLE_PUT(eventInfo, "fromIndex",
|
||||||
GECKOBUNDLE_PUT(eventInfo, "toIndex", java::sdk::Integer::ValueOf(aEndOffset));
|
java::sdk::Integer::ValueOf(aStartOffset));
|
||||||
|
GECKOBUNDLE_PUT(eventInfo, "toIndex",
|
||||||
|
java::sdk::Integer::ValueOf(aEndOffset));
|
||||||
GECKOBUNDLE_FINISH(eventInfo);
|
GECKOBUNDLE_FINISH(eventInfo);
|
||||||
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::
|
java::sdk::AccessibilityEvent::
|
||||||
TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
|
TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendClickedEvent(AccessibleWrap* aAccessible,
|
||||||
SessionAccessibility::SendClickedEvent(AccessibleWrap* aAccessible, bool aChecked)
|
bool aChecked) {
|
||||||
{
|
|
||||||
GECKOBUNDLE_START(eventInfo);
|
GECKOBUNDLE_START(eventInfo);
|
||||||
// Boolean::FALSE/TRUE gets clobbered by a macro, so ugh.
|
// 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);
|
GECKOBUNDLE_FINISH(eventInfo);
|
||||||
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_VIEW_CLICKED,
|
java::sdk::AccessibilityEvent::TYPE_VIEW_CLICKED,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::SendSelectedEvent(AccessibleWrap* aAccessible,
|
||||||
SessionAccessibility::SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelected)
|
bool aSelected) {
|
||||||
{
|
|
||||||
GECKOBUNDLE_START(eventInfo);
|
GECKOBUNDLE_START(eventInfo);
|
||||||
// Boolean::FALSE/TRUE gets clobbered by a macro, so ugh.
|
// 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);
|
GECKOBUNDLE_FINISH(eventInfo);
|
||||||
|
|
||||||
mSessionAccessibility->SendEvent(
|
mSessionAccessibility->SendEvent(
|
||||||
java::sdk::AccessibilityEvent::TYPE_VIEW_SELECTED,
|
java::sdk::AccessibilityEvent::TYPE_VIEW_SELECTED,
|
||||||
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::ReplaceViewportCache(
|
||||||
SessionAccessibility::ReplaceViewportCache(const nsTArray<AccessibleWrap*>& aAccessibles,
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
const nsTArray<BatchData>& aData)
|
const nsTArray<BatchData>& aData) {
|
||||||
{
|
|
||||||
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
|
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
|
||||||
for (size_t i = 0; i < aAccessibles.Length(); i++) {
|
for (size_t i = 0; i < aAccessibles.Length(); i++) {
|
||||||
AccessibleWrap* acc = aAccessibles.ElementAt(i);
|
AccessibleWrap* acc = aAccessibles.ElementAt(i);
|
||||||
@@ -354,27 +331,20 @@ SessionAccessibility::ReplaceViewportCache(const nsTArray<AccessibleWrap*>& aAcc
|
|||||||
mSessionAccessibility->ReplaceViewportCache(infos);
|
mSessionAccessibility->ReplaceViewportCache(infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::ReplaceFocusPathCache(
|
||||||
SessionAccessibility::ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAccessibles,
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
const nsTArray<BatchData>& aData)
|
const nsTArray<BatchData>& aData) {
|
||||||
{
|
|
||||||
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
|
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
|
||||||
for (size_t i = 0; i < aAccessibles.Length(); i++) {
|
for (size_t i = 0; i < aAccessibles.Length(); i++) {
|
||||||
AccessibleWrap* acc = aAccessibles.ElementAt(i);
|
AccessibleWrap* acc = aAccessibles.ElementAt(i);
|
||||||
if (aData.Length() == aAccessibles.Length()) {
|
if (aData.Length() == aAccessibles.Length()) {
|
||||||
const BatchData& data = aData.ElementAt(i);
|
const BatchData& data = aData.ElementAt(i);
|
||||||
nsCOMPtr<nsIPersistentProperties> props =
|
nsCOMPtr<nsIPersistentProperties> props =
|
||||||
AccessibleWrap::AttributeArrayToProperties(data.Attributes());
|
AccessibleWrap::AttributeArrayToProperties(data.Attributes());
|
||||||
auto bundle = acc->ToBundle(data.State(),
|
auto bundle =
|
||||||
data.Bounds(),
|
acc->ToBundle(data.State(), data.Bounds(), data.Name(),
|
||||||
data.Name(),
|
data.TextValue(), data.DOMNodeID(), data.CurValue(),
|
||||||
data.TextValue(),
|
data.MinValue(), data.MaxValue(), data.Step(), props);
|
||||||
data.DOMNodeID(),
|
|
||||||
data.CurValue(),
|
|
||||||
data.MinValue(),
|
|
||||||
data.MaxValue(),
|
|
||||||
data.Step(),
|
|
||||||
props);
|
|
||||||
infos->SetElement(i, bundle);
|
infos->SetElement(i, bundle);
|
||||||
} else {
|
} else {
|
||||||
infos->SetElement(i, acc->ToBundle());
|
infos->SetElement(i, acc->ToBundle());
|
||||||
@@ -384,10 +354,9 @@ SessionAccessibility::ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAc
|
|||||||
mSessionAccessibility->ReplaceFocusPathCache(infos);
|
mSessionAccessibility->ReplaceFocusPathCache(infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SessionAccessibility::UpdateCachedBounds(
|
||||||
SessionAccessibility::UpdateCachedBounds(const nsTArray<AccessibleWrap*>& aAccessibles,
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
const nsTArray<BatchData>& aData)
|
const nsTArray<BatchData>& aData) {
|
||||||
{
|
|
||||||
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
|
auto infos = jni::ObjectArray::New<java::GeckoBundle>(aAccessibles.Length());
|
||||||
for (size_t i = 0; i < aAccessibles.Length(); i++) {
|
for (size_t i = 0; i < aAccessibles.Length(); i++) {
|
||||||
AccessibleWrap* acc = aAccessibles.ElementAt(i);
|
AccessibleWrap* acc = aAccessibles.ElementAt(i);
|
||||||
|
|||||||
@@ -12,28 +12,27 @@
|
|||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsWindow.h"
|
#include "nsWindow.h"
|
||||||
|
|
||||||
#define GECKOBUNDLE_START(name) \
|
#define GECKOBUNDLE_START(name) \
|
||||||
nsTArray<jni::String::LocalRef> _##name##_keys; \
|
nsTArray<jni::String::LocalRef> _##name##_keys; \
|
||||||
nsTArray<jni::Object::LocalRef> _##name##_values;
|
nsTArray<jni::Object::LocalRef> _##name##_values;
|
||||||
|
|
||||||
#define GECKOBUNDLE_PUT(name, key, value) \
|
#define GECKOBUNDLE_PUT(name, key, value) \
|
||||||
_##name##_keys.AppendElement(jni::StringParam(NS_LITERAL_STRING(key))); \
|
_##name##_keys.AppendElement(jni::StringParam(NS_LITERAL_STRING(key))); \
|
||||||
_##name##_values.AppendElement(value);
|
_##name##_values.AppendElement(value);
|
||||||
|
|
||||||
#define GECKOBUNDLE_FINISH(name) \
|
#define GECKOBUNDLE_FINISH(name) \
|
||||||
MOZ_ASSERT(_##name##_keys.Length() == _##name##_values.Length()); \
|
MOZ_ASSERT(_##name##_keys.Length() == _##name##_values.Length()); \
|
||||||
auto _##name##_jkeys = \
|
auto _##name##_jkeys = \
|
||||||
jni::ObjectArray::New<jni::String>(_##name##_keys.Length()); \
|
jni::ObjectArray::New<jni::String>(_##name##_keys.Length()); \
|
||||||
auto _##name##_jvalues = \
|
auto _##name##_jvalues = \
|
||||||
jni::ObjectArray::New<jni::Object>(_##name##_values.Length()); \
|
jni::ObjectArray::New<jni::Object>(_##name##_values.Length()); \
|
||||||
for (size_t i = 0; \
|
for (size_t i = 0; \
|
||||||
i < _##name##_keys.Length() && i < _##name##_values.Length(); \
|
i < _##name##_keys.Length() && i < _##name##_values.Length(); i++) { \
|
||||||
i++) { \
|
_##name##_jkeys->SetElement(i, _##name##_keys.ElementAt(i)); \
|
||||||
_##name##_jkeys->SetElement(i, _##name##_keys.ElementAt(i)); \
|
_##name##_jvalues->SetElement(i, _##name##_values.ElementAt(i)); \
|
||||||
_##name##_jvalues->SetElement(i, _##name##_values.ElementAt(i)); \
|
} \
|
||||||
} \
|
auto name = \
|
||||||
auto name = \
|
mozilla::java::GeckoBundle::New(_##name##_jkeys, _##name##_jvalues);
|
||||||
mozilla::java::GeckoBundle::New(_##name##_jkeys, _##name##_jvalues);
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
@@ -44,28 +43,26 @@ class RootAccessibleWrap;
|
|||||||
class BatchData;
|
class BatchData;
|
||||||
|
|
||||||
class SessionAccessibility final
|
class SessionAccessibility final
|
||||||
: public java::SessionAccessibility::NativeProvider::Natives<SessionAccessibility>
|
: public java::SessionAccessibility::NativeProvider::Natives<
|
||||||
{
|
SessionAccessibility> {
|
||||||
public:
|
public:
|
||||||
typedef java::SessionAccessibility::NativeProvider::Natives<SessionAccessibility> Base;
|
typedef java::SessionAccessibility::NativeProvider::Natives<
|
||||||
|
SessionAccessibility>
|
||||||
|
Base;
|
||||||
|
|
||||||
SessionAccessibility(
|
SessionAccessibility(
|
||||||
nsWindow::NativePtr<SessionAccessibility>* aPtr,
|
nsWindow::NativePtr<SessionAccessibility>* aPtr, nsWindow* aWindow,
|
||||||
nsWindow* aWindow,
|
java::SessionAccessibility::NativeProvider::Param aSessionAccessibility)
|
||||||
java::SessionAccessibility::NativeProvider::Param aSessionAccessibility)
|
: mWindow(aPtr, aWindow), mSessionAccessibility(aSessionAccessibility) {
|
||||||
: mWindow(aPtr, aWindow)
|
|
||||||
, mSessionAccessibility(aSessionAccessibility)
|
|
||||||
{
|
|
||||||
SetAttached(true, nullptr);
|
SetAttached(true, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDetach(already_AddRefed<Runnable> aDisposer)
|
void OnDetach(already_AddRefed<Runnable> aDisposer) {
|
||||||
{
|
|
||||||
SetAttached(false, std::move(aDisposer));
|
SetAttached(false, std::move(aDisposer));
|
||||||
}
|
}
|
||||||
|
|
||||||
const java::SessionAccessibility::NativeProvider::Ref& GetJavaAccessibility()
|
const java::SessionAccessibility::NativeProvider::Ref&
|
||||||
{
|
GetJavaAccessibility() {
|
||||||
return mSessionAccessibility;
|
return mSessionAccessibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,23 +79,17 @@ public:
|
|||||||
|
|
||||||
// Event methods
|
// Event methods
|
||||||
void SendFocusEvent(AccessibleWrap* aAccessible);
|
void SendFocusEvent(AccessibleWrap* aAccessible);
|
||||||
void SendScrollingEvent(AccessibleWrap* aAccessible,
|
void SendScrollingEvent(AccessibleWrap* aAccessible, int32_t aScrollX,
|
||||||
int32_t aScrollX,
|
int32_t aScrollY, int32_t aMaxScrollX,
|
||||||
int32_t aScrollY,
|
|
||||||
int32_t aMaxScrollX,
|
|
||||||
int32_t aMaxScrollY);
|
int32_t aMaxScrollY);
|
||||||
void SendAccessibilityFocusedEvent(AccessibleWrap* aAccessible);
|
void SendAccessibilityFocusedEvent(AccessibleWrap* aAccessible);
|
||||||
void SendHoverEnterEvent(AccessibleWrap* aAccessible);
|
void SendHoverEnterEvent(AccessibleWrap* aAccessible);
|
||||||
void SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
|
void SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
|
||||||
int32_t aCaretOffset);
|
int32_t aCaretOffset);
|
||||||
void SendTextTraversedEvent(AccessibleWrap* aAccessible,
|
void SendTextTraversedEvent(AccessibleWrap* aAccessible, int32_t aStartOffset,
|
||||||
int32_t aStartOffset,
|
|
||||||
int32_t aEndOffset);
|
int32_t aEndOffset);
|
||||||
void SendTextChangedEvent(AccessibleWrap* aAccessible,
|
void SendTextChangedEvent(AccessibleWrap* aAccessible, const nsString& aStr,
|
||||||
const nsString& aStr,
|
int32_t aStart, uint32_t aLen, bool aIsInsert,
|
||||||
int32_t aStart,
|
|
||||||
uint32_t aLen,
|
|
||||||
bool aIsInsert,
|
|
||||||
bool aFromUser);
|
bool aFromUser);
|
||||||
void SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelected);
|
void SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelected);
|
||||||
void SendClickedEvent(AccessibleWrap* aAccessible, bool aChecked);
|
void SendClickedEvent(AccessibleWrap* aAccessible, bool aChecked);
|
||||||
@@ -106,28 +97,31 @@ public:
|
|||||||
void SendWindowStateChangedEvent(AccessibleWrap* aAccessible);
|
void SendWindowStateChangedEvent(AccessibleWrap* aAccessible);
|
||||||
|
|
||||||
// Cache methods
|
// Cache methods
|
||||||
void ReplaceViewportCache(const nsTArray<AccessibleWrap*>& aAccessibles,
|
void ReplaceViewportCache(
|
||||||
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
|
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
||||||
|
|
||||||
void ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAccessibles,
|
void ReplaceFocusPathCache(
|
||||||
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
|
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
||||||
|
|
||||||
void UpdateCachedBounds(const nsTArray<AccessibleWrap*>& aAccessibles,
|
void UpdateCachedBounds(
|
||||||
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
|
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
||||||
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SessionAccessibility)
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SessionAccessibility)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~SessionAccessibility() {}
|
~SessionAccessibility() {}
|
||||||
|
|
||||||
void SetAttached(bool aAttached, already_AddRefed<Runnable> aRunnable);
|
void SetAttached(bool aAttached, already_AddRefed<Runnable> aRunnable);
|
||||||
RootAccessibleWrap* GetRoot();
|
RootAccessibleWrap* GetRoot();
|
||||||
|
|
||||||
nsWindow::WindowPtr<SessionAccessibility> mWindow; // Parent only
|
nsWindow::WindowPtr<SessionAccessibility> mWindow; // Parent only
|
||||||
java::SessionAccessibility::NativeProvider::GlobalRef mSessionAccessibility;
|
java::SessionAccessibility::NativeProvider::GlobalRef mSessionAccessibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class TextLeafAccessible TextLeafAccessibleWrap;
|
typedef class TextLeafAccessible TextLeafAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace a11y {
|
|||||||
typedef class XULListboxAccessible XULListboxAccessibleWrap;
|
typedef class XULListboxAccessible XULListboxAccessibleWrap;
|
||||||
typedef class XULListCellAccessible XULListCellAccessibleWrap;
|
typedef class XULListCellAccessible XULListCellAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class XULMenuitemAccessible XULMenuitemAccessibleWrap;
|
typedef class XULMenuitemAccessible XULMenuitemAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace a11y {
|
|||||||
typedef class XULTreeGridAccessible XULTreeGridAccessibleWrap;
|
typedef class XULTreeGridAccessible XULTreeGridAccessibleWrap;
|
||||||
typedef class XULTreeGridCellAccessible XULTreeGridCellAccessibleWrap;
|
typedef class XULTreeGridCellAccessible XULTreeGridCellAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ using namespace mozilla;
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
bool
|
bool AccessibleNode::IsAOMEnabled(JSContext* aCx, JSObject* /*unused*/) {
|
||||||
AccessibleNode::IsAOMEnabled(JSContext* aCx, JSObject* /*unused*/)
|
|
||||||
{
|
|
||||||
static bool sPrefCached = false;
|
static bool sPrefCached = false;
|
||||||
static bool sPrefCacheValue = false;
|
static bool sPrefCacheValue = false;
|
||||||
|
|
||||||
@@ -43,15 +41,14 @@ NS_INTERFACE_MAP_END
|
|||||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(AccessibleNode)
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(AccessibleNode)
|
||||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(AccessibleNode)
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(AccessibleNode)
|
||||||
|
|
||||||
AccessibleNode::AccessibleNode(nsINode* aNode) :
|
AccessibleNode::AccessibleNode(nsINode* aNode)
|
||||||
mDoubleProperties(3),
|
: mDoubleProperties(3),
|
||||||
mIntProperties(3),
|
mIntProperties(3),
|
||||||
mUIntProperties(6),
|
mUIntProperties(6),
|
||||||
mBooleanProperties(0),
|
mBooleanProperties(0),
|
||||||
mRelationProperties(3),
|
mRelationProperties(3),
|
||||||
mStringProperties(16),
|
mStringProperties(16),
|
||||||
mDOMNode(aNode)
|
mDOMNode(aNode) {
|
||||||
{
|
|
||||||
nsAccessibilityService* accService = GetOrCreateAccService();
|
nsAccessibilityService* accService = GetOrCreateAccService();
|
||||||
if (!accService) {
|
if (!accService) {
|
||||||
return;
|
return;
|
||||||
@@ -63,25 +60,18 @@ AccessibleNode::AccessibleNode(nsINode* aNode) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessibleNode::~AccessibleNode()
|
AccessibleNode::~AccessibleNode() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/* virtual */ JSObject*
|
/* virtual */ JSObject* AccessibleNode::WrapObject(
|
||||||
AccessibleNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
||||||
{
|
|
||||||
return AccessibleNode_Binding::Wrap(aCx, this, aGivenProto);
|
return AccessibleNode_Binding::Wrap(aCx, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ ParentObject
|
/* virtual */ ParentObject AccessibleNode::GetParentObject() const {
|
||||||
AccessibleNode::GetParentObject() const
|
|
||||||
{
|
|
||||||
return mDOMNode->GetParentObject();
|
return mDOMNode->GetParentObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccessibleNode::GetComputedRole(nsAString& aRole) {
|
||||||
AccessibleNode::GetComputedRole(nsAString& aRole)
|
|
||||||
{
|
|
||||||
if (mIntl) {
|
if (mIntl) {
|
||||||
nsAccessibilityService* accService = GetOrCreateAccService();
|
nsAccessibilityService* accService = GetOrCreateAccService();
|
||||||
if (accService) {
|
if (accService) {
|
||||||
@@ -93,9 +83,7 @@ AccessibleNode::GetComputedRole(nsAString& aRole)
|
|||||||
aRole.AssignLiteral("unknown");
|
aRole.AssignLiteral("unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccessibleNode::GetStates(nsTArray<nsString>& aStates) {
|
||||||
AccessibleNode::GetStates(nsTArray<nsString>& aStates)
|
|
||||||
{
|
|
||||||
nsAccessibilityService* accService = GetOrCreateAccService();
|
nsAccessibilityService* accService = GetOrCreateAccService();
|
||||||
if (!mIntl || !accService) {
|
if (!mIntl || !accService) {
|
||||||
aStates.AppendElement(NS_LITERAL_STRING("defunct"));
|
aStates.AppendElement(NS_LITERAL_STRING("defunct"));
|
||||||
@@ -111,9 +99,7 @@ AccessibleNode::GetStates(nsTArray<nsString>& aStates)
|
|||||||
aStates = mStates->StringArray();
|
aStates = mStates->StringArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccessibleNode::GetAttributes(nsTArray<nsString>& aAttributes) {
|
||||||
AccessibleNode::GetAttributes(nsTArray<nsString>& aAttributes)
|
|
||||||
{
|
|
||||||
if (!mIntl) {
|
if (!mIntl) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -136,13 +122,12 @@ AccessibleNode::GetAttributes(nsTArray<nsString>& aAttributes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool AccessibleNode::Is(const Sequence<nsString>& aFlavors) {
|
||||||
AccessibleNode::Is(const Sequence<nsString>& aFlavors)
|
|
||||||
{
|
|
||||||
nsAccessibilityService* accService = GetOrCreateAccService();
|
nsAccessibilityService* accService = GetOrCreateAccService();
|
||||||
if (!mIntl || !accService) {
|
if (!mIntl || !accService) {
|
||||||
for (const auto& flavor : aFlavors) {
|
for (const auto& flavor : aFlavors) {
|
||||||
if (!flavor.EqualsLiteral("unknown") && !flavor.EqualsLiteral("defunct")) {
|
if (!flavor.EqualsLiteral("unknown") &&
|
||||||
|
!flavor.EqualsLiteral("defunct")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,9 +149,7 @@ AccessibleNode::Is(const Sequence<nsString>& aFlavors)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool AccessibleNode::Has(const Sequence<nsString>& aAttributes) {
|
||||||
AccessibleNode::Has(const Sequence<nsString>& aAttributes)
|
|
||||||
{
|
|
||||||
if (!mIntl) {
|
if (!mIntl) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -181,11 +164,9 @@ AccessibleNode::Has(const Sequence<nsString>& aAttributes)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
|
||||||
AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
|
JS::MutableHandle<JS::Value> aValue,
|
||||||
JS::MutableHandle<JS::Value> aValue,
|
ErrorResult& aRv) {
|
||||||
ErrorResult& aRv)
|
|
||||||
{
|
|
||||||
if (!mIntl) {
|
if (!mIntl) {
|
||||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||||
return;
|
return;
|
||||||
@@ -204,8 +185,4 @@ AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
|
|||||||
aValue.set(jsval);
|
aValue.set(jsval);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsINode*
|
nsINode* AccessibleNode::GetDOMNode() { return mDOMNode; }
|
||||||
AccessibleNode::GetDOMNode()
|
|
||||||
{
|
|
||||||
return mDOMNode;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class nsINode;
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
class Accessible;
|
class Accessible;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
@@ -27,86 +27,75 @@ namespace dom {
|
|||||||
class DOMStringList;
|
class DOMStringList;
|
||||||
struct ParentObject;
|
struct ParentObject;
|
||||||
|
|
||||||
#define ANODE_ENUM(name) \
|
#define ANODE_ENUM(name) e##name,
|
||||||
e##name,
|
|
||||||
|
|
||||||
#define ANODE_FUNC(typeName, type, name) \
|
#define ANODE_FUNC(typeName, type, name) \
|
||||||
dom::Nullable<type> Get##name() \
|
dom::Nullable<type> Get##name() { \
|
||||||
{ \
|
|
||||||
return GetProperty(AOM##typeName##Property::e##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); \
|
SetProperty(AOM##typeName##Property::e##name, a##name); \
|
||||||
} \
|
}
|
||||||
|
|
||||||
#define ANODE_STRING_FUNC(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); \
|
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); \
|
SetProperty(AOMStringProperty::e##name, a##name); \
|
||||||
} \
|
}
|
||||||
|
|
||||||
#define ANODE_RELATION_FUNC(name) \
|
#define ANODE_RELATION_FUNC(name) \
|
||||||
already_AddRefed<AccessibleNode> Get##name() \
|
already_AddRefed<AccessibleNode> Get##name() { \
|
||||||
{ \
|
|
||||||
return GetProperty(AOMRelationProperty::e##name); \
|
return GetProperty(AOMRelationProperty::e##name); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void Set##name(AccessibleNode* a##name) \
|
void Set##name(AccessibleNode* a##name) { \
|
||||||
{ \
|
|
||||||
SetProperty(AOMRelationProperty::e##name, a##name); \
|
SetProperty(AOMRelationProperty::e##name, a##name); \
|
||||||
} \
|
}
|
||||||
|
|
||||||
#define ANODE_PROPS(typeName, type, ...) \
|
#define ANODE_PROPS(typeName, type, ...) \
|
||||||
enum class AOM##typeName##Property { \
|
enum class AOM##typeName##Property{ \
|
||||||
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__)) \
|
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__))}; \
|
||||||
}; \
|
MOZ_FOR_EACH(ANODE_FUNC, (typeName, type, ), (__VA_ARGS__))
|
||||||
MOZ_FOR_EACH(ANODE_FUNC, (typeName, type,), (__VA_ARGS__)) \
|
|
||||||
|
|
||||||
#define ANODE_STRING_PROPS(...) \
|
#define ANODE_STRING_PROPS(...) \
|
||||||
enum class AOMStringProperty { \
|
enum class AOMStringProperty { \
|
||||||
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__)) \
|
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(...) \
|
#define ANODE_RELATION_PROPS(...) \
|
||||||
enum class AOMRelationProperty { \
|
enum class AOMRelationProperty { \
|
||||||
MOZ_FOR_EACH(ANODE_ENUM, (), (__VA_ARGS__)) \
|
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) \
|
#define ANODE_ACCESSOR_MUTATOR(typeName, type, defVal) \
|
||||||
nsDataHashtable<nsUint32HashKey, type> m##typeName##Properties; \
|
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; \
|
||||||
type value = defVal; \
|
if (m##typeName##Properties.Get(static_cast<int>(aProperty), &value)) { \
|
||||||
if (m##typeName##Properties.Get(static_cast<int>(aProperty), &value)) { \
|
return dom::Nullable<type>(value); \
|
||||||
return dom::Nullable<type>(value); \
|
} \
|
||||||
} \
|
return dom::Nullable<type>(); \
|
||||||
return dom::Nullable<type>(); \
|
} \
|
||||||
} \
|
\
|
||||||
\
|
void SetProperty(AOM##typeName##Property aProperty, \
|
||||||
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)); \
|
||||||
if (aValue.IsNull()) { \
|
} else { \
|
||||||
m##typeName##Properties.Remove(static_cast<int>(aProperty)); \
|
m##typeName##Properties.Put(static_cast<int>(aProperty), \
|
||||||
} else { \
|
aValue.Value()); \
|
||||||
m##typeName##Properties.Put(static_cast<int>(aProperty), aValue.Value()); \
|
} \
|
||||||
} \
|
}
|
||||||
} \
|
|
||||||
|
|
||||||
class AccessibleNode : public nsISupports,
|
class AccessibleNode : public nsISupports, public nsWrapperCache {
|
||||||
public nsWrapperCache
|
public:
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit AccessibleNode(nsINode* aNode);
|
explicit AccessibleNode(nsINode* aNode);
|
||||||
|
|
||||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS;
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS;
|
||||||
@@ -123,72 +112,27 @@ public:
|
|||||||
bool Is(const Sequence<nsString>& aFlavors);
|
bool Is(const Sequence<nsString>& aFlavors);
|
||||||
bool Has(const Sequence<nsString>& aAttributes);
|
bool Has(const Sequence<nsString>& aAttributes);
|
||||||
void Get(JSContext* cx, const nsAString& aAttribute,
|
void Get(JSContext* cx, const nsAString& aAttribute,
|
||||||
JS::MutableHandle<JS::Value> aValue,
|
JS::MutableHandle<JS::Value> aValue, ErrorResult& aRv);
|
||||||
ErrorResult& aRv);
|
|
||||||
|
|
||||||
static bool IsAOMEnabled(JSContext*, JSObject*);
|
static bool IsAOMEnabled(JSContext*, JSObject*);
|
||||||
|
|
||||||
ANODE_STRING_PROPS(
|
ANODE_STRING_PROPS(Autocomplete, Checked, Current, HasPopUp, Invalid,
|
||||||
Autocomplete,
|
KeyShortcuts, Label, Live, Orientation, Placeholder,
|
||||||
Checked,
|
Pressed, Relevant, Role, RoleDescription, Sort, ValueText)
|
||||||
Current,
|
|
||||||
HasPopUp,
|
|
||||||
Invalid,
|
|
||||||
KeyShortcuts,
|
|
||||||
Label,
|
|
||||||
Live,
|
|
||||||
Orientation,
|
|
||||||
Placeholder,
|
|
||||||
Pressed,
|
|
||||||
Relevant,
|
|
||||||
Role,
|
|
||||||
RoleDescription,
|
|
||||||
Sort,
|
|
||||||
ValueText
|
|
||||||
)
|
|
||||||
|
|
||||||
ANODE_PROPS(Boolean, bool,
|
ANODE_PROPS(Boolean, bool, Atomic, Busy, Disabled, Expanded, Hidden, Modal,
|
||||||
Atomic,
|
Multiline, Multiselectable, ReadOnly, Required, Selected)
|
||||||
Busy,
|
|
||||||
Disabled,
|
|
||||||
Expanded,
|
|
||||||
Hidden,
|
|
||||||
Modal,
|
|
||||||
Multiline,
|
|
||||||
Multiselectable,
|
|
||||||
ReadOnly,
|
|
||||||
Required,
|
|
||||||
Selected
|
|
||||||
)
|
|
||||||
|
|
||||||
ANODE_PROPS(UInt, uint32_t,
|
ANODE_PROPS(UInt, uint32_t, ColIndex, ColSpan, Level, PosInSet, RowIndex,
|
||||||
ColIndex,
|
RowSpan)
|
||||||
ColSpan,
|
|
||||||
Level,
|
|
||||||
PosInSet,
|
|
||||||
RowIndex,
|
|
||||||
RowSpan
|
|
||||||
)
|
|
||||||
|
|
||||||
ANODE_PROPS(Int, int32_t,
|
ANODE_PROPS(Int, int32_t, ColCount, RowCount, SetSize)
|
||||||
ColCount,
|
|
||||||
RowCount,
|
|
||||||
SetSize
|
|
||||||
)
|
|
||||||
|
|
||||||
ANODE_PROPS(Double, double,
|
ANODE_PROPS(Double, double, ValueMax, ValueMin, ValueNow)
|
||||||
ValueMax,
|
|
||||||
ValueMin,
|
|
||||||
ValueNow
|
|
||||||
)
|
|
||||||
|
|
||||||
ANODE_RELATION_PROPS(
|
ANODE_RELATION_PROPS(ActiveDescendant, Details, ErrorMessage)
|
||||||
ActiveDescendant,
|
|
||||||
Details,
|
|
||||||
ErrorMessage
|
|
||||||
)
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AccessibleNode(const AccessibleNode& aCopy) = delete;
|
AccessibleNode(const AccessibleNode& aCopy) = delete;
|
||||||
AccessibleNode& operator=(const AccessibleNode& aCopy) = delete;
|
AccessibleNode& operator=(const AccessibleNode& aCopy) = delete;
|
||||||
virtual ~AccessibleNode();
|
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);
|
int num = static_cast<int>(aProperty);
|
||||||
if (mBooleanProperties & (1U << (2 * num))) {
|
if (mBooleanProperties & (1U << (2 * num))) {
|
||||||
bool data = static_cast<bool>(mBooleanProperties & (1U << (2 * num + 1)));
|
bool data = static_cast<bool>(mBooleanProperties & (1U << (2 * num + 1)));
|
||||||
@@ -221,15 +164,15 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetProperty(AOMBooleanProperty aProperty,
|
void SetProperty(AOMBooleanProperty aProperty,
|
||||||
const dom::Nullable<bool>& aValue)
|
const dom::Nullable<bool>& aValue) {
|
||||||
{
|
|
||||||
int num = static_cast<int>(aProperty);
|
int num = static_cast<int>(aProperty);
|
||||||
if (aValue.IsNull()) {
|
if (aValue.IsNull()) {
|
||||||
mBooleanProperties &= ~(1U << (2 * num));
|
mBooleanProperties &= ~(1U << (2 * num));
|
||||||
} else {
|
} else {
|
||||||
mBooleanProperties |= (1U << (2 * num));
|
mBooleanProperties |= (1U << (2 * num));
|
||||||
mBooleanProperties = (aValue.Value() ? mBooleanProperties | (1U << (2 * num + 1))
|
mBooleanProperties =
|
||||||
: mBooleanProperties & ~(1U << (2 * num + 1)));
|
(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(Int, int32_t, 0)
|
||||||
ANODE_ACCESSOR_MUTATOR(UInt, uint32_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));
|
return mRelationProperties.Get(static_cast<int>(aProperty));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetProperty(AOMRelationProperty aProperty,
|
void SetProperty(AOMRelationProperty aProperty, AccessibleNode* aValue) {
|
||||||
AccessibleNode* aValue)
|
|
||||||
{
|
|
||||||
if (!aValue) {
|
if (!aValue) {
|
||||||
mRelationProperties.Remove(static_cast<int>(aProperty));
|
mRelationProperties.Remove(static_cast<int>(aProperty));
|
||||||
} else {
|
} else {
|
||||||
@@ -252,8 +192,8 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The 2k'th bit indicates whether the k'th boolean property is used(1) or not(0)
|
// The 2k'th bit indicates whether the k'th boolean property is used(1) or
|
||||||
// and 2k+1'th bit contains the property's value(1:true, 0:false)
|
// not(0) and 2k+1'th bit contains the property's value(1:true, 0:false)
|
||||||
uint32_t mBooleanProperties;
|
uint32_t mBooleanProperties;
|
||||||
nsRefPtrHashtable<nsUint32HashKey, AccessibleNode> mRelationProperties;
|
nsRefPtrHashtable<nsUint32HashKey, AccessibleNode> mRelationProperties;
|
||||||
nsDataHashtable<nsUint32HashKey, nsString> mStringProperties;
|
nsDataHashtable<nsUint32HashKey, nsString> mStringProperties;
|
||||||
@@ -263,8 +203,7 @@ protected:
|
|||||||
RefPtr<dom::DOMStringList> mStates;
|
RefPtr<dom::DOMStringList> mStates;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // dom
|
} // namespace dom
|
||||||
} // mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // A11Y_JSAPI_ACCESSIBLENODE
|
||||||
#endif // A11Y_JSAPI_ACCESSIBLENODE
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace a11y {
|
|||||||
typedef class ARIAGridAccessible ARIAGridAccessibleWrap;
|
typedef class ARIAGridAccessible ARIAGridAccessibleWrap;
|
||||||
typedef class ARIAGridCellAccessible ARIAGridCellAccessibleWrap;
|
typedef class ARIAGridCellAccessible ARIAGridCellAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -14,10 +14,10 @@ struct _AtkObject;
|
|||||||
typedef struct _AtkObject AtkObject;
|
typedef struct _AtkObject AtkObject;
|
||||||
|
|
||||||
enum AtkProperty {
|
enum AtkProperty {
|
||||||
PROP_0, // gobject convention
|
PROP_0, // gobject convention
|
||||||
PROP_NAME,
|
PROP_NAME,
|
||||||
PROP_DESCRIPTION,
|
PROP_DESCRIPTION,
|
||||||
PROP_PARENT, // ancestry has changed
|
PROP_PARENT, // ancestry has changed
|
||||||
PROP_ROLE,
|
PROP_ROLE,
|
||||||
PROP_LAYER,
|
PROP_LAYER,
|
||||||
PROP_MDI_ZORDER,
|
PROP_MDI_ZORDER,
|
||||||
@@ -27,13 +27,13 @@ enum AtkProperty {
|
|||||||
PROP_TABLE_ROW_DESCRIPTION,
|
PROP_TABLE_ROW_DESCRIPTION,
|
||||||
PROP_TABLE_ROW_HEADER,
|
PROP_TABLE_ROW_HEADER,
|
||||||
PROP_TABLE_SUMMARY,
|
PROP_TABLE_SUMMARY,
|
||||||
PROP_LAST // gobject convention
|
PROP_LAST // gobject convention
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AtkPropertyChange {
|
struct AtkPropertyChange {
|
||||||
int32_t type; // property type as listed above
|
int32_t type; // property type as listed above
|
||||||
void *oldvalue;
|
void* oldvalue;
|
||||||
void *newvalue;
|
void* newvalue;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
@@ -45,9 +45,8 @@ class MaiHyperlink;
|
|||||||
* AccessibleWrap, and its descendents in atk directory provide the
|
* AccessibleWrap, and its descendents in atk directory provide the
|
||||||
* implementation of AtkObject.
|
* implementation of AtkObject.
|
||||||
*/
|
*/
|
||||||
class AccessibleWrap : public Accessible
|
class AccessibleWrap : public Accessible {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
|
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
|
||||||
virtual ~AccessibleWrap();
|
virtual ~AccessibleWrap();
|
||||||
void ShutdownAtkObject();
|
void ShutdownAtkObject();
|
||||||
@@ -58,12 +57,12 @@ public:
|
|||||||
virtual void GetNativeInterface(void** aOutAccessible) override;
|
virtual void GetNativeInterface(void** aOutAccessible) override;
|
||||||
virtual nsresult HandleAccEvent(AccEvent* aEvent) override;
|
virtual nsresult HandleAccEvent(AccEvent* aEvent) override;
|
||||||
|
|
||||||
AtkObject * GetAtkObject(void);
|
AtkObject* GetAtkObject(void);
|
||||||
static AtkObject* GetAtkObject(Accessible* aAccessible);
|
static AtkObject* GetAtkObject(Accessible* aAccessible);
|
||||||
|
|
||||||
bool IsValidObject();
|
bool IsValidObject();
|
||||||
|
|
||||||
static const char * ReturnString(nsAString &aString) {
|
static const char* ReturnString(nsAString& aString) {
|
||||||
static nsCString returnedString;
|
static nsCString returnedString;
|
||||||
returnedString = NS_ConvertUTF16toUTF8(aString);
|
returnedString = NS_ConvertUTF16toUTF8(aString);
|
||||||
return returnedString.get();
|
return returnedString.get();
|
||||||
@@ -75,18 +74,18 @@ public:
|
|||||||
int32_t aColIdx);
|
int32_t aColIdx);
|
||||||
static Accessible* GetRowHeader(TableAccessible* aAccessible,
|
static Accessible* GetRowHeader(TableAccessible* aAccessible,
|
||||||
int32_t aRowIdx);
|
int32_t aRowIdx);
|
||||||
protected:
|
|
||||||
|
|
||||||
nsresult FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject *aObject);
|
protected:
|
||||||
nsresult FireAtkTextChangedEvent(AccEvent* aEvent, AtkObject *aObject);
|
nsresult FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject* aObject);
|
||||||
|
nsresult FireAtkTextChangedEvent(AccEvent* aEvent, AtkObject* aObject);
|
||||||
|
|
||||||
AtkObject *mAtkObject;
|
AtkObject* mAtkObject;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t CreateMaiInterfaces();
|
uint16_t CreateMaiInterfaces();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* __NS_ACCESSIBLE_WRAP_H__ */
|
#endif /* __NS_ACCESSIBLE_WRAP_H__ */
|
||||||
|
|||||||
@@ -16,70 +16,55 @@
|
|||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
|
|
||||||
// ApplicationAccessibleWrap
|
// ApplicationAccessibleWrap
|
||||||
|
|
||||||
ApplicationAccessibleWrap::ApplicationAccessibleWrap():
|
ApplicationAccessibleWrap::ApplicationAccessibleWrap()
|
||||||
ApplicationAccessible()
|
: ApplicationAccessible() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationAccessibleWrap::~ApplicationAccessibleWrap()
|
ApplicationAccessibleWrap::~ApplicationAccessibleWrap() {
|
||||||
{
|
|
||||||
AccessibleWrap::ShutdownAtkObject();
|
AccessibleWrap::ShutdownAtkObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean toplevel_event_watcher(GSignalInvocationHint* ihint,
|
||||||
toplevel_event_watcher(GSignalInvocationHint* ihint,
|
guint n_param_values,
|
||||||
guint n_param_values,
|
const GValue* param_values, gpointer data) {
|
||||||
const GValue* param_values,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
static GQuark sQuark_gecko_acc_obj = 0;
|
static GQuark sQuark_gecko_acc_obj = 0;
|
||||||
|
|
||||||
if (!sQuark_gecko_acc_obj)
|
if (!sQuark_gecko_acc_obj)
|
||||||
sQuark_gecko_acc_obj = g_quark_from_static_string("GeckoAccObj");
|
sQuark_gecko_acc_obj = g_quark_from_static_string("GeckoAccObj");
|
||||||
|
|
||||||
if (nsAccessibilityService::IsShutdown())
|
if (nsAccessibilityService::IsShutdown()) return TRUE;
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
GObject* object = reinterpret_cast<GObject*>(g_value_get_object(param_values));
|
GObject* object =
|
||||||
if (!GTK_IS_WINDOW(object))
|
reinterpret_cast<GObject*>(g_value_get_object(param_values));
|
||||||
return TRUE;
|
if (!GTK_IS_WINDOW(object)) return TRUE;
|
||||||
|
|
||||||
AtkObject* child = gtk_widget_get_accessible(GTK_WIDGET(object));
|
AtkObject* child = gtk_widget_get_accessible(GTK_WIDGET(object));
|
||||||
|
|
||||||
// GTK native dialog
|
// GTK native dialog
|
||||||
if (!IS_MAI_OBJECT(child) &&
|
if (!IS_MAI_OBJECT(child) &&
|
||||||
(atk_object_get_role(child) == ATK_ROLE_DIALOG)) {
|
(atk_object_get_role(child) == ATK_ROLE_DIALOG)) {
|
||||||
|
|
||||||
if (data == reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW)) {
|
if (data == reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW)) {
|
||||||
|
|
||||||
// Attach the dialog accessible to app accessible tree
|
// Attach the dialog accessible to app accessible tree
|
||||||
Accessible* windowAcc = GetAccService()->AddNativeRootAccessible(child);
|
Accessible* windowAcc = GetAccService()->AddNativeRootAccessible(child);
|
||||||
g_object_set_qdata(G_OBJECT(child), sQuark_gecko_acc_obj,
|
g_object_set_qdata(G_OBJECT(child), sQuark_gecko_acc_obj,
|
||||||
reinterpret_cast<gpointer>(windowAcc));
|
reinterpret_cast<gpointer>(windowAcc));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Deattach the dialog accessible
|
// Deattach the dialog accessible
|
||||||
Accessible* windowAcc =
|
Accessible* windowAcc = reinterpret_cast<Accessible*>(
|
||||||
reinterpret_cast<Accessible*>
|
g_object_get_qdata(G_OBJECT(child), sQuark_gecko_acc_obj));
|
||||||
(g_object_get_qdata(G_OBJECT(child), sQuark_gecko_acc_obj));
|
|
||||||
if (windowAcc) {
|
if (windowAcc) {
|
||||||
GetAccService()->RemoveNativeRootAccessible(windowAcc);
|
GetAccService()->RemoveNativeRootAccessible(windowAcc);
|
||||||
g_object_set_qdata(G_OBJECT(child), sQuark_gecko_acc_obj, nullptr);
|
g_object_set_qdata(G_OBJECT(child), sQuark_gecko_acc_obj, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENameValueFlag
|
ENameValueFlag ApplicationAccessibleWrap::Name(nsString& aName) const {
|
||||||
ApplicationAccessibleWrap::Name(nsString& aName) const
|
|
||||||
{
|
|
||||||
// ATK doesn't provide a way to obtain an application name (for example,
|
// 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
|
// 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,
|
// 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;
|
return eNameOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible) {
|
||||||
ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible)
|
|
||||||
{
|
|
||||||
*aOutAccessible = nullptr;
|
*aOutAccessible = nullptr;
|
||||||
|
|
||||||
if (!mAtkObject) {
|
if (!mAtkObject) {
|
||||||
mAtkObject =
|
mAtkObject = reinterpret_cast<AtkObject*>(
|
||||||
reinterpret_cast<AtkObject*>(g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
|
g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
|
||||||
if (!mAtkObject)
|
if (!mAtkObject) return;
|
||||||
return;
|
|
||||||
|
|
||||||
atk_object_initialize(mAtkObject, this);
|
atk_object_initialize(mAtkObject, this);
|
||||||
mAtkObject->role = ATK_ROLE_INVALID;
|
mAtkObject->role = ATK_ROLE_INVALID;
|
||||||
@@ -108,53 +90,48 @@ ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct AtkRootAccessibleAddedEvent {
|
struct AtkRootAccessibleAddedEvent {
|
||||||
AtkObject *app_accessible;
|
AtkObject* app_accessible;
|
||||||
AtkObject *root_accessible;
|
AtkObject* root_accessible;
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
};
|
};
|
||||||
|
|
||||||
gboolean fireRootAccessibleAddedCB(gpointer data)
|
gboolean fireRootAccessibleAddedCB(gpointer data) {
|
||||||
{
|
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)data;
|
||||||
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)data;
|
g_signal_emit_by_name(eventData->app_accessible, "children_changed::add",
|
||||||
g_signal_emit_by_name(eventData->app_accessible, "children_changed::add",
|
eventData->index, eventData->root_accessible, nullptr);
|
||||||
eventData->index, eventData->root_accessible, nullptr);
|
g_object_unref(eventData->app_accessible);
|
||||||
g_object_unref(eventData->app_accessible);
|
g_object_unref(eventData->root_accessible);
|
||||||
g_object_unref(eventData->root_accessible);
|
free(data);
|
||||||
free(data);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx,
|
||||||
ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx, Accessible* aChild)
|
Accessible* aChild) {
|
||||||
{
|
if (!ApplicationAccessible::InsertChildAt(aIdx, aChild)) return false;
|
||||||
if (!ApplicationAccessible::InsertChildAt(aIdx, aChild))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AtkObject* atkAccessible = AccessibleWrap::GetAtkObject(aChild);
|
AtkObject* atkAccessible = AccessibleWrap::GetAtkObject(aChild);
|
||||||
atk_object_set_parent(atkAccessible, mAtkObject);
|
atk_object_set_parent(atkAccessible, mAtkObject);
|
||||||
|
|
||||||
uint32_t count = mChildren.Length();
|
uint32_t count = mChildren.Length();
|
||||||
|
|
||||||
// Emit children_changed::add in a timeout
|
// Emit children_changed::add in a timeout
|
||||||
// to make sure aRootAccWrap is fully initialized.
|
// to make sure aRootAccWrap is fully initialized.
|
||||||
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)
|
AtkRootAccessibleAddedEvent* eventData =
|
||||||
malloc(sizeof(AtkRootAccessibleAddedEvent));
|
(AtkRootAccessibleAddedEvent*)malloc(sizeof(AtkRootAccessibleAddedEvent));
|
||||||
if (eventData) {
|
if (eventData) {
|
||||||
eventData->app_accessible = mAtkObject;
|
eventData->app_accessible = mAtkObject;
|
||||||
eventData->root_accessible = atkAccessible;
|
eventData->root_accessible = atkAccessible;
|
||||||
eventData->index = count -1;
|
eventData->index = count - 1;
|
||||||
g_object_ref(mAtkObject);
|
g_object_ref(mAtkObject);
|
||||||
g_object_ref(atkAccessible);
|
g_object_ref(atkAccessible);
|
||||||
g_timeout_add(0, fireRootAccessibleAddedCB, eventData);
|
g_timeout_add(0, fireRootAccessibleAddedCB, eventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool ApplicationAccessibleWrap::RemoveChild(Accessible* aChild) {
|
||||||
ApplicationAccessibleWrap::RemoveChild(Accessible* aChild)
|
|
||||||
{
|
|
||||||
int32_t index = aChild->IndexInParent();
|
int32_t index = aChild->IndexInParent();
|
||||||
|
|
||||||
AtkObject* atkAccessible = AccessibleWrap::GetAtkObject(aChild);
|
AtkObject* atkAccessible = AccessibleWrap::GetAtkObject(aChild);
|
||||||
@@ -164,4 +141,3 @@ ApplicationAccessibleWrap::RemoveChild(Accessible* aChild)
|
|||||||
|
|
||||||
return ApplicationAccessible::RemoveChild(aChild);
|
return ApplicationAccessible::RemoveChild(aChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,8 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
class ApplicationAccessibleWrap: public ApplicationAccessible
|
class ApplicationAccessibleWrap : public ApplicationAccessible {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
ApplicationAccessibleWrap();
|
ApplicationAccessibleWrap();
|
||||||
virtual ~ApplicationAccessibleWrap();
|
virtual ~ApplicationAccessibleWrap();
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ public:
|
|||||||
virtual void GetNativeInterface(void** aOutAccessible) override;
|
virtual void GetNativeInterface(void** aOutAccessible) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* __NS_APP_ROOT_ACCESSIBLE_H__ */
|
#endif /* __NS_APP_ROOT_ACCESSIBLE_H__ */
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ using namespace mozilla::a11y;
|
|||||||
AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = nullptr;
|
AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = nullptr;
|
||||||
GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID;
|
GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID;
|
||||||
const char* AtkSocketAccessible::sATKSocketEmbedSymbol = "atk_socket_embed";
|
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;
|
bool AtkSocketAccessible::gCanEmbed = FALSE;
|
||||||
|
|
||||||
@@ -27,19 +28,11 @@ G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
|
|||||||
G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
|
G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
|
||||||
mai_atk_component_iface_init))
|
mai_atk_component_iface_init))
|
||||||
|
|
||||||
void
|
void mai_atk_socket_class_init(MaiAtkSocketClass* aAcc) {}
|
||||||
mai_atk_socket_class_init(MaiAtkSocketClass* aAcc)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void mai_atk_socket_init(MaiAtkSocket* aAcc) {}
|
||||||
mai_atk_socket_init(MaiAtkSocket* aAcc)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject* mai_atk_socket_new(AccessibleWrap* aAccWrap) {
|
||||||
mai_atk_socket_new(AccessibleWrap* aAccWrap)
|
|
||||||
{
|
|
||||||
NS_ENSURE_TRUE(aAccWrap, nullptr);
|
NS_ENSURE_TRUE(aAccWrap, nullptr);
|
||||||
|
|
||||||
MaiAtkSocket* acc = nullptr;
|
MaiAtkSocket* acc = nullptr;
|
||||||
@@ -51,36 +44,28 @@ mai_atk_socket_new(AccessibleWrap* aAccWrap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static AtkObject*
|
static AtkObject* RefAccessibleAtPoint(AtkComponent* aComponent, gint aX,
|
||||||
RefAccessibleAtPoint(AtkComponent* aComponent, gint aX, gint aY,
|
gint aY, AtkCoordType aCoordType) {
|
||||||
AtkCoordType aCoordType)
|
|
||||||
{
|
|
||||||
NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);
|
NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);
|
||||||
|
|
||||||
return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
|
return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX,
|
||||||
aX, aY, aCoordType);
|
aY, aCoordType);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void GetExtents(AtkComponent* aComponent, gint* aX, gint* aY,
|
||||||
GetExtents(AtkComponent* aComponent, gint* aX, gint* aY, gint* aWidth,
|
gint* aWidth, gint* aHeight, AtkCoordType aCoordType) {
|
||||||
gint* aHeight, AtkCoordType aCoordType)
|
|
||||||
{
|
|
||||||
*aX = *aY = *aWidth = *aHeight = 0;
|
*aX = *aY = *aWidth = *aHeight = 0;
|
||||||
|
|
||||||
if (!MAI_IS_ATK_SOCKET(aComponent))
|
if (!MAI_IS_ATK_SOCKET(aComponent)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
|
getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX, aY, aWidth,
|
||||||
aX, aY, aWidth, aHeight, aCoordType);
|
aHeight, aCoordType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void mai_atk_component_iface_init(AtkComponentIface* aIface) {
|
||||||
mai_atk_component_iface_init(AtkComponentIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "Invalid Interface");
|
NS_ASSERTION(aIface, "Invalid Interface");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->ref_accessible_at_point = RefAccessibleAtPoint;
|
aIface->ref_accessible_at_point = RefAccessibleAtPoint;
|
||||||
aIface->get_extents = GetExtents;
|
aIface->get_extents = GetExtents;
|
||||||
@@ -88,12 +73,10 @@ mai_atk_component_iface_init(AtkComponentIface* aIface)
|
|||||||
|
|
||||||
AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
|
AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
|
||||||
DocAccessible* aDoc,
|
DocAccessible* aDoc,
|
||||||
const nsCString& aPlugId) :
|
const nsCString& aPlugId)
|
||||||
AccessibleWrap(aContent, aDoc)
|
: AccessibleWrap(aContent, aDoc) {
|
||||||
{
|
|
||||||
mAtkObject = mai_atk_socket_new(this);
|
mAtkObject = mai_atk_socket_new(this);
|
||||||
if (!mAtkObject)
|
if (!mAtkObject) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Embeds the children of an AtkPlug, specified by plugId, as the children of
|
// Embeds the children of an AtkPlug, specified by plugId, as the children of
|
||||||
// this socket.
|
// this socket.
|
||||||
@@ -102,20 +85,16 @@ AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
|
|||||||
if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) &&
|
if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) &&
|
||||||
!aPlugId.IsVoid()) {
|
!aPlugId.IsVoid()) {
|
||||||
AtkSocket* accSocket =
|
AtkSocket* accSocket =
|
||||||
G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
|
G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
|
||||||
g_atk_socket_embed(accSocket, (gchar*)aPlugId.get());
|
g_atk_socket_embed(accSocket, (gchar*)aPlugId.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AtkSocketAccessible::GetNativeInterface(void** aOutAccessible) {
|
||||||
AtkSocketAccessible::GetNativeInterface(void** aOutAccessible)
|
|
||||||
{
|
|
||||||
*aOutAccessible = mAtkObject;
|
*aOutAccessible = mAtkObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AtkSocketAccessible::Shutdown() {
|
||||||
AtkSocketAccessible::Shutdown()
|
|
||||||
{
|
|
||||||
if (mAtkObject) {
|
if (mAtkObject) {
|
||||||
if (MAI_IS_ATK_SOCKET(mAtkObject))
|
if (MAI_IS_ATK_SOCKET(mAtkObject))
|
||||||
MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr;
|
MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr;
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
// This file gets included by nsAccessibilityService.cpp, which can't include
|
// 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.
|
// atk.h (or glib.h), so we can't rely on it being included.
|
||||||
#ifdef __ATK_H__
|
#ifdef __ATK_H__
|
||||||
extern "C" typedef void (*AtkSocketEmbedType) (AtkSocket*, gchar*);
|
extern "C" typedef void (*AtkSocketEmbedType)(AtkSocket*, gchar*);
|
||||||
#else
|
#else
|
||||||
extern "C" typedef void (*AtkSocketEmbedType) (void*, void*);
|
extern "C" typedef void (*AtkSocketEmbedType)(void*, void*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
@@ -24,10 +24,8 @@ namespace a11y {
|
|||||||
* Provides a AccessibleWrap wrapper around AtkSocket for out-of-process
|
* Provides a AccessibleWrap wrapper around AtkSocket for out-of-process
|
||||||
* accessibles.
|
* accessibles.
|
||||||
*/
|
*/
|
||||||
class AtkSocketAccessible : public AccessibleWrap
|
class AtkSocketAccessible : public AccessibleWrap {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
|
|
||||||
// Soft references to AtkSocket
|
// Soft references to AtkSocket
|
||||||
static AtkSocketEmbedType g_atk_socket_embed;
|
static AtkSocketEmbedType g_atk_socket_embed;
|
||||||
#ifdef __ATK_H__
|
#ifdef __ATK_H__
|
||||||
@@ -50,7 +48,7 @@ public:
|
|||||||
virtual void GetNativeInterface(void** aOutAccessible) override;
|
virtual void GetNativeInterface(void** aOutAccessible) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,13 +12,11 @@ namespace a11y {
|
|||||||
|
|
||||||
namespace DOMtoATK {
|
namespace DOMtoATK {
|
||||||
|
|
||||||
void
|
void AddBOMs(nsACString& aDest, const nsACString& aSource) {
|
||||||
AddBOMs(nsACString& aDest, const nsACString& aSource)
|
|
||||||
{
|
|
||||||
uint32_t destlength = 0;
|
uint32_t destlength = 0;
|
||||||
|
|
||||||
// First compute how much room we will need.
|
// 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]);
|
int bytes = UTF8traits::bytes(aSource[srci]);
|
||||||
if (bytes >= 4) {
|
if (bytes >= 4) {
|
||||||
// Non-BMP character, will add a BOM after it.
|
// Non-BMP character, will add a BOM after it.
|
||||||
@@ -29,14 +27,15 @@ AddBOMs(nsACString& aDest, const nsACString& aSource)
|
|||||||
destlength += bytes;
|
destlength += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t desti = 0; // Index within aDest.
|
uint32_t desti = 0; // Index within aDest.
|
||||||
|
|
||||||
// Add BOMs after non-BMP characters.
|
// Add BOMs after non-BMP characters.
|
||||||
aDest.SetLength(destlength);
|
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]);
|
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.
|
// Copy whole sequence.
|
||||||
aDest.Replace(desti, bytes, Substring(aSource, srci, bytes));
|
aDest.Replace(desti, bytes, Substring(aSource, srci, bytes));
|
||||||
@@ -53,15 +52,16 @@ AddBOMs(nsACString& aDest, const nsACString& aSource)
|
|||||||
desti += 3;
|
desti += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MOZ_ASSERT(desti == destlength, "Incoherency between computed length"
|
MOZ_ASSERT(desti == destlength,
|
||||||
"and actually translated length");
|
"Incoherency between computed length"
|
||||||
|
"and actually translated length");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ATKStringConverterHelper::AdjustOffsets(gint* aStartOffset,
|
||||||
ATKStringConverterHelper::AdjustOffsets(gint* aStartOffset, gint* aEndOffset,
|
gint* aEndOffset, gint count) {
|
||||||
gint count)
|
MOZ_ASSERT(!mAdjusted,
|
||||||
{
|
"DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be "
|
||||||
MOZ_ASSERT(!mAdjusted, "DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be called only once");
|
"called only once");
|
||||||
|
|
||||||
if (*aStartOffset > 0) {
|
if (*aStartOffset > 0) {
|
||||||
(*aStartOffset)--;
|
(*aStartOffset)--;
|
||||||
@@ -78,17 +78,16 @@ ATKStringConverterHelper::AdjustOffsets(gint* aStartOffset, gint* aEndOffset,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar* ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr) {
|
||||||
ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr)
|
|
||||||
{
|
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
|
|
||||||
if (mStartShifted) {
|
if (mStartShifted) {
|
||||||
// AdjustOffsets added a leading character.
|
// AdjustOffsets added a leading character.
|
||||||
|
|
||||||
MOZ_ASSERT(aStr.Length() > 0, "There should be 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(
|
||||||
"The leading character should be complete");
|
static_cast<int>(aStr.Length()) >= UTF8traits::bytes(aStr.CharAt(0)),
|
||||||
|
"The leading character should be complete");
|
||||||
|
|
||||||
// drop first character
|
// drop first character
|
||||||
skip = UTF8traits::bytes(aStr.CharAt(0));
|
skip = UTF8traits::bytes(aStr.CharAt(0));
|
||||||
@@ -108,7 +107,8 @@ ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr)
|
|||||||
}
|
}
|
||||||
MOZ_ASSERT(trail >= 0,
|
MOZ_ASSERT(trail >= 0,
|
||||||
"There should be at least a whole trailing character");
|
"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");
|
"The trailing character should be complete");
|
||||||
|
|
||||||
// Drop the last character.
|
// Drop the last character.
|
||||||
@@ -119,10 +119,10 @@ ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr)
|
|||||||
return g_strdup(aStr.get() + skip);
|
return g_strdup(aStr.get() + skip);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar* ATKStringConverterHelper::ConvertAdjusted(const nsAString& aStr) {
|
||||||
ATKStringConverterHelper::ConvertAdjusted(const nsAString& aStr)
|
MOZ_ASSERT(mAdjusted,
|
||||||
{
|
"DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be "
|
||||||
MOZ_ASSERT(mAdjusted, "DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be called before ATKStringConverterHelper::ConvertAdjusted");
|
"called before ATKStringConverterHelper::ConvertAdjusted");
|
||||||
|
|
||||||
NS_ConvertUTF16toUTF8 cautoStr(aStr);
|
NS_ConvertUTF16toUTF8 cautoStr(aStr);
|
||||||
if (!cautoStr.get()) {
|
if (!cautoStr.get()) {
|
||||||
@@ -134,9 +134,7 @@ ATKStringConverterHelper::ConvertAdjusted(const nsAString& aStr)
|
|||||||
return FinishUTF16toUTF8(cautoStrBOMs);
|
return FinishUTF16toUTF8(cautoStrBOMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar* Convert(const nsAString& aStr) {
|
||||||
Convert(const nsAString& aStr)
|
|
||||||
{
|
|
||||||
NS_ConvertUTF16toUTF8 cautoStr(aStr);
|
NS_ConvertUTF16toUTF8 cautoStr(aStr);
|
||||||
if (!cautoStr.get()) {
|
if (!cautoStr.get()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -147,15 +145,13 @@ Convert(const nsAString& aStr)
|
|||||||
return g_strdup(cautoStrBOMs.get());
|
return g_strdup(cautoStrBOMs.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ConvertTexttoAsterisks(nsAString& aString) {
|
||||||
ConvertTexttoAsterisks(nsAString& aString)
|
|
||||||
{
|
|
||||||
for (uint32_t i = 0; i < aString.Length(); i++) {
|
for (uint32_t i = 0; i < aString.Length(); i++) {
|
||||||
aString.ReplaceLiteral(i, 1, u"*");
|
aString.ReplaceLiteral(i, 1, u"*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace DOMtoATK
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -41,123 +41,122 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
namespace DOMtoATK
|
namespace DOMtoATK {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a string of accessible text into ATK gchar* string (by adding
|
* 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
|
* BOMs). This can be used when offsets do not need to be adjusted because
|
||||||
* ends of the string can not fall between surrogates.
|
* 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.
|
* 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).
|
* Replace all characters with asterisks (e.g. for password fields).
|
||||||
*/
|
*/
|
||||||
void ConvertTexttoAsterisks(nsAString& aString);
|
void ConvertTexttoAsterisks(nsAString& aString);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterize conversion.
|
* Parameterize conversion.
|
||||||
*/
|
*/
|
||||||
enum class AtkStringConvertFlags : uint32_t {
|
enum class AtkStringConvertFlags : uint32_t {
|
||||||
None = 0,
|
None = 0,
|
||||||
ConvertTextToAsterisks = 1 << 0,
|
ConvertTextToAsterisks = 1 << 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AtkStringConvertFlags)
|
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AtkStringConvertFlags)
|
||||||
|
|
||||||
class ATKStringConverterHelper {
|
class ATKStringConverterHelper {
|
||||||
public:
|
public:
|
||||||
ATKStringConverterHelper(void) :
|
ATKStringConverterHelper(void)
|
||||||
|
:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mAdjusted (false),
|
mAdjusted(false),
|
||||||
#endif
|
#endif
|
||||||
mStartShifted (false),
|
mStartShifted(false),
|
||||||
mEndShifted (false) { }
|
mEndShifted(false) {
|
||||||
|
|
||||||
/**
|
|
||||||
* In order to properly get non-BMP values, offsets need to be changed
|
|
||||||
* to get one character more on each end, so that ConvertUTF16toUTF8 can
|
|
||||||
* convert surrogates even if the originally requested offsets fall between
|
|
||||||
* them.
|
|
||||||
*/
|
|
||||||
void AdjustOffsets(gint* aStartOffset, gint* aEndOffset, gint count);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a string of accessible text with adjusted offsets into ATK
|
|
||||||
* gchar* string (by adding BOMs). Note, AdjustOffsets has to be called
|
|
||||||
* before getting the text passed to this.
|
|
||||||
*/
|
|
||||||
gchar* ConvertAdjusted(const nsAString& aStr);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* Remove the additional characters requested by PrepareUTF16toUTF8.
|
|
||||||
*/
|
|
||||||
gchar* FinishUTF16toUTF8(nsCString& aStr);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
bool mAdjusted;
|
|
||||||
#endif
|
|
||||||
bool mStartShifted;
|
|
||||||
bool mEndShifted;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get text from aAccessible, using ATKStringConverterHelper to properly
|
|
||||||
* introduce appropriate BOMs.
|
|
||||||
*/
|
|
||||||
template <class AccessibleOrProxy>
|
|
||||||
gchar* NewATKString(AccessibleOrProxy* aAccessible,
|
|
||||||
gint aStartOffset, gint aEndOffset,
|
|
||||||
AtkStringConvertFlags aFlags)
|
|
||||||
{
|
|
||||||
gint startOffset = aStartOffset, endOffset = aEndOffset;
|
|
||||||
ATKStringConverterHelper converter;
|
|
||||||
converter.AdjustOffsets(&startOffset, &endOffset,
|
|
||||||
gint(aAccessible->CharacterCount()));
|
|
||||||
nsAutoString str;
|
|
||||||
aAccessible->TextSubstring(startOffset, endOffset, str);
|
|
||||||
if (aFlags & AtkStringConvertFlags::ConvertTextToAsterisks)
|
|
||||||
ConvertTexttoAsterisks(str);
|
|
||||||
return converter.ConvertAdjusted(str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a character from aAccessible, fetching more data as appropriate to
|
* In order to properly get non-BMP values, offsets need to be changed
|
||||||
* properly get non-BMP characters or a BOM as appropriate.
|
* to get one character more on each end, so that ConvertUTF16toUTF8 can
|
||||||
|
* convert surrogates even if the originally requested offsets fall between
|
||||||
|
* them.
|
||||||
*/
|
*/
|
||||||
template <class AccessibleCharAt>
|
void AdjustOffsets(gint* aStartOffset, gint* aEndOffset, gint count);
|
||||||
gunichar ATKCharacter(AccessibleCharAt* aAccessible, gint aOffset)
|
|
||||||
{
|
|
||||||
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
|
|
||||||
gunichar character = static_cast<gunichar>(aAccessible->CharAt(aOffset));
|
|
||||||
|
|
||||||
if (NS_IS_LOW_SURROGATE(character)) {
|
/**
|
||||||
// Trailing surrogate, return BOM instead.
|
* Converts a string of accessible text with adjusted offsets into ATK
|
||||||
return 0xFEFF;
|
* gchar* string (by adding BOMs). Note, AdjustOffsets has to be called
|
||||||
}
|
* before getting the text passed to this.
|
||||||
|
*/
|
||||||
|
gchar* ConvertAdjusted(const nsAString& aStr);
|
||||||
|
|
||||||
if (NS_IS_HIGH_SURROGATE(character)) {
|
private:
|
||||||
// Heading surrogate, get the trailing surrogate and combine them.
|
/**
|
||||||
gunichar characterLow = static_cast<gunichar>(aAccessible->CharAt(aOffset + 1));
|
* Remove the additional characters requested by PrepareUTF16toUTF8.
|
||||||
|
*/
|
||||||
|
gchar* FinishUTF16toUTF8(nsCString& aStr);
|
||||||
|
|
||||||
if (!NS_IS_LOW_SURROGATE(characterLow)) {
|
#ifdef DEBUG
|
||||||
// It should have been a trailing surrogate... Flag the error.
|
bool mAdjusted;
|
||||||
return 0xFFFD;
|
#endif
|
||||||
}
|
bool mStartShifted;
|
||||||
return SURROGATE_TO_UCS4(character, characterLow);
|
bool mEndShifted;
|
||||||
}
|
};
|
||||||
|
|
||||||
return character;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get text from aAccessible, using ATKStringConverterHelper to properly
|
||||||
|
* introduce appropriate BOMs.
|
||||||
|
*/
|
||||||
|
template <class AccessibleOrProxy>
|
||||||
|
gchar* NewATKString(AccessibleOrProxy* aAccessible, gint aStartOffset,
|
||||||
|
gint aEndOffset, AtkStringConvertFlags aFlags) {
|
||||||
|
gint startOffset = aStartOffset, endOffset = aEndOffset;
|
||||||
|
ATKStringConverterHelper converter;
|
||||||
|
converter.AdjustOffsets(&startOffset, &endOffset,
|
||||||
|
gint(aAccessible->CharacterCount()));
|
||||||
|
nsAutoString str;
|
||||||
|
aAccessible->TextSubstring(startOffset, endOffset, str);
|
||||||
|
if (aFlags & AtkStringConvertFlags::ConvertTextToAsterisks)
|
||||||
|
ConvertTexttoAsterisks(str);
|
||||||
|
return converter.ConvertAdjusted(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace a11y
|
/**
|
||||||
} // namespace mozilla
|
* Get a character from aAccessible, fetching more data as appropriate to
|
||||||
|
* properly get non-BMP characters or a BOM as appropriate.
|
||||||
|
*/
|
||||||
|
template <class AccessibleCharAt>
|
||||||
|
gunichar ATKCharacter(AccessibleCharAt* aAccessible, gint aOffset) {
|
||||||
|
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
|
||||||
|
gunichar character = static_cast<gunichar>(aAccessible->CharAt(aOffset));
|
||||||
|
|
||||||
|
if (NS_IS_LOW_SURROGATE(character)) {
|
||||||
|
// Trailing surrogate, return BOM instead.
|
||||||
|
return 0xFEFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NS_IS_HIGH_SURROGATE(character)) {
|
||||||
|
// Heading surrogate, get the trailing surrogate and combine them.
|
||||||
|
gunichar characterLow =
|
||||||
|
static_cast<gunichar>(aAccessible->CharAt(aOffset + 1));
|
||||||
|
|
||||||
|
if (!NS_IS_LOW_SURROGATE(characterLow)) {
|
||||||
|
// It should have been a trailing surrogate... Flag the error.
|
||||||
|
return 0xFFFD;
|
||||||
|
}
|
||||||
|
return SURROGATE_TO_UCS4(character, characterLow);
|
||||||
|
}
|
||||||
|
|
||||||
|
return character;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace DOMtoATK
|
||||||
|
|
||||||
|
} // namespace a11y
|
||||||
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -13,13 +13,8 @@ using namespace mozilla::a11y;
|
|||||||
// DocAccessibleWrap
|
// DocAccessibleWrap
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DocAccessibleWrap::
|
DocAccessibleWrap::DocAccessibleWrap(nsIDocument* aDocument,
|
||||||
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell) :
|
nsIPresShell* aPresShell)
|
||||||
DocAccessible(aDocument, aPresShell), mActivated(false)
|
: DocAccessible(aDocument, aPresShell), mActivated(false) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DocAccessibleWrap::~DocAccessibleWrap()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
DocAccessibleWrap::~DocAccessibleWrap() {}
|
||||||
|
|||||||
@@ -16,16 +16,15 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
class DocAccessibleWrap : public DocAccessible
|
class DocAccessibleWrap : public DocAccessible {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
|
DocAccessibleWrap(nsIDocument* aDocument, nsIPresShell* aPresShell);
|
||||||
virtual ~DocAccessibleWrap();
|
virtual ~DocAccessibleWrap();
|
||||||
|
|
||||||
bool mActivated;
|
bool mActivated;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ typedef class HTMLTableAccessible HTMLTableAccessibleWrap;
|
|||||||
typedef class HTMLTableCellAccessible HTMLTableCellAccessibleWrap;
|
typedef class HTMLTableCellAccessible HTMLTableCellAccessibleWrap;
|
||||||
typedef class HTMLTableHeaderCellAccessible HTMLTableHeaderCellAccessibleWrap;
|
typedef class HTMLTableHeaderCellAccessible HTMLTableHeaderCellAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class HyperTextAccessible HyperTextAccessibleWrap;
|
typedef class HyperTextAccessible HyperTextAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class ImageAccessible ImageAccessibleWrap;
|
typedef class ImageAccessible ImageAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,31 +14,30 @@ namespace a11y {
|
|||||||
|
|
||||||
class AccessibleWrap;
|
class AccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void actionInterfaceInitCB(AtkActionIface* aIface);
|
void actionInterfaceInitCB(AtkActionIface* aIface);
|
||||||
void componentInterfaceInitCB(AtkComponentIface* aIface);
|
void componentInterfaceInitCB(AtkComponentIface* aIface);
|
||||||
void documentInterfaceInitCB(AtkDocumentIface *aIface);
|
void documentInterfaceInitCB(AtkDocumentIface* aIface);
|
||||||
void editableTextInterfaceInitCB(AtkEditableTextIface* aIface);
|
void editableTextInterfaceInitCB(AtkEditableTextIface* aIface);
|
||||||
void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface);
|
void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface* aIface);
|
||||||
void hypertextInterfaceInitCB(AtkHypertextIface* aIface);
|
void hypertextInterfaceInitCB(AtkHypertextIface* aIface);
|
||||||
void imageInterfaceInitCB(AtkImageIface* aIface);
|
void imageInterfaceInitCB(AtkImageIface* aIface);
|
||||||
void selectionInterfaceInitCB(AtkSelectionIface* aIface);
|
void selectionInterfaceInitCB(AtkSelectionIface* aIface);
|
||||||
void tableInterfaceInitCB(AtkTableIface *aIface);
|
void tableInterfaceInitCB(AtkTableIface* aIface);
|
||||||
void tableCellInterfaceInitCB(AtkTableCellIface *aIface);
|
void tableCellInterfaceInitCB(AtkTableCellIface* aIface);
|
||||||
void textInterfaceInitCB(AtkTextIface* aIface);
|
void textInterfaceInitCB(AtkTextIface* aIface);
|
||||||
void valueInterfaceInitCB(AtkValueIface *aIface);
|
void valueInterfaceInitCB(AtkValueIface* aIface);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XXX these should live in a file of utils for atk.
|
* XXX these should live in a file of utils for atk.
|
||||||
*/
|
*/
|
||||||
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj,
|
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
||||||
gint aX, gint aY, AtkCoordType aCoordType);
|
AtkCoordType aCoordType);
|
||||||
void getExtentsHelper(AtkObject* aAtkObj,
|
void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
||||||
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
|
gint* aHeight, AtkCoordType aCoordType);
|
||||||
AtkCoordType aCoordType);
|
|
||||||
|
|
||||||
#endif // ATK_INTERFACE_INIT_FUNCS_H_
|
#endif // ATK_INTERFACE_INIT_FUNCS_H_
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_GTK
|
#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
|
#endif
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
@@ -31,15 +32,15 @@ int atkMajorVersion = 1, atkMinorVersion = 12, atkMicroVersion = 0;
|
|||||||
GType (*gAtkTableCellGetTypeFunc)();
|
GType (*gAtkTableCellGetTypeFunc)();
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
typedef GType (* AtkGetTypeType) (void);
|
typedef GType (*AtkGetTypeType)(void);
|
||||||
typedef void (*GnomeAccessibilityInit) (void);
|
typedef void (*GnomeAccessibilityInit)(void);
|
||||||
typedef void (*GnomeAccessibilityShutdown) (void);
|
typedef void (*GnomeAccessibilityShutdown)(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRLibrary* sATKLib = nullptr;
|
static PRLibrary* sATKLib = nullptr;
|
||||||
static const char sATKLibName[] = "libatk-1.0.so.0";
|
static const char sATKLibName[] = "libatk-1.0.so.0";
|
||||||
static const char sATKHyperlinkImplGetTypeSymbol[] =
|
static const char sATKHyperlinkImplGetTypeSymbol[] =
|
||||||
"atk_hyperlink_impl_get_type";
|
"atk_hyperlink_impl_get_type";
|
||||||
|
|
||||||
gboolean toplevel_event_watcher(GSignalInvocationHint*, guint, const GValue*,
|
gboolean toplevel_event_watcher(GSignalInvocationHint*, guint, const GValue*,
|
||||||
gpointer);
|
gpointer);
|
||||||
@@ -49,14 +50,13 @@ static gulong sToplevel_hide_hook = 0;
|
|||||||
|
|
||||||
GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
|
GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
|
||||||
|
|
||||||
struct GnomeAccessibilityModule
|
struct GnomeAccessibilityModule {
|
||||||
{
|
const char* libName;
|
||||||
const char *libName;
|
PRLibrary* lib;
|
||||||
PRLibrary *lib;
|
const char* initName;
|
||||||
const char *initName;
|
GnomeAccessibilityInit init;
|
||||||
GnomeAccessibilityInit init;
|
const char* shutdownName;
|
||||||
const char *shutdownName;
|
GnomeAccessibilityShutdown shutdown;
|
||||||
GnomeAccessibilityShutdown shutdown;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static GnomeAccessibilityModule sAtkBridge = {
|
static GnomeAccessibilityModule sAtkBridge = {
|
||||||
@@ -65,92 +65,84 @@ static GnomeAccessibilityModule sAtkBridge = {
|
|||||||
#else
|
#else
|
||||||
"libatk-bridge.so", nullptr,
|
"libatk-bridge.so", nullptr,
|
||||||
#endif
|
#endif
|
||||||
"gnome_accessibility_module_init", nullptr,
|
"gnome_accessibility_module_init", nullptr,
|
||||||
"gnome_accessibility_module_shutdown", nullptr
|
"gnome_accessibility_module_shutdown", nullptr};
|
||||||
};
|
|
||||||
|
|
||||||
static nsresult
|
static nsresult LoadGtkModule(GnomeAccessibilityModule& aModule) {
|
||||||
LoadGtkModule(GnomeAccessibilityModule& aModule)
|
NS_ENSURE_ARG(aModule.libName);
|
||||||
{
|
|
||||||
NS_ENSURE_ARG(aModule.libName);
|
|
||||||
|
|
||||||
if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) {
|
if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) {
|
||||||
//try to load the module with "gtk-2.0/modules" appended
|
// try to load the module with "gtk-2.0/modules" appended
|
||||||
char *curLibPath = PR_GetLibraryPath();
|
char* curLibPath = PR_GetLibraryPath();
|
||||||
nsAutoCString libPath(curLibPath);
|
nsAutoCString libPath(curLibPath);
|
||||||
#if defined(LINUX) && defined(__x86_64__)
|
#if defined(LINUX) && defined(__x86_64__)
|
||||||
libPath.AppendLiteral(":/usr/lib64:/usr/lib");
|
libPath.AppendLiteral(":/usr/lib64:/usr/lib");
|
||||||
#else
|
#else
|
||||||
libPath.AppendLiteral(":/usr/lib");
|
libPath.AppendLiteral(":/usr/lib");
|
||||||
#endif
|
#endif
|
||||||
PR_FreeLibraryName(curLibPath);
|
PR_FreeLibraryName(curLibPath);
|
||||||
|
|
||||||
int16_t loc1 = 0, loc2 = 0;
|
int16_t loc1 = 0, loc2 = 0;
|
||||||
int16_t subLen = 0;
|
int16_t subLen = 0;
|
||||||
while (loc2 >= 0) {
|
while (loc2 >= 0) {
|
||||||
loc2 = libPath.FindChar(':', loc1);
|
loc2 = libPath.FindChar(':', loc1);
|
||||||
if (loc2 < 0)
|
if (loc2 < 0)
|
||||||
subLen = libPath.Length() - loc1;
|
subLen = libPath.Length() - loc1;
|
||||||
else
|
else
|
||||||
subLen = loc2 - loc1;
|
subLen = loc2 - loc1;
|
||||||
nsAutoCString sub(Substring(libPath, loc1, subLen));
|
nsAutoCString sub(Substring(libPath, loc1, subLen));
|
||||||
sub.AppendLiteral("/gtk-3.0/modules/");
|
sub.AppendLiteral("/gtk-3.0/modules/");
|
||||||
sub.Append(aModule.libName);
|
sub.Append(aModule.libName);
|
||||||
aModule.lib = PR_LoadLibrary(sub.get());
|
aModule.lib = PR_LoadLibrary(sub.get());
|
||||||
if (aModule.lib)
|
if (aModule.lib) break;
|
||||||
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
|
// we have loaded the library, try to get the function ptrs
|
||||||
if (!(aModule.init = PR_FindFunctionSymbol(aModule.lib,
|
if (!(aModule.init = PR_FindFunctionSymbol(aModule.lib, aModule.initName)) ||
|
||||||
aModule.initName)) ||
|
!(aModule.shutdown =
|
||||||
!(aModule.shutdown = PR_FindFunctionSymbol(aModule.lib,
|
PR_FindFunctionSymbol(aModule.lib, aModule.shutdownName))) {
|
||||||
aModule.shutdownName))) {
|
// fail, :(
|
||||||
|
PR_UnloadLibrary(aModule.lib);
|
||||||
//fail, :(
|
aModule.lib = nullptr;
|
||||||
PR_UnloadLibrary(aModule.lib);
|
return NS_ERROR_FAILURE;
|
||||||
aModule.lib = nullptr;
|
}
|
||||||
return NS_ERROR_FAILURE;
|
return NS_OK;
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::PlatformInit() {
|
||||||
a11y::PlatformInit()
|
if (!ShouldA11yBeEnabled()) return;
|
||||||
{
|
|
||||||
if (!ShouldA11yBeEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
sATKLib = PR_LoadLibrary(sATKLibName);
|
sATKLib = PR_LoadLibrary(sATKLibName);
|
||||||
if (!sATKLib)
|
if (!sATKLib) return;
|
||||||
return;
|
|
||||||
|
|
||||||
AtkGetTypeType pfn_atk_hyperlink_impl_get_type =
|
AtkGetTypeType pfn_atk_hyperlink_impl_get_type =
|
||||||
(AtkGetTypeType) PR_FindFunctionSymbol(sATKLib, sATKHyperlinkImplGetTypeSymbol);
|
(AtkGetTypeType)PR_FindFunctionSymbol(sATKLib,
|
||||||
|
sATKHyperlinkImplGetTypeSymbol);
|
||||||
if (pfn_atk_hyperlink_impl_get_type)
|
if (pfn_atk_hyperlink_impl_get_type)
|
||||||
g_atk_hyperlink_impl_type = pfn_atk_hyperlink_impl_get_type();
|
g_atk_hyperlink_impl_type = pfn_atk_hyperlink_impl_get_type();
|
||||||
|
|
||||||
AtkGetTypeType pfn_atk_socket_get_type = (AtkGetTypeType)
|
AtkGetTypeType pfn_atk_socket_get_type =
|
||||||
PR_FindFunctionSymbol(sATKLib, AtkSocketAccessible::sATKSocketGetTypeSymbol);
|
(AtkGetTypeType)PR_FindFunctionSymbol(
|
||||||
|
sATKLib, AtkSocketAccessible::sATKSocketGetTypeSymbol);
|
||||||
if (pfn_atk_socket_get_type) {
|
if (pfn_atk_socket_get_type) {
|
||||||
AtkSocketAccessible::g_atk_socket_type = pfn_atk_socket_get_type();
|
AtkSocketAccessible::g_atk_socket_type = pfn_atk_socket_get_type();
|
||||||
AtkSocketAccessible::g_atk_socket_embed = (AtkSocketEmbedType)
|
AtkSocketAccessible::g_atk_socket_embed =
|
||||||
PR_FindFunctionSymbol(sATKLib, AtkSocketAccessible ::sATKSocketEmbedSymbol);
|
(AtkSocketEmbedType)PR_FindFunctionSymbol(
|
||||||
|
sATKLib, AtkSocketAccessible ::sATKSocketEmbedSymbol);
|
||||||
AtkSocketAccessible::gCanEmbed =
|
AtkSocketAccessible::gCanEmbed =
|
||||||
AtkSocketAccessible::g_atk_socket_type != G_TYPE_INVALID &&
|
AtkSocketAccessible::g_atk_socket_type != G_TYPE_INVALID &&
|
||||||
AtkSocketAccessible::g_atk_socket_embed;
|
AtkSocketAccessible::g_atk_socket_embed;
|
||||||
}
|
}
|
||||||
|
|
||||||
gAtkTableCellGetTypeFunc = (GType (*)())
|
gAtkTableCellGetTypeFunc =
|
||||||
PR_FindFunctionSymbol(sATKLib, "atk_table_cell_get_type");
|
(GType(*)())PR_FindFunctionSymbol(sATKLib, "atk_table_cell_get_type");
|
||||||
|
|
||||||
const char* (*atkGetVersion)() =
|
const char* (*atkGetVersion)() =
|
||||||
(const char* (*)()) PR_FindFunctionSymbol(sATKLib, "atk_get_version");
|
(const char* (*)())PR_FindFunctionSymbol(sATKLib, "atk_get_version");
|
||||||
if (atkGetVersion) {
|
if (atkGetVersion) {
|
||||||
const char* version = atkGetVersion();
|
const char* version = atkGetVersion();
|
||||||
if (version) {
|
if (version) {
|
||||||
@@ -183,58 +175,49 @@ a11y::PlatformInit()
|
|||||||
|
|
||||||
if (!sToplevel_event_hook_added) {
|
if (!sToplevel_event_hook_added) {
|
||||||
sToplevel_event_hook_added = true;
|
sToplevel_event_hook_added = true;
|
||||||
sToplevel_show_hook =
|
sToplevel_show_hook = g_signal_add_emission_hook(
|
||||||
g_signal_add_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
|
g_signal_lookup("show", GTK_TYPE_WINDOW), 0, toplevel_event_watcher,
|
||||||
0, toplevel_event_watcher,
|
reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW), nullptr);
|
||||||
reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW),
|
sToplevel_hide_hook = g_signal_add_emission_hook(
|
||||||
nullptr);
|
g_signal_lookup("hide", GTK_TYPE_WINDOW), 0, toplevel_event_watcher,
|
||||||
sToplevel_hide_hook =
|
reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_HIDE), nullptr);
|
||||||
g_signal_add_emission_hook(g_signal_lookup("hide", GTK_TYPE_WINDOW), 0,
|
|
||||||
toplevel_event_watcher,
|
|
||||||
reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_HIDE),
|
|
||||||
nullptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void a11y::PlatformShutdown() {
|
||||||
a11y::PlatformShutdown()
|
if (sToplevel_event_hook_added) {
|
||||||
{
|
sToplevel_event_hook_added = false;
|
||||||
if (sToplevel_event_hook_added) {
|
g_signal_remove_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
|
||||||
sToplevel_event_hook_added = false;
|
sToplevel_show_hook);
|
||||||
g_signal_remove_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
|
g_signal_remove_emission_hook(g_signal_lookup("hide", GTK_TYPE_WINDOW),
|
||||||
sToplevel_show_hook);
|
sToplevel_hide_hook);
|
||||||
g_signal_remove_emission_hook(g_signal_lookup("hide", GTK_TYPE_WINDOW),
|
}
|
||||||
sToplevel_hide_hook);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sAtkBridge.lib) {
|
if (sAtkBridge.lib) {
|
||||||
// Do not shutdown/unload atk-bridge,
|
// Do not shutdown/unload atk-bridge,
|
||||||
// an exit function registered will take care of it
|
// an exit function registered will take care of it
|
||||||
// if (sAtkBridge.shutdown)
|
// if (sAtkBridge.shutdown)
|
||||||
// (*sAtkBridge.shutdown)();
|
// (*sAtkBridge.shutdown)();
|
||||||
// PR_UnloadLibrary(sAtkBridge.lib);
|
// PR_UnloadLibrary(sAtkBridge.lib);
|
||||||
sAtkBridge.lib = nullptr;
|
sAtkBridge.lib = nullptr;
|
||||||
sAtkBridge.init = nullptr;
|
sAtkBridge.init = nullptr;
|
||||||
sAtkBridge.shutdown = nullptr;
|
sAtkBridge.shutdown = nullptr;
|
||||||
}
|
}
|
||||||
// if (sATKLib) {
|
// if (sATKLib) {
|
||||||
// PR_UnloadLibrary(sATKLib);
|
// PR_UnloadLibrary(sATKLib);
|
||||||
// sATKLib = nullptr;
|
// sATKLib = nullptr;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
|
static const char sAccEnv[] = "GNOME_ACCESSIBILITY";
|
||||||
#ifdef MOZ_ENABLE_DBUS
|
#ifdef MOZ_ENABLE_DBUS
|
||||||
static DBusPendingCall *sPendingCall = nullptr;
|
static DBusPendingCall* sPendingCall = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void a11y::PreInit() {
|
||||||
a11y::PreInit()
|
|
||||||
{
|
|
||||||
#ifdef MOZ_ENABLE_DBUS
|
#ifdef MOZ_ENABLE_DBUS
|
||||||
static bool sChecked = FALSE;
|
static bool sChecked = FALSE;
|
||||||
if (sChecked)
|
if (sChecked) return;
|
||||||
return;
|
|
||||||
|
|
||||||
sChecked = TRUE;
|
sChecked = TRUE;
|
||||||
|
|
||||||
@@ -242,26 +225,23 @@ a11y::PreInit()
|
|||||||
// also make sure that a session bus address is available to prevent dbus from
|
// 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
|
// starting a new one. Dbus confuses the test harness when it creates a new
|
||||||
// process (see bug 693343)
|
// process (see bug 693343)
|
||||||
if (PR_GetEnv(sAccEnv) || !PR_GetEnv("DBUS_SESSION_BUS_ADDRESS"))
|
if (PR_GetEnv(sAccEnv) || !PR_GetEnv("DBUS_SESSION_BUS_ADDRESS")) return;
|
||||||
return;
|
|
||||||
|
|
||||||
DBusConnection* bus = dbus_bus_get(DBUS_BUS_SESSION, nullptr);
|
DBusConnection* bus = dbus_bus_get(DBUS_BUS_SESSION, nullptr);
|
||||||
if (!bus)
|
if (!bus) return;
|
||||||
return;
|
|
||||||
|
|
||||||
dbus_connection_set_exit_on_disconnect(bus, FALSE);
|
dbus_connection_set_exit_on_disconnect(bus, FALSE);
|
||||||
|
|
||||||
static const char* iface = "org.a11y.Status";
|
static const char* iface = "org.a11y.Status";
|
||||||
static const char* member = "IsEnabled";
|
static const char* member = "IsEnabled";
|
||||||
DBusMessage *message;
|
DBusMessage* message;
|
||||||
message = dbus_message_new_method_call("org.a11y.Bus", "/org/a11y/bus",
|
message =
|
||||||
"org.freedesktop.DBus.Properties",
|
dbus_message_new_method_call("org.a11y.Bus", "/org/a11y/bus",
|
||||||
"Get");
|
"org.freedesktop.DBus.Properties", "Get");
|
||||||
if (!message)
|
if (!message) goto dbus_done;
|
||||||
goto dbus_done;
|
|
||||||
|
|
||||||
dbus_message_append_args(message, DBUS_TYPE_STRING, &iface,
|
dbus_message_append_args(message, DBUS_TYPE_STRING, &iface, DBUS_TYPE_STRING,
|
||||||
DBUS_TYPE_STRING, &member, DBUS_TYPE_INVALID);
|
&member, DBUS_TYPE_INVALID);
|
||||||
dbus_connection_send_with_reply(bus, message, &sPendingCall, 1000);
|
dbus_connection_send_with_reply(bus, message, &sPendingCall, 1000);
|
||||||
dbus_message_unref(message);
|
dbus_message_unref(message);
|
||||||
|
|
||||||
@@ -270,30 +250,24 @@ dbus_done:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool a11y::ShouldA11yBeEnabled() {
|
||||||
a11y::ShouldA11yBeEnabled()
|
|
||||||
{
|
|
||||||
static bool sChecked = false, sShouldEnable = false;
|
static bool sChecked = false, sShouldEnable = false;
|
||||||
if (sChecked)
|
if (sChecked) return sShouldEnable;
|
||||||
return sShouldEnable;
|
|
||||||
|
|
||||||
sChecked = true;
|
sChecked = true;
|
||||||
|
|
||||||
EPlatformDisabledState disabledState = PlatformDisabledState();
|
EPlatformDisabledState disabledState = PlatformDisabledState();
|
||||||
if (disabledState == ePlatformIsDisabled)
|
if (disabledState == ePlatformIsDisabled) return sShouldEnable = false;
|
||||||
return sShouldEnable = false;
|
|
||||||
|
|
||||||
// check if accessibility enabled/disabled by environment variable
|
// check if accessibility enabled/disabled by environment variable
|
||||||
const char* envValue = PR_GetEnv(sAccEnv);
|
const char* envValue = PR_GetEnv(sAccEnv);
|
||||||
if (envValue)
|
if (envValue) return sShouldEnable = !!atoi(envValue);
|
||||||
return sShouldEnable = !!atoi(envValue);
|
|
||||||
|
|
||||||
#ifdef MOZ_ENABLE_DBUS
|
#ifdef MOZ_ENABLE_DBUS
|
||||||
PreInit();
|
PreInit();
|
||||||
bool dbusSuccess = false;
|
bool dbusSuccess = false;
|
||||||
DBusMessage *reply = nullptr;
|
DBusMessage* reply = nullptr;
|
||||||
if (!sPendingCall)
|
if (!sPendingCall) goto dbus_done;
|
||||||
goto dbus_done;
|
|
||||||
|
|
||||||
dbus_pending_call_block(sPendingCall);
|
dbus_pending_call_block(sPendingCall);
|
||||||
reply = dbus_pending_call_steal_reply(sPendingCall);
|
reply = dbus_pending_call_steal_reply(sPendingCall);
|
||||||
@@ -301,13 +275,13 @@ a11y::ShouldA11yBeEnabled()
|
|||||||
sPendingCall = nullptr;
|
sPendingCall = nullptr;
|
||||||
if (!reply ||
|
if (!reply ||
|
||||||
dbus_message_get_type(reply) != DBUS_MESSAGE_TYPE_METHOD_RETURN ||
|
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;
|
goto dbus_done;
|
||||||
|
|
||||||
DBusMessageIter iter, iter_variant, iter_struct;
|
DBusMessageIter iter, iter_variant, iter_struct;
|
||||||
dbus_bool_t dResult;
|
dbus_bool_t dResult;
|
||||||
dbus_message_iter_init(reply, &iter);
|
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)) {
|
switch (dbus_message_iter_get_arg_type(&iter_variant)) {
|
||||||
case DBUS_TYPE_STRUCT:
|
case DBUS_TYPE_STRUCT:
|
||||||
// at-spi2-core 2.2.0-2.2.1 had a bug where it returned a struct
|
// at-spi2-core 2.2.0-2.2.1 had a bug where it returned a struct
|
||||||
@@ -329,18 +303,16 @@ a11y::ShouldA11yBeEnabled()
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbus_done:
|
dbus_done:
|
||||||
if (reply)
|
if (reply) dbus_message_unref(reply);
|
||||||
dbus_message_unref(reply);
|
|
||||||
|
|
||||||
if (dbusSuccess)
|
if (dbusSuccess) return sShouldEnable;
|
||||||
return sShouldEnable;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//check gconf-2 setting
|
// check gconf-2 setting
|
||||||
#define GCONF_A11Y_KEY "/desktop/gnome/interface/accessibility"
|
#define GCONF_A11Y_KEY "/desktop/gnome/interface/accessibility"
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
nsCOMPtr<nsIGConfService> gconf =
|
nsCOMPtr<nsIGConfService> gconf =
|
||||||
do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv);
|
do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv);
|
||||||
if (NS_SUCCEEDED(rv) && gconf)
|
if (NS_SUCCEEDED(rv) && gconf)
|
||||||
gconf->GetBool(NS_LITERAL_CSTRING(GCONF_A11Y_KEY), &sShouldEnable);
|
gconf->GetBool(NS_LITERAL_CSTRING(GCONF_A11Y_KEY), &sShouldEnable);
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,13 @@
|
|||||||
|
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
GtkWindowAccessible::GtkWindowAccessible(AtkObject* aAccessible) :
|
GtkWindowAccessible::GtkWindowAccessible(AtkObject* aAccessible)
|
||||||
DummyAccessible()
|
: DummyAccessible() {
|
||||||
{
|
|
||||||
g_object_ref(aAccessible);
|
g_object_ref(aAccessible);
|
||||||
mAtkObject = aAccessible;
|
mAtkObject = aAccessible;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWindowAccessible::~GtkWindowAccessible()
|
GtkWindowAccessible::~GtkWindowAccessible() {
|
||||||
{
|
|
||||||
g_object_unref(mAtkObject);
|
g_object_unref(mAtkObject);
|
||||||
mAtkObject = nullptr;
|
mAtkObject = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,13 @@ typedef RootAccessible RootAccessibleWrap;
|
|||||||
* It is added into root when the toplevel window is created, and removed
|
* It is added into root when the toplevel window is created, and removed
|
||||||
* from root when the toplevel window is destroyed.
|
* from root when the toplevel window is destroyed.
|
||||||
*/
|
*/
|
||||||
class GtkWindowAccessible final : public DummyAccessible
|
class GtkWindowAccessible final : public DummyAccessible {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit GtkWindowAccessible(AtkObject* aAccessible);
|
explicit GtkWindowAccessible(AtkObject* aAccessible);
|
||||||
virtual ~GtkWindowAccessible();
|
virtual ~GtkWindowAccessible();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* mozilla_a11y_Root_Accessible_Wrap_h__ */
|
|
||||||
|
|
||||||
|
#endif /* mozilla_a11y_Root_Accessible_Wrap_h__ */
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class TextLeafAccessible TextLeafAccessibleWrap;
|
typedef class TextLeafAccessible TextLeafAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,14 +24,13 @@ typedef AtkUtilClass MaiUtilClass;
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static guint (*gail_add_global_event_listener)(GSignalEmissionHook listener,
|
static guint (*gail_add_global_event_listener)(GSignalEmissionHook listener,
|
||||||
const gchar* event_type);
|
const gchar *event_type);
|
||||||
static void (*gail_remove_global_event_listener) (guint remove_listener);
|
static void (*gail_remove_global_event_listener)(guint remove_listener);
|
||||||
static void (*gail_remove_key_event_listener) (guint remove_listener);
|
static void (*gail_remove_key_event_listener)(guint remove_listener);
|
||||||
static AtkObject* (*gail_get_root)();
|
static AtkObject *(*gail_get_root)();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MaiUtilListenerInfo
|
struct MaiUtilListenerInfo {
|
||||||
{
|
|
||||||
gint key;
|
gint key;
|
||||||
guint signal_id;
|
guint signal_id;
|
||||||
gulong hook_id;
|
gulong hook_id;
|
||||||
@@ -42,217 +41,186 @@ struct MaiUtilListenerInfo
|
|||||||
guint gail_listenerid;
|
guint gail_listenerid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GHashTable* sListener_list = nullptr;
|
static GHashTable *sListener_list = nullptr;
|
||||||
static gint sListener_idx = 1;
|
static gint sListener_idx = 1;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static guint
|
static guint add_listener(GSignalEmissionHook listener,
|
||||||
add_listener (GSignalEmissionHook listener,
|
const gchar *object_type, const gchar *signal,
|
||||||
const gchar *object_type,
|
const gchar *hook_data, guint gail_listenerid = 0) {
|
||||||
const gchar *signal,
|
GType type;
|
||||||
const gchar *hook_data,
|
guint signal_id;
|
||||||
guint gail_listenerid = 0)
|
gint rc = 0;
|
||||||
{
|
|
||||||
GType type;
|
|
||||||
guint signal_id;
|
|
||||||
gint rc = 0;
|
|
||||||
|
|
||||||
type = g_type_from_name(object_type);
|
type = g_type_from_name(object_type);
|
||||||
if (type) {
|
if (type) {
|
||||||
signal_id = g_signal_lookup(signal, type);
|
signal_id = g_signal_lookup(signal, type);
|
||||||
if (signal_id > 0) {
|
if (signal_id > 0) {
|
||||||
MaiUtilListenerInfo *listener_info;
|
MaiUtilListenerInfo *listener_info;
|
||||||
|
|
||||||
rc = sListener_idx;
|
rc = sListener_idx;
|
||||||
|
|
||||||
listener_info = (MaiUtilListenerInfo *)
|
listener_info =
|
||||||
g_malloc(sizeof(MaiUtilListenerInfo));
|
(MaiUtilListenerInfo *)g_malloc(sizeof(MaiUtilListenerInfo));
|
||||||
listener_info->key = sListener_idx;
|
listener_info->key = sListener_idx;
|
||||||
listener_info->hook_id =
|
listener_info->hook_id = g_signal_add_emission_hook(
|
||||||
g_signal_add_emission_hook(signal_id, 0, listener,
|
signal_id, 0, listener, g_strdup(hook_data), (GDestroyNotify)g_free);
|
||||||
g_strdup(hook_data),
|
listener_info->signal_id = signal_id;
|
||||||
(GDestroyNotify)g_free);
|
listener_info->gail_listenerid = gail_listenerid;
|
||||||
listener_info->signal_id = signal_id;
|
|
||||||
listener_info->gail_listenerid = gail_listenerid;
|
|
||||||
|
|
||||||
g_hash_table_insert(sListener_list, &(listener_info->key),
|
g_hash_table_insert(sListener_list, &(listener_info->key), listener_info);
|
||||||
listener_info);
|
sListener_idx++;
|
||||||
sListener_idx++;
|
} else {
|
||||||
}
|
g_warning("Invalid signal type %s\n", signal);
|
||||||
else {
|
|
||||||
g_warning("Invalid signal type %s\n", signal);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
g_warning("Invalid object type %s\n", object_type);
|
g_warning("Invalid object type %s\n", object_type);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint mai_util_add_global_event_listener(GSignalEmissionHook listener,
|
||||||
mai_util_add_global_event_listener(GSignalEmissionHook listener,
|
const gchar *event_type) {
|
||||||
const gchar *event_type)
|
guint rc = 0;
|
||||||
{
|
gchar **split_string;
|
||||||
guint rc = 0;
|
|
||||||
gchar **split_string;
|
|
||||||
|
|
||||||
split_string = g_strsplit (event_type, ":", 3);
|
split_string = g_strsplit(event_type, ":", 3);
|
||||||
|
|
||||||
if (split_string) {
|
if (split_string) {
|
||||||
if (!strcmp ("window", split_string[0])) {
|
if (!strcmp("window", split_string[0])) {
|
||||||
guint gail_listenerid = 0;
|
guint gail_listenerid = 0;
|
||||||
if (gail_add_global_event_listener) {
|
if (gail_add_global_event_listener) {
|
||||||
// call gail's function to track gtk native window events
|
// call gail's function to track gtk native window events
|
||||||
gail_listenerid =
|
gail_listenerid = gail_add_global_event_listener(listener, event_type);
|
||||||
gail_add_global_event_listener(listener, event_type);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rc = add_listener (listener, "MaiAtkObject", split_string[1],
|
rc = add_listener(listener, "MaiAtkObject", split_string[1], event_type,
|
||||||
event_type, gail_listenerid);
|
gail_listenerid);
|
||||||
}
|
} else {
|
||||||
else {
|
rc = add_listener(listener, split_string[1], split_string[2], event_type);
|
||||||
rc = add_listener (listener, split_string[1], split_string[2],
|
|
||||||
event_type);
|
|
||||||
}
|
|
||||||
g_strfreev(split_string);
|
|
||||||
}
|
}
|
||||||
return rc;
|
g_strfreev(split_string);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void mai_util_remove_global_event_listener(guint remove_listener) {
|
||||||
mai_util_remove_global_event_listener(guint remove_listener)
|
if (remove_listener > 0) {
|
||||||
{
|
MaiUtilListenerInfo *listener_info;
|
||||||
if (remove_listener > 0) {
|
gint tmp_idx = remove_listener;
|
||||||
MaiUtilListenerInfo *listener_info;
|
|
||||||
gint tmp_idx = remove_listener;
|
|
||||||
|
|
||||||
listener_info = (MaiUtilListenerInfo *)
|
listener_info =
|
||||||
g_hash_table_lookup(sListener_list, &tmp_idx);
|
(MaiUtilListenerInfo *)g_hash_table_lookup(sListener_list, &tmp_idx);
|
||||||
|
|
||||||
if (listener_info != nullptr) {
|
if (listener_info != nullptr) {
|
||||||
if (gail_remove_global_event_listener &&
|
if (gail_remove_global_event_listener && listener_info->gail_listenerid) {
|
||||||
listener_info->gail_listenerid) {
|
gail_remove_global_event_listener(listener_info->gail_listenerid);
|
||||||
gail_remove_global_event_listener(listener_info->gail_listenerid);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Hook id of 0 and signal id of 0 are invalid */
|
/* Hook id of 0 and signal id of 0 are invalid */
|
||||||
if (listener_info->hook_id != 0 && listener_info->signal_id != 0) {
|
if (listener_info->hook_id != 0 && listener_info->signal_id != 0) {
|
||||||
/* Remove the emission hook */
|
/* Remove the emission hook */
|
||||||
g_signal_remove_emission_hook(listener_info->signal_id,
|
g_signal_remove_emission_hook(listener_info->signal_id,
|
||||||
listener_info->hook_id);
|
listener_info->hook_id);
|
||||||
|
|
||||||
/* Remove the element from the hash */
|
/* Remove the element from the hash */
|
||||||
g_hash_table_remove(sListener_list, &tmp_idx);
|
g_hash_table_remove(sListener_list, &tmp_idx);
|
||||||
}
|
} else {
|
||||||
else {
|
g_warning("Invalid listener hook_id %ld or signal_id %d\n",
|
||||||
g_warning("Invalid listener hook_id %ld or signal_id %d\n",
|
listener_info->hook_id, listener_info->signal_id);
|
||||||
listener_info->hook_id, listener_info->signal_id);
|
}
|
||||||
}
|
} else {
|
||||||
}
|
// atk-bridge is initialized with gail (e.g. yelp)
|
||||||
else {
|
// try gail_remove_global_event_listener
|
||||||
// atk-bridge is initialized with gail (e.g. yelp)
|
if (gail_remove_global_event_listener) {
|
||||||
// try gail_remove_global_event_listener
|
return gail_remove_global_event_listener(remove_listener);
|
||||||
if (gail_remove_global_event_listener) {
|
}
|
||||||
return gail_remove_global_event_listener(remove_listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_warning("No listener with the specified listener id %d",
|
g_warning("No listener with the specified listener id %d",
|
||||||
remove_listener);
|
remove_listener);
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
g_warning("Invalid listener_id %d", remove_listener);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
g_warning("Invalid listener_id %d", remove_listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkKeyEventStruct *
|
static AtkKeyEventStruct *atk_key_event_from_gdk_event_key(GdkEventKey *key) {
|
||||||
atk_key_event_from_gdk_event_key (GdkEventKey *key)
|
AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1);
|
||||||
{
|
switch (key->type) {
|
||||||
AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1);
|
|
||||||
switch (key->type) {
|
|
||||||
case GDK_KEY_PRESS:
|
case GDK_KEY_PRESS:
|
||||||
event->type = ATK_KEY_EVENT_PRESS;
|
event->type = ATK_KEY_EVENT_PRESS;
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_RELEASE:
|
case GDK_KEY_RELEASE:
|
||||||
event->type = ATK_KEY_EVENT_RELEASE;
|
event->type = ATK_KEY_EVENT_RELEASE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
event->state = key->state;
|
event->state = key->state;
|
||||||
event->keyval = key->keyval;
|
event->keyval = key->keyval;
|
||||||
event->length = key->length;
|
event->length = key->length;
|
||||||
if (key->string && key->string [0] &&
|
if (key->string && key->string[0] &&
|
||||||
(key->state & GDK_CONTROL_MASK ||
|
(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;
|
event->string = key->string;
|
||||||
}
|
} else if (key->type == GDK_KEY_PRESS || key->type == GDK_KEY_RELEASE) {
|
||||||
else if (key->type == GDK_KEY_PRESS ||
|
event->string = gdk_keyval_name(key->keyval);
|
||||||
key->type == GDK_KEY_RELEASE) {
|
}
|
||||||
event->string = gdk_keyval_name (key->keyval);
|
event->keycode = key->hardware_keycode;
|
||||||
}
|
event->timestamp = key->time;
|
||||||
event->keycode = key->hardware_keycode;
|
|
||||||
event->timestamp = key->time;
|
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MaiKeyEventInfo
|
struct MaiKeyEventInfo {
|
||||||
{
|
AtkKeyEventStruct *key_event;
|
||||||
AtkKeyEventStruct *key_event;
|
gpointer func_data;
|
||||||
gpointer func_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
union AtkKeySnoopFuncPointer
|
union AtkKeySnoopFuncPointer {
|
||||||
{
|
AtkKeySnoopFunc func_ptr;
|
||||||
AtkKeySnoopFunc func_ptr;
|
gpointer data;
|
||||||
gpointer data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean notify_hf(gpointer key, gpointer value, gpointer data) {
|
||||||
notify_hf(gpointer key, gpointer value, gpointer data)
|
MaiKeyEventInfo *info = (MaiKeyEventInfo *)data;
|
||||||
{
|
AtkKeySnoopFuncPointer atkKeySnoop;
|
||||||
MaiKeyEventInfo *info = (MaiKeyEventInfo *)data;
|
atkKeySnoop.data = value;
|
||||||
AtkKeySnoopFuncPointer atkKeySnoop;
|
return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE
|
||||||
atkKeySnoop.data = value;
|
: FALSE;
|
||||||
return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE : FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void insert_hf(gpointer key, gpointer value, gpointer data) {
|
||||||
insert_hf(gpointer key, gpointer value, gpointer data)
|
GHashTable *new_table = (GHashTable *)data;
|
||||||
{
|
g_hash_table_insert(new_table, key, value);
|
||||||
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
|
static gint mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event,
|
||||||
mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event, gpointer func_data)
|
gpointer func_data) {
|
||||||
{
|
/* notify each AtkKeySnoopFunc in turn... */
|
||||||
/* notify each AtkKeySnoopFunc in turn... */
|
|
||||||
|
|
||||||
MaiKeyEventInfo *info = g_new0(MaiKeyEventInfo, 1);
|
MaiKeyEventInfo *info = g_new0(MaiKeyEventInfo, 1);
|
||||||
gint consumed = 0;
|
gint consumed = 0;
|
||||||
if (sKey_listener_list) {
|
if (sKey_listener_list) {
|
||||||
GHashTable *new_hash = g_hash_table_new(nullptr, nullptr);
|
GHashTable *new_hash = g_hash_table_new(nullptr, nullptr);
|
||||||
g_hash_table_foreach (sKey_listener_list, insert_hf, new_hash);
|
g_hash_table_foreach(sKey_listener_list, insert_hf, new_hash);
|
||||||
info->key_event = atk_key_event_from_gdk_event_key (event);
|
info->key_event = atk_key_event_from_gdk_event_key(event);
|
||||||
info->func_data = func_data;
|
info->func_data = func_data;
|
||||||
consumed = g_hash_table_foreach_steal (new_hash, notify_hf, info);
|
consumed = g_hash_table_foreach_steal(new_hash, notify_hf, info);
|
||||||
g_hash_table_destroy (new_hash);
|
g_hash_table_destroy(new_hash);
|
||||||
g_free(info->key_event);
|
g_free(info->key_event);
|
||||||
}
|
}
|
||||||
g_free(info);
|
g_free(info);
|
||||||
return (consumed ? 1 : 0);
|
return (consumed ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint sKey_snooper_id = 0;
|
static guint sKey_snooper_id = 0;
|
||||||
|
|
||||||
static guint
|
static guint mai_util_add_key_event_listener(AtkKeySnoopFunc listener,
|
||||||
mai_util_add_key_event_listener(AtkKeySnoopFunc listener, gpointer data)
|
gpointer data) {
|
||||||
{
|
|
||||||
if (MOZ_UNLIKELY(!listener)) {
|
if (MOZ_UNLIKELY(!listener)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -277,135 +245,103 @@ mai_util_add_key_event_listener(AtkKeySnoopFunc listener, gpointer data)
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void mai_util_remove_key_event_listener(guint remove_listener) {
|
||||||
mai_util_remove_key_event_listener (guint remove_listener)
|
if (!sKey_listener_list) {
|
||||||
{
|
// atk-bridge is initialized with gail (e.g. yelp)
|
||||||
if (!sKey_listener_list) {
|
// try gail_remove_key_event_listener
|
||||||
// atk-bridge is initialized with gail (e.g. yelp)
|
return gail_remove_key_event_listener(remove_listener);
|
||||||
// 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) {
|
if (g_hash_table_size(sKey_listener_list) == 0) {
|
||||||
gtk_key_snooper_remove(sKey_snooper_id);
|
gtk_key_snooper_remove(sKey_snooper_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject *mai_util_get_root() {
|
||||||
mai_util_get_root()
|
ApplicationAccessible *app = ApplicationAcc();
|
||||||
{
|
if (app) return app->GetAtkObject();
|
||||||
ApplicationAccessible* app = ApplicationAcc();
|
|
||||||
if (app)
|
|
||||||
return app->GetAtkObject();
|
|
||||||
|
|
||||||
// We've shutdown, try to use gail instead
|
// We've shutdown, try to use gail instead
|
||||||
// (to avoid assert in spi_atk_tidy_windows())
|
// (to avoid assert in spi_atk_tidy_windows())
|
||||||
// XXX tbsaunde then why didn't we replace the gail atk_util impl?
|
// XXX tbsaunde then why didn't we replace the gail atk_util impl?
|
||||||
if (gail_get_root)
|
if (gail_get_root) return gail_get_root();
|
||||||
return gail_get_root();
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar*
|
static const gchar *mai_util_get_toolkit_name() { return MAI_NAME; }
|
||||||
mai_util_get_toolkit_name()
|
|
||||||
{
|
static const gchar *mai_util_get_toolkit_version() { return MAI_VERSION; }
|
||||||
return MAI_NAME;
|
|
||||||
|
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*
|
static void window_removed(AtkObject *atk_obj, guint index, AtkObject *child) {
|
||||||
mai_util_get_toolkit_version()
|
if (!IS_MAI_OBJECT(child)) return;
|
||||||
{
|
|
||||||
return MAI_VERSION;
|
static guint id = g_signal_lookup("destroy", MAI_TYPE_ATK_OBJECT);
|
||||||
|
g_signal_emit(child, id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void UtilInterfaceInit(MaiUtilClass *klass) {
|
||||||
_listener_info_destroy(gpointer data)
|
AtkUtilClass *atk_class;
|
||||||
{
|
gpointer data;
|
||||||
g_free(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
data = g_type_class_peek(ATK_TYPE_UTIL);
|
||||||
window_added (AtkObject *atk_obj,
|
atk_class = ATK_UTIL_CLASS(data);
|
||||||
guint index,
|
|
||||||
AtkObject *child)
|
|
||||||
{
|
|
||||||
if (!IS_MAI_OBJECT(child))
|
|
||||||
return;
|
|
||||||
|
|
||||||
static guint id = g_signal_lookup ("create", MAI_TYPE_ATK_OBJECT);
|
// save gail function pointer
|
||||||
g_signal_emit (child, id, 0);
|
gail_add_global_event_listener = atk_class->add_global_event_listener;
|
||||||
}
|
gail_remove_global_event_listener = atk_class->remove_global_event_listener;
|
||||||
|
gail_remove_key_event_listener = atk_class->remove_key_event_listener;
|
||||||
|
gail_get_root = atk_class->get_root;
|
||||||
|
|
||||||
static void
|
atk_class->add_global_event_listener = mai_util_add_global_event_listener;
|
||||||
window_removed (AtkObject *atk_obj,
|
atk_class->remove_global_event_listener =
|
||||||
guint index,
|
mai_util_remove_global_event_listener;
|
||||||
AtkObject *child)
|
atk_class->add_key_event_listener = mai_util_add_key_event_listener;
|
||||||
{
|
atk_class->remove_key_event_listener = mai_util_remove_key_event_listener;
|
||||||
if (!IS_MAI_OBJECT(child))
|
atk_class->get_root = mai_util_get_root;
|
||||||
return;
|
atk_class->get_toolkit_name = mai_util_get_toolkit_name;
|
||||||
|
atk_class->get_toolkit_version = mai_util_get_toolkit_version;
|
||||||
|
|
||||||
static guint id = g_signal_lookup ("destroy", MAI_TYPE_ATK_OBJECT);
|
sListener_list = g_hash_table_new_full(g_int_hash, g_int_equal, nullptr,
|
||||||
g_signal_emit (child, id, 0);
|
_listener_info_destroy);
|
||||||
}
|
// Keep track of added/removed windows.
|
||||||
|
AtkObject *root = atk_get_root();
|
||||||
static void
|
g_signal_connect(root, "children-changed::add", (GCallback)window_added,
|
||||||
UtilInterfaceInit(MaiUtilClass* klass)
|
nullptr);
|
||||||
{
|
g_signal_connect(root, "children-changed::remove", (GCallback)window_removed,
|
||||||
AtkUtilClass *atk_class;
|
nullptr);
|
||||||
gpointer data;
|
|
||||||
|
|
||||||
data = g_type_class_peek(ATK_TYPE_UTIL);
|
|
||||||
atk_class = ATK_UTIL_CLASS(data);
|
|
||||||
|
|
||||||
// save gail function pointer
|
|
||||||
gail_add_global_event_listener = atk_class->add_global_event_listener;
|
|
||||||
gail_remove_global_event_listener = atk_class->remove_global_event_listener;
|
|
||||||
gail_remove_key_event_listener = atk_class->remove_key_event_listener;
|
|
||||||
gail_get_root = atk_class->get_root;
|
|
||||||
|
|
||||||
atk_class->add_global_event_listener =
|
|
||||||
mai_util_add_global_event_listener;
|
|
||||||
atk_class->remove_global_event_listener =
|
|
||||||
mai_util_remove_global_event_listener;
|
|
||||||
atk_class->add_key_event_listener = mai_util_add_key_event_listener;
|
|
||||||
atk_class->remove_key_event_listener = mai_util_remove_key_event_listener;
|
|
||||||
atk_class->get_root = mai_util_get_root;
|
|
||||||
atk_class->get_toolkit_name = mai_util_get_toolkit_name;
|
|
||||||
atk_class->get_toolkit_version = mai_util_get_toolkit_version;
|
|
||||||
|
|
||||||
sListener_list = g_hash_table_new_full(g_int_hash, g_int_equal, nullptr,
|
|
||||||
_listener_info_destroy);
|
|
||||||
// Keep track of added/removed windows.
|
|
||||||
AtkObject *root = atk_get_root ();
|
|
||||||
g_signal_connect (root, "children-changed::add", (GCallback) window_added, nullptr);
|
|
||||||
g_signal_connect (root, "children-changed::remove", (GCallback) window_removed, nullptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GType
|
GType mai_util_get_type() {
|
||||||
mai_util_get_type()
|
static GType type = 0;
|
||||||
{
|
|
||||||
static GType type = 0;
|
|
||||||
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
static const GTypeInfo tinfo = {
|
static const GTypeInfo tinfo = {
|
||||||
sizeof(MaiUtilClass),
|
sizeof(MaiUtilClass),
|
||||||
(GBaseInitFunc) nullptr, /* base init */
|
(GBaseInitFunc) nullptr, /* base init */
|
||||||
(GBaseFinalizeFunc) nullptr, /* base finalize */
|
(GBaseFinalizeFunc) nullptr, /* base finalize */
|
||||||
(GClassInitFunc) UtilInterfaceInit, /* class init */
|
(GClassInitFunc)UtilInterfaceInit, /* class init */
|
||||||
(GClassFinalizeFunc) nullptr, /* class finalize */
|
(GClassFinalizeFunc) nullptr, /* class finalize */
|
||||||
nullptr, /* class data */
|
nullptr, /* class data */
|
||||||
sizeof(MaiUtil), /* instance size */
|
sizeof(MaiUtil), /* instance size */
|
||||||
0, /* nb preallocs */
|
0, /* nb preallocs */
|
||||||
(GInstanceInitFunc) nullptr, /* instance init */
|
(GInstanceInitFunc) nullptr, /* instance init */
|
||||||
nullptr /* value table */
|
nullptr /* value table */
|
||||||
};
|
};
|
||||||
|
|
||||||
type = g_type_register_static(ATK_TYPE_UTIL,
|
type =
|
||||||
"MaiUtil", &tinfo, GTypeFlags(0));
|
g_type_register_static(ATK_TYPE_UTIL, "MaiUtil", &tinfo, GTypeFlags(0));
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class XULListboxAccessible XULListboxAccessibleWrap;
|
typedef class XULListboxAccessible XULListboxAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace a11y {
|
|||||||
|
|
||||||
typedef class XULMenuitemAccessible XULMenuitemAccessibleWrap;
|
typedef class XULMenuitemAccessible XULMenuitemAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ namespace a11y {
|
|||||||
typedef class XULTreeGridAccessible XULTreeGridAccessibleWrap;
|
typedef class XULTreeGridAccessible XULTreeGridAccessibleWrap;
|
||||||
typedef class XULTreeGridCellAccessible XULTreeGridCellAccessibleWrap;
|
typedef class XULTreeGridCellAccessible XULTreeGridCellAccessibleWrap;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -18,50 +18,44 @@ namespace mozilla {
|
|||||||
namespace a11y {
|
namespace a11y {
|
||||||
class ProxyAccessible;
|
class ProxyAccessible;
|
||||||
}
|
}
|
||||||
}
|
} // namespace mozilla
|
||||||
|
|
||||||
#define MAI_TYPE_ATK_OBJECT (mai_atk_object_get_type ())
|
#define MAI_TYPE_ATK_OBJECT (mai_atk_object_get_type())
|
||||||
#define MAI_ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
#define MAI_ATK_OBJECT(obj) \
|
||||||
MAI_TYPE_ATK_OBJECT, MaiAtkObject))
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), MAI_TYPE_ATK_OBJECT, MaiAtkObject))
|
||||||
#define MAI_ATK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
|
#define MAI_ATK_OBJECT_CLASS(klass) \
|
||||||
MAI_TYPE_ATK_OBJECT, \
|
(G_TYPE_CHECK_CLASS_CAST((klass), MAI_TYPE_ATK_OBJECT, MaiAtkObjectClass))
|
||||||
MaiAtkObjectClass))
|
#define IS_MAI_OBJECT(obj) \
|
||||||
#define IS_MAI_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj), MAI_TYPE_ATK_OBJECT))
|
||||||
MAI_TYPE_ATK_OBJECT))
|
#define IS_MAI_OBJECT_CLASS(klass) \
|
||||||
#define IS_MAI_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
(G_TYPE_CHECK_CLASS_TYPE((klass), MAI_TYPE_ATK_OBJECT))
|
||||||
MAI_TYPE_ATK_OBJECT))
|
#define MAI_ATK_OBJECT_GET_CLASS(obj) \
|
||||||
#define MAI_ATK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
(G_TYPE_INSTANCE_GET_CLASS((obj), MAI_TYPE_ATK_OBJECT, MaiAtkObjectClass))
|
||||||
MAI_TYPE_ATK_OBJECT, \
|
|
||||||
MaiAtkObjectClass))
|
|
||||||
GType mai_atk_object_get_type(void);
|
GType mai_atk_object_get_type(void);
|
||||||
GType mai_util_get_type();
|
GType mai_util_get_type();
|
||||||
extern "C" GType mai_atk_socket_get_type(void);
|
extern "C" GType mai_atk_socket_get_type(void);
|
||||||
|
|
||||||
/* MaiAtkSocket */
|
/* MaiAtkSocket */
|
||||||
|
|
||||||
#define MAI_TYPE_ATK_SOCKET (mai_atk_socket_get_type ())
|
#define MAI_TYPE_ATK_SOCKET (mai_atk_socket_get_type())
|
||||||
#define MAI_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
|
#define MAI_ATK_SOCKET(obj) \
|
||||||
MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
|
||||||
#define MAI_IS_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
|
#define MAI_IS_ATK_SOCKET(obj) \
|
||||||
MAI_TYPE_ATK_SOCKET))
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj), MAI_TYPE_ATK_SOCKET))
|
||||||
#define MAI_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
|
#define MAI_ATK_SOCKET_CLASS(klass) \
|
||||||
MAI_TYPE_ATK_SOCKET,\
|
(G_TYPE_CHECK_CLASS_CAST((klass), MAI_TYPE_ATK_SOCKET, MaiAtkSocketClass))
|
||||||
MaiAtkSocketClass))
|
#define MAI_IS_ATK_SOCKET_CLASS(klass) \
|
||||||
#define MAI_IS_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
|
(G_TYPE_CHECK_CLASS_TYPE((klass), MAI_TYPE_ATK_SOCKET))
|
||||||
MAI_TYPE_ATK_SOCKET))
|
#define MAI_ATK_SOCKET_GET_CLASS(obj) \
|
||||||
#define MAI_ATK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
|
(G_TYPE_INSTANCE_GET_CLASS((obj), MAI_TYPE_ATK_SOCKET, MaiAtkSocketClass))
|
||||||
MAI_TYPE_ATK_SOCKET,\
|
|
||||||
MaiAtkSocketClass))
|
|
||||||
|
|
||||||
typedef struct _MaiAtkSocket
|
typedef struct _MaiAtkSocket {
|
||||||
{
|
|
||||||
AtkSocket parent;
|
AtkSocket parent;
|
||||||
|
|
||||||
mozilla::a11y::AccessibleWrap* accWrap;
|
mozilla::a11y::AccessibleWrap* accWrap;
|
||||||
} MaiAtkSocket;
|
} MaiAtkSocket;
|
||||||
|
|
||||||
typedef struct _MaiAtkSocketClass
|
typedef struct _MaiAtkSocketClass {
|
||||||
{
|
|
||||||
AtkSocketClass parent_class;
|
AtkSocketClass parent_class;
|
||||||
} MaiAtkSocketClass;
|
} MaiAtkSocketClass;
|
||||||
|
|
||||||
@@ -81,9 +75,7 @@ extern int atkMajorVersion, atkMinorVersion, atkMicroVersion;
|
|||||||
* Return true if the loaded version of libatk-1.0.so is at least
|
* Return true if the loaded version of libatk-1.0.so is at least
|
||||||
* aMajor.aMinor.aMicro.
|
* aMajor.aMinor.aMicro.
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool IsAtkVersionAtLeast(int aMajor, int aMinor, int aMicro = 0) {
|
||||||
IsAtkVersionAtLeast(int aMajor, int aMinor, int aMicro=0)
|
|
||||||
{
|
|
||||||
return aMajor < atkMajorVersion ||
|
return aMajor < atkMajorVersion ||
|
||||||
(aMajor == atkMajorVersion &&
|
(aMajor == atkMajorVersion &&
|
||||||
(aMinor < atkMinorVersion ||
|
(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
|
* This MaiAtkObject is a thin wrapper, in the MAI namespace, for AtkObject
|
||||||
*/
|
*/
|
||||||
struct MaiAtkObject
|
struct MaiAtkObject {
|
||||||
{
|
|
||||||
AtkObject parent;
|
AtkObject parent;
|
||||||
/*
|
/*
|
||||||
* The AccessibleWrap whose properties and features are exported
|
* The AccessibleWrap whose properties and features are exported
|
||||||
@@ -133,7 +124,7 @@ struct MaiAtkObject
|
|||||||
*/
|
*/
|
||||||
void FireAtkShowHideEvent(AtkObject* aParent, bool aIsAdded, bool aFromUser);
|
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
|
* do we have text-remove and text-insert signals if not we need to use
|
||||||
* text-changed see AccessibleWrap::FireAtkTextChangedEvent() and
|
* text-changed see AccessibleWrap::FireAtkTextChangedEvent() and
|
||||||
|
|||||||
@@ -12,37 +12,37 @@ using namespace mozilla::a11y;
|
|||||||
|
|
||||||
/* MaiAtkHyperlink */
|
/* MaiAtkHyperlink */
|
||||||
|
|
||||||
#define MAI_TYPE_ATK_HYPERLINK (mai_atk_hyperlink_get_type ())
|
#define MAI_TYPE_ATK_HYPERLINK (mai_atk_hyperlink_get_type())
|
||||||
#define MAI_ATK_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
|
#define MAI_ATK_HYPERLINK(obj) \
|
||||||
MAI_TYPE_ATK_HYPERLINK, MaiAtkHyperlink))
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), MAI_TYPE_ATK_HYPERLINK, MaiAtkHyperlink))
|
||||||
#define MAI_ATK_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
|
#define MAI_ATK_HYPERLINK_CLASS(klass) \
|
||||||
MAI_TYPE_ATK_HYPERLINK, MaiAtkHyperlinkClass))
|
(G_TYPE_CHECK_CLASS_CAST((klass), MAI_TYPE_ATK_HYPERLINK, \
|
||||||
#define MAI_IS_ATK_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
|
MaiAtkHyperlinkClass))
|
||||||
MAI_TYPE_ATK_HYPERLINK))
|
#define MAI_IS_ATK_HYPERLINK(obj) \
|
||||||
#define MAI_IS_ATK_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj), MAI_TYPE_ATK_HYPERLINK))
|
||||||
MAI_TYPE_ATK_HYPERLINK))
|
#define MAI_IS_ATK_HYPERLINK_CLASS(klass) \
|
||||||
#define MAI_ATK_HYPERLINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
|
(G_TYPE_CHECK_CLASS_TYPE((klass), MAI_TYPE_ATK_HYPERLINK))
|
||||||
MAI_TYPE_ATK_HYPERLINK, MaiAtkHyperlinkClass))
|
#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,
|
* This MaiAtkHyperlink is a thin wrapper, in the MAI namespace,
|
||||||
* for AtkHyperlink
|
* for AtkHyperlink
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct MaiAtkHyperlink
|
struct MaiAtkHyperlink {
|
||||||
{
|
AtkHyperlink parent;
|
||||||
AtkHyperlink parent;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The MaiHyperlink whose properties and features are exported via this
|
* The MaiHyperlink whose properties and features are exported via this
|
||||||
* hyperlink instance.
|
* hyperlink instance.
|
||||||
*/
|
*/
|
||||||
MaiHyperlink *maiHyperlink;
|
MaiHyperlink *maiHyperlink;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MaiAtkHyperlinkClass
|
struct MaiAtkHyperlinkClass {
|
||||||
{
|
AtkHyperlinkClass parent_class;
|
||||||
AtkHyperlinkClass parent_class;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType mai_atk_hyperlink_get_type(void);
|
GType mai_atk_hyperlink_get_type(void);
|
||||||
@@ -63,112 +63,91 @@ G_END_DECLS
|
|||||||
|
|
||||||
static gpointer parent_class = nullptr;
|
static gpointer parent_class = nullptr;
|
||||||
|
|
||||||
static MaiHyperlink*
|
static MaiHyperlink *GetMaiHyperlink(AtkHyperlink *aHyperlink) {
|
||||||
GetMaiHyperlink(AtkHyperlink *aHyperlink)
|
NS_ENSURE_TRUE(MAI_IS_ATK_HYPERLINK(aHyperlink), nullptr);
|
||||||
{
|
MaiHyperlink *maiHyperlink = MAI_ATK_HYPERLINK(aHyperlink)->maiHyperlink;
|
||||||
NS_ENSURE_TRUE(MAI_IS_ATK_HYPERLINK(aHyperlink), nullptr);
|
NS_ENSURE_TRUE(maiHyperlink != nullptr, nullptr);
|
||||||
MaiHyperlink * maiHyperlink =
|
NS_ENSURE_TRUE(maiHyperlink->GetAtkHyperlink() == aHyperlink, nullptr);
|
||||||
MAI_ATK_HYPERLINK(aHyperlink)->maiHyperlink;
|
return maiHyperlink;
|
||||||
NS_ENSURE_TRUE(maiHyperlink != nullptr, nullptr);
|
|
||||||
NS_ENSURE_TRUE(maiHyperlink->GetAtkHyperlink() == aHyperlink, nullptr);
|
|
||||||
return maiHyperlink;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GType
|
GType mai_atk_hyperlink_get_type(void) {
|
||||||
mai_atk_hyperlink_get_type(void)
|
static GType type = 0;
|
||||||
{
|
|
||||||
static GType type = 0;
|
|
||||||
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
static const GTypeInfo tinfo = {
|
static const GTypeInfo tinfo = {
|
||||||
sizeof(MaiAtkHyperlinkClass),
|
sizeof(MaiAtkHyperlinkClass),
|
||||||
(GBaseInitFunc)nullptr,
|
(GBaseInitFunc) nullptr,
|
||||||
(GBaseFinalizeFunc)nullptr,
|
(GBaseFinalizeFunc) nullptr,
|
||||||
(GClassInitFunc)classInitCB,
|
(GClassInitFunc)classInitCB,
|
||||||
(GClassFinalizeFunc)nullptr,
|
(GClassFinalizeFunc) nullptr,
|
||||||
nullptr, /* class data */
|
nullptr, /* class data */
|
||||||
sizeof(MaiAtkHyperlink), /* instance size */
|
sizeof(MaiAtkHyperlink), /* instance size */
|
||||||
0, /* nb preallocs */
|
0, /* nb preallocs */
|
||||||
(GInstanceInitFunc)nullptr,
|
(GInstanceInitFunc) nullptr,
|
||||||
nullptr /* value table */
|
nullptr /* value table */
|
||||||
};
|
};
|
||||||
|
|
||||||
type = g_type_register_static(ATK_TYPE_HYPERLINK,
|
type = g_type_register_static(ATK_TYPE_HYPERLINK, "MaiAtkHyperlink", &tinfo,
|
||||||
"MaiAtkHyperlink",
|
GTypeFlags(0));
|
||||||
&tinfo, GTypeFlags(0));
|
}
|
||||||
}
|
return type;
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaiHyperlink::MaiHyperlink(AccessibleOrProxy aHyperLink) :
|
MaiHyperlink::MaiHyperlink(AccessibleOrProxy aHyperLink)
|
||||||
mHyperlink(aHyperLink),
|
: mHyperlink(aHyperLink), mMaiAtkHyperlink(nullptr) {
|
||||||
mMaiAtkHyperlink(nullptr)
|
mMaiAtkHyperlink = reinterpret_cast<AtkHyperlink *>(
|
||||||
{
|
g_object_new(mai_atk_hyperlink_get_type(), nullptr));
|
||||||
mMaiAtkHyperlink =
|
NS_ASSERTION(mMaiAtkHyperlink, "OUT OF MEMORY");
|
||||||
reinterpret_cast<AtkHyperlink *>
|
if (!mMaiAtkHyperlink) return;
|
||||||
(g_object_new(mai_atk_hyperlink_get_type(), nullptr));
|
|
||||||
NS_ASSERTION(mMaiAtkHyperlink, "OUT OF MEMORY");
|
|
||||||
if (!mMaiAtkHyperlink)
|
|
||||||
return;
|
|
||||||
|
|
||||||
MAI_ATK_HYPERLINK(mMaiAtkHyperlink)->maiHyperlink = this;
|
MAI_ATK_HYPERLINK(mMaiAtkHyperlink)->maiHyperlink = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaiHyperlink::~MaiHyperlink()
|
MaiHyperlink::~MaiHyperlink() {
|
||||||
{
|
|
||||||
if (mMaiAtkHyperlink) {
|
if (mMaiAtkHyperlink) {
|
||||||
MAI_ATK_HYPERLINK(mMaiAtkHyperlink)->maiHyperlink = nullptr;
|
MAI_ATK_HYPERLINK(mMaiAtkHyperlink)->maiHyperlink = nullptr;
|
||||||
g_object_unref(mMaiAtkHyperlink);
|
g_object_unref(mMaiAtkHyperlink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* static functions for ATK callbacks */
|
/* static functions for ATK callbacks */
|
||||||
|
|
||||||
void
|
void classInitCB(AtkHyperlinkClass *aClass) {
|
||||||
classInitCB(AtkHyperlinkClass *aClass)
|
GObjectClass *gobject_class = G_OBJECT_CLASS(aClass);
|
||||||
{
|
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS(aClass);
|
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent(aClass);
|
parent_class = g_type_class_peek_parent(aClass);
|
||||||
|
|
||||||
aClass->get_uri = getUriCB;
|
aClass->get_uri = getUriCB;
|
||||||
aClass->get_object = getObjectCB;
|
aClass->get_object = getObjectCB;
|
||||||
aClass->get_end_index = getEndIndexCB;
|
aClass->get_end_index = getEndIndexCB;
|
||||||
aClass->get_start_index = getStartIndexCB;
|
aClass->get_start_index = getStartIndexCB;
|
||||||
aClass->is_valid = isValidCB;
|
aClass->is_valid = isValidCB;
|
||||||
aClass->get_n_anchors = getAnchorCountCB;
|
aClass->get_n_anchors = getAnchorCountCB;
|
||||||
|
|
||||||
gobject_class->finalize = finalizeCB;
|
gobject_class->finalize = finalizeCB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void finalizeCB(GObject *aObj) {
|
||||||
finalizeCB(GObject *aObj)
|
NS_ASSERTION(MAI_IS_ATK_HYPERLINK(aObj), "Invalid MaiAtkHyperlink");
|
||||||
{
|
if (!MAI_IS_ATK_HYPERLINK(aObj)) return;
|
||||||
NS_ASSERTION(MAI_IS_ATK_HYPERLINK(aObj), "Invalid MaiAtkHyperlink");
|
|
||||||
if (!MAI_IS_ATK_HYPERLINK(aObj))
|
|
||||||
return;
|
|
||||||
|
|
||||||
MaiAtkHyperlink *maiAtkHyperlink = MAI_ATK_HYPERLINK(aObj);
|
MaiAtkHyperlink *maiAtkHyperlink = MAI_ATK_HYPERLINK(aObj);
|
||||||
maiAtkHyperlink->maiHyperlink = nullptr;
|
maiAtkHyperlink->maiHyperlink = nullptr;
|
||||||
|
|
||||||
/* call parent finalize function */
|
/* call parent finalize function */
|
||||||
if (G_OBJECT_CLASS (parent_class)->finalize)
|
if (G_OBJECT_CLASS(parent_class)->finalize)
|
||||||
G_OBJECT_CLASS (parent_class)->finalize(aObj);
|
G_OBJECT_CLASS(parent_class)->finalize(aObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *getUriCB(AtkHyperlink *aLink, gint aLinkIndex) {
|
||||||
getUriCB(AtkHyperlink *aLink, gint aLinkIndex)
|
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
|
||||||
{
|
if (!maiLink) return nullptr;
|
||||||
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
|
|
||||||
if (!maiLink)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
nsAutoCString cautoStr;
|
nsAutoCString cautoStr;
|
||||||
if (Accessible* hyperlink = maiLink->GetAccHyperlink()) {
|
if (Accessible *hyperlink = maiLink->GetAccHyperlink()) {
|
||||||
nsCOMPtr<nsIURI> uri = hyperlink->AnchorURIAt(aLinkIndex);
|
nsCOMPtr<nsIURI> uri = hyperlink->AnchorURIAt(aLinkIndex);
|
||||||
if (!uri)
|
if (!uri) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
nsresult rv = uri->GetSpec(cautoStr);
|
nsresult rv = uri->GetSpec(cautoStr);
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
@@ -178,39 +157,33 @@ getUriCB(AtkHyperlink *aLink, gint aLinkIndex)
|
|||||||
|
|
||||||
bool valid;
|
bool valid;
|
||||||
maiLink->Proxy()->AnchorURIAt(aLinkIndex, cautoStr, &valid);
|
maiLink->Proxy()->AnchorURIAt(aLinkIndex, cautoStr, &valid);
|
||||||
if (!valid)
|
if (!valid) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
return g_strdup(cautoStr.get());
|
return g_strdup(cautoStr.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
AtkObject *
|
AtkObject *getObjectCB(AtkHyperlink *aLink, gint aLinkIndex) {
|
||||||
getObjectCB(AtkHyperlink *aLink, gint aLinkIndex)
|
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
|
||||||
{
|
|
||||||
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
|
|
||||||
if (!maiLink) {
|
if (!maiLink) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Accessible* hyperlink = maiLink->GetAccHyperlink()) {
|
if (Accessible *hyperlink = maiLink->GetAccHyperlink()) {
|
||||||
Accessible* anchor = hyperlink->AnchorAt(aLinkIndex);
|
Accessible *anchor = hyperlink->AnchorAt(aLinkIndex);
|
||||||
NS_ENSURE_TRUE(anchor, nullptr);
|
NS_ENSURE_TRUE(anchor, nullptr);
|
||||||
|
|
||||||
return AccessibleWrap::GetAtkObject(anchor);
|
return AccessibleWrap::GetAtkObject(anchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyAccessible* anchor = maiLink->Proxy()->AnchorAt(aLinkIndex);
|
ProxyAccessible *anchor = maiLink->Proxy()->AnchorAt(aLinkIndex);
|
||||||
return anchor ? GetWrapperFor(anchor) : nullptr;
|
return anchor ? GetWrapperFor(anchor) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint getEndIndexCB(AtkHyperlink *aLink) {
|
||||||
getEndIndexCB(AtkHyperlink *aLink)
|
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
|
||||||
{
|
if (!maiLink) return false;
|
||||||
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
|
|
||||||
if (!maiLink)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (Accessible* hyperlink = maiLink->GetAccHyperlink())
|
if (Accessible *hyperlink = maiLink->GetAccHyperlink())
|
||||||
return static_cast<gint>(hyperlink->EndOffset());
|
return static_cast<gint>(hyperlink->EndOffset());
|
||||||
|
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
@@ -218,14 +191,11 @@ getEndIndexCB(AtkHyperlink *aLink)
|
|||||||
return valid ? static_cast<gint>(endIdx) : -1;
|
return valid ? static_cast<gint>(endIdx) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint getStartIndexCB(AtkHyperlink *aLink) {
|
||||||
getStartIndexCB(AtkHyperlink *aLink)
|
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
|
||||||
{
|
if (!maiLink) return -1;
|
||||||
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
|
|
||||||
if (!maiLink)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (Accessible* hyperlink = maiLink->GetAccHyperlink())
|
if (Accessible *hyperlink = maiLink->GetAccHyperlink())
|
||||||
return static_cast<gint>(hyperlink->StartOffset());
|
return static_cast<gint>(hyperlink->StartOffset());
|
||||||
|
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
@@ -233,27 +203,21 @@ getStartIndexCB(AtkHyperlink *aLink)
|
|||||||
return valid ? static_cast<gint>(startIdx) : -1;
|
return valid ? static_cast<gint>(startIdx) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean isValidCB(AtkHyperlink *aLink) {
|
||||||
isValidCB(AtkHyperlink *aLink)
|
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
|
||||||
{
|
if (!maiLink) return false;
|
||||||
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>(hyperlink->IsLinkValid());
|
||||||
|
|
||||||
return static_cast<gboolean>(maiLink->Proxy()->IsLinkValid());
|
return static_cast<gboolean>(maiLink->Proxy()->IsLinkValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint getAnchorCountCB(AtkHyperlink *aLink) {
|
||||||
getAnchorCountCB(AtkHyperlink *aLink)
|
MaiHyperlink *maiLink = GetMaiHyperlink(aLink);
|
||||||
{
|
if (!maiLink) return -1;
|
||||||
MaiHyperlink* maiLink = GetMaiHyperlink(aLink);
|
|
||||||
if (!maiLink)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (Accessible* hyperlink = maiLink->GetAccHyperlink())
|
if (Accessible *hyperlink = maiLink->GetAccHyperlink())
|
||||||
return static_cast<gint>(hyperlink->AnchorCount());
|
return static_cast<gint>(hyperlink->AnchorCount());
|
||||||
|
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "Accessible.h"
|
#include "Accessible.h"
|
||||||
|
|
||||||
struct _AtkHyperlink;
|
struct _AtkHyperlink;
|
||||||
typedef struct _AtkHyperlink AtkHyperlink;
|
typedef struct _AtkHyperlink AtkHyperlink;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
@@ -20,36 +20,33 @@ namespace a11y {
|
|||||||
* MaiHyperlink is a auxiliary class for MaiInterfaceHyperText.
|
* MaiHyperlink is a auxiliary class for MaiInterfaceHyperText.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MaiHyperlink
|
class MaiHyperlink {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit MaiHyperlink(AccessibleOrProxy aHyperLink);
|
explicit MaiHyperlink(AccessibleOrProxy aHyperLink);
|
||||||
~MaiHyperlink();
|
~MaiHyperlink();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AtkHyperlink* GetAtkHyperlink() const { return mMaiAtkHyperlink; }
|
AtkHyperlink* GetAtkHyperlink() const { return mMaiAtkHyperlink; }
|
||||||
Accessible* GetAccHyperlink()
|
Accessible* GetAccHyperlink() {
|
||||||
{
|
if (!mHyperlink.IsAccessible()) return nullptr;
|
||||||
if (!mHyperlink.IsAccessible())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
Accessible* link = mHyperlink.AsAccessible();
|
Accessible* link = mHyperlink.AsAccessible();
|
||||||
if (!link) {
|
if (!link) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
NS_ASSERTION(link->IsLink(), "Why isn't it a link!");
|
|
||||||
return link;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_ASSERTION(link->IsLink(), "Why isn't it a link!");
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
ProxyAccessible* Proxy() const { return mHyperlink.AsProxy(); }
|
ProxyAccessible* Proxy() const { return mHyperlink.AsProxy(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AccessibleOrProxy mHyperlink;
|
AccessibleOrProxy mHyperlink;
|
||||||
AtkHyperlink* mMaiAtkHyperlink;
|
AtkHyperlink* mMaiAtkHyperlink;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* __MAI_HYPERLINK_H__ */
|
#endif /* __MAI_HYPERLINK_H__ */
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ using namespace mozilla::a11y;
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static gboolean
|
static gboolean doActionCB(AtkAction* aAction, gint aActionIndex) {
|
||||||
doActionCB(AtkAction *aAction, gint aActionIndex)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return accWrap->DoAction(aActionIndex);
|
return accWrap->DoAction(aActionIndex);
|
||||||
@@ -29,9 +27,7 @@ doActionCB(AtkAction *aAction, gint aActionIndex)
|
|||||||
return proxy && proxy->DoAction(aActionIndex);
|
return proxy && proxy->DoAction(aActionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getActionCountCB(AtkAction* aAction) {
|
||||||
getActionCountCB(AtkAction *aAction)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return accWrap->ActionCount();
|
return accWrap->ActionCount();
|
||||||
@@ -41,9 +37,8 @@ getActionCountCB(AtkAction *aAction)
|
|||||||
return proxy ? proxy->ActionCount() : 0;
|
return proxy ? proxy->ActionCount() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar*
|
static const gchar* getActionDescriptionCB(AtkAction* aAction,
|
||||||
getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
|
gint aActionIndex) {
|
||||||
{
|
|
||||||
nsAutoString description;
|
nsAutoString description;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -57,9 +52,7 @@ getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
|
|||||||
return AccessibleWrap::ReturnString(description);
|
return AccessibleWrap::ReturnString(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar*
|
static const gchar* getActionNameCB(AtkAction* aAction, gint aActionIndex) {
|
||||||
getActionNameCB(AtkAction *aAction, gint aActionIndex)
|
|
||||||
{
|
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -73,9 +66,7 @@ getActionNameCB(AtkAction *aAction, gint aActionIndex)
|
|||||||
return AccessibleWrap::ReturnString(autoStr);
|
return AccessibleWrap::ReturnString(autoStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar*
|
static const gchar* getKeyBindingCB(AtkAction* aAction, gint aActionIndex) {
|
||||||
getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
|
|
||||||
{
|
|
||||||
nsAutoString keyBindingsStr;
|
nsAutoString keyBindingsStr;
|
||||||
AccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction));
|
AccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction));
|
||||||
if (acc) {
|
if (acc) {
|
||||||
@@ -90,12 +81,9 @@ getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void actionInterfaceInitCB(AtkActionIface* aIface) {
|
||||||
actionInterfaceInitCB(AtkActionIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "Invalid aIface");
|
NS_ASSERTION(aIface, "Invalid aIface");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->do_action = doActionCB;
|
aIface->do_action = doActionCB;
|
||||||
aIface->get_n_actions = getActionCountCB;
|
aIface->get_n_actions = getActionCountCB;
|
||||||
|
|||||||
@@ -18,25 +18,18 @@ using namespace mozilla::a11y;
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject* refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX,
|
||||||
refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX, gint aAccY,
|
gint aAccY, AtkCoordType aCoordType) {
|
||||||
AtkCoordType aCoordType)
|
return refAccessibleAtPointHelper(ATK_OBJECT(aComponent), aAccX, aAccY,
|
||||||
{
|
aCoordType);
|
||||||
return refAccessibleAtPointHelper(ATK_OBJECT(aComponent),
|
|
||||||
aAccX, aAccY, aCoordType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
|
||||||
getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
|
gint* aWidth, gint* aHeight, AtkCoordType aCoordType) {
|
||||||
gint* aWidth, gint* aHeight, AtkCoordType aCoordType)
|
getExtentsHelper(ATK_OBJECT(aComponent), aX, aY, aWidth, aHeight, aCoordType);
|
||||||
{
|
|
||||||
getExtentsHelper(ATK_OBJECT(aComponent),
|
|
||||||
aX, aY, aWidth, aHeight, aCoordType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean grabFocusCB(AtkComponent* aComponent) {
|
||||||
grabFocusCB(AtkComponent* aComponent)
|
|
||||||
{
|
|
||||||
AtkObject* atkObject = ATK_OBJECT(aComponent);
|
AtkObject* atkObject = ATK_OBJECT(aComponent);
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
|
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -54,9 +47,7 @@ grabFocusCB(AtkComponent* aComponent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ScrollType is compatible
|
// ScrollType is compatible
|
||||||
static gboolean
|
static gboolean scrollToCB(AtkComponent* aComponent, AtkScrollType type) {
|
||||||
scrollToCB(AtkComponent* aComponent, AtkScrollType type)
|
|
||||||
{
|
|
||||||
AtkObject* atkObject = ATK_OBJECT(aComponent);
|
AtkObject* atkObject = ATK_OBJECT(aComponent);
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
|
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -74,9 +65,8 @@ scrollToCB(AtkComponent* aComponent, AtkScrollType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CoordType is compatible
|
// CoordType is compatible
|
||||||
static gboolean
|
static gboolean scrollToPointCB(AtkComponent* aComponent, AtkCoordType coords,
|
||||||
scrollToPointCB(AtkComponent* aComponent, AtkCoordType coords, gint x, gint y)
|
gint x, gint y) {
|
||||||
{
|
|
||||||
AtkObject* atkObject = ATK_OBJECT(aComponent);
|
AtkObject* atkObject = ATK_OBJECT(aComponent);
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
|
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -94,10 +84,8 @@ scrollToPointCB(AtkComponent* aComponent, AtkCoordType coords, gint x, gint y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AtkObject*
|
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
||||||
refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
AtkCoordType aCoordType) {
|
||||||
AtkCoordType aCoordType)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
if (accWrap->IsDefunct() || nsAccUtils::MustPrune(accWrap)) {
|
if (accWrap->IsDefunct() || nsAccUtils::MustPrune(accWrap)) {
|
||||||
@@ -107,13 +95,13 @@ refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
|||||||
// Accessible::ChildAtPoint(x,y) is in screen pixels.
|
// Accessible::ChildAtPoint(x,y) is in screen pixels.
|
||||||
if (aCoordType == ATK_XY_WINDOW) {
|
if (aCoordType == ATK_XY_WINDOW) {
|
||||||
nsIntPoint winCoords =
|
nsIntPoint winCoords =
|
||||||
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
|
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
|
||||||
aX += winCoords.x;
|
aX += winCoords.x;
|
||||||
aY += winCoords.y;
|
aY += winCoords.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible* accAtPoint = accWrap->ChildAtPoint(aX, aY,
|
Accessible* accAtPoint =
|
||||||
Accessible::eDirectChild);
|
accWrap->ChildAtPoint(aX, aY, Accessible::eDirectChild);
|
||||||
if (!accAtPoint) {
|
if (!accAtPoint) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -128,7 +116,7 @@ refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
|||||||
|
|
||||||
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
|
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
|
||||||
ProxyAccessible* result =
|
ProxyAccessible* result =
|
||||||
proxy->AccessibleAtPoint(aX, aY, aCoordType == ATK_XY_WINDOW);
|
proxy->AccessibleAtPoint(aX, aY, aCoordType == ATK_XY_WINDOW);
|
||||||
AtkObject* atkObj = result ? GetWrapperFor(result) : nullptr;
|
AtkObject* atkObj = result ? GetWrapperFor(result) : nullptr;
|
||||||
if (atkObj) {
|
if (atkObj) {
|
||||||
g_object_ref(atkObj);
|
g_object_ref(atkObj);
|
||||||
@@ -139,11 +127,8 @@ refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
||||||
getExtentsHelper(AtkObject* aAtkObj,
|
gint* aHeight, AtkCoordType aCoordType) {
|
||||||
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
|
|
||||||
AtkCoordType aCoordType)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
||||||
*aX = *aY = *aWidth = *aHeight = 0;
|
*aX = *aY = *aWidth = *aHeight = 0;
|
||||||
|
|
||||||
@@ -153,12 +138,11 @@ getExtentsHelper(AtkObject* aAtkObj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsIntRect screenRect = accWrap->Bounds();
|
nsIntRect screenRect = accWrap->Bounds();
|
||||||
if (screenRect.IsEmpty())
|
if (screenRect.IsEmpty()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (aCoordType == ATK_XY_WINDOW) {
|
if (aCoordType == ATK_XY_WINDOW) {
|
||||||
nsIntPoint winCoords =
|
nsIntPoint winCoords =
|
||||||
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
|
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
|
||||||
screenRect.x -= winCoords.x;
|
screenRect.x -= winCoords.x;
|
||||||
screenRect.y -= winCoords.y;
|
screenRect.y -= winCoords.y;
|
||||||
}
|
}
|
||||||
@@ -175,12 +159,9 @@ getExtentsHelper(AtkObject* aAtkObj,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void componentInterfaceInitCB(AtkComponentIface* aIface) {
|
||||||
componentInterfaceInitCB(AtkComponentIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "Invalid Interface");
|
NS_ASSERTION(aIface, "Invalid Interface");
|
||||||
if(MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use default implementation in atk for contains, get_position,
|
* Use default implementation in atk for contains, get_position,
|
||||||
|
|||||||
@@ -27,26 +27,21 @@ static AtkAttributeSet* getDocumentAttributesCB(AtkDocument* aDocument);
|
|||||||
static const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
|
static const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
|
||||||
const gchar* aAttrName);
|
const gchar* aAttrName);
|
||||||
|
|
||||||
void
|
void documentInterfaceInitCB(AtkDocumentIface* aIface) {
|
||||||
documentInterfaceInitCB(AtkDocumentIface *aIface)
|
NS_ASSERTION(aIface, "Invalid Interface");
|
||||||
{
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
NS_ASSERTION(aIface, "Invalid Interface");
|
|
||||||
if(MOZ_UNLIKELY(!aIface))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't support get_document or set_attribute right now.
|
* We don't support get_document or set_attribute right now.
|
||||||
* get_document_type is deprecated, we return DocType in
|
* get_document_type is deprecated, we return DocType in
|
||||||
* get_document_attribute_value and get_document_attributes instead.
|
* get_document_attribute_value and get_document_attributes instead.
|
||||||
*/
|
*/
|
||||||
aIface->get_document_attributes = getDocumentAttributesCB;
|
aIface->get_document_attributes = getDocumentAttributesCB;
|
||||||
aIface->get_document_attribute_value = getDocumentAttributeValueCB;
|
aIface->get_document_attribute_value = getDocumentAttributeValueCB;
|
||||||
aIface->get_document_locale = getDocumentLocaleCB;
|
aIface->get_document_locale = getDocumentLocaleCB;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar* getDocumentLocaleCB(AtkDocument* aDocument) {
|
||||||
getDocumentLocaleCB(AtkDocument *aDocument)
|
|
||||||
{
|
|
||||||
nsAutoString locale;
|
nsAutoString locale;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -58,23 +53,20 @@ getDocumentLocaleCB(AtkDocument *aDocument)
|
|||||||
return locale.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(locale);
|
return locale.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline GSList *
|
static inline GSList* prependToList(GSList* aList, const char* const aName,
|
||||||
prependToList(GSList *aList, const char *const aName, const nsAutoString &aValue)
|
const nsAutoString& aValue) {
|
||||||
{
|
|
||||||
if (aValue.IsEmpty()) {
|
if (aValue.IsEmpty()) {
|
||||||
return aList;
|
return aList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// libspi will free these
|
// libspi will free these
|
||||||
AtkAttribute *atkAttr = (AtkAttribute *)g_malloc(sizeof(AtkAttribute));
|
AtkAttribute* atkAttr = (AtkAttribute*)g_malloc(sizeof(AtkAttribute));
|
||||||
atkAttr->name = g_strdup(aName);
|
atkAttr->name = g_strdup(aName);
|
||||||
atkAttr->value = g_strdup(NS_ConvertUTF16toUTF8(aValue).get());
|
atkAttr->value = g_strdup(NS_ConvertUTF16toUTF8(aValue).get());
|
||||||
return g_slist_prepend(aList, atkAttr);
|
return g_slist_prepend(aList, atkAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
AtkAttributeSet *
|
AtkAttributeSet* getDocumentAttributesCB(AtkDocument* aDocument) {
|
||||||
getDocumentAttributesCB(AtkDocument *aDocument)
|
|
||||||
{
|
|
||||||
nsAutoString url;
|
nsAutoString url;
|
||||||
nsAutoString w3cDocType;
|
nsAutoString w3cDocType;
|
||||||
nsAutoString mimeType;
|
nsAutoString mimeType;
|
||||||
@@ -103,10 +95,8 @@ getDocumentAttributesCB(AtkDocument *aDocument)
|
|||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
|
||||||
getDocumentAttributeValueCB(AtkDocument *aDocument,
|
const gchar* aAttrName) {
|
||||||
const gchar *aAttrName)
|
|
||||||
{
|
|
||||||
ProxyAccessible* proxy = nullptr;
|
ProxyAccessible* proxy = nullptr;
|
||||||
DocAccessible* document = nullptr;
|
DocAccessible* document = nullptr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
|
||||||
@@ -146,6 +136,7 @@ getDocumentAttributeValueCB(AtkDocument *aDocument,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return attrValue.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(attrValue);
|
return attrValue.IsEmpty() ? nullptr
|
||||||
|
: AccessibleWrap::ReturnString(attrValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,7 @@
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static void
|
static void setTextContentsCB(AtkEditableText* aText, const gchar* aString) {
|
||||||
setTextContentsCB(AtkEditableText *aText, const gchar *aString)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -34,10 +32,8 @@ setTextContentsCB(AtkEditableText *aText, const gchar *aString)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void insertTextCB(AtkEditableText* aText, const gchar* aString,
|
||||||
insertTextCB(AtkEditableText *aText,
|
gint aLength, gint* aPosition) {
|
||||||
const gchar *aString, gint aLength, gint *aPosition)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -53,9 +49,7 @@ insertTextCB(AtkEditableText *aText,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void copyTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
|
||||||
copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -69,9 +63,7 @@ copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void cutTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
|
||||||
cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -85,9 +77,7 @@ cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void deleteTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
|
||||||
deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -101,9 +91,7 @@ deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void pasteTextCB(AtkEditableText* aText, gint aPosition) {
|
||||||
pasteTextCB(AtkEditableText *aText, gint aPosition)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -118,12 +106,9 @@ pasteTextCB(AtkEditableText *aText, gint aPosition)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void editableTextInterfaceInitCB(AtkEditableTextIface* aIface) {
|
||||||
editableTextInterfaceInitCB(AtkEditableTextIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "Invalid aIface");
|
NS_ASSERTION(aIface, "Invalid aIface");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->set_text_contents = setTextContentsCB;
|
aIface->set_text_contents = setTextContentsCB;
|
||||||
aIface->insert_text = insertTextCB;
|
aIface->insert_text = insertTextCB;
|
||||||
|
|||||||
@@ -12,26 +12,19 @@
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static AtkHyperlink*
|
static AtkHyperlink* getHyperlinkCB(AtkHyperlinkImpl* aImpl) {
|
||||||
getHyperlinkCB(AtkHyperlinkImpl* aImpl)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImpl));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImpl));
|
||||||
if (!accWrap && !GetProxy(ATK_OBJECT(aImpl)))
|
if (!accWrap && !GetProxy(ATK_OBJECT(aImpl))) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
if (accWrap)
|
if (accWrap) NS_ASSERTION(accWrap->IsLink(), "why isn't it a link!");
|
||||||
NS_ASSERTION(accWrap->IsLink(), "why isn't it a link!");
|
|
||||||
|
|
||||||
return MAI_ATK_OBJECT(aImpl)->GetAtkHyperlink();
|
return MAI_ATK_OBJECT(aImpl)->GetAtkHyperlink();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface* aIface) {
|
||||||
hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "no interface!");
|
NS_ASSERTION(aIface, "no interface!");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->get_hyperlink = getHyperlinkCB;
|
aIface->get_hyperlink = getHyperlinkCB;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,11 @@
|
|||||||
#include "ProxyAccessible.h"
|
#include "ProxyAccessible.h"
|
||||||
#include "mozilla/Likely.h"
|
#include "mozilla/Likely.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static AtkHyperlink*
|
static AtkHyperlink* getLinkCB(AtkHypertext* aText, gint aLinkIndex) {
|
||||||
getLinkCB(AtkHypertext *aText, gint aLinkIndex)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
AtkObject* atkHyperLink = nullptr;
|
AtkObject* atkHyperLink = nullptr;
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -35,19 +32,16 @@ getLinkCB(AtkHypertext *aText, gint aLinkIndex)
|
|||||||
atkHyperLink = AccessibleWrap::GetAtkObject(hyperLink);
|
atkHyperLink = AccessibleWrap::GetAtkObject(hyperLink);
|
||||||
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||||
ProxyAccessible* proxyLink = proxy->LinkAt(aLinkIndex);
|
ProxyAccessible* proxyLink = proxy->LinkAt(aLinkIndex);
|
||||||
if (!proxyLink)
|
if (!proxyLink) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
atkHyperLink = GetWrapperFor(proxyLink);
|
atkHyperLink = GetWrapperFor(proxyLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ENSURE_TRUE(IS_MAI_OBJECT(atkHyperLink), nullptr);
|
NS_ENSURE_TRUE(IS_MAI_OBJECT(atkHyperLink), nullptr);
|
||||||
return MAI_ATK_OBJECT(atkHyperLink)->GetAtkHyperlink();
|
return MAI_ATK_OBJECT(atkHyperLink)->GetAtkHyperlink();
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getLinkCountCB(AtkHypertext* aText) {
|
||||||
getLinkCountCB(AtkHypertext *aText)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* hyperText = accWrap->AsHyperText();
|
HyperTextAccessible* hyperText = accWrap->AsHyperText();
|
||||||
@@ -62,9 +56,7 @@ getLinkCountCB(AtkHypertext *aText)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getLinkIndexCB(AtkHypertext* aText, gint aCharIndex) {
|
||||||
getLinkIndexCB(AtkHypertext *aText, gint aCharIndex)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* hyperText = accWrap->AsHyperText();
|
HyperTextAccessible* hyperText = accWrap->AsHyperText();
|
||||||
@@ -81,12 +73,9 @@ getLinkIndexCB(AtkHypertext *aText, gint aCharIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void hypertextInterfaceInitCB(AtkHypertextIface* aIface) {
|
||||||
hypertextInterfaceInitCB(AtkHypertextIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "no interface!");
|
NS_ASSERTION(aIface, "no interface!");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->get_link = getLinkCB;
|
aIface->get_link = getLinkCB;
|
||||||
aIface->get_n_links = getLinkCountCB;
|
aIface->get_n_links = getLinkCountCB;
|
||||||
|
|||||||
@@ -20,14 +20,13 @@ using namespace mozilla::a11y;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
const gchar* getDescriptionCB(AtkObject* aAtkObj);
|
const gchar* getDescriptionCB(AtkObject* aAtkObj);
|
||||||
|
|
||||||
static void
|
static void getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
|
||||||
getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
|
AtkCoordType aCoordType) {
|
||||||
AtkCoordType aCoordType)
|
|
||||||
{
|
|
||||||
nsIntPoint pos;
|
nsIntPoint pos;
|
||||||
uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
|
uint32_t geckoCoordType =
|
||||||
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
|
(aCoordType == ATK_XY_WINDOW)
|
||||||
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
|
? nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE
|
||||||
|
: nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
|
||||||
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
||||||
if (accWrap && accWrap->IsImage()) {
|
if (accWrap && accWrap->IsImage()) {
|
||||||
@@ -41,15 +40,12 @@ getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
|
|||||||
*aAccY = pos.y;
|
*aAccY = pos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar*
|
static const gchar* getImageDescriptionCB(AtkImage* aImage) {
|
||||||
getImageDescriptionCB(AtkImage* aImage)
|
|
||||||
{
|
|
||||||
return getDescriptionCB(ATK_OBJECT(aImage));
|
return getDescriptionCB(ATK_OBJECT(aImage));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void getImageSizeCB(AtkImage* aImage, gint* aAccWidth,
|
||||||
getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
|
gint* aAccHeight) {
|
||||||
{
|
|
||||||
nsIntSize size;
|
nsIntSize size;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
||||||
if (accWrap && accWrap->IsImage()) {
|
if (accWrap && accWrap->IsImage()) {
|
||||||
@@ -62,14 +58,11 @@ getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
|
|||||||
*aAccHeight = size.height;
|
*aAccHeight = size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
void
|
void imageInterfaceInitCB(AtkImageIface* aIface) {
|
||||||
imageInterfaceInitCB(AtkImageIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "no interface!");
|
NS_ASSERTION(aIface, "no interface!");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->get_image_position = getImagePositionCB;
|
aIface->get_image_position = getImagePositionCB;
|
||||||
aIface->get_image_description = getImageDescriptionCB;
|
aIface->get_image_description = getImageDescriptionCB;
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ using namespace mozilla::a11y;
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static gboolean
|
static gboolean addSelectionCB(AtkSelection* aSelection, gint i) {
|
||||||
addSelectionCB(AtkSelection *aSelection, gint i)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
||||||
if (accWrap && accWrap->IsSelect()) {
|
if (accWrap && accWrap->IsSelect()) {
|
||||||
return accWrap->AddItemToSelection(i);
|
return accWrap->AddItemToSelection(i);
|
||||||
@@ -33,9 +31,7 @@ addSelectionCB(AtkSelection *aSelection, gint i)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean clearSelectionCB(AtkSelection* aSelection) {
|
||||||
clearSelectionCB(AtkSelection *aSelection)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
||||||
if (accWrap && accWrap->IsSelect()) {
|
if (accWrap && accWrap->IsSelect()) {
|
||||||
return accWrap->UnselectAll();
|
return accWrap->UnselectAll();
|
||||||
@@ -48,9 +44,7 @@ clearSelectionCB(AtkSelection *aSelection)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject* refSelectionCB(AtkSelection* aSelection, gint i) {
|
||||||
refSelectionCB(AtkSelection *aSelection, gint i)
|
|
||||||
{
|
|
||||||
AtkObject* atkObj = nullptr;
|
AtkObject* atkObj = nullptr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
||||||
if (accWrap && accWrap->IsSelect()) {
|
if (accWrap && accWrap->IsSelect()) {
|
||||||
@@ -74,9 +68,7 @@ refSelectionCB(AtkSelection *aSelection, gint i)
|
|||||||
return atkObj;
|
return atkObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getSelectionCountCB(AtkSelection* aSelection) {
|
||||||
getSelectionCountCB(AtkSelection *aSelection)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
||||||
if (accWrap && accWrap->IsSelect()) {
|
if (accWrap && accWrap->IsSelect()) {
|
||||||
return accWrap->SelectedItemCount();
|
return accWrap->SelectedItemCount();
|
||||||
@@ -89,9 +81,7 @@ getSelectionCountCB(AtkSelection *aSelection)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean isChildSelectedCB(AtkSelection* aSelection, gint i) {
|
||||||
isChildSelectedCB(AtkSelection *aSelection, gint i)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
||||||
if (accWrap && accWrap->IsSelect()) {
|
if (accWrap && accWrap->IsSelect()) {
|
||||||
return accWrap->IsItemSelected(i);
|
return accWrap->IsItemSelected(i);
|
||||||
@@ -104,9 +94,7 @@ isChildSelectedCB(AtkSelection *aSelection, gint i)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean removeSelectionCB(AtkSelection* aSelection, gint i) {
|
||||||
removeSelectionCB(AtkSelection *aSelection, gint i)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
||||||
if (accWrap && accWrap->IsSelect()) {
|
if (accWrap && accWrap->IsSelect()) {
|
||||||
return accWrap->RemoveItemFromSelection(i);
|
return accWrap->RemoveItemFromSelection(i);
|
||||||
@@ -119,9 +107,7 @@ removeSelectionCB(AtkSelection *aSelection, gint i)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean selectAllSelectionCB(AtkSelection* aSelection) {
|
||||||
selectAllSelectionCB(AtkSelection *aSelection)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
||||||
if (accWrap && accWrap->IsSelect()) {
|
if (accWrap && accWrap->IsSelect()) {
|
||||||
return accWrap->SelectAll();
|
return accWrap->SelectAll();
|
||||||
@@ -135,12 +121,9 @@ selectAllSelectionCB(AtkSelection *aSelection)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void selectionInterfaceInitCB(AtkSelectionIface* aIface) {
|
||||||
selectionInterfaceInitCB(AtkSelectionIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "Invalid aIface");
|
NS_ASSERTION(aIface, "Invalid aIface");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->add_selection = addSelectionCB;
|
aIface->add_selection = addSelectionCB;
|
||||||
aIface->clear_selection = clearSelectionCB;
|
aIface->clear_selection = clearSelectionCB;
|
||||||
|
|||||||
@@ -20,9 +20,7 @@
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static AtkObject*
|
static AtkObject* refAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
|
||||||
refAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx)
|
|
||||||
{
|
|
||||||
if (aRowIdx < 0 || aColIdx < 0) {
|
if (aRowIdx < 0 || aColIdx < 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -52,9 +50,7 @@ refAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx)
|
|||||||
return cellAtkObj;
|
return cellAtkObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getIndexAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
|
||||||
getIndexAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx)
|
|
||||||
{
|
|
||||||
if (aRowIdx < 0 || aColIdx < 0) {
|
if (aRowIdx < 0 || aColIdx < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -71,9 +67,7 @@ getIndexAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getColumnAtIndexCB(AtkTable* aTable, gint aIdx) {
|
||||||
getColumnAtIndexCB(AtkTable *aTable, gint aIdx)
|
|
||||||
{
|
|
||||||
if (aIdx < 0) {
|
if (aIdx < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -90,9 +84,7 @@ getColumnAtIndexCB(AtkTable *aTable, gint aIdx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getRowAtIndexCB(AtkTable* aTable, gint aIdx) {
|
||||||
getRowAtIndexCB(AtkTable *aTable, gint aIdx)
|
|
||||||
{
|
|
||||||
if (aIdx < 0) {
|
if (aIdx < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -109,9 +101,7 @@ getRowAtIndexCB(AtkTable *aTable, gint aIdx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getColumnCountCB(AtkTable* aTable) {
|
||||||
getColumnCountCB(AtkTable *aTable)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return static_cast<gint>(accWrap->AsTable()->ColCount());
|
return static_cast<gint>(accWrap->AsTable()->ColCount());
|
||||||
@@ -124,9 +114,7 @@ getColumnCountCB(AtkTable *aTable)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getRowCountCB(AtkTable* aTable) {
|
||||||
getRowCountCB(AtkTable *aTable)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return static_cast<gint>(accWrap->AsTable()->RowCount());
|
return static_cast<gint>(accWrap->AsTable()->RowCount());
|
||||||
@@ -139,9 +127,7 @@ getRowCountCB(AtkTable *aTable)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getColumnExtentAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
|
||||||
getColumnExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
|
|
||||||
{
|
|
||||||
if (aRowIdx < 0 || aColIdx < 0) {
|
if (aRowIdx < 0 || aColIdx < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -158,9 +144,7 @@ getColumnExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getRowExtentAtCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
|
||||||
getRowExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return static_cast<gint>(accWrap->AsTable()->RowExtentAt(aRowIdx, aColIdx));
|
return static_cast<gint>(accWrap->AsTable()->RowExtentAt(aRowIdx, aColIdx));
|
||||||
@@ -173,9 +157,7 @@ getRowExtentAtCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject* getCaptionCB(AtkTable* aTable) {
|
||||||
getCaptionCB(AtkTable* aTable)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
Accessible* caption = accWrap->AsTable()->Caption();
|
Accessible* caption = accWrap->AsTable()->Caption();
|
||||||
@@ -190,9 +172,7 @@ getCaptionCB(AtkTable* aTable)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar*
|
static const gchar* getColumnDescriptionCB(AtkTable* aTable, gint aColumn) {
|
||||||
getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
|
|
||||||
{
|
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -206,13 +186,11 @@ getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
|
|||||||
return AccessibleWrap::ReturnString(autoStr);
|
return AccessibleWrap::ReturnString(autoStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject* getColumnHeaderCB(AtkTable* aTable, gint aColIdx) {
|
||||||
getColumnHeaderCB(AtkTable *aTable, gint aColIdx)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
Accessible* header =
|
Accessible* header =
|
||||||
AccessibleWrap::GetColumnHeader(accWrap->AsTable(), aColIdx);
|
AccessibleWrap::GetColumnHeader(accWrap->AsTable(), aColIdx);
|
||||||
return header ? AccessibleWrap::GetAtkObject(header) : nullptr;
|
return header ? AccessibleWrap::GetAtkObject(header) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,9 +202,7 @@ getColumnHeaderCB(AtkTable *aTable, gint aColIdx)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar*
|
static const gchar* getRowDescriptionCB(AtkTable* aTable, gint aRow) {
|
||||||
getRowDescriptionCB(AtkTable *aTable, gint aRow)
|
|
||||||
{
|
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -240,13 +216,11 @@ getRowDescriptionCB(AtkTable *aTable, gint aRow)
|
|||||||
return AccessibleWrap::ReturnString(autoStr);
|
return AccessibleWrap::ReturnString(autoStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject* getRowHeaderCB(AtkTable* aTable, gint aRowIdx) {
|
||||||
getRowHeaderCB(AtkTable *aTable, gint aRowIdx)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
Accessible* header =
|
Accessible* header =
|
||||||
AccessibleWrap::GetRowHeader(accWrap->AsTable(), aRowIdx);
|
AccessibleWrap::GetRowHeader(accWrap->AsTable(), aRowIdx);
|
||||||
return header ? AccessibleWrap::GetAtkObject(header) : nullptr;
|
return header ? AccessibleWrap::GetAtkObject(header) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,9 +232,7 @@ getRowHeaderCB(AtkTable *aTable, gint aRowIdx)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject* getSummaryCB(AtkTable* aTable) {
|
||||||
getSummaryCB(AtkTable *aTable)
|
|
||||||
{
|
|
||||||
// Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
|
// 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
|
// 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
|
// in TableAccessible::summary to get a summary as a string which is not
|
||||||
@@ -268,23 +240,20 @@ getSummaryCB(AtkTable *aTable)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getSelectedColumnsCB(AtkTable* aTable, gint** aSelected) {
|
||||||
getSelectedColumnsCB(AtkTable *aTable, gint** aSelected)
|
|
||||||
{
|
|
||||||
*aSelected = nullptr;
|
*aSelected = nullptr;
|
||||||
|
|
||||||
AutoTArray<uint32_t, 10> cols;
|
AutoTArray<uint32_t, 10> cols;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
accWrap->AsTable()->SelectedColIndices(&cols);
|
accWrap->AsTable()->SelectedColIndices(&cols);
|
||||||
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) {
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) {
|
||||||
proxy->TableSelectedColumnIndices(&cols);
|
proxy->TableSelectedColumnIndices(&cols);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cols.IsEmpty())
|
if (cols.IsEmpty()) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
gint* atkColumns = g_new(gint, cols.Length());
|
gint* atkColumns = g_new(gint, cols.Length());
|
||||||
if (!atkColumns) {
|
if (!atkColumns) {
|
||||||
@@ -297,9 +266,7 @@ getSelectedColumnsCB(AtkTable *aTable, gint** aSelected)
|
|||||||
return cols.Length();
|
return cols.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getSelectedRowsCB(AtkTable* aTable, gint** aSelected) {
|
||||||
getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
|
|
||||||
{
|
|
||||||
AutoTArray<uint32_t, 10> rows;
|
AutoTArray<uint32_t, 10> rows;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -321,9 +288,7 @@ getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
|
|||||||
return rows.Length();
|
return rows.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean isColumnSelectedCB(AtkTable* aTable, gint aColIdx) {
|
||||||
isColumnSelectedCB(AtkTable *aTable, gint aColIdx)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return static_cast<gboolean>(accWrap->AsTable()->IsColSelected(aColIdx));
|
return static_cast<gboolean>(accWrap->AsTable()->IsColSelected(aColIdx));
|
||||||
@@ -335,9 +300,7 @@ isColumnSelectedCB(AtkTable *aTable, gint aColIdx)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean isRowSelectedCB(AtkTable* aTable, gint aRowIdx) {
|
||||||
isRowSelectedCB(AtkTable *aTable, gint aRowIdx)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return static_cast<gboolean>(accWrap->AsTable()->IsRowSelected(aRowIdx));
|
return static_cast<gboolean>(accWrap->AsTable()->IsRowSelected(aRowIdx));
|
||||||
@@ -349,13 +312,11 @@ isRowSelectedCB(AtkTable *aTable, gint aRowIdx)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean isCellSelectedCB(AtkTable* aTable, gint aRowIdx, gint aColIdx) {
|
||||||
isCellSelectedCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return static_cast<gboolean>(accWrap->AsTable()->
|
return static_cast<gboolean>(
|
||||||
IsCellSelected(aRowIdx, aColIdx));
|
accWrap->AsTable()->IsCellSelected(aRowIdx, aColIdx));
|
||||||
}
|
}
|
||||||
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) {
|
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTable))) {
|
||||||
return static_cast<gboolean>(proxy->TableCellSelected(aRowIdx, aColIdx));
|
return static_cast<gboolean>(proxy->TableCellSelected(aRowIdx, aColIdx));
|
||||||
@@ -365,12 +326,9 @@ isCellSelectedCB(AtkTable *aTable, gint aRowIdx, gint aColIdx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void tableInterfaceInitCB(AtkTableIface* aIface) {
|
||||||
tableInterfaceInitCB(AtkTableIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "no interface!");
|
NS_ASSERTION(aIface, "no interface!");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->ref_at = refAtCB;
|
aIface->ref_at = refAtCB;
|
||||||
aIface->get_index_at = getIndexAtCB;
|
aIface->get_index_at = getIndexAtCB;
|
||||||
|
|||||||
@@ -20,9 +20,7 @@
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static gint
|
static gint GetColumnSpanCB(AtkTableCell* aCell) {
|
||||||
GetColumnSpanCB(AtkTableCell* aCell)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return accWrap->AsTableCell()->ColExtent();
|
return accWrap->AsTableCell()->ColExtent();
|
||||||
@@ -35,9 +33,7 @@ GetColumnSpanCB(AtkTableCell* aCell)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean GetRowSpanCB(AtkTableCell* aCell) {
|
||||||
GetRowSpanCB(AtkTableCell* aCell)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
return accWrap->AsTableCell()->RowExtent();
|
return accWrap->AsTableCell()->RowExtent();
|
||||||
@@ -50,9 +46,7 @@ GetRowSpanCB(AtkTableCell* aCell)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol) {
|
||||||
GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol)
|
|
||||||
{
|
|
||||||
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
||||||
TableCellAccessible* cell = accWrap->AsTableCell();
|
TableCellAccessible* cell = accWrap->AsTableCell();
|
||||||
if (!cell) {
|
if (!cell) {
|
||||||
@@ -74,9 +68,8 @@ GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
|
||||||
GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
|
gint* aColExtent, gint* aRowExtent) {
|
||||||
gint* aColExtent, gint* aRowExtent) {
|
|
||||||
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
||||||
TableCellAccessible* cellAcc = accWrap->AsTableCell();
|
TableCellAccessible* cellAcc = accWrap->AsTableCell();
|
||||||
if (!cellAcc) {
|
if (!cellAcc) {
|
||||||
@@ -96,15 +89,13 @@ GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
|
|||||||
*aRow = rowIdx;
|
*aRow = rowIdx;
|
||||||
*aColExtent = colExtent;
|
*aColExtent = colExtent;
|
||||||
*aRowExtent = rowExtent;
|
*aRowExtent = rowExtent;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkObject*
|
static AtkObject* GetTableCB(AtkTableCell* aTableCell) {
|
||||||
GetTableCB(AtkTableCell* aTableCell)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTableCell));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTableCell));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
TableAccessible* table = accWrap->AsTableCell()->Table();
|
TableAccessible* table = accWrap->AsTableCell()->Table();
|
||||||
@@ -124,9 +115,7 @@ GetTableCB(AtkTableCell* aTableCell)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GPtrArray*
|
static GPtrArray* GetColumnHeaderCellsCB(AtkTableCell* aCell) {
|
||||||
GetColumnHeaderCellsCB(AtkTableCell* aCell)
|
|
||||||
{
|
|
||||||
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
||||||
AutoTArray<Accessible*, 10> headers;
|
AutoTArray<Accessible*, 10> headers;
|
||||||
accWrap->AsTableCell()->ColHeaderCells(&headers);
|
accWrap->AsTableCell()->ColHeaderCells(&headers);
|
||||||
@@ -135,7 +124,7 @@ GetColumnHeaderCellsCB(AtkTableCell* aCell)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
||||||
for (Accessible* header: headers) {
|
for (Accessible* header : headers) {
|
||||||
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
|
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
|
||||||
g_object_ref(atkHeader);
|
g_object_ref(atkHeader);
|
||||||
g_ptr_array_add(atkHeaders, atkHeader);
|
g_ptr_array_add(atkHeaders, atkHeader);
|
||||||
@@ -152,7 +141,7 @@ GetColumnHeaderCellsCB(AtkTableCell* aCell)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
||||||
for (ProxyAccessible* header: headers) {
|
for (ProxyAccessible* header : headers) {
|
||||||
AtkObject* atkHeader = GetWrapperFor(header);
|
AtkObject* atkHeader = GetWrapperFor(header);
|
||||||
g_object_ref(atkHeader);
|
g_object_ref(atkHeader);
|
||||||
g_ptr_array_add(atkHeaders, atkHeader);
|
g_ptr_array_add(atkHeaders, atkHeader);
|
||||||
@@ -164,9 +153,7 @@ GetColumnHeaderCellsCB(AtkTableCell* aCell)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GPtrArray*
|
static GPtrArray* GetRowHeaderCellsCB(AtkTableCell* aCell) {
|
||||||
GetRowHeaderCellsCB(AtkTableCell* aCell)
|
|
||||||
{
|
|
||||||
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
||||||
AutoTArray<Accessible*, 10> headers;
|
AutoTArray<Accessible*, 10> headers;
|
||||||
accWrap->AsTableCell()->RowHeaderCells(&headers);
|
accWrap->AsTableCell()->RowHeaderCells(&headers);
|
||||||
@@ -175,7 +162,7 @@ GetRowHeaderCellsCB(AtkTableCell* aCell)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
||||||
for (Accessible* header: headers) {
|
for (Accessible* header : headers) {
|
||||||
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
|
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
|
||||||
g_object_ref(atkHeader);
|
g_object_ref(atkHeader);
|
||||||
g_ptr_array_add(atkHeaders, atkHeader);
|
g_ptr_array_add(atkHeaders, atkHeader);
|
||||||
@@ -192,7 +179,7 @@ GetRowHeaderCellsCB(AtkTableCell* aCell)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
||||||
for (ProxyAccessible* header: headers) {
|
for (ProxyAccessible* header : headers) {
|
||||||
AtkObject* atkHeader = GetWrapperFor(header);
|
AtkObject* atkHeader = GetWrapperFor(header);
|
||||||
g_object_ref(atkHeader);
|
g_object_ref(atkHeader);
|
||||||
g_ptr_array_add(atkHeaders, atkHeader);
|
g_ptr_array_add(atkHeaders, atkHeader);
|
||||||
@@ -205,12 +192,9 @@ GetRowHeaderCellsCB(AtkTableCell* aCell)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void tableCellInterfaceInitCB(AtkTableCellIface* aIface) {
|
||||||
tableCellInterfaceInitCB(AtkTableCellIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "no interface!");
|
NS_ASSERTION(aIface, "no interface!");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->get_column_span = GetColumnSpanCB;
|
aIface->get_column_span = GetColumnSpanCB;
|
||||||
aIface->get_column_header_cells = GetColumnHeaderCellsCB;
|
aIface->get_column_header_cells = GetColumnHeaderCellsCB;
|
||||||
|
|||||||
@@ -25,11 +25,9 @@ using namespace mozilla::a11y;
|
|||||||
|
|
||||||
static const char* sAtkTextAttrNames[ATK_TEXT_ATTR_LAST_DEFINED];
|
static const char* sAtkTextAttrNames[ATK_TEXT_ATTR_LAST_DEFINED];
|
||||||
|
|
||||||
void
|
void ConvertTextAttributeToAtkAttribute(const nsACString& aName,
|
||||||
ConvertTextAttributeToAtkAttribute(const nsACString& aName,
|
const nsAString& aValue,
|
||||||
const nsAString& aValue,
|
AtkAttributeSet** aAttributeSet) {
|
||||||
AtkAttributeSet** aAttributeSet)
|
|
||||||
{
|
|
||||||
// Handle attributes where atk has its own name.
|
// Handle attributes where atk has its own name.
|
||||||
const char* atkName = nullptr;
|
const char* atkName = nullptr;
|
||||||
nsAutoString atkValue;
|
nsAutoString atkValue;
|
||||||
@@ -62,35 +60,31 @@ ConvertTextAttributeToAtkAttribute(const nsACString& aName,
|
|||||||
|
|
||||||
if (atkName) {
|
if (atkName) {
|
||||||
AtkAttribute* objAttr =
|
AtkAttribute* objAttr =
|
||||||
static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
|
static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
|
||||||
objAttr->name = g_strdup(atkName);
|
objAttr->name = g_strdup(atkName);
|
||||||
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(atkValue).get());
|
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(atkValue).get());
|
||||||
*aAttributeSet = g_slist_prepend(*aAttributeSet, objAttr);
|
*aAttributeSet = g_slist_prepend(*aAttributeSet, objAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkAttributeSet*
|
static AtkAttributeSet* ConvertToAtkTextAttributeSet(
|
||||||
ConvertToAtkTextAttributeSet(nsTArray<Attribute>& aAttributes)
|
nsTArray<Attribute>& aAttributes) {
|
||||||
{
|
|
||||||
AtkAttributeSet* objAttributeSet = nullptr;
|
AtkAttributeSet* objAttributeSet = nullptr;
|
||||||
for (size_t i = 0; i < aAttributes.Length(); ++i) {
|
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->name = g_strdup(aAttributes[i].Name().get());
|
||||||
objAttr->value =
|
objAttr->value =
|
||||||
g_strdup(NS_ConvertUTF16toUTF8(aAttributes[i].Value()).get());
|
g_strdup(NS_ConvertUTF16toUTF8(aAttributes[i].Value()).get());
|
||||||
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);
|
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);
|
||||||
ConvertTextAttributeToAtkAttribute(aAttributes[i].Name(),
|
ConvertTextAttributeToAtkAttribute(
|
||||||
aAttributes[i].Value(),
|
aAttributes[i].Name(), aAttributes[i].Value(), &objAttributeSet);
|
||||||
&objAttributeSet);
|
|
||||||
}
|
}
|
||||||
return objAttributeSet;
|
return objAttributeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkAttributeSet*
|
static AtkAttributeSet* ConvertToAtkTextAttributeSet(
|
||||||
ConvertToAtkTextAttributeSet(nsIPersistentProperties* aAttributes)
|
nsIPersistentProperties* aAttributes) {
|
||||||
{
|
if (!aAttributes) return nullptr;
|
||||||
if (!aAttributes)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
AtkAttributeSet* objAttributeSet = nullptr;
|
AtkAttributeSet* objAttributeSet = nullptr;
|
||||||
nsCOMPtr<nsISimpleEnumerator> propEnum;
|
nsCOMPtr<nsISimpleEnumerator> propEnum;
|
||||||
@@ -126,9 +120,8 @@ ConvertToAtkTextAttributeSet(nsIPersistentProperties* aAttributes)
|
|||||||
return objAttributeSet;
|
return objAttributeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void ConvertTexttoAsterisks(AccessibleWrap* accWrap,
|
||||||
ConvertTexttoAsterisks(AccessibleWrap* accWrap, nsAString& aString)
|
nsAString& aString) {
|
||||||
{
|
|
||||||
// convert each char to "*" when it's "password text"
|
// convert each char to "*" when it's "password text"
|
||||||
if (accWrap->IsPassword()) {
|
if (accWrap->IsPassword()) {
|
||||||
DOMtoATK::ConvertTexttoAsterisks(aString);
|
DOMtoATK::ConvertTexttoAsterisks(aString);
|
||||||
@@ -137,24 +130,22 @@ ConvertTexttoAsterisks(AccessibleWrap* accWrap, nsAString& aString)
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static gchar*
|
static gchar* getTextCB(AtkText* aText, gint aStartOffset, gint aEndOffset) {
|
||||||
getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
if (!text || !text->IsTextRole() || text->IsDefunct())
|
if (!text || !text->IsTextRole() || text->IsDefunct()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
return DOMtoATK::NewATKString(text, aStartOffset, aEndOffset,
|
return DOMtoATK::NewATKString(
|
||||||
accWrap->IsPassword() ?
|
text, aStartOffset, aEndOffset,
|
||||||
DOMtoATK::AtkStringConvertFlags::ConvertTextToAsterisks :
|
accWrap->IsPassword()
|
||||||
DOMtoATK::AtkStringConvertFlags::None);
|
? DOMtoATK::AtkStringConvertFlags::ConvertTextToAsterisks
|
||||||
|
: DOMtoATK::AtkStringConvertFlags::None);
|
||||||
|
|
||||||
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||||
return DOMtoATK::NewATKString(proxy, aStartOffset, aEndOffset,
|
return DOMtoATK::NewATKString(proxy, aStartOffset, aEndOffset,
|
||||||
DOMtoATK::AtkStringConvertFlags::None);
|
DOMtoATK::AtkStringConvertFlags::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -164,10 +155,8 @@ static gint getCharacterCountCB(AtkText* aText);
|
|||||||
|
|
||||||
// Note: this does not support magic offsets, which is fine for its callers
|
// Note: this does not support magic offsets, which is fine for its callers
|
||||||
// which do not implement any.
|
// which do not implement any.
|
||||||
static gchar*
|
static gchar* getCharTextAtOffset(AtkText* aText, gint aOffset,
|
||||||
getCharTextAtOffset(AtkText* aText, gint aOffset,
|
gint* aStartOffset, gint* aEndOffset) {
|
||||||
gint* aStartOffset, gint* aEndOffset)
|
|
||||||
{
|
|
||||||
gint end = aOffset + 1;
|
gint end = aOffset + 1;
|
||||||
gint count = getCharacterCountCB(aText);
|
gint count = getCharacterCountCB(aText);
|
||||||
|
|
||||||
@@ -189,24 +178,22 @@ getCharTextAtOffset(AtkText* aText, gint aOffset,
|
|||||||
return getTextCB(aText, aOffset, end);
|
return getTextCB(aText, aOffset, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar*
|
static gchar* getTextAfterOffsetCB(AtkText* aText, gint aOffset,
|
||||||
getTextAfterOffsetCB(AtkText *aText, gint aOffset,
|
AtkTextBoundary aBoundaryType,
|
||||||
AtkTextBoundary aBoundaryType,
|
gint* aStartOffset, gint* aEndOffset) {
|
||||||
gint *aStartOffset, gint *aEndOffset)
|
|
||||||
{
|
|
||||||
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
|
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
|
||||||
return getCharTextAtOffset(aText, aOffset + 1, aStartOffset, aEndOffset);
|
return getCharTextAtOffset(aText, aOffset + 1, aStartOffset, aEndOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
int32_t startOffset = 0, endOffset = 0;
|
int32_t startOffset = 0, endOffset = 0;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
if (!text || !text->IsTextRole())
|
if (!text || !text->IsTextRole()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
text->TextAfterOffset(aOffset, aBoundaryType, &startOffset, &endOffset, autoStr);
|
text->TextAfterOffset(aOffset, aBoundaryType, &startOffset, &endOffset,
|
||||||
|
autoStr);
|
||||||
ConvertTexttoAsterisks(accWrap, autoStr);
|
ConvertTexttoAsterisks(accWrap, autoStr);
|
||||||
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||||
proxy->GetTextAfterOffset(aOffset, aBoundaryType, autoStr, &startOffset,
|
proxy->GetTextAfterOffset(aOffset, aBoundaryType, autoStr, &startOffset,
|
||||||
@@ -220,11 +207,9 @@ getTextAfterOffsetCB(AtkText *aText, gint aOffset,
|
|||||||
return DOMtoATK::Convert(autoStr);
|
return DOMtoATK::Convert(autoStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar*
|
static gchar* getTextAtOffsetCB(AtkText* aText, gint aOffset,
|
||||||
getTextAtOffsetCB(AtkText *aText, gint aOffset,
|
AtkTextBoundary aBoundaryType,
|
||||||
AtkTextBoundary aBoundaryType,
|
gint* aStartOffset, gint* aEndOffset) {
|
||||||
gint *aStartOffset, gint *aEndOffset)
|
|
||||||
{
|
|
||||||
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
|
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
|
||||||
return getCharTextAtOffset(aText, aOffset, aStartOffset, aEndOffset);
|
return getCharTextAtOffset(aText, aOffset, aStartOffset, aEndOffset);
|
||||||
}
|
}
|
||||||
@@ -234,10 +219,10 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
|
|||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
if (!text || !text->IsTextRole())
|
if (!text || !text->IsTextRole()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
text->TextAtOffset(aOffset, aBoundaryType, &startOffset, &endOffset, autoStr);
|
text->TextAtOffset(aOffset, aBoundaryType, &startOffset, &endOffset,
|
||||||
|
autoStr);
|
||||||
ConvertTexttoAsterisks(accWrap, autoStr);
|
ConvertTexttoAsterisks(accWrap, autoStr);
|
||||||
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||||
proxy->GetTextAtOffset(aOffset, aBoundaryType, autoStr, &startOffset,
|
proxy->GetTextAtOffset(aOffset, aBoundaryType, autoStr, &startOffset,
|
||||||
@@ -251,9 +236,7 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
|
|||||||
return DOMtoATK::Convert(autoStr);
|
return DOMtoATK::Convert(autoStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gunichar
|
static gunichar getCharacterAtOffsetCB(AtkText* aText, gint aOffset) {
|
||||||
getCharacterAtOffsetCB(AtkText* aText, gint aOffset)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -270,11 +253,9 @@ getCharacterAtOffsetCB(AtkText* aText, gint aOffset)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar*
|
static gchar* getTextBeforeOffsetCB(AtkText* aText, gint aOffset,
|
||||||
getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
|
AtkTextBoundary aBoundaryType,
|
||||||
AtkTextBoundary aBoundaryType,
|
gint* aStartOffset, gint* aEndOffset) {
|
||||||
gint *aStartOffset, gint *aEndOffset)
|
|
||||||
{
|
|
||||||
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
|
if (aBoundaryType == ATK_TEXT_BOUNDARY_CHAR) {
|
||||||
return getCharTextAtOffset(aText, aOffset - 1, aStartOffset, aEndOffset);
|
return getCharTextAtOffset(aText, aOffset - 1, aStartOffset, aEndOffset);
|
||||||
}
|
}
|
||||||
@@ -284,11 +265,10 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
|
|||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
if (!text || !text->IsTextRole())
|
if (!text || !text->IsTextRole()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
text->TextBeforeOffset(aOffset, aBoundaryType,
|
text->TextBeforeOffset(aOffset, aBoundaryType, &startOffset, &endOffset,
|
||||||
&startOffset, &endOffset, autoStr);
|
autoStr);
|
||||||
ConvertTexttoAsterisks(accWrap, autoStr);
|
ConvertTexttoAsterisks(accWrap, autoStr);
|
||||||
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||||
proxy->GetTextBeforeOffset(aOffset, aBoundaryType, autoStr, &startOffset,
|
proxy->GetTextBeforeOffset(aOffset, aBoundaryType, autoStr, &startOffset,
|
||||||
@@ -302,9 +282,7 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
|
|||||||
return DOMtoATK::Convert(autoStr);
|
return DOMtoATK::Convert(autoStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getCaretOffsetCB(AtkText* aText) {
|
||||||
getCaretOffsetCB(AtkText *aText)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -322,11 +300,9 @@ getCaretOffsetCB(AtkText *aText)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkAttributeSet*
|
static AtkAttributeSet* getRunAttributesCB(AtkText* aText, gint aOffset,
|
||||||
getRunAttributesCB(AtkText *aText, gint aOffset,
|
gint* aStartOffset,
|
||||||
gint *aStartOffset,
|
gint* aEndOffset) {
|
||||||
gint *aEndOffset)
|
|
||||||
{
|
|
||||||
*aStartOffset = -1;
|
*aStartOffset = -1;
|
||||||
*aEndOffset = -1;
|
*aEndOffset = -1;
|
||||||
int32_t startOffset = 0, endOffset = 0;
|
int32_t startOffset = 0, endOffset = 0;
|
||||||
@@ -339,7 +315,7 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPersistentProperties> attributes =
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
||||||
text->TextAttributes(false, aOffset, &startOffset, &endOffset);
|
text->TextAttributes(false, aOffset, &startOffset, &endOffset);
|
||||||
|
|
||||||
*aStartOffset = startOffset;
|
*aStartOffset = startOffset;
|
||||||
*aEndOffset = endOffset;
|
*aEndOffset = endOffset;
|
||||||
@@ -359,9 +335,7 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
|
|||||||
return ConvertToAtkTextAttributeSet(attrs);
|
return ConvertToAtkTextAttributeSet(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkAttributeSet*
|
static AtkAttributeSet* getDefaultAttributesCB(AtkText* aText) {
|
||||||
getDefaultAttributesCB(AtkText *aText)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -369,7 +343,8 @@ getDefaultAttributesCB(AtkText *aText)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPersistentProperties> attributes = text->DefaultTextAttributes();
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
||||||
|
text->DefaultTextAttributes();
|
||||||
return ConvertToAtkTextAttributeSet(attributes);
|
return ConvertToAtkTextAttributeSet(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,13 +358,10 @@ getDefaultAttributesCB(AtkText *aText)
|
|||||||
return ConvertToAtkTextAttributeSet(attrs);
|
return ConvertToAtkTextAttributeSet(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void getCharacterExtentsCB(AtkText* aText, gint aOffset, gint* aX,
|
||||||
getCharacterExtentsCB(AtkText *aText, gint aOffset,
|
gint* aY, gint* aWidth, gint* aHeight,
|
||||||
gint *aX, gint *aY,
|
AtkCoordType aCoords) {
|
||||||
gint *aWidth, gint *aHeight,
|
if (!aX || !aY || !aWidth || !aHeight) {
|
||||||
AtkCoordType aCoords)
|
|
||||||
{
|
|
||||||
if(!aX || !aY || !aWidth || !aHeight) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,10 +393,9 @@ getCharacterExtentsCB(AtkText *aText, gint aOffset,
|
|||||||
*aHeight = rect.height;
|
*aHeight = rect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void getRangeExtentsCB(AtkText* aText, gint aStartOffset,
|
||||||
getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
|
gint aEndOffset, AtkCoordType aCoords,
|
||||||
AtkCoordType aCoords, AtkTextRectangle *aRect)
|
AtkTextRectangle* aRect) {
|
||||||
{
|
|
||||||
if (!aRect) {
|
if (!aRect) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -438,7 +409,7 @@ getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if(accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
if (!text || !text->IsTextRole()) {
|
if (!text || !text->IsTextRole()) {
|
||||||
return;
|
return;
|
||||||
@@ -457,14 +428,13 @@ getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
|
|||||||
aRect->height = rect.height;
|
aRect->height = rect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getCharacterCountCB(AtkText* aText) {
|
||||||
getCharacterCountCB(AtkText *aText)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* textAcc = accWrap->AsHyperText();
|
HyperTextAccessible* textAcc = accWrap->AsHyperText();
|
||||||
return !textAcc || textAcc->IsDefunct() ?
|
return !textAcc || textAcc->IsDefunct()
|
||||||
0 : static_cast<gint>(textAcc->CharacterCount());
|
? 0
|
||||||
|
: static_cast<gint>(textAcc->CharacterCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||||
@@ -474,11 +444,8 @@ getCharacterCountCB(AtkText *aText)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getOffsetAtPointCB(AtkText* aText, gint aX, gint aY,
|
||||||
getOffsetAtPointCB(AtkText *aText,
|
AtkCoordType aCoords) {
|
||||||
gint aX, gint aY,
|
|
||||||
AtkCoordType aCoords)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -486,27 +453,25 @@ getOffsetAtPointCB(AtkText *aText,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<gint>(
|
return static_cast<gint>(text->OffsetAtPoint(
|
||||||
text->OffsetAtPoint(aX, aY,
|
aX, aY,
|
||||||
(aCoords == ATK_XY_SCREEN ?
|
(aCoords == ATK_XY_SCREEN
|
||||||
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
|
? nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE
|
||||||
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
|
: nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||||
return static_cast<gint>(
|
return static_cast<gint>(proxy->OffsetAtPoint(
|
||||||
proxy->OffsetAtPoint(aX, aY,
|
aX, aY,
|
||||||
(aCoords == ATK_XY_SCREEN ?
|
(aCoords == ATK_XY_SCREEN
|
||||||
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
|
? nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE
|
||||||
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
|
: nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint getTextSelectionCountCB(AtkText* aText) {
|
||||||
getTextSelectionCountCB(AtkText *aText)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -524,10 +489,8 @@ getTextSelectionCountCB(AtkText *aText)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar*
|
static gchar* getTextSelectionCB(AtkText* aText, gint aSelectionNum,
|
||||||
getTextSelectionCB(AtkText *aText, gint aSelectionNum,
|
gint* aStartOffset, gint* aEndOffset) {
|
||||||
gint *aStartOffset, gint *aEndOffset)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
int32_t startOffset = 0, endOffset = 0;
|
int32_t startOffset = 0, endOffset = 0;
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
@@ -555,11 +518,8 @@ getTextSelectionCB(AtkText *aText, gint aSelectionNum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set methods
|
// set methods
|
||||||
static gboolean
|
static gboolean addTextSelectionCB(AtkText* aText, gint aStartOffset,
|
||||||
addTextSelectionCB(AtkText *aText,
|
gint aEndOffset) {
|
||||||
gint aStartOffset,
|
|
||||||
gint aEndOffset)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -576,10 +536,7 @@ addTextSelectionCB(AtkText *aText,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean removeTextSelectionCB(AtkText* aText, gint aSelectionNum) {
|
||||||
removeTextSelectionCB(AtkText *aText,
|
|
||||||
gint aSelectionNum)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -596,10 +553,8 @@ removeTextSelectionCB(AtkText *aText,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean setTextSelectionCB(AtkText* aText, gint aSelectionNum,
|
||||||
setTextSelectionCB(AtkText *aText, gint aSelectionNum,
|
gint aStartOffset, gint aEndOffset) {
|
||||||
gint aStartOffset, gint aEndOffset)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -616,9 +571,7 @@ setTextSelectionCB(AtkText *aText, gint aSelectionNum,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean setCaretOffsetCB(AtkText* aText, gint aOffset) {
|
||||||
setCaretOffsetCB(AtkText *aText, gint aOffset)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||||
if (accWrap) {
|
if (accWrap) {
|
||||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
@@ -639,12 +592,9 @@ setCaretOffsetCB(AtkText *aText, gint aOffset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void textInterfaceInitCB(AtkTextIface* aIface) {
|
||||||
textInterfaceInitCB(AtkTextIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "Invalid aIface");
|
NS_ASSERTION(aIface, "Invalid aIface");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->get_text = getTextCB;
|
aIface->get_text = getTextCB;
|
||||||
aIface->get_text_after_offset = getTextAfterOffsetCB;
|
aIface->get_text_after_offset = getTextAfterOffsetCB;
|
||||||
@@ -661,7 +611,7 @@ textInterfaceInitCB(AtkTextIface* aIface)
|
|||||||
aIface->get_n_selections = getTextSelectionCountCB;
|
aIface->get_n_selections = getTextSelectionCountCB;
|
||||||
aIface->get_selection = getTextSelectionCB;
|
aIface->get_selection = getTextSelectionCB;
|
||||||
|
|
||||||
// set methods
|
// set methods
|
||||||
aIface->add_selection = addTextSelectionCB;
|
aIface->add_selection = addTextSelectionCB;
|
||||||
aIface->remove_selection = removeTextSelectionCB;
|
aIface->remove_selection = removeTextSelectionCB;
|
||||||
aIface->set_selection = setTextSelectionCB;
|
aIface->set_selection = setTextSelectionCB;
|
||||||
@@ -670,5 +620,5 @@ textInterfaceInitCB(AtkTextIface* aIface)
|
|||||||
// Cache the string values of the atk text attribute names.
|
// Cache the string values of the atk text attribute names.
|
||||||
for (uint32_t i = 0; i < ArrayLength(sAtkTextAttrNames); i++)
|
for (uint32_t i = 0; i < ArrayLength(sAtkTextAttrNames); i++)
|
||||||
sAtkTextAttrNames[i] =
|
sAtkTextAttrNames[i] =
|
||||||
atk_text_attribute_get_name(static_cast<AtkTextAttribute>(i));
|
atk_text_attribute_get_name(static_cast<AtkTextAttribute>(i));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ using namespace mozilla::a11y;
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static void
|
static void getCurrentValueCB(AtkValue* obj, GValue* value) {
|
||||||
getCurrentValueCB(AtkValue *obj, GValue *value)
|
|
||||||
{
|
|
||||||
ProxyAccessible* proxy = nullptr;
|
ProxyAccessible* proxy = nullptr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
||||||
if (!accWrap) {
|
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();
|
double accValue = accWrap ? accWrap->CurValue() : proxy->CurValue();
|
||||||
if (IsNaN(accValue))
|
if (IsNaN(accValue)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
g_value_init (value, G_TYPE_DOUBLE);
|
g_value_init(value, G_TYPE_DOUBLE);
|
||||||
g_value_set_double (value, accValue);
|
g_value_set_double(value, accValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void getMaximumValueCB(AtkValue* obj, GValue* value) {
|
||||||
getMaximumValueCB(AtkValue *obj, GValue *value)
|
|
||||||
{
|
|
||||||
ProxyAccessible* proxy = nullptr;
|
ProxyAccessible* proxy = nullptr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
||||||
if (!accWrap) {
|
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();
|
double accValue = accWrap ? accWrap->MaxValue() : proxy->MaxValue();
|
||||||
if (IsNaN(accValue))
|
if (IsNaN(accValue)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
g_value_init(value, G_TYPE_DOUBLE);
|
g_value_init(value, G_TYPE_DOUBLE);
|
||||||
g_value_set_double(value, accValue);
|
g_value_set_double(value, accValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void getMinimumValueCB(AtkValue* obj, GValue* value) {
|
||||||
getMinimumValueCB(AtkValue *obj, GValue *value)
|
|
||||||
{
|
|
||||||
ProxyAccessible* proxy = nullptr;
|
ProxyAccessible* proxy = nullptr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
||||||
if (!accWrap) {
|
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();
|
double accValue = accWrap ? accWrap->MinValue() : proxy->MinValue();
|
||||||
if (IsNaN(accValue))
|
if (IsNaN(accValue)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
g_value_init(value, G_TYPE_DOUBLE);
|
g_value_init(value, G_TYPE_DOUBLE);
|
||||||
g_value_set_double(value, accValue);
|
g_value_set_double(value, accValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void getMinimumIncrementCB(AtkValue* obj, GValue* minimumIncrement) {
|
||||||
getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
|
|
||||||
{
|
|
||||||
ProxyAccessible* proxy = nullptr;
|
ProxyAccessible* proxy = nullptr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
||||||
if (!accWrap) {
|
if (!accWrap) {
|
||||||
@@ -92,18 +81,16 @@ getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(minimumIncrement, 0, sizeof (GValue));
|
memset(minimumIncrement, 0, sizeof(GValue));
|
||||||
double accValue = accWrap ? accWrap->Step() : proxy->Step();
|
double accValue = accWrap ? accWrap->Step() : proxy->Step();
|
||||||
if (IsNaN(accValue))
|
if (IsNaN(accValue))
|
||||||
accValue = 0; // zero if the minimum increment is undefined
|
accValue = 0; // zero if the minimum increment is undefined
|
||||||
|
|
||||||
g_value_init(minimumIncrement, G_TYPE_DOUBLE);
|
g_value_init(minimumIncrement, G_TYPE_DOUBLE);
|
||||||
g_value_set_double(minimumIncrement, accValue);
|
g_value_set_double(minimumIncrement, accValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean setCurrentValueCB(AtkValue* obj, const GValue* value) {
|
||||||
setCurrentValueCB(AtkValue *obj, const GValue *value)
|
|
||||||
{
|
|
||||||
ProxyAccessible* proxy = nullptr;
|
ProxyAccessible* proxy = nullptr;
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
||||||
if (!accWrap) {
|
if (!accWrap) {
|
||||||
@@ -113,17 +100,15 @@ setCurrentValueCB(AtkValue *obj, const GValue *value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double accValue =g_value_get_double(value);
|
double accValue = g_value_get_double(value);
|
||||||
return accWrap ? accWrap->SetCurValue(accValue) : proxy->SetCurValue(accValue);
|
return accWrap ? accWrap->SetCurValue(accValue)
|
||||||
|
: proxy->SetCurValue(accValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void valueInterfaceInitCB(AtkValueIface* aIface) {
|
||||||
valueInterfaceInitCB(AtkValueIface* aIface)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aIface, "Invalid aIface");
|
NS_ASSERTION(aIface, "Invalid aIface");
|
||||||
if (MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
aIface->get_current_value = getCurrentValueCB;
|
aIface->get_current_value = getCurrentValueCB;
|
||||||
aIface->get_maximum_value = getMaximumValueCB;
|
aIface->get_maximum_value = getMaximumValueCB;
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ The following ATK states are not supported:
|
|||||||
|
|
||||||
enum EStateMapEntryType {
|
enum EStateMapEntryType {
|
||||||
kMapDirectly,
|
kMapDirectly,
|
||||||
kMapOpposite, // For example, UNAVAILABLE is the opposite of ENABLED
|
kMapOpposite, // For example, UNAVAILABLE is the opposite of ENABLED
|
||||||
kNoStateChange, // Don't fire state change event
|
kNoStateChange, // Don't fire state change event
|
||||||
};
|
};
|
||||||
|
|
||||||
const AtkStateType kNone = ATK_STATE_INVALID;
|
const AtkStateType kNone = ATK_STATE_INVALID;
|
||||||
@@ -52,10 +52,12 @@ struct AtkStateMap {
|
|||||||
EStateMapEntryType stateMapEntryType;
|
EStateMapEntryType stateMapEntryType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Map array from cross platform states to ATK states
|
// Map array from cross platform states to ATK states
|
||||||
static const AtkStateMap gAtkStateMap[] = { // Cross Platform States
|
static const AtkStateMap
|
||||||
// clang-format off
|
gAtkStateMap[] =
|
||||||
|
{
|
||||||
|
// Cross Platform States
|
||||||
|
// clang-format off
|
||||||
{ kNone, kMapOpposite }, // states::UNAVAILABLE = 1 << 0
|
{ kNone, kMapOpposite }, // states::UNAVAILABLE = 1 << 0
|
||||||
{ ATK_STATE_SELECTED, kMapDirectly }, // states::SELECTED = 1 << 1
|
{ ATK_STATE_SELECTED, kMapDirectly }, // states::SELECTED = 1 << 1
|
||||||
{ ATK_STATE_FOCUSED, kMapDirectly }, // states::FOCUSED = 1 << 2
|
{ ATK_STATE_FOCUSED, kMapDirectly }, // states::FOCUSED = 1 << 2
|
||||||
@@ -105,10 +107,11 @@ static const AtkStateMap gAtkStateMap[] = { // Cross Platfor
|
|||||||
{ ATK_STATE_EXPANDABLE, kMapDirectly }, // states::EXPANDABLE = 1 << 46
|
{ ATK_STATE_EXPANDABLE, kMapDirectly }, // states::EXPANDABLE = 1 << 46
|
||||||
{ kNone, kMapDirectly }, // states::PINNED = 1 << 47
|
{ kNone, kMapDirectly }, // states::PINNED = 1 << 47
|
||||||
{ ATK_STATE_ACTIVE, kMapDirectly } // states::CURRENT = 1 << 48
|
{ ATK_STATE_ACTIVE, kMapDirectly } // states::CURRENT = 1 << 48
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
||||||
static const auto gAtkStateMapLen = std::extent<decltype(gAtkStateMap)>::value;
|
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");
|
"ATK states map is out of sync with internal states");
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ static const uint32_t kGenericAccType = 0;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This list of WAI-defined roles are currently hardcoded.
|
* This list of WAI-defined roles are currently hardcoded.
|
||||||
* Eventually we will most likely be loading an RDF resource that contains this information
|
* Eventually we will most likely be loading an RDF resource that contains this
|
||||||
* Using RDF will also allow for role extensibility. See bug 280138.
|
* information Using RDF will also allow for role extensibility. See bug 280138.
|
||||||
*
|
*
|
||||||
* Definition of nsRoleMapEntry contains comments explaining this table.
|
* Definition of nsRoleMapEntry contains comments explaining this table.
|
||||||
*
|
*
|
||||||
@@ -35,9 +35,8 @@ static const uint32_t kGenericAccType = 0;
|
|||||||
* via the object attribute "xml-roles".
|
* via the object attribute "xml-roles".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const nsRoleMapEntry sWAIRoleMaps[] =
|
static const nsRoleMapEntry sWAIRoleMaps[] = {
|
||||||
{
|
// clang-format off
|
||||||
// clang-format off
|
|
||||||
{ // alert
|
{ // alert
|
||||||
nsGkAtoms::alert,
|
nsGkAtoms::alert,
|
||||||
roles::ALERT,
|
roles::ALERT,
|
||||||
@@ -1241,30 +1240,16 @@ static const nsRoleMapEntry sWAIRoleMaps[] =
|
|||||||
eARIASelectable,
|
eARIASelectable,
|
||||||
eARIACheckedMixed
|
eARIACheckedMixed
|
||||||
}
|
}
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
||||||
static const nsRoleMapEntry sLandmarkRoleMap = {
|
static const nsRoleMapEntry sLandmarkRoleMap = {
|
||||||
nsGkAtoms::_empty,
|
nsGkAtoms::_empty, roles::NOTHING, kUseNativeRole, eNoValue,
|
||||||
roles::NOTHING,
|
eNoAction, eNoLiveAttr, kGenericAccType, kNoReqStates};
|
||||||
kUseNativeRole,
|
|
||||||
eNoValue,
|
|
||||||
eNoAction,
|
|
||||||
eNoLiveAttr,
|
|
||||||
kGenericAccType,
|
|
||||||
kNoReqStates
|
|
||||||
};
|
|
||||||
|
|
||||||
nsRoleMapEntry aria::gEmptyRoleMap = {
|
nsRoleMapEntry aria::gEmptyRoleMap = {
|
||||||
nsGkAtoms::_empty,
|
nsGkAtoms::_empty, roles::NOTHING, kUseMapRole, eNoValue,
|
||||||
roles::NOTHING,
|
eNoAction, eNoLiveAttr, kGenericAccType, kNoReqStates};
|
||||||
kUseMapRole,
|
|
||||||
eNoValue,
|
|
||||||
eNoAction,
|
|
||||||
eNoLiveAttr,
|
|
||||||
kGenericAccType,
|
|
||||||
kNoReqStates
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Universal (Global) states:
|
* Universal (Global) states:
|
||||||
@@ -1272,31 +1257,25 @@ nsRoleMapEntry aria::gEmptyRoleMap = {
|
|||||||
* whether there is an ARIA role or not:
|
* whether there is an ARIA role or not:
|
||||||
*/
|
*/
|
||||||
static const EStateRule sWAIUnivStateMap[] = {
|
static const EStateRule sWAIUnivStateMap[] = {
|
||||||
eARIABusy,
|
eARIABusy, eARIACurrent, eARIADisabled,
|
||||||
eARIACurrent,
|
eARIAExpanded, // Currently under spec review but precedent exists
|
||||||
eARIADisabled,
|
eARIAHasPopup, // Note this is a tokenised attribute starting in ARIA 1.1
|
||||||
eARIAExpanded, // Currently under spec review but precedent exists
|
eARIAInvalid, eARIAModal,
|
||||||
eARIAHasPopup, // Note this is a tokenised attribute starting in ARIA 1.1
|
eARIARequired, // XXX not global, Bug 553117
|
||||||
eARIAInvalid,
|
eARIANone};
|
||||||
eARIAModal,
|
|
||||||
eARIARequired, // XXX not global, Bug 553117
|
|
||||||
eARIANone
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ARIA attribute map for attribute characteristics.
|
* ARIA attribute map for attribute characteristics.
|
||||||
* @note ARIA attributes that don't have any flags are not included here.
|
* @note ARIA attributes that don't have any flags are not included here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct AttrCharacteristics
|
struct AttrCharacteristics {
|
||||||
{
|
|
||||||
const nsStaticAtom* const attributeName;
|
const nsStaticAtom* const attributeName;
|
||||||
const uint8_t characteristics;
|
const uint8_t characteristics;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const AttrCharacteristics gWAIUnivAttrMap[] = {
|
static const AttrCharacteristics gWAIUnivAttrMap[] = {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
{nsGkAtoms::aria_activedescendant, ATTR_BYPASSOBJ },
|
{nsGkAtoms::aria_activedescendant, ATTR_BYPASSOBJ },
|
||||||
{nsGkAtoms::aria_atomic, ATTR_BYPASSOBJ_IF_FALSE | ATTR_VALTOKEN | ATTR_GLOBAL },
|
{nsGkAtoms::aria_atomic, ATTR_BYPASSOBJ_IF_FALSE | ATTR_VALTOKEN | ATTR_GLOBAL },
|
||||||
{nsGkAtoms::aria_busy, ATTR_VALTOKEN | ATTR_GLOBAL },
|
{nsGkAtoms::aria_busy, ATTR_VALTOKEN | ATTR_GLOBAL },
|
||||||
@@ -1335,13 +1314,12 @@ static const AttrCharacteristics gWAIUnivAttrMap[] = {
|
|||||||
{nsGkAtoms::aria_valuemin, ATTR_BYPASSOBJ },
|
{nsGkAtoms::aria_valuemin, ATTR_BYPASSOBJ },
|
||||||
{nsGkAtoms::aria_valuemax, ATTR_BYPASSOBJ },
|
{nsGkAtoms::aria_valuemax, ATTR_BYPASSOBJ },
|
||||||
{nsGkAtoms::aria_valuetext, ATTR_BYPASSOBJ }
|
{nsGkAtoms::aria_valuetext, ATTR_BYPASSOBJ }
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct RoleComparator
|
struct RoleComparator {
|
||||||
{
|
|
||||||
const nsDependentSubstring& mRole;
|
const nsDependentSubstring& mRole;
|
||||||
explicit RoleComparator(const nsDependentSubstring& aRole) : mRole(aRole) {}
|
explicit RoleComparator(const nsDependentSubstring& aRole) : mRole(aRole) {}
|
||||||
int operator()(const nsRoleMapEntry& aEntry) const {
|
int operator()(const nsRoleMapEntry& aEntry) const {
|
||||||
@@ -1349,17 +1327,13 @@ struct RoleComparator
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
const nsRoleMapEntry*
|
const nsRoleMapEntry* aria::GetRoleMap(dom::Element* aEl) {
|
||||||
aria::GetRoleMap(dom::Element* aEl)
|
|
||||||
{
|
|
||||||
return GetRoleMapFromIndex(GetRoleMapIndex(aEl));
|
return GetRoleMapFromIndex(GetRoleMapIndex(aEl));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t aria::GetRoleMapIndex(dom::Element* aEl) {
|
||||||
aria::GetRoleMapIndex(dom::Element* aEl)
|
|
||||||
{
|
|
||||||
nsAutoString roles;
|
nsAutoString roles;
|
||||||
if (!aEl || !aEl->GetAttr(kNameSpaceID_None, nsGkAtoms::role, roles) ||
|
if (!aEl || !aEl->GetAttr(kNameSpaceID_None, nsGkAtoms::role, roles) ||
|
||||||
roles.IsEmpty()) {
|
roles.IsEmpty()) {
|
||||||
@@ -1383,10 +1357,7 @@ aria::GetRoleMapIndex(dom::Element* aEl)
|
|||||||
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
|
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nsRoleMapEntry* aria::GetRoleMapFromIndex(uint8_t aRoleMapIndex) {
|
||||||
const nsRoleMapEntry*
|
|
||||||
aria::GetRoleMapFromIndex(uint8_t aRoleMapIndex)
|
|
||||||
{
|
|
||||||
switch (aRoleMapIndex) {
|
switch (aRoleMapIndex) {
|
||||||
case NO_ROLE_MAP_ENTRY_INDEX:
|
case NO_ROLE_MAP_ENTRY_INDEX:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -1399,34 +1370,27 @@ aria::GetRoleMapFromIndex(uint8_t aRoleMapIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t aria::GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMapEntry) {
|
||||||
aria::GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMapEntry)
|
|
||||||
{
|
|
||||||
if (aRoleMapEntry == nullptr) {
|
if (aRoleMapEntry == nullptr) {
|
||||||
return NO_ROLE_MAP_ENTRY_INDEX;
|
return NO_ROLE_MAP_ENTRY_INDEX;
|
||||||
} else if (aRoleMapEntry == &gEmptyRoleMap) {
|
} else if (aRoleMapEntry == &gEmptyRoleMap) {
|
||||||
return EMPTY_ROLE_MAP_ENTRY_INDEX;
|
return EMPTY_ROLE_MAP_ENTRY_INDEX;
|
||||||
} else if (aRoleMapEntry == &sLandmarkRoleMap) {
|
} else if (aRoleMapEntry == &sLandmarkRoleMap) {
|
||||||
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
|
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
|
||||||
} else {
|
} else {
|
||||||
return aRoleMapEntry - sWAIRoleMaps;
|
return aRoleMapEntry - sWAIRoleMaps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t aria::UniversalStatesFor(mozilla::dom::Element* aElement) {
|
||||||
aria::UniversalStatesFor(mozilla::dom::Element* aElement)
|
|
||||||
{
|
|
||||||
uint64_t state = 0;
|
uint64_t state = 0;
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
while (MapToState(sWAIUnivStateMap[index], aElement, &state))
|
while (MapToState(sWAIUnivStateMap[index], aElement, &state)) index++;
|
||||||
index++;
|
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t aria::AttrCharacteristicsFor(nsAtom* aAtom) {
|
||||||
aria::AttrCharacteristicsFor(nsAtom* aAtom)
|
|
||||||
{
|
|
||||||
for (uint32_t i = 0; i < ArrayLength(gWAIUnivAttrMap); i++)
|
for (uint32_t i = 0; i < ArrayLength(gWAIUnivAttrMap); i++)
|
||||||
if (gWAIUnivAttrMap[i].attributeName == aAtom)
|
if (gWAIUnivAttrMap[i].attributeName == aAtom)
|
||||||
return gWAIUnivAttrMap[i].characteristics;
|
return gWAIUnivAttrMap[i].characteristics;
|
||||||
@@ -1434,21 +1398,17 @@ aria::AttrCharacteristicsFor(nsAtom* aAtom)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool aria::HasDefinedARIAHidden(nsIContent* aContent) {
|
||||||
aria::HasDefinedARIAHidden(nsIContent* aContent)
|
|
||||||
{
|
|
||||||
return aContent && aContent->IsElement() &&
|
return aContent && aContent->IsElement() &&
|
||||||
aContent->AsElement()->AttrValueIs(kNameSpaceID_None,
|
aContent->AsElement()->AttrValueIs(kNameSpaceID_None,
|
||||||
nsGkAtoms::aria_hidden,
|
nsGkAtoms::aria_hidden,
|
||||||
nsGkAtoms::_true, eCaseMatters);
|
nsGkAtoms::_true, eCaseMatters);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AttrIterator class
|
// AttrIterator class
|
||||||
|
|
||||||
bool
|
bool AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue) {
|
||||||
AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
|
|
||||||
{
|
|
||||||
while (mAttrIdx < mAttrCount) {
|
while (mAttrIdx < mAttrCount) {
|
||||||
const nsAttrName* attr = mElement->GetAttrNameAt(mAttrIdx);
|
const nsAttrName* attr = mElement->GetAttrNameAt(mAttrIdx);
|
||||||
mAttrIdx++;
|
mAttrIdx++;
|
||||||
@@ -1456,20 +1416,20 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
|
|||||||
nsAtom* attrAtom = attr->Atom();
|
nsAtom* attrAtom = attr->Atom();
|
||||||
nsDependentAtomString attrStr(attrAtom);
|
nsDependentAtomString attrStr(attrAtom);
|
||||||
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
|
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
|
||||||
continue; // Not ARIA
|
continue; // Not ARIA
|
||||||
|
|
||||||
uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
|
uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
|
||||||
if (attrFlags & ATTR_BYPASSOBJ)
|
if (attrFlags & ATTR_BYPASSOBJ)
|
||||||
continue; // No need to handle exposing as obj attribute here
|
continue; // No need to handle exposing as obj attribute here
|
||||||
|
|
||||||
if ((attrFlags & ATTR_VALTOKEN) &&
|
if ((attrFlags & ATTR_VALTOKEN) &&
|
||||||
!nsAccUtils::HasDefinedARIAToken(mElement, attrAtom))
|
!nsAccUtils::HasDefinedARIAToken(mElement, attrAtom))
|
||||||
continue; // only expose token based attributes if they are defined
|
continue; // only expose token based attributes if they are defined
|
||||||
|
|
||||||
if ((attrFlags & ATTR_BYPASSOBJ_IF_FALSE) &&
|
if ((attrFlags & ATTR_BYPASSOBJ_IF_FALSE) &&
|
||||||
mElement->AttrValueIs(kNameSpaceID_None, attrAtom,
|
mElement->AttrValueIs(kNameSpaceID_None, attrAtom, nsGkAtoms::_false,
|
||||||
nsGkAtoms::_false, eCaseMatters)) {
|
eCaseMatters)) {
|
||||||
continue; // only expose token based attribute if value is not 'false'.
|
continue; // only expose token based attribute if value is not 'false'.
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
@@ -1477,7 +1437,7 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
|
|||||||
aAttrName.Assign(Substring(attrStr, 5));
|
aAttrName.Assign(Substring(attrStr, 5));
|
||||||
if (attrFlags & ATTR_VALTOKEN) {
|
if (attrFlags & ATTR_VALTOKEN) {
|
||||||
nsAtom* normalizedValue =
|
nsAtom* normalizedValue =
|
||||||
nsAccUtils::NormalizeARIAToken(mElement, attrAtom);
|
nsAccUtils::NormalizeARIAToken(mElement, attrAtom);
|
||||||
if (normalizedValue) {
|
if (normalizedValue) {
|
||||||
nsDependentAtomString normalizedValueStr(normalizedValue);
|
nsDependentAtomString normalizedValueStr(normalizedValue);
|
||||||
aAttrValue.Assign(normalizedValueStr);
|
aAttrValue.Assign(normalizedValueStr);
|
||||||
@@ -1492,4 +1452,3 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ class nsINode;
|
|||||||
/**
|
/**
|
||||||
* Used to define if role requires to expose Value interface.
|
* Used to define if role requires to expose Value interface.
|
||||||
*/
|
*/
|
||||||
enum EValueRule
|
enum EValueRule {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Value interface isn't exposed.
|
* Value interface isn't exposed.
|
||||||
*/
|
*/
|
||||||
@@ -46,15 +45,13 @@ enum EValueRule
|
|||||||
eHasValueMinMaxIfFocusable
|
eHasValueMinMaxIfFocusable
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Action constants
|
// Action constants
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to define if the role requires to expose action.
|
* Used to define if the role requires to expose action.
|
||||||
*/
|
*/
|
||||||
enum EActionRule
|
enum EActionRule {
|
||||||
{
|
|
||||||
eNoAction,
|
eNoAction,
|
||||||
eActivateAction,
|
eActivateAction,
|
||||||
eClickAction,
|
eClickAction,
|
||||||
@@ -68,20 +65,13 @@ enum EActionRule
|
|||||||
eSwitchAction
|
eSwitchAction
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Live region constants
|
// Live region constants
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to define if role exposes default value of aria-live attribute.
|
* Used to define if role exposes default value of aria-live attribute.
|
||||||
*/
|
*/
|
||||||
enum ELiveAttrRule
|
enum ELiveAttrRule { eNoLiveAttr, eOffLiveAttr, ePoliteLiveAttr };
|
||||||
{
|
|
||||||
eNoLiveAttr,
|
|
||||||
eOffLiveAttr,
|
|
||||||
ePoliteLiveAttr
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Role constants
|
// Role constants
|
||||||
@@ -96,7 +86,6 @@ const bool kUseMapRole = true;
|
|||||||
*/
|
*/
|
||||||
const bool kUseNativeRole = false;
|
const bool kUseNativeRole = false;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ARIA attribute characteristic masks
|
// ARIA attribute characteristic masks
|
||||||
|
|
||||||
@@ -110,8 +99,8 @@ const uint8_t ATTR_BYPASSOBJ = 0x1 << 0;
|
|||||||
const uint8_t ATTR_BYPASSOBJ_IF_FALSE = 0x1 << 1;
|
const uint8_t ATTR_BYPASSOBJ_IF_FALSE = 0x1 << 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This mask indicates the attribute is expected to have an NMTOKEN or bool value.
|
* This mask indicates the attribute is expected to have an NMTOKEN or bool
|
||||||
* (See for example usage in Accessible::Attributes())
|
* value. (See for example usage in Accessible::Attributes())
|
||||||
*/
|
*/
|
||||||
const uint8_t ATTR_VALTOKEN = 0x1 << 2;
|
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.
|
* For each ARIA role, this maps the nsIAccessible information.
|
||||||
*/
|
*/
|
||||||
struct nsRoleMapEntry
|
struct nsRoleMapEntry {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Return true if matches to the given ARIA role.
|
* Return true if matches to the given ARIA role.
|
||||||
*/
|
*/
|
||||||
bool Is(nsAtom* aARIARole) const
|
bool Is(nsAtom* aARIARole) const { return roleAtom == aARIARole; }
|
||||||
{ return roleAtom == aARIARole; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if ARIA role has the given accessible type.
|
* Return true if ARIA role has the given accessible type.
|
||||||
*/
|
*/
|
||||||
bool IsOfType(mozilla::a11y::AccGenericType aType) const
|
bool IsOfType(mozilla::a11y::AccGenericType aType) const {
|
||||||
{ return accTypes & aType; }
|
return accTypes & aType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return ARIA role.
|
* Return ARIA role.
|
||||||
*/
|
*/
|
||||||
const nsDependentAtomString ARIARoleString() const
|
const nsDependentAtomString ARIARoleString() const {
|
||||||
{ return nsDependentAtomString(roleAtom); }
|
return nsDependentAtomString(roleAtom);
|
||||||
|
}
|
||||||
|
|
||||||
// ARIA role: string representation such as "button"
|
// ARIA role: string representation such as "button"
|
||||||
nsStaticAtom* const roleAtom;
|
nsStaticAtom* const roleAtom;
|
||||||
@@ -179,7 +168,7 @@ struct nsRoleMapEntry
|
|||||||
uint32_t accTypes;
|
uint32_t accTypes;
|
||||||
|
|
||||||
// Automatic state mapping rule: always include in states
|
// Automatic state mapping rule: always include in states
|
||||||
uint64_t state; // or kNoReqStates if no default state for this role
|
uint64_t state; // or kNoReqStates if no default state for this role
|
||||||
|
|
||||||
// ARIA properties supported for this role (in other words, the aria-foo
|
// ARIA properties supported for this role (in other words, the aria-foo
|
||||||
// attribute to accessible states mapping rules).
|
// attribute to accessible states mapping rules).
|
||||||
@@ -192,7 +181,6 @@ struct nsRoleMapEntry
|
|||||||
mozilla::a11y::aria::EStateRule attributeMap4;
|
mozilla::a11y::aria::EStateRule attributeMap4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ARIA map
|
// ARIA map
|
||||||
|
|
||||||
@@ -282,34 +270,31 @@ uint8_t AttrCharacteristicsFor(nsAtom* aAtom);
|
|||||||
*/
|
*/
|
||||||
bool HasDefinedARIAHidden(nsIContent* aContent);
|
bool HasDefinedARIAHidden(nsIContent* aContent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a simple enumerator for iterating through ARIA attributes
|
* Represents a simple enumerator for iterating through ARIA attributes
|
||||||
* exposed as object attributes on a given accessible.
|
* exposed as object attributes on a given accessible.
|
||||||
*/
|
*/
|
||||||
class AttrIterator
|
class AttrIterator {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit AttrIterator(nsIContent* aContent)
|
explicit AttrIterator(nsIContent* aContent)
|
||||||
: mElement(Element::FromNode(aContent))
|
: mElement(Element::FromNode(aContent)), mAttrIdx(0) {
|
||||||
, mAttrIdx(0)
|
|
||||||
{
|
|
||||||
mAttrCount = mElement ? mElement->GetAttrCount() : 0;
|
mAttrCount = mElement ? mElement->GetAttrCount() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Next(nsAString& aAttrName, nsAString& aAttrValue);
|
bool Next(nsAString& aAttrName, nsAString& aAttrValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AttrIterator() = delete;
|
AttrIterator() = delete;
|
||||||
AttrIterator(const AttrIterator&) = delete;
|
AttrIterator(const AttrIterator&) = delete;
|
||||||
AttrIterator& operator= (const AttrIterator&) = delete;
|
AttrIterator& operator=(const AttrIterator&) = delete;
|
||||||
|
|
||||||
dom::Element* mElement;
|
dom::Element* mElement;
|
||||||
uint32_t mAttrIdx;
|
uint32_t mAttrIdx;
|
||||||
uint32_t mAttrCount;
|
uint32_t mAttrCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria
|
} // namespace aria
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ using namespace mozilla::a11y::aria;
|
|||||||
/**
|
/**
|
||||||
* Used to store state map rule data for ARIA attribute of enum type.
|
* Used to store state map rule data for ARIA attribute of enum type.
|
||||||
*/
|
*/
|
||||||
struct EnumTypeData
|
struct EnumTypeData {
|
||||||
{
|
|
||||||
// ARIA attribute name.
|
// ARIA attribute name.
|
||||||
nsStaticAtom* const mAttrName;
|
nsStaticAtom* const mAttrName;
|
||||||
|
|
||||||
@@ -33,26 +32,24 @@ struct EnumTypeData
|
|||||||
const uint64_t mClearState;
|
const uint64_t mClearState;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ETokenType
|
enum ETokenType {
|
||||||
{
|
|
||||||
eBoolType = 0,
|
eBoolType = 0,
|
||||||
eMixedType = 1, // can take 'mixed' value
|
eMixedType = 1, // can take 'mixed' value
|
||||||
eDefinedIfAbsent = 2 // permanent and false state are applied if absent
|
eDefinedIfAbsent = 2 // permanent and false state are applied if absent
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to store state map rule data for ARIA attribute of token type (including
|
* Used to store state map rule data for ARIA attribute of token type (including
|
||||||
* mixed value).
|
* mixed value).
|
||||||
*/
|
*/
|
||||||
struct TokenTypeData
|
struct TokenTypeData {
|
||||||
{
|
TokenTypeData(nsAtom* aAttrName, uint32_t aType, uint64_t aPermanentState,
|
||||||
TokenTypeData(nsAtom* aAttrName, uint32_t aType,
|
uint64_t aTrueState, uint64_t aFalseState = 0)
|
||||||
uint64_t aPermanentState,
|
: mAttrName(aAttrName),
|
||||||
uint64_t aTrueState,
|
mType(aType),
|
||||||
uint64_t aFalseState = 0) :
|
mPermanentState(aPermanentState),
|
||||||
mAttrName(aAttrName), mType(aType), mPermanentState(aPermanentState),
|
mTrueState(aTrueState),
|
||||||
mTrueState(aTrueState), mFalseState(aFalseState)
|
mFalseState(aFalseState) {}
|
||||||
{ }
|
|
||||||
|
|
||||||
// ARIA attribute name.
|
// ARIA attribute name.
|
||||||
nsAtom* const mAttrName;
|
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,
|
static void MapTokenType(dom::Element* aContent, uint64_t* aState,
|
||||||
const TokenTypeData& aData);
|
const TokenTypeData& aData);
|
||||||
|
|
||||||
bool
|
bool aria::MapToState(EStateRule aRule, dom::Element* aElement,
|
||||||
aria::MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState)
|
uint64_t* aState) {
|
||||||
{
|
|
||||||
switch (aRule) {
|
switch (aRule) {
|
||||||
case eARIAAutoComplete:
|
case eARIAAutoComplete: {
|
||||||
{
|
|
||||||
static const EnumTypeData data = {
|
static const EnumTypeData data = {
|
||||||
nsGkAtoms::aria_autocomplete,
|
nsGkAtoms::aria_autocomplete,
|
||||||
{ nsGkAtoms::inlinevalue,
|
{nsGkAtoms::inlinevalue, nsGkAtoms::list_, nsGkAtoms::both, nullptr},
|
||||||
nsGkAtoms::list_,
|
{states::SUPPORTS_AUTOCOMPLETION,
|
||||||
nsGkAtoms::both, nullptr },
|
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION,
|
||||||
{ states::SUPPORTS_AUTOCOMPLETION,
|
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION},
|
||||||
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION,
|
0};
|
||||||
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION }, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
MapEnumType(aElement, aState, data);
|
MapEnumType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIABusy:
|
case eARIABusy: {
|
||||||
{
|
|
||||||
static const EnumTypeData data = {
|
static const EnumTypeData data = {
|
||||||
nsGkAtoms::aria_busy,
|
nsGkAtoms::aria_busy,
|
||||||
{ nsGkAtoms::_true,
|
{nsGkAtoms::_true, nsGkAtoms::error, nullptr},
|
||||||
nsGkAtoms::error, nullptr },
|
{states::BUSY, states::INVALID},
|
||||||
{ states::BUSY,
|
0};
|
||||||
states::INVALID }, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
MapEnumType(aElement, aState, data);
|
MapEnumType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIACheckableBool:
|
case eARIACheckableBool: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_checked,
|
||||||
static const TokenTypeData data(
|
eBoolType | eDefinedIfAbsent,
|
||||||
nsGkAtoms::aria_checked, eBoolType | eDefinedIfAbsent,
|
states::CHECKABLE, states::CHECKED);
|
||||||
states::CHECKABLE, states::CHECKED);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIACheckableMixed:
|
case eARIACheckableMixed: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_checked,
|
||||||
static const TokenTypeData data(
|
eMixedType | eDefinedIfAbsent,
|
||||||
nsGkAtoms::aria_checked, eMixedType | eDefinedIfAbsent,
|
states::CHECKABLE, states::CHECKED);
|
||||||
states::CHECKABLE, states::CHECKED);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIACheckedMixed:
|
case eARIACheckedMixed: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_checked, eMixedType,
|
||||||
static const TokenTypeData data(
|
states::CHECKABLE, states::CHECKED);
|
||||||
nsGkAtoms::aria_checked, eMixedType,
|
|
||||||
states::CHECKABLE, states::CHECKED);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIACurrent:
|
case eARIACurrent: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_current, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::CURRENT);
|
||||||
nsGkAtoms::aria_current, eBoolType,
|
|
||||||
0, states::CURRENT);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIADisabled:
|
case eARIADisabled: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_disabled, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::UNAVAILABLE);
|
||||||
nsGkAtoms::aria_disabled, eBoolType,
|
|
||||||
0, states::UNAVAILABLE);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAExpanded:
|
case eARIAExpanded: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_expanded, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::EXPANDED, states::COLLAPSED);
|
||||||
nsGkAtoms::aria_expanded, eBoolType,
|
|
||||||
0, states::EXPANDED, states::COLLAPSED);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAHasPopup:
|
case eARIAHasPopup: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_haspopup, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::HASPOPUP);
|
||||||
nsGkAtoms::aria_haspopup, eBoolType,
|
|
||||||
0, states::HASPOPUP);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAInvalid:
|
case eARIAInvalid: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_invalid, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::INVALID);
|
||||||
nsGkAtoms::aria_invalid, eBoolType,
|
|
||||||
0, states::INVALID);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAModal:
|
case eARIAModal: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_modal, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::MODAL);
|
||||||
nsGkAtoms::aria_modal, eBoolType,
|
|
||||||
0, states::MODAL);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAMultiline:
|
case eARIAMultiline: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_multiline,
|
||||||
static const TokenTypeData data(
|
eBoolType | eDefinedIfAbsent, 0,
|
||||||
nsGkAtoms::aria_multiline, eBoolType | eDefinedIfAbsent,
|
states::MULTI_LINE, states::SINGLE_LINE);
|
||||||
0, states::MULTI_LINE, states::SINGLE_LINE);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAMultiSelectable:
|
case eARIAMultiSelectable: {
|
||||||
{
|
|
||||||
static const TokenTypeData data(
|
static const TokenTypeData data(
|
||||||
nsGkAtoms::aria_multiselectable, eBoolType,
|
nsGkAtoms::aria_multiselectable, eBoolType, 0,
|
||||||
0, states::MULTISELECTABLE | states::EXTSELECTABLE);
|
states::MULTISELECTABLE | states::EXTSELECTABLE);
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAOrientation:
|
case eARIAOrientation: {
|
||||||
{
|
|
||||||
static const EnumTypeData data = {
|
static const EnumTypeData data = {
|
||||||
nsGkAtoms::aria_orientation,
|
nsGkAtoms::aria_orientation,
|
||||||
{ nsGkAtoms::horizontal,
|
{nsGkAtoms::horizontal, nsGkAtoms::vertical, nullptr},
|
||||||
nsGkAtoms::vertical, nullptr },
|
{states::HORIZONTAL, states::VERTICAL},
|
||||||
{ states::HORIZONTAL,
|
states::HORIZONTAL | states::VERTICAL};
|
||||||
states::VERTICAL },
|
|
||||||
states::HORIZONTAL | states::VERTICAL
|
|
||||||
};
|
|
||||||
|
|
||||||
MapEnumType(aElement, aState, data);
|
MapEnumType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAPressed:
|
case eARIAPressed: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_pressed, eMixedType, 0,
|
||||||
static const TokenTypeData data(
|
states::PRESSED);
|
||||||
nsGkAtoms::aria_pressed, eMixedType,
|
|
||||||
0, states::PRESSED);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAReadonly:
|
case eARIAReadonly: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_readonly, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::READONLY);
|
||||||
nsGkAtoms::aria_readonly, eBoolType,
|
|
||||||
0, states::READONLY);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAReadonlyOrEditable:
|
case eARIAReadonlyOrEditable: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_readonly,
|
||||||
static const TokenTypeData data(
|
eBoolType | eDefinedIfAbsent, 0,
|
||||||
nsGkAtoms::aria_readonly, eBoolType | eDefinedIfAbsent,
|
states::READONLY, states::EDITABLE);
|
||||||
0, states::READONLY, states::EDITABLE);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIAReadonlyOrEditableIfDefined:
|
case eARIAReadonlyOrEditableIfDefined: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_readonly, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::READONLY, states::EDITABLE);
|
||||||
nsGkAtoms::aria_readonly, eBoolType,
|
|
||||||
0, states::READONLY, states::EDITABLE);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIARequired:
|
case eARIARequired: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_required, eBoolType, 0,
|
||||||
static const TokenTypeData data(
|
states::REQUIRED);
|
||||||
nsGkAtoms::aria_required, eBoolType,
|
|
||||||
0, states::REQUIRED);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIASelectable:
|
case eARIASelectable: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_selected,
|
||||||
static const TokenTypeData data(
|
eBoolType | eDefinedIfAbsent,
|
||||||
nsGkAtoms::aria_selected, eBoolType | eDefinedIfAbsent,
|
states::SELECTABLE, states::SELECTED);
|
||||||
states::SELECTABLE, states::SELECTED);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eARIASelectableIfDefined:
|
case eARIASelectableIfDefined: {
|
||||||
{
|
static const TokenTypeData data(nsGkAtoms::aria_selected, eBoolType,
|
||||||
static const TokenTypeData data(
|
states::SELECTABLE, states::SELECTED);
|
||||||
nsGkAtoms::aria_selected, eBoolType,
|
|
||||||
states::SELECTABLE, states::SELECTED);
|
|
||||||
|
|
||||||
MapTokenType(aElement, aState, data);
|
MapTokenType(aElement, aState, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eReadonlyUntilEditable:
|
case eReadonlyUntilEditable: {
|
||||||
{
|
if (!(*aState & states::EDITABLE)) *aState |= states::READONLY;
|
||||||
if (!(*aState & states::EDITABLE))
|
|
||||||
*aState |= states::READONLY;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eIndeterminateIfNoValue:
|
case eIndeterminateIfNoValue: {
|
||||||
{
|
|
||||||
if (!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_valuenow) &&
|
if (!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_valuenow) &&
|
||||||
!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_valuetext))
|
!aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_valuetext))
|
||||||
*aState |= states::MIXED;
|
*aState |= states::MIXED;
|
||||||
@@ -327,9 +280,9 @@ aria::MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eFocusableUntilDisabled:
|
case eFocusableUntilDisabled: {
|
||||||
{
|
if (!nsAccUtils::HasDefinedARIAToken(aElement,
|
||||||
if (!nsAccUtils::HasDefinedARIAToken(aElement, nsGkAtoms::aria_disabled) ||
|
nsGkAtoms::aria_disabled) ||
|
||||||
aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_disabled,
|
aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_disabled,
|
||||||
nsGkAtoms::_false, eCaseMatters))
|
nsGkAtoms::_false, eCaseMatters))
|
||||||
*aState |= states::FOCUSABLE;
|
*aState |= states::FOCUSABLE;
|
||||||
@@ -342,9 +295,8 @@ aria::MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void MapEnumType(dom::Element* aElement, uint64_t* aState,
|
||||||
MapEnumType(dom::Element* aElement, uint64_t* aState, const EnumTypeData& aData)
|
const EnumTypeData& aData) {
|
||||||
{
|
|
||||||
switch (aElement->FindAttrValueIn(kNameSpaceID_None, aData.mAttrName,
|
switch (aElement->FindAttrValueIn(kNameSpaceID_None, aData.mAttrName,
|
||||||
aData.mValues, eCaseMatters)) {
|
aData.mValues, eCaseMatters)) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -359,16 +311,14 @@ MapEnumType(dom::Element* aElement, uint64_t* aState, const EnumTypeData& aData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void MapTokenType(dom::Element* aElement, uint64_t* aState,
|
||||||
MapTokenType(dom::Element* aElement, uint64_t* aState,
|
const TokenTypeData& aData) {
|
||||||
const TokenTypeData& aData)
|
|
||||||
{
|
|
||||||
if (nsAccUtils::HasDefinedARIAToken(aElement, aData.mAttrName)) {
|
if (nsAccUtils::HasDefinedARIAToken(aElement, aData.mAttrName)) {
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, aData.mAttrName,
|
if (aElement->AttrValueIs(kNameSpaceID_None, aData.mAttrName,
|
||||||
nsGkAtoms::mixed, eCaseMatters)) {
|
nsGkAtoms::mixed, eCaseMatters)) {
|
||||||
if (aData.mType & eMixedType)
|
if (aData.mType & eMixedType)
|
||||||
*aState |= aData.mPermanentState | states::MIXED;
|
*aState |= aData.mPermanentState | states::MIXED;
|
||||||
else // unsupported use of 'mixed' is an authoring error
|
else // unsupported use of 'mixed' is an authoring error
|
||||||
*aState |= aData.mPermanentState | aData.mFalseState;
|
*aState |= aData.mPermanentState | aData.mFalseState;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ namespace aria {
|
|||||||
/**
|
/**
|
||||||
* List of the ARIA state mapping rules.
|
* List of the ARIA state mapping rules.
|
||||||
*/
|
*/
|
||||||
enum EStateRule
|
enum EStateRule {
|
||||||
{
|
|
||||||
eARIANone,
|
eARIANone,
|
||||||
eARIAAutoComplete,
|
eARIAAutoComplete,
|
||||||
eARIABusy,
|
eARIABusy,
|
||||||
@@ -61,8 +60,8 @@ enum EStateRule
|
|||||||
*/
|
*/
|
||||||
bool MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState);
|
bool MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState);
|
||||||
|
|
||||||
} // namespace aria
|
} // namespace aria
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ using namespace mozilla;
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
static_assert(static_cast<bool>(eNoUserInput) == false &&
|
static_assert(static_cast<bool>(eNoUserInput) == false &&
|
||||||
static_cast<bool>(eFromUserInput) == true,
|
static_cast<bool>(eFromUserInput) == true,
|
||||||
"EIsFromUserInput cannot be casted to bool");
|
"EIsFromUserInput cannot be casted to bool");
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -30,9 +30,8 @@ static_assert(static_cast<bool>(eNoUserInput) == false &&
|
|||||||
// AccEvent constructors
|
// AccEvent constructors
|
||||||
|
|
||||||
AccEvent::AccEvent(uint32_t aEventType, Accessible* aAccessible,
|
AccEvent::AccEvent(uint32_t aEventType, Accessible* aAccessible,
|
||||||
EIsFromUserInput aIsFromUserInput, EEventRule aEventRule) :
|
EIsFromUserInput aIsFromUserInput, EEventRule aEventRule)
|
||||||
mEventType(aEventType), mEventRule(aEventRule), mAccessible(aAccessible)
|
: mEventType(aEventType), mEventRule(aEventRule), mAccessible(aAccessible) {
|
||||||
{
|
|
||||||
if (aIsFromUserInput == eAutoDetect)
|
if (aIsFromUserInput == eAutoDetect)
|
||||||
mIsFromUserInput = EventStateManager::IsHandlingUserInput();
|
mIsFromUserInput = EventStateManager::IsHandlingUserInput();
|
||||||
else
|
else
|
||||||
@@ -75,84 +74,78 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AccEvent, Release)
|
|||||||
// we are ready to fire the event and so we will no longer assert at that point
|
// 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
|
// 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.
|
// a defunct accessible so the behaviour should be equivalent.
|
||||||
AccTextChangeEvent::
|
AccTextChangeEvent::AccTextChangeEvent(Accessible* aAccessible, int32_t aStart,
|
||||||
AccTextChangeEvent(Accessible* aAccessible, int32_t aStart,
|
const nsAString& aModifiedText,
|
||||||
const nsAString& aModifiedText, bool aIsInserted,
|
bool aIsInserted,
|
||||||
EIsFromUserInput aIsFromUserInput)
|
EIsFromUserInput aIsFromUserInput)
|
||||||
: AccEvent(aIsInserted ?
|
: AccEvent(
|
||||||
static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_INSERTED) :
|
aIsInserted
|
||||||
static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_REMOVED),
|
? static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_INSERTED)
|
||||||
aAccessible, aIsFromUserInput, eAllowDupes)
|
: static_cast<uint32_t>(nsIAccessibleEvent::EVENT_TEXT_REMOVED),
|
||||||
, mStart(aStart)
|
aAccessible, aIsFromUserInput, eAllowDupes),
|
||||||
, mIsInserted(aIsInserted)
|
mStart(aStart),
|
||||||
, mModifiedText(aModifiedText)
|
mIsInserted(aIsInserted),
|
||||||
{
|
mModifiedText(aModifiedText) {
|
||||||
// XXX We should use IsFromUserInput here, but that isn't always correct
|
// XXX We should use IsFromUserInput here, but that isn't always correct
|
||||||
// when the text change isn't related to content insertion or removal.
|
// when the text change isn't related to content insertion or removal.
|
||||||
mIsFromUserInput = mAccessible->State() &
|
mIsFromUserInput =
|
||||||
(states::FOCUSED | states::EDITABLE);
|
mAccessible->State() & (states::FOCUSED | states::EDITABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AccHideEvent
|
// AccHideEvent
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AccHideEvent::
|
AccHideEvent::AccHideEvent(Accessible* aTarget, bool aNeedsShutdown)
|
||||||
AccHideEvent(Accessible* aTarget, bool aNeedsShutdown) :
|
: AccMutationEvent(::nsIAccessibleEvent::EVENT_HIDE, aTarget),
|
||||||
AccMutationEvent(::nsIAccessibleEvent::EVENT_HIDE, aTarget),
|
mNeedsShutdown(aNeedsShutdown) {
|
||||||
mNeedsShutdown(aNeedsShutdown)
|
|
||||||
{
|
|
||||||
mNextSibling = mAccessible->NextSibling();
|
mNextSibling = mAccessible->NextSibling();
|
||||||
mPrevSibling = mAccessible->PrevSibling();
|
mPrevSibling = mAccessible->PrevSibling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AccShowEvent
|
// AccShowEvent
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AccShowEvent::
|
AccShowEvent::AccShowEvent(Accessible* aTarget)
|
||||||
AccShowEvent(Accessible* aTarget) :
|
: AccMutationEvent(::nsIAccessibleEvent::EVENT_SHOW, aTarget) {
|
||||||
AccMutationEvent(::nsIAccessibleEvent::EVENT_SHOW, aTarget)
|
|
||||||
{
|
|
||||||
int32_t idx = aTarget->IndexInParent();
|
int32_t idx = aTarget->IndexInParent();
|
||||||
MOZ_ASSERT(idx >= 0);
|
MOZ_ASSERT(idx >= 0);
|
||||||
mInsertionIndex = idx;
|
mInsertionIndex = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AccTextSelChangeEvent
|
// AccTextSelChangeEvent
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AccTextSelChangeEvent::AccTextSelChangeEvent(HyperTextAccessible* aTarget,
|
AccTextSelChangeEvent::AccTextSelChangeEvent(HyperTextAccessible* aTarget,
|
||||||
dom::Selection* aSelection,
|
dom::Selection* aSelection,
|
||||||
int32_t aReason) :
|
int32_t aReason)
|
||||||
AccEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED, aTarget,
|
: AccEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED, aTarget,
|
||||||
eAutoDetect, eCoalesceTextSelChange),
|
eAutoDetect, eCoalesceTextSelChange),
|
||||||
mSel(aSelection), mReason(aReason) {}
|
mSel(aSelection),
|
||||||
|
mReason(aReason) {}
|
||||||
|
|
||||||
AccTextSelChangeEvent::~AccTextSelChangeEvent() { }
|
AccTextSelChangeEvent::~AccTextSelChangeEvent() {}
|
||||||
|
|
||||||
bool
|
bool AccTextSelChangeEvent::IsCaretMoveOnly() const {
|
||||||
AccTextSelChangeEvent::IsCaretMoveOnly() const
|
|
||||||
{
|
|
||||||
return mSel->RangeCount() == 1 && mSel->IsCollapsed() &&
|
return mSel->RangeCount() == 1 && mSel->IsCollapsed() &&
|
||||||
((mReason & (nsISelectionListener::COLLAPSETOSTART_REASON |
|
((mReason & (nsISelectionListener::COLLAPSETOSTART_REASON |
|
||||||
nsISelectionListener::COLLAPSETOEND_REASON)) == 0);
|
nsISelectionListener::COLLAPSETOEND_REASON)) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AccSelChangeEvent
|
// AccSelChangeEvent
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AccSelChangeEvent::
|
AccSelChangeEvent::AccSelChangeEvent(Accessible* aWidget, Accessible* aItem,
|
||||||
AccSelChangeEvent(Accessible* aWidget, Accessible* aItem,
|
SelChangeType aSelChangeType)
|
||||||
SelChangeType aSelChangeType) :
|
: AccEvent(0, aItem, eAutoDetect, eCoalesceSelectionChange),
|
||||||
AccEvent(0, aItem, eAutoDetect, eCoalesceSelectionChange),
|
mWidget(aWidget),
|
||||||
mWidget(aWidget), mItem(aItem), mSelChangeType(aSelChangeType),
|
mItem(aItem),
|
||||||
mPreceedingCount(0), mPackedEvent(nullptr)
|
mSelChangeType(aSelChangeType),
|
||||||
{
|
mPreceedingCount(0),
|
||||||
|
mPackedEvent(nullptr) {
|
||||||
if (aSelChangeType == eSelectionAdd) {
|
if (aSelChangeType == eSelectionAdd) {
|
||||||
if (mWidget->GetSelectedItem(1))
|
if (mWidget->GetSelectedItem(1))
|
||||||
mEventType = nsIAccessibleEvent::EVENT_SELECTION_ADD;
|
mEventType = nsIAccessibleEvent::EVENT_SELECTION_ADD;
|
||||||
@@ -163,44 +156,41 @@ AccSelChangeEvent::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AccTableChangeEvent
|
// AccTableChangeEvent
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AccTableChangeEvent::
|
AccTableChangeEvent::AccTableChangeEvent(Accessible* aAccessible,
|
||||||
AccTableChangeEvent(Accessible* aAccessible, uint32_t aEventType,
|
uint32_t aEventType,
|
||||||
int32_t aRowOrColIndex, int32_t aNumRowsOrCols) :
|
int32_t aRowOrColIndex,
|
||||||
AccEvent(aEventType, aAccessible),
|
int32_t aNumRowsOrCols)
|
||||||
mRowOrColIndex(aRowOrColIndex), mNumRowsOrCols(aNumRowsOrCols)
|
: AccEvent(aEventType, aAccessible),
|
||||||
{
|
mRowOrColIndex(aRowOrColIndex),
|
||||||
}
|
mNumRowsOrCols(aNumRowsOrCols) {}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AccVCChangeEvent
|
// AccVCChangeEvent
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AccVCChangeEvent::
|
AccVCChangeEvent::AccVCChangeEvent(Accessible* aAccessible,
|
||||||
AccVCChangeEvent(Accessible* aAccessible,
|
Accessible* aOldAccessible,
|
||||||
Accessible* aOldAccessible,
|
int32_t aOldStart, int32_t aOldEnd,
|
||||||
int32_t aOldStart, int32_t aOldEnd,
|
Accessible* aNewAccessible,
|
||||||
Accessible* aNewAccessible,
|
int32_t aNewStart, int32_t aNewEnd,
|
||||||
int32_t aNewStart, int32_t aNewEnd,
|
int16_t aReason, int16_t aBoundaryType,
|
||||||
int16_t aReason, int16_t aBoundaryType,
|
EIsFromUserInput aIsFromUserInput)
|
||||||
EIsFromUserInput aIsFromUserInput) :
|
: AccEvent(::nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED, aAccessible,
|
||||||
AccEvent(::nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED, aAccessible,
|
aIsFromUserInput),
|
||||||
aIsFromUserInput),
|
mOldAccessible(aOldAccessible),
|
||||||
mOldAccessible(aOldAccessible), mNewAccessible(aNewAccessible),
|
mNewAccessible(aNewAccessible),
|
||||||
mOldStart(aOldStart), mNewStart(aNewStart),
|
mOldStart(aOldStart),
|
||||||
mOldEnd(aOldEnd), mNewEnd(aNewEnd),
|
mNewStart(aNewStart),
|
||||||
mReason(aReason), mBoundaryType(aBoundaryType)
|
mOldEnd(aOldEnd),
|
||||||
{
|
mNewEnd(aNewEnd),
|
||||||
}
|
mReason(aReason),
|
||||||
|
mBoundaryType(aBoundaryType) {}
|
||||||
|
|
||||||
already_AddRefed<nsIAccessibleEvent>
|
already_AddRefed<nsIAccessibleEvent> a11y::MakeXPCEvent(AccEvent* aEvent) {
|
||||||
a11y::MakeXPCEvent(AccEvent* aEvent)
|
|
||||||
{
|
|
||||||
DocAccessible* doc = aEvent->Document();
|
DocAccessible* doc = aEvent->Document();
|
||||||
Accessible* acc = aEvent->GetAccessible();
|
Accessible* acc = aEvent->GetAccessible();
|
||||||
nsINode* node = acc->GetNode();
|
nsINode* node = acc->GetNode();
|
||||||
@@ -214,8 +204,8 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
|
|||||||
bool extra = false;
|
bool extra = false;
|
||||||
uint32_t state = nsAccUtils::To32States(sc->GetState(), &extra);
|
uint32_t state = nsAccUtils::To32States(sc->GetState(), &extra);
|
||||||
xpEvent = new xpcAccStateChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
|
xpEvent = new xpcAccStateChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
|
||||||
node, fromUser,
|
node, fromUser, state, extra,
|
||||||
state, extra, sc->IsStateEnabled());
|
sc->IsStateEnabled());
|
||||||
return xpEvent.forget();
|
return xpEvent.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,18 +213,16 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
|
|||||||
AccTextChangeEvent* tc = downcast_accEvent(aEvent);
|
AccTextChangeEvent* tc = downcast_accEvent(aEvent);
|
||||||
nsString text;
|
nsString text;
|
||||||
tc->GetModifiedText(text);
|
tc->GetModifiedText(text);
|
||||||
xpEvent = new xpcAccTextChangeEvent(type, ToXPC(acc), ToXPCDocument(doc),
|
xpEvent = new xpcAccTextChangeEvent(
|
||||||
node, fromUser,
|
type, ToXPC(acc), ToXPCDocument(doc), node, fromUser,
|
||||||
tc->GetStartOffset(), tc->GetLength(),
|
tc->GetStartOffset(), tc->GetLength(), tc->IsTextInserted(), text);
|
||||||
tc->IsTextInserted(), text);
|
|
||||||
return xpEvent.forget();
|
return xpEvent.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventGroup & (1 << AccEvent::eHideEvent)) {
|
if (eventGroup & (1 << AccEvent::eHideEvent)) {
|
||||||
AccHideEvent* hideEvent = downcast_accEvent(aEvent);
|
AccHideEvent* hideEvent = downcast_accEvent(aEvent);
|
||||||
xpEvent = new xpcAccHideEvent(type, ToXPC(acc), ToXPCDocument(doc),
|
xpEvent = new xpcAccHideEvent(type, ToXPC(acc), ToXPCDocument(doc), node,
|
||||||
node, fromUser,
|
fromUser, ToXPC(hideEvent->TargetParent()),
|
||||||
ToXPC(hideEvent->TargetParent()),
|
|
||||||
ToXPC(hideEvent->TargetNextSibling()),
|
ToXPC(hideEvent->TargetNextSibling()),
|
||||||
ToXPC(hideEvent->TargetPrevSibling()));
|
ToXPC(hideEvent->TargetPrevSibling()));
|
||||||
return xpEvent.forget();
|
return xpEvent.forget();
|
||||||
@@ -243,24 +231,17 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
|
|||||||
if (eventGroup & (1 << AccEvent::eCaretMoveEvent)) {
|
if (eventGroup & (1 << AccEvent::eCaretMoveEvent)) {
|
||||||
AccCaretMoveEvent* cm = downcast_accEvent(aEvent);
|
AccCaretMoveEvent* cm = downcast_accEvent(aEvent);
|
||||||
xpEvent = new xpcAccCaretMoveEvent(type, ToXPC(acc), ToXPCDocument(doc),
|
xpEvent = new xpcAccCaretMoveEvent(type, ToXPC(acc), ToXPCDocument(doc),
|
||||||
node, fromUser,
|
node, fromUser, cm->GetCaretOffset());
|
||||||
cm->GetCaretOffset());
|
|
||||||
return xpEvent.forget();
|
return xpEvent.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventGroup & (1 << AccEvent::eVirtualCursorChangeEvent)) {
|
if (eventGroup & (1 << AccEvent::eVirtualCursorChangeEvent)) {
|
||||||
AccVCChangeEvent* vcc = downcast_accEvent(aEvent);
|
AccVCChangeEvent* vcc = downcast_accEvent(aEvent);
|
||||||
xpEvent = new xpcAccVirtualCursorChangeEvent(type,
|
xpEvent = new xpcAccVirtualCursorChangeEvent(
|
||||||
ToXPC(acc), ToXPCDocument(doc),
|
type, ToXPC(acc), ToXPCDocument(doc), node, fromUser,
|
||||||
node, fromUser,
|
ToXPC(vcc->OldAccessible()), vcc->OldStartOffset(), vcc->OldEndOffset(),
|
||||||
ToXPC(vcc->OldAccessible()),
|
ToXPC(vcc->NewAccessible()), vcc->NewStartOffset(), vcc->NewEndOffset(),
|
||||||
vcc->OldStartOffset(),
|
vcc->Reason(), vcc->BoundaryType());
|
||||||
vcc->OldEndOffset(),
|
|
||||||
ToXPC(vcc->NewAccessible()),
|
|
||||||
vcc->NewStartOffset(),
|
|
||||||
vcc->NewEndOffset(),
|
|
||||||
vcc->Reason(),
|
|
||||||
vcc->BoundaryType());
|
|
||||||
return xpEvent.forget();
|
return xpEvent.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,21 +249,19 @@ a11y::MakeXPCEvent(AccEvent* aEvent)
|
|||||||
AccObjectAttrChangedEvent* oac = downcast_accEvent(aEvent);
|
AccObjectAttrChangedEvent* oac = downcast_accEvent(aEvent);
|
||||||
nsString attribute;
|
nsString attribute;
|
||||||
oac->GetAttribute()->ToString(attribute);
|
oac->GetAttribute()->ToString(attribute);
|
||||||
xpEvent = new xpcAccObjectAttributeChangedEvent(type,
|
xpEvent = new xpcAccObjectAttributeChangedEvent(
|
||||||
ToXPC(acc),
|
type, ToXPC(acc), ToXPCDocument(doc), node, fromUser, attribute);
|
||||||
ToXPCDocument(doc), node,
|
|
||||||
fromUser,
|
|
||||||
attribute);
|
|
||||||
return xpEvent.forget();
|
return xpEvent.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventGroup & (1 << AccEvent::eScrollingEvent)) {
|
if (eventGroup & (1 << AccEvent::eScrollingEvent)) {
|
||||||
AccScrollingEvent* sa = downcast_accEvent(aEvent);
|
AccScrollingEvent* sa = downcast_accEvent(aEvent);
|
||||||
xpEvent = new xpcAccScrollingEvent(type, ToXPC(acc), ToXPCDocument(doc), node,
|
xpEvent = new xpcAccScrollingEvent(
|
||||||
fromUser, sa->ScrollX(), sa->ScrollY(),
|
type, ToXPC(acc), ToXPCDocument(doc), node, fromUser, sa->ScrollX(),
|
||||||
sa->MaxScrollX(), sa->MaxScrollY());
|
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();
|
return xpEvent.forget();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ namespace a11y {
|
|||||||
class DocAccessible;
|
class DocAccessible;
|
||||||
|
|
||||||
// Constants used to point whether the event is from user input.
|
// Constants used to point whether the event is from user input.
|
||||||
enum EIsFromUserInput
|
enum EIsFromUserInput {
|
||||||
{
|
|
||||||
// eNoUserInput: event is not from user input
|
// eNoUserInput: event is not from user input
|
||||||
eNoUserInput = 0,
|
eNoUserInput = 0,
|
||||||
// eFromUserInput: event is from user input
|
// eFromUserInput: event is from user input
|
||||||
@@ -35,10 +34,8 @@ enum EIsFromUserInput
|
|||||||
/**
|
/**
|
||||||
* Generic accessible event.
|
* Generic accessible event.
|
||||||
*/
|
*/
|
||||||
class AccEvent
|
class AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
|
|
||||||
// Rule for accessible events.
|
// Rule for accessible events.
|
||||||
// The rule will be applied when flushing pending events.
|
// The rule will be applied when flushing pending events.
|
||||||
enum EEventRule {
|
enum EEventRule {
|
||||||
@@ -47,8 +44,8 @@ public:
|
|||||||
// don't support coalescence.
|
// don't support coalescence.
|
||||||
eAllowDupes,
|
eAllowDupes,
|
||||||
|
|
||||||
// eCoalesceReorder : For reorder events from the same subtree or the same
|
// eCoalesceReorder : For reorder events from the same subtree or the same
|
||||||
// node, only the umbrella event on the ancestor will be emitted.
|
// node, only the umbrella event on the ancestor will be emitted.
|
||||||
eCoalesceReorder,
|
eCoalesceReorder,
|
||||||
|
|
||||||
// eCoalesceOfSameType : For events of the same type, only the newest event
|
// eCoalesceOfSameType : For events of the same type, only the newest event
|
||||||
@@ -64,11 +61,11 @@ public:
|
|||||||
// eCoalesceTextSelChange: coalescence of text selection change events.
|
// eCoalesceTextSelChange: coalescence of text selection change events.
|
||||||
eCoalesceTextSelChange,
|
eCoalesceTextSelChange,
|
||||||
|
|
||||||
// eRemoveDupes : For repeat events, only the newest event in queue
|
// eRemoveDupes : For repeat events, only the newest event in queue
|
||||||
// will be emitted.
|
// will be emitted.
|
||||||
eRemoveDupes,
|
eRemoveDupes,
|
||||||
|
|
||||||
// eDoNotEmit : This event is confirmed as a duplicate, do not emit it.
|
// eDoNotEmit : This event is confirmed as a duplicate, do not emit it.
|
||||||
eDoNotEmit
|
eDoNotEmit
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -81,8 +78,9 @@ public:
|
|||||||
uint32_t GetEventType() const { return mEventType; }
|
uint32_t GetEventType() const { return mEventType; }
|
||||||
EEventRule GetEventRule() const { return mEventRule; }
|
EEventRule GetEventRule() const { return mEventRule; }
|
||||||
bool IsFromUserInput() const { return mIsFromUserInput; }
|
bool IsFromUserInput() const { return mIsFromUserInput; }
|
||||||
EIsFromUserInput FromUserInput() const
|
EIsFromUserInput FromUserInput() const {
|
||||||
{ return static_cast<EIsFromUserInput>(mIsFromUserInput); }
|
return static_cast<EIsFromUserInput>(mIsFromUserInput);
|
||||||
|
}
|
||||||
|
|
||||||
Accessible* GetAccessible() const { return mAccessible; }
|
Accessible* GetAccessible() const { return mAccessible; }
|
||||||
DocAccessible* Document() const { return mAccessible->Document(); }
|
DocAccessible* Document() const { return mAccessible->Document(); }
|
||||||
@@ -109,10 +107,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const EventGroup kEventGroup = eGenericEvent;
|
static const EventGroup kEventGroup = eGenericEvent;
|
||||||
virtual unsigned int GetEventGroups() const
|
virtual unsigned int GetEventGroups() const { return 1U << eGenericEvent; }
|
||||||
{
|
|
||||||
return 1U << eGenericEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference counting and cycle collection.
|
* Reference counting and cycle collection.
|
||||||
@@ -120,7 +115,7 @@ public:
|
|||||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AccEvent)
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AccEvent)
|
||||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(AccEvent)
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(AccEvent)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~AccEvent() {}
|
virtual ~AccEvent() {}
|
||||||
|
|
||||||
bool mIsFromUserInput;
|
bool mIsFromUserInput;
|
||||||
@@ -134,29 +129,28 @@ protected:
|
|||||||
friend class NotificationController;
|
friend class NotificationController;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible state change event.
|
* Accessible state change event.
|
||||||
*/
|
*/
|
||||||
class AccStateChangeEvent: public AccEvent
|
class AccStateChangeEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
AccStateChangeEvent(Accessible* aAccessible, uint64_t aState, bool aIsEnabled,
|
||||||
AccStateChangeEvent(Accessible* aAccessible, uint64_t aState,
|
EIsFromUserInput aIsFromUserInput = eAutoDetect)
|
||||||
bool aIsEnabled,
|
: AccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
|
||||||
EIsFromUserInput aIsFromUserInput = eAutoDetect) :
|
aIsFromUserInput, eCoalesceStateChange),
|
||||||
AccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
|
mState(aState),
|
||||||
aIsFromUserInput, eCoalesceStateChange),
|
mIsEnabled(aIsEnabled) {}
|
||||||
mState(aState), mIsEnabled(aIsEnabled) { }
|
|
||||||
|
|
||||||
AccStateChangeEvent(Accessible* aAccessible, uint64_t aState) :
|
AccStateChangeEvent(Accessible* aAccessible, uint64_t aState)
|
||||||
AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
|
: AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
|
||||||
eAutoDetect, eCoalesceStateChange), mState(aState)
|
eAutoDetect, eCoalesceStateChange),
|
||||||
{ mIsEnabled = (mAccessible->State() & mState) != 0; }
|
mState(aState) {
|
||||||
|
mIsEnabled = (mAccessible->State() & mState) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eStateChangeEvent;
|
static const EventGroup kEventGroup = eStateChangeEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eStateChangeEvent);
|
return AccEvent::GetEventGroups() | (1U << eStateChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,28 +158,25 @@ public:
|
|||||||
uint64_t GetState() const { return mState; }
|
uint64_t GetState() const { return mState; }
|
||||||
bool IsStateEnabled() const { return mIsEnabled; }
|
bool IsStateEnabled() const { return mIsEnabled; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t mState;
|
uint64_t mState;
|
||||||
bool mIsEnabled;
|
bool mIsEnabled;
|
||||||
|
|
||||||
friend class EventQueue;
|
friend class EventQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible text change event.
|
* Accessible text change event.
|
||||||
*/
|
*/
|
||||||
class AccTextChangeEvent: public AccEvent
|
class AccTextChangeEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AccTextChangeEvent(Accessible* aAccessible, int32_t aStart,
|
AccTextChangeEvent(Accessible* aAccessible, int32_t aStart,
|
||||||
const nsAString& aModifiedText, bool aIsInserted,
|
const nsAString& aModifiedText, bool aIsInserted,
|
||||||
EIsFromUserInput aIsFromUserInput = eAutoDetect);
|
EIsFromUserInput aIsFromUserInput = eAutoDetect);
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eTextChangeEvent;
|
static const EventGroup kEventGroup = eTextChangeEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eTextChangeEvent);
|
return AccEvent::GetEventGroups() | (1U << eTextChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,11 +184,12 @@ public:
|
|||||||
int32_t GetStartOffset() const { return mStart; }
|
int32_t GetStartOffset() const { return mStart; }
|
||||||
uint32_t GetLength() const { return mModifiedText.Length(); }
|
uint32_t GetLength() const { return mModifiedText.Length(); }
|
||||||
bool IsTextInserted() const { return mIsInserted; }
|
bool IsTextInserted() const { return mIsInserted; }
|
||||||
void GetModifiedText(nsAString& aModifiedText)
|
void GetModifiedText(nsAString& aModifiedText) {
|
||||||
{ aModifiedText = mModifiedText; }
|
aModifiedText = mModifiedText;
|
||||||
|
}
|
||||||
const nsString& ModifiedText() const { return mModifiedText; }
|
const nsString& ModifiedText() const { return mModifiedText; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t mStart;
|
int32_t mStart;
|
||||||
bool mIsInserted;
|
bool mIsInserted;
|
||||||
nsString mModifiedText;
|
nsString mModifiedText;
|
||||||
@@ -210,16 +202,15 @@ private:
|
|||||||
* A base class for events related to tree mutation, either an AccMutation
|
* A base class for events related to tree mutation, either an AccMutation
|
||||||
* event, or an AccReorderEvent.
|
* event, or an AccReorderEvent.
|
||||||
*/
|
*/
|
||||||
class AccTreeMutationEvent : public AccEvent
|
class AccTreeMutationEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
AccTreeMutationEvent(uint32_t aEventType, Accessible* aTarget)
|
||||||
AccTreeMutationEvent(uint32_t aEventType, Accessible* aTarget) :
|
: AccEvent(aEventType, aTarget, eAutoDetect, eCoalesceReorder),
|
||||||
AccEvent(aEventType, aTarget, eAutoDetect, eCoalesceReorder), mGeneration(0) {}
|
mGeneration(0) {}
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
static const EventGroup kEventGroup = eTreeMutationEvent;
|
static const EventGroup kEventGroup = eTreeMutationEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eTreeMutationEvent);
|
return AccEvent::GetEventGroups() | (1U << eTreeMutationEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +225,7 @@ public:
|
|||||||
uint32_t EventGeneration() const { return mGeneration; }
|
uint32_t EventGeneration() const { return mGeneration; }
|
||||||
void SetEventGeneration(uint32_t aGeneration) { mGeneration = aGeneration; }
|
void SetEventGeneration(uint32_t aGeneration) { mGeneration = aGeneration; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<AccTreeMutationEvent> mNextEvent;
|
RefPtr<AccTreeMutationEvent> mNextEvent;
|
||||||
RefPtr<AccTreeMutationEvent> mPrevEvent;
|
RefPtr<AccTreeMutationEvent> mPrevEvent;
|
||||||
uint32_t mGeneration;
|
uint32_t mGeneration;
|
||||||
@@ -243,22 +234,19 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Base class for show and hide accessible events.
|
* Base class for show and hide accessible events.
|
||||||
*/
|
*/
|
||||||
class AccMutationEvent: public AccTreeMutationEvent
|
class AccMutationEvent : public AccTreeMutationEvent {
|
||||||
{
|
public:
|
||||||
public:
|
AccMutationEvent(uint32_t aEventType, Accessible* aTarget)
|
||||||
AccMutationEvent(uint32_t aEventType, Accessible* aTarget) :
|
: AccTreeMutationEvent(aEventType, aTarget) {
|
||||||
AccTreeMutationEvent(aEventType, aTarget)
|
|
||||||
{
|
|
||||||
// Don't coalesce these since they are coalesced by reorder event. Coalesce
|
// Don't coalesce these since they are coalesced by reorder event. Coalesce
|
||||||
// contained text change events.
|
// contained text change events.
|
||||||
mParent = mAccessible->Parent();
|
mParent = mAccessible->Parent();
|
||||||
}
|
}
|
||||||
virtual ~AccMutationEvent() { }
|
virtual ~AccMutationEvent() {}
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
static const EventGroup kEventGroup = eMutationEvent;
|
static const EventGroup kEventGroup = eMutationEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccTreeMutationEvent::GetEventGroups() | (1U << eMutationEvent);
|
return AccTreeMutationEvent::GetEventGroups() | (1U << eMutationEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +256,7 @@ public:
|
|||||||
|
|
||||||
Accessible* Parent() const { return mParent; }
|
Accessible* Parent() const { return mParent; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsCOMPtr<nsINode> mNode;
|
nsCOMPtr<nsINode> mNode;
|
||||||
RefPtr<Accessible> mParent;
|
RefPtr<Accessible> mParent;
|
||||||
RefPtr<AccTextChangeEvent> mTextChangeEvent;
|
RefPtr<AccTextChangeEvent> mTextChangeEvent;
|
||||||
@@ -277,19 +265,16 @@ protected:
|
|||||||
friend class NotificationController;
|
friend class NotificationController;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible hide event.
|
* Accessible hide event.
|
||||||
*/
|
*/
|
||||||
class AccHideEvent: public AccMutationEvent
|
class AccHideEvent : public AccMutationEvent {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit AccHideEvent(Accessible* aTarget, bool aNeedsShutdown = true);
|
explicit AccHideEvent(Accessible* aTarget, bool aNeedsShutdown = true);
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
static const EventGroup kEventGroup = eHideEvent;
|
static const EventGroup kEventGroup = eHideEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccMutationEvent::GetEventGroups() | (1U << eHideEvent);
|
return AccMutationEvent::GetEventGroups() | (1U << eHideEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +284,7 @@ public:
|
|||||||
Accessible* TargetPrevSibling() const { return mPrevSibling; }
|
Accessible* TargetPrevSibling() const { return mPrevSibling; }
|
||||||
bool NeedsShutdown() const { return mNeedsShutdown; }
|
bool NeedsShutdown() const { return mNeedsShutdown; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool mNeedsShutdown;
|
bool mNeedsShutdown;
|
||||||
RefPtr<Accessible> mNextSibling;
|
RefPtr<Accessible> mNextSibling;
|
||||||
RefPtr<Accessible> mPrevSibling;
|
RefPtr<Accessible> mPrevSibling;
|
||||||
@@ -308,94 +293,81 @@ protected:
|
|||||||
friend class NotificationController;
|
friend class NotificationController;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible show event.
|
* Accessible show event.
|
||||||
*/
|
*/
|
||||||
class AccShowEvent: public AccMutationEvent
|
class AccShowEvent : public AccMutationEvent {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit AccShowEvent(Accessible* aTarget);
|
explicit AccShowEvent(Accessible* aTarget);
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
static const EventGroup kEventGroup = eShowEvent;
|
static const EventGroup kEventGroup = eShowEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccMutationEvent::GetEventGroups() | (1U << eShowEvent);
|
return AccMutationEvent::GetEventGroups() | (1U << eShowEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t InsertionIndex() const { return mInsertionIndex; }
|
uint32_t InsertionIndex() const { return mInsertionIndex; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsTArray<RefPtr<AccHideEvent>> mPrecedingEvents;
|
nsTArray<RefPtr<AccHideEvent>> mPrecedingEvents;
|
||||||
uint32_t mInsertionIndex;
|
uint32_t mInsertionIndex;
|
||||||
|
|
||||||
friend class EventTree;
|
friend class EventTree;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for reorder accessible event. Takes care about
|
* Class for reorder accessible event. Takes care about
|
||||||
*/
|
*/
|
||||||
class AccReorderEvent : public AccTreeMutationEvent
|
class AccReorderEvent : public AccTreeMutationEvent {
|
||||||
{
|
public:
|
||||||
public:
|
explicit AccReorderEvent(Accessible* aTarget)
|
||||||
explicit AccReorderEvent(Accessible* aTarget) :
|
: AccTreeMutationEvent(::nsIAccessibleEvent::EVENT_REORDER, aTarget) {}
|
||||||
AccTreeMutationEvent(::nsIAccessibleEvent::EVENT_REORDER, aTarget) { }
|
virtual ~AccReorderEvent() {}
|
||||||
virtual ~AccReorderEvent() { }
|
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
static const EventGroup kEventGroup = eReorderEvent;
|
static const EventGroup kEventGroup = eReorderEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccTreeMutationEvent::GetEventGroups() | (1U << eReorderEvent);
|
return AccTreeMutationEvent::GetEventGroups() | (1U << eReorderEvent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible caret move event.
|
* Accessible caret move event.
|
||||||
*/
|
*/
|
||||||
class AccCaretMoveEvent: public AccEvent
|
class AccCaretMoveEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AccCaretMoveEvent(Accessible* aAccessible, int32_t aCaretOffset,
|
AccCaretMoveEvent(Accessible* aAccessible, int32_t aCaretOffset,
|
||||||
EIsFromUserInput aIsFromUserInput = eAutoDetect) :
|
EIsFromUserInput aIsFromUserInput = eAutoDetect)
|
||||||
AccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aAccessible,
|
: AccEvent(::nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED, aAccessible,
|
||||||
aIsFromUserInput),
|
aIsFromUserInput),
|
||||||
mCaretOffset(aCaretOffset) { }
|
mCaretOffset(aCaretOffset) {}
|
||||||
virtual ~AccCaretMoveEvent() { }
|
virtual ~AccCaretMoveEvent() {}
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eCaretMoveEvent;
|
static const EventGroup kEventGroup = eCaretMoveEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eCaretMoveEvent);
|
return AccEvent::GetEventGroups() | (1U << eCaretMoveEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccCaretMoveEvent
|
// AccCaretMoveEvent
|
||||||
int32_t GetCaretOffset() const { return mCaretOffset; }
|
int32_t GetCaretOffset() const { return mCaretOffset; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t mCaretOffset;
|
int32_t mCaretOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible text selection change event.
|
* Accessible text selection change event.
|
||||||
*/
|
*/
|
||||||
class AccTextSelChangeEvent : public AccEvent
|
class AccTextSelChangeEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AccTextSelChangeEvent(HyperTextAccessible* aTarget,
|
AccTextSelChangeEvent(HyperTextAccessible* aTarget,
|
||||||
dom::Selection* aSelection,
|
dom::Selection* aSelection, int32_t aReason);
|
||||||
int32_t aReason);
|
|
||||||
virtual ~AccTextSelChangeEvent();
|
virtual ~AccTextSelChangeEvent();
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eTextSelChangeEvent;
|
static const EventGroup kEventGroup = eTextSelChangeEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eTextSelChangeEvent);
|
return AccEvent::GetEventGroups() | (1U << eTextSelChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,7 +378,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool IsCaretMoveOnly() const;
|
bool IsCaretMoveOnly() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<dom::Selection> mSel;
|
RefPtr<dom::Selection> mSel;
|
||||||
int32_t mReason;
|
int32_t mReason;
|
||||||
|
|
||||||
@@ -414,34 +386,28 @@ private:
|
|||||||
friend class SelectionManager;
|
friend class SelectionManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible widget selection change event.
|
* Accessible widget selection change event.
|
||||||
*/
|
*/
|
||||||
class AccSelChangeEvent : public AccEvent
|
class AccSelChangeEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
enum SelChangeType { eSelectionAdd, eSelectionRemove };
|
||||||
enum SelChangeType {
|
|
||||||
eSelectionAdd,
|
|
||||||
eSelectionRemove
|
|
||||||
};
|
|
||||||
|
|
||||||
AccSelChangeEvent(Accessible* aWidget, Accessible* aItem,
|
AccSelChangeEvent(Accessible* aWidget, Accessible* aItem,
|
||||||
SelChangeType aSelChangeType);
|
SelChangeType aSelChangeType);
|
||||||
|
|
||||||
virtual ~AccSelChangeEvent() { }
|
virtual ~AccSelChangeEvent() {}
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eSelectionChangeEvent;
|
static const EventGroup kEventGroup = eSelectionChangeEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eSelectionChangeEvent);
|
return AccEvent::GetEventGroups() | (1U << eSelectionChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccSelChangeEvent
|
// AccSelChangeEvent
|
||||||
Accessible* Widget() const { return mWidget; }
|
Accessible* Widget() const { return mWidget; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<Accessible> mWidget;
|
RefPtr<Accessible> mWidget;
|
||||||
RefPtr<Accessible> mItem;
|
RefPtr<Accessible> mItem;
|
||||||
SelChangeType mSelChangeType;
|
SelChangeType mSelChangeType;
|
||||||
@@ -451,20 +417,17 @@ private:
|
|||||||
friend class EventQueue;
|
friend class EventQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible table change event.
|
* Accessible table change event.
|
||||||
*/
|
*/
|
||||||
class AccTableChangeEvent : public AccEvent
|
class AccTableChangeEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AccTableChangeEvent(Accessible* aAccessible, uint32_t aEventType,
|
AccTableChangeEvent(Accessible* aAccessible, uint32_t aEventType,
|
||||||
int32_t aRowOrColIndex, int32_t aNumRowsOrCols);
|
int32_t aRowOrColIndex, int32_t aNumRowsOrCols);
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eTableChangeEvent;
|
static const EventGroup kEventGroup = eTableChangeEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eTableChangeEvent);
|
return AccEvent::GetEventGroups() | (1U << eTableChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,32 +435,28 @@ public:
|
|||||||
uint32_t GetIndex() const { return mRowOrColIndex; }
|
uint32_t GetIndex() const { return mRowOrColIndex; }
|
||||||
uint32_t GetCount() const { return mNumRowsOrCols; }
|
uint32_t GetCount() const { return mNumRowsOrCols; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t mRowOrColIndex; // the start row/column after which the rows are inserted/deleted.
|
uint32_t mRowOrColIndex; // the start row/column after which the rows are
|
||||||
uint32_t mNumRowsOrCols; // the number of inserted/deleted rows/columns
|
// inserted/deleted.
|
||||||
|
uint32_t mNumRowsOrCols; // the number of inserted/deleted rows/columns
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible virtual cursor change event.
|
* Accessible virtual cursor change event.
|
||||||
*/
|
*/
|
||||||
class AccVCChangeEvent : public AccEvent
|
class AccVCChangeEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
AccVCChangeEvent(Accessible* aAccessible, Accessible* aOldAccessible,
|
||||||
AccVCChangeEvent(Accessible* aAccessible,
|
|
||||||
Accessible* aOldAccessible,
|
|
||||||
int32_t aOldStart, int32_t aOldEnd,
|
int32_t aOldStart, int32_t aOldEnd,
|
||||||
Accessible* aNewAccessible,
|
Accessible* aNewAccessible, int32_t aNewStart,
|
||||||
int32_t aNewStart, int32_t aNewEnd,
|
int32_t aNewEnd, int16_t aReason, int16_t aBoundaryType,
|
||||||
int16_t aReason,
|
|
||||||
int16_t aBoundaryType,
|
|
||||||
EIsFromUserInput aIsFromUserInput = eFromUserInput);
|
EIsFromUserInput aIsFromUserInput = eFromUserInput);
|
||||||
|
|
||||||
virtual ~AccVCChangeEvent() { }
|
virtual ~AccVCChangeEvent() {}
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eVirtualCursorChangeEvent;
|
static const EventGroup kEventGroup = eVirtualCursorChangeEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eVirtualCursorChangeEvent);
|
return AccEvent::GetEventGroups() | (1U << eVirtualCursorChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +470,7 @@ public:
|
|||||||
int32_t Reason() const { return mReason; }
|
int32_t Reason() const { return mReason; }
|
||||||
int32_t BoundaryType() const { return mBoundaryType; }
|
int32_t BoundaryType() const { return mBoundaryType; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<Accessible> mOldAccessible;
|
RefPtr<Accessible> mOldAccessible;
|
||||||
RefPtr<Accessible> mNewAccessible;
|
RefPtr<Accessible> mNewAccessible;
|
||||||
int32_t mOldStart;
|
int32_t mOldStart;
|
||||||
@@ -525,50 +484,47 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Accessible object attribute changed event.
|
* Accessible object attribute changed event.
|
||||||
*/
|
*/
|
||||||
class AccObjectAttrChangedEvent: public AccEvent
|
class AccObjectAttrChangedEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
AccObjectAttrChangedEvent(Accessible* aAccessible, nsAtom* aAttribute)
|
||||||
AccObjectAttrChangedEvent(Accessible* aAccessible, nsAtom* aAttribute) :
|
: AccEvent(::nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
|
||||||
AccEvent(::nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED, aAccessible),
|
aAccessible),
|
||||||
mAttribute(aAttribute) { }
|
mAttribute(aAttribute) {}
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eObjectAttrChangedEvent;
|
static const EventGroup kEventGroup = eObjectAttrChangedEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eObjectAttrChangedEvent);
|
return AccEvent::GetEventGroups() | (1U << eObjectAttrChangedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccObjectAttrChangedEvent
|
// AccObjectAttrChangedEvent
|
||||||
nsAtom* GetAttribute() const { return mAttribute; }
|
nsAtom* GetAttribute() const { return mAttribute; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<nsAtom> mAttribute;
|
RefPtr<nsAtom> mAttribute;
|
||||||
|
|
||||||
virtual ~AccObjectAttrChangedEvent() { }
|
virtual ~AccObjectAttrChangedEvent() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessible scroll event.
|
* Accessible scroll event.
|
||||||
*/
|
*/
|
||||||
class AccScrollingEvent : public AccEvent
|
class AccScrollingEvent : public AccEvent {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AccScrollingEvent(uint32_t aEventType, Accessible* aAccessible,
|
AccScrollingEvent(uint32_t aEventType, Accessible* aAccessible,
|
||||||
uint32_t aScrollX, uint32_t aScrollY,
|
uint32_t aScrollX, uint32_t aScrollY, uint32_t aMaxScrollX,
|
||||||
uint32_t aMaxScrollX, uint32_t aMaxScrollY) :
|
uint32_t aMaxScrollY)
|
||||||
AccEvent(aEventType, aAccessible),
|
: AccEvent(aEventType, aAccessible),
|
||||||
mScrollX(aScrollX),
|
mScrollX(aScrollX),
|
||||||
mScrollY(aScrollY),
|
mScrollY(aScrollY),
|
||||||
mMaxScrollX(aMaxScrollX),
|
mMaxScrollX(aMaxScrollX),
|
||||||
mMaxScrollY(aMaxScrollY) { }
|
mMaxScrollY(aMaxScrollY) {}
|
||||||
|
|
||||||
virtual ~AccScrollingEvent() { }
|
virtual ~AccScrollingEvent() {}
|
||||||
|
|
||||||
// AccEvent
|
// AccEvent
|
||||||
static const EventGroup kEventGroup = eScrollingEvent;
|
static const EventGroup kEventGroup = eScrollingEvent;
|
||||||
virtual unsigned int GetEventGroups() const override
|
virtual unsigned int GetEventGroups() const override {
|
||||||
{
|
|
||||||
return AccEvent::GetEventGroups() | (1U << eScrollingEvent);
|
return AccEvent::GetEventGroups() | (1U << eScrollingEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,7 +537,7 @@ public:
|
|||||||
// The max Y offset of the container.
|
// The max Y offset of the container.
|
||||||
uint32_t MaxScrollY() { return mMaxScrollY; }
|
uint32_t MaxScrollY() { return mMaxScrollY; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t mScrollX;
|
uint32_t mScrollX;
|
||||||
uint32_t mScrollY;
|
uint32_t mScrollY;
|
||||||
uint32_t mMaxScrollX;
|
uint32_t mMaxScrollX;
|
||||||
@@ -591,31 +547,29 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Downcast the generic accessible event object to derived type.
|
* Downcast the generic accessible event object to derived type.
|
||||||
*/
|
*/
|
||||||
class downcast_accEvent
|
class downcast_accEvent {
|
||||||
{
|
public:
|
||||||
public:
|
explicit downcast_accEvent(AccEvent* e) : mRawPtr(e) {}
|
||||||
explicit downcast_accEvent(AccEvent* e) : mRawPtr(e) { }
|
|
||||||
|
|
||||||
template<class Destination>
|
template <class Destination>
|
||||||
operator Destination*() {
|
operator Destination*() {
|
||||||
if (!mRawPtr)
|
if (!mRawPtr) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
return mRawPtr->GetEventGroups() & (1U << Destination::kEventGroup) ?
|
return mRawPtr->GetEventGroups() & (1U << Destination::kEventGroup)
|
||||||
static_cast<Destination*>(mRawPtr) : nullptr;
|
? static_cast<Destination*>(mRawPtr)
|
||||||
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AccEvent* mRawPtr;
|
AccEvent* mRawPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new xpcom accessible event for the given internal one.
|
* Return a new xpcom accessible event for the given internal one.
|
||||||
*/
|
*/
|
||||||
already_AddRefed<nsIAccessibleEvent>
|
already_AddRefed<nsIAccessibleEvent> MakeXPCEvent(AccEvent* aEvent);
|
||||||
MakeXPCEvent(AccEvent* aEvent);
|
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,19 +11,15 @@
|
|||||||
|
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
AccGroupInfo::AccGroupInfo(const Accessible* aItem, role aRole) :
|
AccGroupInfo::AccGroupInfo(const Accessible* aItem, role aRole)
|
||||||
mPosInSet(0), mSetSize(0), mParent(nullptr), mItem(aItem), mRole(aRole)
|
: mPosInSet(0), mSetSize(0), mParent(nullptr), mItem(aItem), mRole(aRole) {
|
||||||
{
|
|
||||||
MOZ_COUNT_CTOR(AccGroupInfo);
|
MOZ_COUNT_CTOR(AccGroupInfo);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AccGroupInfo::Update() {
|
||||||
AccGroupInfo::Update()
|
|
||||||
{
|
|
||||||
Accessible* parent = mItem->Parent();
|
Accessible* parent = mItem->Parent();
|
||||||
if (!parent)
|
if (!parent) return;
|
||||||
return;
|
|
||||||
|
|
||||||
int32_t indexInParent = mItem->IndexInParent();
|
int32_t indexInParent = mItem->IndexInParent();
|
||||||
uint32_t siblingCount = parent->ChildCount();
|
uint32_t siblingCount = parent->ChildCount();
|
||||||
@@ -37,13 +33,12 @@ AccGroupInfo::Update()
|
|||||||
|
|
||||||
// Compute position in set.
|
// Compute position in set.
|
||||||
mPosInSet = 1;
|
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);
|
Accessible* sibling = parent->GetChildAt(idx);
|
||||||
roles::Role siblingRole = sibling->Role();
|
roles::Role siblingRole = sibling->Role();
|
||||||
|
|
||||||
// If the sibling is separator then the group is ended.
|
// If the sibling is separator then the group is ended.
|
||||||
if (siblingRole == roles::SEPARATOR)
|
if (siblingRole == roles::SEPARATOR) break;
|
||||||
break;
|
|
||||||
|
|
||||||
// If sibling is not visible and hasn't the same base role.
|
// If sibling is not visible and hasn't the same base role.
|
||||||
if (BaseRole(siblingRole) != mRole || sibling->State() & states::INVISIBLE)
|
if (BaseRole(siblingRole) != mRole || sibling->State() & states::INVISIBLE)
|
||||||
@@ -60,8 +55,7 @@ AccGroupInfo::Update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip subset.
|
// Skip subset.
|
||||||
if (siblingLevel > level)
|
if (siblingLevel > level) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
// If the previous item in the group has calculated group information then
|
// If the previous item in the group has calculated group information then
|
||||||
// build group information for this item based on found one.
|
// build group information for this item based on found one.
|
||||||
@@ -84,8 +78,7 @@ AccGroupInfo::Update()
|
|||||||
roles::Role siblingRole = sibling->Role();
|
roles::Role siblingRole = sibling->Role();
|
||||||
|
|
||||||
// If the sibling is separator then the group is ended.
|
// If the sibling is separator then the group is ended.
|
||||||
if (siblingRole == roles::SEPARATOR)
|
if (siblingRole == roles::SEPARATOR) break;
|
||||||
break;
|
|
||||||
|
|
||||||
// If sibling is visible and has the same base role
|
// If sibling is visible and has the same base role
|
||||||
if (BaseRole(siblingRole) != mRole || sibling->State() & states::INVISIBLE)
|
if (BaseRole(siblingRole) != mRole || sibling->State() & states::INVISIBLE)
|
||||||
@@ -93,12 +86,10 @@ AccGroupInfo::Update()
|
|||||||
|
|
||||||
// and check if it's hierarchical flatten structure.
|
// and check if it's hierarchical flatten structure.
|
||||||
int32_t siblingLevel = nsAccUtils::GetARIAOrDefaultLevel(sibling);
|
int32_t siblingLevel = nsAccUtils::GetARIAOrDefaultLevel(sibling);
|
||||||
if (siblingLevel < level)
|
if (siblingLevel < level) break;
|
||||||
break;
|
|
||||||
|
|
||||||
// Skip subset.
|
// Skip subset.
|
||||||
if (siblingLevel > level)
|
if (siblingLevel > level) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
// If the next item in the group has calculated group information then
|
// If the next item in the group has calculated group information then
|
||||||
// build group information for this item based on found one.
|
// build group information for this item based on found one.
|
||||||
@@ -111,16 +102,13 @@ AccGroupInfo::Update()
|
|||||||
mSetSize++;
|
mSetSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mParent)
|
if (mParent) return;
|
||||||
return;
|
|
||||||
|
|
||||||
roles::Role parentRole = parent->Role();
|
roles::Role parentRole = parent->Role();
|
||||||
if (ShouldReportRelations(mRole, parentRole))
|
if (ShouldReportRelations(mRole, parentRole)) mParent = parent;
|
||||||
mParent = parent;
|
|
||||||
|
|
||||||
// ARIA tree and list can be arranged by using ARIA groups to organize levels.
|
// ARIA tree and list can be arranged by using ARIA groups to organize levels.
|
||||||
if (parentRole != roles::GROUPING)
|
if (parentRole != roles::GROUPING) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Way #1 for ARIA tree (not ARIA treegrid): previous sibling of a group is a
|
// 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
|
// 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.
|
// a conceptual parent of the item.
|
||||||
if (mRole == roles::LISTITEM || mRole == roles::OUTLINEITEM) {
|
if (mRole == roles::LISTITEM || mRole == roles::OUTLINEITEM) {
|
||||||
Accessible* grandParent = parent->Parent();
|
Accessible* grandParent = parent->Parent();
|
||||||
if (grandParent && grandParent->Role() == mRole)
|
if (grandParent && grandParent->Role() == mRole) mParent = grandParent;
|
||||||
mParent = grandParent;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* AccGroupInfo::FirstItemOf(const Accessible* aContainer) {
|
||||||
AccGroupInfo::FirstItemOf(const Accessible* aContainer)
|
|
||||||
{
|
|
||||||
// ARIA tree can be arranged by ARIA groups case #1 (previous sibling of a
|
// ARIA tree can be arranged by ARIA groups case #1 (previous sibling of a
|
||||||
// group is a parent) or by aria-level.
|
// group is a parent) or by aria-level.
|
||||||
a11y::role containerRole = aContainer->Role();
|
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
|
// ARIA list and tree can be arranged by ARIA groups case #2 (group is
|
||||||
// a child of an item).
|
// a child of an item).
|
||||||
item = aContainer->LastChild();
|
item = aContainer->LastChild();
|
||||||
if (!item)
|
if (!item) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
if (item->Role() == roles::GROUPING &&
|
if (item->Role() == roles::GROUPING &&
|
||||||
(containerRole == roles::LISTITEM || containerRole == roles::OUTLINEITEM)) {
|
(containerRole == roles::LISTITEM ||
|
||||||
|
containerRole == roles::OUTLINEITEM)) {
|
||||||
item = item->FirstChild();
|
item = item->FirstChild();
|
||||||
if (item) {
|
if (item) {
|
||||||
AccGroupInfo* itemGroupInfo = item->GetGroupInfo();
|
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.
|
// Otherwise, it can be a direct child if the container is a list or tree.
|
||||||
item = aContainer->FirstChild();
|
item = aContainer->FirstChild();
|
||||||
if (ShouldReportRelations(item->Role(), containerRole))
|
if (ShouldReportRelations(item->Role(), containerRole)) return item;
|
||||||
return item;
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t AccGroupInfo::TotalItemCount(Accessible* aContainer,
|
||||||
AccGroupInfo::TotalItemCount(Accessible* aContainer, bool* aIsHierarchical)
|
bool* aIsHierarchical) {
|
||||||
{
|
|
||||||
uint32_t itemCount = 0;
|
uint32_t itemCount = 0;
|
||||||
switch (aContainer->Role()) {
|
switch (aContainer->Role()) {
|
||||||
case roles::TABLE:
|
case roles::TABLE:
|
||||||
@@ -255,16 +238,12 @@ AccGroupInfo::TotalItemCount(Accessible* aContainer, bool* aIsHierarchical)
|
|||||||
return itemCount;
|
return itemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* AccGroupInfo::NextItemTo(Accessible* aItem) {
|
||||||
AccGroupInfo::NextItemTo(Accessible* aItem)
|
|
||||||
{
|
|
||||||
AccGroupInfo* groupInfo = aItem->GetGroupInfo();
|
AccGroupInfo* groupInfo = aItem->GetGroupInfo();
|
||||||
if (!groupInfo)
|
if (!groupInfo) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
// If the item in middle of the group then search next item in siblings.
|
// If the item in middle of the group then search next item in siblings.
|
||||||
if (groupInfo->PosInSet() >= groupInfo->SetSize())
|
if (groupInfo->PosInSet() >= groupInfo->SetSize()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
Accessible* parent = aItem->Parent();
|
Accessible* parent = aItem->Parent();
|
||||||
uint32_t childCount = parent->ChildCount();
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool AccGroupInfo::ShouldReportRelations(role aRole, role aParentRole) {
|
||||||
AccGroupInfo::ShouldReportRelations(role aRole, role aParentRole)
|
|
||||||
{
|
|
||||||
// We only want to report hierarchy-based node relations for items in tree or
|
// We only want to report hierarchy-based node relations for items in tree or
|
||||||
// list form. ARIA level/owns relations are always reported.
|
// list form. ARIA level/owns relations are always reported.
|
||||||
if (aParentRole == roles::OUTLINE && aRole == roles::OUTLINEITEM)
|
if (aParentRole == roles::OUTLINE && aRole == roles::OUTLINEITEM) return true;
|
||||||
return true;
|
if (aParentRole == roles::TREE_TABLE && aRole == roles::ROW) return true;
|
||||||
if (aParentRole == roles::TREE_TABLE && aRole == roles::ROW)
|
if (aParentRole == roles::LIST && aRole == roles::LISTITEM) return true;
|
||||||
return true;
|
|
||||||
if (aParentRole == roles::LIST && aRole == roles::LISTITEM)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ namespace a11y {
|
|||||||
/**
|
/**
|
||||||
* Calculate and store group information.
|
* Calculate and store group information.
|
||||||
*/
|
*/
|
||||||
class AccGroupInfo
|
class AccGroupInfo {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); }
|
~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,8 +41,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Create group info.
|
* Create group info.
|
||||||
*/
|
*/
|
||||||
static AccGroupInfo* CreateGroupInfo(const Accessible* aAccessible)
|
static AccGroupInfo* CreateGroupInfo(const Accessible* aAccessible) {
|
||||||
{
|
|
||||||
mozilla::a11y::role role = aAccessible->Role();
|
mozilla::a11y::role role = aAccessible->Role();
|
||||||
if (role != mozilla::a11y::roles::ROW &&
|
if (role != mozilla::a11y::roles::ROW &&
|
||||||
role != mozilla::a11y::roles::OUTLINEITEM &&
|
role != mozilla::a11y::roles::OUTLINEITEM &&
|
||||||
@@ -70,7 +68,8 @@ public:
|
|||||||
static Accessible* FirstItemOf(const Accessible* aContainer);
|
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);
|
static uint32_t TotalItemCount(Accessible* aContainer, bool* aIsHierarchical);
|
||||||
|
|
||||||
@@ -79,16 +78,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
static Accessible* NextItemTo(Accessible* aItem);
|
static Accessible* NextItemTo(Accessible* aItem);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AccGroupInfo(const Accessible* aItem, a11y::role aRole);
|
AccGroupInfo(const Accessible* aItem, a11y::role aRole);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AccGroupInfo() = delete;
|
AccGroupInfo() = delete;
|
||||||
AccGroupInfo(const 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 ||
|
if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM ||
|
||||||
aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
|
aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
|
||||||
aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
|
aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
|
||||||
@@ -113,7 +111,7 @@ private:
|
|||||||
a11y::role mRole;
|
a11y::role mRole;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace a11y
|
||||||
} // namespace a11y
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -19,24 +19,20 @@ using namespace mozilla::a11y;
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AccIterator::AccIterator(const Accessible* aAccessible,
|
AccIterator::AccIterator(const Accessible* aAccessible,
|
||||||
filters::FilterFuncPtr aFilterFunc) :
|
filters::FilterFuncPtr aFilterFunc)
|
||||||
mFilterFunc(aFilterFunc)
|
: mFilterFunc(aFilterFunc) {
|
||||||
{
|
|
||||||
mState = new IteratorState(aAccessible);
|
mState = new IteratorState(aAccessible);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccIterator::~AccIterator()
|
AccIterator::~AccIterator() {
|
||||||
{
|
|
||||||
while (mState) {
|
while (mState) {
|
||||||
IteratorState *tmp = mState;
|
IteratorState* tmp = mState;
|
||||||
mState = tmp->mParentState;
|
mState = tmp->mParentState;
|
||||||
delete tmp;
|
delete tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* AccIterator::Next() {
|
||||||
AccIterator::Next()
|
|
||||||
{
|
|
||||||
while (mState) {
|
while (mState) {
|
||||||
Accessible* child = mState->mParent->GetChildAt(mState->mIndex++);
|
Accessible* child = mState->mParent->GetChildAt(mState->mIndex++);
|
||||||
if (!child) {
|
if (!child) {
|
||||||
@@ -48,8 +44,7 @@ AccIterator::Next()
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t result = mFilterFunc(child);
|
uint32_t result = mFilterFunc(child);
|
||||||
if (result & filters::eMatch)
|
if (result & filters::eMatch) return child;
|
||||||
return child;
|
|
||||||
|
|
||||||
if (!(result & filters::eSkipSubtree)) {
|
if (!(result & filters::eSkipSubtree)) {
|
||||||
IteratorState* childState = new IteratorState(child, mState);
|
IteratorState* childState = new IteratorState(child, mState);
|
||||||
@@ -64,26 +59,25 @@ AccIterator::Next()
|
|||||||
// nsAccIterator::IteratorState
|
// nsAccIterator::IteratorState
|
||||||
|
|
||||||
AccIterator::IteratorState::IteratorState(const Accessible* aParent,
|
AccIterator::IteratorState::IteratorState(const Accessible* aParent,
|
||||||
IteratorState *mParentState) :
|
IteratorState* mParentState)
|
||||||
mParent(aParent), mIndex(0), mParentState(mParentState)
|
: mParent(aParent), mIndex(0), mParentState(mParentState) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// RelatedAccIterator
|
// RelatedAccIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
RelatedAccIterator::
|
RelatedAccIterator::RelatedAccIterator(DocAccessible* aDocument,
|
||||||
RelatedAccIterator(DocAccessible* aDocument, nsIContent* aDependentContent,
|
nsIContent* aDependentContent,
|
||||||
nsAtom* aRelAttr) :
|
nsAtom* aRelAttr)
|
||||||
mDocument(aDocument), mRelAttr(aRelAttr), mProviders(nullptr),
|
: mDocument(aDocument),
|
||||||
mBindingParent(nullptr), mIndex(0)
|
mRelAttr(aRelAttr),
|
||||||
{
|
mProviders(nullptr),
|
||||||
mBindingParent = aDependentContent->IsInAnonymousSubtree() ?
|
mBindingParent(nullptr),
|
||||||
aDependentContent->GetBindingParent() : nullptr;
|
mIndex(0) {
|
||||||
nsAtom* IDAttr = mBindingParent ?
|
mBindingParent = aDependentContent->IsInAnonymousSubtree()
|
||||||
nsGkAtoms::anonid : nsGkAtoms::id;
|
? aDependentContent->GetBindingParent()
|
||||||
|
: nullptr;
|
||||||
|
nsAtom* IDAttr = mBindingParent ? nsGkAtoms::anonid : nsGkAtoms::id;
|
||||||
|
|
||||||
nsAutoString id;
|
nsAutoString id;
|
||||||
if (aDependentContent->IsElement() &&
|
if (aDependentContent->IsElement() &&
|
||||||
@@ -92,11 +86,8 @@ RelatedAccIterator::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* RelatedAccIterator::Next() {
|
||||||
RelatedAccIterator::Next()
|
if (!mProviders) return nullptr;
|
||||||
{
|
|
||||||
if (!mProviders)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
while (mIndex < mProviders->Length()) {
|
while (mIndex < mProviders->Length()) {
|
||||||
DocAccessible::AttrRelProvider* provider = (*mProviders)[mIndex++];
|
DocAccessible::AttrRelProvider* provider = (*mProviders)[mIndex++];
|
||||||
@@ -104,20 +95,19 @@ RelatedAccIterator::Next()
|
|||||||
// Return related accessible for the given attribute and if the provider
|
// Return related accessible for the given attribute and if the provider
|
||||||
// content is in the same binding in the case of XBL usage.
|
// content is in the same binding in the case of XBL usage.
|
||||||
if (provider->mRelAttr == mRelAttr) {
|
if (provider->mRelAttr == mRelAttr) {
|
||||||
nsIContent* bindingParent = provider->mContent->IsInAnonymousSubtree() ?
|
nsIContent* bindingParent = provider->mContent->IsInAnonymousSubtree()
|
||||||
provider->mContent->GetBindingParent() : nullptr;
|
? provider->mContent->GetBindingParent()
|
||||||
|
: nullptr;
|
||||||
bool inScope = mBindingParent == bindingParent ||
|
bool inScope = mBindingParent == bindingParent ||
|
||||||
mBindingParent == provider->mContent;
|
mBindingParent == provider->mContent;
|
||||||
|
|
||||||
if (inScope) {
|
if (inScope) {
|
||||||
Accessible* related = mDocument->GetAccessible(provider->mContent);
|
Accessible* related = mDocument->GetAccessible(provider->mContent);
|
||||||
if (related)
|
if (related) return related;
|
||||||
return related;
|
|
||||||
|
|
||||||
// If the document content is pointed by relation then return the document
|
// If the document content is pointed by relation then return the
|
||||||
// itself.
|
// document itself.
|
||||||
if (provider->mContent == mDocument->GetContent())
|
if (provider->mContent == mDocument->GetContent()) return mDocument;
|
||||||
return mDocument;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,30 +115,24 @@ RelatedAccIterator::Next()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// HTMLLabelIterator
|
// HTMLLabelIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
HTMLLabelIterator::
|
HTMLLabelIterator::HTMLLabelIterator(DocAccessible* aDocument,
|
||||||
HTMLLabelIterator(DocAccessible* aDocument, const Accessible* aAccessible,
|
const Accessible* aAccessible,
|
||||||
LabelFilter aFilter) :
|
LabelFilter aFilter)
|
||||||
mRelIter(aDocument, aAccessible->GetContent(), nsGkAtoms::_for),
|
: mRelIter(aDocument, aAccessible->GetContent(), nsGkAtoms::_for),
|
||||||
mAcc(aAccessible), mLabelFilter(aFilter)
|
mAcc(aAccessible),
|
||||||
{
|
mLabelFilter(aFilter) {}
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool HTMLLabelIterator::IsLabel(Accessible* aLabel) {
|
||||||
HTMLLabelIterator::IsLabel(Accessible* aLabel)
|
|
||||||
{
|
|
||||||
dom::HTMLLabelElement* labelEl =
|
dom::HTMLLabelElement* labelEl =
|
||||||
dom::HTMLLabelElement::FromNode(aLabel->GetContent());
|
dom::HTMLLabelElement::FromNode(aLabel->GetContent());
|
||||||
return labelEl && labelEl->GetControl() == mAcc->GetContent();
|
return labelEl && labelEl->GetControl() == mAcc->GetContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* HTMLLabelIterator::Next() {
|
||||||
HTMLLabelIterator::Next()
|
|
||||||
{
|
|
||||||
// Get either <label for="[id]"> element which explicitly points to given
|
// Get either <label for="[id]"> element which explicitly points to given
|
||||||
// element, or <label> ancestor which implicitly point to it.
|
// element, or <label> ancestor which implicitly point to it.
|
||||||
Accessible* label = nullptr;
|
Accessible* label = nullptr;
|
||||||
@@ -159,8 +143,7 @@ HTMLLabelIterator::Next()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ignore ancestor label on not widget accessible.
|
// Ignore ancestor label on not widget accessible.
|
||||||
if (mLabelFilter == eSkipAncestorLabel || !mAcc->IsWidget())
|
if (mLabelFilter == eSkipAncestorLabel || !mAcc->IsWidget()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
// Go up tree to get a name of ancestor label if there is one (an ancestor
|
// 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
|
// <label> implicitly points to us). Don't go up farther than form or
|
||||||
@@ -170,12 +153,11 @@ HTMLLabelIterator::Next()
|
|||||||
nsIContent* walkUpEl = walkUp->GetContent();
|
nsIContent* walkUpEl = walkUp->GetContent();
|
||||||
if (IsLabel(walkUp) &&
|
if (IsLabel(walkUp) &&
|
||||||
!walkUpEl->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
|
!walkUpEl->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
|
||||||
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
|
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
|
||||||
return walkUp;
|
return walkUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walkUpEl->IsHTMLElement(nsGkAtoms::form))
|
if (walkUpEl->IsHTMLElement(nsGkAtoms::form)) break;
|
||||||
break;
|
|
||||||
|
|
||||||
walkUp = walkUp->Parent();
|
walkUp = walkUp->Parent();
|
||||||
}
|
}
|
||||||
@@ -183,70 +165,52 @@ HTMLLabelIterator::Next()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// HTMLOutputIterator
|
// HTMLOutputIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
HTMLOutputIterator::
|
HTMLOutputIterator::HTMLOutputIterator(DocAccessible* aDocument,
|
||||||
HTMLOutputIterator(DocAccessible* aDocument, nsIContent* aElement) :
|
nsIContent* aElement)
|
||||||
mRelIter(aDocument, aElement, nsGkAtoms::_for)
|
: mRelIter(aDocument, aElement, nsGkAtoms::_for) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Accessible*
|
Accessible* HTMLOutputIterator::Next() {
|
||||||
HTMLOutputIterator::Next()
|
|
||||||
{
|
|
||||||
Accessible* output = nullptr;
|
Accessible* output = nullptr;
|
||||||
while ((output = mRelIter.Next())) {
|
while ((output = mRelIter.Next())) {
|
||||||
if (output->GetContent()->IsHTMLElement(nsGkAtoms::output))
|
if (output->GetContent()->IsHTMLElement(nsGkAtoms::output)) return output;
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// XULLabelIterator
|
// XULLabelIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
XULLabelIterator::
|
XULLabelIterator::XULLabelIterator(DocAccessible* aDocument,
|
||||||
XULLabelIterator(DocAccessible* aDocument, nsIContent* aElement) :
|
nsIContent* aElement)
|
||||||
mRelIter(aDocument, aElement, nsGkAtoms::control)
|
: mRelIter(aDocument, aElement, nsGkAtoms::control) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Accessible*
|
Accessible* XULLabelIterator::Next() {
|
||||||
XULLabelIterator::Next()
|
|
||||||
{
|
|
||||||
Accessible* label = nullptr;
|
Accessible* label = nullptr;
|
||||||
while ((label = mRelIter.Next())) {
|
while ((label = mRelIter.Next())) {
|
||||||
if (label->GetContent()->IsXULElement(nsGkAtoms::label))
|
if (label->GetContent()->IsXULElement(nsGkAtoms::label)) return label;
|
||||||
return label;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// XULDescriptionIterator
|
// XULDescriptionIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
XULDescriptionIterator::
|
XULDescriptionIterator::XULDescriptionIterator(DocAccessible* aDocument,
|
||||||
XULDescriptionIterator(DocAccessible* aDocument, nsIContent* aElement) :
|
nsIContent* aElement)
|
||||||
mRelIter(aDocument, aElement, nsGkAtoms::control)
|
: mRelIter(aDocument, aElement, nsGkAtoms::control) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Accessible*
|
Accessible* XULDescriptionIterator::Next() {
|
||||||
XULDescriptionIterator::Next()
|
|
||||||
{
|
|
||||||
Accessible* descr = nullptr;
|
Accessible* descr = nullptr;
|
||||||
while ((descr = mRelIter.Next())) {
|
while ((descr = mRelIter.Next())) {
|
||||||
if (descr->GetContent()->IsXULElement(nsGkAtoms::description))
|
if (descr->GetContent()->IsXULElement(nsGkAtoms::description)) return descr;
|
||||||
return descr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -256,64 +220,50 @@ XULDescriptionIterator::Next()
|
|||||||
// IDRefsIterator
|
// IDRefsIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
IDRefsIterator::
|
IDRefsIterator::IDRefsIterator(DocAccessible* aDoc, nsIContent* aContent,
|
||||||
IDRefsIterator(DocAccessible* aDoc, nsIContent* aContent,
|
nsAtom* aIDRefsAttr)
|
||||||
nsAtom* aIDRefsAttr) :
|
: mContent(aContent), mDoc(aDoc), mCurrIdx(0) {
|
||||||
mContent(aContent), mDoc(aDoc), mCurrIdx(0)
|
|
||||||
{
|
|
||||||
if (mContent->IsElement()) {
|
if (mContent->IsElement()) {
|
||||||
mContent->AsElement()->GetAttr(kNameSpaceID_None, aIDRefsAttr, mIDs);
|
mContent->AsElement()->GetAttr(kNameSpaceID_None, aIDRefsAttr, mIDs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const nsDependentSubstring
|
const nsDependentSubstring IDRefsIterator::NextID() {
|
||||||
IDRefsIterator::NextID()
|
|
||||||
{
|
|
||||||
for (; mCurrIdx < mIDs.Length(); mCurrIdx++) {
|
for (; mCurrIdx < mIDs.Length(); mCurrIdx++) {
|
||||||
if (!NS_IsAsciiWhitespace(mIDs[mCurrIdx]))
|
if (!NS_IsAsciiWhitespace(mIDs[mCurrIdx])) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrIdx >= mIDs.Length())
|
if (mCurrIdx >= mIDs.Length()) return nsDependentSubstring();
|
||||||
return nsDependentSubstring();
|
|
||||||
|
|
||||||
nsAString::index_type idStartIdx = mCurrIdx;
|
nsAString::index_type idStartIdx = mCurrIdx;
|
||||||
while (++mCurrIdx < mIDs.Length()) {
|
while (++mCurrIdx < mIDs.Length()) {
|
||||||
if (NS_IsAsciiWhitespace(mIDs[mCurrIdx]))
|
if (NS_IsAsciiWhitespace(mIDs[mCurrIdx])) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Substring(mIDs, idStartIdx, mCurrIdx++ - idStartIdx);
|
return Substring(mIDs, idStartIdx, mCurrIdx++ - idStartIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIContent*
|
nsIContent* IDRefsIterator::NextElem() {
|
||||||
IDRefsIterator::NextElem()
|
|
||||||
{
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const nsDependentSubstring id = NextID();
|
const nsDependentSubstring id = NextID();
|
||||||
if (id.IsEmpty())
|
if (id.IsEmpty()) break;
|
||||||
break;
|
|
||||||
|
|
||||||
nsIContent* refContent = GetElem(id);
|
nsIContent* refContent = GetElem(id);
|
||||||
if (refContent)
|
if (refContent) return refContent;
|
||||||
return refContent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIContent*
|
nsIContent* IDRefsIterator::GetElem(const nsDependentSubstring& aID) {
|
||||||
IDRefsIterator::GetElem(const nsDependentSubstring& aID)
|
|
||||||
{
|
|
||||||
// Get elements in DOM tree by ID attribute if this is an explicit content.
|
// Get elements in DOM tree by ID attribute if this is an explicit content.
|
||||||
// In case of bound element check its anonymous subtree.
|
// In case of bound element check its anonymous subtree.
|
||||||
if (!mContent->IsInAnonymousSubtree()) {
|
if (!mContent->IsInAnonymousSubtree()) {
|
||||||
dom::DocumentOrShadowRoot* docOrShadowRoot =
|
dom::DocumentOrShadowRoot* docOrShadowRoot =
|
||||||
mContent->GetUncomposedDocOrConnectedShadowRoot();
|
mContent->GetUncomposedDocOrConnectedShadowRoot();
|
||||||
if (docOrShadowRoot) {
|
if (docOrShadowRoot) {
|
||||||
dom::Element* refElm = docOrShadowRoot->GetElementById(aID);
|
dom::Element* refElm = docOrShadowRoot->GetElementById(aID);
|
||||||
if (refElm || !mContent->GetXBLBinding())
|
if (refElm || !mContent->GetXBLBinding()) return refElm;
|
||||||
return refElm;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,25 +273,23 @@ IDRefsIterator::GetElem(const nsDependentSubstring& aID)
|
|||||||
// Check inside the binding the element is contained in.
|
// Check inside the binding the element is contained in.
|
||||||
nsIContent* bindingParent = mContent->GetBindingParent();
|
nsIContent* bindingParent = mContent->GetBindingParent();
|
||||||
if (bindingParent) {
|
if (bindingParent) {
|
||||||
nsIContent* refElm = bindingParent->OwnerDoc()->
|
nsIContent* refElm =
|
||||||
GetAnonymousElementByAttribute(bindingParent, nsGkAtoms::anonid, aID);
|
bindingParent->OwnerDoc()->GetAnonymousElementByAttribute(
|
||||||
|
bindingParent, nsGkAtoms::anonid, aID);
|
||||||
|
|
||||||
if (refElm)
|
if (refElm) return refElm;
|
||||||
return refElm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check inside the binding of the element.
|
// Check inside the binding of the element.
|
||||||
if (mContent->GetXBLBinding()) {
|
if (mContent->GetXBLBinding()) {
|
||||||
return mContent->OwnerDoc()->
|
return mContent->OwnerDoc()->GetAnonymousElementByAttribute(
|
||||||
GetAnonymousElementByAttribute(mContent, nsGkAtoms::anonid, aID);
|
mContent, nsGkAtoms::anonid, aID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* IDRefsIterator::Next() {
|
||||||
IDRefsIterator::Next()
|
|
||||||
{
|
|
||||||
nsIContent* nextEl = nullptr;
|
nsIContent* nextEl = nullptr;
|
||||||
while ((nextEl = NextElem())) {
|
while ((nextEl = NextElem())) {
|
||||||
Accessible* acc = mDoc->GetAccessible(nextEl);
|
Accessible* acc = mDoc->GetAccessible(nextEl);
|
||||||
@@ -352,14 +300,11 @@ IDRefsIterator::Next()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// SingleAccIterator
|
// SingleAccIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Accessible*
|
Accessible* SingleAccIterator::Next() {
|
||||||
SingleAccIterator::Next()
|
|
||||||
{
|
|
||||||
RefPtr<Accessible> nextAcc;
|
RefPtr<Accessible> nextAcc;
|
||||||
mAcc.swap(nextAcc);
|
mAcc.swap(nextAcc);
|
||||||
if (!nextAcc || nextAcc->IsDefunct()) {
|
if (!nextAcc || nextAcc->IsDefunct()) {
|
||||||
@@ -368,14 +313,11 @@ SingleAccIterator::Next()
|
|||||||
return nextAcc;
|
return nextAcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ItemIterator
|
// ItemIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Accessible*
|
Accessible* ItemIterator::Next() {
|
||||||
ItemIterator::Next()
|
|
||||||
{
|
|
||||||
if (mContainer) {
|
if (mContainer) {
|
||||||
mAnchor = AccGroupInfo::FirstItemOf(mContainer);
|
mAnchor = AccGroupInfo::FirstItemOf(mContainer);
|
||||||
mContainer = nullptr;
|
mContainer = nullptr;
|
||||||
@@ -385,25 +327,23 @@ ItemIterator::Next()
|
|||||||
return mAnchor ? (mAnchor = AccGroupInfo::NextItemTo(mAnchor)) : nullptr;
|
return mAnchor ? (mAnchor = AccGroupInfo::NextItemTo(mAnchor)) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// XULTreeItemIterator
|
// XULTreeItemIterator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
XULTreeItemIterator::XULTreeItemIterator(const XULTreeAccessible* aXULTree,
|
XULTreeItemIterator::XULTreeItemIterator(const XULTreeAccessible* aXULTree,
|
||||||
nsITreeView* aTreeView,
|
nsITreeView* aTreeView,
|
||||||
int32_t aRowIdx) :
|
int32_t aRowIdx)
|
||||||
mXULTree(aXULTree), mTreeView(aTreeView), mRowCount(-1),
|
: mXULTree(aXULTree),
|
||||||
mContainerLevel(-1), mCurrRowIdx(aRowIdx + 1)
|
mTreeView(aTreeView),
|
||||||
{
|
mRowCount(-1),
|
||||||
|
mContainerLevel(-1),
|
||||||
|
mCurrRowIdx(aRowIdx + 1) {
|
||||||
mTreeView->GetRowCount(&mRowCount);
|
mTreeView->GetRowCount(&mRowCount);
|
||||||
if (aRowIdx != -1)
|
if (aRowIdx != -1) mTreeView->GetLevel(aRowIdx, &mContainerLevel);
|
||||||
mTreeView->GetLevel(aRowIdx, &mContainerLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* XULTreeItemIterator::Next() {
|
||||||
XULTreeItemIterator::Next()
|
|
||||||
{
|
|
||||||
while (mCurrRowIdx < mRowCount) {
|
while (mCurrRowIdx < mRowCount) {
|
||||||
int32_t level = 0;
|
int32_t level = 0;
|
||||||
mTreeView->GetLevel(mCurrRowIdx, &level);
|
mTreeView->GetLevel(mCurrRowIdx, &level);
|
||||||
@@ -411,7 +351,7 @@ XULTreeItemIterator::Next()
|
|||||||
if (level == mContainerLevel + 1)
|
if (level == mContainerLevel + 1)
|
||||||
return mXULTree->GetTreeItemAccessible(mCurrRowIdx++);
|
return mXULTree->GetTreeItemAccessible(mCurrRowIdx++);
|
||||||
|
|
||||||
if (level <= mContainerLevel) { // got level up
|
if (level <= mContainerLevel) { // got level up
|
||||||
mCurrRowIdx = mRowCount;
|
mCurrRowIdx = mRowCount;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,12 @@ namespace a11y {
|
|||||||
/**
|
/**
|
||||||
* AccIterable is a basic interface for iterators over accessibles.
|
* AccIterable is a basic interface for iterators over accessibles.
|
||||||
*/
|
*/
|
||||||
class AccIterable
|
class AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
virtual ~AccIterable() {}
|
||||||
virtual ~AccIterable() { }
|
|
||||||
virtual Accessible* Next() = 0;
|
virtual Accessible* Next() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Relation;
|
friend class Relation;
|
||||||
std::unique_ptr<AccIterable> mNextIter;
|
std::unique_ptr<AccIterable> mNextIter;
|
||||||
};
|
};
|
||||||
@@ -35,9 +34,8 @@ private:
|
|||||||
* Allows to iterate through accessible children or subtree complying with
|
* Allows to iterate through accessible children or subtree complying with
|
||||||
* filter function.
|
* filter function.
|
||||||
*/
|
*/
|
||||||
class AccIterator : public AccIterable
|
class AccIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
AccIterator(const Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
|
AccIterator(const Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
|
||||||
virtual ~AccIterator();
|
virtual ~AccIterator();
|
||||||
|
|
||||||
@@ -47,14 +45,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AccIterator();
|
AccIterator();
|
||||||
AccIterator(const AccIterator&);
|
AccIterator(const AccIterator&);
|
||||||
AccIterator& operator =(const AccIterator&);
|
AccIterator& operator=(const AccIterator&);
|
||||||
|
|
||||||
struct IteratorState
|
struct IteratorState {
|
||||||
{
|
explicit IteratorState(const Accessible* aParent,
|
||||||
explicit IteratorState(const Accessible* aParent, IteratorState* mParentState = nullptr);
|
IteratorState* mParentState = nullptr);
|
||||||
|
|
||||||
const Accessible* mParent;
|
const Accessible* mParent;
|
||||||
int32_t mIndex;
|
int32_t mIndex;
|
||||||
@@ -65,14 +63,12 @@ private:
|
|||||||
IteratorState* mState;
|
IteratorState* mState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to traverse through related accessibles that are pointing to the given
|
* Allows to traverse through related accessibles that are pointing to the given
|
||||||
* dependent accessible by relation attribute.
|
* dependent accessible by relation attribute.
|
||||||
*/
|
*/
|
||||||
class RelatedAccIterator : public AccIterable
|
class RelatedAccIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@@ -86,17 +82,17 @@ public:
|
|||||||
RelatedAccIterator(DocAccessible* aDocument, nsIContent* aDependentContent,
|
RelatedAccIterator(DocAccessible* aDocument, nsIContent* aDependentContent,
|
||||||
nsAtom* aRelAttr);
|
nsAtom* aRelAttr);
|
||||||
|
|
||||||
virtual ~RelatedAccIterator() { }
|
virtual ~RelatedAccIterator() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next related accessible for the given dependent accessible.
|
* Return next related accessible for the given dependent accessible.
|
||||||
*/
|
*/
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RelatedAccIterator();
|
RelatedAccIterator();
|
||||||
RelatedAccIterator(const RelatedAccIterator&);
|
RelatedAccIterator(const RelatedAccIterator&);
|
||||||
RelatedAccIterator& operator = (const RelatedAccIterator&);
|
RelatedAccIterator& operator=(const RelatedAccIterator&);
|
||||||
|
|
||||||
DocAccessible* mDocument;
|
DocAccessible* mDocument;
|
||||||
nsAtom* mRelAttr;
|
nsAtom* mRelAttr;
|
||||||
@@ -105,32 +101,27 @@ private:
|
|||||||
uint32_t mIndex;
|
uint32_t mIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to iterate through HTML labels associated with the given accessible.
|
* Used to iterate through HTML labels associated with the given accessible.
|
||||||
*/
|
*/
|
||||||
class HTMLLabelIterator : public AccIterable
|
class HTMLLabelIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
enum LabelFilter { eAllLabels, eSkipAncestorLabel };
|
||||||
enum LabelFilter {
|
|
||||||
eAllLabels,
|
|
||||||
eSkipAncestorLabel
|
|
||||||
};
|
|
||||||
|
|
||||||
HTMLLabelIterator(DocAccessible* aDocument, const Accessible* aAccessible,
|
HTMLLabelIterator(DocAccessible* aDocument, const Accessible* aAccessible,
|
||||||
LabelFilter aFilter = eAllLabels);
|
LabelFilter aFilter = eAllLabels);
|
||||||
|
|
||||||
virtual ~HTMLLabelIterator() { }
|
virtual ~HTMLLabelIterator() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next label accessible associated with the given element.
|
* Return next label accessible associated with the given element.
|
||||||
*/
|
*/
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLLabelIterator();
|
HTMLLabelIterator();
|
||||||
HTMLLabelIterator(const HTMLLabelIterator&);
|
HTMLLabelIterator(const HTMLLabelIterator&);
|
||||||
HTMLLabelIterator& operator = (const HTMLLabelIterator&);
|
HTMLLabelIterator& operator=(const HTMLLabelIterator&);
|
||||||
|
|
||||||
bool IsLabel(Accessible* aLabel);
|
bool IsLabel(Accessible* aLabel);
|
||||||
|
|
||||||
@@ -141,71 +132,65 @@ private:
|
|||||||
LabelFilter mLabelFilter;
|
LabelFilter mLabelFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to iterate through HTML outputs associated with the given element.
|
* Used to iterate through HTML outputs associated with the given element.
|
||||||
*/
|
*/
|
||||||
class HTMLOutputIterator : public AccIterable
|
class HTMLOutputIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
HTMLOutputIterator(DocAccessible* aDocument, nsIContent* aElement);
|
HTMLOutputIterator(DocAccessible* aDocument, nsIContent* aElement);
|
||||||
virtual ~HTMLOutputIterator() { }
|
virtual ~HTMLOutputIterator() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next output accessible associated with the given element.
|
* Return next output accessible associated with the given element.
|
||||||
*/
|
*/
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLOutputIterator();
|
HTMLOutputIterator();
|
||||||
HTMLOutputIterator(const HTMLOutputIterator&);
|
HTMLOutputIterator(const HTMLOutputIterator&);
|
||||||
HTMLOutputIterator& operator = (const HTMLOutputIterator&);
|
HTMLOutputIterator& operator=(const HTMLOutputIterator&);
|
||||||
|
|
||||||
RelatedAccIterator mRelIter;
|
RelatedAccIterator mRelIter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to iterate through XUL labels associated with the given element.
|
* Used to iterate through XUL labels associated with the given element.
|
||||||
*/
|
*/
|
||||||
class XULLabelIterator : public AccIterable
|
class XULLabelIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
XULLabelIterator(DocAccessible* aDocument, nsIContent* aElement);
|
XULLabelIterator(DocAccessible* aDocument, nsIContent* aElement);
|
||||||
virtual ~XULLabelIterator() { }
|
virtual ~XULLabelIterator() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next label accessible associated with the given element.
|
* Return next label accessible associated with the given element.
|
||||||
*/
|
*/
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XULLabelIterator();
|
XULLabelIterator();
|
||||||
XULLabelIterator(const XULLabelIterator&);
|
XULLabelIterator(const XULLabelIterator&);
|
||||||
XULLabelIterator& operator = (const XULLabelIterator&);
|
XULLabelIterator& operator=(const XULLabelIterator&);
|
||||||
|
|
||||||
RelatedAccIterator mRelIter;
|
RelatedAccIterator mRelIter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to iterate through XUL descriptions associated with the given element.
|
* Used to iterate through XUL descriptions associated with the given element.
|
||||||
*/
|
*/
|
||||||
class XULDescriptionIterator : public AccIterable
|
class XULDescriptionIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
XULDescriptionIterator(DocAccessible* aDocument, nsIContent* aElement);
|
XULDescriptionIterator(DocAccessible* aDocument, nsIContent* aElement);
|
||||||
virtual ~XULDescriptionIterator() { }
|
virtual ~XULDescriptionIterator() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next description accessible associated with the given element.
|
* Return next description accessible associated with the given element.
|
||||||
*/
|
*/
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XULDescriptionIterator();
|
XULDescriptionIterator();
|
||||||
XULDescriptionIterator(const XULDescriptionIterator&);
|
XULDescriptionIterator(const XULDescriptionIterator&);
|
||||||
XULDescriptionIterator& operator = (const XULDescriptionIterator&);
|
XULDescriptionIterator& operator=(const XULDescriptionIterator&);
|
||||||
|
|
||||||
RelatedAccIterator mRelIter;
|
RelatedAccIterator mRelIter;
|
||||||
};
|
};
|
||||||
@@ -215,12 +200,11 @@ private:
|
|||||||
* attribute. Note, any method used to iterate through IDs, elements, or
|
* attribute. Note, any method used to iterate through IDs, elements, or
|
||||||
* accessibles moves iterator to next position.
|
* accessibles moves iterator to next position.
|
||||||
*/
|
*/
|
||||||
class IDRefsIterator : public AccIterable
|
class IDRefsIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
IDRefsIterator(DocAccessible* aDoc, nsIContent* aContent,
|
IDRefsIterator(DocAccessible* aDoc, nsIContent* aContent,
|
||||||
nsAtom* aIDRefsAttr);
|
nsAtom* aIDRefsAttr);
|
||||||
virtual ~IDRefsIterator() { }
|
virtual ~IDRefsIterator() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next ID.
|
* Return next ID.
|
||||||
@@ -240,10 +224,10 @@ public:
|
|||||||
// AccIterable
|
// AccIterable
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IDRefsIterator();
|
IDRefsIterator();
|
||||||
IDRefsIterator(const IDRefsIterator&);
|
IDRefsIterator(const IDRefsIterator&);
|
||||||
IDRefsIterator operator = (const IDRefsIterator&);
|
IDRefsIterator operator=(const IDRefsIterator&);
|
||||||
|
|
||||||
nsString mIDs;
|
nsString mIDs;
|
||||||
nsIContent* mContent;
|
nsIContent* mContent;
|
||||||
@@ -251,66 +235,60 @@ private:
|
|||||||
nsAString::index_type mCurrIdx;
|
nsAString::index_type mCurrIdx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterator that points to a single accessible returning it on the first call
|
* Iterator that points to a single accessible returning it on the first call
|
||||||
* to Next().
|
* to Next().
|
||||||
*/
|
*/
|
||||||
class SingleAccIterator : public AccIterable
|
class SingleAccIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
explicit SingleAccIterator(Accessible* aTarget) : mAcc(aTarget) {}
|
||||||
explicit SingleAccIterator(Accessible* aTarget): mAcc(aTarget) { }
|
virtual ~SingleAccIterator() {}
|
||||||
virtual ~SingleAccIterator() { }
|
|
||||||
|
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SingleAccIterator();
|
SingleAccIterator();
|
||||||
SingleAccIterator(const SingleAccIterator&);
|
SingleAccIterator(const SingleAccIterator&);
|
||||||
SingleAccIterator& operator = (const SingleAccIterator&);
|
SingleAccIterator& operator=(const SingleAccIterator&);
|
||||||
|
|
||||||
RefPtr<Accessible> mAcc;
|
RefPtr<Accessible> mAcc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to iterate items of the given item container.
|
* Used to iterate items of the given item container.
|
||||||
*/
|
*/
|
||||||
class ItemIterator : public AccIterable
|
class ItemIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
explicit ItemIterator(const Accessible* aItemContainer)
|
||||||
explicit ItemIterator(const Accessible* aItemContainer) :
|
: mContainer(aItemContainer), mAnchor(nullptr) {}
|
||||||
mContainer(aItemContainer), mAnchor(nullptr) { }
|
virtual ~ItemIterator() {}
|
||||||
virtual ~ItemIterator() { }
|
|
||||||
|
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ItemIterator() = delete;
|
ItemIterator() = delete;
|
||||||
ItemIterator(const ItemIterator&) = delete;
|
ItemIterator(const ItemIterator&) = delete;
|
||||||
ItemIterator& operator = (const ItemIterator&) = delete;
|
ItemIterator& operator=(const ItemIterator&) = delete;
|
||||||
|
|
||||||
const Accessible* mContainer;
|
const Accessible* mContainer;
|
||||||
Accessible* mAnchor;
|
Accessible* mAnchor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to iterate through XUL tree items of the same level.
|
* Used to iterate through XUL tree items of the same level.
|
||||||
*/
|
*/
|
||||||
class XULTreeItemIterator : public AccIterable
|
class XULTreeItemIterator : public AccIterable {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
XULTreeItemIterator(const XULTreeAccessible* aXULTree, nsITreeView* aTreeView,
|
XULTreeItemIterator(const XULTreeAccessible* aXULTree, nsITreeView* aTreeView,
|
||||||
int32_t aRowIdx);
|
int32_t aRowIdx);
|
||||||
virtual ~XULTreeItemIterator() { }
|
virtual ~XULTreeItemIterator() {}
|
||||||
|
|
||||||
virtual Accessible* Next() override;
|
virtual Accessible* Next() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XULTreeItemIterator() = delete;
|
XULTreeItemIterator() = delete;
|
||||||
XULTreeItemIterator(const XULTreeItemIterator&) = delete;
|
XULTreeItemIterator(const XULTreeItemIterator&) = delete;
|
||||||
XULTreeItemIterator& operator = (const XULTreeItemIterator&) = delete;
|
XULTreeItemIterator& operator=(const XULTreeItemIterator&) = delete;
|
||||||
|
|
||||||
const XULTreeAccessible* mXULTree;
|
const XULTreeAccessible* mXULTree;
|
||||||
nsITreeView* mTreeView;
|
nsITreeView* mTreeView;
|
||||||
@@ -319,7 +297,7 @@ private:
|
|||||||
int32_t mCurrRowIdx;
|
int32_t mCurrRowIdx;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ enum AccGenericType {
|
|||||||
eLastAccGenericType = eText
|
eLastAccGenericType = eText
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif // mozilla_a11y_AccTypes_h
|
#endif // mozilla_a11y_AccTypes_h
|
||||||
|
|||||||
@@ -9,9 +9,7 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
AccessibleOrProxy
|
AccessibleOrProxy AccessibleOrProxy::Parent() const {
|
||||||
AccessibleOrProxy::Parent() const
|
|
||||||
{
|
|
||||||
if (IsAccessible()) {
|
if (IsAccessible()) {
|
||||||
return AsAccessible()->Parent();
|
return AsAccessible()->Parent();
|
||||||
}
|
}
|
||||||
@@ -29,5 +27,5 @@ AccessibleOrProxy::Parent() const
|
|||||||
return proxy->OuterDocOfRemoteBrowser();
|
return proxy->OuterDocOfRemoteBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace a11y
|
||||||
}
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -20,18 +20,16 @@ namespace a11y {
|
|||||||
* This class stores an Accessible* or a ProxyAccessible* in a safe manner
|
* This class stores an Accessible* or a ProxyAccessible* in a safe manner
|
||||||
* with size sizeof(void*).
|
* with size sizeof(void*).
|
||||||
*/
|
*/
|
||||||
class AccessibleOrProxy
|
class AccessibleOrProxy {
|
||||||
{
|
public:
|
||||||
public:
|
MOZ_IMPLICIT AccessibleOrProxy(Accessible* aAcc)
|
||||||
MOZ_IMPLICIT AccessibleOrProxy(Accessible* aAcc) :
|
: mBits(reinterpret_cast<uintptr_t>(aAcc)) {}
|
||||||
mBits(reinterpret_cast<uintptr_t>(aAcc)) {}
|
MOZ_IMPLICIT AccessibleOrProxy(ProxyAccessible* aProxy)
|
||||||
MOZ_IMPLICIT AccessibleOrProxy(ProxyAccessible* aProxy) :
|
: mBits(aProxy ? (reinterpret_cast<uintptr_t>(aProxy) | IS_PROXY) : 0) {}
|
||||||
mBits(aProxy ? (reinterpret_cast<uintptr_t>(aProxy) | IS_PROXY) : 0) {}
|
|
||||||
MOZ_IMPLICIT AccessibleOrProxy(decltype(nullptr)) : mBits(0) {}
|
MOZ_IMPLICIT AccessibleOrProxy(decltype(nullptr)) : mBits(0) {}
|
||||||
|
|
||||||
bool IsProxy() const { return mBits & IS_PROXY; }
|
bool IsProxy() const { return mBits & IS_PROXY; }
|
||||||
ProxyAccessible* AsProxy() const
|
ProxyAccessible* AsProxy() const {
|
||||||
{
|
|
||||||
if (IsProxy()) {
|
if (IsProxy()) {
|
||||||
return reinterpret_cast<ProxyAccessible*>(mBits & ~IS_PROXY);
|
return reinterpret_cast<ProxyAccessible*>(mBits & ~IS_PROXY);
|
||||||
}
|
}
|
||||||
@@ -40,8 +38,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsAccessible() const { return !IsProxy(); }
|
bool IsAccessible() const { return !IsProxy(); }
|
||||||
Accessible* AsAccessible() const
|
Accessible* AsAccessible() const {
|
||||||
{
|
|
||||||
if (IsAccessible()) {
|
if (IsAccessible()) {
|
||||||
return reinterpret_cast<Accessible*>(mBits);
|
return reinterpret_cast<Accessible*>(mBits);
|
||||||
}
|
}
|
||||||
@@ -51,8 +48,7 @@ public:
|
|||||||
|
|
||||||
bool IsNull() const { return mBits == 0; }
|
bool IsNull() const { return mBits == 0; }
|
||||||
|
|
||||||
uint32_t ChildCount() const
|
uint32_t ChildCount() const {
|
||||||
{
|
|
||||||
if (IsProxy()) {
|
if (IsProxy()) {
|
||||||
return AsProxy()->ChildrenCount();
|
return AsProxy()->ChildrenCount();
|
||||||
}
|
}
|
||||||
@@ -64,8 +60,7 @@ public:
|
|||||||
* Return the child object either an accessible or a proxied accessible at
|
* Return the child object either an accessible or a proxied accessible at
|
||||||
* the given index.
|
* the given index.
|
||||||
*/
|
*/
|
||||||
AccessibleOrProxy ChildAt(uint32_t aIdx)
|
AccessibleOrProxy ChildAt(uint32_t aIdx) {
|
||||||
{
|
|
||||||
if (IsProxy()) {
|
if (IsProxy()) {
|
||||||
return AsProxy()->ChildAt(aIdx);
|
return AsProxy()->ChildAt(aIdx);
|
||||||
}
|
}
|
||||||
@@ -76,8 +71,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Return the first child object.
|
* Return the first child object.
|
||||||
*/
|
*/
|
||||||
AccessibleOrProxy FirstChild()
|
AccessibleOrProxy FirstChild() {
|
||||||
{
|
|
||||||
if (IsProxy()) {
|
if (IsProxy()) {
|
||||||
return AsProxy()->FirstChild();
|
return AsProxy()->FirstChild();
|
||||||
}
|
}
|
||||||
@@ -88,8 +82,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Return the first child object.
|
* Return the first child object.
|
||||||
*/
|
*/
|
||||||
AccessibleOrProxy LastChild()
|
AccessibleOrProxy LastChild() {
|
||||||
{
|
|
||||||
if (IsProxy()) {
|
if (IsProxy()) {
|
||||||
return AsProxy()->LastChild();
|
return AsProxy()->LastChild();
|
||||||
}
|
}
|
||||||
@@ -97,8 +90,7 @@ public:
|
|||||||
return AsAccessible()->LastChild();
|
return AsAccessible()->LastChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
role Role() const
|
role Role() const {
|
||||||
{
|
|
||||||
if (IsProxy()) {
|
if (IsProxy()) {
|
||||||
return AsProxy()->Role();
|
return AsProxy()->Role();
|
||||||
}
|
}
|
||||||
@@ -112,12 +104,12 @@ public:
|
|||||||
uintptr_t Bits() const { return mBits; }
|
uintptr_t Bits() const { return mBits; }
|
||||||
void SetBits(uintptr_t aBits) { mBits = aBits; }
|
void SetBits(uintptr_t aBits) { mBits = aBits; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uintptr_t mBits;
|
uintptr_t mBits;
|
||||||
static const uintptr_t IS_PROXY = 0x1;
|
static const uintptr_t IS_PROXY = 0x1;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace a11y
|
||||||
}
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,16 +11,19 @@
|
|||||||
|
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, androidClass, nameRule) \
|
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, \
|
||||||
static_assert(static_cast<uint32_t>(roles::geckoRole) \
|
androidClass, nameRule) \
|
||||||
== static_cast<uint32_t>(nsIAccessibleRole::ROLE_ ## geckoRole), \
|
static_assert( \
|
||||||
"internal and xpcom roles differ!");
|
static_cast<uint32_t>(roles::geckoRole) == \
|
||||||
|
static_cast<uint32_t>(nsIAccessibleRole::ROLE_##geckoRole), \
|
||||||
|
"internal and xpcom roles differ!");
|
||||||
#include "RoleMap.h"
|
#include "RoleMap.h"
|
||||||
#undef ROLE
|
#undef ROLE
|
||||||
|
|
||||||
#define RELATIONTYPE(geckoType, stringType, atkType, msaaType, ia2Type) \
|
#define RELATIONTYPE(geckoType, stringType, atkType, msaaType, ia2Type) \
|
||||||
static_assert(static_cast<uint32_t>(RelationType::geckoType) \
|
static_assert( \
|
||||||
== static_cast<uint32_t>(nsIAccessibleRelation::RELATION_ ## geckoType), \
|
static_cast<uint32_t>(RelationType::geckoType) == \
|
||||||
"internal and xpcom relations differ!");
|
static_cast<uint32_t>(nsIAccessibleRelation::RELATION_##geckoType), \
|
||||||
|
"internal and xpcom relations differ!");
|
||||||
#include "RelationTypeMap.h"
|
#include "RelationTypeMap.h"
|
||||||
#undef RELATIONTYPE
|
#undef RELATIONTYPE
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mozilla/EventListenerManager.h"
|
#include "mozilla/EventListenerManager.h"
|
||||||
#include "mozilla/dom/Event.h" // for Event
|
#include "mozilla/dom/Event.h" // for Event
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsCURILoader.h"
|
#include "nsCURILoader.h"
|
||||||
#include "nsDocShellLoadTypes.h"
|
#include "nsDocShellLoadTypes.h"
|
||||||
@@ -39,37 +39,29 @@ using namespace mozilla::a11y;
|
|||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
StaticAutoPtr<nsTArray<DocAccessibleParent*>> DocManager::sRemoteDocuments;
|
StaticAutoPtr<nsTArray<DocAccessibleParent*>> DocManager::sRemoteDocuments;
|
||||||
nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>, xpcAccessibleDocument>*
|
nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>,
|
||||||
DocManager::sRemoteXPCDocumentCache = nullptr;
|
xpcAccessibleDocument>* DocManager::sRemoteXPCDocumentCache =
|
||||||
|
nullptr;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// DocManager
|
// DocManager
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DocManager::DocManager()
|
DocManager::DocManager() : mDocAccessibleCache(2), mXPCDocumentCache(0) {}
|
||||||
: mDocAccessibleCache(2), mXPCDocumentCache(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// DocManager public
|
// DocManager public
|
||||||
|
|
||||||
DocAccessible*
|
DocAccessible* DocManager::GetDocAccessible(nsIDocument* aDocument) {
|
||||||
DocManager::GetDocAccessible(nsIDocument* aDocument)
|
if (!aDocument) return nullptr;
|
||||||
{
|
|
||||||
if (!aDocument)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
DocAccessible* docAcc = GetExistingDocAccessible(aDocument);
|
DocAccessible* docAcc = GetExistingDocAccessible(aDocument);
|
||||||
if (docAcc)
|
if (docAcc) return docAcc;
|
||||||
return docAcc;
|
|
||||||
|
|
||||||
return CreateDocOrRootAccessible(aDocument);
|
return CreateDocOrRootAccessible(aDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* DocManager::FindAccessibleInCache(nsINode* aNode) const {
|
||||||
DocManager::FindAccessibleInCache(nsINode* aNode) const
|
|
||||||
{
|
|
||||||
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
|
||||||
DocAccessible* docAccessible = iter.UserData();
|
DocAccessible* docAccessible = iter.UserData();
|
||||||
NS_ASSERTION(docAccessible,
|
NS_ASSERTION(docAccessible,
|
||||||
@@ -85,9 +77,7 @@ DocManager::FindAccessibleInCache(nsINode* aNode) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocManager::RemoveFromXPCDocumentCache(DocAccessible* aDocument) {
|
||||||
DocManager::RemoveFromXPCDocumentCache(DocAccessible* aDocument)
|
|
||||||
{
|
|
||||||
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
|
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
|
||||||
if (xpcDoc) {
|
if (xpcDoc) {
|
||||||
xpcDoc->Shutdown();
|
xpcDoc->Shutdown();
|
||||||
@@ -99,10 +89,8 @@ DocManager::RemoveFromXPCDocumentCache(DocAccessible* aDocument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
|
||||||
DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
|
nsIDocument* aDOMDocument) {
|
||||||
nsIDocument* aDOMDocument)
|
|
||||||
{
|
|
||||||
// We need to remove listeners in both cases, when document is being shutdown
|
// We need to remove listeners in both cases, when document is being shutdown
|
||||||
// or when accessibility service is being shut down as well.
|
// or when accessibility service is being shut down as well.
|
||||||
RemoveListeners(aDOMDocument);
|
RemoveListeners(aDOMDocument);
|
||||||
@@ -117,9 +105,7 @@ DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
|
|||||||
mDocAccessibleCache.Remove(aDOMDocument);
|
mDocAccessibleCache.Remove(aDOMDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocManager::RemoveFromRemoteXPCDocumentCache(DocAccessibleParent* aDoc) {
|
||||||
DocManager::RemoveFromRemoteXPCDocumentCache(DocAccessibleParent* aDoc)
|
|
||||||
{
|
|
||||||
xpcAccessibleDocument* doc = GetCachedXPCDocument(aDoc);
|
xpcAccessibleDocument* doc = GetCachedXPCDocument(aDoc);
|
||||||
if (doc) {
|
if (doc) {
|
||||||
doc->Shutdown();
|
doc->Shutdown();
|
||||||
@@ -131,17 +117,12 @@ DocManager::RemoveFromRemoteXPCDocumentCache(DocAccessibleParent* aDoc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocManager::NotifyOfRemoteDocShutdown(DocAccessibleParent* aDoc) {
|
||||||
DocManager::NotifyOfRemoteDocShutdown(DocAccessibleParent* aDoc)
|
|
||||||
{
|
|
||||||
RemoveFromRemoteXPCDocumentCache(aDoc);
|
RemoveFromRemoteXPCDocumentCache(aDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
xpcAccessibleDocument*
|
xpcAccessibleDocument* DocManager::GetXPCDocument(DocAccessible* aDocument) {
|
||||||
DocManager::GetXPCDocument(DocAccessible* aDocument)
|
if (!aDocument) return nullptr;
|
||||||
{
|
|
||||||
if (!aDocument)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
|
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
|
||||||
if (!xpcDoc) {
|
if (!xpcDoc) {
|
||||||
@@ -151,9 +132,7 @@ DocManager::GetXPCDocument(DocAccessible* aDocument)
|
|||||||
return xpcDoc;
|
return xpcDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
xpcAccessibleDocument*
|
xpcAccessibleDocument* DocManager::GetXPCDocument(DocAccessibleParent* aDoc) {
|
||||||
DocManager::GetXPCDocument(DocAccessibleParent* aDoc)
|
|
||||||
{
|
|
||||||
xpcAccessibleDocument* doc = GetCachedXPCDocument(aDoc);
|
xpcAccessibleDocument* doc = GetCachedXPCDocument(aDoc);
|
||||||
if (doc) {
|
if (doc) {
|
||||||
return doc;
|
return doc;
|
||||||
@@ -161,20 +140,19 @@ DocManager::GetXPCDocument(DocAccessibleParent* aDoc)
|
|||||||
|
|
||||||
if (!sRemoteXPCDocumentCache) {
|
if (!sRemoteXPCDocumentCache) {
|
||||||
sRemoteXPCDocumentCache =
|
sRemoteXPCDocumentCache =
|
||||||
new nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>, xpcAccessibleDocument>;
|
new nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>,
|
||||||
|
xpcAccessibleDocument>;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc =
|
doc = new xpcAccessibleDocument(aDoc,
|
||||||
new xpcAccessibleDocument(aDoc, Interfaces::DOCUMENT | Interfaces::HYPERTEXT);
|
Interfaces::DOCUMENT | Interfaces::HYPERTEXT);
|
||||||
sRemoteXPCDocumentCache->Put(aDoc, doc);
|
sRemoteXPCDocumentCache->Put(aDoc, doc);
|
||||||
|
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool
|
bool DocManager::IsProcessingRefreshDriverNotification() const {
|
||||||
DocManager::IsProcessingRefreshDriverNotification() const
|
|
||||||
{
|
|
||||||
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
|
||||||
DocAccessible* docAccessible = iter.UserData();
|
DocAccessible* docAccessible = iter.UserData();
|
||||||
NS_ASSERTION(docAccessible,
|
NS_ASSERTION(docAccessible,
|
||||||
@@ -189,18 +167,14 @@ DocManager::IsProcessingRefreshDriverNotification() const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// DocManager protected
|
// DocManager protected
|
||||||
|
|
||||||
bool
|
bool DocManager::Init() {
|
||||||
DocManager::Init()
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIWebProgress> progress =
|
nsCOMPtr<nsIWebProgress> progress =
|
||||||
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
|
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
|
||||||
|
|
||||||
if (!progress)
|
if (!progress) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
progress->AddProgressListener(static_cast<nsIWebProgressListener*>(this),
|
progress->AddProgressListener(static_cast<nsIWebProgressListener*>(this),
|
||||||
nsIWebProgress::NOTIFY_STATE_DOCUMENT);
|
nsIWebProgress::NOTIFY_STATE_DOCUMENT);
|
||||||
@@ -208,14 +182,13 @@ DocManager::Init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocManager::Shutdown() {
|
||||||
DocManager::Shutdown()
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIWebProgress> progress =
|
nsCOMPtr<nsIWebProgress> progress =
|
||||||
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
|
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
|
||||||
|
|
||||||
if (progress)
|
if (progress)
|
||||||
progress->RemoveProgressListener(static_cast<nsIWebProgressListener*>(this));
|
progress->RemoveProgressListener(
|
||||||
|
static_cast<nsIWebProgressListener*>(this));
|
||||||
|
|
||||||
ClearDocCache();
|
ClearDocCache();
|
||||||
}
|
}
|
||||||
@@ -223,19 +196,15 @@ DocManager::Shutdown()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// nsISupports
|
// nsISupports
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(DocManager,
|
NS_IMPL_ISUPPORTS(DocManager, nsIWebProgressListener, nsIDOMEventListener,
|
||||||
nsIWebProgressListener,
|
|
||||||
nsIDOMEventListener,
|
|
||||||
nsISupportsWeakReference)
|
nsISupportsWeakReference)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// nsIWebProgressListener
|
// nsIWebProgressListener
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DocManager::OnStateChange(nsIWebProgress* aWebProgress,
|
DocManager::OnStateChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
|
||||||
nsIRequest* aRequest, uint32_t aStateFlags,
|
uint32_t aStateFlags, nsresult aStatus) {
|
||||||
nsresult aStatus)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aStateFlags & STATE_IS_DOCUMENT, "Other notifications excluded");
|
NS_ASSERTION(aStateFlags & STATE_IS_DOCUMENT, "Other notifications excluded");
|
||||||
|
|
||||||
if (nsAccessibilityService::IsShutdown() || !aWebProgress ||
|
if (nsAccessibilityService::IsShutdown() || !aWebProgress ||
|
||||||
@@ -274,8 +243,7 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
|
|||||||
if (aRequest) {
|
if (aRequest) {
|
||||||
uint32_t loadFlags = 0;
|
uint32_t loadFlags = 0;
|
||||||
aRequest->GetLoadFlags(&loadFlags);
|
aRequest->GetLoadFlags(&loadFlags);
|
||||||
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
|
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) eventType = 0;
|
||||||
eventType = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleDOMDocumentLoad(document, eventType);
|
HandleDOMDocumentLoad(document, eventType);
|
||||||
@@ -285,12 +253,12 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
|
|||||||
// Document loading was started.
|
// Document loading was started.
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eDocLoad))
|
if (logging::IsEnabled(logging::eDocLoad))
|
||||||
logging::DocLoad("start document loading", aWebProgress, aRequest, aStateFlags);
|
logging::DocLoad("start document loading", aWebProgress, aRequest,
|
||||||
|
aStateFlags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DocAccessible* docAcc = GetExistingDocAccessible(document);
|
DocAccessible* docAcc = GetExistingDocAccessible(document);
|
||||||
if (!docAcc)
|
if (!docAcc) return NS_OK;
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(DOMWindow));
|
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(DOMWindow));
|
||||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
|
||||||
@@ -299,8 +267,7 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
|
|||||||
bool isReloading = false;
|
bool isReloading = false;
|
||||||
uint32_t loadType;
|
uint32_t loadType;
|
||||||
docShell->GetLoadType(&loadType);
|
docShell->GetLoadType(&loadType);
|
||||||
if (loadType == LOAD_RELOAD_NORMAL ||
|
if (loadType == LOAD_RELOAD_NORMAL || loadType == LOAD_RELOAD_BYPASS_CACHE ||
|
||||||
loadType == LOAD_RELOAD_BYPASS_CACHE ||
|
|
||||||
loadType == LOAD_RELOAD_BYPASS_PROXY ||
|
loadType == LOAD_RELOAD_BYPASS_PROXY ||
|
||||||
loadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE ||
|
loadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE ||
|
||||||
loadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
|
loadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
|
||||||
@@ -312,42 +279,32 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DocManager::OnProgressChange(nsIWebProgress* aWebProgress,
|
DocManager::OnProgressChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
|
||||||
nsIRequest* aRequest,
|
int32_t aCurSelfProgress, int32_t aMaxSelfProgress,
|
||||||
int32_t aCurSelfProgress,
|
|
||||||
int32_t aMaxSelfProgress,
|
|
||||||
int32_t aCurTotalProgress,
|
int32_t aCurTotalProgress,
|
||||||
int32_t aMaxTotalProgress)
|
int32_t aMaxTotalProgress) {
|
||||||
{
|
|
||||||
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
|
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DocManager::OnLocationChange(nsIWebProgress* aWebProgress,
|
DocManager::OnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
|
||||||
nsIRequest* aRequest, nsIURI* aLocation,
|
nsIURI* aLocation, uint32_t aFlags) {
|
||||||
uint32_t aFlags)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
|
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DocManager::OnStatusChange(nsIWebProgress* aWebProgress,
|
DocManager::OnStatusChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
|
||||||
nsIRequest* aRequest, nsresult aStatus,
|
nsresult aStatus, const char16_t* aMessage) {
|
||||||
const char16_t* aMessage)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
|
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DocManager::OnSecurityChange(nsIWebProgress* aWebProgress,
|
DocManager::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest,
|
||||||
nsIRequest* aRequest,
|
uint32_t aOldState, uint32_t aState,
|
||||||
uint32_t aOldState,
|
const nsAString& aContentBlockingLogJSON) {
|
||||||
uint32_t aState,
|
|
||||||
const nsAString& aContentBlockingLogJSON)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
|
MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -356,15 +313,13 @@ DocManager::OnSecurityChange(nsIWebProgress* aWebProgress,
|
|||||||
// nsIDOMEventListener
|
// nsIDOMEventListener
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DocManager::HandleEvent(Event* aEvent)
|
DocManager::HandleEvent(Event* aEvent) {
|
||||||
{
|
|
||||||
nsAutoString type;
|
nsAutoString type;
|
||||||
aEvent->GetType(type);
|
aEvent->GetType(type);
|
||||||
|
|
||||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(aEvent->GetTarget());
|
nsCOMPtr<nsIDocument> document = do_QueryInterface(aEvent->GetTarget());
|
||||||
NS_ASSERTION(document, "pagehide or DOMContentLoaded for non document!");
|
NS_ASSERTION(document, "pagehide or DOMContentLoaded for non document!");
|
||||||
if (!document)
|
if (!document) return NS_OK;
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
if (type.EqualsLiteral("pagehide")) {
|
if (type.EqualsLiteral("pagehide")) {
|
||||||
// 'pagehide' event is registered on every DOM document we create an
|
// '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
|
// shutdown since we don't keep strong reference on chrome event target and
|
||||||
// listeners are removed automatically when chrome event target goes away.
|
// listeners are removed automatically when chrome event target goes away.
|
||||||
DocAccessible* docAccessible = GetExistingDocAccessible(document);
|
DocAccessible* docAccessible = GetExistingDocAccessible(document);
|
||||||
if (docAccessible)
|
if (docAccessible) docAccessible->Shutdown();
|
||||||
docAccessible->Shutdown();
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -408,26 +362,21 @@ DocManager::HandleEvent(Event* aEvent)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// DocManager private
|
// DocManager private
|
||||||
|
|
||||||
void
|
void DocManager::HandleDOMDocumentLoad(nsIDocument* aDocument,
|
||||||
DocManager::HandleDOMDocumentLoad(nsIDocument* aDocument,
|
uint32_t aLoadEventType) {
|
||||||
uint32_t aLoadEventType)
|
|
||||||
{
|
|
||||||
// Document accessible can be created before we were notified the DOM document
|
// 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.
|
// was loaded completely. However if it's not created yet then create it.
|
||||||
DocAccessible* docAcc = GetExistingDocAccessible(aDocument);
|
DocAccessible* docAcc = GetExistingDocAccessible(aDocument);
|
||||||
if (!docAcc) {
|
if (!docAcc) {
|
||||||
docAcc = CreateDocOrRootAccessible(aDocument);
|
docAcc = CreateDocOrRootAccessible(aDocument);
|
||||||
if (!docAcc)
|
if (!docAcc) return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
docAcc->NotifyOfLoad(aLoadEventType);
|
docAcc->NotifyOfLoad(aLoadEventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocManager::AddListeners(nsIDocument* aDocument,
|
||||||
DocManager::AddListeners(nsIDocument* aDocument,
|
bool aAddDOMContentLoadedListener) {
|
||||||
bool aAddDOMContentLoadedListener)
|
|
||||||
{
|
|
||||||
nsPIDOMWindowOuter* window = aDocument->GetWindow();
|
nsPIDOMWindowOuter* window = aDocument->GetWindow();
|
||||||
EventTarget* target = window->GetChromeEventHandler();
|
EventTarget* target = window->GetChromeEventHandler();
|
||||||
EventListenerManager* elm = target->GetOrCreateListenerManager();
|
EventListenerManager* elm = target->GetOrCreateListenerManager();
|
||||||
@@ -449,16 +398,12 @@ DocManager::AddListeners(nsIDocument* aDocument,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocManager::RemoveListeners(nsIDocument* aDocument) {
|
||||||
DocManager::RemoveListeners(nsIDocument* aDocument)
|
|
||||||
{
|
|
||||||
nsPIDOMWindowOuter* window = aDocument->GetWindow();
|
nsPIDOMWindowOuter* window = aDocument->GetWindow();
|
||||||
if (!window)
|
if (!window) return;
|
||||||
return;
|
|
||||||
|
|
||||||
EventTarget* target = window->GetChromeEventHandler();
|
EventTarget* target = window->GetChromeEventHandler();
|
||||||
if (!target)
|
if (!target) return;
|
||||||
return;
|
|
||||||
|
|
||||||
EventListenerManager* elm = target->GetOrCreateListenerManager();
|
EventListenerManager* elm = target->GetOrCreateListenerManager();
|
||||||
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
|
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
|
||||||
@@ -468,9 +413,7 @@ DocManager::RemoveListeners(nsIDocument* aDocument)
|
|||||||
TrustedEventsAtCapture());
|
TrustedEventsAtCapture());
|
||||||
}
|
}
|
||||||
|
|
||||||
DocAccessible*
|
DocAccessible* DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument) {
|
||||||
DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
|
|
||||||
{
|
|
||||||
// Ignore hidden documents, resource documents, static clone
|
// Ignore hidden documents, resource documents, static clone
|
||||||
// (printing) documents and documents without a docshell.
|
// (printing) documents and documents without a docshell.
|
||||||
if (!aDocument->IsVisibleConsideringAncestors() ||
|
if (!aDocument->IsVisibleConsideringAncestors() ||
|
||||||
@@ -491,8 +434,7 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
|
|||||||
|
|
||||||
// Ignore documents without presshell and not having root frame.
|
// Ignore documents without presshell and not having root frame.
|
||||||
nsIPresShell* presShell = aDocument->GetShell();
|
nsIPresShell* presShell = aDocument->GetShell();
|
||||||
if (!presShell || presShell->IsDestroying())
|
if (!presShell || presShell->IsDestroying()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
bool isRootDoc = nsCoreUtils::IsRootDocument(aDocument);
|
bool isRootDoc = nsCoreUtils::IsRootDocument(aDocument);
|
||||||
|
|
||||||
@@ -501,17 +443,15 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
|
|||||||
// XXXaaronl: ideally we would traverse the presshell chain. Since there's
|
// XXXaaronl: ideally we would traverse the presshell chain. Since there's
|
||||||
// no easy way to do that, we cheat and use the document hierarchy.
|
// no easy way to do that, we cheat and use the document hierarchy.
|
||||||
parentDocAcc = GetDocAccessible(aDocument->GetParentDocument());
|
parentDocAcc = GetDocAccessible(aDocument->GetParentDocument());
|
||||||
NS_ASSERTION(parentDocAcc,
|
NS_ASSERTION(parentDocAcc, "Can't create an accessible for the document!");
|
||||||
"Can't create an accessible for the document!");
|
if (!parentDocAcc) return nullptr;
|
||||||
if (!parentDocAcc)
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We only create root accessibles for the true root, otherwise create a
|
// We only create root accessibles for the true root, otherwise create a
|
||||||
// doc accessible.
|
// doc accessible.
|
||||||
RefPtr<DocAccessible> docAcc = isRootDoc ?
|
RefPtr<DocAccessible> docAcc =
|
||||||
new RootAccessibleWrap(aDocument, presShell) :
|
isRootDoc ? new RootAccessibleWrap(aDocument, presShell)
|
||||||
new DocAccessibleWrap(aDocument, presShell);
|
: new DocAccessibleWrap(aDocument, presShell);
|
||||||
|
|
||||||
// Cache the document accessible into document cache.
|
// Cache the document accessible into document cache.
|
||||||
mDocAccessibleCache.Put(aDocument, docAcc);
|
mDocAccessibleCache.Put(aDocument, docAcc);
|
||||||
@@ -553,9 +493,7 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// DocManager static
|
// DocManager static
|
||||||
|
|
||||||
void
|
void DocManager::ClearDocCache() {
|
||||||
DocManager::ClearDocCache()
|
|
||||||
{
|
|
||||||
while (mDocAccessibleCache.Count() > 0) {
|
while (mDocAccessibleCache.Count() > 0) {
|
||||||
auto iter = mDocAccessibleCache.Iter();
|
auto iter = mDocAccessibleCache.Iter();
|
||||||
MOZ_ASSERT(!iter.Done());
|
MOZ_ASSERT(!iter.Done());
|
||||||
@@ -581,19 +519,17 @@ DocManager::ClearDocCache()
|
|||||||
}
|
}
|
||||||
|
|
||||||
iter.Remove();
|
iter.Remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void DocManager::RemoteDocAdded(DocAccessibleParent* aDoc) {
|
||||||
DocManager::RemoteDocAdded(DocAccessibleParent* aDoc)
|
|
||||||
{
|
|
||||||
if (!sRemoteDocuments) {
|
if (!sRemoteDocuments) {
|
||||||
sRemoteDocuments = new nsTArray<DocAccessibleParent*>;
|
sRemoteDocuments = new nsTArray<DocAccessibleParent*>;
|
||||||
ClearOnShutdown(&sRemoteDocuments);
|
ClearOnShutdown(&sRemoteDocuments);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(!sRemoteDocuments->Contains(aDoc),
|
MOZ_ASSERT(!sRemoteDocuments->Contains(aDoc),
|
||||||
"How did we already have the doc!");
|
"How did we already have the doc!");
|
||||||
sRemoteDocuments->AppendElement(aDoc);
|
sRemoteDocuments->AppendElement(aDoc);
|
||||||
ProxyCreated(aDoc, Interfaces::DOCUMENT | Interfaces::HYPERTEXT);
|
ProxyCreated(aDoc, Interfaces::DOCUMENT | Interfaces::HYPERTEXT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,8 @@ class DocAccessibleParent;
|
|||||||
*/
|
*/
|
||||||
class DocManager : public nsIWebProgressListener,
|
class DocManager : public nsIWebProgressListener,
|
||||||
public nsIDOMEventListener,
|
public nsIDOMEventListener,
|
||||||
public nsSupportsWeakReference
|
public nsSupportsWeakReference {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
NS_DECL_THREADSAFE_ISUPPORTS
|
NS_DECL_THREADSAFE_ISUPPORTS
|
||||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||||
NS_DECL_NSIDOMEVENTLISTENER
|
NS_DECL_NSIDOMEVENTLISTENER
|
||||||
@@ -42,14 +41,11 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Return document accessible for the given presshell.
|
* Return document accessible for the given presshell.
|
||||||
*/
|
*/
|
||||||
DocAccessible* GetDocAccessible(const nsIPresShell* aPresShell)
|
DocAccessible* GetDocAccessible(const nsIPresShell* aPresShell) {
|
||||||
{
|
if (!aPresShell) return nullptr;
|
||||||
if (!aPresShell)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
DocAccessible* doc = aPresShell->GetDocAccessible();
|
DocAccessible* doc = aPresShell->GetDocAccessible();
|
||||||
if (doc)
|
if (doc) return doc;
|
||||||
return doc;
|
|
||||||
|
|
||||||
return GetDocAccessible(aPresShell->GetDocument());
|
return GetDocAccessible(aPresShell->GetDocument());
|
||||||
}
|
}
|
||||||
@@ -72,14 +68,14 @@ public:
|
|||||||
* Return XPCOM accessible document.
|
* Return XPCOM accessible document.
|
||||||
*/
|
*/
|
||||||
xpcAccessibleDocument* GetXPCDocument(DocAccessible* aDocument);
|
xpcAccessibleDocument* GetXPCDocument(DocAccessible* aDocument);
|
||||||
xpcAccessibleDocument* GetCachedXPCDocument(DocAccessible* aDocument) const
|
xpcAccessibleDocument* GetCachedXPCDocument(DocAccessible* aDocument) const {
|
||||||
{ return mXPCDocumentCache.GetWeak(aDocument); }
|
return mXPCDocumentCache.GetWeak(aDocument);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Notification that a top level document in a content process has gone away.
|
* 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);
|
DebugOnly<bool> result = sRemoteDocuments->RemoveElement(aDoc);
|
||||||
MOZ_ASSERT(result, "Why didn't we find the document!");
|
MOZ_ASSERT(result, "Why didn't we find the document!");
|
||||||
}
|
}
|
||||||
@@ -89,8 +85,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
static void RemoteDocAdded(DocAccessibleParent* aDoc);
|
static void RemoteDocAdded(DocAccessibleParent* aDoc);
|
||||||
|
|
||||||
static const nsTArray<DocAccessibleParent*>* TopLevelRemoteDocs()
|
static const nsTArray<DocAccessibleParent*>* TopLevelRemoteDocs() {
|
||||||
{ return sRemoteDocuments; }
|
return sRemoteDocuments;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the xpc document for a remote document if there is one.
|
* Remove the xpc document for a remote document if there is one.
|
||||||
@@ -103,19 +100,19 @@ public:
|
|||||||
* Get a XPC document for a remote document.
|
* Get a XPC document for a remote document.
|
||||||
*/
|
*/
|
||||||
static xpcAccessibleDocument* GetXPCDocument(DocAccessibleParent* aDoc);
|
static xpcAccessibleDocument* GetXPCDocument(DocAccessibleParent* aDoc);
|
||||||
static xpcAccessibleDocument* GetCachedXPCDocument(const DocAccessibleParent* aDoc)
|
static xpcAccessibleDocument* GetCachedXPCDocument(
|
||||||
{
|
const DocAccessibleParent* aDoc) {
|
||||||
return sRemoteXPCDocumentCache ? sRemoteXPCDocumentCache->GetWeak(aDoc)
|
return sRemoteXPCDocumentCache ? sRemoteXPCDocumentCache->GetWeak(aDoc)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool IsProcessingRefreshDriverNotification() const;
|
bool IsProcessingRefreshDriverNotification() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DocManager();
|
DocManager();
|
||||||
virtual ~DocManager() { }
|
virtual ~DocManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the manager.
|
* Initialize the manager.
|
||||||
@@ -127,17 +124,16 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
bool HasXPCDocuments()
|
bool HasXPCDocuments() {
|
||||||
{
|
|
||||||
return mXPCDocumentCache.Count() > 0 ||
|
return mXPCDocumentCache.Count() > 0 ||
|
||||||
(sRemoteXPCDocumentCache && sRemoteXPCDocumentCache->Count() > 0);
|
(sRemoteXPCDocumentCache && sRemoteXPCDocumentCache->Count() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DocManager(const DocManager&);
|
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
|
* Create an accessible document if it was't created and fire accessibility
|
||||||
* events if needed.
|
* events if needed.
|
||||||
@@ -146,13 +142,12 @@ private:
|
|||||||
* @param aLoadEventType [in] specifies the event type to fire load event,
|
* @param aLoadEventType [in] specifies the event type to fire load event,
|
||||||
* if 0 then no event is fired
|
* if 0 then no event is fired
|
||||||
*/
|
*/
|
||||||
void HandleDOMDocumentLoad(nsIDocument* aDocument,
|
void HandleDOMDocumentLoad(nsIDocument* aDocument, uint32_t aLoadEventType);
|
||||||
uint32_t aLoadEventType);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add/remove 'pagehide' and 'DOMContentLoaded' event listeners.
|
* Add/remove 'pagehide' and 'DOMContentLoaded' event listeners.
|
||||||
*/
|
*/
|
||||||
void AddListeners(nsIDocument *aDocument, bool aAddPageShowListener);
|
void AddListeners(nsIDocument* aDocument, bool aAddPageShowListener);
|
||||||
void RemoveListeners(nsIDocument* aDocument);
|
void RemoveListeners(nsIDocument* aDocument);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,14 +161,15 @@ private:
|
|||||||
void ClearDocCache();
|
void ClearDocCache();
|
||||||
|
|
||||||
typedef nsRefPtrHashtable<nsPtrHashKey<const nsIDocument>, DocAccessible>
|
typedef nsRefPtrHashtable<nsPtrHashKey<const nsIDocument>, DocAccessible>
|
||||||
DocAccessibleHashtable;
|
DocAccessibleHashtable;
|
||||||
DocAccessibleHashtable mDocAccessibleCache;
|
DocAccessibleHashtable mDocAccessibleCache;
|
||||||
|
|
||||||
typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>, xpcAccessibleDocument>
|
typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>,
|
||||||
XPCDocumentHashtable;
|
xpcAccessibleDocument>
|
||||||
|
XPCDocumentHashtable;
|
||||||
XPCDocumentHashtable mXPCDocumentCache;
|
XPCDocumentHashtable mXPCDocumentCache;
|
||||||
static nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>, xpcAccessibleDocument>*
|
static nsRefPtrHashtable<nsPtrHashKey<const DocAccessibleParent>,
|
||||||
sRemoteXPCDocumentCache;
|
xpcAccessibleDocument>* sRemoteXPCDocumentCache;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The list of remote top level documents.
|
* The list of remote top level documents.
|
||||||
@@ -186,14 +182,12 @@ private:
|
|||||||
* Note this returns the doc accessible for the primary pres shell if there is
|
* Note this returns the doc accessible for the primary pres shell if there is
|
||||||
* more than one.
|
* more than one.
|
||||||
*/
|
*/
|
||||||
inline DocAccessible*
|
inline DocAccessible* GetExistingDocAccessible(const nsIDocument* aDocument) {
|
||||||
GetExistingDocAccessible(const nsIDocument* aDocument)
|
|
||||||
{
|
|
||||||
nsIPresShell* ps = aDocument->GetShell();
|
nsIPresShell* ps = aDocument->GetShell();
|
||||||
return ps ? ps->GetDocAccessible() : nullptr;
|
return ps ? ps->GetDocAccessible() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif // mozilla_a11_DocManager_h_
|
#endif // mozilla_a11_DocManager_h_
|
||||||
|
|||||||
@@ -8,73 +8,55 @@
|
|||||||
|
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
uint32_t
|
uint32_t EmbeddedObjCollector::Count() {
|
||||||
EmbeddedObjCollector::Count()
|
|
||||||
{
|
|
||||||
EnsureNGetIndex(nullptr);
|
EnsureNGetIndex(nullptr);
|
||||||
return mObjects.Length();
|
return mObjects.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* EmbeddedObjCollector::GetAccessibleAt(uint32_t aIndex) {
|
||||||
EmbeddedObjCollector::GetAccessibleAt(uint32_t aIndex)
|
|
||||||
{
|
|
||||||
Accessible* accessible = mObjects.SafeElementAt(aIndex, nullptr);
|
Accessible* accessible = mObjects.SafeElementAt(aIndex, nullptr);
|
||||||
if (accessible)
|
if (accessible) return accessible;
|
||||||
return accessible;
|
|
||||||
|
|
||||||
return EnsureNGetObject(aIndex);
|
return EnsureNGetObject(aIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* EmbeddedObjCollector::EnsureNGetObject(uint32_t aIndex) {
|
||||||
EmbeddedObjCollector::EnsureNGetObject(uint32_t aIndex)
|
|
||||||
{
|
|
||||||
uint32_t childCount = mRoot->ChildCount();
|
uint32_t childCount = mRoot->ChildCount();
|
||||||
while (mRootChildIdx < childCount) {
|
while (mRootChildIdx < childCount) {
|
||||||
Accessible* child = mRoot->GetChildAt(mRootChildIdx++);
|
Accessible* child = mRoot->GetChildAt(mRootChildIdx++);
|
||||||
if (child->IsText())
|
if (child->IsText()) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
AppendObject(child);
|
AppendObject(child);
|
||||||
if (mObjects.Length() - 1 == aIndex)
|
if (mObjects.Length() - 1 == aIndex) return mObjects[aIndex];
|
||||||
return mObjects[aIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t EmbeddedObjCollector::EnsureNGetIndex(Accessible* aAccessible) {
|
||||||
EmbeddedObjCollector::EnsureNGetIndex(Accessible* aAccessible)
|
|
||||||
{
|
|
||||||
uint32_t childCount = mRoot->ChildCount();
|
uint32_t childCount = mRoot->ChildCount();
|
||||||
while (mRootChildIdx < childCount) {
|
while (mRootChildIdx < childCount) {
|
||||||
Accessible* child = mRoot->GetChildAt(mRootChildIdx++);
|
Accessible* child = mRoot->GetChildAt(mRootChildIdx++);
|
||||||
if (child->IsText())
|
if (child->IsText()) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
AppendObject(child);
|
AppendObject(child);
|
||||||
if (child == aAccessible)
|
if (child == aAccessible) return mObjects.Length() - 1;
|
||||||
return mObjects.Length() - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t EmbeddedObjCollector::GetIndexAt(Accessible* aAccessible) {
|
||||||
EmbeddedObjCollector::GetIndexAt(Accessible* aAccessible)
|
if (aAccessible->mParent != mRoot) return -1;
|
||||||
{
|
|
||||||
if (aAccessible->mParent != mRoot)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
MOZ_ASSERT(!aAccessible->IsProxy());
|
MOZ_ASSERT(!aAccessible->IsProxy());
|
||||||
if (aAccessible->mInt.mIndexOfEmbeddedChild != -1)
|
if (aAccessible->mInt.mIndexOfEmbeddedChild != -1)
|
||||||
return aAccessible->mInt.mIndexOfEmbeddedChild;
|
return aAccessible->mInt.mIndexOfEmbeddedChild;
|
||||||
|
|
||||||
return !aAccessible->IsText() ? EnsureNGetIndex(aAccessible) : -1;
|
return !aAccessible->IsText() ? EnsureNGetIndex(aAccessible) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void EmbeddedObjCollector::AppendObject(Accessible* aAccessible) {
|
||||||
EmbeddedObjCollector::AppendObject(Accessible* aAccessible)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!aAccessible->IsProxy());
|
MOZ_ASSERT(!aAccessible->IsProxy());
|
||||||
aAccessible->mInt.mIndexOfEmbeddedChild = mObjects.Length();
|
aAccessible->mInt.mIndexOfEmbeddedChild = mObjects.Length();
|
||||||
mObjects.AppendElement(aAccessible);
|
mObjects.AppendElement(aAccessible);
|
||||||
|
|||||||
@@ -16,10 +16,9 @@ class Accessible;
|
|||||||
* Collect embedded objects. Provide quick access to accessible by index and
|
* Collect embedded objects. Provide quick access to accessible by index and
|
||||||
* vice versa.
|
* vice versa.
|
||||||
*/
|
*/
|
||||||
class EmbeddedObjCollector final
|
class EmbeddedObjCollector final {
|
||||||
{
|
public:
|
||||||
public:
|
~EmbeddedObjCollector() {}
|
||||||
~EmbeddedObjCollector() { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return index of the given accessible within the collection.
|
* Return index of the given accessible within the collection.
|
||||||
@@ -36,7 +35,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
Accessible* GetAccessibleAt(uint32_t aIndex);
|
Accessible* GetAccessibleAt(uint32_t aIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Ensure accessible at the given index is stored and return it.
|
* Ensure accessible at the given index is stored and return it.
|
||||||
*/
|
*/
|
||||||
@@ -48,8 +47,8 @@ protected:
|
|||||||
int32_t EnsureNGetIndex(Accessible* aAccessible);
|
int32_t EnsureNGetIndex(Accessible* aAccessible);
|
||||||
|
|
||||||
// Make sure it's used by Accessible class only.
|
// Make sure it's used by Accessible class only.
|
||||||
explicit EmbeddedObjCollector(Accessible* aRoot) :
|
explicit EmbeddedObjCollector(Accessible* aRoot)
|
||||||
mRoot(aRoot), mRootChildIdx(0) {}
|
: mRoot(aRoot), mRootChildIdx(0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append the object to collection.
|
* Append the object to collection.
|
||||||
@@ -63,7 +62,7 @@ protected:
|
|||||||
nsTArray<Accessible*> mObjects;
|
nsTArray<Accessible*> mObjects;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,15 +26,12 @@ const unsigned int kSelChangeCountToPack = 5;
|
|||||||
// EventQueue
|
// EventQueue
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool
|
bool EventQueue::PushEvent(AccEvent* aEvent) {
|
||||||
EventQueue::PushEvent(AccEvent* aEvent)
|
|
||||||
{
|
|
||||||
NS_ASSERTION((aEvent->mAccessible && aEvent->mAccessible->IsApplication()) ||
|
NS_ASSERTION((aEvent->mAccessible && aEvent->mAccessible->IsApplication()) ||
|
||||||
aEvent->Document() == mDocument,
|
aEvent->Document() == mDocument,
|
||||||
"Queued event belongs to another document!");
|
"Queued event belongs to another document!");
|
||||||
|
|
||||||
if (!mEvents.AppendElement(aEvent))
|
if (!mEvents.AppendElement(aEvent)) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
// Filter events.
|
// Filter events.
|
||||||
CoalesceEvents();
|
CoalesceEvents();
|
||||||
@@ -48,9 +45,7 @@ EventQueue::PushEvent(AccEvent* aEvent)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool EventQueue::PushNameChange(Accessible* aTarget) {
|
||||||
EventQueue::PushNameChange(Accessible* aTarget)
|
|
||||||
{
|
|
||||||
// Fire name change event on parent given that this event hasn't been
|
// 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
|
// coalesced, the parent's name was calculated from its subtree, and the
|
||||||
// subtree was changed.
|
// subtree was changed.
|
||||||
@@ -67,7 +62,7 @@ EventQueue::PushNameChange(Accessible* aTarget)
|
|||||||
// If name is obtained from subtree, fire name change event.
|
// If name is obtained from subtree, fire name change event.
|
||||||
if (nameFlag == eNameFromSubtree) {
|
if (nameFlag == eNameFromSubtree) {
|
||||||
RefPtr<AccEvent> nameChangeEvent =
|
RefPtr<AccEvent> nameChangeEvent =
|
||||||
new AccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, parent);
|
new AccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, parent);
|
||||||
return PushEvent(nameChangeEvent);
|
return PushEvent(nameChangeEvent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -81,60 +76,55 @@ EventQueue::PushNameChange(Accessible* aTarget)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// EventQueue: private
|
// EventQueue: private
|
||||||
|
|
||||||
void
|
void EventQueue::CoalesceEvents() {
|
||||||
EventQueue::CoalesceEvents()
|
|
||||||
{
|
|
||||||
NS_ASSERTION(mEvents.Length(), "There should be at least one pending event!");
|
NS_ASSERTION(mEvents.Length(), "There should be at least one pending event!");
|
||||||
uint32_t tail = mEvents.Length() - 1;
|
uint32_t tail = mEvents.Length() - 1;
|
||||||
AccEvent* tailEvent = mEvents[tail];
|
AccEvent* tailEvent = mEvents[tail];
|
||||||
|
|
||||||
switch(tailEvent->mEventRule) {
|
switch (tailEvent->mEventRule) {
|
||||||
case AccEvent::eCoalesceReorder:
|
case AccEvent::eCoalesceReorder: {
|
||||||
{
|
|
||||||
DebugOnly<Accessible*> target = tailEvent->mAccessible.get();
|
DebugOnly<Accessible*> target = tailEvent->mAccessible.get();
|
||||||
MOZ_ASSERT(target->IsApplication() ||
|
MOZ_ASSERT(
|
||||||
target->IsOuterDoc() ||
|
target->IsApplication() || target->IsOuterDoc() ||
|
||||||
target->IsXULTree(),
|
target->IsXULTree(),
|
||||||
"Only app or outerdoc accessible reorder events are in the queue");
|
"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,
|
||||||
break; // case eCoalesceReorder
|
"only reorder events should be queued");
|
||||||
|
break; // case eCoalesceReorder
|
||||||
}
|
}
|
||||||
|
|
||||||
case AccEvent::eCoalesceOfSameType:
|
case AccEvent::eCoalesceOfSameType: {
|
||||||
{
|
|
||||||
// Coalesce old events by newer event.
|
// Coalesce old events by newer event.
|
||||||
for (uint32_t index = tail - 1; index < tail; index--) {
|
for (uint32_t index = tail - 1; index < tail; index--) {
|
||||||
AccEvent* accEvent = mEvents[index];
|
AccEvent* accEvent = mEvents[index];
|
||||||
if (accEvent->mEventType == tailEvent->mEventType &&
|
if (accEvent->mEventType == tailEvent->mEventType &&
|
||||||
accEvent->mEventRule == tailEvent->mEventRule) {
|
accEvent->mEventRule == tailEvent->mEventRule) {
|
||||||
accEvent->mEventRule = AccEvent::eDoNotEmit;
|
accEvent->mEventRule = AccEvent::eDoNotEmit;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break; // case eCoalesceOfSameType
|
break; // case eCoalesceOfSameType
|
||||||
}
|
}
|
||||||
|
|
||||||
case AccEvent::eCoalesceSelectionChange:
|
case AccEvent::eCoalesceSelectionChange: {
|
||||||
{
|
|
||||||
AccSelChangeEvent* tailSelChangeEvent = downcast_accEvent(tailEvent);
|
AccSelChangeEvent* tailSelChangeEvent = downcast_accEvent(tailEvent);
|
||||||
for (uint32_t index = tail - 1; index < tail; index--) {
|
for (uint32_t index = tail - 1; index < tail; index--) {
|
||||||
AccEvent* thisEvent = mEvents[index];
|
AccEvent* thisEvent = mEvents[index];
|
||||||
if (thisEvent->mEventRule == tailEvent->mEventRule) {
|
if (thisEvent->mEventRule == tailEvent->mEventRule) {
|
||||||
AccSelChangeEvent* thisSelChangeEvent =
|
AccSelChangeEvent* thisSelChangeEvent = downcast_accEvent(thisEvent);
|
||||||
downcast_accEvent(thisEvent);
|
|
||||||
|
|
||||||
// Coalesce selection change events within same control.
|
// Coalesce selection change events within same control.
|
||||||
if (tailSelChangeEvent->mWidget == thisSelChangeEvent->mWidget) {
|
if (tailSelChangeEvent->mWidget == thisSelChangeEvent->mWidget) {
|
||||||
CoalesceSelChangeEvents(tailSelChangeEvent, thisSelChangeEvent, index);
|
CoalesceSelChangeEvents(tailSelChangeEvent, thisSelChangeEvent,
|
||||||
|
index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break; // eCoalesceSelectionChange
|
break; // eCoalesceSelectionChange
|
||||||
}
|
}
|
||||||
|
|
||||||
case AccEvent::eCoalesceStateChange:
|
case AccEvent::eCoalesceStateChange: {
|
||||||
{
|
|
||||||
// If state change event is duped then ignore previous event. If state
|
// If state change event is duped then ignore previous event. If state
|
||||||
// change event is opposite to previous event then no event is emitted
|
// change event is opposite to previous event then no event is emitted
|
||||||
// (accessible state wasn't changed).
|
// (accessible state wasn't changed).
|
||||||
@@ -152,11 +142,10 @@ EventQueue::CoalesceEvents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break; // eCoalesceStateChange
|
break; // eCoalesceStateChange
|
||||||
}
|
}
|
||||||
|
|
||||||
case AccEvent::eCoalesceTextSelChange:
|
case AccEvent::eCoalesceTextSelChange: {
|
||||||
{
|
|
||||||
// Coalesce older event by newer event for the same selection or target.
|
// Coalesce older event by newer event for the same selection or target.
|
||||||
// Events for same selection may have different targets and vice versa one
|
// Events for same selection may have different targets and vice versa one
|
||||||
// target may be pointed by different selections (for latter see
|
// target may be pointed by different selections (for latter see
|
||||||
@@ -171,37 +160,33 @@ EventQueue::CoalesceEvents()
|
|||||||
thisEvent->mAccessible == tailEvent->mAccessible)
|
thisEvent->mAccessible == tailEvent->mAccessible)
|
||||||
thisEvent->mEventRule = AccEvent::eDoNotEmit;
|
thisEvent->mEventRule = AccEvent::eDoNotEmit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break; // eCoalesceTextSelChange
|
break; // eCoalesceTextSelChange
|
||||||
}
|
}
|
||||||
|
|
||||||
case AccEvent::eRemoveDupes:
|
case AccEvent::eRemoveDupes: {
|
||||||
{
|
|
||||||
// Check for repeat events, coalesce newly appended event by more older
|
// Check for repeat events, coalesce newly appended event by more older
|
||||||
// event.
|
// event.
|
||||||
for (uint32_t index = tail - 1; index < tail; index--) {
|
for (uint32_t index = tail - 1; index < tail; index--) {
|
||||||
AccEvent* accEvent = mEvents[index];
|
AccEvent* accEvent = mEvents[index];
|
||||||
if (accEvent->mEventType == tailEvent->mEventType &&
|
if (accEvent->mEventType == tailEvent->mEventType &&
|
||||||
accEvent->mEventRule == tailEvent->mEventRule &&
|
accEvent->mEventRule == tailEvent->mEventRule &&
|
||||||
accEvent->mAccessible == tailEvent->mAccessible) {
|
accEvent->mAccessible == tailEvent->mAccessible) {
|
||||||
tailEvent->mEventRule = AccEvent::eDoNotEmit;
|
tailEvent->mEventRule = AccEvent::eDoNotEmit;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break; // case eRemoveDupes
|
break; // case eRemoveDupes
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break; // case eAllowDupes, eDoNotEmit
|
break; // case eAllowDupes, eDoNotEmit
|
||||||
} // switch
|
} // switch
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
|
||||||
EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
|
AccSelChangeEvent* aThisEvent,
|
||||||
AccSelChangeEvent* aThisEvent,
|
uint32_t aThisIndex) {
|
||||||
uint32_t aThisIndex)
|
|
||||||
{
|
|
||||||
aTailEvent->mPreceedingCount = aThisEvent->mPreceedingCount + 1;
|
aTailEvent->mPreceedingCount = aThisEvent->mPreceedingCount + 1;
|
||||||
|
|
||||||
// Pack all preceding events into single selection within event
|
// 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--) {
|
for (uint32_t jdx = aThisIndex - 1; jdx < aThisIndex; jdx--) {
|
||||||
AccEvent* prevEvent = mEvents[jdx];
|
AccEvent* prevEvent = mEvents[jdx];
|
||||||
if (prevEvent->mEventRule == aTailEvent->mEventRule) {
|
if (prevEvent->mEventRule == aTailEvent->mEventRule) {
|
||||||
AccSelChangeEvent* prevSelChangeEvent =
|
AccSelChangeEvent* prevSelChangeEvent = downcast_accEvent(prevEvent);
|
||||||
downcast_accEvent(prevEvent);
|
|
||||||
if (prevSelChangeEvent->mWidget == aTailEvent->mWidget)
|
if (prevSelChangeEvent->mWidget == aTailEvent->mWidget)
|
||||||
prevSelChangeEvent->mEventRule = AccEvent::eDoNotEmit;
|
prevSelChangeEvent->mEventRule = AccEvent::eDoNotEmit;
|
||||||
}
|
}
|
||||||
@@ -253,20 +237,20 @@ EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
|
|||||||
if (aThisEvent->mEventType == nsIAccessibleEvent::EVENT_SELECTION) {
|
if (aThisEvent->mEventType == nsIAccessibleEvent::EVENT_SELECTION) {
|
||||||
if (aThisEvent->mPackedEvent) {
|
if (aThisEvent->mPackedEvent) {
|
||||||
aThisEvent->mPackedEvent->mEventType =
|
aThisEvent->mPackedEvent->mEventType =
|
||||||
aThisEvent->mPackedEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd ?
|
aThisEvent->mPackedEvent->mSelChangeType ==
|
||||||
nsIAccessibleEvent::EVENT_SELECTION_ADD :
|
AccSelChangeEvent::eSelectionAdd
|
||||||
nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
|
? nsIAccessibleEvent::EVENT_SELECTION_ADD
|
||||||
|
: nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
|
||||||
|
|
||||||
aThisEvent->mPackedEvent->mEventRule =
|
aThisEvent->mPackedEvent->mEventRule = AccEvent::eCoalesceSelectionChange;
|
||||||
AccEvent::eCoalesceSelectionChange;
|
|
||||||
|
|
||||||
aThisEvent->mPackedEvent = nullptr;
|
aThisEvent->mPackedEvent = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
aThisEvent->mEventType =
|
aThisEvent->mEventType =
|
||||||
aThisEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd ?
|
aThisEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd
|
||||||
nsIAccessibleEvent::EVENT_SELECTION_ADD :
|
? nsIAccessibleEvent::EVENT_SELECTION_ADD
|
||||||
nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
|
: nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -280,9 +264,7 @@ EventQueue::CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// EventQueue: event queue
|
// EventQueue: event queue
|
||||||
|
|
||||||
void
|
void EventQueue::ProcessEventQueue() {
|
||||||
EventQueue::ProcessEventQueue()
|
|
||||||
{
|
|
||||||
// Process only currently queued events.
|
// Process only currently queued events.
|
||||||
nsTArray<RefPtr<AccEvent> > events;
|
nsTArray<RefPtr<AccEvent> > events;
|
||||||
events.SwapElements(mEvents);
|
events.SwapElements(mEvents);
|
||||||
@@ -300,8 +282,7 @@ EventQueue::ProcessEventQueue()
|
|||||||
AccEvent* event = events[idx];
|
AccEvent* event = events[idx];
|
||||||
if (event->mEventRule != AccEvent::eDoNotEmit) {
|
if (event->mEventRule != AccEvent::eDoNotEmit) {
|
||||||
Accessible* target = event->GetAccessible();
|
Accessible* target = event->GetAccessible();
|
||||||
if (!target || target->IsDefunct())
|
if (!target || target->IsDefunct()) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
// Dispatch the focus event if target is still focused.
|
// Dispatch the focus event if target is still focused.
|
||||||
if (event->mEventType == nsIAccessibleEvent::EVENT_FOCUS) {
|
if (event->mEventType == nsIAccessibleEvent::EVENT_FOCUS) {
|
||||||
@@ -310,38 +291,41 @@ EventQueue::ProcessEventQueue()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch caret moved and text selection change events.
|
// 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);
|
SelectionMgr()->ProcessTextSelChangeEvent(event);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire selected state change events in support to selection events.
|
// Fire selected state change events in support to selection events.
|
||||||
if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION_ADD) {
|
if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION_ADD) {
|
||||||
nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
|
nsEventShell::FireEvent(event->mAccessible, states::SELECTED, true,
|
||||||
true, event->mIsFromUserInput);
|
event->mIsFromUserInput);
|
||||||
|
|
||||||
} else if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION_REMOVE) {
|
} else if (event->mEventType ==
|
||||||
nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
|
nsIAccessibleEvent::EVENT_SELECTION_REMOVE) {
|
||||||
false, event->mIsFromUserInput);
|
nsEventShell::FireEvent(event->mAccessible, states::SELECTED, false,
|
||||||
|
event->mIsFromUserInput);
|
||||||
|
|
||||||
} else if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION) {
|
} else if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION) {
|
||||||
AccSelChangeEvent* selChangeEvent = downcast_accEvent(event);
|
AccSelChangeEvent* selChangeEvent = downcast_accEvent(event);
|
||||||
nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
|
nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
|
||||||
(selChangeEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd),
|
(selChangeEvent->mSelChangeType ==
|
||||||
|
AccSelChangeEvent::eSelectionAdd),
|
||||||
event->mIsFromUserInput);
|
event->mIsFromUserInput);
|
||||||
|
|
||||||
if (selChangeEvent->mPackedEvent) {
|
if (selChangeEvent->mPackedEvent) {
|
||||||
nsEventShell::FireEvent(selChangeEvent->mPackedEvent->mAccessible,
|
nsEventShell::FireEvent(
|
||||||
states::SELECTED,
|
selChangeEvent->mPackedEvent->mAccessible, states::SELECTED,
|
||||||
(selChangeEvent->mPackedEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd),
|
(selChangeEvent->mPackedEvent->mSelChangeType ==
|
||||||
selChangeEvent->mPackedEvent->mIsFromUserInput);
|
AccSelChangeEvent::eSelectionAdd),
|
||||||
|
selChangeEvent->mPackedEvent->mIsFromUserInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsEventShell::FireEvent(event);
|
nsEventShell::FireEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mDocument)
|
if (!mDocument) return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,9 @@ class DocAccessible;
|
|||||||
/**
|
/**
|
||||||
* Used to organize and coalesce pending events.
|
* Used to organize and coalesce pending events.
|
||||||
*/
|
*/
|
||||||
class EventQueue
|
class EventQueue {
|
||||||
{
|
protected:
|
||||||
protected:
|
explicit EventQueue(DocAccessible* aDocument) : mDocument(aDocument) {}
|
||||||
explicit EventQueue(DocAccessible* aDocument) : mDocument(aDocument) { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put an accessible event into the queue to process it later.
|
* Put an accessible event into the queue to process it later.
|
||||||
@@ -36,9 +35,9 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void ProcessEventQueue();
|
void ProcessEventQueue();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventQueue(const EventQueue&) = delete;
|
EventQueue(const EventQueue&) = delete;
|
||||||
EventQueue& operator = (const EventQueue&) = delete;
|
EventQueue& operator=(const EventQueue&) = delete;
|
||||||
|
|
||||||
// Event queue processing
|
// Event queue processing
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +57,7 @@ private:
|
|||||||
AccSelChangeEvent* aThisEvent,
|
AccSelChangeEvent* aThisEvent,
|
||||||
uint32_t aThisIndex);
|
uint32_t aThisIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* The document accessible reference owning this queue.
|
* The document accessible reference owning this queue.
|
||||||
*/
|
*/
|
||||||
@@ -71,7 +70,7 @@ protected:
|
|||||||
nsTArray<RefPtr<AccEvent>> mEvents;
|
nsTArray<RefPtr<AccEvent>> mEvents;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif // mozilla_a11y_EventQueue_h_
|
#endif // mozilla_a11y_EventQueue_h_
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ using namespace mozilla::a11y;
|
|||||||
|
|
||||||
EventTree* const TreeMutation::kNoEventTree = reinterpret_cast<EventTree*>(-1);
|
EventTree* const TreeMutation::kNoEventTree = reinterpret_cast<EventTree*>(-1);
|
||||||
|
|
||||||
TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents) :
|
TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents)
|
||||||
mParent(aParent), mStartIdx(UINT32_MAX),
|
: mParent(aParent),
|
||||||
mStateFlagsCopy(mParent->mStateFlags),
|
mStartIdx(UINT32_MAX),
|
||||||
mQueueEvents(!aNoEvents)
|
mStateFlagsCopy(mParent->mStateFlags),
|
||||||
{
|
mQueueEvents(!aNoEvents) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mIsDone = false;
|
mIsDone = false;
|
||||||
#endif
|
#endif
|
||||||
@@ -50,14 +50,11 @@ TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents) :
|
|||||||
mParent->mStateFlags |= Accessible::eKidsMutating;
|
mParent->mStateFlags |= Accessible::eKidsMutating;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeMutation::~TreeMutation()
|
TreeMutation::~TreeMutation() {
|
||||||
{
|
|
||||||
MOZ_ASSERT(mIsDone, "Done() must be called explicitly");
|
MOZ_ASSERT(mIsDone, "Done() must be called explicitly");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TreeMutation::AfterInsertion(Accessible* aChild) {
|
||||||
TreeMutation::AfterInsertion(Accessible* aChild)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aChild->Parent() == mParent);
|
MOZ_ASSERT(aChild->Parent() == mParent);
|
||||||
|
|
||||||
if (static_cast<uint32_t>(aChild->mIndexInParent) < mStartIdx) {
|
if (static_cast<uint32_t>(aChild->mIndexInParent) < mStartIdx) {
|
||||||
@@ -74,9 +71,7 @@ TreeMutation::AfterInsertion(Accessible* aChild)
|
|||||||
aChild->SetShowEventTarget(true);
|
aChild->SetShowEventTarget(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TreeMutation::BeforeRemoval(Accessible* aChild, bool aNoShutdown) {
|
||||||
TreeMutation::BeforeRemoval(Accessible* aChild, bool aNoShutdown)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aChild->Parent() == mParent);
|
MOZ_ASSERT(aChild->Parent() == mParent);
|
||||||
|
|
||||||
if (static_cast<uint32_t>(aChild->mIndexInParent) < mStartIdx) {
|
if (static_cast<uint32_t>(aChild->mIndexInParent) < mStartIdx) {
|
||||||
@@ -93,17 +88,16 @@ TreeMutation::BeforeRemoval(Accessible* aChild, bool aNoShutdown)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TreeMutation::Done() {
|
||||||
TreeMutation::Done()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(mParent->mStateFlags & Accessible::eKidsMutating);
|
MOZ_ASSERT(mParent->mStateFlags & Accessible::eKidsMutating);
|
||||||
mParent->mStateFlags &= ~Accessible::eKidsMutating;
|
mParent->mStateFlags &= ~Accessible::eKidsMutating;
|
||||||
|
|
||||||
uint32_t length = mParent->mChildren.Length();
|
uint32_t length = mParent->mChildren.Length();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (uint32_t idx = 0; idx < mStartIdx && idx < length; idx++) {
|
for (uint32_t idx = 0; idx < mStartIdx && idx < length; idx++) {
|
||||||
MOZ_ASSERT(mParent->mChildren[idx]->mIndexInParent == static_cast<int32_t>(idx),
|
MOZ_ASSERT(
|
||||||
"Wrong index detected");
|
mParent->mChildren[idx]->mIndexInParent == static_cast<int32_t>(idx),
|
||||||
|
"Wrong index detected");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -130,9 +124,7 @@ TreeMutation::Done()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
const char*
|
const char* TreeMutation::PrefixLog(void* aData, Accessible* aAcc) {
|
||||||
TreeMutation::PrefixLog(void* aData, Accessible* aAcc)
|
|
||||||
{
|
|
||||||
TreeMutation* thisObj = reinterpret_cast<TreeMutation*>(aData);
|
TreeMutation* thisObj = reinterpret_cast<TreeMutation*>(aData);
|
||||||
if (thisObj->mParent == aAcc) {
|
if (thisObj->mParent == aAcc) {
|
||||||
return "_X_";
|
return "_X_";
|
||||||
@@ -145,21 +137,16 @@ TreeMutation::PrefixLog(void* aData, Accessible* aAcc)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// EventTree
|
// EventTree
|
||||||
|
|
||||||
void
|
void EventTree::Shown(Accessible* aChild) {
|
||||||
EventTree::Shown(Accessible* aChild)
|
|
||||||
{
|
|
||||||
RefPtr<AccShowEvent> ev = new AccShowEvent(aChild);
|
RefPtr<AccShowEvent> ev = new AccShowEvent(aChild);
|
||||||
Controller(aChild)->WithdrawPrecedingEvents(&ev->mPrecedingEvents);
|
Controller(aChild)->WithdrawPrecedingEvents(&ev->mPrecedingEvents);
|
||||||
Mutated(ev);
|
Mutated(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void EventTree::Hidden(Accessible* aChild, bool aNeedsShutdown) {
|
||||||
EventTree::Hidden(Accessible* aChild, bool aNeedsShutdown)
|
|
||||||
{
|
|
||||||
RefPtr<AccHideEvent> ev = new AccHideEvent(aChild, aNeedsShutdown);
|
RefPtr<AccHideEvent> ev = new AccHideEvent(aChild, aNeedsShutdown);
|
||||||
if (!aNeedsShutdown) {
|
if (!aNeedsShutdown) {
|
||||||
Controller(aChild)->StorePrecedingEvent(ev);
|
Controller(aChild)->StorePrecedingEvent(ev);
|
||||||
@@ -167,9 +154,7 @@ EventTree::Hidden(Accessible* aChild, bool aNeedsShutdown)
|
|||||||
Mutated(ev);
|
Mutated(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void EventTree::Process(const RefPtr<DocAccessible>& aDeathGrip) {
|
||||||
EventTree::Process(const RefPtr<DocAccessible>& aDeathGrip)
|
|
||||||
{
|
|
||||||
while (mFirst) {
|
while (mFirst) {
|
||||||
// Skip a node and its subtree if its container is not in the document.
|
// Skip a node and its subtree if its container is not in the document.
|
||||||
if (mFirst->mContainer->IsInDocument()) {
|
if (mFirst->mContainer->IsInDocument()) {
|
||||||
@@ -250,9 +235,7 @@ EventTree::Process(const RefPtr<DocAccessible>& aDeathGrip)
|
|||||||
mDependentEvents.Clear();
|
mDependentEvents.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTree*
|
EventTree* EventTree::FindOrInsert(Accessible* aContainer) {
|
||||||
EventTree::FindOrInsert(Accessible* aContainer)
|
|
||||||
{
|
|
||||||
if (!mFirst) {
|
if (!mFirst) {
|
||||||
mFirst.reset(new EventTree(aContainer, mDependentEvents.IsEmpty()));
|
mFirst.reset(new EventTree(aContainer, mDependentEvents.IsEmpty()));
|
||||||
return mFirst.get();
|
return mFirst.get();
|
||||||
@@ -263,7 +246,8 @@ EventTree::FindOrInsert(Accessible* aContainer)
|
|||||||
do {
|
do {
|
||||||
MOZ_ASSERT(!node->mContainer->IsApplication(),
|
MOZ_ASSERT(!node->mContainer->IsApplication(),
|
||||||
"No event for application accessible is expected here");
|
"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.
|
// Case of same target.
|
||||||
if (node->mContainer == aContainer) {
|
if (node->mContainer == aContainer) {
|
||||||
@@ -289,7 +273,7 @@ EventTree::FindOrInsert(Accessible* aContainer)
|
|||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eEventTree)) {
|
if (logging::IsEnabled(logging::eEventTree)) {
|
||||||
logging::MsgBegin("EVENTS_TREE",
|
logging::MsgBegin("EVENTS_TREE",
|
||||||
"Rejecting node contained by show/hide");
|
"Rejecting node contained by show/hide");
|
||||||
logging::AccessibleInfo("Node", aContainer);
|
logging::AccessibleInfo("Node", aContainer);
|
||||||
logging::MsgEnd();
|
logging::MsgEnd();
|
||||||
}
|
}
|
||||||
@@ -298,8 +282,8 @@ EventTree::FindOrInsert(Accessible* aContainer)
|
|||||||
// on stack, and if so, then connect it to the parent show event.
|
// on stack, and if so, then connect it to the parent show event.
|
||||||
if (ev->IsShow()) {
|
if (ev->IsShow()) {
|
||||||
AccShowEvent* showEv = downcast_accEvent(ev);
|
AccShowEvent* showEv = downcast_accEvent(ev);
|
||||||
Controller(aContainer)->
|
Controller(aContainer)
|
||||||
WithdrawPrecedingEvents(&showEv->mPrecedingEvents);
|
->WithdrawPrecedingEvents(&showEv->mPrecedingEvents);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -314,8 +298,8 @@ EventTree::FindOrInsert(Accessible* aContainer)
|
|||||||
|
|
||||||
// If the given container contains a current node
|
// If the given container contains a current node
|
||||||
// then
|
// then
|
||||||
// if show or hide of the given node contains a grand parent of the current node
|
// if show or hide of the given node contains a grand parent of the
|
||||||
// then ignore the current node and its show and hide events
|
// 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
|
// otherwise ignore the current node, but not its show and hide events
|
||||||
Accessible* curParent = node->mContainer;
|
Accessible* curParent = node->mContainer;
|
||||||
while (curParent && !curParent->IsDoc()) {
|
while (curParent && !curParent->IsDoc()) {
|
||||||
@@ -328,7 +312,8 @@ EventTree::FindOrInsert(Accessible* aContainer)
|
|||||||
// its parent.
|
// its parent.
|
||||||
node->mFireReorder = false;
|
node->mFireReorder = false;
|
||||||
UniquePtr<EventTree>& nodeOwnerRef = prevNode ? prevNode->mNext : mFirst;
|
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);
|
newNode->mFirst = std::move(nodeOwnerRef);
|
||||||
nodeOwnerRef = std::move(newNode);
|
nodeOwnerRef = std::move(newNode);
|
||||||
nodeOwnerRef->mNext = std::move(node->mNext);
|
nodeOwnerRef->mNext = std::move(node->mNext);
|
||||||
@@ -381,9 +366,7 @@ EventTree::FindOrInsert(Accessible* aContainer)
|
|||||||
return prevNode->mNext.get();
|
return prevNode->mNext.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void EventTree::Clear() {
|
||||||
EventTree::Clear()
|
|
||||||
{
|
|
||||||
mFirst = nullptr;
|
mFirst = nullptr;
|
||||||
mNext = nullptr;
|
mNext = nullptr;
|
||||||
mContainer = nullptr;
|
mContainer = nullptr;
|
||||||
@@ -399,9 +382,7 @@ EventTree::Clear()
|
|||||||
mDependentEvents.Clear();
|
mDependentEvents.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const EventTree*
|
const EventTree* EventTree::Find(const Accessible* aContainer) const {
|
||||||
EventTree::Find(const Accessible* aContainer) const
|
|
||||||
{
|
|
||||||
const EventTree* et = this;
|
const EventTree* et = this;
|
||||||
while (et) {
|
while (et) {
|
||||||
if (et->mContainer == aContainer) {
|
if (et->mContainer == aContainer) {
|
||||||
@@ -427,9 +408,7 @@ EventTree::Find(const Accessible* aContainer) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
void
|
void EventTree::Log(uint32_t aLevel) const {
|
||||||
EventTree::Log(uint32_t aLevel) const
|
|
||||||
{
|
|
||||||
if (aLevel == UINT32_MAX) {
|
if (aLevel == UINT32_MAX) {
|
||||||
if (mFirst) {
|
if (mFirst) {
|
||||||
mFirst->Log(0);
|
mFirst->Log(0);
|
||||||
@@ -458,8 +437,7 @@ EventTree::Log(uint32_t aLevel) const
|
|||||||
logging::AccessibleInfo("preceding",
|
logging::AccessibleInfo("preceding",
|
||||||
showEv->mPrecedingEvents[i]->mAccessible);
|
showEv->mPrecedingEvents[i]->mAccessible);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (uint32_t i = 0; i < aLevel + 1; i++) {
|
for (uint32_t i = 0; i < aLevel + 1; i++) {
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
@@ -477,9 +455,7 @@ EventTree::Log(uint32_t aLevel) const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void EventTree::Mutated(AccMutationEvent* aEv) {
|
||||||
EventTree::Mutated(AccMutationEvent* aEv)
|
|
||||||
{
|
|
||||||
// If shown or hidden node is a root of previously mutated subtree, then
|
// 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.
|
// discard those subtree mutations as we are no longer interested in them.
|
||||||
UniquePtr<EventTree>* node = &mFirst;
|
UniquePtr<EventTree>* node = &mFirst;
|
||||||
@@ -507,8 +483,9 @@ EventTree::Mutated(AccMutationEvent* aEv)
|
|||||||
if (childEv->IsShow()) {
|
if (childEv->IsShow()) {
|
||||||
AccShowEvent* childShowEv = downcast_accEvent(childEv);
|
AccShowEvent* childShowEv = downcast_accEvent(childEv);
|
||||||
if (childShowEv->mPrecedingEvents.Length() > 0) {
|
if (childShowEv->mPrecedingEvents.Length() > 0) {
|
||||||
Controller(mContainer)->StorePrecedingEvents(
|
Controller(mContainer)
|
||||||
std::move(childShowEv->mPrecedingEvents));
|
->StorePrecedingEvents(
|
||||||
|
std::move(childShowEv->mPrecedingEvents));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -527,14 +504,17 @@ EventTree::Mutated(AccMutationEvent* aEv)
|
|||||||
if (logging::IsEnabled(logging::eEventTree)) {
|
if (logging::IsEnabled(logging::eEventTree)) {
|
||||||
logging::MsgBegin("EVENTS_TREE", "Adopt preceding events");
|
logging::MsgBegin("EVENTS_TREE", "Adopt preceding events");
|
||||||
logging::AccessibleInfo("Parent", aEv->mAccessible);
|
logging::AccessibleInfo("Parent", aEv->mAccessible);
|
||||||
for (uint32_t j = 0; j < showChildEv->mPrecedingEvents.Length(); j++) {
|
for (uint32_t j = 0;
|
||||||
logging::AccessibleInfo("Adoptee",
|
j < showChildEv->mPrecedingEvents.Length(); j++) {
|
||||||
showChildEv->mPrecedingEvents[i]->mAccessible);
|
logging::AccessibleInfo(
|
||||||
|
"Adoptee",
|
||||||
|
showChildEv->mPrecedingEvents[i]->mAccessible);
|
||||||
}
|
}
|
||||||
logging::MsgEnd();
|
logging::MsgEnd();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
showEv->mPrecedingEvents.AppendElements(showChildEv->mPrecedingEvents);
|
showEv->mPrecedingEvents.AppendElements(
|
||||||
|
showChildEv->mPrecedingEvents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -566,8 +546,7 @@ EventTree::Mutated(AccMutationEvent* aEv)
|
|||||||
|
|
||||||
if (prevHideEvent->mNextSibling == hideEvent->mAccessible) {
|
if (prevHideEvent->mNextSibling == hideEvent->mAccessible) {
|
||||||
hideEvent->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
|
hideEvent->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
|
||||||
}
|
} else if (prevHideEvent->mPrevSibling == hideEvent->mAccessible) {
|
||||||
else if (prevHideEvent->mPrevSibling == hideEvent->mAccessible) {
|
|
||||||
uint32_t oldLen = prevTextEvent->GetLength();
|
uint32_t oldLen = prevTextEvent->GetLength();
|
||||||
hideEvent->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
|
hideEvent->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
|
||||||
prevTextEvent->mStart -= prevTextEvent->GetLength() - oldLen;
|
prevTextEvent->mStart -= prevTextEvent->GetLength() - oldLen;
|
||||||
@@ -575,23 +554,22 @@ EventTree::Mutated(AccMutationEvent* aEv)
|
|||||||
|
|
||||||
hideEvent->mTextChangeEvent.swap(prevEvent->mTextChangeEvent);
|
hideEvent->mTextChangeEvent.swap(prevEvent->mTextChangeEvent);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
AccTextChangeEvent* prevTextEvent = prevEvent->mTextChangeEvent;
|
AccTextChangeEvent* prevTextEvent = prevEvent->mTextChangeEvent;
|
||||||
if (prevTextEvent) {
|
if (prevTextEvent) {
|
||||||
if (aEv->mAccessible->IndexInParent() ==
|
if (aEv->mAccessible->IndexInParent() ==
|
||||||
prevEvent->mAccessible->IndexInParent() + 1) {
|
prevEvent->mAccessible->IndexInParent() + 1) {
|
||||||
// If tail target was inserted after this target, i.e. tail target is next
|
// If tail target was inserted after this target, i.e. tail target is
|
||||||
// sibling of this target.
|
// next sibling of this target.
|
||||||
aEv->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
|
aEv->mAccessible->AppendTextTo(prevTextEvent->mModifiedText);
|
||||||
}
|
} else if (aEv->mAccessible->IndexInParent() ==
|
||||||
else if (aEv->mAccessible->IndexInParent() ==
|
prevEvent->mAccessible->IndexInParent() - 1) {
|
||||||
prevEvent->mAccessible->IndexInParent() - 1) {
|
|
||||||
// If tail target was inserted before this target, i.e. tail target is
|
// If tail target was inserted before this target, i.e. tail target is
|
||||||
// previous sibling of this target.
|
// previous sibling of this target.
|
||||||
nsAutoString startText;
|
nsAutoString startText;
|
||||||
aEv->mAccessible->AppendTextTo(startText);
|
aEv->mAccessible->AppendTextTo(startText);
|
||||||
prevTextEvent->mModifiedText = startText + prevTextEvent->mModifiedText;
|
prevTextEvent->mModifiedText =
|
||||||
|
startText + prevTextEvent->mModifiedText;
|
||||||
prevTextEvent->mStart -= startText.Length();
|
prevTextEvent->mStart -= startText.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,7 +592,7 @@ EventTree::Mutated(AccMutationEvent* aEv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t offset = mContainer->AsHyperText()->GetChildOffset(aEv->mAccessible);
|
int32_t offset = mContainer->AsHyperText()->GetChildOffset(aEv->mAccessible);
|
||||||
aEv->mTextChangeEvent =
|
aEv->mTextChangeEvent = new AccTextChangeEvent(
|
||||||
new AccTextChangeEvent(mContainer, offset, text, aEv->IsShow(),
|
mContainer, offset, text, aEv->IsShow(),
|
||||||
aEv->mIsFromUserInput ? eFromUserInput : eNoUserInput);
|
aEv->mIsFromUserInput ? eFromUserInput : eNoUserInput);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,8 @@ class NotificationController;
|
|||||||
* have an object of this class on the stack when calling methods that mutate
|
* have an object of this class on the stack when calling methods that mutate
|
||||||
* the accessible tree.
|
* the accessible tree.
|
||||||
*/
|
*/
|
||||||
class TreeMutation final
|
class TreeMutation final {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
static const bool kNoEvents = true;
|
static const bool kNoEvents = true;
|
||||||
static const bool kNoShutdown = true;
|
static const bool kNoShutdown = true;
|
||||||
|
|
||||||
@@ -37,9 +36,10 @@ public:
|
|||||||
void BeforeRemoval(Accessible* aChild, bool aNoShutdown = false);
|
void BeforeRemoval(Accessible* aChild, bool aNoShutdown = false);
|
||||||
void Done();
|
void Done();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NotificationController* Controller() const
|
NotificationController* Controller() const {
|
||||||
{ return mParent->Document()->Controller(); }
|
return mParent->Document()->Controller();
|
||||||
|
}
|
||||||
|
|
||||||
static EventTree* const kNoEventTree;
|
static EventTree* const kNoEventTree;
|
||||||
|
|
||||||
@@ -61,17 +61,21 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mutation events coalescence structure.
|
* A mutation events coalescence structure.
|
||||||
*/
|
*/
|
||||||
class EventTree final {
|
class EventTree final {
|
||||||
public:
|
public:
|
||||||
EventTree() :
|
EventTree()
|
||||||
mFirst(nullptr), mNext(nullptr), mContainer(nullptr), mFireReorder(false) { }
|
: mFirst(nullptr),
|
||||||
explicit EventTree(Accessible* aContainer, bool aFireReorder) :
|
mNext(nullptr),
|
||||||
mFirst(nullptr), mNext(nullptr), mContainer(aContainer),
|
mContainer(nullptr),
|
||||||
mFireReorder(aFireReorder) { }
|
mFireReorder(false) {}
|
||||||
|
explicit EventTree(Accessible* aContainer, bool aFireReorder)
|
||||||
|
: mFirst(nullptr),
|
||||||
|
mNext(nullptr),
|
||||||
|
mContainer(aContainer),
|
||||||
|
mFireReorder(aFireReorder) {}
|
||||||
~EventTree() { Clear(); }
|
~EventTree() { Clear(); }
|
||||||
|
|
||||||
void Shown(Accessible* aTarget);
|
void Shown(Accessible* aTarget);
|
||||||
@@ -91,7 +95,7 @@ public:
|
|||||||
void Log(uint32_t aLevel = UINT32_MAX) const;
|
void Log(uint32_t aLevel = UINT32_MAX) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Processes the event queue and fires events.
|
* Processes the event queue and fires events.
|
||||||
*/
|
*/
|
||||||
@@ -111,14 +115,14 @@ private:
|
|||||||
nsTArray<RefPtr<AccMutationEvent>> mDependentEvents;
|
nsTArray<RefPtr<AccMutationEvent>> mDependentEvents;
|
||||||
bool mFireReorder;
|
bool mFireReorder;
|
||||||
|
|
||||||
static NotificationController* Controller(Accessible* aAcc)
|
static NotificationController* Controller(Accessible* aAcc) {
|
||||||
{ return aAcc->Document()->Controller(); }
|
return aAcc->Document()->Controller();
|
||||||
|
}
|
||||||
|
|
||||||
friend class NotificationController;
|
friend class NotificationController;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace a11y
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
} // namespace a11y
|
#endif // mozilla_a11y_EventQueue_h_
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif // mozilla_a11y_EventQueue_h_
|
|
||||||
|
|||||||
@@ -12,40 +12,29 @@
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
using namespace mozilla::a11y::filters;
|
using namespace mozilla::a11y::filters;
|
||||||
|
|
||||||
uint32_t
|
uint32_t filters::GetSelected(Accessible* aAccessible) {
|
||||||
filters::GetSelected(Accessible* aAccessible)
|
if (aAccessible->State() & states::SELECTED) return eMatch | eSkipSubtree;
|
||||||
{
|
|
||||||
if (aAccessible->State() & states::SELECTED)
|
|
||||||
return eMatch | eSkipSubtree;
|
|
||||||
|
|
||||||
return eSkip;
|
return eSkip;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t filters::GetSelectable(Accessible* aAccessible) {
|
||||||
filters::GetSelectable(Accessible* aAccessible)
|
|
||||||
{
|
|
||||||
if (aAccessible->InteractiveState() & states::SELECTABLE)
|
if (aAccessible->InteractiveState() & states::SELECTABLE)
|
||||||
return eMatch | eSkipSubtree;
|
return eMatch | eSkipSubtree;
|
||||||
|
|
||||||
return eSkip;
|
return eSkip;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t filters::GetRow(Accessible* aAccessible) {
|
||||||
filters::GetRow(Accessible* aAccessible)
|
if (aAccessible->IsTableRow()) return eMatch | eSkipSubtree;
|
||||||
{
|
|
||||||
if (aAccessible->IsTableRow())
|
|
||||||
return eMatch | eSkipSubtree;
|
|
||||||
|
|
||||||
// Look for rows inside rowgroup.
|
// Look for rows inside rowgroup.
|
||||||
a11y::role role = aAccessible->Role();
|
a11y::role role = aAccessible->Role();
|
||||||
if (role == roles::GROUPING)
|
if (role == roles::GROUPING) return eSkip;
|
||||||
return eSkip;
|
|
||||||
|
|
||||||
return eSkipSubtree;
|
return eSkipSubtree;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t filters::GetCell(Accessible* aAccessible) {
|
||||||
filters::GetCell(Accessible* aAccessible)
|
|
||||||
{
|
|
||||||
return aAccessible->IsTableCell() ? eMatch : eSkipSubtree;
|
return aAccessible->IsTableCell() ? eMatch : eSkipSubtree;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,16 +17,12 @@ class Accessible;
|
|||||||
|
|
||||||
namespace filters {
|
namespace filters {
|
||||||
|
|
||||||
enum EResult {
|
enum EResult { eSkip = 0, eMatch = 1, eSkipSubtree = 2 };
|
||||||
eSkip = 0,
|
|
||||||
eMatch = 1,
|
|
||||||
eSkipSubtree = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the traversed accessible complies with filter.
|
* 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.
|
* Matches selected/selectable accessibles in subtree.
|
||||||
@@ -43,8 +39,8 @@ uint32_t GetRow(Accessible* aAccessible);
|
|||||||
* Matches cell accessibles in children.
|
* Matches cell accessibles in children.
|
||||||
*/
|
*/
|
||||||
uint32_t GetCell(Accessible* aAccessible);
|
uint32_t GetCell(Accessible* aAccessible);
|
||||||
} // namespace filters
|
} // namespace filters
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,35 +22,26 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
FocusManager::FocusManager()
|
FocusManager::FocusManager() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
FocusManager::~FocusManager()
|
FocusManager::~FocusManager() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Accessible*
|
Accessible* FocusManager::FocusedAccessible() const {
|
||||||
FocusManager::FocusedAccessible() const
|
if (mActiveItem) return mActiveItem;
|
||||||
{
|
|
||||||
if (mActiveItem)
|
|
||||||
return mActiveItem;
|
|
||||||
|
|
||||||
nsINode* focusedNode = FocusedDOMNode();
|
nsINode* focusedNode = FocusedDOMNode();
|
||||||
if (focusedNode) {
|
if (focusedNode) {
|
||||||
DocAccessible* doc =
|
DocAccessible* doc =
|
||||||
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
||||||
return doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr;
|
return doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode)
|
||||||
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool FocusManager::IsFocused(const Accessible* aAccessible) const {
|
||||||
FocusManager::IsFocused(const Accessible* aAccessible) const
|
if (mActiveItem) return mActiveItem == aAccessible;
|
||||||
{
|
|
||||||
if (mActiveItem)
|
|
||||||
return mActiveItem == aAccessible;
|
|
||||||
|
|
||||||
nsINode* focusedNode = FocusedDOMNode();
|
nsINode* focusedNode = FocusedDOMNode();
|
||||||
if (focusedNode) {
|
if (focusedNode) {
|
||||||
@@ -62,43 +53,37 @@ FocusManager::IsFocused(const Accessible* aAccessible) const
|
|||||||
// bug 638465.
|
// bug 638465.
|
||||||
if (focusedNode->OwnerDoc() == aAccessible->GetNode()->OwnerDoc()) {
|
if (focusedNode->OwnerDoc() == aAccessible->GetNode()->OwnerDoc()) {
|
||||||
DocAccessible* doc =
|
DocAccessible* doc =
|
||||||
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
||||||
return aAccessible ==
|
return aAccessible ==
|
||||||
(doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr);
|
(doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode)
|
||||||
|
: nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool FocusManager::IsFocusWithin(const Accessible* aContainer) const {
|
||||||
FocusManager::IsFocusWithin(const Accessible* aContainer) const
|
|
||||||
{
|
|
||||||
Accessible* child = FocusedAccessible();
|
Accessible* child = FocusedAccessible();
|
||||||
while (child) {
|
while (child) {
|
||||||
if (child == aContainer)
|
if (child == aContainer) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
child = child->Parent();
|
child = child->Parent();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FocusManager::FocusDisposition
|
FocusManager::FocusDisposition FocusManager::IsInOrContainsFocus(
|
||||||
FocusManager::IsInOrContainsFocus(const Accessible* aAccessible) const
|
const Accessible* aAccessible) const {
|
||||||
{
|
|
||||||
Accessible* focus = FocusedAccessible();
|
Accessible* focus = FocusedAccessible();
|
||||||
if (!focus)
|
if (!focus) return eNone;
|
||||||
return eNone;
|
|
||||||
|
|
||||||
// If focused.
|
// If focused.
|
||||||
if (focus == aAccessible)
|
if (focus == aAccessible) return eFocused;
|
||||||
return eFocused;
|
|
||||||
|
|
||||||
// If contains the focus.
|
// If contains the focus.
|
||||||
Accessible* child = focus->Parent();
|
Accessible* child = focus->Parent();
|
||||||
while (child) {
|
while (child) {
|
||||||
if (child == aAccessible)
|
if (child == aAccessible) return eContainsFocus;
|
||||||
return eContainsFocus;
|
|
||||||
|
|
||||||
child = child->Parent();
|
child = child->Parent();
|
||||||
}
|
}
|
||||||
@@ -106,8 +91,7 @@ FocusManager::IsInOrContainsFocus(const Accessible* aAccessible) const
|
|||||||
// If contained by focus.
|
// If contained by focus.
|
||||||
child = aAccessible->Parent();
|
child = aAccessible->Parent();
|
||||||
while (child) {
|
while (child) {
|
||||||
if (child == focus)
|
if (child == focus) return eContainedByFocus;
|
||||||
return eContainedByFocus;
|
|
||||||
|
|
||||||
child = child->Parent();
|
child = child->Parent();
|
||||||
}
|
}
|
||||||
@@ -115,9 +99,7 @@ FocusManager::IsInOrContainsFocus(const Accessible* aAccessible) const
|
|||||||
return eNone;
|
return eNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void FocusManager::NotifyOfDOMFocus(nsISupports* aTarget) {
|
||||||
FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
|
|
||||||
{
|
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eFocus))
|
if (logging::IsEnabled(logging::eFocus))
|
||||||
logging::FocusNotificationTarget("DOM focus", "Target", aTarget);
|
logging::FocusNotificationTarget("DOM focus", "Target", aTarget);
|
||||||
@@ -128,21 +110,19 @@ FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
|
|||||||
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
|
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
|
||||||
if (targetNode) {
|
if (targetNode) {
|
||||||
DocAccessible* document =
|
DocAccessible* document =
|
||||||
GetAccService()->GetDocAccessible(targetNode->OwnerDoc());
|
GetAccService()->GetDocAccessible(targetNode->OwnerDoc());
|
||||||
if (document) {
|
if (document) {
|
||||||
// Set selection listener for focused element.
|
// Set selection listener for focused element.
|
||||||
if (targetNode->IsElement())
|
if (targetNode->IsElement())
|
||||||
SelectionMgr()->SetControlSelectionListener(targetNode->AsElement());
|
SelectionMgr()->SetControlSelectionListener(targetNode->AsElement());
|
||||||
|
|
||||||
document->HandleNotification<FocusManager, nsINode>
|
document->HandleNotification<FocusManager, nsINode>(
|
||||||
(this, &FocusManager::ProcessDOMFocus, targetNode);
|
this, &FocusManager::ProcessDOMFocus, targetNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void FocusManager::NotifyOfDOMBlur(nsISupports* aTarget) {
|
||||||
FocusManager::NotifyOfDOMBlur(nsISupports* aTarget)
|
|
||||||
{
|
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eFocus))
|
if (logging::IsEnabled(logging::eFocus))
|
||||||
logging::FocusNotificationTarget("DOM blur", "Target", aTarget);
|
logging::FocusNotificationTarget("DOM blur", "Target", aTarget);
|
||||||
@@ -155,38 +135,33 @@ FocusManager::NotifyOfDOMBlur(nsISupports* aTarget)
|
|||||||
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
|
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
|
||||||
if (targetNode && targetNode->OwnerDoc() == FocusedDOMDocument()) {
|
if (targetNode && targetNode->OwnerDoc() == FocusedDOMDocument()) {
|
||||||
nsIDocument* DOMDoc = targetNode->OwnerDoc();
|
nsIDocument* DOMDoc = targetNode->OwnerDoc();
|
||||||
DocAccessible* document =
|
DocAccessible* document = GetAccService()->GetDocAccessible(DOMDoc);
|
||||||
GetAccService()->GetDocAccessible(DOMDoc);
|
|
||||||
if (document) {
|
if (document) {
|
||||||
// Clear selection listener for previously focused element.
|
// Clear selection listener for previously focused element.
|
||||||
if (targetNode->IsElement())
|
if (targetNode->IsElement())
|
||||||
SelectionMgr()->ClearControlSelectionListener();
|
SelectionMgr()->ClearControlSelectionListener();
|
||||||
|
|
||||||
document->HandleNotification<FocusManager, nsINode>
|
document->HandleNotification<FocusManager, nsINode>(
|
||||||
(this, &FocusManager::ProcessDOMFocus, DOMDoc);
|
this, &FocusManager::ProcessDOMFocus, DOMDoc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive) {
|
||||||
FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
|
|
||||||
{
|
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eFocus))
|
if (logging::IsEnabled(logging::eFocus))
|
||||||
logging::FocusNotificationTarget("active item changed", "Item", aItem);
|
logging::FocusNotificationTarget("active item changed", "Item", aItem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Nothing changed, happens for XUL trees and HTML selects.
|
// Nothing changed, happens for XUL trees and HTML selects.
|
||||||
if (aItem && aItem == mActiveItem)
|
if (aItem && aItem == mActiveItem) return;
|
||||||
return;
|
|
||||||
|
|
||||||
mActiveItem = nullptr;
|
mActiveItem = nullptr;
|
||||||
|
|
||||||
if (aItem && aCheckIfActive) {
|
if (aItem && aCheckIfActive) {
|
||||||
Accessible* widget = aItem->ContainerWidget();
|
Accessible* widget = aItem->ContainerWidget();
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eFocus))
|
if (logging::IsEnabled(logging::eFocus)) logging::ActiveWidget(widget);
|
||||||
logging::ActiveWidget(widget);
|
|
||||||
#endif
|
#endif
|
||||||
if (!widget || !widget->IsActiveWidget() || !widget->AreItemsOperable())
|
if (!widget || !widget->IsActiveWidget() || !widget->AreItemsOperable())
|
||||||
return;
|
return;
|
||||||
@@ -221,63 +196,54 @@ FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void FocusManager::ForceFocusEvent() {
|
||||||
FocusManager::ForceFocusEvent()
|
|
||||||
{
|
|
||||||
nsINode* focusedNode = FocusedDOMNode();
|
nsINode* focusedNode = FocusedDOMNode();
|
||||||
if (focusedNode) {
|
if (focusedNode) {
|
||||||
DocAccessible* document =
|
DocAccessible* document =
|
||||||
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
||||||
if (document) {
|
if (document) {
|
||||||
document->HandleNotification<FocusManager, nsINode>
|
document->HandleNotification<FocusManager, nsINode>(
|
||||||
(this, &FocusManager::ProcessDOMFocus, focusedNode);
|
this, &FocusManager::ProcessDOMFocus, focusedNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
|
||||||
FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
|
Accessible* aTarget) {
|
||||||
Accessible* aTarget)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aDocument, "No document for focused accessible!");
|
MOZ_ASSERT(aDocument, "No document for focused accessible!");
|
||||||
if (aDocument) {
|
if (aDocument) {
|
||||||
RefPtr<AccEvent> event =
|
RefPtr<AccEvent> event =
|
||||||
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget,
|
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget, eAutoDetect,
|
||||||
eAutoDetect, AccEvent::eCoalesceOfSameType);
|
AccEvent::eCoalesceOfSameType);
|
||||||
aDocument->FireDelayedEvent(event);
|
aDocument->FireDelayedEvent(event);
|
||||||
|
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eFocus))
|
if (logging::IsEnabled(logging::eFocus)) logging::FocusDispatched(aTarget);
|
||||||
logging::FocusDispatched(aTarget);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void FocusManager::ProcessDOMFocus(nsINode* aTarget) {
|
||||||
FocusManager::ProcessDOMFocus(nsINode* aTarget)
|
|
||||||
{
|
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eFocus))
|
if (logging::IsEnabled(logging::eFocus))
|
||||||
logging::FocusNotificationTarget("process DOM focus", "Target", aTarget);
|
logging::FocusNotificationTarget("process DOM focus", "Target", aTarget);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DocAccessible* document =
|
DocAccessible* document =
|
||||||
GetAccService()->GetDocAccessible(aTarget->OwnerDoc());
|
GetAccService()->GetDocAccessible(aTarget->OwnerDoc());
|
||||||
if (!document)
|
if (!document) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Accessible* target = document->GetAccessibleEvenIfNotInMapOrContainer(aTarget);
|
Accessible* target =
|
||||||
|
document->GetAccessibleEvenIfNotInMapOrContainer(aTarget);
|
||||||
if (target) {
|
if (target) {
|
||||||
// Check if still focused. Otherwise we can end up with storing the active
|
// Check if still focused. Otherwise we can end up with storing the active
|
||||||
// item for control that isn't focused anymore.
|
// item for control that isn't focused anymore.
|
||||||
nsINode* focusedNode = FocusedDOMNode();
|
nsINode* focusedNode = FocusedDOMNode();
|
||||||
if (!focusedNode)
|
if (!focusedNode) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Accessible* DOMFocus =
|
Accessible* DOMFocus =
|
||||||
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
|
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
|
||||||
if (target != DOMFocus)
|
if (target != DOMFocus) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Accessible* activeItem = target->CurrentItem();
|
Accessible* activeItem = target->CurrentItem();
|
||||||
if (activeItem) {
|
if (activeItem) {
|
||||||
@@ -289,9 +255,7 @@ FocusManager::ProcessDOMFocus(nsINode* aTarget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void FocusManager::ProcessFocusEvent(AccEvent* aEvent) {
|
||||||
FocusManager::ProcessFocusEvent(AccEvent* aEvent)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
|
MOZ_ASSERT(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
|
||||||
"Focus event is expected!");
|
"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.
|
// if it's still focused and then update active item and emit focus event.
|
||||||
Accessible* target = aEvent->GetAccessible();
|
Accessible* target = aEvent->GetAccessible();
|
||||||
if (target != mActiveItem) {
|
if (target != mActiveItem) {
|
||||||
|
|
||||||
// Check if still focused. Otherwise we can end up with storing the active
|
// Check if still focused. Otherwise we can end up with storing the active
|
||||||
// item for control that isn't focused anymore.
|
// item for control that isn't focused anymore.
|
||||||
DocAccessible* document = aEvent->Document();
|
DocAccessible* document = aEvent->Document();
|
||||||
nsINode* focusedNode = FocusedDOMNode();
|
nsINode* focusedNode = FocusedDOMNode();
|
||||||
if (!focusedNode)
|
if (!focusedNode) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Accessible* DOMFocus =
|
Accessible* DOMFocus =
|
||||||
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
|
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
|
||||||
if (target != DOMFocus)
|
if (target != DOMFocus) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Accessible* activeItem = target->CurrentItem();
|
Accessible* activeItem = target->CurrentItem();
|
||||||
if (activeItem) {
|
if (activeItem) {
|
||||||
@@ -323,7 +284,8 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
|
|||||||
if (target->IsARIARole(nsGkAtoms::menuitem)) {
|
if (target->IsARIARole(nsGkAtoms::menuitem)) {
|
||||||
// The focus was moved into menu.
|
// The focus was moved into menu.
|
||||||
Accessible* ARIAMenubar = nullptr;
|
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)) {
|
if (parent->IsARIARole(nsGkAtoms::menubar)) {
|
||||||
ARIAMenubar = parent;
|
ARIAMenubar = parent;
|
||||||
break;
|
break;
|
||||||
@@ -340,8 +302,8 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
|
|||||||
// Leaving ARIA menu. Fire menu_end event on current menubar.
|
// Leaving ARIA menu. Fire menu_end event on current menubar.
|
||||||
if (mActiveARIAMenubar) {
|
if (mActiveARIAMenubar) {
|
||||||
RefPtr<AccEvent> menuEndEvent =
|
RefPtr<AccEvent> menuEndEvent =
|
||||||
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
|
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
|
||||||
aEvent->FromUserInput());
|
aEvent->FromUserInput());
|
||||||
nsEventShell::FireEvent(menuEndEvent);
|
nsEventShell::FireEvent(menuEndEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,16 +312,16 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
|
|||||||
// Entering ARIA menu. Fire menu_start event.
|
// Entering ARIA menu. Fire menu_start event.
|
||||||
if (mActiveARIAMenubar) {
|
if (mActiveARIAMenubar) {
|
||||||
RefPtr<AccEvent> menuStartEvent =
|
RefPtr<AccEvent> menuStartEvent =
|
||||||
new AccEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
new AccEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
||||||
mActiveARIAMenubar, aEvent->FromUserInput());
|
mActiveARIAMenubar, aEvent->FromUserInput());
|
||||||
nsEventShell::FireEvent(menuStartEvent);
|
nsEventShell::FireEvent(menuStartEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mActiveARIAMenubar) {
|
} else if (mActiveARIAMenubar) {
|
||||||
// Focus left a menu. Fire menu_end event.
|
// Focus left a menu. Fire menu_end event.
|
||||||
RefPtr<AccEvent> menuEndEvent =
|
RefPtr<AccEvent> menuEndEvent =
|
||||||
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
|
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
|
||||||
aEvent->FromUserInput());
|
aEvent->FromUserInput());
|
||||||
nsEventShell::FireEvent(menuEndEvent);
|
nsEventShell::FireEvent(menuEndEvent);
|
||||||
|
|
||||||
mActiveARIAMenubar = nullptr;
|
mActiveARIAMenubar = nullptr;
|
||||||
@@ -375,8 +337,8 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
|
|||||||
// offset before the caret move event is handled.
|
// offset before the caret move event is handled.
|
||||||
SelectionMgr()->ResetCaretOffset();
|
SelectionMgr()->ResetCaretOffset();
|
||||||
|
|
||||||
RefPtr<AccEvent> focusEvent =
|
RefPtr<AccEvent> focusEvent = new AccEvent(nsIAccessibleEvent::EVENT_FOCUS,
|
||||||
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, target, aEvent->FromUserInput());
|
target, aEvent->FromUserInput());
|
||||||
nsEventShell::FireEvent(focusEvent);
|
nsEventShell::FireEvent(focusEvent);
|
||||||
|
|
||||||
// Fire scrolling_start event when the document receives the focus if it has
|
// Fire scrolling_start event when the document receives the focus if it has
|
||||||
@@ -395,9 +357,7 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsINode*
|
nsINode* FocusManager::FocusedDOMNode() const {
|
||||||
FocusManager::FocusedDOMNode() const
|
|
||||||
{
|
|
||||||
nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
|
nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
|
||||||
nsIContent* focusedElm = DOMFocusManager->GetFocusedElement();
|
nsIContent* focusedElm = DOMFocusManager->GetFocusedElement();
|
||||||
|
|
||||||
@@ -416,12 +376,10 @@ FocusManager::FocusedDOMNode() const
|
|||||||
return focusedWnd ? focusedWnd->GetExtantDoc() : nullptr;
|
return focusedWnd ? focusedWnd->GetExtantDoc() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIDocument*
|
nsIDocument* FocusManager::FocusedDOMDocument() const {
|
||||||
FocusManager::FocusedDOMDocument() const
|
|
||||||
{
|
|
||||||
nsINode* focusedNode = FocusedDOMNode();
|
nsINode* focusedNode = FocusedDOMNode();
|
||||||
return focusedNode ? focusedNode->OwnerDoc() : nullptr;
|
return focusedNode ? focusedNode->OwnerDoc() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ class DocAccessible;
|
|||||||
/**
|
/**
|
||||||
* Manage the accessible focus. Used to fire and process accessible events.
|
* Manage the accessible focus. Used to fire and process accessible events.
|
||||||
*/
|
*/
|
||||||
class FocusManager
|
class FocusManager {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
virtual ~FocusManager();
|
virtual ~FocusManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,8 +39,9 @@ public:
|
|||||||
* Return true if the given accessible is an active item, i.e. an item that
|
* Return true if the given accessible is an active item, i.e. an item that
|
||||||
* is current within the active widget.
|
* is current within the active widget.
|
||||||
*/
|
*/
|
||||||
inline bool IsActiveItem(const Accessible* aAccessible)
|
inline bool IsActiveItem(const Accessible* aAccessible) {
|
||||||
{ return aAccessible == mActiveItem; }
|
return aAccessible == mActiveItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return DOM node having DOM focus.
|
* Return DOM node having DOM focus.
|
||||||
@@ -51,8 +51,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Return true if given DOM node has DOM focus.
|
* Return true if given DOM node has DOM focus.
|
||||||
*/
|
*/
|
||||||
inline bool HasDOMFocus(const nsINode* aNode) const
|
inline bool HasDOMFocus(const nsINode* aNode) const {
|
||||||
{ return aNode == FocusedDOMNode(); }
|
return aNode == FocusedDOMNode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if focused accessible is within the given container.
|
* 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
|
* Return whether the given accessible is focused or contains the focus or
|
||||||
* contained by focused accessible.
|
* contained by focused accessible.
|
||||||
*/
|
*/
|
||||||
enum FocusDisposition {
|
enum FocusDisposition { eNone, eFocused, eContainsFocus, eContainedByFocus };
|
||||||
eNone,
|
|
||||||
eFocused,
|
|
||||||
eContainsFocus,
|
|
||||||
eContainedByFocus
|
|
||||||
};
|
|
||||||
FocusDisposition IsInOrContainsFocus(const Accessible* aAccessible) const;
|
FocusDisposition IsInOrContainsFocus(const Accessible* aAccessible) const;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -111,24 +107,24 @@ public:
|
|||||||
*/
|
*/
|
||||||
void ProcessFocusEvent(AccEvent* aEvent);
|
void ProcessFocusEvent(AccEvent* aEvent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FocusManager();
|
FocusManager();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FocusManager(const FocusManager&);
|
FocusManager(const FocusManager&);
|
||||||
FocusManager& operator =(const FocusManager&);
|
FocusManager& operator=(const FocusManager&);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return DOM document having DOM focus.
|
* Return DOM document having DOM focus.
|
||||||
*/
|
*/
|
||||||
nsIDocument* FocusedDOMDocument() const;
|
nsIDocument* FocusedDOMDocument() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<Accessible> mActiveItem;
|
RefPtr<Accessible> mActiveItem;
|
||||||
RefPtr<Accessible> mActiveARIAMenubar;
|
RefPtr<Accessible> mActiveARIAMenubar;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,22 +32,18 @@ namespace a11y {
|
|||||||
* decoration on the ID generated by IDSet.
|
* decoration on the ID generated by IDSet.
|
||||||
* @see mozilla::a11y::MsaaIdGenerator
|
* @see mozilla::a11y::MsaaIdGenerator
|
||||||
*/
|
*/
|
||||||
class IDSet
|
class IDSet {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
constexpr explicit IDSet(const uint32_t aMaxIdBits)
|
constexpr explicit IDSet(const uint32_t aMaxIdBits)
|
||||||
: mBitSet()
|
: mBitSet(),
|
||||||
, mIdx(0)
|
mIdx(0),
|
||||||
, mMaxId((1UL << aMaxIdBits) - 1UL)
|
mMaxId((1UL << aMaxIdBits) - 1UL),
|
||||||
, mMaxIdx(mMaxId / bitsPerElt)
|
mMaxIdx(mMaxId / bitsPerElt) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new unique id.
|
* Return a new unique id.
|
||||||
*/
|
*/
|
||||||
uint32_t GetID()
|
uint32_t GetID() {
|
||||||
{
|
|
||||||
uint32_t idx = mIdx;
|
uint32_t idx = mIdx;
|
||||||
while (true) {
|
while (true) {
|
||||||
BitSetElt* elt = mBitSet.findOrInsert(BitSetElt(idx));
|
BitSetElt* elt = mBitSet.findOrInsert(BitSetElt(idx));
|
||||||
@@ -81,8 +77,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Free a no longer required id so it may be allocated again.
|
* 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);
|
MOZ_ASSERT(aID < mMaxId);
|
||||||
|
|
||||||
uint32_t idx = aID / bitsPerElt;
|
uint32_t idx = aID / bitsPerElt;
|
||||||
@@ -97,22 +92,20 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const unsigned int wordsPerElt = 2;
|
static const unsigned int wordsPerElt = 2;
|
||||||
static const unsigned int bitsPerWord = 64;
|
static const unsigned int bitsPerWord = 64;
|
||||||
static const unsigned int bitsPerElt = wordsPerElt * bitsPerWord;
|
static const unsigned int bitsPerElt = wordsPerElt * bitsPerWord;
|
||||||
|
|
||||||
struct BitSetElt : mozilla::SplayTreeNode<BitSetElt>
|
struct BitSetElt : mozilla::SplayTreeNode<BitSetElt> {
|
||||||
{
|
explicit BitSetElt(uint32_t aIdx) : mIdx(aIdx) {
|
||||||
explicit BitSetElt(uint32_t aIdx) :
|
mBitvec[0] = mBitvec[1] = 0;
|
||||||
mIdx(aIdx)
|
}
|
||||||
{ mBitvec[0] = mBitvec[1] = 0; }
|
|
||||||
|
|
||||||
uint64_t mBitvec[wordsPerElt];
|
uint64_t mBitvec[wordsPerElt];
|
||||||
uint32_t mIdx;
|
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) {
|
if (a.mIdx == b.mIdx) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -130,7 +123,7 @@ private:
|
|||||||
const uint32_t mMaxIdx;
|
const uint32_t mMaxIdx;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace a11y
|
||||||
}
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -39,33 +39,28 @@ struct ModuleRep {
|
|||||||
logging::EModules mModule;
|
logging::EModules mModule;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ModuleRep sModuleMap[] = {
|
static ModuleRep sModuleMap[] = {{"docload", logging::eDocLoad},
|
||||||
{ "docload", logging::eDocLoad },
|
{"doccreate", logging::eDocCreate},
|
||||||
{ "doccreate", logging::eDocCreate },
|
{"docdestroy", logging::eDocDestroy},
|
||||||
{ "docdestroy", logging::eDocDestroy },
|
{"doclifecycle", logging::eDocLifeCycle},
|
||||||
{ "doclifecycle", logging::eDocLifeCycle },
|
|
||||||
|
|
||||||
{ "events", logging::eEvents },
|
{"events", logging::eEvents},
|
||||||
{ "eventTree", logging::eEventTree },
|
{"eventTree", logging::eEventTree},
|
||||||
{ "platforms", logging::ePlatforms },
|
{"platforms", logging::ePlatforms},
|
||||||
{ "text", logging::eText },
|
{"text", logging::eText},
|
||||||
{ "tree", logging::eTree },
|
{"tree", logging::eTree},
|
||||||
|
|
||||||
{ "DOMEvents", logging::eDOMEvents },
|
{"DOMEvents", logging::eDOMEvents},
|
||||||
{ "focus", logging::eFocus },
|
{"focus", logging::eFocus},
|
||||||
{ "selection", logging::eSelection },
|
{"selection", logging::eSelection},
|
||||||
{ "notifications", logging::eNotifications },
|
{"notifications", logging::eNotifications},
|
||||||
|
|
||||||
{ "stack", logging::eStack },
|
{"stack", logging::eStack},
|
||||||
{ "verbose", logging::eVerbose }
|
{"verbose", logging::eVerbose}};
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void EnableLogging(const char* aModulesStr) {
|
||||||
EnableLogging(const char* aModulesStr)
|
|
||||||
{
|
|
||||||
sModules = 0;
|
sModules = 0;
|
||||||
if (!aModulesStr)
|
if (!aModulesStr) return;
|
||||||
return;
|
|
||||||
|
|
||||||
const char* token = aModulesStr;
|
const char* token = aModulesStr;
|
||||||
while (*token != '\0') {
|
while (*token != '\0') {
|
||||||
@@ -74,8 +69,7 @@ EnableLogging(const char* aModulesStr)
|
|||||||
if (strncmp(token, sModuleMap[idx].mStr, tokenLen) == 0) {
|
if (strncmp(token, sModuleMap[idx].mStr, tokenLen) == 0) {
|
||||||
#if !defined(MOZ_PROFILING) && (!defined(DEBUG) || defined(MOZ_OPTIMIZE))
|
#if !defined(MOZ_PROFILING) && (!defined(DEBUG) || defined(MOZ_OPTIMIZE))
|
||||||
// Stack tracing on profiling enabled or debug not optimized builds.
|
// Stack tracing on profiling enabled or debug not optimized builds.
|
||||||
if (strncmp(token, "stack", tokenLen) == 0)
|
if (strncmp(token, "stack", tokenLen) == 0) break;
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
sModules |= sModuleMap[idx].mModule;
|
sModules |= sModuleMap[idx].mModule;
|
||||||
printf("\n\nmodule enabled: %s\n", sModuleMap[idx].mStr);
|
printf("\n\nmodule enabled: %s\n", sModuleMap[idx].mStr);
|
||||||
@@ -84,20 +78,15 @@ EnableLogging(const char* aModulesStr)
|
|||||||
}
|
}
|
||||||
token += tokenLen;
|
token += tokenLen;
|
||||||
|
|
||||||
if (*token == ',')
|
if (*token == ',') token++; // skip ',' char
|
||||||
token++; // skip ',' char
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocURI(nsIDocument* aDocumentNode) {
|
||||||
LogDocURI(nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
printf("uri: %s", aDocumentNode->GetDocumentURI()->GetSpecOrDefault().get());
|
printf("uri: %s", aDocumentNode->GetDocumentURI()->GetSpecOrDefault().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocShellState(nsIDocument* aDocumentNode) {
|
||||||
LogDocShellState(nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
printf("docshell busy: ");
|
printf("docshell busy: ");
|
||||||
|
|
||||||
nsAutoCString docShellBusy;
|
nsAutoCString docShellBusy;
|
||||||
@@ -118,20 +107,16 @@ LogDocShellState(nsIDocument* aDocumentNode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocType(nsIDocument* aDocumentNode) {
|
||||||
LogDocType(nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
if (aDocumentNode->IsActive()) {
|
if (aDocumentNode->IsActive()) {
|
||||||
bool isContent = nsCoreUtils::IsContentDocument(aDocumentNode);
|
bool isContent = nsCoreUtils::IsContentDocument(aDocumentNode);
|
||||||
printf("%s document", (isContent ? "content" : "chrome"));
|
printf("%s document", (isContent ? "content" : "chrome"));
|
||||||
} else {
|
} else {
|
||||||
printf("document type: [failed]");\
|
printf("document type: [failed]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocShellTree(nsIDocument* aDocumentNode) {
|
||||||
LogDocShellTree(nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
if (aDocumentNode->IsActive()) {
|
if (aDocumentNode->IsActive()) {
|
||||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(aDocumentNode->GetDocShell());
|
nsCOMPtr<nsIDocShellTreeItem> treeItem(aDocumentNode->GetDocShell());
|
||||||
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
||||||
@@ -144,14 +129,12 @@ LogDocShellTree(nsIDocument* aDocumentNode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocState(nsIDocument* aDocumentNode) {
|
||||||
LogDocState(nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
const char* docState = nullptr;
|
const char* docState = nullptr;
|
||||||
nsIDocument::ReadyState docStateFlag = aDocumentNode->GetReadyStateEnum();
|
nsIDocument::ReadyState docStateFlag = aDocumentNode->GetReadyStateEnum();
|
||||||
switch (docStateFlag) {
|
switch (docStateFlag) {
|
||||||
case nsIDocument::READYSTATE_UNINITIALIZED:
|
case nsIDocument::READYSTATE_UNINITIALIZED:
|
||||||
docState = "uninitialized";
|
docState = "uninitialized";
|
||||||
break;
|
break;
|
||||||
case nsIDocument::READYSTATE_LOADING:
|
case nsIDocument::READYSTATE_LOADING:
|
||||||
docState = "loading";
|
docState = "loading";
|
||||||
@@ -168,7 +151,8 @@ LogDocState(nsIDocument* aDocumentNode)
|
|||||||
printf(", %sinitial", aDocumentNode->IsInitialDocument() ? "" : "not ");
|
printf(", %sinitial", aDocumentNode->IsInitialDocument() ? "" : "not ");
|
||||||
printf(", %sshowing", aDocumentNode->IsShowing() ? "" : "not ");
|
printf(", %sshowing", aDocumentNode->IsShowing() ? "" : "not ");
|
||||||
printf(", %svisible", aDocumentNode->IsVisible() ? "" : "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(", %sactive", aDocumentNode->IsActive() ? "" : "not ");
|
||||||
printf(", %sresource", aDocumentNode->IsResourceDoc() ? "" : "not ");
|
printf(", %sresource", aDocumentNode->IsResourceDoc() ? "" : "not ");
|
||||||
|
|
||||||
@@ -179,9 +163,7 @@ LogDocState(nsIDocument* aDocumentNode)
|
|||||||
printf(", has %srole content", rootEl ? "" : "no ");
|
printf(", has %srole content", rootEl ? "" : "no ");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogPresShell(nsIDocument* aDocumentNode) {
|
||||||
LogPresShell(nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
nsIPresShell* ps = aDocumentNode->GetShell();
|
nsIPresShell* ps = aDocumentNode->GetShell();
|
||||||
printf("presshell: %p", static_cast<void*>(ps));
|
printf("presshell: %p", static_cast<void*>(ps));
|
||||||
|
|
||||||
@@ -193,16 +175,12 @@ LogPresShell(nsIDocument* aDocumentNode)
|
|||||||
printf(", root scroll frame: %p", static_cast<void*>(sf));
|
printf(", root scroll frame: %p", static_cast<void*>(sf));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocLoadGroup(nsIDocument* aDocumentNode) {
|
||||||
LogDocLoadGroup(nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsILoadGroup> loadGroup = aDocumentNode->GetDocumentLoadGroup();
|
nsCOMPtr<nsILoadGroup> loadGroup = aDocumentNode->GetDocumentLoadGroup();
|
||||||
printf("load group: %p", static_cast<void*>(loadGroup));
|
printf("load group: %p", static_cast<void*>(loadGroup));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocParent(nsIDocument* aDocumentNode) {
|
||||||
LogDocParent(nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
nsIDocument* parentDoc = aDocumentNode->GetParentDocument();
|
nsIDocument* parentDoc = aDocumentNode->GetParentDocument();
|
||||||
printf("parent DOM document: %p", static_cast<void*>(parentDoc));
|
printf("parent DOM document: %p", static_cast<void*>(parentDoc));
|
||||||
if (parentDoc) {
|
if (parentDoc) {
|
||||||
@@ -214,9 +192,7 @@ LogDocParent(nsIDocument* aDocumentNode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument) {
|
||||||
LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument)
|
|
||||||
{
|
|
||||||
printf(" DOM document: %p, acc document: %p\n ",
|
printf(" DOM document: %p, acc document: %p\n ",
|
||||||
static_cast<void*>(aDocumentNode), static_cast<void*>(aDocument));
|
static_cast<void*>(aDocumentNode), static_cast<void*>(aDocument));
|
||||||
|
|
||||||
@@ -241,9 +217,7 @@ LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogShellLoadType(nsIDocShell* aDocShell) {
|
||||||
LogShellLoadType(nsIDocShell* aDocShell)
|
|
||||||
{
|
|
||||||
printf("load type: ");
|
printf("load type: ");
|
||||||
|
|
||||||
uint32_t loadType = 0;
|
uint32_t loadType = 0;
|
||||||
@@ -320,9 +294,7 @@ LogShellLoadType(nsIDocShell* aDocShell)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogRequest(nsIRequest* aRequest) {
|
||||||
LogRequest(nsIRequest* aRequest)
|
|
||||||
{
|
|
||||||
if (aRequest) {
|
if (aRequest) {
|
||||||
nsAutoCString name;
|
nsAutoCString name;
|
||||||
aRequest->GetName(name);
|
aRequest->GetName(name);
|
||||||
@@ -330,28 +302,22 @@ LogRequest(nsIRequest* aRequest)
|
|||||||
uint32_t loadFlags = 0;
|
uint32_t loadFlags = 0;
|
||||||
aRequest->GetLoadFlags(&loadFlags);
|
aRequest->GetLoadFlags(&loadFlags);
|
||||||
printf(" request load flags: %x; ", loadFlags);
|
printf(" request load flags: %x; ", loadFlags);
|
||||||
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI)
|
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) printf("document uri; ");
|
||||||
printf("document uri; ");
|
|
||||||
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
|
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
|
||||||
printf("retargeted document uri; ");
|
printf("retargeted document uri; ");
|
||||||
if (loadFlags & nsIChannel::LOAD_REPLACE)
|
if (loadFlags & nsIChannel::LOAD_REPLACE) printf("replace; ");
|
||||||
printf("replace; ");
|
|
||||||
if (loadFlags & nsIChannel::LOAD_INITIAL_DOCUMENT_URI)
|
if (loadFlags & nsIChannel::LOAD_INITIAL_DOCUMENT_URI)
|
||||||
printf("initial document uri; ");
|
printf("initial document uri; ");
|
||||||
if (loadFlags & nsIChannel::LOAD_TARGETED)
|
if (loadFlags & nsIChannel::LOAD_TARGETED) printf("targeted; ");
|
||||||
printf("targeted; ");
|
|
||||||
if (loadFlags & nsIChannel::LOAD_CALL_CONTENT_SNIFFERS)
|
if (loadFlags & nsIChannel::LOAD_CALL_CONTENT_SNIFFERS)
|
||||||
printf("call content sniffers; ");
|
printf("call content sniffers; ");
|
||||||
if (loadFlags & nsIChannel::LOAD_CLASSIFY_URI)
|
if (loadFlags & nsIChannel::LOAD_CLASSIFY_URI) printf("classify uri; ");
|
||||||
printf("classify uri; ");
|
|
||||||
} else {
|
} else {
|
||||||
printf(" no request");
|
printf(" no request");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void LogDocAccState(DocAccessible* aDocument) {
|
||||||
LogDocAccState(DocAccessible* aDocument)
|
|
||||||
{
|
|
||||||
printf("document acc state: ");
|
printf("document acc state: ");
|
||||||
if (aDocument->HasLoadState(DocAccessible::eCompletelyLoaded))
|
if (aDocument->HasLoadState(DocAccessible::eCompletelyLoaded))
|
||||||
printf("completely loaded;");
|
printf("completely loaded;");
|
||||||
@@ -363,9 +329,7 @@ LogDocAccState(DocAccessible* aDocument)
|
|||||||
printf("tree constructed;");
|
printf("tree constructed;");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void GetDocLoadEventType(AccEvent* aEvent, nsACString& aEventType) {
|
||||||
GetDocLoadEventType(AccEvent* aEvent, nsACString& aEventType)
|
|
||||||
{
|
|
||||||
uint32_t type = aEvent->GetEventType();
|
uint32_t type = aEvent->GetEventType();
|
||||||
if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED) {
|
if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED) {
|
||||||
aEventType.AssignLiteral("load stopped");
|
aEventType.AssignLiteral("load stopped");
|
||||||
@@ -394,10 +358,8 @@ static const char* sDocDestroyTitle = "DOCDESTROY";
|
|||||||
static const char* sDocEventTitle = "DOCEVENT";
|
static const char* sDocEventTitle = "DOCEVENT";
|
||||||
static const char* sFocusTitle = "FOCUS";
|
static const char* sFocusTitle = "FOCUS";
|
||||||
|
|
||||||
void
|
void logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
|
||||||
logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
|
nsIRequest* aRequest, uint32_t aStateFlags) {
|
||||||
nsIRequest* aRequest, uint32_t aStateFlags)
|
|
||||||
{
|
|
||||||
MsgBegin(sDocLoadTitle, "%s", aMsg);
|
MsgBegin(sDocLoadTitle, "%s", aMsg);
|
||||||
|
|
||||||
nsCOMPtr<mozIDOMWindowProxy> DOMWindow;
|
nsCOMPtr<mozIDOMWindowProxy> DOMWindow;
|
||||||
@@ -432,9 +394,7 @@ logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
|
|||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode) {
|
||||||
logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode)
|
|
||||||
{
|
|
||||||
MsgBegin(sDocLoadTitle, "%s", aMsg);
|
MsgBegin(sDocLoadTitle, "%s", aMsg);
|
||||||
|
|
||||||
DocAccessible* document = GetExistingDocAccessible(aDocumentNode);
|
DocAccessible* document = GetExistingDocAccessible(aDocumentNode);
|
||||||
@@ -443,9 +403,8 @@ logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode)
|
|||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::DocCompleteLoad(DocAccessible* aDocument,
|
||||||
logging::DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget)
|
bool aIsLoadEventTarget) {
|
||||||
{
|
|
||||||
MsgBegin(sDocLoadTitle, "document loaded *completely*");
|
MsgBegin(sDocLoadTitle, "document loaded *completely*");
|
||||||
|
|
||||||
printf(" DOM document: %p, acc document: %p\n",
|
printf(" DOM document: %p, acc document: %p\n",
|
||||||
@@ -466,86 +425,70 @@ logging::DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget)
|
|||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::DocLoadEventFired(AccEvent* aEvent) {
|
||||||
logging::DocLoadEventFired(AccEvent* aEvent)
|
|
||||||
{
|
|
||||||
nsAutoCString strEventType;
|
nsAutoCString strEventType;
|
||||||
GetDocLoadEventType(aEvent, strEventType);
|
GetDocLoadEventType(aEvent, strEventType);
|
||||||
if (!strEventType.IsEmpty())
|
if (!strEventType.IsEmpty()) printf(" fire: %s\n", strEventType.get());
|
||||||
printf(" fire: %s\n", strEventType.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::DocLoadEventHandled(AccEvent* aEvent) {
|
||||||
logging::DocLoadEventHandled(AccEvent* aEvent)
|
|
||||||
{
|
|
||||||
nsAutoCString strEventType;
|
nsAutoCString strEventType;
|
||||||
GetDocLoadEventType(aEvent, strEventType);
|
GetDocLoadEventType(aEvent, strEventType);
|
||||||
if (strEventType.IsEmpty())
|
if (strEventType.IsEmpty()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
MsgBegin(sDocEventTitle, "handled '%s' event", strEventType.get());
|
MsgBegin(sDocEventTitle, "handled '%s' event", strEventType.get());
|
||||||
|
|
||||||
DocAccessible* document = aEvent->GetAccessible()->AsDoc();
|
DocAccessible* document = aEvent->GetAccessible()->AsDoc();
|
||||||
if (document)
|
if (document) LogDocInfo(document->DocumentNode(), document);
|
||||||
LogDocInfo(document->DocumentNode(), document);
|
|
||||||
|
|
||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::DocCreate(const char* aMsg, nsIDocument* aDocumentNode,
|
||||||
logging::DocCreate(const char* aMsg, nsIDocument* aDocumentNode,
|
DocAccessible* aDocument) {
|
||||||
DocAccessible* aDocument)
|
DocAccessible* document =
|
||||||
{
|
aDocument ? aDocument : GetExistingDocAccessible(aDocumentNode);
|
||||||
DocAccessible* document = aDocument ?
|
|
||||||
aDocument : GetExistingDocAccessible(aDocumentNode);
|
|
||||||
|
|
||||||
MsgBegin(sDocCreateTitle, "%s", aMsg);
|
MsgBegin(sDocCreateTitle, "%s", aMsg);
|
||||||
LogDocInfo(aDocumentNode, document);
|
LogDocInfo(aDocumentNode, document);
|
||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::DocDestroy(const char* aMsg, nsIDocument* aDocumentNode,
|
||||||
logging::DocDestroy(const char* aMsg, nsIDocument* aDocumentNode,
|
DocAccessible* aDocument) {
|
||||||
DocAccessible* aDocument)
|
DocAccessible* document =
|
||||||
{
|
aDocument ? aDocument : GetExistingDocAccessible(aDocumentNode);
|
||||||
DocAccessible* document = aDocument ?
|
|
||||||
aDocument : GetExistingDocAccessible(aDocumentNode);
|
|
||||||
|
|
||||||
MsgBegin(sDocDestroyTitle, "%s", aMsg);
|
MsgBegin(sDocDestroyTitle, "%s", aMsg);
|
||||||
LogDocInfo(aDocumentNode, document);
|
LogDocInfo(aDocumentNode, document);
|
||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::OuterDocDestroy(OuterDocAccessible* aOuterDoc) {
|
||||||
logging::OuterDocDestroy(OuterDocAccessible* aOuterDoc)
|
|
||||||
{
|
|
||||||
MsgBegin(sDocDestroyTitle, "outerdoc shutdown");
|
MsgBegin(sDocDestroyTitle, "outerdoc shutdown");
|
||||||
logging::Address("outerdoc", aOuterDoc);
|
logging::Address("outerdoc", aOuterDoc);
|
||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::FocusNotificationTarget(const char* aMsg,
|
||||||
logging::FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
|
const char* aTargetDescr,
|
||||||
Accessible* aTarget)
|
Accessible* aTarget) {
|
||||||
{
|
|
||||||
MsgBegin(sFocusTitle, "%s", aMsg);
|
MsgBegin(sFocusTitle, "%s", aMsg);
|
||||||
AccessibleNNode(aTargetDescr, aTarget);
|
AccessibleNNode(aTargetDescr, aTarget);
|
||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::FocusNotificationTarget(const char* aMsg,
|
||||||
logging::FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
|
const char* aTargetDescr,
|
||||||
nsINode* aTargetNode)
|
nsINode* aTargetNode) {
|
||||||
{
|
|
||||||
MsgBegin(sFocusTitle, "%s", aMsg);
|
MsgBegin(sFocusTitle, "%s", aMsg);
|
||||||
Node(aTargetDescr, aTargetNode);
|
Node(aTargetDescr, aTargetNode);
|
||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::FocusNotificationTarget(const char* aMsg,
|
||||||
logging::FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
|
const char* aTargetDescr,
|
||||||
nsISupports* aTargetThing)
|
nsISupports* aTargetThing) {
|
||||||
{
|
|
||||||
MsgBegin(sFocusTitle, "%s", aMsg);
|
MsgBegin(sFocusTitle, "%s", aMsg);
|
||||||
|
|
||||||
if (aTargetThing) {
|
if (aTargetThing) {
|
||||||
@@ -560,18 +503,15 @@ logging::FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
|
|||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::ActiveItemChangeCausedBy(const char* aCause,
|
||||||
logging::ActiveItemChangeCausedBy(const char* aCause, Accessible* aTarget)
|
Accessible* aTarget) {
|
||||||
{
|
|
||||||
SubMsgBegin();
|
SubMsgBegin();
|
||||||
printf(" Caused by: %s\n", aCause);
|
printf(" Caused by: %s\n", aCause);
|
||||||
AccessibleNNode("Item", aTarget);
|
AccessibleNNode("Item", aTarget);
|
||||||
SubMsgEnd();
|
SubMsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::ActiveWidget(Accessible* aWidget) {
|
||||||
logging::ActiveWidget(Accessible* aWidget)
|
|
||||||
{
|
|
||||||
SubMsgBegin();
|
SubMsgBegin();
|
||||||
|
|
||||||
AccessibleNNode("Widget", aWidget);
|
AccessibleNNode("Widget", aWidget);
|
||||||
@@ -582,18 +522,14 @@ logging::ActiveWidget(Accessible* aWidget)
|
|||||||
SubMsgEnd();
|
SubMsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::FocusDispatched(Accessible* aTarget) {
|
||||||
logging::FocusDispatched(Accessible* aTarget)
|
|
||||||
{
|
|
||||||
SubMsgBegin();
|
SubMsgBegin();
|
||||||
AccessibleNNode("A11y target", aTarget);
|
AccessibleNNode("A11y target", aTarget);
|
||||||
SubMsgEnd();
|
SubMsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
|
||||||
logging::SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
|
int16_t aReason) {
|
||||||
int16_t aReason)
|
|
||||||
{
|
|
||||||
SelectionType type = aSelection->GetType();
|
SelectionType type = aSelection->GetType();
|
||||||
|
|
||||||
const char* strType = 0;
|
const char* strType = 0;
|
||||||
@@ -605,15 +541,14 @@ logging::SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
|
|||||||
strType = "unknown";
|
strType = "unknown";
|
||||||
|
|
||||||
bool isIgnored = !aDocument || !aDocument->IsContentLoaded();
|
bool isIgnored = !aDocument || !aDocument->IsContentLoaded();
|
||||||
printf("\nSelection changed, selection type: %s, notification %s, reason: %d\n",
|
printf(
|
||||||
strType, (isIgnored ? "ignored" : "pending"), aReason);
|
"\nSelection changed, selection type: %s, notification %s, reason: %d\n",
|
||||||
|
strType, (isIgnored ? "ignored" : "pending"), aReason);
|
||||||
|
|
||||||
Stack();
|
Stack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...) {
|
||||||
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...)
|
|
||||||
{
|
|
||||||
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, aExtraFlags);
|
va_start(vl, aExtraFlags);
|
||||||
@@ -625,8 +560,7 @@ logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...)
|
|||||||
while ((descr = va_arg(vl, const char*))) {
|
while ((descr = va_arg(vl, const char*))) {
|
||||||
AccessibleInfo(descr, va_arg(vl, Accessible*));
|
AccessibleInfo(descr, va_arg(vl, Accessible*));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
MsgBegin("TREE", "%s", aMsg);
|
MsgBegin("TREE", "%s", aMsg);
|
||||||
}
|
}
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
@@ -638,29 +572,24 @@ logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
|
||||||
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
|
const char* aMsg1, Accessible* aAcc, const char* aMsg2,
|
||||||
const char* aMsg1, Accessible* aAcc,
|
nsINode* aNode) {
|
||||||
const char* aMsg2, nsINode* aNode)
|
|
||||||
{
|
|
||||||
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
||||||
MsgBegin("TREE", "%s; doc: %p", aMsg, aAcc ? aAcc->Document() : nullptr);
|
MsgBegin("TREE", "%s; doc: %p", aMsg, aAcc ? aAcc->Document() : nullptr);
|
||||||
AccessibleInfo(aMsg1, aAcc);
|
AccessibleInfo(aMsg1, aAcc);
|
||||||
Accessible* acc = aAcc ? aAcc->Document()->GetAccessible(aNode) : nullptr;
|
Accessible* acc = aAcc ? aAcc->Document()->GetAccessible(aNode) : nullptr;
|
||||||
if (acc) {
|
if (acc) {
|
||||||
AccessibleInfo(aMsg2, acc);
|
AccessibleInfo(aMsg2, acc);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Node(aMsg2, aNode);
|
Node(aMsg2, aNode);
|
||||||
}
|
}
|
||||||
MsgEnd();
|
MsgEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
|
||||||
void
|
Accessible* aParent) {
|
||||||
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent)
|
|
||||||
{
|
|
||||||
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
||||||
MsgBegin("TREE", "%s; doc: %p", aMsg, aParent->Document());
|
MsgBegin("TREE", "%s; doc: %p", aMsg, aParent->Document());
|
||||||
AccessibleInfo("container", aParent);
|
AccessibleInfo("container", aParent);
|
||||||
@@ -671,17 +600,15 @@ logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::Tree(const char* aTitle, const char* aMsgText, Accessible* aRoot,
|
||||||
logging::Tree(const char* aTitle, const char* aMsgText,
|
GetTreePrefix aPrefixFunc, void* aGetTreePrefixData) {
|
||||||
Accessible* aRoot, GetTreePrefix aPrefixFunc,
|
|
||||||
void* aGetTreePrefixData)
|
|
||||||
{
|
|
||||||
logging::MsgBegin(aTitle, "%s", aMsgText);
|
logging::MsgBegin(aTitle, "%s", aMsgText);
|
||||||
|
|
||||||
nsAutoString level;
|
nsAutoString level;
|
||||||
Accessible* root = aRoot;
|
Accessible* root = aRoot;
|
||||||
do {
|
do {
|
||||||
const char* prefix = aPrefixFunc ? aPrefixFunc(aGetTreePrefixData, root) : "";
|
const char* prefix =
|
||||||
|
aPrefixFunc ? aPrefixFunc(aGetTreePrefixData, root) : "";
|
||||||
printf("%s", NS_ConvertUTF16toUTF8(level).get());
|
printf("%s", NS_ConvertUTF16toUTF8(level).get());
|
||||||
logging::AccessibleInfo(prefix, root);
|
logging::AccessibleInfo(prefix, root);
|
||||||
if (root->FirstChild() && !root->FirstChild()->IsDoc()) {
|
if (root->FirstChild() && !root->FirstChild()->IsDoc()) {
|
||||||
@@ -689,33 +616,34 @@ logging::Tree(const char* aTitle, const char* aMsgText,
|
|||||||
root = root->FirstChild();
|
root = root->FirstChild();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int32_t idxInParent = root != aRoot && root->mParent ?
|
int32_t idxInParent = root != aRoot && root->mParent
|
||||||
root->mParent->mChildren.IndexOf(root) : -1;
|
? root->mParent->mChildren.IndexOf(root)
|
||||||
|
: -1;
|
||||||
if (idxInParent != -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);
|
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
while (root != aRoot && (root = root->Parent())) {
|
while (root != aRoot && (root = root->Parent())) {
|
||||||
level.Cut(0, 2);
|
level.Cut(0, 2);
|
||||||
int32_t idxInParent = !root->IsDoc() && root->mParent ?
|
int32_t idxInParent = !root->IsDoc() && root->mParent
|
||||||
root->mParent->mChildren.IndexOf(root) : -1;
|
? root->mParent->mChildren.IndexOf(root)
|
||||||
|
: -1;
|
||||||
if (idxInParent != -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);
|
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (root && root != aRoot);
|
||||||
while (root && root != aRoot);
|
|
||||||
|
|
||||||
logging::MsgEnd();
|
logging::MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::DOMTree(const char* aTitle, const char* aMsgText,
|
||||||
logging::DOMTree(const char* aTitle, const char* aMsgText,
|
DocAccessible* aDocument) {
|
||||||
DocAccessible* aDocument)
|
|
||||||
{
|
|
||||||
logging::MsgBegin(aTitle, "%s", aMsgText);
|
logging::MsgBegin(aTitle, "%s", aMsgText);
|
||||||
nsAutoString level;
|
nsAutoString level;
|
||||||
nsINode* root = aDocument->DocumentNode();
|
nsINode* root = aDocument->DocumentNode();
|
||||||
@@ -738,14 +666,11 @@ logging::DOMTree(const char* aTitle, const char* aMsgText,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (root);
|
||||||
while (root);
|
|
||||||
logging::MsgEnd();
|
logging::MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::MsgBegin(const char* aTitle, const char* aMsgText, ...) {
|
||||||
logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
|
|
||||||
{
|
|
||||||
printf("\nA11Y %s: ", aTitle);
|
printf("\nA11Y %s: ", aTitle);
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
@@ -762,27 +687,13 @@ logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
|
|||||||
printf("\n {\n");
|
printf("\n {\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::MsgEnd() { printf(" }\n"); }
|
||||||
logging::MsgEnd()
|
|
||||||
{
|
|
||||||
printf(" }\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void logging::SubMsgBegin() { printf(" {\n"); }
|
||||||
logging::SubMsgBegin()
|
|
||||||
{
|
|
||||||
printf(" {\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void logging::SubMsgEnd() { printf(" }\n"); }
|
||||||
logging::SubMsgEnd()
|
|
||||||
{
|
|
||||||
printf(" }\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void logging::MsgEntry(const char* aEntryText, ...) {
|
||||||
logging::MsgEntry(const char* aEntryText, ...)
|
|
||||||
{
|
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
@@ -793,15 +704,9 @@ logging::MsgEntry(const char* aEntryText, ...)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::Text(const char* aText) { printf(" %s\n", aText); }
|
||||||
logging::Text(const char* aText)
|
|
||||||
{
|
|
||||||
printf(" %s\n", aText);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void logging::Address(const char* aDescr, Accessible* aAcc) {
|
||||||
logging::Address(const char* aDescr, Accessible* aAcc)
|
|
||||||
{
|
|
||||||
if (!aAcc->IsDoc()) {
|
if (!aAcc->IsDoc()) {
|
||||||
printf(" %s accessible: %p, node: %p\n", aDescr,
|
printf(" %s accessible: %p, node: %p\n", aDescr,
|
||||||
static_cast<void*>(aAcc), static_cast<void*>(aAcc->GetNode()));
|
static_cast<void*>(aAcc), static_cast<void*>(aAcc->GetNode()));
|
||||||
@@ -809,17 +714,15 @@ logging::Address(const char* aDescr, Accessible* aAcc)
|
|||||||
|
|
||||||
DocAccessible* doc = aAcc->Document();
|
DocAccessible* doc = aAcc->Document();
|
||||||
nsIDocument* docNode = doc->DocumentNode();
|
nsIDocument* docNode = doc->DocumentNode();
|
||||||
printf(" document: %p, node: %p\n",
|
printf(" document: %p, node: %p\n", static_cast<void*>(doc),
|
||||||
static_cast<void*>(doc), static_cast<void*>(docNode));
|
static_cast<void*>(docNode));
|
||||||
|
|
||||||
printf(" ");
|
printf(" ");
|
||||||
LogDocURI(docNode);
|
LogDocURI(docNode);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::Node(const char* aDescr, nsINode* aNode) {
|
||||||
logging::Node(const char* aDescr, nsINode* aNode)
|
|
||||||
{
|
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|
||||||
if (!aNode) {
|
if (!aNode) {
|
||||||
@@ -833,17 +736,17 @@ logging::Node(const char* aDescr, nsINode* aNode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsINode* parentNode = aNode->GetParentNode();
|
nsINode* parentNode = aNode->GetParentNode();
|
||||||
int32_t idxInParent = parentNode ? parentNode->ComputeIndexOf(aNode) : - 1;
|
int32_t idxInParent = parentNode ? parentNode->ComputeIndexOf(aNode) : -1;
|
||||||
|
|
||||||
if (aNode->IsText()) {
|
if (aNode->IsText()) {
|
||||||
printf("%s: %p, text node, idx in parent: %d\n",
|
printf("%s: %p, text node, idx in parent: %d\n", aDescr,
|
||||||
aDescr, static_cast<void*>(aNode), idxInParent);
|
static_cast<void*>(aNode), idxInParent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aNode->IsElement()) {
|
if (!aNode->IsElement()) {
|
||||||
printf("%s: %p, not accessible node type, idx in parent: %d\n",
|
printf("%s: %p, not accessible node type, idx in parent: %d\n", aDescr,
|
||||||
aDescr, static_cast<void*>(aNode), idxInParent);
|
static_cast<void*>(aNode), idxInParent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -854,18 +757,14 @@ logging::Node(const char* aDescr, nsINode* aNode)
|
|||||||
|
|
||||||
nsAtom* idAtom = elm->GetID();
|
nsAtom* idAtom = elm->GetID();
|
||||||
nsAutoCString id;
|
nsAutoCString id;
|
||||||
if (idAtom)
|
if (idAtom) idAtom->ToUTF8String(id);
|
||||||
idAtom->ToUTF8String(id);
|
|
||||||
|
|
||||||
printf("%s: %p, %s@id='%s', idx in parent: %d\n",
|
printf("%s: %p, %s@id='%s', idx in parent: %d\n", aDescr,
|
||||||
aDescr, static_cast<void*>(elm), tag.get(), id.get(), idxInParent);
|
static_cast<void*>(elm), tag.get(), id.get(), idxInParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::Document(DocAccessible* aDocument) {
|
||||||
logging::Document(DocAccessible* aDocument)
|
printf(" Document: %p, document node: %p\n", static_cast<void*>(aDocument),
|
||||||
{
|
|
||||||
printf(" Document: %p, document node: %p\n",
|
|
||||||
static_cast<void*>(aDocument),
|
|
||||||
static_cast<void*>(aDocument->DocumentNode()));
|
static_cast<void*>(aDocument->DocumentNode()));
|
||||||
|
|
||||||
printf(" Document ");
|
printf(" Document ");
|
||||||
@@ -873,9 +772,7 @@ logging::Document(DocAccessible* aDocument)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible) {
|
||||||
logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible)
|
|
||||||
{
|
|
||||||
printf(" %s: %p; ", aDescr, static_cast<void*>(aAccessible));
|
printf(" %s: %p; ", aDescr, static_cast<void*>(aAccessible));
|
||||||
if (!aAccessible) {
|
if (!aAccessible) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -905,14 +802,11 @@ logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible)
|
|||||||
nsINode* node = aAccessible->GetNode();
|
nsINode* node = aAccessible->GetNode();
|
||||||
if (!node) {
|
if (!node) {
|
||||||
printf(", node: null\n");
|
printf(", node: null\n");
|
||||||
}
|
} else if (node->IsDocument()) {
|
||||||
else if (node->IsDocument()) {
|
|
||||||
printf(", document node: %p\n", static_cast<void*>(node));
|
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));
|
printf(", text node: %p\n", static_cast<void*>(node));
|
||||||
}
|
} else if (node->IsElement()) {
|
||||||
else if (node->IsElement()) {
|
|
||||||
dom::Element* el = node->AsElement();
|
dom::Element* el = node->AsElement();
|
||||||
|
|
||||||
nsAutoCString tag;
|
nsAutoCString tag;
|
||||||
@@ -924,17 +818,14 @@ logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible)
|
|||||||
idAtom->ToUTF8String(id);
|
idAtom->ToUTF8String(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(", element node: %p, %s@id='%s'\n",
|
printf(", element node: %p, %s@id='%s'\n", static_cast<void*>(el),
|
||||||
static_cast<void*>(el), tag.get(), id.get());
|
tag.get(), id.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::AccessibleNNode(const char* aDescr, Accessible* aAccessible) {
|
||||||
logging::AccessibleNNode(const char* aDescr, Accessible* aAccessible)
|
|
||||||
{
|
|
||||||
printf(" %s: %p; ", aDescr, static_cast<void*>(aAccessible));
|
printf(" %s: %p; ", aDescr, static_cast<void*>(aAccessible));
|
||||||
if (!aAccessible)
|
if (!aAccessible) return;
|
||||||
return;
|
|
||||||
|
|
||||||
nsAutoString role;
|
nsAutoString role;
|
||||||
GetAccService()->GetStringRole(aAccessible->Role(), role);
|
GetAccService()->GetStringRole(aAccessible->Role(), role);
|
||||||
@@ -951,11 +842,9 @@ logging::AccessibleNNode(const char* aDescr, Accessible* aAccessible)
|
|||||||
Document(aAccessible->Document());
|
Document(aAccessible->Document());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::AccessibleNNode(const char* aDescr, nsINode* aNode) {
|
||||||
logging::AccessibleNNode(const char* aDescr, nsINode* aNode)
|
|
||||||
{
|
|
||||||
DocAccessible* document =
|
DocAccessible* document =
|
||||||
GetAccService()->GetDocAccessible(aNode->OwnerDoc());
|
GetAccService()->GetDocAccessible(aNode->OwnerDoc());
|
||||||
|
|
||||||
if (document) {
|
if (document) {
|
||||||
Accessible* accessible = document->GetAccessible(aNode);
|
Accessible* accessible = document->GetAccessible(aNode);
|
||||||
@@ -979,19 +868,15 @@ logging::AccessibleNNode(const char* aDescr, nsINode* aNode)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::DOMEvent(const char* aDescr, nsINode* aOrigTarget,
|
||||||
logging::DOMEvent(const char* aDescr, nsINode* aOrigTarget,
|
const nsAString& aEventType) {
|
||||||
const nsAString& aEventType)
|
|
||||||
{
|
|
||||||
logging::MsgBegin("DOMEvents", "event '%s' %s",
|
logging::MsgBegin("DOMEvents", "event '%s' %s",
|
||||||
NS_ConvertUTF16toUTF8(aEventType).get(), aDescr);
|
NS_ConvertUTF16toUTF8(aEventType).get(), aDescr);
|
||||||
logging::AccessibleNNode("Target", aOrigTarget);
|
logging::AccessibleNNode("Target", aOrigTarget);
|
||||||
logging::MsgEnd();
|
logging::MsgEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::Stack() {
|
||||||
logging::Stack()
|
|
||||||
{
|
|
||||||
if (IsEnabled(eStack)) {
|
if (IsEnabled(eStack)) {
|
||||||
printf(" stack: \n");
|
printf(" stack: \n");
|
||||||
nsTraceRefcnt::WalkTheStack(stdout);
|
nsTraceRefcnt::WalkTheStack(stdout);
|
||||||
@@ -1001,21 +886,13 @@ logging::Stack()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// namespace logging:: initialization
|
// namespace logging:: initialization
|
||||||
|
|
||||||
bool
|
bool logging::IsEnabled(uint32_t aModules) { return sModules & aModules; }
|
||||||
logging::IsEnabled(uint32_t aModules)
|
|
||||||
{
|
|
||||||
return sModules & aModules;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool logging::IsEnabledAll(uint32_t aModules) {
|
||||||
logging::IsEnabledAll(uint32_t aModules)
|
|
||||||
{
|
|
||||||
return (sModules & aModules) == aModules;
|
return (sModules & aModules) == aModules;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool logging::IsEnabled(const nsAString& aModuleStr) {
|
||||||
logging::IsEnabled(const nsAString& aModuleStr)
|
|
||||||
{
|
|
||||||
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
|
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
|
||||||
if (aModuleStr.EqualsASCII(sModuleMap[idx].mStr))
|
if (aModuleStr.EqualsASCII(sModuleMap[idx].mStr))
|
||||||
return sModules & sModuleMap[idx].mModule;
|
return sModules & sModuleMap[idx].mModule;
|
||||||
@@ -1024,15 +901,8 @@ logging::IsEnabled(const nsAString& aModuleStr)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void logging::Enable(const nsCString& aModules) {
|
||||||
logging::Enable(const nsCString& aModules)
|
|
||||||
{
|
|
||||||
EnableLogging(aModules.get());
|
EnableLogging(aModules.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void logging::CheckEnv() { EnableLogging(PR_GetEnv("A11YLOG")); }
|
||||||
void
|
|
||||||
logging::CheckEnv()
|
|
||||||
{
|
|
||||||
EnableLogging(PR_GetEnv("A11YLOG"));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace mozilla {
|
|||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
class Selection;
|
class Selection;
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
@@ -139,9 +139,8 @@ void SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
|
|||||||
* Log the given accessible elements info.
|
* Log the given accessible elements info.
|
||||||
*/
|
*/
|
||||||
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...);
|
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...);
|
||||||
void TreeInfo(const char* aMsg, uint32_t aExtraFlags,
|
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, const char* aMsg1,
|
||||||
const char* aMsg1, Accessible* aAcc,
|
Accessible* aAcc, const char* aMsg2, nsINode* aNode);
|
||||||
const char* aMsg2, nsINode* aNode);
|
|
||||||
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
|
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*);
|
typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
|
||||||
void Tree(const char* aTitle, const char* aMsgText, Accessible* aRoot,
|
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);
|
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
|
* boundaries of the message body designated by '{' and '}' (2 spaces indent for
|
||||||
* body).
|
* 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();
|
void MsgEnd();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -221,10 +222,9 @@ void Enable(const nsCString& aModules);
|
|||||||
*/
|
*/
|
||||||
void CheckEnv();
|
void CheckEnv();
|
||||||
|
|
||||||
} // namespace logging
|
} // namespace logging
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -5,586 +5,424 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(a,
|
||||||
a,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
// Only some roles truly enjoy life as HTMLLinkAccessibles, for
|
||||||
// Only some roles truly enjoy life as HTMLLinkAccessibles, for details
|
// details see closed bug 494807.
|
||||||
// see closed bug 494807.
|
const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement);
|
||||||
const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement);
|
if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
|
||||||
if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
|
roleMapEntry->role != roles::LINK) {
|
||||||
roleMapEntry->role != roles::LINK) {
|
return new HyperTextAccessibleWrap(aElement,
|
||||||
return new HyperTextAccessibleWrap(aElement, aContext->Document());
|
aContext->Document());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HTMLLinkAccessible(aElement, aContext->Document());
|
return new HTMLLinkAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::LINK
|
roles::LINK)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(abbr,
|
MARKUPMAP(abbr, New_HyperText, 0)
|
||||||
New_HyperText,
|
|
||||||
|
MARKUPMAP(acronym, New_HyperText, 0)
|
||||||
|
|
||||||
|
MARKUPMAP(article, New_HyperText, roles::ARTICLE, Attr(xmlroles, article))
|
||||||
|
|
||||||
|
MARKUPMAP(aside, New_HyperText, roles::LANDMARK)
|
||||||
|
|
||||||
|
MARKUPMAP(blockquote, New_HyperText, roles::BLOCKQUOTE)
|
||||||
|
|
||||||
|
MARKUPMAP(button,
|
||||||
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
|
return new HTMLButtonAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
0)
|
0)
|
||||||
|
|
||||||
MARKUPMAP(acronym,
|
MARKUPMAP(caption,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
|
if (aContext->IsTable()) {
|
||||||
|
dom::HTMLTableElement* tableEl =
|
||||||
|
dom::HTMLTableElement::FromNode(aContext->GetContent());
|
||||||
|
if (tableEl && tableEl == aElement->GetParent() &&
|
||||||
|
tableEl->GetCaption() == aElement) {
|
||||||
|
return new HTMLCaptionAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
},
|
||||||
0)
|
0)
|
||||||
|
|
||||||
MARKUPMAP(article,
|
MARKUPMAP(dd, New_HTMLDtOrDd<HyperTextAccessibleWrap>, roles::DEFINITION)
|
||||||
New_HyperText,
|
|
||||||
roles::ARTICLE,
|
|
||||||
Attr(xmlroles, article))
|
|
||||||
|
|
||||||
MARKUPMAP(aside,
|
MARKUPMAP(del, New_HyperText, roles::CONTENT_DELETION)
|
||||||
New_HyperText,
|
|
||||||
roles::LANDMARK)
|
|
||||||
|
|
||||||
MARKUPMAP(blockquote,
|
MARKUPMAP(details, New_HyperText, roles::DETAILS)
|
||||||
New_HyperText,
|
|
||||||
roles::BLOCKQUOTE)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(div, nullptr, roles::SECTION)
|
||||||
button,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLButtonAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(dl,
|
||||||
caption,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLListAccessible(aElement, aContext->Document());
|
||||||
if (aContext->IsTable()) {
|
},
|
||||||
dom::HTMLTableElement* tableEl =
|
roles::DEFINITION_LIST)
|
||||||
dom::HTMLTableElement::FromNode(aContext->GetContent());
|
|
||||||
if (tableEl && tableEl == aElement->GetParent() &&
|
|
||||||
tableEl->GetCaption() == aElement) {
|
|
||||||
return new HTMLCaptionAccessible(aElement, aContext->Document());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(dd,
|
MARKUPMAP(dt, New_HTMLDtOrDd<HTMLLIAccessible>, roles::TERM)
|
||||||
New_HTMLDtOrDd<HyperTextAccessibleWrap>,
|
|
||||||
roles::DEFINITION)
|
|
||||||
|
|
||||||
MARKUPMAP(del,
|
MARKUPMAP(figcaption,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::CONTENT_DELETION)
|
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
roles::CAPTION)
|
||||||
|
|
||||||
MARKUPMAP(details,
|
MARKUPMAP(figure,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::DETAILS)
|
return new HTMLFigureAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
roles::FIGURE, Attr(xmlroles, figure))
|
||||||
|
|
||||||
MARKUPMAP(div,
|
MARKUPMAP(fieldset,
|
||||||
nullptr,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::SECTION)
|
return new HTMLGroupboxAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(form,
|
||||||
dl,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLFormAccessible(aElement, aContext->Document());
|
||||||
return new HTMLListAccessible(aElement, aContext->Document());
|
},
|
||||||
},
|
0)
|
||||||
roles::DEFINITION_LIST
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(dt,
|
MARKUPMAP(footer,
|
||||||
New_HTMLDtOrDd<HTMLLIAccessible>,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::TERM)
|
return new HTMLHeaderOrFooterAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(header,
|
||||||
figcaption,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLHeaderOrFooterAccessible(aElement,
|
||||||
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
|
aContext->Document());
|
||||||
},
|
},
|
||||||
roles::CAPTION
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(h1, New_HyperText, roles::HEADING)
|
||||||
figure,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLFigureAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
roles::FIGURE,
|
|
||||||
Attr(xmlroles, figure)
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(h2, New_HyperText, roles::HEADING)
|
||||||
fieldset,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLGroupboxAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(h3, New_HyperText, roles::HEADING)
|
||||||
form,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLFormAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(h4, New_HyperText, roles::HEADING)
|
||||||
footer,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(h5, New_HyperText, roles::HEADING)
|
||||||
header,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(h1,
|
MARKUPMAP(h6, New_HyperText, roles::HEADING)
|
||||||
New_HyperText,
|
|
||||||
roles::HEADING)
|
|
||||||
|
|
||||||
MARKUPMAP(h2,
|
MARKUPMAP(hr,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::HEADING)
|
return new HTMLHRAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
MARKUPMAP(h3,
|
MARKUPMAP(input,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::HEADING)
|
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||||
|
nsGkAtoms::checkbox, eIgnoreCase)) {
|
||||||
|
return new CheckboxAccessible(aElement, aContext->Document());
|
||||||
|
}
|
||||||
|
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||||
|
nsGkAtoms::radio, eIgnoreCase)) {
|
||||||
|
return new HTMLRadioButtonAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
|
}
|
||||||
|
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||||
|
nsGkAtoms::time, eIgnoreCase)) {
|
||||||
|
return new EnumRoleAccessible<roles::GROUPING>(
|
||||||
|
aElement, aContext->Document());
|
||||||
|
}
|
||||||
|
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||||
|
nsGkAtoms::date, eIgnoreCase)) {
|
||||||
|
return new EnumRoleAccessible<roles::DATE_EDITOR>(
|
||||||
|
aElement, aContext->Document());
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
MARKUPMAP(h4,
|
MARKUPMAP(ins, New_HyperText, roles::CONTENT_INSERTION)
|
||||||
New_HyperText,
|
|
||||||
roles::HEADING)
|
|
||||||
|
|
||||||
MARKUPMAP(h5,
|
MARKUPMAP(label,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::HEADING)
|
return new HTMLLabelAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
roles::LABEL)
|
||||||
|
|
||||||
MARKUPMAP(h6,
|
MARKUPMAP(legend,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::HEADING)
|
return new HTMLLegendAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
roles::LABEL)
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(li,
|
||||||
hr,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
// If list item is a child of accessible list then create an
|
||||||
return new HTMLHRAccessible(aElement, aContext->Document());
|
// accessible for it unconditionally by tag name. nsBlockFrame
|
||||||
},
|
// creates the list item accessible for other elements styled as
|
||||||
0
|
// list items.
|
||||||
)
|
if (aContext->IsList() &&
|
||||||
|
aContext->GetContent() == aElement->GetParent()) {
|
||||||
|
return new HTMLLIAccessible(aElement, aContext->Document());
|
||||||
|
}
|
||||||
|
|
||||||
MARKUPMAP(
|
return nullptr;
|
||||||
input,
|
},
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
0)
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
||||||
nsGkAtoms::checkbox, eIgnoreCase)) {
|
|
||||||
return new CheckboxAccessible(aElement, aContext->Document());
|
|
||||||
}
|
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
||||||
nsGkAtoms::radio, eIgnoreCase)) {
|
|
||||||
return new HTMLRadioButtonAccessible(aElement, aContext->Document());
|
|
||||||
}
|
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
||||||
nsGkAtoms::time, eIgnoreCase)) {
|
|
||||||
return new EnumRoleAccessible<roles::GROUPING>(aElement, aContext->Document());
|
|
||||||
}
|
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
||||||
nsGkAtoms::date, eIgnoreCase)) {
|
|
||||||
return new EnumRoleAccessible<roles::DATE_EDITOR>(aElement, aContext->Document());
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(ins,
|
MARKUPMAP(main, New_HyperText, roles::LANDMARK)
|
||||||
New_HyperText,
|
|
||||||
roles::CONTENT_INSERTION)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(map, nullptr, roles::TEXT_CONTAINER)
|
||||||
label,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLLabelAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
roles::LABEL
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(math, New_HyperText, roles::MATHML_MATH)
|
||||||
legend,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLLegendAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
roles::LABEL
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(mi_, New_HyperText, roles::MATHML_IDENTIFIER)
|
||||||
li,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
// If list item is a child of accessible list then create an accessible for
|
|
||||||
// it unconditionally by tag name. nsBlockFrame creates the list item
|
|
||||||
// accessible for other elements styled as list items.
|
|
||||||
if (aContext->IsList() && aContext->GetContent() == aElement->GetParent()) {
|
|
||||||
return new HTMLLIAccessible(aElement, aContext->Document());
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
MARKUPMAP(mn_, New_HyperText, roles::MATHML_NUMBER)
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(main,
|
MARKUPMAP(mo_, New_HyperText, roles::MATHML_OPERATOR,
|
||||||
New_HyperText,
|
AttrFromDOM(accent_, accent_), AttrFromDOM(fence_, fence_),
|
||||||
roles::LANDMARK)
|
AttrFromDOM(separator_, separator_), AttrFromDOM(largeop_, largeop_))
|
||||||
|
|
||||||
MARKUPMAP(map,
|
MARKUPMAP(mtext_, New_HyperText, roles::MATHML_TEXT)
|
||||||
nullptr,
|
|
||||||
roles::TEXT_CONTAINER)
|
|
||||||
|
|
||||||
MARKUPMAP(math,
|
MARKUPMAP(ms_, New_HyperText, roles::MATHML_STRING_LITERAL)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_MATH)
|
|
||||||
|
|
||||||
MARKUPMAP(mi_,
|
MARKUPMAP(mglyph_, New_HyperText, roles::MATHML_GLYPH)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_IDENTIFIER)
|
|
||||||
|
|
||||||
MARKUPMAP(mn_,
|
MARKUPMAP(mrow_, New_HyperText, roles::MATHML_ROW)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_NUMBER)
|
|
||||||
|
|
||||||
MARKUPMAP(mo_,
|
MARKUPMAP(mfrac_, New_HyperText, roles::MATHML_FRACTION,
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_OPERATOR,
|
|
||||||
AttrFromDOM(accent_, accent_),
|
|
||||||
AttrFromDOM(fence_, fence_),
|
|
||||||
AttrFromDOM(separator_, separator_),
|
|
||||||
AttrFromDOM(largeop_, largeop_))
|
|
||||||
|
|
||||||
MARKUPMAP(mtext_,
|
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_TEXT)
|
|
||||||
|
|
||||||
MARKUPMAP(ms_,
|
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_STRING_LITERAL)
|
|
||||||
|
|
||||||
MARKUPMAP(mglyph_,
|
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_GLYPH)
|
|
||||||
|
|
||||||
MARKUPMAP(mrow_,
|
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_ROW)
|
|
||||||
|
|
||||||
MARKUPMAP(mfrac_,
|
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_FRACTION,
|
|
||||||
AttrFromDOM(bevelled_, bevelled_),
|
AttrFromDOM(bevelled_, bevelled_),
|
||||||
AttrFromDOM(linethickness_, linethickness_))
|
AttrFromDOM(linethickness_, linethickness_))
|
||||||
|
|
||||||
MARKUPMAP(msqrt_,
|
MARKUPMAP(msqrt_, New_HyperText, roles::MATHML_SQUARE_ROOT)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_SQUARE_ROOT)
|
|
||||||
|
|
||||||
MARKUPMAP(mroot_,
|
MARKUPMAP(mroot_, New_HyperText, roles::MATHML_ROOT)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_ROOT)
|
|
||||||
|
|
||||||
MARKUPMAP(mfenced_,
|
MARKUPMAP(mfenced_, New_HyperText, roles::MATHML_FENCED,
|
||||||
New_HyperText,
|
AttrFromDOM(close, close), AttrFromDOM(open, open),
|
||||||
roles::MATHML_FENCED,
|
|
||||||
AttrFromDOM(close, close),
|
|
||||||
AttrFromDOM(open, open),
|
|
||||||
AttrFromDOM(separators_, separators_))
|
AttrFromDOM(separators_, separators_))
|
||||||
|
|
||||||
MARKUPMAP(menclose_,
|
MARKUPMAP(menclose_, New_HyperText, roles::MATHML_ENCLOSED,
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_ENCLOSED,
|
|
||||||
AttrFromDOM(notation_, notation_))
|
AttrFromDOM(notation_, notation_))
|
||||||
|
|
||||||
MARKUPMAP(mstyle_,
|
MARKUPMAP(mstyle_, New_HyperText, roles::MATHML_STYLE)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_STYLE)
|
|
||||||
|
|
||||||
MARKUPMAP(msub_,
|
MARKUPMAP(msub_, New_HyperText, roles::MATHML_SUB)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_SUB)
|
|
||||||
|
|
||||||
MARKUPMAP(msup_,
|
MARKUPMAP(msup_, New_HyperText, roles::MATHML_SUP)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_SUP)
|
|
||||||
|
|
||||||
MARKUPMAP(msubsup_,
|
MARKUPMAP(msubsup_, New_HyperText, roles::MATHML_SUB_SUP)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_SUB_SUP)
|
|
||||||
|
|
||||||
MARKUPMAP(munder_,
|
MARKUPMAP(munder_, New_HyperText, roles::MATHML_UNDER,
|
||||||
New_HyperText,
|
AttrFromDOM(accentunder_, accentunder_), AttrFromDOM(align, align))
|
||||||
roles::MATHML_UNDER,
|
|
||||||
AttrFromDOM(accentunder_, accentunder_),
|
|
||||||
AttrFromDOM(align, align))
|
|
||||||
|
|
||||||
MARKUPMAP(mover_,
|
MARKUPMAP(mover_, New_HyperText, roles::MATHML_OVER,
|
||||||
New_HyperText,
|
AttrFromDOM(accent_, accent_), AttrFromDOM(align, align))
|
||||||
roles::MATHML_OVER,
|
|
||||||
|
MARKUPMAP(munderover_, New_HyperText, roles::MATHML_UNDER_OVER,
|
||||||
AttrFromDOM(accent_, accent_),
|
AttrFromDOM(accent_, accent_),
|
||||||
AttrFromDOM(align, align))
|
AttrFromDOM(accentunder_, accentunder_), AttrFromDOM(align, align))
|
||||||
|
|
||||||
MARKUPMAP(munderover_,
|
MARKUPMAP(mmultiscripts_, New_HyperText, roles::MATHML_MULTISCRIPTS)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_UNDER_OVER,
|
|
||||||
AttrFromDOM(accent_, accent_),
|
|
||||||
AttrFromDOM(accentunder_, accentunder_),
|
|
||||||
AttrFromDOM(align, align))
|
|
||||||
|
|
||||||
MARKUPMAP(mmultiscripts_,
|
MARKUPMAP(mtable_,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
roles::MATHML_MULTISCRIPTS)
|
return new HTMLTableAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
roles::MATHML_TABLE, AttrFromDOM(align, align),
|
||||||
|
AttrFromDOM(columnlines_, columnlines_),
|
||||||
|
AttrFromDOM(rowlines_, rowlines_))
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(mlabeledtr_,
|
||||||
mtable_,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLTableRowAccessible(aElement, aContext->Document());
|
||||||
return new HTMLTableAccessible(aElement, aContext->Document());
|
},
|
||||||
},
|
roles::MATHML_LABELED_ROW)
|
||||||
roles::MATHML_TABLE,
|
|
||||||
AttrFromDOM(align, align),
|
|
||||||
AttrFromDOM(columnlines_, columnlines_),
|
|
||||||
AttrFromDOM(rowlines_, rowlines_)
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(mtr_,
|
||||||
mlabeledtr_,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLTableRowAccessible(aElement, aContext->Document());
|
||||||
return new HTMLTableRowAccessible(aElement, aContext->Document());
|
},
|
||||||
},
|
roles::MATHML_TABLE_ROW)
|
||||||
roles::MATHML_LABELED_ROW
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(mtd_,
|
||||||
mtr_,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLTableCellAccessible(aElement, aContext->Document());
|
||||||
return new HTMLTableRowAccessible(aElement, aContext->Document());
|
},
|
||||||
},
|
roles::MATHML_CELL)
|
||||||
roles::MATHML_TABLE_ROW
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(maction_, New_HyperText, roles::MATHML_ACTION,
|
||||||
mtd_,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLTableCellAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
roles::MATHML_CELL
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(maction_,
|
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_ACTION,
|
|
||||||
AttrFromDOM(actiontype_, actiontype_),
|
AttrFromDOM(actiontype_, actiontype_),
|
||||||
AttrFromDOM(selection_, selection_))
|
AttrFromDOM(selection_, selection_))
|
||||||
|
|
||||||
MARKUPMAP(merror_,
|
MARKUPMAP(merror_, New_HyperText, roles::MATHML_ERROR)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_ERROR)
|
|
||||||
|
|
||||||
MARKUPMAP(mstack_,
|
MARKUPMAP(mstack_, New_HyperText, roles::MATHML_STACK,
|
||||||
New_HyperText,
|
AttrFromDOM(align, align), AttrFromDOM(position, position))
|
||||||
roles::MATHML_STACK,
|
|
||||||
AttrFromDOM(align, align),
|
|
||||||
AttrFromDOM(position, position))
|
|
||||||
|
|
||||||
MARKUPMAP(mlongdiv_,
|
MARKUPMAP(mlongdiv_, New_HyperText, roles::MATHML_LONG_DIVISION,
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_LONG_DIVISION,
|
|
||||||
AttrFromDOM(longdivstyle_, longdivstyle_))
|
AttrFromDOM(longdivstyle_, longdivstyle_))
|
||||||
|
|
||||||
MARKUPMAP(msgroup_,
|
MARKUPMAP(msgroup_, New_HyperText, roles::MATHML_STACK_GROUP,
|
||||||
New_HyperText,
|
AttrFromDOM(position, position), AttrFromDOM(shift_, shift_))
|
||||||
roles::MATHML_STACK_GROUP,
|
|
||||||
AttrFromDOM(position, position),
|
|
||||||
AttrFromDOM(shift_, shift_))
|
|
||||||
|
|
||||||
MARKUPMAP(msrow_,
|
MARKUPMAP(msrow_, New_HyperText, roles::MATHML_STACK_ROW,
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_STACK_ROW,
|
|
||||||
AttrFromDOM(position, position))
|
AttrFromDOM(position, position))
|
||||||
|
|
||||||
MARKUPMAP(mscarries_,
|
MARKUPMAP(mscarries_, New_HyperText, roles::MATHML_STACK_CARRIES,
|
||||||
New_HyperText,
|
AttrFromDOM(location_, location_), AttrFromDOM(position, position))
|
||||||
roles::MATHML_STACK_CARRIES,
|
|
||||||
AttrFromDOM(location_, location_),
|
|
||||||
AttrFromDOM(position, position))
|
|
||||||
|
|
||||||
MARKUPMAP(mscarry_,
|
MARKUPMAP(mscarry_, New_HyperText, roles::MATHML_STACK_CARRY,
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_STACK_CARRY,
|
|
||||||
AttrFromDOM(crossout_, crossout_))
|
AttrFromDOM(crossout_, crossout_))
|
||||||
|
|
||||||
MARKUPMAP(msline_,
|
MARKUPMAP(msline_, New_HyperText, roles::MATHML_STACK_LINE,
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_STACK_LINE,
|
|
||||||
AttrFromDOM(position, position))
|
AttrFromDOM(position, position))
|
||||||
|
|
||||||
MARKUPMAP(nav,
|
MARKUPMAP(nav, New_HyperText, roles::LANDMARK)
|
||||||
New_HyperText,
|
|
||||||
roles::LANDMARK)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(ol,
|
||||||
ol,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLListAccessible(aElement, aContext->Document());
|
||||||
return new HTMLListAccessible(aElement, aContext->Document());
|
},
|
||||||
},
|
roles::LIST)
|
||||||
roles::LIST
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(option,
|
||||||
option,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLSelectOptionAccessible(aElement,
|
||||||
return new HTMLSelectOptionAccessible(aElement, aContext->Document());
|
aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
|
||||||
optgroup,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLSelectOptGroupAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
|
||||||
output,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLOutputAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
roles::SECTION,
|
|
||||||
Attr(live, polite)
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(p,
|
|
||||||
nullptr,
|
|
||||||
roles::PARAGRAPH)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
|
||||||
progress,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
return new HTMLProgressAccessible(aElement, aContext->Document());
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(q,
|
|
||||||
New_HyperText,
|
|
||||||
0)
|
0)
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(optgroup,
|
||||||
section,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLSelectOptGroupAccessible(aElement,
|
||||||
return new HTMLSectionAccessible(aElement, aContext->Document());
|
aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(output,
|
||||||
summary,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLOutputAccessible(aElement, aContext->Document());
|
||||||
return new HTMLSummaryAccessible(aElement, aContext->Document());
|
},
|
||||||
},
|
roles::SECTION, Attr(live, polite))
|
||||||
roles::SUMMARY
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(p, nullptr, roles::PARAGRAPH)
|
||||||
table,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
|
||||||
if (aElement->GetPrimaryFrame() &&
|
|
||||||
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableType) {
|
|
||||||
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
},
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(time,
|
MARKUPMAP(progress,
|
||||||
New_HyperText,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
0,
|
return new HTMLProgressAccessible(aElement, aContext->Document());
|
||||||
Attr(xmlroles, time),
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
|
MARKUPMAP(q, New_HyperText, 0)
|
||||||
|
|
||||||
|
MARKUPMAP(section,
|
||||||
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
|
return new HTMLSectionAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
|
MARKUPMAP(summary,
|
||||||
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
|
return new HTMLSummaryAccessible(aElement, aContext->Document());
|
||||||
|
},
|
||||||
|
roles::SUMMARY)
|
||||||
|
|
||||||
|
MARKUPMAP(table,
|
||||||
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
|
if (aElement->GetPrimaryFrame() &&
|
||||||
|
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||||
|
eHTMLTableType) {
|
||||||
|
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
|
MARKUPMAP(time, New_HyperText, 0, Attr(xmlroles, time),
|
||||||
AttrFromDOM(datetime, datetime))
|
AttrFromDOM(datetime, datetime))
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(td,
|
||||||
td,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
if (aContext->IsTableRow() &&
|
||||||
if (aContext->IsTableRow() && aContext->GetContent() == aElement->GetParent()) {
|
aContext->GetContent() == aElement->GetParent()) {
|
||||||
// If HTML:td element is part of its HTML:table, which has CSS
|
// If HTML:td element is part of its HTML:table, which has CSS
|
||||||
// display style other than 'table', then create a generic table cell
|
// display style other than 'table', then create a generic table
|
||||||
// accessible, because there's no underlying table layout and thus native
|
// cell accessible, because there's no underlying table layout and
|
||||||
// HTML table cell class doesn't work.
|
// thus native HTML table cell class doesn't work. The same is
|
||||||
// The same is true if the cell itself has CSS display:block;.
|
// true if the cell itself has CSS display:block;.
|
||||||
if (!aContext->IsHTMLTableRow() ||
|
if (!aContext->IsHTMLTableRow() ||
|
||||||
(aElement->GetPrimaryFrame() &&
|
(aElement->GetPrimaryFrame() &&
|
||||||
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableCellType)) {
|
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||||
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
|
eHTMLTableCellType)) {
|
||||||
}
|
return new ARIAGridCellAccessibleWrap(aElement,
|
||||||
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
|
aContext->Document());
|
||||||
return new HTMLTableHeaderCellAccessibleWrap(aElement, aContext->Document());
|
}
|
||||||
}
|
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
|
||||||
}
|
return new HTMLTableHeaderCellAccessibleWrap(
|
||||||
return nullptr;
|
aElement, aContext->Document());
|
||||||
},
|
}
|
||||||
0
|
}
|
||||||
)
|
return nullptr;
|
||||||
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(th,
|
||||||
th,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
if (aContext->IsTableRow() &&
|
||||||
if (aContext->IsTableRow() && aContext->GetContent() == aElement->GetParent()) {
|
aContext->GetContent() == aElement->GetParent()) {
|
||||||
if (!aContext->IsHTMLTableRow()) {
|
if (!aContext->IsHTMLTableRow()) {
|
||||||
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
|
return new ARIAGridCellAccessibleWrap(aElement,
|
||||||
}
|
aContext->Document());
|
||||||
return new HTMLTableHeaderCellAccessibleWrap(aElement, aContext->Document());
|
}
|
||||||
}
|
return new HTMLTableHeaderCellAccessibleWrap(
|
||||||
return nullptr;
|
aElement, aContext->Document());
|
||||||
},
|
}
|
||||||
0
|
return nullptr;
|
||||||
)
|
},
|
||||||
|
0)
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(tr,
|
||||||
tr,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
// If HTML:tr element is part of its HTML:table, which has CSS
|
||||||
// If HTML:tr element is part of its HTML:table, which has CSS
|
// display style other than 'table', then create a generic table row
|
||||||
// display style other than 'table', then create a generic table row
|
// accessible, because there's no underlying table layout and thus
|
||||||
// accessible, because there's no underlying table layout and thus native
|
// native HTML table row class doesn't work. Refer to
|
||||||
// HTML table row class doesn't work. Refer to
|
// CreateAccessibleByFrameType dual logic.
|
||||||
// CreateAccessibleByFrameType dual logic.
|
Accessible* table = aContext->IsTable() ? aContext : nullptr;
|
||||||
Accessible* table = aContext->IsTable() ? aContext : nullptr;
|
if (!table && aContext->Parent() && aContext->Parent()->IsTable()) {
|
||||||
if (!table && aContext->Parent() && aContext->Parent()->IsTable()) {
|
table = aContext->Parent();
|
||||||
table = aContext->Parent();
|
}
|
||||||
}
|
if (table) {
|
||||||
if (table) {
|
nsIContent* parentContent = aElement->GetParent();
|
||||||
nsIContent* parentContent = aElement->GetParent();
|
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
|
||||||
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
|
if (parentFrame && !parentFrame->IsTableWrapperFrame()) {
|
||||||
if (parentFrame && !parentFrame->IsTableWrapperFrame()) {
|
parentContent = parentContent->GetParent();
|
||||||
parentContent = parentContent->GetParent();
|
parentFrame = parentContent->GetPrimaryFrame();
|
||||||
parentFrame = parentContent->GetPrimaryFrame();
|
if (table->GetContent() == parentContent &&
|
||||||
if (table->GetContent() == parentContent &&
|
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
|
||||||
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
|
(aElement->GetPrimaryFrame() &&
|
||||||
(aElement->GetPrimaryFrame() &&
|
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||||
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableRowType))) {
|
eHTMLTableRowType))) {
|
||||||
return new ARIARowAccessible(aElement, aContext->Document());
|
return new ARIARowAccessible(aElement, aContext->Document());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(ul,
|
||||||
ul,
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
return new HTMLListAccessible(aElement, aContext->Document());
|
||||||
return new HTMLListAccessible(aElement, aContext->Document());
|
},
|
||||||
},
|
roles::LIST)
|
||||||
roles::LIST
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -24,10 +24,11 @@ using namespace mozilla::dom;
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
NotificationController::NotificationController(DocAccessible* aDocument,
|
NotificationController::NotificationController(DocAccessible* aDocument,
|
||||||
nsIPresShell* aPresShell) :
|
nsIPresShell* aPresShell)
|
||||||
EventQueue(aDocument), mObservingState(eNotObservingRefresh),
|
: EventQueue(aDocument),
|
||||||
mPresShell(aPresShell), mEventGeneration(0)
|
mObservingState(eNotObservingRefresh),
|
||||||
{
|
mPresShell(aPresShell),
|
||||||
|
mEventGeneration(0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mMoveGuardOnStack = false;
|
mMoveGuardOnStack = false;
|
||||||
#endif
|
#endif
|
||||||
@@ -36,11 +37,9 @@ NotificationController::NotificationController(DocAccessible* aDocument,
|
|||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationController::~NotificationController()
|
NotificationController::~NotificationController() {
|
||||||
{
|
|
||||||
NS_ASSERTION(!mDocument, "Controller wasn't shutdown properly!");
|
NS_ASSERTION(!mDocument, "Controller wasn't shutdown properly!");
|
||||||
if (mDocument)
|
if (mDocument) Shutdown();
|
||||||
Shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -52,8 +51,7 @@ NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE(NotificationController)
|
|||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(NotificationController)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(NotificationController)
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(NotificationController)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(NotificationController)
|
||||||
if (tmp->mDocument)
|
if (tmp->mDocument) tmp->Shutdown();
|
||||||
tmp->Shutdown();
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NotificationController)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NotificationController)
|
||||||
@@ -63,8 +61,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NotificationController)
|
|||||||
cb.NoteXPCOMChild(it.Key());
|
cb.NoteXPCOMChild(it.Key());
|
||||||
nsTArray<nsCOMPtr<nsIContent>>* list = it.UserData();
|
nsTArray<nsCOMPtr<nsIContent>>* list = it.UserData();
|
||||||
for (uint32_t i = 0; i < list->Length(); i++) {
|
for (uint32_t i = 0; i < list->Length(); i++) {
|
||||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mContentInsertions value item");
|
||||||
"mContentInsertions value item");
|
|
||||||
cb.NoteXPCOMChild(list->ElementAt(i));
|
cb.NoteXPCOMChild(list->ElementAt(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,9 +75,7 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(NotificationController, Release)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// NotificationCollector: public
|
// NotificationCollector: public
|
||||||
|
|
||||||
void
|
void NotificationController::Shutdown() {
|
||||||
NotificationController::Shutdown()
|
|
||||||
{
|
|
||||||
if (mObservingState != eNotObservingRefresh &&
|
if (mObservingState != eNotObservingRefresh &&
|
||||||
mPresShell->RemoveRefreshObserver(this, FlushType::Display)) {
|
mPresShell->RemoveRefreshObserver(this, FlushType::Display)) {
|
||||||
mObservingState = eNotObservingRefresh;
|
mObservingState = eNotObservingRefresh;
|
||||||
@@ -106,9 +101,7 @@ NotificationController::Shutdown()
|
|||||||
mEventTree.Clear();
|
mEventTree.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTree*
|
EventTree* NotificationController::QueueMutation(Accessible* aContainer) {
|
||||||
NotificationController::QueueMutation(Accessible* aContainer)
|
|
||||||
{
|
|
||||||
EventTree* tree = mEventTree.FindOrInsert(aContainer);
|
EventTree* tree = mEventTree.FindOrInsert(aContainer);
|
||||||
if (tree) {
|
if (tree) {
|
||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
@@ -116,15 +109,14 @@ NotificationController::QueueMutation(Accessible* aContainer)
|
|||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent) {
|
||||||
NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
|
|
||||||
{
|
|
||||||
// We have to allow there to be a hide and then a show event for a target
|
// 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
|
// 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.
|
// then a hide for a target which means we need to check for that here.
|
||||||
if (aEvent->GetEventType() == nsIAccessibleEvent::EVENT_HIDE &&
|
if (aEvent->GetEventType() == nsIAccessibleEvent::EVENT_HIDE &&
|
||||||
aEvent->GetAccessible()->ShowEventTarget()) {
|
aEvent->GetAccessible()->ShowEventTarget()) {
|
||||||
AccTreeMutationEvent* showEvent = mMutationMap.GetEvent(aEvent->GetAccessible(), EventMap::ShowEvent);
|
AccTreeMutationEvent* showEvent =
|
||||||
|
mMutationMap.GetEvent(aEvent->GetAccessible(), EventMap::ShowEvent);
|
||||||
DropMutationEvent(showEvent);
|
DropMutationEvent(showEvent);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -139,7 +131,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mLastMutationEvent) {
|
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);
|
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
|
// We need to fire a reorder event after all of the events targeted at shown
|
||||||
// hidden children of a container. So either queue a new one, or move an
|
// 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
|
// existing one to the end of the queue if the container already has a
|
||||||
// reorder event.
|
// reorder event.
|
||||||
Accessible* target = aEvent->GetAccessible();
|
Accessible* target = aEvent->GetAccessible();
|
||||||
@@ -178,7 +171,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
|
|||||||
// container may be changing.
|
// container may be changing.
|
||||||
QueueNameChange(target);
|
QueueNameChange(target);
|
||||||
} else {
|
} else {
|
||||||
AccReorderEvent* event = downcast_accEvent(mMutationMap.GetEvent(container, EventMap::ReorderEvent));
|
AccReorderEvent* event = downcast_accEvent(
|
||||||
|
mMutationMap.GetEvent(container, EventMap::ReorderEvent));
|
||||||
reorder = event;
|
reorder = event;
|
||||||
if (mFirstMutationEvent == event) {
|
if (mFirstMutationEvent == event) {
|
||||||
mFirstMutationEvent = event->NextEvent();
|
mFirstMutationEvent = event->NextEvent();
|
||||||
@@ -186,8 +180,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
|
|||||||
event->PrevEvent()->SetNextEvent(event->NextEvent());
|
event->PrevEvent()->SetNextEvent(event->NextEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
event->NextEvent()->SetPrevEvent(event->PrevEvent());
|
event->NextEvent()->SetPrevEvent(event->PrevEvent());
|
||||||
event->SetNextEvent(nullptr);
|
event->SetNextEvent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
reorder->SetEventGeneration(mEventGeneration);
|
reorder->SetEventGeneration(mEventGeneration);
|
||||||
@@ -211,11 +205,13 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
|
|||||||
|
|
||||||
int32_t offset = container->AsHyperText()->GetChildOffset(target);
|
int32_t offset = container->AsHyperText()->GetChildOffset(target);
|
||||||
AccTreeMutationEvent* prevEvent = aEvent->PrevEvent();
|
AccTreeMutationEvent* prevEvent = aEvent->PrevEvent();
|
||||||
while (prevEvent && prevEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER) {
|
while (prevEvent &&
|
||||||
|
prevEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER) {
|
||||||
prevEvent = prevEvent->PrevEvent();
|
prevEvent = prevEvent->PrevEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevEvent && prevEvent->GetEventType() == nsIAccessibleEvent::EVENT_HIDE &&
|
if (prevEvent &&
|
||||||
|
prevEvent->GetEventType() == nsIAccessibleEvent::EVENT_HIDE &&
|
||||||
mutEvent->IsHide()) {
|
mutEvent->IsHide()) {
|
||||||
AccHideEvent* prevHide = downcast_accEvent(prevEvent);
|
AccHideEvent* prevHide = downcast_accEvent(prevEvent);
|
||||||
AccTextChangeEvent* prevTextChange = prevHide->mTextChangeEvent;
|
AccTextChangeEvent* prevTextChange = prevHide->mTextChangeEvent;
|
||||||
@@ -228,7 +224,8 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
|
|||||||
target->AppendTextTo(temp);
|
target->AppendTextTo(temp);
|
||||||
|
|
||||||
uint32_t extraLen = temp.Length();
|
uint32_t extraLen = temp.Length();
|
||||||
temp += prevTextChange->mModifiedText;;
|
temp += prevTextChange->mModifiedText;
|
||||||
|
;
|
||||||
prevTextChange->mModifiedText = temp;
|
prevTextChange->mModifiedText = temp;
|
||||||
prevTextChange->mStart -= extraLen;
|
prevTextChange->mStart -= extraLen;
|
||||||
prevHide->mTextChangeEvent.swap(mutEvent->mTextChangeEvent);
|
prevHide->mTextChangeEvent.swap(mutEvent->mTextChangeEvent);
|
||||||
@@ -256,17 +253,15 @@ NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!mutEvent->mTextChangeEvent) {
|
if (!mutEvent->mTextChangeEvent) {
|
||||||
mutEvent->mTextChangeEvent =
|
mutEvent->mTextChangeEvent = new AccTextChangeEvent(
|
||||||
new AccTextChangeEvent(container, offset, text, mutEvent->IsShow(),
|
container, offset, text, mutEvent->IsShow(),
|
||||||
aEvent->mIsFromUserInput ? eFromUserInput : eNoUserInput);
|
aEvent->mIsFromUserInput ? eFromUserInput : eNoUserInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void NotificationController::DropMutationEvent(AccTreeMutationEvent* aEvent) {
|
||||||
NotificationController::DropMutationEvent(AccTreeMutationEvent* aEvent)
|
|
||||||
{
|
|
||||||
// unset the event bits since the event isn't being fired any more.
|
// unset the event bits since the event isn't being fired any more.
|
||||||
if (aEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER) {
|
if (aEvent->GetEventType() == nsIAccessibleEvent::EVENT_REORDER) {
|
||||||
aEvent->GetAccessible()->SetReorderEventTarget(false);
|
aEvent->GetAccessible()->SetReorderEventTarget(false);
|
||||||
@@ -301,9 +296,7 @@ NotificationController::DropMutationEvent(AccTreeMutationEvent* aEvent)
|
|||||||
mMutationMap.RemoveEvent(aEvent);
|
mMutationMap.RemoveEvent(aEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void NotificationController::CoalesceMutationEvents() {
|
||||||
NotificationController::CoalesceMutationEvents()
|
|
||||||
{
|
|
||||||
AccTreeMutationEvent* event = mFirstMutationEvent;
|
AccTreeMutationEvent* event = mFirstMutationEvent;
|
||||||
while (event) {
|
while (event) {
|
||||||
AccTreeMutationEvent* nextEvent = event->NextEvent();
|
AccTreeMutationEvent* nextEvent = event->NextEvent();
|
||||||
@@ -325,14 +318,16 @@ NotificationController::CoalesceMutationEvents()
|
|||||||
|
|
||||||
Accessible* parent = acc->Parent();
|
Accessible* parent = acc->Parent();
|
||||||
if (parent->ReorderEventTarget()) {
|
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
|
// 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
|
// hide events targeted at the children of its target. We keep the
|
||||||
// invariant that event generation goes up as you are farther in 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
|
// queue, so we want to use the spot of the event with the higher
|
||||||
// generation number, and keep that generation number.
|
// generation number, and keep that generation number.
|
||||||
if (reorder && reorder->EventGeneration() < event->EventGeneration()) {
|
if (reorder &&
|
||||||
|
reorder->EventGeneration() < event->EventGeneration()) {
|
||||||
reorder->SetEventGeneration(event->EventGeneration());
|
reorder->SetEventGeneration(event->EventGeneration());
|
||||||
|
|
||||||
// It may be true that reorder was before event, and we coalesced
|
// It may be true that reorder was before event, and we coalesced
|
||||||
@@ -378,7 +373,8 @@ NotificationController::CoalesceMutationEvents()
|
|||||||
parent = parent->Parent();
|
parent = parent->Parent();
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
AccHideEvent* hideEvent = downcast_accEvent(event);
|
||||||
Accessible* parent = hideEvent->Parent();
|
Accessible* parent = hideEvent->Parent();
|
||||||
@@ -393,7 +389,8 @@ NotificationController::CoalesceMutationEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parent->ShowEventTarget()) {
|
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()) {
|
if (showEvent->EventGeneration() < hideEvent->EventGeneration()) {
|
||||||
DropMutationEvent(hideEvent);
|
DropMutationEvent(hideEvent);
|
||||||
break;
|
break;
|
||||||
@@ -408,18 +405,14 @@ NotificationController::CoalesceMutationEvents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void NotificationController::ScheduleChildDocBinding(DocAccessible* aDocument) {
|
||||||
NotificationController::ScheduleChildDocBinding(DocAccessible* aDocument)
|
|
||||||
{
|
|
||||||
// Schedule child document binding to the tree.
|
// Schedule child document binding to the tree.
|
||||||
mHangingChildDocuments.AppendElement(aDocument);
|
mHangingChildDocuments.AppendElement(aDocument);
|
||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void NotificationController::ScheduleContentInsertion(
|
||||||
NotificationController::ScheduleContentInsertion(nsIContent* aStartChildNode,
|
nsIContent* aStartChildNode, nsIContent* aEndChildNode) {
|
||||||
nsIContent* aEndChildNode)
|
|
||||||
{
|
|
||||||
// The frame constructor guarantees that only ranges with the same parent
|
// The frame constructor guarantees that only ranges with the same parent
|
||||||
// arrive here in presence of dynamic changes to the page, see
|
// arrive here in presence of dynamic changes to the page, see
|
||||||
// nsCSSFrameConstructor::IssueSingleInsertNotifications' callers.
|
// nsCSSFrameConstructor::IssueSingleInsertNotifications' callers.
|
||||||
@@ -434,8 +427,7 @@ NotificationController::ScheduleContentInsertion(nsIContent* aStartChildNode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AutoTArray<nsCOMPtr<nsIContent>, 10> list;
|
AutoTArray<nsCOMPtr<nsIContent>, 10> list;
|
||||||
for (nsIContent* node = aStartChildNode;
|
for (nsIContent* node = aStartChildNode; node != aEndChildNode;
|
||||||
node != aEndChildNode;
|
|
||||||
node = node->GetNextSibling()) {
|
node = node->GetNextSibling()) {
|
||||||
MOZ_ASSERT(parent == node->GetFlattenedTreeParentNode());
|
MOZ_ASSERT(parent == node->GetFlattenedTreeParentNode());
|
||||||
// Notification triggers for content insertion even if no content was
|
// Notification triggers for content insertion even if no content was
|
||||||
@@ -453,9 +445,7 @@ NotificationController::ScheduleContentInsertion(nsIContent* aStartChildNode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void NotificationController::ScheduleProcessing() {
|
||||||
NotificationController::ScheduleProcessing()
|
|
||||||
{
|
|
||||||
// If notification flush isn't planed yet start notification flush
|
// If notification flush isn't planed yet start notification flush
|
||||||
// asynchronously (after style and layout).
|
// asynchronously (after style and layout).
|
||||||
if (mObservingState == eNotObservingRefresh) {
|
if (mObservingState == eNotObservingRefresh) {
|
||||||
@@ -467,20 +457,15 @@ NotificationController::ScheduleProcessing()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// NotificationCollector: protected
|
// NotificationCollector: protected
|
||||||
|
|
||||||
bool
|
bool NotificationController::IsUpdatePending() {
|
||||||
NotificationController::IsUpdatePending()
|
|
||||||
{
|
|
||||||
return mPresShell->IsLayoutFlushObserver() ||
|
return mPresShell->IsLayoutFlushObserver() ||
|
||||||
mObservingState == eRefreshProcessingForUpdate ||
|
mObservingState == eRefreshProcessingForUpdate || WaitingForParent() ||
|
||||||
WaitingForParent() ||
|
mContentInsertions.Count() != 0 || mNotifications.Length() != 0 ||
|
||||||
mContentInsertions.Count() != 0 || mNotifications.Length() != 0 ||
|
mTextHash.Count() != 0 ||
|
||||||
mTextHash.Count() != 0 ||
|
!mDocument->HasLoadState(DocAccessible::eTreeConstructed);
|
||||||
!mDocument->HasLoadState(DocAccessible::eTreeConstructed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool NotificationController::WaitingForParent() {
|
||||||
NotificationController::WaitingForParent()
|
|
||||||
{
|
|
||||||
DocAccessible* parentdoc = mDocument->ParentDocument();
|
DocAccessible* parentdoc = mDocument->ParentDocument();
|
||||||
if (!parentdoc) {
|
if (!parentdoc) {
|
||||||
return false;
|
return false;
|
||||||
@@ -497,17 +482,15 @@ NotificationController::WaitingForParent()
|
|||||||
parent->mNotifications.Length() != 0;
|
parent->mNotifications.Length() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void NotificationController::ProcessMutationEvents() {
|
||||||
NotificationController::ProcessMutationEvents()
|
|
||||||
{
|
|
||||||
// there is no reason to fire a hide event for a child of a show event
|
// 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
|
// target. That can happen if something is inserted into the tree and
|
||||||
// removed before the next refresh driver tick, but it should not be
|
// 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
|
// 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
|
// events. This means that it should be fine to fire all of the hide events
|
||||||
// first, and then deal with any shown subtrees.
|
// first, and then deal with any shown subtrees.
|
||||||
for (AccTreeMutationEvent* event = mFirstMutationEvent;
|
for (AccTreeMutationEvent* event = mFirstMutationEvent; event;
|
||||||
event; event = event->NextEvent()) {
|
event = event->NextEvent()) {
|
||||||
if (event->GetEventType() != nsIAccessibleEvent::EVENT_HIDE) {
|
if (event->GetEventType() != nsIAccessibleEvent::EVENT_HIDE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -549,9 +532,10 @@ NotificationController::ProcessMutationEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Group the show events by the parent of their target.
|
// Group the show events by the parent of their target.
|
||||||
nsDataHashtable<nsPtrHashKey<Accessible>, nsTArray<AccTreeMutationEvent*>> showEvents;
|
nsDataHashtable<nsPtrHashKey<Accessible>, nsTArray<AccTreeMutationEvent*>>
|
||||||
for (AccTreeMutationEvent* event = mFirstMutationEvent;
|
showEvents;
|
||||||
event; event = event->NextEvent()) {
|
for (AccTreeMutationEvent* event = mFirstMutationEvent; event;
|
||||||
|
event = event->NextEvent()) {
|
||||||
if (event->GetEventType() != nsIAccessibleEvent::EVENT_SHOW) {
|
if (event->GetEventType() != nsIAccessibleEvent::EVENT_SHOW) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -565,15 +549,15 @@ NotificationController::ProcessMutationEvents()
|
|||||||
// container by the index of their target.
|
// container by the index of their target.
|
||||||
for (auto iter = showEvents.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = showEvents.Iter(); !iter.Done(); iter.Next()) {
|
||||||
struct AccIdxComparator {
|
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 aIdx = a->GetAccessible()->IndexInParent();
|
||||||
int32_t bIdx = b->GetAccessible()->IndexInParent();
|
int32_t bIdx = b->GetAccessible()->IndexInParent();
|
||||||
MOZ_ASSERT(aIdx >= 0 && bIdx >= 0 && aIdx != bIdx);
|
MOZ_ASSERT(aIdx >= 0 && bIdx >= 0 && aIdx != bIdx);
|
||||||
return 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> aIdx = a->GetAccessible()->IndexInParent();
|
||||||
DebugOnly<int32_t> bIdx = b->GetAccessible()->IndexInParent();
|
DebugOnly<int32_t> bIdx = b->GetAccessible()->IndexInParent();
|
||||||
MOZ_ASSERT(aIdx >= 0 && bIdx >= 0 && aIdx != bIdx);
|
MOZ_ASSERT(aIdx >= 0 && bIdx >= 0 && aIdx != bIdx);
|
||||||
@@ -583,7 +567,7 @@ NotificationController::ProcessMutationEvents()
|
|||||||
|
|
||||||
nsTArray<AccTreeMutationEvent*>& events = iter.Data();
|
nsTArray<AccTreeMutationEvent*>& events = iter.Data();
|
||||||
events.Sort(AccIdxComparator());
|
events.Sort(AccIdxComparator());
|
||||||
for (AccTreeMutationEvent* event: events) {
|
for (AccTreeMutationEvent* event : events) {
|
||||||
nsEventShell::FireEvent(event);
|
nsEventShell::FireEvent(event);
|
||||||
if (!mDocument) {
|
if (!mDocument) {
|
||||||
return;
|
return;
|
||||||
@@ -600,8 +584,8 @@ NotificationController::ProcessMutationEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now we can fire the reorder events after all the show and hide events.
|
// Now we can fire the reorder events after all the show and hide events.
|
||||||
for (AccTreeMutationEvent* event = mFirstMutationEvent;
|
for (AccTreeMutationEvent* event = mFirstMutationEvent; event;
|
||||||
event; event = event->NextEvent()) {
|
event = event->NextEvent()) {
|
||||||
if (event->GetEventType() != nsIAccessibleEvent::EVENT_REORDER) {
|
if (event->GetEventType() != nsIAccessibleEvent::EVENT_REORDER) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -622,19 +606,17 @@ NotificationController::ProcessMutationEvents()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// NotificationCollector: private
|
// NotificationCollector: private
|
||||||
|
|
||||||
void
|
void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
|
||||||
NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|
||||||
{
|
|
||||||
Telemetry::AutoTimer<Telemetry::A11Y_TREE_UPDATE_TIMING_MS> timer;
|
Telemetry::AutoTimer<Telemetry::A11Y_TREE_UPDATE_TIMING_MS> timer;
|
||||||
|
|
||||||
AUTO_PROFILER_LABEL("NotificationController::WillRefresh", OTHER);
|
AUTO_PROFILER_LABEL("NotificationController::WillRefresh", OTHER);
|
||||||
|
|
||||||
// If the document accessible that notification collector was created for is
|
// If the document accessible that notification collector was created for is
|
||||||
// now shut down, don't process notifications anymore.
|
// now shut down, don't process notifications anymore.
|
||||||
NS_ASSERTION(mDocument,
|
NS_ASSERTION(
|
||||||
"The document was shut down while refresh observer is attached!");
|
mDocument,
|
||||||
if (!mDocument)
|
"The document was shut down while refresh observer is attached!");
|
||||||
return;
|
if (!mDocument) return;
|
||||||
|
|
||||||
// Wait until an update, we have started, or an interruptible reflow is
|
// Wait until an update, we have started, or an interruptible reflow is
|
||||||
// finished.
|
// finished.
|
||||||
@@ -677,7 +659,8 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||||||
mDocument->DoInitialUpdate();
|
mDocument->DoInitialUpdate();
|
||||||
|
|
||||||
NS_ASSERTION(mContentInsertions.Count() == 0,
|
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.
|
// Initialize scroll support if needed.
|
||||||
@@ -707,44 +690,46 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
nsIContent* containerElm = containerNode->IsElement() ?
|
nsIContent* containerElm =
|
||||||
containerNode->AsElement() : nullptr;
|
containerNode->IsElement() ? containerNode->AsElement() : nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsIFrame::RenderedText text = textFrame->GetRenderedText(0,
|
nsIFrame::RenderedText text = textFrame->GetRenderedText(
|
||||||
UINT32_MAX, nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
|
0, UINT32_MAX, nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
|
||||||
nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE);
|
nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE);
|
||||||
|
|
||||||
// Remove text accessible if rendered text is empty.
|
// Remove text accessible if rendered text is empty.
|
||||||
if (textAcc) {
|
if (textAcc) {
|
||||||
if (text.mString.IsEmpty()) {
|
if (text.mString.IsEmpty()) {
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eTree | logging::eText)) {
|
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("container", containerElm);
|
||||||
logging::Node("content", textNode);
|
logging::Node("content", textNode);
|
||||||
logging::MsgEnd();
|
logging::MsgEnd();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mDocument->ContentRemoved(textAcc);
|
mDocument->ContentRemoved(textAcc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update text of the accessible and fire text change events.
|
// Update text of the accessible and fire text change events.
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eText)) {
|
if (logging::IsEnabled(logging::eText)) {
|
||||||
logging::MsgBegin("TEXT", "text may be changed; doc: %p", mDocument);
|
logging::MsgBegin("TEXT", "text may be changed; doc: %p", mDocument);
|
||||||
logging::Node("container", containerElm);
|
logging::Node("container", containerElm);
|
||||||
logging::Node("content", textNode);
|
logging::Node("content", textNode);
|
||||||
logging::MsgEntry("old text '%s'",
|
logging::MsgEntry(
|
||||||
NS_ConvertUTF16toUTF8(textAcc->AsTextLeaf()->Text()).get());
|
"old text '%s'",
|
||||||
|
NS_ConvertUTF16toUTF8(textAcc->AsTextLeaf()->Text()).get());
|
||||||
logging::MsgEntry("new text: '%s'",
|
logging::MsgEntry("new text: '%s'",
|
||||||
NS_ConvertUTF16toUTF8(text.mString).get());
|
NS_ConvertUTF16toUTF8(text.mString).get());
|
||||||
logging::MsgEnd();
|
logging::MsgEnd();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text.mString);
|
TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text.mString);
|
||||||
continue;
|
continue;
|
||||||
@@ -752,23 +737,24 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||||||
|
|
||||||
// Append an accessible if rendered text is not empty.
|
// Append an accessible if rendered text is not empty.
|
||||||
if (!text.mString.IsEmpty()) {
|
if (!text.mString.IsEmpty()) {
|
||||||
#ifdef A11Y_LOG
|
#ifdef A11Y_LOG
|
||||||
if (logging::IsEnabled(logging::eTree | logging::eText)) {
|
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("container", containerElm);
|
||||||
logging::Node("content", textNode);
|
logging::Node("content", textNode);
|
||||||
logging::MsgEnd();
|
logging::MsgEnd();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MOZ_ASSERT(mDocument->AccessibleOrTrueContainer(containerNode),
|
MOZ_ASSERT(mDocument->AccessibleOrTrueContainer(containerNode),
|
||||||
"Text node having rendered text hasn't accessible document!");
|
"Text node having rendered text hasn't accessible document!");
|
||||||
|
|
||||||
Accessible* container = mDocument->AccessibleOrTrueContainer(
|
Accessible* container = mDocument->AccessibleOrTrueContainer(
|
||||||
containerNode, DocAccessible::eNoContainerIfARIAHidden);
|
containerNode, DocAccessible::eNoContainerIfARIAHidden);
|
||||||
if (container) {
|
if (container) {
|
||||||
nsTArray<nsCOMPtr<nsIContent>>* list =
|
nsTArray<nsCOMPtr<nsIContent>>* list =
|
||||||
mContentInsertions.LookupOrAdd(container);
|
mContentInsertions.LookupOrAdd(container);
|
||||||
list->AppendElement(textNode);
|
list->AppendElement(textNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -791,16 +777,16 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||||||
nsTArray<RefPtr<DocAccessible>> newChildDocs;
|
nsTArray<RefPtr<DocAccessible>> newChildDocs;
|
||||||
for (uint32_t idx = 0; idx < hangingDocCnt; idx++) {
|
for (uint32_t idx = 0; idx < hangingDocCnt; idx++) {
|
||||||
DocAccessible* childDoc = mHangingChildDocuments[idx];
|
DocAccessible* childDoc = mHangingChildDocuments[idx];
|
||||||
if (childDoc->IsDefunct())
|
if (childDoc->IsDefunct()) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
if (IPCAccessibilityActive() && !mDocument->IPCDoc()) {
|
if (IPCAccessibilityActive() && !mDocument->IPCDoc()) {
|
||||||
childDoc->Shutdown();
|
childDoc->Shutdown();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIContent* ownerContent = mDocument->DocumentNode()->
|
nsIContent* ownerContent =
|
||||||
FindContentForSubDocument(childDoc->DocumentNode());
|
mDocument->DocumentNode()->FindContentForSubDocument(
|
||||||
|
childDoc->DocumentNode());
|
||||||
if (ownerContent) {
|
if (ownerContent) {
|
||||||
Accessible* outerDocAcc = mDocument->GetAccessible(ownerContent);
|
Accessible* outerDocAcc = mDocument->GetAccessible(ownerContent);
|
||||||
if (outerDocAcc && outerDocAcc->AppendChild(childDoc)) {
|
if (outerDocAcc && outerDocAcc->AppendChild(childDoc)) {
|
||||||
@@ -832,26 +818,23 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||||||
uint32_t childDocCnt = mDocument->ChildDocumentCount(), childDocIdx = 0;
|
uint32_t childDocCnt = mDocument->ChildDocumentCount(), childDocIdx = 0;
|
||||||
for (; childDocIdx < childDocCnt; childDocIdx++) {
|
for (; childDocIdx < childDocCnt; childDocIdx++) {
|
||||||
DocAccessible* childDoc = mDocument->GetChildDocumentAt(childDocIdx);
|
DocAccessible* childDoc = mDocument->GetChildDocumentAt(childDocIdx);
|
||||||
if (!childDoc->HasLoadState(DocAccessible::eCompletelyLoaded))
|
if (!childDoc->HasLoadState(DocAccessible::eCompletelyLoaded)) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (childDocIdx == childDocCnt) {
|
if (childDocIdx == childDocCnt) {
|
||||||
mDocument->ProcessLoad();
|
mDocument->ProcessLoad();
|
||||||
if (!mDocument)
|
if (!mDocument) return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process only currently queued generic notifications.
|
// Process only currently queued generic notifications.
|
||||||
nsTArray < RefPtr<Notification> > notifications;
|
nsTArray<RefPtr<Notification>> notifications;
|
||||||
notifications.SwapElements(mNotifications);
|
notifications.SwapElements(mNotifications);
|
||||||
|
|
||||||
uint32_t notificationCount = notifications.Length();
|
uint32_t notificationCount = notifications.Length();
|
||||||
for (uint32_t idx = 0; idx < notificationCount; idx++) {
|
for (uint32_t idx = 0; idx < notificationCount; idx++) {
|
||||||
notifications[idx]->Process();
|
notifications[idx]->Process();
|
||||||
if (!mDocument)
|
if (!mDocument) return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process invalidation list of the document after all accessible tree
|
// Process invalidation list of the document after all accessible tree
|
||||||
@@ -860,8 +843,10 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||||||
|
|
||||||
// Process relocation list.
|
// Process relocation list.
|
||||||
for (uint32_t idx = 0; idx < mRelocations.Length(); idx++) {
|
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)
|
// owner should be in a document and have na associated DOM node (docs
|
||||||
if (mRelocations[idx]->IsInDocument() && mRelocations[idx]->HasOwnContent()) {
|
// sometimes don't)
|
||||||
|
if (mRelocations[idx]->IsInDocument() &&
|
||||||
|
mRelocations[idx]->HasOwnContent()) {
|
||||||
mDocument->DoARIAOwnsRelocation(mRelocations[idx]);
|
mDocument->DoARIAOwnsRelocation(mRelocations[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -931,22 +916,21 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||||||
childDoc->SetIPCDoc(ipcDoc);
|
childDoc->SetIPCDoc(ipcDoc);
|
||||||
|
|
||||||
#if defined(XP_WIN)
|
#if defined(XP_WIN)
|
||||||
parentIPCDoc->ConstructChildDocInParentProcess(ipcDoc, id,
|
parentIPCDoc->ConstructChildDocInParentProcess(
|
||||||
AccessibleWrap::GetChildIDFor(childDoc));
|
ipcDoc, id, AccessibleWrap::GetChildIDFor(childDoc));
|
||||||
#else
|
#else
|
||||||
nsCOMPtr<nsITabChild> tabChild =
|
nsCOMPtr<nsITabChild> tabChild =
|
||||||
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
|
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
|
||||||
if (tabChild) {
|
if (tabChild) {
|
||||||
static_cast<TabChild*>(tabChild.get())->
|
static_cast<TabChild*>(tabChild.get())
|
||||||
SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id, 0, 0);
|
->SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id, 0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mObservingState = eRefreshObserving;
|
mObservingState = eRefreshObserving;
|
||||||
if (!mDocument)
|
if (!mDocument) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Stop further processing if there are no new notifications of any kind or
|
// Stop further processing if there are no new notifications of any kind or
|
||||||
// events and document load is processed.
|
// events and document load is processed.
|
||||||
@@ -959,9 +943,7 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void NotificationController::EventMap::PutEvent(AccTreeMutationEvent* aEvent) {
|
||||||
NotificationController::EventMap::PutEvent(AccTreeMutationEvent* aEvent)
|
|
||||||
{
|
|
||||||
EventType type = GetEventType(aEvent);
|
EventType type = GetEventType(aEvent);
|
||||||
uint64_t addr = reinterpret_cast<uintptr_t>(aEvent->GetAccessible());
|
uint64_t addr = reinterpret_cast<uintptr_t>(aEvent->GetAccessible());
|
||||||
MOZ_ASSERT((addr & 0x3) == 0, "accessible is not 4 byte aligned");
|
MOZ_ASSERT((addr & 0x3) == 0, "accessible is not 4 byte aligned");
|
||||||
@@ -969,9 +951,8 @@ NotificationController::EventMap::PutEvent(AccTreeMutationEvent* aEvent)
|
|||||||
mTable.Put(addr, aEvent);
|
mTable.Put(addr, aEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccTreeMutationEvent*
|
AccTreeMutationEvent* NotificationController::EventMap::GetEvent(
|
||||||
NotificationController::EventMap::GetEvent(Accessible* aTarget, EventType aType)
|
Accessible* aTarget, EventType aType) {
|
||||||
{
|
|
||||||
uint64_t addr = reinterpret_cast<uintptr_t>(aTarget);
|
uint64_t addr = reinterpret_cast<uintptr_t>(aTarget);
|
||||||
MOZ_ASSERT((addr & 0x3) == 0, "target is not 4 byte aligned");
|
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);
|
return mTable.GetWeak(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void NotificationController::EventMap::RemoveEvent(
|
||||||
NotificationController::EventMap::RemoveEvent(AccTreeMutationEvent* aEvent)
|
AccTreeMutationEvent* aEvent) {
|
||||||
{
|
|
||||||
EventType type = GetEventType(aEvent);
|
EventType type = GetEventType(aEvent);
|
||||||
uint64_t addr = reinterpret_cast<uintptr_t>(aEvent->GetAccessible());
|
uint64_t addr = reinterpret_cast<uintptr_t>(aEvent->GetAccessible());
|
||||||
MOZ_ASSERT((addr & 0x3) == 0, "accessible is not 4 byte aligned");
|
MOZ_ASSERT((addr & 0x3) == 0, "accessible is not 4 byte aligned");
|
||||||
@@ -991,11 +971,9 @@ NotificationController::EventMap::RemoveEvent(AccTreeMutationEvent* aEvent)
|
|||||||
mTable.Remove(addr);
|
mTable.Remove(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationController::EventMap::EventType
|
NotificationController::EventMap::EventType
|
||||||
NotificationController::EventMap::GetEventType(AccTreeMutationEvent* aEvent)
|
NotificationController::EventMap::GetEventType(AccTreeMutationEvent* aEvent) {
|
||||||
{
|
switch (aEvent->GetEventType()) {
|
||||||
switch(aEvent->GetEventType())
|
|
||||||
{
|
|
||||||
case nsIAccessibleEvent::EVENT_SHOW:
|
case nsIAccessibleEvent::EVENT_SHOW:
|
||||||
return ShowEvent;
|
return ShowEvent;
|
||||||
case nsIAccessibleEvent::EVENT_HIDE:
|
case nsIAccessibleEvent::EVENT_HIDE:
|
||||||
|
|||||||
@@ -27,9 +27,8 @@ class DocAccessible;
|
|||||||
/**
|
/**
|
||||||
* Notification interface.
|
* Notification interface.
|
||||||
*/
|
*/
|
||||||
class Notification
|
class Notification {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
NS_INLINE_DECL_REFCOUNTING(mozilla::a11y::Notification)
|
NS_INLINE_DECL_REFCOUNTING(mozilla::a11y::Notification)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,20 +36,19 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void Process() = 0;
|
virtual void Process() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Notification() { }
|
Notification() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected destructor, to discourage deletion outside of Release():
|
* Protected destructor, to discourage deletion outside of Release():
|
||||||
*/
|
*/
|
||||||
virtual ~Notification() { }
|
virtual ~Notification() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Notification(const Notification&);
|
Notification(const Notification&);
|
||||||
Notification& operator = (const Notification&);
|
Notification& operator=(const Notification&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template class for generic notification.
|
* Template class for generic notification.
|
||||||
*
|
*
|
||||||
@@ -58,41 +56,39 @@ private:
|
|||||||
* longer than the document accessible owning the notification controller
|
* longer than the document accessible owning the notification controller
|
||||||
* that this notification is processed by.
|
* that this notification is processed by.
|
||||||
*/
|
*/
|
||||||
template<class Class, class ... Args>
|
template <class Class, class... Args>
|
||||||
class TNotification : public Notification
|
class TNotification : public Notification {
|
||||||
{
|
public:
|
||||||
public:
|
typedef void (Class::*Callback)(Args*...);
|
||||||
typedef void (Class::*Callback)(Args* ...);
|
|
||||||
|
|
||||||
TNotification(Class* aInstance, Callback aCallback, Args* ... aArgs) :
|
TNotification(Class* aInstance, Callback aCallback, Args*... aArgs)
|
||||||
mInstance(aInstance), mCallback(aCallback), mArgs(aArgs...) { }
|
: mInstance(aInstance), mCallback(aCallback), mArgs(aArgs...) {}
|
||||||
virtual ~TNotification() { mInstance = nullptr; }
|
virtual ~TNotification() { mInstance = nullptr; }
|
||||||
|
|
||||||
virtual void Process() override
|
virtual void Process() override {
|
||||||
{ ProcessHelper(std::index_sequence_for<Args...>{}); }
|
ProcessHelper(std::index_sequence_for<Args...>{});
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TNotification(const TNotification&);
|
TNotification(const TNotification&);
|
||||||
TNotification& operator = (const TNotification&);
|
TNotification& operator=(const TNotification&);
|
||||||
|
|
||||||
template <size_t... Indices>
|
template <size_t... Indices>
|
||||||
void ProcessHelper(std::index_sequence<Indices...>)
|
void ProcessHelper(std::index_sequence<Indices...>) {
|
||||||
{
|
(mInstance->*mCallback)(Get<Indices>(mArgs)...);
|
||||||
(mInstance->*mCallback)(Get<Indices>(mArgs)...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Class* mInstance;
|
Class* mInstance;
|
||||||
Callback mCallback;
|
Callback mCallback;
|
||||||
Tuple<RefPtr<Args> ...> mArgs;
|
Tuple<RefPtr<Args>...> mArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to process notifications from core for the document accessible.
|
* Used to process notifications from core for the document accessible.
|
||||||
*/
|
*/
|
||||||
class NotificationController final : public EventQueue,
|
class NotificationController final : public EventQueue,
|
||||||
public nsARefreshObserver
|
public nsARefreshObserver {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
NotificationController(DocAccessible* aDocument, nsIPresShell* aPresShell);
|
NotificationController(DocAccessible* aDocument, nsIPresShell* aPresShell);
|
||||||
|
|
||||||
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
|
||||||
@@ -108,8 +104,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add an accessible event into the queue to process it later.
|
* Add an accessible event into the queue to process it later.
|
||||||
*/
|
*/
|
||||||
void QueueEvent(AccEvent* aEvent)
|
void QueueEvent(AccEvent* aEvent) {
|
||||||
{
|
|
||||||
if (PushEvent(aEvent)) {
|
if (PushEvent(aEvent)) {
|
||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
}
|
}
|
||||||
@@ -120,8 +115,7 @@ public:
|
|||||||
* the given accessible, if the accessible is a part of name computation of
|
* the given accessible, if the accessible is a part of name computation of
|
||||||
* the container.
|
* the container.
|
||||||
*/
|
*/
|
||||||
void QueueNameChange(Accessible* aChangeTarget)
|
void QueueNameChange(Accessible* aChangeTarget) {
|
||||||
{
|
|
||||||
if (PushNameChange(aChangeTarget)) {
|
if (PushNameChange(aChangeTarget)) {
|
||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
}
|
}
|
||||||
@@ -134,10 +128,9 @@ public:
|
|||||||
EventTree* QueueMutation(Accessible* aContainer);
|
EventTree* QueueMutation(Accessible* aContainer);
|
||||||
|
|
||||||
class MoveGuard final {
|
class MoveGuard final {
|
||||||
public:
|
public:
|
||||||
explicit MoveGuard(NotificationController* aController) :
|
explicit MoveGuard(NotificationController* aController)
|
||||||
mController(aController)
|
: mController(aController) {
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
MOZ_ASSERT(!mController->mMoveGuardOnStack,
|
MOZ_ASSERT(!mController->mMoveGuardOnStack,
|
||||||
"Move guard is on stack already!");
|
"Move guard is on stack already!");
|
||||||
@@ -152,7 +145,7 @@ public:
|
|||||||
mController->mPrecedingEvents.Clear();
|
mController->mPrecedingEvents.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NotificationController* mController;
|
NotificationController* mController;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -179,12 +172,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Schedule the accessible tree update because of rendered text changes.
|
* 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
|
// Make sure we are not called with a node that is not in the DOM tree or
|
||||||
// not visible.
|
// not visible.
|
||||||
MOZ_ASSERT(aTextNode->GetParentNode(), "A text node is not in DOM");
|
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(),
|
MOZ_ASSERT(aTextNode->GetPrimaryFrame()->StyleVisibility()->IsVisible(),
|
||||||
"A text node is not visible");
|
"A text node is not visible");
|
||||||
|
|
||||||
@@ -201,8 +194,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Pend an accessible subtree relocation.
|
* Pend an accessible subtree relocation.
|
||||||
*/
|
*/
|
||||||
void ScheduleRelocation(Accessible* aOwner)
|
void ScheduleRelocation(Accessible* aOwner) {
|
||||||
{
|
|
||||||
if (!mRelocations.Contains(aOwner) && mRelocations.AppendElement(aOwner)) {
|
if (!mRelocations.Contains(aOwner) && mRelocations.AppendElement(aOwner)) {
|
||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
}
|
}
|
||||||
@@ -222,14 +214,14 @@ public:
|
|||||||
* @note The caller must guarantee that the given instance still exists when
|
* @note The caller must guarantee that the given instance still exists when
|
||||||
* the notification is processed.
|
* the notification is processed.
|
||||||
*/
|
*/
|
||||||
template<class Class, class Arg>
|
template <class Class, class Arg>
|
||||||
inline void HandleNotification(Class* aInstance,
|
inline void HandleNotification(
|
||||||
typename TNotification<Class, Arg>::Callback aMethod,
|
Class* aInstance, typename TNotification<Class, Arg>::Callback aMethod,
|
||||||
Arg* aArg)
|
Arg* aArg) {
|
||||||
{
|
|
||||||
if (!IsUpdatePending()) {
|
if (!IsUpdatePending()) {
|
||||||
#ifdef A11Y_LOG
|
#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");
|
mozilla::a11y::logging::Text("sync notification processing");
|
||||||
#endif
|
#endif
|
||||||
(aInstance->*aMethod)(aArg);
|
(aInstance->*aMethod)(aArg);
|
||||||
@@ -237,7 +229,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Notification> notification =
|
RefPtr<Notification> notification =
|
||||||
new TNotification<Class, Arg>(aInstance, aMethod, aArg);
|
new TNotification<Class, Arg>(aInstance, aMethod, aArg);
|
||||||
if (notification && mNotifications.AppendElement(notification))
|
if (notification && mNotifications.AppendElement(notification))
|
||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
}
|
}
|
||||||
@@ -248,34 +240,33 @@ public:
|
|||||||
* @note The caller must guarantee that the given instance still exists when
|
* @note The caller must guarantee that the given instance still exists when
|
||||||
* the notification is processed.
|
* the notification is processed.
|
||||||
*/
|
*/
|
||||||
template<class Class>
|
template <class Class>
|
||||||
inline void ScheduleNotification(Class* aInstance,
|
inline void ScheduleNotification(
|
||||||
typename TNotification<Class>::Callback aMethod)
|
Class* aInstance, typename TNotification<Class>::Callback aMethod) {
|
||||||
{
|
|
||||||
RefPtr<Notification> notification =
|
RefPtr<Notification> notification =
|
||||||
new TNotification<Class>(aInstance, aMethod);
|
new TNotification<Class>(aInstance, aMethod);
|
||||||
if (notification && mNotifications.AppendElement(notification))
|
if (notification && mNotifications.AppendElement(notification))
|
||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Class, class Arg>
|
template <class Class, class Arg>
|
||||||
inline void ScheduleNotification(Class* aInstance,
|
inline void ScheduleNotification(
|
||||||
typename TNotification<Class, Arg>::Callback aMethod,
|
Class* aInstance, typename TNotification<Class, Arg>::Callback aMethod,
|
||||||
Arg* aArg)
|
Arg* aArg) {
|
||||||
{
|
|
||||||
RefPtr<Notification> notification =
|
RefPtr<Notification> notification =
|
||||||
new TNotification<Class, Arg>(aInstance, aMethod, aArg);
|
new TNotification<Class, Arg>(aInstance, aMethod, aArg);
|
||||||
if (notification && mNotifications.AppendElement(notification)) {
|
if (notification && mNotifications.AppendElement(notification)) {
|
||||||
ScheduleProcessing();
|
ScheduleProcessing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool IsUpdating() const
|
bool IsUpdating() const {
|
||||||
{ return mObservingState == eRefreshProcessingForUpdate; }
|
return mObservingState == eRefreshProcessingForUpdate;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~NotificationController();
|
virtual ~NotificationController();
|
||||||
|
|
||||||
nsCycleCollectingAutoRefCnt mRefCnt;
|
nsCycleCollectingAutoRefCnt mRefCnt;
|
||||||
@@ -292,9 +283,9 @@ protected:
|
|||||||
*/
|
*/
|
||||||
bool WaitingForParent();
|
bool WaitingForParent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NotificationController(const NotificationController&);
|
NotificationController(const NotificationController&);
|
||||||
NotificationController& operator = (const NotificationController&);
|
NotificationController& operator=(const NotificationController&);
|
||||||
|
|
||||||
// nsARefreshObserver
|
// nsARefreshObserver
|
||||||
virtual void WillRefresh(mozilla::TimeStamp aTime) override;
|
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.
|
* 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) {
|
if (mPrecedingEvents.Length() > 0) {
|
||||||
aEvs->AppendElements(std::move(mPrecedingEvents));
|
aEvs->AppendElements(std::move(mPrecedingEvents));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void StorePrecedingEvent(AccHideEvent* aEv)
|
void StorePrecedingEvent(AccHideEvent* aEv) {
|
||||||
{
|
|
||||||
MOZ_ASSERT(mMoveGuardOnStack, "No move guard on stack!");
|
MOZ_ASSERT(mMoveGuardOnStack, "No move guard on stack!");
|
||||||
mPrecedingEvents.AppendElement(aEv);
|
mPrecedingEvents.AppendElement(aEv);
|
||||||
}
|
}
|
||||||
void StorePrecedingEvents(nsTArray<RefPtr<AccHideEvent>>&& aEvs)
|
void StorePrecedingEvents(nsTArray<RefPtr<AccHideEvent>>&& aEvs) {
|
||||||
{
|
|
||||||
MOZ_ASSERT(mMoveGuardOnStack, "No move guard on stack!");
|
MOZ_ASSERT(mMoveGuardOnStack, "No move guard on stack!");
|
||||||
mPrecedingEvents.InsertElementsAt(0, aEvs);
|
mPrecedingEvents.InsertElementsAt(0, aEvs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* get rid of a mutation event that is no longer necessary.
|
* get rid of a mutation event that is no longer necessary.
|
||||||
*/
|
*/
|
||||||
@@ -350,56 +338,54 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Child documents that needs to be bound to the tree.
|
* 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.
|
* Pending accessible tree update notifications for content insertions.
|
||||||
*/
|
*/
|
||||||
nsClassHashtable<nsRefPtrHashKey<Accessible>,
|
nsClassHashtable<nsRefPtrHashKey<Accessible>, nsTArray<nsCOMPtr<nsIContent>>>
|
||||||
nsTArray<nsCOMPtr<nsIContent>>> mContentInsertions;
|
mContentInsertions;
|
||||||
|
|
||||||
template<class T>
|
template <class T>
|
||||||
class nsCOMPtrHashKey : public PLDHashEntryHdr
|
class nsCOMPtrHashKey : public PLDHashEntryHdr {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
typedef T* KeyType;
|
typedef T* KeyType;
|
||||||
typedef const T* KeyTypePointer;
|
typedef const T* KeyTypePointer;
|
||||||
|
|
||||||
explicit nsCOMPtrHashKey(const T* aKey) : mKey(const_cast<T*>(aKey)) {}
|
explicit nsCOMPtrHashKey(const T* aKey) : mKey(const_cast<T*>(aKey)) {}
|
||||||
nsCOMPtrHashKey(nsCOMPtrHashKey<T>&& aOther)
|
nsCOMPtrHashKey(nsCOMPtrHashKey<T>&& aOther)
|
||||||
: PLDHashEntryHdr(std::move(aOther))
|
: PLDHashEntryHdr(std::move(aOther)), mKey(std::move(aOther.mKey)) {}
|
||||||
, mKey(std::move(aOther.mKey))
|
~nsCOMPtrHashKey() {}
|
||||||
{}
|
|
||||||
~nsCOMPtrHashKey() { }
|
|
||||||
|
|
||||||
KeyType GetKey() const { return mKey; }
|
KeyType GetKey() const { return mKey; }
|
||||||
bool KeyEquals(KeyTypePointer aKey) const { return aKey == mKey; }
|
bool KeyEquals(KeyTypePointer aKey) const { return aKey == mKey; }
|
||||||
|
|
||||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
|
static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
|
||||||
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
static PLDHashNumber HashKey(KeyTypePointer aKey) {
|
||||||
{ return NS_PTR_TO_INT32(aKey) >> 2; }
|
return NS_PTR_TO_INT32(aKey) >> 2;
|
||||||
|
}
|
||||||
|
|
||||||
enum { ALLOW_MEMMOVE = true };
|
enum { ALLOW_MEMMOVE = true };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsCOMPtr<T> mKey;
|
nsCOMPtr<T> mKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pending accessible tree update notifications for rendered text changes.
|
* 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
|
* Other notifications like DOM events. Don't make this an AutoTArray; we
|
||||||
* use SwapElements() on it.
|
* use SwapElements() on it.
|
||||||
*/
|
*/
|
||||||
nsTArray<RefPtr<Notification> > mNotifications;
|
nsTArray<RefPtr<Notification>> mNotifications;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds all scheduled relocations.
|
* Holds all scheduled relocations.
|
||||||
*/
|
*/
|
||||||
nsTArray<RefPtr<Accessible> > mRelocations;
|
nsTArray<RefPtr<Accessible>> mRelocations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds all mutation events.
|
* Holds all mutation events.
|
||||||
@@ -429,11 +415,9 @@ private:
|
|||||||
/**
|
/**
|
||||||
* A class to map an accessible and event type to an event.
|
* A class to map an accessible and event type to an event.
|
||||||
*/
|
*/
|
||||||
class EventMap
|
class EventMap {
|
||||||
{
|
public:
|
||||||
public:
|
enum EventType {
|
||||||
enum EventType
|
|
||||||
{
|
|
||||||
ShowEvent = 0x0,
|
ShowEvent = 0x0,
|
||||||
HideEvent = 0x1,
|
HideEvent = 0x1,
|
||||||
ReorderEvent = 0x2,
|
ReorderEvent = 0x2,
|
||||||
@@ -444,7 +428,7 @@ private:
|
|||||||
void RemoveEvent(AccTreeMutationEvent* aEvent);
|
void RemoveEvent(AccTreeMutationEvent* aEvent);
|
||||||
void Clear() { mTable.Clear(); }
|
void Clear() { mTable.Clear(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventType GetEventType(AccTreeMutationEvent* aEvent);
|
EventType GetEventType(AccTreeMutationEvent* aEvent);
|
||||||
|
|
||||||
nsRefPtrHashtable<nsUint64HashKey, AccTreeMutationEvent> mTable;
|
nsRefPtrHashtable<nsUint64HashKey, AccTreeMutationEvent> mTable;
|
||||||
@@ -454,7 +438,7 @@ private:
|
|||||||
uint32_t mEventGeneration;
|
uint32_t mEventGeneration;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif // mozilla_a11y_NotificationController_h_
|
#endif // mozilla_a11y_NotificationController_h_
|
||||||
|
|||||||
@@ -115,9 +115,8 @@ void ProxyVirtualCursorChangeEvent(ProxyAccessible* aTarget,
|
|||||||
int32_t aOldEndOffset,
|
int32_t aOldEndOffset,
|
||||||
ProxyAccessible* aNewPosition,
|
ProxyAccessible* aNewPosition,
|
||||||
int32_t aNewStartOffset,
|
int32_t aNewStartOffset,
|
||||||
int32_t aNewEndOffset,
|
int32_t aNewEndOffset, int16_t aReason,
|
||||||
int16_t aReason, int16_t aBoundaryType,
|
int16_t aBoundaryType, bool aFromUser);
|
||||||
bool aFromUser);
|
|
||||||
|
|
||||||
void ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType,
|
void ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType,
|
||||||
uint32_t aScrollX, uint32_t aScrollY,
|
uint32_t aScrollX, uint32_t aScrollY,
|
||||||
@@ -125,13 +124,12 @@ void ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType,
|
|||||||
|
|
||||||
class BatchData;
|
class BatchData;
|
||||||
|
|
||||||
void ProxyBatch(ProxyAccessible* aDocument,
|
void ProxyBatch(ProxyAccessible* aDocument, const uint64_t aBatchType,
|
||||||
const uint64_t aBatchType,
|
|
||||||
const nsTArray<ProxyAccessible*>& aAccessibles,
|
const nsTArray<ProxyAccessible*>& aAccessibles,
|
||||||
const nsTArray<BatchData>& aData);
|
const nsTArray<BatchData>& aData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif // mozilla_a11y_Platform_h
|
#endif // mozilla_a11y_Platform_h
|
||||||
|
|||||||
@@ -18,38 +18,35 @@ namespace a11y {
|
|||||||
* A collection of relation targets of a certain type. Targets are computed
|
* A collection of relation targets of a certain type. Targets are computed
|
||||||
* lazily while enumerating.
|
* lazily while enumerating.
|
||||||
*/
|
*/
|
||||||
class Relation
|
class Relation {
|
||||||
{
|
public:
|
||||||
public:
|
Relation() : mFirstIter(nullptr), mLastIter(nullptr) {}
|
||||||
Relation() : mFirstIter(nullptr), mLastIter(nullptr) { }
|
|
||||||
|
|
||||||
explicit Relation(AccIterable* aIter) :
|
explicit Relation(AccIterable* aIter) : mFirstIter(aIter), mLastIter(aIter) {}
|
||||||
mFirstIter(aIter), mLastIter(aIter) { }
|
|
||||||
|
|
||||||
explicit Relation(Accessible* aAcc) :
|
explicit Relation(Accessible* aAcc)
|
||||||
mFirstIter(nullptr), mLastIter(nullptr)
|
: mFirstIter(nullptr), mLastIter(nullptr) {
|
||||||
{ AppendTarget(aAcc); }
|
AppendTarget(aAcc);
|
||||||
|
}
|
||||||
|
|
||||||
Relation(DocAccessible* aDocument, nsIContent* aContent) :
|
Relation(DocAccessible* aDocument, nsIContent* aContent)
|
||||||
mFirstIter(nullptr), mLastIter(nullptr)
|
: mFirstIter(nullptr), mLastIter(nullptr) {
|
||||||
{ AppendTarget(aDocument, aContent); }
|
AppendTarget(aDocument, aContent);
|
||||||
|
}
|
||||||
|
|
||||||
Relation(Relation&& aOther) :
|
Relation(Relation&& aOther)
|
||||||
mFirstIter(std::move(aOther.mFirstIter)), mLastIter(aOther.mLastIter)
|
: mFirstIter(std::move(aOther.mFirstIter)), mLastIter(aOther.mLastIter) {
|
||||||
{
|
|
||||||
aOther.mLastIter = nullptr;
|
aOther.mLastIter = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Relation& operator = (Relation&& aRH)
|
Relation& operator=(Relation&& aRH) {
|
||||||
{
|
|
||||||
mFirstIter = std::move(aRH.mFirstIter);
|
mFirstIter = std::move(aRH.mFirstIter);
|
||||||
mLastIter = aRH.mLastIter;
|
mLastIter = aRH.mLastIter;
|
||||||
aRH.mLastIter = nullptr;
|
aRH.mLastIter = nullptr;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void AppendIter(AccIterable* aIter)
|
inline void AppendIter(AccIterable* aIter) {
|
||||||
{
|
|
||||||
if (mLastIter)
|
if (mLastIter)
|
||||||
mLastIter->mNextIter.reset(aIter);
|
mLastIter->mNextIter.reset(aIter);
|
||||||
else
|
else
|
||||||
@@ -61,48 +58,41 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Append the given accessible to the set of related accessibles.
|
* Append the given accessible to the set of related accessibles.
|
||||||
*/
|
*/
|
||||||
inline void AppendTarget(Accessible* aAcc)
|
inline void AppendTarget(Accessible* aAcc) {
|
||||||
{
|
if (aAcc) AppendIter(new SingleAccIterator(aAcc));
|
||||||
if (aAcc)
|
|
||||||
AppendIter(new SingleAccIterator(aAcc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append the one accessible for this content node to the set of related
|
* Append the one accessible for this content node to the set of related
|
||||||
* accessibles.
|
* accessibles.
|
||||||
*/
|
*/
|
||||||
void AppendTarget(DocAccessible* aDocument, nsIContent* aContent)
|
void AppendTarget(DocAccessible* aDocument, nsIContent* aContent) {
|
||||||
{
|
if (aContent) AppendTarget(aDocument->GetAccessible(aContent));
|
||||||
if (aContent)
|
|
||||||
AppendTarget(aDocument->GetAccessible(aContent));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* compute and return the next related accessible.
|
* compute and return the next related accessible.
|
||||||
*/
|
*/
|
||||||
inline Accessible* Next()
|
inline Accessible* Next() {
|
||||||
{
|
|
||||||
Accessible* target = nullptr;
|
Accessible* target = nullptr;
|
||||||
|
|
||||||
while (mFirstIter && !(target = mFirstIter->Next()))
|
while (mFirstIter && !(target = mFirstIter->Next()))
|
||||||
mFirstIter = std::move(mFirstIter->mNextIter);
|
mFirstIter = std::move(mFirstIter->mNextIter);
|
||||||
|
|
||||||
if (!mFirstIter)
|
if (!mFirstIter) mLastIter = nullptr;
|
||||||
mLastIter = nullptr;
|
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Relation& operator = (const Relation&) = delete;
|
Relation& operator=(const Relation&) = delete;
|
||||||
Relation(const Relation&) = delete;
|
Relation(const Relation&) = delete;
|
||||||
|
|
||||||
std::unique_ptr<AccIterable> mFirstIter;
|
std::unique_ptr<AccIterable> mFirstIter;
|
||||||
AccIterable* mLastIter;
|
AccIterable* mLastIter;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ enum class RelationType {
|
|||||||
CONTAINING_DOCUMENT = 0x11,
|
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,
|
CONTAINING_TAB_PANE = 0x12,
|
||||||
|
|
||||||
@@ -127,7 +128,6 @@ enum class RelationType {
|
|||||||
*/
|
*/
|
||||||
CONTAINING_APPLICATION = 0x14,
|
CONTAINING_APPLICATION = 0x14,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target object provides the detailed, extended description for this
|
* The target object provides the detailed, extended description for this
|
||||||
* object. It provides more detailed information than would normally be
|
* object. It provides more detailed information than would normally be
|
||||||
@@ -157,7 +157,7 @@ enum class RelationType {
|
|||||||
LAST = ERRORMSG_FOR
|
LAST = ERRORMSG_FOR
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,152 +9,79 @@
|
|||||||
* RELATIONTYPE(geckoType, geckoTypeName, atkType, msaaType, ia2Type)
|
* RELATIONTYPE(geckoType, geckoTypeName, atkType, msaaType, ia2Type)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RELATIONTYPE(LABELLED_BY,
|
RELATIONTYPE(LABELLED_BY, "labelled by", ATK_RELATION_LABELLED_BY,
|
||||||
"labelled by",
|
NAVRELATION_LABELLED_BY, IA2_RELATION_LABELLED_BY)
|
||||||
ATK_RELATION_LABELLED_BY,
|
|
||||||
NAVRELATION_LABELLED_BY,
|
|
||||||
IA2_RELATION_LABELLED_BY)
|
|
||||||
|
|
||||||
RELATIONTYPE(LABEL_FOR,
|
RELATIONTYPE(LABEL_FOR, "label for", ATK_RELATION_LABEL_FOR,
|
||||||
"label for",
|
NAVRELATION_LABEL_FOR, IA2_RELATION_LABEL_FOR)
|
||||||
ATK_RELATION_LABEL_FOR,
|
|
||||||
NAVRELATION_LABEL_FOR,
|
|
||||||
IA2_RELATION_LABEL_FOR)
|
|
||||||
|
|
||||||
RELATIONTYPE(DESCRIBED_BY,
|
RELATIONTYPE(DESCRIBED_BY, "described by", ATK_RELATION_DESCRIBED_BY,
|
||||||
"described by",
|
NAVRELATION_DESCRIBED_BY, IA2_RELATION_DESCRIBED_BY)
|
||||||
ATK_RELATION_DESCRIBED_BY,
|
|
||||||
NAVRELATION_DESCRIBED_BY,
|
|
||||||
IA2_RELATION_DESCRIBED_BY)
|
|
||||||
|
|
||||||
RELATIONTYPE(DESCRIPTION_FOR,
|
RELATIONTYPE(DESCRIPTION_FOR, "description for", ATK_RELATION_DESCRIPTION_FOR,
|
||||||
"description for",
|
NAVRELATION_DESCRIPTION_FOR, IA2_RELATION_DESCRIPTION_FOR)
|
||||||
ATK_RELATION_DESCRIPTION_FOR,
|
|
||||||
NAVRELATION_DESCRIPTION_FOR,
|
|
||||||
IA2_RELATION_DESCRIPTION_FOR)
|
|
||||||
|
|
||||||
RELATIONTYPE(NODE_CHILD_OF,
|
RELATIONTYPE(NODE_CHILD_OF, "node child of", ATK_RELATION_NODE_CHILD_OF,
|
||||||
"node child of",
|
NAVRELATION_NODE_CHILD_OF, IA2_RELATION_NODE_CHILD_OF)
|
||||||
ATK_RELATION_NODE_CHILD_OF,
|
|
||||||
NAVRELATION_NODE_CHILD_OF,
|
|
||||||
IA2_RELATION_NODE_CHILD_OF)
|
|
||||||
|
|
||||||
RELATIONTYPE(NODE_PARENT_OF,
|
RELATIONTYPE(NODE_PARENT_OF, "node parent of", ATK_RELATION_NODE_PARENT_OF,
|
||||||
"node parent of",
|
NAVRELATION_NODE_PARENT_OF, IA2_RELATION_NODE_PARENT_OF)
|
||||||
ATK_RELATION_NODE_PARENT_OF,
|
|
||||||
NAVRELATION_NODE_PARENT_OF,
|
|
||||||
IA2_RELATION_NODE_PARENT_OF)
|
|
||||||
|
|
||||||
RELATIONTYPE(CONTROLLED_BY,
|
RELATIONTYPE(CONTROLLED_BY, "controlled by", ATK_RELATION_CONTROLLED_BY,
|
||||||
"controlled by",
|
NAVRELATION_CONTROLLED_BY, IA2_RELATION_CONTROLLED_BY)
|
||||||
ATK_RELATION_CONTROLLED_BY,
|
|
||||||
NAVRELATION_CONTROLLED_BY,
|
|
||||||
IA2_RELATION_CONTROLLED_BY)
|
|
||||||
|
|
||||||
RELATIONTYPE(CONTROLLER_FOR,
|
RELATIONTYPE(CONTROLLER_FOR, "controller for", ATK_RELATION_CONTROLLER_FOR,
|
||||||
"controller for",
|
NAVRELATION_CONTROLLER_FOR, IA2_RELATION_CONTROLLER_FOR)
|
||||||
ATK_RELATION_CONTROLLER_FOR,
|
|
||||||
NAVRELATION_CONTROLLER_FOR,
|
|
||||||
IA2_RELATION_CONTROLLER_FOR)
|
|
||||||
|
|
||||||
RELATIONTYPE(FLOWS_TO,
|
RELATIONTYPE(FLOWS_TO, "flows to", ATK_RELATION_FLOWS_TO, NAVRELATION_FLOWS_TO,
|
||||||
"flows to",
|
|
||||||
ATK_RELATION_FLOWS_TO,
|
|
||||||
NAVRELATION_FLOWS_TO,
|
|
||||||
IA2_RELATION_FLOWS_TO)
|
IA2_RELATION_FLOWS_TO)
|
||||||
|
|
||||||
RELATIONTYPE(FLOWS_FROM,
|
RELATIONTYPE(FLOWS_FROM, "flows from", ATK_RELATION_FLOWS_FROM,
|
||||||
"flows from",
|
NAVRELATION_FLOWS_FROM, IA2_RELATION_FLOWS_FROM)
|
||||||
ATK_RELATION_FLOWS_FROM,
|
|
||||||
NAVRELATION_FLOWS_FROM,
|
|
||||||
IA2_RELATION_FLOWS_FROM)
|
|
||||||
|
|
||||||
RELATIONTYPE(MEMBER_OF,
|
RELATIONTYPE(MEMBER_OF, "member of", ATK_RELATION_MEMBER_OF,
|
||||||
"member of",
|
NAVRELATION_MEMBER_OF, IA2_RELATION_MEMBER_OF)
|
||||||
ATK_RELATION_MEMBER_OF,
|
|
||||||
NAVRELATION_MEMBER_OF,
|
|
||||||
IA2_RELATION_MEMBER_OF)
|
|
||||||
|
|
||||||
RELATIONTYPE(SUBWINDOW_OF,
|
RELATIONTYPE(SUBWINDOW_OF, "subwindow of", ATK_RELATION_SUBWINDOW_OF,
|
||||||
"subwindow of",
|
NAVRELATION_SUBWINDOW_OF, IA2_RELATION_SUBWINDOW_OF)
|
||||||
ATK_RELATION_SUBWINDOW_OF,
|
|
||||||
NAVRELATION_SUBWINDOW_OF,
|
|
||||||
IA2_RELATION_SUBWINDOW_OF)
|
|
||||||
|
|
||||||
RELATIONTYPE(EMBEDS,
|
RELATIONTYPE(EMBEDS, "embeds", ATK_RELATION_EMBEDS, NAVRELATION_EMBEDS,
|
||||||
"embeds",
|
|
||||||
ATK_RELATION_EMBEDS,
|
|
||||||
NAVRELATION_EMBEDS,
|
|
||||||
IA2_RELATION_EMBEDS)
|
IA2_RELATION_EMBEDS)
|
||||||
|
|
||||||
RELATIONTYPE(EMBEDDED_BY,
|
RELATIONTYPE(EMBEDDED_BY, "embedded by", ATK_RELATION_EMBEDDED_BY,
|
||||||
"embedded by",
|
NAVRELATION_EMBEDDED_BY, IA2_RELATION_EMBEDDED_BY)
|
||||||
ATK_RELATION_EMBEDDED_BY,
|
|
||||||
NAVRELATION_EMBEDDED_BY,
|
|
||||||
IA2_RELATION_EMBEDDED_BY)
|
|
||||||
|
|
||||||
RELATIONTYPE(POPUP_FOR,
|
RELATIONTYPE(POPUP_FOR, "popup for", ATK_RELATION_POPUP_FOR,
|
||||||
"popup for",
|
NAVRELATION_POPUP_FOR, IA2_RELATION_POPUP_FOR)
|
||||||
ATK_RELATION_POPUP_FOR,
|
|
||||||
NAVRELATION_POPUP_FOR,
|
|
||||||
IA2_RELATION_POPUP_FOR)
|
|
||||||
|
|
||||||
RELATIONTYPE(PARENT_WINDOW_OF,
|
RELATIONTYPE(PARENT_WINDOW_OF, "parent window of",
|
||||||
"parent window of",
|
ATK_RELATION_PARENT_WINDOW_OF, NAVRELATION_PARENT_WINDOW_OF,
|
||||||
ATK_RELATION_PARENT_WINDOW_OF,
|
|
||||||
NAVRELATION_PARENT_WINDOW_OF,
|
|
||||||
IA2_RELATION_PARENT_WINDOW_OF)
|
IA2_RELATION_PARENT_WINDOW_OF)
|
||||||
|
|
||||||
RELATIONTYPE(DEFAULT_BUTTON,
|
RELATIONTYPE(DEFAULT_BUTTON, "default button", ATK_RELATION_NULL,
|
||||||
"default button",
|
NAVRELATION_DEFAULT_BUTTON, IA2_RELATION_NULL)
|
||||||
ATK_RELATION_NULL,
|
|
||||||
NAVRELATION_DEFAULT_BUTTON,
|
|
||||||
IA2_RELATION_NULL)
|
|
||||||
|
|
||||||
RELATIONTYPE(CONTAINING_DOCUMENT,
|
RELATIONTYPE(CONTAINING_DOCUMENT, "containing document", ATK_RELATION_NULL,
|
||||||
"containing document",
|
NAVRELATION_CONTAINING_DOCUMENT, IA2_RELATION_CONTAINING_DOCUMENT)
|
||||||
ATK_RELATION_NULL,
|
|
||||||
NAVRELATION_CONTAINING_DOCUMENT,
|
|
||||||
IA2_RELATION_CONTAINING_DOCUMENT)
|
|
||||||
|
|
||||||
RELATIONTYPE(CONTAINING_TAB_PANE,
|
RELATIONTYPE(CONTAINING_TAB_PANE, "containing tab pane", ATK_RELATION_NULL,
|
||||||
"containing tab pane",
|
NAVRELATION_CONTAINING_TAB_PANE, IA2_RELATION_CONTAINING_TAB_PANE)
|
||||||
ATK_RELATION_NULL,
|
|
||||||
NAVRELATION_CONTAINING_TAB_PANE,
|
|
||||||
IA2_RELATION_CONTAINING_TAB_PANE)
|
|
||||||
|
|
||||||
RELATIONTYPE(CONTAINING_WINDOW,
|
RELATIONTYPE(CONTAINING_WINDOW, "containing window", ATK_RELATION_NULL,
|
||||||
"containing window",
|
NAVRELATION_CONTAINING_WINDOW, IA2_RELATION_CONTAINING_WINDOW)
|
||||||
ATK_RELATION_NULL,
|
|
||||||
NAVRELATION_CONTAINING_WINDOW,
|
|
||||||
IA2_RELATION_CONTAINING_WINDOW)
|
|
||||||
|
|
||||||
RELATIONTYPE(CONTAINING_APPLICATION,
|
RELATIONTYPE(CONTAINING_APPLICATION, "containing application",
|
||||||
"containing application",
|
ATK_RELATION_NULL, NAVRELATION_CONTAINING_APPLICATION,
|
||||||
ATK_RELATION_NULL,
|
|
||||||
NAVRELATION_CONTAINING_APPLICATION,
|
|
||||||
IA2_RELATION_CONTAINING_APPLICATION)
|
IA2_RELATION_CONTAINING_APPLICATION)
|
||||||
|
|
||||||
RELATIONTYPE(DETAILS,
|
RELATIONTYPE(DETAILS, "details", ATK_RELATION_DETAILS, NAVRELATION_DETAILS,
|
||||||
"details",
|
|
||||||
ATK_RELATION_DETAILS,
|
|
||||||
NAVRELATION_DETAILS,
|
|
||||||
IA2_RELATION_DETAILS)
|
IA2_RELATION_DETAILS)
|
||||||
|
|
||||||
RELATIONTYPE(DETAILS_FOR,
|
RELATIONTYPE(DETAILS_FOR, "details for", ATK_RELATION_DETAILS_FOR,
|
||||||
"details for",
|
NAVRELATION_DETAILS_FOR, IA2_RELATION_DETAILS_FOR)
|
||||||
ATK_RELATION_DETAILS_FOR,
|
|
||||||
NAVRELATION_DETAILS_FOR,
|
|
||||||
IA2_RELATION_DETAILS_FOR)
|
|
||||||
|
|
||||||
RELATIONTYPE(ERRORMSG,
|
RELATIONTYPE(ERRORMSG, "error", ATK_RELATION_ERROR_MESSAGE, NAVRELATION_ERROR,
|
||||||
"error",
|
|
||||||
ATK_RELATION_ERROR_MESSAGE,
|
|
||||||
NAVRELATION_ERROR,
|
|
||||||
IA2_RELATION_ERROR)
|
IA2_RELATION_ERROR)
|
||||||
|
|
||||||
RELATIONTYPE(ERRORMSG_FOR,
|
RELATIONTYPE(ERRORMSG_FOR, "error for", ATK_RELATION_ERROR_FOR,
|
||||||
"error for",
|
NAVRELATION_ERROR_FOR, IA2_RELATION_ERROR_FOR)
|
||||||
ATK_RELATION_ERROR_FOR,
|
|
||||||
NAVRELATION_ERROR_FOR,
|
|
||||||
IA2_RELATION_ERROR_FOR)
|
|
||||||
|
|||||||
@@ -362,7 +362,8 @@ enum Role {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a mathematical equation. It is used by MATHML, where there is a
|
* 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,
|
EQUATION = 55,
|
||||||
|
|
||||||
@@ -418,7 +419,7 @@ enum Role {
|
|||||||
/**
|
/**
|
||||||
* Represents an arrow in one of the four cardinal directions.
|
* Represents an arrow in one of the four cardinal directions.
|
||||||
*/
|
*/
|
||||||
ARROW = 65,
|
ARROW = 65,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a control that can be drawn into and is used to trap events.
|
* Represents a control that can be drawn into and is used to trap events.
|
||||||
@@ -434,7 +435,7 @@ enum Role {
|
|||||||
/**
|
/**
|
||||||
* Represents a specialized dialog that lets the user choose a color.
|
* Represents a specialized dialog that lets the user choose a color.
|
||||||
*/
|
*/
|
||||||
COLOR_CHOOSER = 68,
|
COLOR_CHOOSER = 68,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents control whose purpose is to allow a user to edit a date.
|
* Represents control whose purpose is to allow a user to edit a date.
|
||||||
@@ -1047,11 +1048,11 @@ enum Role {
|
|||||||
LAST_ROLE = FORM_LANDMARK
|
LAST_ROLE = FORM_LANDMARK
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace role
|
} // namespace roles
|
||||||
|
|
||||||
typedef enum mozilla::a11y::roles::Role role;
|
typedef enum mozilla::a11y::roles::Role role;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,30 +24,23 @@ using namespace mozilla;
|
|||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
using mozilla::dom::Selection;
|
using mozilla::dom::Selection;
|
||||||
|
|
||||||
struct mozilla::a11y::SelData final
|
struct mozilla::a11y::SelData final {
|
||||||
{
|
SelData(Selection* aSel, int32_t aReason) : mSel(aSel), mReason(aReason) {}
|
||||||
SelData(Selection* aSel, int32_t aReason) :
|
|
||||||
mSel(aSel), mReason(aReason) {}
|
|
||||||
|
|
||||||
RefPtr<Selection> mSel;
|
RefPtr<Selection> mSel;
|
||||||
int16_t mReason;
|
int16_t mReason;
|
||||||
|
|
||||||
NS_INLINE_DECL_REFCOUNTING(SelData)
|
NS_INLINE_DECL_REFCOUNTING(SelData)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Private destructor, to discourage deletion outside of Release():
|
// Private destructor, to discourage deletion outside of Release():
|
||||||
~SelData() {}
|
~SelData() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
SelectionManager::SelectionManager() :
|
SelectionManager::SelectionManager()
|
||||||
mCaretOffset(-1), mAccWithCaret(nullptr)
|
: mCaretOffset(-1), mAccWithCaret(nullptr) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void SelectionManager::ClearControlSelectionListener() {
|
||||||
|
|
||||||
void
|
|
||||||
SelectionManager::ClearControlSelectionListener()
|
|
||||||
{
|
|
||||||
// Remove 'this' registered as selection listener for the normal selection.
|
// Remove 'this' registered as selection listener for the normal selection.
|
||||||
if (mCurrCtrlNormalSel) {
|
if (mCurrCtrlNormalSel) {
|
||||||
mCurrCtrlNormalSel->RemoveSelectionListener(this);
|
mCurrCtrlNormalSel->RemoveSelectionListener(this);
|
||||||
@@ -62,22 +55,18 @@ SelectionManager::ClearControlSelectionListener()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm) {
|
||||||
SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
|
|
||||||
{
|
|
||||||
// When focus moves such that the caret is part of a new frame selection
|
// 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
|
// this removes the old selection listener and attaches a new one for
|
||||||
// the current focus.
|
// the current focus.
|
||||||
ClearControlSelectionListener();
|
ClearControlSelectionListener();
|
||||||
|
|
||||||
nsIFrame* controlFrame = aFocusedElm->GetPrimaryFrame();
|
nsIFrame* controlFrame = aFocusedElm->GetPrimaryFrame();
|
||||||
if (!controlFrame)
|
if (!controlFrame) return;
|
||||||
return;
|
|
||||||
|
|
||||||
const nsFrameSelection* frameSel = controlFrame->GetConstFrameSelection();
|
const nsFrameSelection* frameSel = controlFrame->GetConstFrameSelection();
|
||||||
NS_ASSERTION(frameSel, "No frame selection for focused element!");
|
NS_ASSERTION(frameSel, "No frame selection for focused element!");
|
||||||
if (!frameSel)
|
if (!frameSel) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Register 'this' as selection listener for the normal selection.
|
// Register 'this' as selection listener for the normal selection.
|
||||||
Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal);
|
Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal);
|
||||||
@@ -90,9 +79,7 @@ SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
|
|||||||
mCurrCtrlSpellSel = spellSel;
|
mCurrCtrlSpellSel = spellSel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SelectionManager::AddDocSelectionListener(nsIPresShell* aPresShell) {
|
||||||
SelectionManager::AddDocSelectionListener(nsIPresShell* aPresShell)
|
|
||||||
{
|
|
||||||
const nsFrameSelection* frameSel = aPresShell->ConstFrameSelection();
|
const nsFrameSelection* frameSel = aPresShell->ConstFrameSelection();
|
||||||
|
|
||||||
// Register 'this' as selection listener for the normal selection.
|
// Register 'this' as selection listener for the normal selection.
|
||||||
@@ -104,9 +91,7 @@ SelectionManager::AddDocSelectionListener(nsIPresShell* aPresShell)
|
|||||||
spellSel->AddSelectionListener(this);
|
spellSel->AddSelectionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SelectionManager::RemoveDocSelectionListener(nsIPresShell* aPresShell) {
|
||||||
SelectionManager::RemoveDocSelectionListener(nsIPresShell* aPresShell)
|
|
||||||
{
|
|
||||||
const nsFrameSelection* frameSel = aPresShell->ConstFrameSelection();
|
const nsFrameSelection* frameSel = aPresShell->ConstFrameSelection();
|
||||||
|
|
||||||
// Remove 'this' registered as selection listener for the normal selection.
|
// Remove 'this' registered as selection listener for the normal selection.
|
||||||
@@ -119,41 +104,35 @@ SelectionManager::RemoveDocSelectionListener(nsIPresShell* aPresShell)
|
|||||||
spellSel->RemoveSelectionListener(this);
|
spellSel->RemoveSelectionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent) {
|
||||||
SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent)
|
|
||||||
{
|
|
||||||
// Fire selection change event if it's not pure caret-move selection change,
|
// Fire selection change event if it's not pure caret-move selection change,
|
||||||
// i.e. the accessible has or had not collapsed selection.
|
// i.e. the accessible has or had not collapsed selection.
|
||||||
AccTextSelChangeEvent* event = downcast_accEvent(aEvent);
|
AccTextSelChangeEvent* event = downcast_accEvent(aEvent);
|
||||||
if (!event->IsCaretMoveOnly())
|
if (!event->IsCaretMoveOnly()) nsEventShell::FireEvent(aEvent);
|
||||||
nsEventShell::FireEvent(aEvent);
|
|
||||||
|
|
||||||
// Fire caret move event if there's a caret in the selection.
|
// Fire caret move event if there's a caret in the selection.
|
||||||
nsINode* caretCntrNode =
|
nsINode* caretCntrNode = nsCoreUtils::GetDOMNodeFromDOMPoint(
|
||||||
nsCoreUtils::GetDOMNodeFromDOMPoint(event->mSel->GetFocusNode(),
|
event->mSel->GetFocusNode(), event->mSel->FocusOffset());
|
||||||
event->mSel->FocusOffset());
|
if (!caretCntrNode) return;
|
||||||
if (!caretCntrNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
HyperTextAccessible* caretCntr = nsAccUtils::GetTextContainer(caretCntrNode);
|
HyperTextAccessible* caretCntr = nsAccUtils::GetTextContainer(caretCntrNode);
|
||||||
NS_ASSERTION(caretCntr,
|
NS_ASSERTION(
|
||||||
"No text container for focus while there's one for common ancestor?!");
|
caretCntr,
|
||||||
if (!caretCntr)
|
"No text container for focus while there's one for common ancestor?!");
|
||||||
return;
|
if (!caretCntr) return;
|
||||||
|
|
||||||
Selection* selection = caretCntr->DOMSelection();
|
Selection* selection = caretCntr->DOMSelection();
|
||||||
|
|
||||||
// XXX Sometimes we can't get a selection for caretCntr, in that case assume
|
// XXX Sometimes we can't get a selection for caretCntr, in that case assume
|
||||||
// event->mSel is correct.
|
// event->mSel is correct.
|
||||||
if (!selection)
|
if (!selection) selection = event->mSel;
|
||||||
selection = event->mSel;
|
|
||||||
|
|
||||||
mCaretOffset = caretCntr->DOMPointToOffset(selection->GetFocusNode(),
|
mCaretOffset = caretCntr->DOMPointToOffset(selection->GetFocusNode(),
|
||||||
selection->FocusOffset());
|
selection->FocusOffset());
|
||||||
mAccWithCaret = caretCntr;
|
mAccWithCaret = caretCntr;
|
||||||
if (mCaretOffset != -1) {
|
if (mCaretOffset != -1) {
|
||||||
RefPtr<AccCaretMoveEvent> caretMoveEvent =
|
RefPtr<AccCaretMoveEvent> caretMoveEvent =
|
||||||
new AccCaretMoveEvent(caretCntr, mCaretOffset, aEvent->FromUserInput());
|
new AccCaretMoveEvent(caretCntr, mCaretOffset, aEvent->FromUserInput());
|
||||||
nsEventShell::FireEvent(caretMoveEvent);
|
nsEventShell::FireEvent(caretMoveEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,8 +140,7 @@ SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
SelectionManager::NotifySelectionChanged(nsIDocument* aDocument,
|
SelectionManager::NotifySelectionChanged(nsIDocument* aDocument,
|
||||||
Selection* aSelection,
|
Selection* aSelection,
|
||||||
int16_t aReason)
|
int16_t aReason) {
|
||||||
{
|
|
||||||
if (NS_WARN_IF(!aDocument) || NS_WARN_IF(!aSelection)) {
|
if (NS_WARN_IF(!aDocument) || NS_WARN_IF(!aSelection)) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
@@ -179,30 +157,27 @@ SelectionManager::NotifySelectionChanged(nsIDocument* aDocument,
|
|||||||
// so that we are guaranteed that the notification is processed before
|
// so that we are guaranteed that the notification is processed before
|
||||||
// the selection manager is destroyed.
|
// the selection manager is destroyed.
|
||||||
RefPtr<SelData> selData = new SelData(aSelection, aReason);
|
RefPtr<SelData> selData = new SelData(aSelection, aReason);
|
||||||
document->HandleNotification<SelectionManager, SelData>
|
document->HandleNotification<SelectionManager, SelData>(
|
||||||
(this, &SelectionManager::ProcessSelectionChanged, selData);
|
this, &SelectionManager::ProcessSelectionChanged, selData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SelectionManager::ProcessSelectionChanged(SelData* aSelData) {
|
||||||
SelectionManager::ProcessSelectionChanged(SelData* aSelData)
|
|
||||||
{
|
|
||||||
Selection* selection = aSelData->mSel;
|
Selection* selection = aSelData->mSel;
|
||||||
if (!selection->GetPresShell())
|
if (!selection->GetPresShell()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
const nsRange* range = selection->GetAnchorFocusRange();
|
const nsRange* range = selection->GetAnchorFocusRange();
|
||||||
nsINode* cntrNode = nullptr;
|
nsINode* cntrNode = nullptr;
|
||||||
if (range)
|
if (range) cntrNode = range->GetCommonAncestor();
|
||||||
cntrNode = range->GetCommonAncestor();
|
|
||||||
|
|
||||||
if (!cntrNode) {
|
if (!cntrNode) {
|
||||||
cntrNode = selection->GetFrameSelection()->GetAncestorLimiter();
|
cntrNode = selection->GetFrameSelection()->GetAncestorLimiter();
|
||||||
if (!cntrNode) {
|
if (!cntrNode) {
|
||||||
cntrNode = selection->GetPresShell()->GetDocument();
|
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!");
|
"Wrong selection container was used!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,13 +191,13 @@ SelectionManager::ProcessSelectionChanged(SelData* aSelData)
|
|||||||
|
|
||||||
if (selection->GetType() == SelectionType::eNormal) {
|
if (selection->GetType() == SelectionType::eNormal) {
|
||||||
RefPtr<AccEvent> event =
|
RefPtr<AccEvent> event =
|
||||||
new AccTextSelChangeEvent(text, selection, aSelData->mReason);
|
new AccTextSelChangeEvent(text, selection, aSelData->mReason);
|
||||||
text->Document()->FireDelayedEvent(event);
|
text->Document()->FireDelayedEvent(event);
|
||||||
|
|
||||||
} else if (selection->GetType() == SelectionType::eSpellCheck) {
|
} else if (selection->GetType() == SelectionType::eSpellCheck) {
|
||||||
// XXX: fire an event for container accessible of the focus/anchor range
|
// XXX: fire an event for container accessible of the focus/anchor range
|
||||||
// of the spelcheck selection.
|
// of the spelcheck selection.
|
||||||
text->Document()->FireDelayedEvent(nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED,
|
text->Document()->FireDelayedEvent(
|
||||||
text);
|
nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user