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"}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,11 +130,9 @@ 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->IsTextInserted(),
|
|
||||||
event->IsFromUserInput());
|
event->IsFromUserInput());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -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,11 +271,8 @@ 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 =
|
||||||
@@ -310,38 +290,30 @@ 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, \
|
|
||||||
stringRole, \
|
|
||||||
atkRole, \
|
|
||||||
macRole, \
|
|
||||||
msaaRole, \
|
|
||||||
ia2Role, \
|
|
||||||
androidClass, \
|
|
||||||
nameRule) \
|
|
||||||
case roles::geckoRole: \
|
case roles::geckoRole: \
|
||||||
return androidClass;
|
return androidClass;
|
||||||
|
|
||||||
@@ -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(
|
||||||
|
nodeInfo, "parentId",
|
||||||
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
|
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(
|
||||||
|
nodeInfo, "parentId",
|
||||||
java::sdk::Integer::ValueOf(parent ? parent->VirtualViewID() : 0));
|
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,25 +32,20 @@ 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());
|
||||||
}
|
}
|
||||||
@@ -61,8 +55,7 @@ public:
|
|||||||
|
|
||||||
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,22 +66,22 @@ 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,9 +101,7 @@ 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,
|
|
||||||
frames,
|
|
||||||
nsLayoutUtils::FrameForPointFlags::ONLY_VISIBLE);
|
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++) {
|
||||||
@@ -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()
|
||||||
|
? 0
|
||||||
: reinterpret_cast<uint64_t>(accessible->UniqueID());
|
: reinterpret_cast<uint64_t>(accessible->UniqueID());
|
||||||
cacheData.AppendElement(BatchData(accessible->Document()->IPCDoc(),
|
cacheData.AppendElement(
|
||||||
uid,
|
BatchData(accessible->Document()->IPCDoc(), uid, accessible->State(),
|
||||||
accessible->State(),
|
accessible->Bounds(), nsString(), nsString(), nsString(),
|
||||||
accessible->Bounds(),
|
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
|
||||||
nsString(),
|
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
|
||||||
nsString(),
|
|
||||||
nsString(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
UnspecifiedNaN<double>(),
|
|
||||||
nsTArray<Attribute>()));
|
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,15 +157,11 @@ 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
|
||||||
@@ -185,9 +169,10 @@ DocAccessibleWrap::CacheViewport()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,16 +180,15 @@ 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()
|
||||||
|
? 0
|
||||||
: reinterpret_cast<uint64_t>(acc->UniqueID());
|
: reinterpret_cast<uint64_t>(acc->UniqueID());
|
||||||
nsAutoString name;
|
nsAutoString name;
|
||||||
acc->Name(name);
|
acc->Name(name);
|
||||||
@@ -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()
|
||||||
|
? 0
|
||||||
: reinterpret_cast<uint64_t>(accessible->UniqueID());
|
: reinterpret_cast<uint64_t>(accessible->UniqueID());
|
||||||
boundsData.AppendElement(BatchData(accessible->Document()->IPCDoc(),
|
boundsData.AppendElement(BatchData(
|
||||||
uid,
|
accessible->Document()->IPCDoc(), uid, 0, accessible->Bounds(),
|
||||||
0,
|
nsString(), nsString(), nsString(), UnspecifiedNaN<double>(),
|
||||||
accessible->Bounds(),
|
UnspecifiedNaN<double>(), UnspecifiedNaN<double>(),
|
||||||
nsString(),
|
UnspecifiedNaN<double>(), nsTArray<Attribute>()));
|
||||||
nsString(),
|
|
||||||
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();
|
||||||
|
|||||||
@@ -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,9 +31,7 @@ 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());
|
||||||
|
|
||||||
@@ -57,9 +47,7 @@ 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) {
|
||||||
@@ -73,11 +61,8 @@ 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);
|
||||||
|
|
||||||
@@ -98,9 +83,7 @@ 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);
|
||||||
|
|
||||||
@@ -109,29 +92,21 @@ a11y::ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t 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) {
|
||||||
@@ -139,23 +114,14 @@ a11y::ProxyShowHideEvent(ProxyAccessible* aTarget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -176,36 +142,28 @@ 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 uint64_t aBatchType,
|
|
||||||
const nsTArray<ProxyAccessible*>& aAccessibles,
|
const nsTArray<ProxyAccessible*>& aAccessibles,
|
||||||
const nsTArray<BatchData>& aData)
|
const nsTArray<BatchData>& aData) {
|
||||||
{
|
|
||||||
SessionAccessibility* sessionAcc =
|
SessionAccessibility* sessionAcc =
|
||||||
SessionAccessibility::GetInstanceFor(aDocument);
|
SessionAccessibility::GetInstanceFor(aDocument);
|
||||||
if (!sessionAcc) {
|
if (!sessionAcc) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -34,9 +33,7 @@ ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -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,8 +104,7 @@ 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*>(
|
||||||
@@ -118,23 +114,21 @@ public:
|
|||||||
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) {
|
||||||
@@ -63,10 +57,8 @@ RootAccessibleWrap::FindAccessibleById(int32_t aID)
|
|||||||
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) {
|
||||||
@@ -81,9 +73,8 @@ 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) {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
@@ -29,18 +29,16 @@
|
|||||||
} 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,10 +47,8 @@ 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",
|
||||||
@@ -68,17 +64,13 @@ SessionAccessibility::SetAttached(bool aAttached,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -184,13 +165,11 @@ SessionAccessibility::SendFocusEvent(AccessibleWrap* aAccessible)
|
|||||||
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,8 +180,10 @@ 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(
|
||||||
@@ -212,17 +193,15 @@ SessionAccessibility::SendScrollingEvent(AccessibleWrap* aAccessible,
|
|||||||
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) {
|
||||||
@@ -234,10 +213,8 @@ SessionAccessibility::SendWindowStateChangedEvent(AccessibleWrap* aAccessible)
|
|||||||
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,8 +223,10 @@ 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(
|
||||||
@@ -255,14 +234,11 @@ SessionAccessibility::SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
|
|||||||
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,
|
int32_t aStart, uint32_t aLen,
|
||||||
uint32_t aLen,
|
|
||||||
bool aIsInsert,
|
bool aIsInsert,
|
||||||
bool aFromUser)
|
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,8 +256,10 @@ 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(
|
||||||
@@ -289,18 +267,18 @@ SessionAccessibility::SendTextChangedEvent(AccessibleWrap* aAccessible,
|
|||||||
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(
|
||||||
@@ -309,12 +287,12 @@ SessionAccessibility::SendTextTraversedEvent(AccessibleWrap* aAccessible,
|
|||||||
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(
|
||||||
@@ -322,12 +300,12 @@ SessionAccessibility::SendClickedEvent(AccessibleWrap* aAccessible, bool aChecke
|
|||||||
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(
|
||||||
@@ -335,10 +313,9 @@ SessionAccessibility::SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelec
|
|||||||
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,10 +331,9 @@ 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);
|
||||||
@@ -365,16 +341,10 @@ SessionAccessibility::ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAc
|
|||||||
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);
|
||||||
|
|||||||
@@ -27,8 +27,7 @@
|
|||||||
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)); \
|
||||||
} \
|
} \
|
||||||
@@ -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)
|
: mWindow(aPtr, aWindow), mSessionAccessibility(aSessionAccessibility) {
|
||||||
, 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,18 +97,21 @@ public:
|
|||||||
void SendWindowStateChangedEvent(AccessibleWrap* aAccessible);
|
void SendWindowStateChangedEvent(AccessibleWrap* aAccessible);
|
||||||
|
|
||||||
// Cache methods
|
// Cache methods
|
||||||
void ReplaceViewportCache(const nsTArray<AccessibleWrap*>& aAccessibles,
|
void ReplaceViewportCache(
|
||||||
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
||||||
|
|
||||||
void ReplaceFocusPathCache(const nsTArray<AccessibleWrap*>& aAccessibles,
|
void ReplaceFocusPathCache(
|
||||||
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
||||||
|
|
||||||
void UpdateCachedBounds(const nsTArray<AccessibleWrap*>& aAccessibles,
|
void UpdateCachedBounds(
|
||||||
|
const nsTArray<AccessibleWrap*>& aAccessibles,
|
||||||
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
|
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);
|
||||||
|
|||||||
@@ -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,65 +27,56 @@ 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); \
|
||||||
@@ -94,19 +85,17 @@ struct ParentObject;
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
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()) { \
|
if (aValue.IsNull()) { \
|
||||||
m##typeName##Properties.Remove(static_cast<int>(aProperty)); \
|
m##typeName##Properties.Remove(static_cast<int>(aProperty)); \
|
||||||
} else { \
|
} else { \
|
||||||
m##typeName##Properties.Put(static_cast<int>(aProperty), aValue.Value()); \
|
m##typeName##Properties.Put(static_cast<int>(aProperty), \
|
||||||
} \
|
aValue.Value()); \
|
||||||
} \
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
class AccessibleNode : public nsISupports,
|
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,14 +164,14 @@ 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 =
|
||||||
|
(aValue.Value() ? mBooleanProperties | (1U << (2 * num + 1))
|
||||||
: 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
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -32,8 +32,8 @@ enum AtkProperty {
|
|||||||
|
|
||||||
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,14 +74,14 @@ 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();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
const GValue* param_values, gpointer data) {
|
||||||
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,13 +90,12 @@ 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);
|
||||||
@@ -125,11 +106,9 @@ gboolean fireRootAccessibleAddedCB(gpointer 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);
|
||||||
@@ -138,12 +117,12 @@ ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx, Accessible* aChild)
|
|||||||
|
|
||||||
// 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);
|
||||||
@@ -152,9 +131,7 @@ ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx, Accessible* aChild)
|
|||||||
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();
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -107,15 +90,11 @@ AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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__
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -33,10 +31,11 @@ AddBOMs(nsACString& aDest, const nsACString& aSource)
|
|||||||
|
|
||||||
// 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,
|
||||||
|
"Incoherency between computed length"
|
||||||
"and actually translated 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,16 +78,15 @@ 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(
|
||||||
|
static_cast<int>(aStr.Length()) >= UTF8traits::bytes(aStr.CharAt(0)),
|
||||||
"The leading character should be complete");
|
"The leading character should be complete");
|
||||||
|
|
||||||
// drop first character
|
// drop first character
|
||||||
@@ -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,44 +41,45 @@
|
|||||||
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
|
* In order to properly get non-BMP values, offsets need to be changed
|
||||||
@@ -106,17 +107,15 @@ namespace DOMtoATK
|
|||||||
#endif
|
#endif
|
||||||
bool mStartShifted;
|
bool mStartShifted;
|
||||||
bool mEndShifted;
|
bool mEndShifted;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get text from aAccessible, using ATKStringConverterHelper to properly
|
* Get text from aAccessible, using ATKStringConverterHelper to properly
|
||||||
* introduce appropriate BOMs.
|
* introduce appropriate BOMs.
|
||||||
*/
|
*/
|
||||||
template <class AccessibleOrProxy>
|
template <class AccessibleOrProxy>
|
||||||
gchar* NewATKString(AccessibleOrProxy* aAccessible,
|
gchar* NewATKString(AccessibleOrProxy* aAccessible, gint aStartOffset,
|
||||||
gint aStartOffset, gint aEndOffset,
|
gint aEndOffset, AtkStringConvertFlags aFlags) {
|
||||||
AtkStringConvertFlags aFlags)
|
|
||||||
{
|
|
||||||
gint startOffset = aStartOffset, endOffset = aEndOffset;
|
gint startOffset = aStartOffset, endOffset = aEndOffset;
|
||||||
ATKStringConverterHelper converter;
|
ATKStringConverterHelper converter;
|
||||||
converter.AdjustOffsets(&startOffset, &endOffset,
|
converter.AdjustOffsets(&startOffset, &endOffset,
|
||||||
@@ -126,15 +125,14 @@ namespace DOMtoATK
|
|||||||
if (aFlags & AtkStringConvertFlags::ConvertTextToAsterisks)
|
if (aFlags & AtkStringConvertFlags::ConvertTextToAsterisks)
|
||||||
ConvertTexttoAsterisks(str);
|
ConvertTexttoAsterisks(str);
|
||||||
return converter.ConvertAdjusted(str);
|
return converter.ConvertAdjusted(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a character from aAccessible, fetching more data as appropriate to
|
* Get a character from aAccessible, fetching more data as appropriate to
|
||||||
* properly get non-BMP characters or a BOM as appropriate.
|
* properly get non-BMP characters or a BOM as appropriate.
|
||||||
*/
|
*/
|
||||||
template <class AccessibleCharAt>
|
template <class AccessibleCharAt>
|
||||||
gunichar ATKCharacter(AccessibleCharAt* aAccessible, gint aOffset)
|
gunichar ATKCharacter(AccessibleCharAt* aAccessible, gint aOffset) {
|
||||||
{
|
|
||||||
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
|
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
|
||||||
gunichar character = static_cast<gunichar>(aAccessible->CharAt(aOffset));
|
gunichar character = static_cast<gunichar>(aAccessible->CharAt(aOffset));
|
||||||
|
|
||||||
@@ -145,7 +143,8 @@ namespace DOMtoATK
|
|||||||
|
|
||||||
if (NS_IS_HIGH_SURROGATE(character)) {
|
if (NS_IS_HIGH_SURROGATE(character)) {
|
||||||
// Heading surrogate, get the trailing surrogate and combine them.
|
// Heading surrogate, get the trailing surrogate and combine them.
|
||||||
gunichar characterLow = static_cast<gunichar>(aAccessible->CharAt(aOffset + 1));
|
gunichar characterLow =
|
||||||
|
static_cast<gunichar>(aAccessible->CharAt(aOffset + 1));
|
||||||
|
|
||||||
if (!NS_IS_LOW_SURROGATE(characterLow)) {
|
if (!NS_IS_LOW_SURROGATE(characterLow)) {
|
||||||
// It should have been a trailing surrogate... Flag the error.
|
// It should have been a trailing surrogate... Flag the error.
|
||||||
@@ -155,9 +154,9 @@ namespace DOMtoATK
|
|||||||
}
|
}
|
||||||
|
|
||||||
return character;
|
return character;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace DOMtoATK
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // 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,9 +16,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();
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@ typedef class HTMLTableHeaderCellAccessible HTMLTableHeaderCellAccessibleWrap;
|
|||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@ typedef class HyperTextAccessible HyperTextAccessibleWrap;
|
|||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@ typedef class ImageAccessible ImageAccessibleWrap;
|
|||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -20,25 +20,24 @@ class AccessibleWrap;
|
|||||||
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);
|
|
||||||
void getExtentsHelper(AtkObject* aAtkObj,
|
|
||||||
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
|
|
||||||
AtkCoordType aCoordType);
|
AtkCoordType aCoordType);
|
||||||
|
void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
||||||
|
gint* aHeight, AtkCoordType aCoordType);
|
||||||
|
|
||||||
#endif // ATK_INTERFACE_INIT_FUNCS_H_
|
#endif // ATK_INTERFACE_INIT_FUNCS_H_
|
||||||
|
|||||||
@@ -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,9 +32,9 @@ 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;
|
||||||
@@ -49,13 +50,12 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,17 +66,14 @@ static GnomeAccessibilityModule sAtkBridge = {
|
|||||||
"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");
|
||||||
@@ -97,22 +94,18 @@ LoadGtkModule(GnomeAccessibilityModule& aModule)
|
|||||||
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)
|
if (!aModule.lib) return NS_ERROR_FAILURE;
|
||||||
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, :(
|
||||||
|
|
||||||
//fail, :(
|
|
||||||
PR_UnloadLibrary(aModule.lib);
|
PR_UnloadLibrary(aModule.lib);
|
||||||
aModule.lib = nullptr;
|
aModule.lib = nullptr;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
@@ -120,37 +113,36 @@ LoadGtkModule(GnomeAccessibilityModule& aModule)
|
|||||||
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,22 +175,16 @@ 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) {
|
if (sToplevel_event_hook_added) {
|
||||||
sToplevel_event_hook_added = false;
|
sToplevel_event_hook_added = false;
|
||||||
g_signal_remove_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
|
g_signal_remove_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
|
||||||
@@ -223,18 +209,15 @@ a11y::PlatformShutdown()
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
|
static const char sAccEnv[] = "GNOME_ACCESSIBILITY";
|
||||||
#ifdef MOZ_ENABLE_DBUS
|
#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,14 +303,12 @@ 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 =
|
||||||
|
|||||||
@@ -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,9 +20,8 @@ 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();
|
||||||
};
|
};
|
||||||
@@ -31,4 +30,3 @@ public:
|
|||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* mozilla_a11y_Root_Accessible_Wrap_h__ */
|
#endif /* mozilla_a11y_Root_Accessible_Wrap_h__ */
|
||||||
|
|
||||||
|
|||||||
@@ -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,17 +41,13 @@ 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,
|
|
||||||
const gchar *hook_data,
|
|
||||||
guint gail_listenerid = 0)
|
|
||||||
{
|
|
||||||
GType type;
|
GType type;
|
||||||
guint signal_id;
|
guint signal_id;
|
||||||
gint rc = 0;
|
gint rc = 0;
|
||||||
@@ -65,73 +60,60 @@ add_listener (GSignalEmissionHook listener,
|
|||||||
|
|
||||||
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),
|
|
||||||
(GDestroyNotify)g_free);
|
|
||||||
listener_info->signal_id = signal_id;
|
listener_info->signal_id = signal_id;
|
||||||
listener_info->gail_listenerid = gail_listenerid;
|
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 {
|
||||||
else {
|
|
||||||
g_warning("Invalid signal type %s\n", signal);
|
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;
|
guint rc = 0;
|
||||||
gchar **split_string;
|
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);
|
g_strfreev(split_string);
|
||||||
}
|
}
|
||||||
return rc;
|
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) {
|
if (remove_listener > 0) {
|
||||||
MaiUtilListenerInfo *listener_info;
|
MaiUtilListenerInfo *listener_info;
|
||||||
gint tmp_idx = remove_listener;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,13 +125,11 @@ mai_util_remove_global_event_listener(guint remove_listener)
|
|||||||
|
|
||||||
/* 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 {
|
||||||
else {
|
|
||||||
// atk-bridge is initialized with gail (e.g. yelp)
|
// atk-bridge is initialized with gail (e.g. yelp)
|
||||||
// try gail_remove_global_event_listener
|
// try gail_remove_global_event_listener
|
||||||
if (gail_remove_global_event_listener) {
|
if (gail_remove_global_event_listener) {
|
||||||
@@ -159,15 +139,12 @@ mai_util_remove_global_event_listener(guint remove_listener)
|
|||||||
g_warning("No listener with the specified listener id %d",
|
g_warning("No listener with the specified listener id %d",
|
||||||
remove_listener);
|
remove_listener);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
g_warning("Invalid listener_id %d", remove_listener);
|
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);
|
AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1);
|
||||||
switch (key->type) {
|
switch (key->type) {
|
||||||
case GDK_KEY_PRESS:
|
case GDK_KEY_PRESS:
|
||||||
@@ -177,20 +154,18 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key)
|
|||||||
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->keycode = key->hardware_keycode;
|
||||||
event->timestamp = key->time;
|
event->timestamp = key->time;
|
||||||
@@ -198,50 +173,44 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key)
|
|||||||
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;
|
MaiKeyEventInfo *info = (MaiKeyEventInfo *)data;
|
||||||
AtkKeySnoopFuncPointer atkKeySnoop;
|
AtkKeySnoopFuncPointer atkKeySnoop;
|
||||||
atkKeySnoop.data = value;
|
atkKeySnoop.data = value;
|
||||||
return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE : FALSE;
|
return (atkKeySnoop.func_ptr)(info->key_event, info->func_data) ? TRUE
|
||||||
|
: FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
||||||
@@ -250,9 +219,8 @@ mai_key_snooper(GtkWidget *the_widget, GdkEventKey *event, gpointer func_data)
|
|||||||
|
|
||||||
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,82 +245,52 @@ 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) {
|
if (!sKey_listener_list) {
|
||||||
// atk-bridge is initialized with gail (e.g. yelp)
|
// atk-bridge is initialized with gail (e.g. yelp)
|
||||||
// try gail_remove_key_event_listener
|
// try gail_remove_key_event_listener
|
||||||
return gail_remove_key_event_listener(remove_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)
|
|
||||||
{
|
|
||||||
g_free(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
window_added (AtkObject *atk_obj,
|
|
||||||
guint index,
|
|
||||||
AtkObject *child)
|
|
||||||
{
|
|
||||||
if (!IS_MAI_OBJECT(child))
|
|
||||||
return;
|
|
||||||
|
|
||||||
static guint id = g_signal_lookup ("create", MAI_TYPE_ATK_OBJECT);
|
|
||||||
g_signal_emit (child, id, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
window_removed (AtkObject *atk_obj,
|
|
||||||
guint index,
|
|
||||||
AtkObject *child)
|
|
||||||
{
|
|
||||||
if (!IS_MAI_OBJECT(child))
|
|
||||||
return;
|
|
||||||
|
|
||||||
static guint id = g_signal_lookup ("destroy", MAI_TYPE_ATK_OBJECT);
|
|
||||||
g_signal_emit (child, id, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
UtilInterfaceInit(MaiUtilClass* klass)
|
|
||||||
{
|
|
||||||
AtkUtilClass *atk_class;
|
AtkUtilClass *atk_class;
|
||||||
gpointer data;
|
gpointer data;
|
||||||
|
|
||||||
@@ -365,8 +303,7 @@ UtilInterfaceInit(MaiUtilClass* klass)
|
|||||||
gail_remove_key_event_listener = atk_class->remove_key_event_listener;
|
gail_remove_key_event_listener = atk_class->remove_key_event_listener;
|
||||||
gail_get_root = atk_class->get_root;
|
gail_get_root = atk_class->get_root;
|
||||||
|
|
||||||
atk_class->add_global_event_listener =
|
atk_class->add_global_event_listener = mai_util_add_global_event_listener;
|
||||||
mai_util_add_global_event_listener;
|
|
||||||
atk_class->remove_global_event_listener =
|
atk_class->remove_global_event_listener =
|
||||||
mai_util_remove_global_event_listener;
|
mai_util_remove_global_event_listener;
|
||||||
atk_class->add_key_event_listener = mai_util_add_key_event_listener;
|
atk_class->add_key_event_listener = mai_util_add_key_event_listener;
|
||||||
@@ -378,15 +315,15 @@ UtilInterfaceInit(MaiUtilClass* klass)
|
|||||||
sListener_list = g_hash_table_new_full(g_int_hash, g_int_equal, nullptr,
|
sListener_list = g_hash_table_new_full(g_int_hash, g_int_equal, nullptr,
|
||||||
_listener_info_destroy);
|
_listener_info_destroy);
|
||||||
// Keep track of added/removed windows.
|
// Keep track of added/removed windows.
|
||||||
AtkObject *root = atk_get_root ();
|
AtkObject *root = atk_get_root();
|
||||||
g_signal_connect (root, "children-changed::add", (GCallback) window_added, nullptr);
|
g_signal_connect(root, "children-changed::add", (GCallback)window_added,
|
||||||
g_signal_connect (root, "children-changed::remove", (GCallback) window_removed, nullptr);
|
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) {
|
||||||
@@ -394,7 +331,7 @@ mai_util_get_type()
|
|||||||
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 */
|
||||||
@@ -403,9 +340,8 @@ mai_util_get_type()
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,4 +19,3 @@ typedef class XULTreeGridCellAccessible XULTreeGridCellAccessibleWrap;
|
|||||||
} // 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,25 +12,26 @@ 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;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -40,8 +41,7 @@ struct MaiAtkHyperlink
|
|||||||
MaiHyperlink *maiHyperlink;
|
MaiHyperlink *maiHyperlink;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MaiAtkHyperlinkClass
|
struct MaiAtkHyperlinkClass {
|
||||||
{
|
|
||||||
AtkHyperlinkClass parent_class;
|
AtkHyperlinkClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,71 +63,57 @@ 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);
|
NS_ENSURE_TRUE(MAI_IS_ATK_HYPERLINK(aHyperlink), nullptr);
|
||||||
MaiHyperlink * maiHyperlink =
|
MaiHyperlink *maiHyperlink = MAI_ATK_HYPERLINK(aHyperlink)->maiHyperlink;
|
||||||
MAI_ATK_HYPERLINK(aHyperlink)->maiHyperlink;
|
|
||||||
NS_ENSURE_TRUE(maiHyperlink != nullptr, nullptr);
|
NS_ENSURE_TRUE(maiHyperlink != nullptr, nullptr);
|
||||||
NS_ENSURE_TRUE(maiHyperlink->GetAtkHyperlink() == aHyperlink, nullptr);
|
NS_ENSURE_TRUE(maiHyperlink->GetAtkHyperlink() == aHyperlink, nullptr);
|
||||||
return maiHyperlink;
|
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 =
|
|
||||||
reinterpret_cast<AtkHyperlink *>
|
|
||||||
(g_object_new(mai_atk_hyperlink_get_type(), nullptr));
|
|
||||||
NS_ASSERTION(mMaiAtkHyperlink, "OUT OF MEMORY");
|
NS_ASSERTION(mMaiAtkHyperlink, "OUT OF MEMORY");
|
||||||
if (!mMaiAtkHyperlink)
|
if (!mMaiAtkHyperlink) return;
|
||||||
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);
|
||||||
@@ -142,33 +128,26 @@ classInitCB(AtkHyperlinkClass *aClass)
|
|||||||
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");
|
NS_ASSERTION(MAI_IS_ATK_HYPERLINK(aObj), "Invalid MaiAtkHyperlink");
|
||||||
if (!MAI_IS_ATK_HYPERLINK(aObj))
|
if (!MAI_IS_ATK_HYPERLINK(aObj)) return;
|
||||||
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;
|
||||||
|
|||||||
@@ -20,18 +20,15 @@ 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) {
|
||||||
@@ -44,7 +41,7 @@ public:
|
|||||||
|
|
||||||
ProxyAccessible* Proxy() const { return mHyperlink.AsProxy(); }
|
ProxyAccessible* Proxy() const { return mHyperlink.AsProxy(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AccessibleOrProxy mHyperlink;
|
AccessibleOrProxy mHyperlink;
|
||||||
AtkHyperlink* mMaiAtkHyperlink;
|
AtkHyperlink* mMaiAtkHyperlink;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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)) {
|
||||||
@@ -112,8 +100,8 @@ refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@@ -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,8 +138,7 @@ 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 =
|
||||||
@@ -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,12 +27,9 @@ 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");
|
NS_ASSERTION(aIface, "Invalid Interface");
|
||||||
if(MOZ_UNLIKELY(!aIface))
|
if (MOZ_UNLIKELY(!aIface)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't support get_document or set_attribute right now.
|
* We don't support get_document or set_attribute right now.
|
||||||
@@ -44,9 +41,7 @@ documentInterfaceInitCB(AtkDocumentIface *aIface)
|
|||||||
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,8 +32,7 @@ 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);
|
||||||
}
|
}
|
||||||
@@ -45,9 +41,7 @@ getLinkCB(AtkHypertext *aText, gint aLinkIndex)
|
|||||||
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()) {
|
||||||
@@ -64,12 +60,9 @@ getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
|
|||||||
|
|
||||||
} // 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,9 +186,7 @@ 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 =
|
||||||
@@ -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,9 +216,7 @@ 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 =
|
||||||
@@ -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,9 +240,7 @@ 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;
|
||||||
@@ -283,8 +253,7 @@ getSelectedColumnsCB(AtkTable *aTable, gint** aSelected)
|
|||||||
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,8 +68,7 @@ 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();
|
||||||
@@ -102,9 +95,7 @@ GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
|
|||||||
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;
|
||||||
@@ -69,28 +67,24 @@ ConvertTextAttributeToAtkAttribute(const nsACString& aName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,20 +130,18 @@ 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,
|
||||||
@@ -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,11 +178,9 @@ 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);
|
||||||
}
|
}
|
||||||
@@ -203,10 +190,10 @@ getTextAfterOffsetCB(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->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;
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,7 +81,7 @@ getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(minimumIncrement, 0, sizeof (GValue));
|
memset(minimumIncrement, 0, sizeof(GValue));
|
||||||
double accValue = accWrap ? accWrap->Step() : proxy->Step();
|
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
|
||||||
@@ -101,9 +90,7 @@ getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
|
|||||||
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;
|
||||||
|
|||||||
@@ -52,9 +52,11 @@ 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
|
||||||
|
gAtkStateMap[] =
|
||||||
|
{
|
||||||
|
// Cross Platform States
|
||||||
// clang-format off
|
// 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
|
||||||
@@ -110,5 +112,6 @@ static const AtkStateMap gAtkStateMap[] = { // Cross Platfor
|
|||||||
|
|
||||||
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,8 +35,7 @@ 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,
|
||||||
@@ -1245,26 +1244,12 @@ static const nsRoleMapEntry sWAIRoleMaps[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
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,25 +1257,19 @@ 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,
|
|
||||||
eARIADisabled,
|
|
||||||
eARIAExpanded, // Currently under spec review but precedent exists
|
eARIAExpanded, // Currently under spec review but precedent exists
|
||||||
eARIAHasPopup, // Note this is a tokenised attribute starting in ARIA 1.1
|
eARIAHasPopup, // Note this is a tokenised attribute starting in ARIA 1.1
|
||||||
eARIAInvalid,
|
eARIAInvalid, eARIAModal,
|
||||||
eARIAModal,
|
|
||||||
eARIARequired, // XXX not global, Bug 553117
|
eARIARequired, // XXX not global, Bug 553117
|
||||||
eARIANone
|
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;
|
||||||
};
|
};
|
||||||
@@ -1340,8 +1319,7 @@ static const AttrCharacteristics gWAIUnivAttrMap[] = {
|
|||||||
|
|
||||||
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,9 +1370,7 @@ 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) {
|
||||||
@@ -1413,20 +1382,15 @@ aria::GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMapEntry)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,9 +1398,7 @@ 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,
|
||||||
@@ -1446,9 +1408,7 @@ aria::HasDefinedARIAHidden(nsIContent* aContent)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// 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++;
|
||||||
@@ -1467,8 +1427,8 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
|
|||||||
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'.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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;
|
||||||
@@ -192,7 +181,6 @@ struct nsRoleMapEntry
|
|||||||
mozilla::a11y::aria::EStateRule attributeMap4;
|
mozilla::a11y::aria::EStateRule attributeMap4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ARIA map
|
// ARIA map
|
||||||
|
|
||||||
@@ -282,26 +270,23 @@ 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;
|
||||||
|
|||||||
@@ -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,8 +32,7 @@ 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
|
||||||
@@ -44,15 +42,14 @@ enum ETokenType
|
|||||||
* 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::SUPPORTS_AUTOCOMPLETION,
|
|
||||||
states::HASPOPUP | 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(
|
|
||||||
nsGkAtoms::aria_checked, eMixedType,
|
|
||||||
states::CHECKABLE, states::CHECKED);
|
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(
|
|
||||||
nsGkAtoms::aria_selected, eBoolType,
|
|
||||||
states::SELECTABLE, states::SELECTED);
|
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,10 +311,8 @@ 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)) {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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,68 +74,61 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AccEvent, Release)
|
|||||||
// we are ready to fire the event and so we will no longer assert at that point
|
// 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);
|
||||||
@@ -146,13 +138,14 @@ AccTextSelChangeEvent::IsCaretMoveOnly() const
|
|||||||
// 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), mNewAccessible(aNewAccessible),
|
mOldAccessible(aOldAccessible),
|
||||||
mOldStart(aOldStart), mNewStart(aNewStart),
|
mNewAccessible(aNewAccessible),
|
||||||
mOldEnd(aOldEnd), mNewEnd(aNewEnd),
|
mOldStart(aOldStart),
|
||||||
mReason(aReason), mBoundaryType(aBoundaryType)
|
mNewStart(aNewStart),
|
||||||
{
|
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 {
|
||||||
@@ -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) :
|
|
||||||
AccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
|
|
||||||
aIsFromUserInput, eCoalesceStateChange),
|
aIsFromUserInput, eCoalesceStateChange),
|
||||||
mState(aState), 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
|
||||||
|
// inserted/deleted.
|
||||||
uint32_t mNumRowsOrCols; // the number of inserted/deleted rows/columns
|
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,29 +547,27 @@ 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
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -174,8 +157,7 @@ HTMLLabelIterator::Next()
|
|||||||
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,55 +220,42 @@ 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()) {
|
||||||
@@ -312,8 +263,7 @@ IDRefsIterator::GetElem(const nsDependentSubstring& aID)
|
|||||||
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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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( \
|
||||||
|
static_cast<uint32_t>(roles::geckoRole) == \
|
||||||
|
static_cast<uint32_t>(nsIAccessibleRole::ROLE_##geckoRole), \
|
||||||
"internal and xpcom roles differ!");
|
"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) == \
|
||||||
|
static_cast<uint32_t>(nsIAccessibleRelation::RELATION_##geckoType), \
|
||||||
"internal and xpcom relations differ!");
|
"internal and xpcom relations differ!");
|
||||||
#include "RelationTypeMap.h"
|
#include "RelationTypeMap.h"
|
||||||
#undef RELATIONTYPE
|
#undef RELATIONTYPE
|
||||||
|
|||||||
@@ -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());
|
||||||
@@ -584,9 +522,7 @@ DocManager::ClearDocCache()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -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,8 +100,8 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -113,9 +110,9 @@ public:
|
|||||||
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,11 +164,12 @@ private:
|
|||||||
DocAccessibleHashtable;
|
DocAccessibleHashtable;
|
||||||
DocAccessibleHashtable mDocAccessibleCache;
|
DocAccessibleHashtable mDocAccessibleCache;
|
||||||
|
|
||||||
typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>, xpcAccessibleDocument>
|
typedef nsRefPtrHashtable<nsPtrHashKey<const DocAccessible>,
|
||||||
|
xpcAccessibleDocument>
|
||||||
XPCDocumentHashtable;
|
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,9 +182,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,62 +8,46 @@
|
|||||||
|
|
||||||
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)
|
||||||
@@ -72,9 +56,7 @@ EmbeddedObjCollector::GetIndexAt(Accessible* aAccessible)
|
|||||||
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.
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -81,27 +76,24 @@ 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,
|
||||||
|
"only reorder events should be queued");
|
||||||
break; // case eCoalesceReorder
|
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];
|
||||||
@@ -114,18 +106,17 @@ EventQueue::CoalesceEvents()
|
|||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,8 +124,7 @@ EventQueue::CoalesceEvents()
|
|||||||
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).
|
||||||
@@ -155,8 +145,7 @@ 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,13 +160,11 @@ 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--) {
|
||||||
@@ -197,11 +184,9 @@ EventQueue::CoalesceEvents()
|
|||||||
} // 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,30 +291,34 @@ 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 ==
|
||||||
|
AccSelChangeEvent::eSelectionAdd),
|
||||||
selChangeEvent->mPackedEvent->mIsFromUserInput);
|
selChangeEvent->mPackedEvent->mIsFromUserInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,7 +326,6 @@ EventQueue::ProcessEventQueue()
|
|||||||
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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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),
|
||||||
|
mStartIdx(UINT32_MAX),
|
||||||
mStateFlagsCopy(mParent->mStateFlags),
|
mStateFlagsCopy(mParent->mStateFlags),
|
||||||
mQueueEvents(!aNoEvents)
|
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,16 +88,15 @@ 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(
|
||||||
|
mParent->mChildren[idx]->mIndexInParent == static_cast<int32_t>(idx),
|
||||||
"Wrong index detected");
|
"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) {
|
||||||
@@ -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,7 +483,8 @@ 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)
|
||||||
|
->StorePrecedingEvents(
|
||||||
std::move(childShowEv->mPrecedingEvents));
|
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++) {
|
||||||
|
logging::AccessibleInfo(
|
||||||
|
"Adoptee",
|
||||||
showChildEv->mPrecedingEvents[i]->mAccessible);
|
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,13 +115,13 @@ 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 a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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) {
|
||||||
@@ -64,41 +55,35 @@ FocusManager::IsFocused(const Accessible* aAccessible) const
|
|||||||
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);
|
||||||
@@ -134,15 +116,13 @@ FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
|
|||||||
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,41 +196,34 @@ 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);
|
||||||
@@ -263,21 +231,19 @@ FocusManager::ProcessDOMFocus(nsINode* aTarget)
|
|||||||
|
|
||||||
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;
|
||||||
@@ -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,9 +376,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,19 +107,19 @@ 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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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,9 +129,7 @@ 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) {
|
||||||
@@ -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(
|
||||||
|
"\nSelection changed, selection type: %s, notification %s, reason: %d\n",
|
||||||
strType, (isIgnored ? "ignored" : "pending"), aReason);
|
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,9 +842,7 @@ 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());
|
||||||
|
|
||||||
@@ -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"));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,4 +228,3 @@ void CheckEnv();
|
|||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -5,178 +5,125 @@
|
|||||||
* 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 details
|
// Only some roles truly enjoy life as HTMLLinkAccessibles, for
|
||||||
// see closed bug 494807.
|
// details 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, aContext->Document());
|
return new HyperTextAccessibleWrap(aElement,
|
||||||
|
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,
|
|
||||||
0)
|
|
||||||
|
|
||||||
MARKUPMAP(acronym,
|
MARKUPMAP(acronym, New_HyperText, 0)
|
||||||
New_HyperText,
|
|
||||||
0)
|
|
||||||
|
|
||||||
MARKUPMAP(article,
|
MARKUPMAP(article, New_HyperText, roles::ARTICLE, Attr(xmlroles, article))
|
||||||
New_HyperText,
|
|
||||||
roles::ARTICLE,
|
|
||||||
Attr(xmlroles, article))
|
|
||||||
|
|
||||||
MARKUPMAP(aside,
|
MARKUPMAP(aside, New_HyperText, roles::LANDMARK)
|
||||||
New_HyperText,
|
|
||||||
roles::LANDMARK)
|
|
||||||
|
|
||||||
MARKUPMAP(blockquote,
|
MARKUPMAP(blockquote, New_HyperText, roles::BLOCKQUOTE)
|
||||||
New_HyperText,
|
|
||||||
roles::BLOCKQUOTE)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(button,
|
||||||
button,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLButtonAccessible(aElement, aContext->Document());
|
return new HTMLButtonAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(caption,
|
||||||
caption,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
if (aContext->IsTable()) {
|
if (aContext->IsTable()) {
|
||||||
dom::HTMLTableElement* tableEl =
|
dom::HTMLTableElement* tableEl =
|
||||||
dom::HTMLTableElement::FromNode(aContext->GetContent());
|
dom::HTMLTableElement::FromNode(aContext->GetContent());
|
||||||
if (tableEl && tableEl == aElement->GetParent() &&
|
if (tableEl && tableEl == aElement->GetParent() &&
|
||||||
tableEl->GetCaption() == aElement) {
|
tableEl->GetCaption() == aElement) {
|
||||||
return new HTMLCaptionAccessible(aElement, aContext->Document());
|
return new HTMLCaptionAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(dd,
|
MARKUPMAP(dd, New_HTMLDtOrDd<HyperTextAccessibleWrap>, roles::DEFINITION)
|
||||||
New_HTMLDtOrDd<HyperTextAccessibleWrap>,
|
|
||||||
roles::DEFINITION)
|
|
||||||
|
|
||||||
MARKUPMAP(del,
|
MARKUPMAP(del, New_HyperText, roles::CONTENT_DELETION)
|
||||||
New_HyperText,
|
|
||||||
roles::CONTENT_DELETION)
|
|
||||||
|
|
||||||
MARKUPMAP(details,
|
MARKUPMAP(details, New_HyperText, roles::DETAILS)
|
||||||
New_HyperText,
|
|
||||||
roles::DETAILS)
|
|
||||||
|
|
||||||
MARKUPMAP(div,
|
MARKUPMAP(div, nullptr, roles::SECTION)
|
||||||
nullptr,
|
|
||||||
roles::SECTION)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(dl,
|
||||||
dl,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLListAccessible(aElement, aContext->Document());
|
return new HTMLListAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::DEFINITION_LIST
|
roles::DEFINITION_LIST)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(dt,
|
MARKUPMAP(dt, New_HTMLDtOrDd<HTMLLIAccessible>, roles::TERM)
|
||||||
New_HTMLDtOrDd<HTMLLIAccessible>,
|
|
||||||
roles::TERM)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(figcaption,
|
||||||
figcaption,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
|
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::CAPTION
|
roles::CAPTION)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(figure,
|
||||||
figure,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLFigureAccessible(aElement, aContext->Document());
|
return new HTMLFigureAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::FIGURE,
|
roles::FIGURE, Attr(xmlroles, figure))
|
||||||
Attr(xmlroles, figure)
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(fieldset,
|
||||||
fieldset,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLGroupboxAccessible(aElement, aContext->Document());
|
return new HTMLGroupboxAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(form,
|
||||||
form,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLFormAccessible(aElement, aContext->Document());
|
return new HTMLFormAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(footer,
|
||||||
footer,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
|
return new HTMLHeaderOrFooterAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(header,
|
||||||
header,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
|
return new HTMLHeaderOrFooterAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(h1,
|
MARKUPMAP(h1, New_HyperText, roles::HEADING)
|
||||||
New_HyperText,
|
|
||||||
roles::HEADING)
|
|
||||||
|
|
||||||
MARKUPMAP(h2,
|
MARKUPMAP(h2, New_HyperText, roles::HEADING)
|
||||||
New_HyperText,
|
|
||||||
roles::HEADING)
|
|
||||||
|
|
||||||
MARKUPMAP(h3,
|
MARKUPMAP(h3, New_HyperText, roles::HEADING)
|
||||||
New_HyperText,
|
|
||||||
roles::HEADING)
|
|
||||||
|
|
||||||
MARKUPMAP(h4,
|
MARKUPMAP(h4, New_HyperText, roles::HEADING)
|
||||||
New_HyperText,
|
|
||||||
roles::HEADING)
|
|
||||||
|
|
||||||
MARKUPMAP(h5,
|
MARKUPMAP(h5, New_HyperText, roles::HEADING)
|
||||||
New_HyperText,
|
|
||||||
roles::HEADING)
|
|
||||||
|
|
||||||
MARKUPMAP(h6,
|
MARKUPMAP(h6, New_HyperText, roles::HEADING)
|
||||||
New_HyperText,
|
|
||||||
roles::HEADING)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(hr,
|
||||||
hr,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLHRAccessible(aElement, aContext->Document());
|
return new HTMLHRAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(input,
|
||||||
input,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||||
nsGkAtoms::checkbox, eIgnoreCase)) {
|
nsGkAtoms::checkbox, eIgnoreCase)) {
|
||||||
@@ -184,379 +131,272 @@ MARKUPMAP(
|
|||||||
}
|
}
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||||
nsGkAtoms::radio, eIgnoreCase)) {
|
nsGkAtoms::radio, eIgnoreCase)) {
|
||||||
return new HTMLRadioButtonAccessible(aElement, aContext->Document());
|
return new HTMLRadioButtonAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
}
|
}
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||||
nsGkAtoms::time, eIgnoreCase)) {
|
nsGkAtoms::time, eIgnoreCase)) {
|
||||||
return new EnumRoleAccessible<roles::GROUPING>(aElement, aContext->Document());
|
return new EnumRoleAccessible<roles::GROUPING>(
|
||||||
|
aElement, aContext->Document());
|
||||||
}
|
}
|
||||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||||
nsGkAtoms::date, eIgnoreCase)) {
|
nsGkAtoms::date, eIgnoreCase)) {
|
||||||
return new EnumRoleAccessible<roles::DATE_EDITOR>(aElement, aContext->Document());
|
return new EnumRoleAccessible<roles::DATE_EDITOR>(
|
||||||
|
aElement, aContext->Document());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(ins,
|
MARKUPMAP(ins, New_HyperText, roles::CONTENT_INSERTION)
|
||||||
New_HyperText,
|
|
||||||
roles::CONTENT_INSERTION)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(label,
|
||||||
label,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLLabelAccessible(aElement, aContext->Document());
|
return new HTMLLabelAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::LABEL
|
roles::LABEL)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(legend,
|
||||||
legend,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLLegendAccessible(aElement, aContext->Document());
|
return new HTMLLegendAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::LABEL
|
roles::LABEL)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(li,
|
||||||
li,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
// If list item is a child of accessible list then create an accessible for
|
// If list item is a child of accessible list then create an
|
||||||
// it unconditionally by tag name. nsBlockFrame creates the list item
|
// accessible for it unconditionally by tag name. nsBlockFrame
|
||||||
// accessible for other elements styled as list items.
|
// creates the list item accessible for other elements styled as
|
||||||
if (aContext->IsList() && aContext->GetContent() == aElement->GetParent()) {
|
// list items.
|
||||||
|
if (aContext->IsList() &&
|
||||||
|
aContext->GetContent() == aElement->GetParent()) {
|
||||||
return new HTMLLIAccessible(aElement, aContext->Document());
|
return new HTMLLIAccessible(aElement, aContext->Document());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(main,
|
MARKUPMAP(main, New_HyperText, roles::LANDMARK)
|
||||||
New_HyperText,
|
|
||||||
roles::LANDMARK)
|
|
||||||
|
|
||||||
MARKUPMAP(map,
|
MARKUPMAP(map, nullptr, roles::TEXT_CONTAINER)
|
||||||
nullptr,
|
|
||||||
roles::TEXT_CONTAINER)
|
|
||||||
|
|
||||||
MARKUPMAP(math,
|
MARKUPMAP(math, New_HyperText, roles::MATHML_MATH)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_MATH)
|
|
||||||
|
|
||||||
MARKUPMAP(mi_,
|
MARKUPMAP(mi_, New_HyperText, roles::MATHML_IDENTIFIER)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_IDENTIFIER)
|
|
||||||
|
|
||||||
MARKUPMAP(mn_,
|
MARKUPMAP(mn_, New_HyperText, roles::MATHML_NUMBER)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_NUMBER)
|
|
||||||
|
|
||||||
MARKUPMAP(mo_,
|
MARKUPMAP(mo_, New_HyperText, roles::MATHML_OPERATOR,
|
||||||
New_HyperText,
|
AttrFromDOM(accent_, accent_), AttrFromDOM(fence_, fence_),
|
||||||
roles::MATHML_OPERATOR,
|
AttrFromDOM(separator_, separator_), AttrFromDOM(largeop_, largeop_))
|
||||||
AttrFromDOM(accent_, accent_),
|
|
||||||
AttrFromDOM(fence_, fence_),
|
|
||||||
AttrFromDOM(separator_, separator_),
|
|
||||||
AttrFromDOM(largeop_, largeop_))
|
|
||||||
|
|
||||||
MARKUPMAP(mtext_,
|
MARKUPMAP(mtext_, New_HyperText, roles::MATHML_TEXT)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_TEXT)
|
|
||||||
|
|
||||||
MARKUPMAP(ms_,
|
MARKUPMAP(ms_, New_HyperText, roles::MATHML_STRING_LITERAL)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_STRING_LITERAL)
|
|
||||||
|
|
||||||
MARKUPMAP(mglyph_,
|
MARKUPMAP(mglyph_, New_HyperText, roles::MATHML_GLYPH)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_GLYPH)
|
|
||||||
|
|
||||||
MARKUPMAP(mrow_,
|
MARKUPMAP(mrow_, New_HyperText, roles::MATHML_ROW)
|
||||||
New_HyperText,
|
|
||||||
roles::MATHML_ROW)
|
|
||||||
|
|
||||||
MARKUPMAP(mfrac_,
|
MARKUPMAP(mfrac_, New_HyperText, roles::MATHML_FRACTION,
|
||||||
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,
|
|
||||||
roles::MATHML_MULTISCRIPTS)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
|
||||||
mtable_,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLTableAccessible(aElement, aContext->Document());
|
return new HTMLTableAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::MATHML_TABLE,
|
roles::MATHML_TABLE, AttrFromDOM(align, align),
|
||||||
AttrFromDOM(align, align),
|
|
||||||
AttrFromDOM(columnlines_, columnlines_),
|
AttrFromDOM(columnlines_, columnlines_),
|
||||||
AttrFromDOM(rowlines_, rowlines_)
|
AttrFromDOM(rowlines_, rowlines_))
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(mlabeledtr_,
|
||||||
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_LABELED_ROW
|
roles::MATHML_LABELED_ROW)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(mtr_,
|
||||||
mtr_,
|
|
||||||
[](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_TABLE_ROW)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(mtd_,
|
||||||
mtd_,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLTableCellAccessible(aElement, aContext->Document());
|
return new HTMLTableCellAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::MATHML_CELL
|
roles::MATHML_CELL)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(maction_,
|
MARKUPMAP(maction_, New_HyperText, roles::MATHML_ACTION,
|
||||||
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, aContext->Document());
|
return new HTMLSelectOptionAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(optgroup,
|
||||||
optgroup,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLSelectOptGroupAccessible(aElement, aContext->Document());
|
return new HTMLSelectOptGroupAccessible(aElement,
|
||||||
|
aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(output,
|
||||||
output,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLOutputAccessible(aElement, aContext->Document());
|
return new HTMLOutputAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::SECTION,
|
roles::SECTION, Attr(live, polite))
|
||||||
Attr(live, polite)
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(p,
|
MARKUPMAP(p, nullptr, roles::PARAGRAPH)
|
||||||
nullptr,
|
|
||||||
roles::PARAGRAPH)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(progress,
|
||||||
progress,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLProgressAccessible(aElement, aContext->Document());
|
return new HTMLProgressAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(q,
|
|
||||||
New_HyperText,
|
|
||||||
0)
|
0)
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(q, New_HyperText, 0)
|
||||||
section,
|
|
||||||
|
MARKUPMAP(section,
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLSectionAccessible(aElement, aContext->Document());
|
return new HTMLSectionAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(summary,
|
||||||
summary,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
return new HTMLSummaryAccessible(aElement, aContext->Document());
|
return new HTMLSummaryAccessible(aElement, aContext->Document());
|
||||||
},
|
},
|
||||||
roles::SUMMARY
|
roles::SUMMARY)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(table,
|
||||||
table,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
if (aElement->GetPrimaryFrame() &&
|
if (aElement->GetPrimaryFrame() &&
|
||||||
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableType) {
|
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||||
|
eHTMLTableType) {
|
||||||
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
|
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(time,
|
MARKUPMAP(time, New_HyperText, 0, Attr(xmlroles, 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() && aContext->GetContent() == aElement->GetParent()) {
|
if (aContext->IsTableRow() &&
|
||||||
|
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,
|
||||||
|
aContext->Document());
|
||||||
}
|
}
|
||||||
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
|
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
|
||||||
return new HTMLTableHeaderCellAccessibleWrap(aElement, aContext->Document());
|
return new HTMLTableHeaderCellAccessibleWrap(
|
||||||
|
aElement, aContext->Document());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
MARKUPMAP(
|
MARKUPMAP(th,
|
||||||
th,
|
|
||||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||||
if (aContext->IsTableRow() && aContext->GetContent() == aElement->GetParent()) {
|
if (aContext->IsTableRow() &&
|
||||||
|
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(
|
||||||
|
aElement, aContext->Document());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
0
|
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 native
|
// accessible, because there's no underlying table layout and thus
|
||||||
// HTML table row class doesn't work. Refer to
|
// native 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()) {
|
||||||
@@ -571,20 +411,18 @@ MARKUPMAP(
|
|||||||
if (table->GetContent() == parentContent &&
|
if (table->GetContent() == parentContent &&
|
||||||
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
|
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
|
||||||
(aElement->GetPrimaryFrame() &&
|
(aElement->GetPrimaryFrame() &&
|
||||||
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableRowType))) {
|
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||||
|
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();
|
||||||
@@ -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(
|
||||||
|
mDocument,
|
||||||
"The document was shut down while refresh observer is attached!");
|
"The document was shut down while refresh observer is attached!");
|
||||||
if (!mDocument)
|
if (!mDocument) return;
|
||||||
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(
|
||||||
|
"old text '%s'",
|
||||||
NS_ConvertUTF16toUTF8(textAcc->AsTextLeaf()->Text()).get());
|
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,14 +737,15 @@ 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!");
|
||||||
@@ -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();
|
||||||
}
|
}
|
||||||
@@ -135,9 +129,8 @@ public:
|
|||||||
|
|
||||||
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!");
|
||||||
@@ -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);
|
||||||
@@ -248,21 +240,19 @@ 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)) {
|
||||||
@@ -271,11 +261,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#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,34 +338,32 @@ 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 };
|
||||||
|
|
||||||
@@ -388,18 +374,18 @@ private:
|
|||||||
/**
|
/**
|
||||||
* 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,
|
||||||
|
|||||||
@@ -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,8 +124,7 @@ 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
|
||||||
|
|||||||
@@ -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,40 +58,34 @@ 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;
|
||||||
@@ -105,4 +96,3 @@ private:
|
|||||||
} // 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
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|
||||||
@@ -1047,7 +1048,7 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -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,34 +104,28 @@ 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(
|
||||||
|
caretCntr,
|
||||||
"No text container for focus while there's one for common ancestor?!");
|
"No text container for focus while there's one for common ancestor?!");
|
||||||
if (!caretCntr)
|
if (!caretCntr) return;
|
||||||
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());
|
||||||
@@ -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!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +197,7 @@ SelectionManager::ProcessSelectionChanged(SelData* aSelData)
|
|||||||
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace mozilla {
|
|||||||
namespace dom {
|
namespace dom {
|
||||||
class Element;
|
class Element;
|
||||||
class Selection;
|
class Selection;
|
||||||
}
|
} // namespace dom
|
||||||
|
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
@@ -43,9 +43,8 @@ class HyperTextAccessible;
|
|||||||
|
|
||||||
struct SelData;
|
struct SelData;
|
||||||
|
|
||||||
class SelectionManager : public nsISelectionListener
|
class SelectionManager : public nsISelectionListener {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
// nsISupports
|
// nsISupports
|
||||||
// implemented by derived nsAccessibilityService
|
// implemented by derived nsAccessibilityService
|
||||||
|
|
||||||
@@ -89,10 +88,8 @@ public:
|
|||||||
* current pair, then returns -1 for the offset and a nullptr for the
|
* current pair, then returns -1 for the offset and a nullptr for the
|
||||||
* accessible.
|
* accessible.
|
||||||
*/
|
*/
|
||||||
inline HyperTextAccessible* AccessibleWithCaret(int32_t* aCaret)
|
inline HyperTextAccessible* AccessibleWithCaret(int32_t* aCaret) {
|
||||||
{
|
if (aCaret) *aCaret = mCaretOffset;
|
||||||
if (aCaret)
|
|
||||||
*aCaret = mCaretOffset;
|
|
||||||
|
|
||||||
return mAccWithCaret;
|
return mAccWithCaret;
|
||||||
}
|
}
|
||||||
@@ -100,20 +97,17 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Update caret offset when it doesn't go through a caret move event.
|
* Update caret offset when it doesn't go through a caret move event.
|
||||||
*/
|
*/
|
||||||
inline void UpdateCaretOffset(HyperTextAccessible* aItem, int32_t aOffset)
|
inline void UpdateCaretOffset(HyperTextAccessible* aItem, int32_t aOffset) {
|
||||||
{
|
|
||||||
mAccWithCaret = aItem;
|
mAccWithCaret = aItem;
|
||||||
mCaretOffset = aOffset;
|
mCaretOffset = aOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ResetCaretOffset()
|
inline void ResetCaretOffset() {
|
||||||
{
|
|
||||||
mCaretOffset = -1;
|
mCaretOffset = -1;
|
||||||
mAccWithCaret = nullptr;
|
mAccWithCaret = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SelectionManager();
|
SelectionManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,7 +115,7 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void ProcessSelectionChanged(SelData* aSelData);
|
void ProcessSelectionChanged(SelData* aSelData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Currently focused control.
|
// Currently focused control.
|
||||||
int32_t mCaretOffset;
|
int32_t mCaretOffset;
|
||||||
HyperTextAccessible* mAccWithCaret;
|
HyperTextAccessible* mAccWithCaret;
|
||||||
|
|||||||
@@ -13,284 +13,285 @@ namespace mozilla {
|
|||||||
namespace a11y {
|
namespace a11y {
|
||||||
namespace states {
|
namespace states {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is disabled, opposite to enabled and sensitive.
|
* The object is disabled, opposite to enabled and sensitive.
|
||||||
*/
|
*/
|
||||||
const uint64_t UNAVAILABLE = ((uint64_t) 0x1) << 0;
|
const uint64_t UNAVAILABLE = ((uint64_t)0x1) << 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is selected.
|
* The object is selected.
|
||||||
*/
|
*/
|
||||||
const uint64_t SELECTED = ((uint64_t) 0x1) << 1;
|
const uint64_t SELECTED = ((uint64_t)0x1) << 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object has the keyboard focus.
|
* The object has the keyboard focus.
|
||||||
*/
|
*/
|
||||||
const uint64_t FOCUSED = ((uint64_t) 0x1) << 2;
|
const uint64_t FOCUSED = ((uint64_t)0x1) << 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is pressed.
|
* The object is pressed.
|
||||||
*/
|
*/
|
||||||
const uint64_t PRESSED = ((uint64_t) 0x1) << 3;
|
const uint64_t PRESSED = ((uint64_t)0x1) << 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The checkable object is checked, applied to check box controls,
|
* The checkable object is checked, applied to check box controls,
|
||||||
* @see CHECKABLE and MIXED states.
|
* @see CHECKABLE and MIXED states.
|
||||||
*/
|
*/
|
||||||
const uint64_t CHECKED = ((uint64_t) 0x1) << 4;
|
const uint64_t CHECKED = ((uint64_t)0x1) << 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that the state of a three-state check box or tool bar button is
|
* Indicates that the state of a three-state check box or tool bar button is
|
||||||
* undetermined. The check box is neither checked or unchecked, and is
|
* undetermined. The check box is neither checked or unchecked, and is
|
||||||
* in the third or mixed state.
|
* in the third or mixed state.
|
||||||
*/
|
*/
|
||||||
const uint64_t MIXED = ((uint64_t) 0x1) << 5;
|
const uint64_t MIXED = ((uint64_t)0x1) << 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is designated read-only, so it can't be edited.
|
* The object is designated read-only, so it can't be edited.
|
||||||
*/
|
*/
|
||||||
const uint64_t READONLY = ((uint64_t) 0x1) << 6;
|
const uint64_t READONLY = ((uint64_t)0x1) << 6;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is hot-tracked by the mouse, which means that its appearance
|
* The object is hot-tracked by the mouse, which means that its appearance
|
||||||
* has changed to indicate that the mouse pointer is located over it.
|
* has changed to indicate that the mouse pointer is located over it.
|
||||||
*
|
*
|
||||||
* This is currently unused.
|
* This is currently unused.
|
||||||
*/
|
*/
|
||||||
const uint64_t HOTTRACKED = ((uint64_t) 0x1) << 7;
|
const uint64_t HOTTRACKED = ((uint64_t)0x1) << 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object is the default button in a window.
|
* This object is the default button in a window.
|
||||||
*/
|
*/
|
||||||
const uint64_t DEFAULT = ((uint64_t) 0x1) << 8;
|
const uint64_t DEFAULT = ((uint64_t)0x1) << 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The expandable object's children are displayed, the opposite of collapsed,
|
* The expandable object's children are displayed, the opposite of collapsed,
|
||||||
* applied to trees, list and other controls.
|
* applied to trees, list and other controls.
|
||||||
* @see COLLAPSED state
|
* @see COLLAPSED state
|
||||||
*/
|
*/
|
||||||
const uint64_t EXPANDED = ((uint64_t) 0x1) << 9;
|
const uint64_t EXPANDED = ((uint64_t)0x1) << 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The expandable object's children are not displayed, the opposite of
|
* The expandable object's children are not displayed, the opposite of
|
||||||
* expanded, applied to tree lists and other controls,
|
* expanded, applied to tree lists and other controls,
|
||||||
* @see EXPANDED state.
|
* @see EXPANDED state.
|
||||||
*/
|
*/
|
||||||
const uint64_t COLLAPSED = ((uint64_t) 0x1) << 10;
|
const uint64_t COLLAPSED = ((uint64_t)0x1) << 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The control or document can not accept input at this time.
|
* The control or document can not accept input at this time.
|
||||||
*/
|
*/
|
||||||
const uint64_t BUSY = ((uint64_t) 0x1) << 11;
|
const uint64_t BUSY = ((uint64_t)0x1) << 11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is out of normal flow, may be outside of boundaries of its
|
* The object is out of normal flow, may be outside of boundaries of its
|
||||||
* parent.
|
* parent.
|
||||||
*/
|
*/
|
||||||
const uint64_t FLOATING = ((uint64_t) 0x1) << 12;
|
const uint64_t FLOATING = ((uint64_t)0x1) << 12;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object can be checked.
|
* The object can be checked.
|
||||||
*/
|
*/
|
||||||
const uint64_t CHECKABLE = ((uint64_t) 0x1) << 13;
|
const uint64_t CHECKABLE = ((uint64_t)0x1) << 13;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object is a graphic which is rapidly changing appearance.
|
* This object is a graphic which is rapidly changing appearance.
|
||||||
*/
|
*/
|
||||||
const uint64_t ANIMATED = ((uint64_t) 0x1) << 14;
|
const uint64_t ANIMATED = ((uint64_t)0x1) << 14;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is programmatically hidden.
|
* The object is programmatically hidden.
|
||||||
* So user action like scrolling or switching tabs won't make this visible.
|
* So user action like scrolling or switching tabs won't make this visible.
|
||||||
*/
|
*/
|
||||||
const uint64_t INVISIBLE = ((uint64_t) 0x1) << 15;
|
const uint64_t INVISIBLE = ((uint64_t)0x1) << 15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is scrolled off screen.
|
* The object is scrolled off screen.
|
||||||
* User action such as scrolling or changing tab may make the object
|
* User action such as scrolling or changing tab may make the object
|
||||||
* visible.
|
* visible.
|
||||||
*/
|
*/
|
||||||
const uint64_t OFFSCREEN = ((uint64_t) 0x1) << 16;
|
const uint64_t OFFSCREEN = ((uint64_t)0x1) << 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object can be resized.
|
* The object can be resized.
|
||||||
*/
|
*/
|
||||||
const uint64_t SIZEABLE = ((uint64_t) 0x1) << 17;
|
const uint64_t SIZEABLE = ((uint64_t)0x1) << 17;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object can be moved to a different position.
|
* The object can be moved to a different position.
|
||||||
*/
|
*/
|
||||||
const uint64_t MOVEABLE = ((uint64_t) 0x1) << 18;
|
const uint64_t MOVEABLE = ((uint64_t)0x1) << 18;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object describes itself with speech.
|
* The object describes itself with speech.
|
||||||
* Other speech related assistive technology may want to avoid speaking
|
* Other speech related assistive technology may want to avoid speaking
|
||||||
* information about this object, because the object is already doing this.
|
* information about this object, because the object is already doing this.
|
||||||
*/
|
*/
|
||||||
const uint64_t SELFVOICING = ((uint64_t) 0x1) << 19;
|
const uint64_t SELFVOICING = ((uint64_t)0x1) << 19;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object can have the focus and become focused.
|
* The object can have the focus and become focused.
|
||||||
*/
|
*/
|
||||||
const uint64_t FOCUSABLE = ((uint64_t) 0x1) << 20;
|
const uint64_t FOCUSABLE = ((uint64_t)0x1) << 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object can be selected.
|
* The object can be selected.
|
||||||
*/
|
*/
|
||||||
const uint64_t SELECTABLE = ((uint64_t) 0x1) << 21;
|
const uint64_t SELECTABLE = ((uint64_t)0x1) << 21;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object is a link.
|
* This object is a link.
|
||||||
*/
|
*/
|
||||||
const uint64_t LINKED = ((uint64_t) 0x1) << 22;
|
const uint64_t LINKED = ((uint64_t)0x1) << 22;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used for links that have been traversed
|
* This is used for links that have been traversed
|
||||||
* i.e. the linked page has been visited.
|
* i.e. the linked page has been visited.
|
||||||
*/
|
*/
|
||||||
const uint64_t TRAVERSED = ((uint64_t) 0x1) << 23;
|
const uint64_t TRAVERSED = ((uint64_t)0x1) << 23;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports multiple selection.
|
* Supports multiple selection.
|
||||||
*/
|
*/
|
||||||
const uint64_t MULTISELECTABLE = ((uint64_t) 0x1) << 24;
|
const uint64_t MULTISELECTABLE = ((uint64_t)0x1) << 24;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports extended selection.
|
* Supports extended selection.
|
||||||
* All objects supporting this are also multipselectable.
|
* All objects supporting this are also multipselectable.
|
||||||
* This only makes sense for msaa see bug 635690.
|
* This only makes sense for msaa see bug 635690.
|
||||||
*/
|
*/
|
||||||
const uint64_t EXTSELECTABLE = ((uint64_t) 0x1) << 25;
|
const uint64_t EXTSELECTABLE = ((uint64_t)0x1) << 25;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user is required to interact with this object.
|
* The user is required to interact with this object.
|
||||||
*/
|
*/
|
||||||
const uint64_t REQUIRED = ((uint64_t) 0x1) << 26;
|
const uint64_t REQUIRED = ((uint64_t)0x1) << 26;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is an alert, notifying the user of something important.
|
* The object is an alert, notifying the user of something important.
|
||||||
*/
|
*/
|
||||||
const uint64_t ALERT = ((uint64_t) 0x1) << 27;
|
const uint64_t ALERT = ((uint64_t)0x1) << 27;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for text fields containing invalid values.
|
* Used for text fields containing invalid values.
|
||||||
*/
|
*/
|
||||||
const uint64_t INVALID = ((uint64_t) 0x1) << 28;
|
const uint64_t INVALID = ((uint64_t)0x1) << 28;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controls value can not be obtained, and is returned as a set of "*"s.
|
* The controls value can not be obtained, and is returned as a set of "*"s.
|
||||||
*/
|
*/
|
||||||
const uint64_t PROTECTED = ((uint64_t) 0x1) << 29;
|
const uint64_t PROTECTED = ((uint64_t)0x1) << 29;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object can be invoked to show a pop up menu or window.
|
* The object can be invoked to show a pop up menu or window.
|
||||||
*/
|
*/
|
||||||
const uint64_t HASPOPUP = ((uint64_t) 0x1) << 30;
|
const uint64_t HASPOPUP = ((uint64_t)0x1) << 30;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The editable area has some kind of autocompletion.
|
* The editable area has some kind of autocompletion.
|
||||||
*/
|
*/
|
||||||
const uint64_t SUPPORTS_AUTOCOMPLETION = ((uint64_t) 0x1) << 31;
|
const uint64_t SUPPORTS_AUTOCOMPLETION = ((uint64_t)0x1) << 31;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is no longer available to be queried.
|
* The object is no longer available to be queried.
|
||||||
*/
|
*/
|
||||||
const uint64_t DEFUNCT = ((uint64_t) 0x1) << 32;
|
const uint64_t DEFUNCT = ((uint64_t)0x1) << 32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The text is selectable, the object must implement the text interface.
|
* The text is selectable, the object must implement the text interface.
|
||||||
*/
|
*/
|
||||||
const uint64_t SELECTABLE_TEXT = ((uint64_t) 0x1) << 33;
|
const uint64_t SELECTABLE_TEXT = ((uint64_t)0x1) << 33;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The text in this object can be edited.
|
* The text in this object can be edited.
|
||||||
*/
|
*/
|
||||||
const uint64_t EDITABLE = ((uint64_t) 0x1) << 34;
|
const uint64_t EDITABLE = ((uint64_t)0x1) << 34;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This window is currently the active window.
|
* This window is currently the active window.
|
||||||
*/
|
*/
|
||||||
const uint64_t ACTIVE = ((uint64_t) 0x1) << 35;
|
const uint64_t ACTIVE = ((uint64_t)0x1) << 35;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that the object is modal. Modal objects have the behavior
|
* Indicates that the object is modal. Modal objects have the behavior
|
||||||
* that something must be done with the object before the user can
|
* that something must be done with the object before the user can
|
||||||
* interact with an object in a different window.
|
* interact with an object in a different window.
|
||||||
*/
|
*/
|
||||||
const uint64_t MODAL = ((uint64_t) 0x1) << 36;
|
const uint64_t MODAL = ((uint64_t)0x1) << 36;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit control that can take multiple lines.
|
* Edit control that can take multiple lines.
|
||||||
*/
|
*/
|
||||||
const uint64_t MULTI_LINE = ((uint64_t) 0x1) << 37;
|
const uint64_t MULTI_LINE = ((uint64_t)0x1) << 37;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses horizontal layout.
|
* Uses horizontal layout.
|
||||||
*/
|
*/
|
||||||
const uint64_t HORIZONTAL = ((uint64_t) 0x1) << 38;
|
const uint64_t HORIZONTAL = ((uint64_t)0x1) << 38;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates this object paints every pixel within its rectangular region.
|
* Indicates this object paints every pixel within its rectangular region.
|
||||||
*/
|
*/
|
||||||
const uint64_t OPAQUE1 = ((uint64_t) 0x1) << 39;
|
const uint64_t OPAQUE1 = ((uint64_t)0x1) << 39;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This text object can only contain 1 line of text.
|
* This text object can only contain 1 line of text.
|
||||||
*/
|
*/
|
||||||
const uint64_t SINGLE_LINE = ((uint64_t) 0x1) << 40;
|
const uint64_t SINGLE_LINE = ((uint64_t)0x1) << 40;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent object manages descendants, and this object may only exist
|
* The parent object manages descendants, and this object may only exist
|
||||||
* while it is visible or has focus.
|
* while it is visible or has focus.
|
||||||
* For example the focused cell of a table or the current element of a list box may have this state.
|
* For example the focused cell of a table or the current element of a list box
|
||||||
|
* may have this state.
|
||||||
*/
|
*/
|
||||||
const uint64_t TRANSIENT = ((uint64_t) 0x1) << 41;
|
const uint64_t TRANSIENT = ((uint64_t)0x1) << 41;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses vertical layout.
|
* Uses vertical layout.
|
||||||
* Especially used for sliders and scrollbars.
|
* Especially used for sliders and scrollbars.
|
||||||
*/
|
*/
|
||||||
const uint64_t VERTICAL = ((uint64_t) 0x1) << 42;
|
const uint64_t VERTICAL = ((uint64_t)0x1) << 42;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object not dead, but not up-to-date either.
|
* Object not dead, but not up-to-date either.
|
||||||
*/
|
*/
|
||||||
const uint64_t STALE = ((uint64_t) 0x1) << 43;
|
const uint64_t STALE = ((uint64_t)0x1) << 43;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A widget that is not unavailable.
|
* A widget that is not unavailable.
|
||||||
*/
|
*/
|
||||||
const uint64_t ENABLED = ((uint64_t) 0x1) << 44;
|
const uint64_t ENABLED = ((uint64_t)0x1) << 44;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as ENABLED state for now see bug 636158
|
* Same as ENABLED state for now see bug 636158
|
||||||
*/
|
*/
|
||||||
const uint64_t SENSITIVE = ((uint64_t) 0x1) << 45;
|
const uint64_t SENSITIVE = ((uint64_t)0x1) << 45;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is expandable, provides a UI to expand/collapse its children
|
* The object is expandable, provides a UI to expand/collapse its children
|
||||||
* @see EXPANDED and COLLAPSED states.
|
* @see EXPANDED and COLLAPSED states.
|
||||||
*/
|
*/
|
||||||
const uint64_t EXPANDABLE = ((uint64_t) 0x1) << 46;
|
const uint64_t EXPANDABLE = ((uint64_t)0x1) << 46;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is pinned, usually indicating it is fixed in place and has permanence.
|
* The object is pinned, usually indicating it is fixed in place and has
|
||||||
|
* permanence.
|
||||||
*/
|
*/
|
||||||
const uint64_t PINNED = ((uint64_t) 0x1) << 47;
|
const uint64_t PINNED = ((uint64_t)0x1) << 47;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The object is the current item within a container or set of related elements.
|
* The object is the current item within a container or set of related elements.
|
||||||
*/
|
*/
|
||||||
const uint64_t CURRENT = ((uint64_t) 0x1) << 48;
|
const uint64_t CURRENT = ((uint64_t)0x1) << 48;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not a real state, used for static assertions.
|
* Not a real state, used for static assertions.
|
||||||
*/
|
*/
|
||||||
const uint64_t LAST_ENTRY = CURRENT;
|
const uint64_t LAST_ENTRY = CURRENT;
|
||||||
|
|
||||||
} // namespace states
|
} // namespace states
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -13,27 +13,30 @@ namespace mozilla {
|
|||||||
namespace a11y {
|
namespace a11y {
|
||||||
namespace statistics {
|
namespace statistics {
|
||||||
|
|
||||||
inline void A11yInitialized()
|
inline void A11yInitialized() {
|
||||||
{ Telemetry::Accumulate(Telemetry::A11Y_INSTANTIATED_FLAG, true); }
|
Telemetry::Accumulate(Telemetry::A11Y_INSTANTIATED_FLAG, true);
|
||||||
|
}
|
||||||
|
|
||||||
inline void A11yConsumers(uint32_t aConsumer)
|
inline void A11yConsumers(uint32_t aConsumer) {
|
||||||
{ Telemetry::Accumulate(Telemetry::A11Y_CONSUMERS, aConsumer); }
|
Telemetry::Accumulate(Telemetry::A11Y_CONSUMERS, aConsumer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report that ISimpleDOM* has been used.
|
* Report that ISimpleDOM* has been used.
|
||||||
*/
|
*/
|
||||||
inline void ISimpleDOMUsed()
|
inline void ISimpleDOMUsed() {
|
||||||
{ Telemetry::Accumulate(Telemetry::A11Y_ISIMPLEDOM_USAGE_FLAG, true); }
|
Telemetry::Accumulate(Telemetry::A11Y_ISIMPLEDOM_USAGE_FLAG, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report that IAccessibleTable has been used.
|
* Report that IAccessibleTable has been used.
|
||||||
*/
|
*/
|
||||||
inline void IAccessibleTableUsed()
|
inline void IAccessibleTableUsed() {
|
||||||
{ Telemetry::Accumulate(Telemetry::A11Y_IATABLE_USAGE_FLAG, true); }
|
Telemetry::Accumulate(Telemetry::A11Y_IATABLE_USAGE_FLAG, true);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace statistics
|
} // namespace statistics
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,38 +14,31 @@
|
|||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
StyleInfo::StyleInfo(dom::Element* aElement) :
|
StyleInfo::StyleInfo(dom::Element* aElement) : mElement(aElement) {
|
||||||
mElement(aElement)
|
|
||||||
{
|
|
||||||
mComputedStyle =
|
mComputedStyle =
|
||||||
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement, nullptr);
|
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void StyleInfo::Display(nsAString& aValue) {
|
||||||
StyleInfo::Display(nsAString& aValue)
|
|
||||||
{
|
|
||||||
aValue.Truncate();
|
aValue.Truncate();
|
||||||
AppendASCIItoUTF16(
|
AppendASCIItoUTF16(
|
||||||
nsCSSProps::ValueToKeyword(mComputedStyle->StyleDisplay()->mDisplay,
|
nsCSSProps::ValueToKeyword(mComputedStyle->StyleDisplay()->mDisplay,
|
||||||
nsCSSProps::kDisplayKTable), aValue);
|
nsCSSProps::kDisplayKTable),
|
||||||
|
aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void StyleInfo::TextAlign(nsAString& aValue) {
|
||||||
StyleInfo::TextAlign(nsAString& aValue)
|
|
||||||
{
|
|
||||||
aValue.Truncate();
|
aValue.Truncate();
|
||||||
AppendASCIItoUTF16(
|
AppendASCIItoUTF16(
|
||||||
nsCSSProps::ValueToKeyword(mComputedStyle->StyleText()->mTextAlign,
|
nsCSSProps::ValueToKeyword(mComputedStyle->StyleText()->mTextAlign,
|
||||||
nsCSSProps::kTextAlignKTable), aValue);
|
nsCSSProps::kTextAlignKTable),
|
||||||
|
aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void StyleInfo::TextIndent(nsAString& aValue) {
|
||||||
StyleInfo::TextIndent(nsAString& aValue)
|
|
||||||
{
|
|
||||||
aValue.Truncate();
|
aValue.Truncate();
|
||||||
|
|
||||||
const nsStyleCoord& styleCoord =
|
const nsStyleCoord& styleCoord = mComputedStyle->StyleText()->mTextIndent;
|
||||||
mComputedStyle->StyleText()->mTextIndent;
|
|
||||||
|
|
||||||
nscoord coordVal = 0;
|
nscoord coordVal = 0;
|
||||||
switch (styleCoord.GetUnit()) {
|
switch (styleCoord.GetUnit()) {
|
||||||
@@ -75,10 +68,9 @@ StyleInfo::TextIndent(nsAString& aValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void StyleInfo::Margin(Side aSide, nsAString& aValue) {
|
||||||
StyleInfo::Margin(Side aSide, nsAString& aValue)
|
MOZ_ASSERT(mElement->GetPrimaryFrame(),
|
||||||
{
|
" mElement->GetPrimaryFrame() needs to be valid pointer");
|
||||||
MOZ_ASSERT(mElement->GetPrimaryFrame(), " mElement->GetPrimaryFrame() needs to be valid pointer");
|
|
||||||
aValue.Truncate();
|
aValue.Truncate();
|
||||||
|
|
||||||
nscoord coordVal = mElement->GetPrimaryFrame()->GetUsedMargin().Side(aSide);
|
nscoord coordVal = mElement->GetPrimaryFrame()->GetUsedMargin().Side(aSide);
|
||||||
@@ -86,9 +78,7 @@ StyleInfo::Margin(Side aSide, nsAString& aValue)
|
|||||||
aValue.AppendLiteral("px");
|
aValue.AppendLiteral("px");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void StyleInfo::FormatColor(const nscolor& aValue, nsString& aFormattedValue) {
|
||||||
StyleInfo::FormatColor(const nscolor& aValue, nsString& aFormattedValue)
|
|
||||||
{
|
|
||||||
// Combine the string like rgb(R, G, B) from nscolor.
|
// Combine the string like rgb(R, G, B) from nscolor.
|
||||||
aFormattedValue.AppendLiteral("rgb(");
|
aFormattedValue.AppendLiteral("rgb(");
|
||||||
aFormattedValue.AppendInt(NS_GET_R(aValue));
|
aFormattedValue.AppendInt(NS_GET_R(aValue));
|
||||||
@@ -99,11 +89,9 @@ StyleInfo::FormatColor(const nscolor& aValue, nsString& aFormattedValue)
|
|||||||
aFormattedValue.Append(')');
|
aFormattedValue.Append(')');
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void StyleInfo::FormatTextDecorationStyle(uint8_t aValue,
|
||||||
StyleInfo::FormatTextDecorationStyle(uint8_t aValue, nsAString& aFormattedValue)
|
nsAString& aFormattedValue) {
|
||||||
{
|
nsCSSKeyword keyword = nsCSSProps::ValueToKeywordEnum(
|
||||||
nsCSSKeyword keyword =
|
aValue, nsCSSProps::kTextDecorationStyleKTable);
|
||||||
nsCSSProps::ValueToKeywordEnum(aValue,
|
|
||||||
nsCSSProps::kTextDecorationStyleKTable);
|
|
||||||
AppendUTF8toUTF16(nsCSSKeywords::GetStringValue(keyword), aFormattedValue);
|
AppendUTF8toUTF16(nsCSSKeywords::GetStringValue(keyword), aFormattedValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ class Element;
|
|||||||
} // namespace dom
|
} // namespace dom
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
class StyleInfo
|
class StyleInfo {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit StyleInfo(dom::Element* aElement);
|
explicit StyleInfo(dom::Element* aElement);
|
||||||
~StyleInfo() { }
|
~StyleInfo() {}
|
||||||
|
|
||||||
void Display(nsAString& aValue);
|
void Display(nsAString& aValue);
|
||||||
void TextAlign(nsAString& aValue);
|
void TextAlign(nsAString& aValue);
|
||||||
@@ -31,12 +30,13 @@ public:
|
|||||||
void MarginBottom(nsAString& aValue) { Margin(eSideBottom, aValue); }
|
void MarginBottom(nsAString& aValue) { Margin(eSideBottom, aValue); }
|
||||||
|
|
||||||
static void FormatColor(const nscolor& aValue, nsString& aFormattedValue);
|
static void FormatColor(const nscolor& aValue, nsString& aFormattedValue);
|
||||||
static void FormatTextDecorationStyle(uint8_t aValue, nsAString& aFormattedValue);
|
static void FormatTextDecorationStyle(uint8_t aValue,
|
||||||
|
nsAString& aFormattedValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StyleInfo() = delete;
|
StyleInfo() = delete;
|
||||||
StyleInfo(const StyleInfo&) = delete;
|
StyleInfo(const StyleInfo&) = delete;
|
||||||
StyleInfo& operator = (const StyleInfo&) = delete;
|
StyleInfo& operator=(const StyleInfo&) = delete;
|
||||||
|
|
||||||
void Margin(Side aSide, nsAString& aValue);
|
void Margin(Side aSide, nsAString& aValue);
|
||||||
|
|
||||||
|
|||||||
@@ -26,31 +26,26 @@ using namespace mozilla::a11y;
|
|||||||
// TextAttrsMgr
|
// TextAttrsMgr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
||||||
TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
uint32_t* aStartOffset, uint32_t* aEndOffset) {
|
||||||
uint32_t* aStartOffset,
|
|
||||||
uint32_t* aEndOffset)
|
|
||||||
{
|
|
||||||
// 1. Hyper text accessible must be specified always.
|
// 1. Hyper text accessible must be specified always.
|
||||||
// 2. Offset accessible and result hyper text offsets must be specified in
|
// 2. Offset accessible and result hyper text offsets must be specified in
|
||||||
// the case of text attributes.
|
// the case of text attributes.
|
||||||
// 3. Offset accessible and result hyper text offsets must not be specified
|
// 3. Offset accessible and result hyper text offsets must not be specified
|
||||||
// but include default text attributes flag and attributes list must be
|
// but include default text attributes flag and attributes list must be
|
||||||
// specified in the case of default text attributes.
|
// specified in the case of default text attributes.
|
||||||
MOZ_ASSERT(mHyperTextAcc &&
|
MOZ_ASSERT(
|
||||||
((mOffsetAcc && mOffsetAccIdx != -1 &&
|
mHyperTextAcc &&
|
||||||
aStartOffset && aEndOffset) ||
|
((mOffsetAcc && mOffsetAccIdx != -1 && aStartOffset && aEndOffset) ||
|
||||||
(!mOffsetAcc && mOffsetAccIdx == -1 &&
|
(!mOffsetAcc && mOffsetAccIdx == -1 && !aStartOffset &&
|
||||||
!aStartOffset && !aEndOffset &&
|
!aEndOffset && mIncludeDefAttrs && aAttributes)),
|
||||||
mIncludeDefAttrs && aAttributes)),
|
|
||||||
"Wrong usage of TextAttrsMgr!");
|
"Wrong usage of TextAttrsMgr!");
|
||||||
|
|
||||||
// Embedded objects are combined into own range with empty attributes set.
|
// Embedded objects are combined into own range with empty attributes set.
|
||||||
if (mOffsetAcc && !mOffsetAcc->IsText()) {
|
if (mOffsetAcc && !mOffsetAcc->IsText()) {
|
||||||
for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
|
for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
|
||||||
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
||||||
if (currAcc->IsText())
|
if (currAcc->IsText()) break;
|
||||||
break;
|
|
||||||
|
|
||||||
(*aStartOffset)--;
|
(*aStartOffset)--;
|
||||||
}
|
}
|
||||||
@@ -59,8 +54,7 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
|||||||
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childCount;
|
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childCount;
|
||||||
childIdx++) {
|
childIdx++) {
|
||||||
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
||||||
if (currAcc->IsText())
|
if (currAcc->IsText()) break;
|
||||||
break;
|
|
||||||
|
|
||||||
(*aEndOffset)++;
|
(*aEndOffset)++;
|
||||||
}
|
}
|
||||||
@@ -76,17 +70,15 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
|||||||
|
|
||||||
nsIFrame* rootFrame = mHyperTextAcc->GetFrame();
|
nsIFrame* rootFrame = mHyperTextAcc->GetFrame();
|
||||||
MOZ_ASSERT(rootFrame, "No frame for accessible!");
|
MOZ_ASSERT(rootFrame, "No frame for accessible!");
|
||||||
if (!rootFrame)
|
if (!rootFrame) return;
|
||||||
return;
|
|
||||||
|
|
||||||
nsIContent *offsetNode = nullptr, *offsetElm = nullptr;
|
nsIContent *offsetNode = nullptr, *offsetElm = nullptr;
|
||||||
nsIFrame *frame = nullptr;
|
nsIFrame* frame = nullptr;
|
||||||
if (mOffsetAcc) {
|
if (mOffsetAcc) {
|
||||||
offsetNode = mOffsetAcc->GetContent();
|
offsetNode = mOffsetAcc->GetContent();
|
||||||
offsetElm = nsCoreUtils::GetDOMElementFor(offsetNode);
|
offsetElm = nsCoreUtils::GetDOMElementFor(offsetNode);
|
||||||
MOZ_ASSERT(offsetElm, "No element for offset accessible!");
|
MOZ_ASSERT(offsetElm, "No element for offset accessible!");
|
||||||
if (!offsetElm)
|
if (!offsetElm) return;
|
||||||
return;
|
|
||||||
|
|
||||||
frame = offsetElm->GetPrimaryFrame();
|
frame = offsetElm->GetPrimaryFrame();
|
||||||
}
|
}
|
||||||
@@ -124,20 +116,11 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
|||||||
// "text-position" text attribute
|
// "text-position" text attribute
|
||||||
TextPosTextAttr textPosTextAttr(rootFrame, frame);
|
TextPosTextAttr textPosTextAttr(rootFrame, frame);
|
||||||
|
|
||||||
TextAttr* attrArray[] =
|
TextAttr* attrArray[] = {
|
||||||
{
|
&langTextAttr, &invalidTextAttr, &bgColorTextAttr,
|
||||||
&langTextAttr,
|
&colorTextAttr, &fontFamilyTextAttr, &fontSizeTextAttr,
|
||||||
&invalidTextAttr,
|
&fontStyleTextAttr, &fontWeightTextAttr, &autoGenTextAttr,
|
||||||
&bgColorTextAttr,
|
&textDecorTextAttr, &textPosTextAttr};
|
||||||
&colorTextAttr,
|
|
||||||
&fontFamilyTextAttr,
|
|
||||||
&fontSizeTextAttr,
|
|
||||||
&fontStyleTextAttr,
|
|
||||||
&fontWeightTextAttr,
|
|
||||||
&autoGenTextAttr,
|
|
||||||
&textDecorTextAttr,
|
|
||||||
&textPosTextAttr
|
|
||||||
};
|
|
||||||
|
|
||||||
// Expose text attributes if applicable.
|
// Expose text attributes if applicable.
|
||||||
if (aAttributes) {
|
if (aAttributes) {
|
||||||
@@ -150,18 +133,15 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
|||||||
GetRange(attrArray, ArrayLength(attrArray), aStartOffset, aEndOffset);
|
GetRange(attrArray, ArrayLength(attrArray), aStartOffset, aEndOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
||||||
TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
uint32_t* aStartOffset, uint32_t* aEndOffset) {
|
||||||
uint32_t* aStartOffset, uint32_t* aEndOffset)
|
|
||||||
{
|
|
||||||
// Navigate backward from anchor accessible to find start offset.
|
// Navigate backward from anchor accessible to find start offset.
|
||||||
for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
|
for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
|
||||||
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
||||||
|
|
||||||
// Stop on embedded accessible since embedded accessibles are combined into
|
// Stop on embedded accessible since embedded accessibles are combined into
|
||||||
// own range.
|
// own range.
|
||||||
if (!currAcc->IsText())
|
if (!currAcc->IsText()) break;
|
||||||
break;
|
|
||||||
|
|
||||||
MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()),
|
MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()),
|
||||||
"Text accessible has to have an associated DOM element");
|
"Text accessible has to have an associated DOM element");
|
||||||
@@ -175,8 +155,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offsetFound)
|
if (offsetFound) break;
|
||||||
break;
|
|
||||||
|
|
||||||
*(aStartOffset) -= nsAccUtils::TextLength(currAcc);
|
*(aStartOffset) -= nsAccUtils::TextLength(currAcc);
|
||||||
}
|
}
|
||||||
@@ -185,8 +164,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
|||||||
uint32_t childLen = mHyperTextAcc->ChildCount();
|
uint32_t childLen = mHyperTextAcc->ChildCount();
|
||||||
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
|
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
|
||||||
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
||||||
if (!currAcc->IsText())
|
if (!currAcc->IsText()) break;
|
||||||
break;
|
|
||||||
|
|
||||||
MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()),
|
MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()),
|
||||||
"Text accessible has to have an associated DOM element");
|
"Text accessible has to have an associated DOM element");
|
||||||
@@ -203,23 +181,19 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offsetFound)
|
if (offsetFound) break;
|
||||||
break;
|
|
||||||
|
|
||||||
(*aEndOffset) += nsAccUtils::TextLength(currAcc);
|
(*aEndOffset) += nsAccUtils::TextLength(currAcc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// LangTextAttr
|
// LangTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::LangTextAttr::
|
TextAttrsMgr::LangTextAttr::LangTextAttr(HyperTextAccessible* aRoot,
|
||||||
LangTextAttr(HyperTextAccessible* aRoot,
|
nsIContent* aRootElm, nsIContent* aElm)
|
||||||
nsIContent* aRootElm, nsIContent* aElm) :
|
: TTextAttr<nsString>(!aElm), mRootContent(aRootElm) {
|
||||||
TTextAttr<nsString>(!aElm), mRootContent(aRootElm)
|
|
||||||
{
|
|
||||||
aRoot->Language(mRootNativeValue);
|
aRoot->Language(mRootNativeValue);
|
||||||
mIsRootDefined = !mRootNativeValue.IsEmpty();
|
mIsRootDefined = !mRootNativeValue.IsEmpty();
|
||||||
|
|
||||||
@@ -229,21 +203,16 @@ TextAttrsMgr::LangTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextAttrsMgr::LangTextAttr::
|
TextAttrsMgr::LangTextAttr::~LangTextAttr() {}
|
||||||
~LangTextAttr() {}
|
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::LangTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::LangTextAttr::
|
nsString* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, nsString* aValue)
|
|
||||||
{
|
|
||||||
nsCoreUtils::GetLanguageFor(aAccessible->GetContent(), mRootContent, *aValue);
|
nsCoreUtils::GetLanguageFor(aAccessible->GetContent(), mRootContent, *aValue);
|
||||||
return !aValue->IsEmpty();
|
return !aValue->IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::LangTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::LangTextAttr::
|
nsIPersistentProperties* aAttributes, const nsString& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const nsString& aValue)
|
|
||||||
{
|
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::language, aValue);
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::language, aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,27 +220,21 @@ TextAttrsMgr::LangTextAttr::
|
|||||||
// InvalidTextAttr
|
// InvalidTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::InvalidTextAttr::
|
TextAttrsMgr::InvalidTextAttr::InvalidTextAttr(nsIContent* aRootElm,
|
||||||
InvalidTextAttr(nsIContent* aRootElm, nsIContent* aElm) :
|
nsIContent* aElm)
|
||||||
TTextAttr<uint32_t>(!aElm), mRootElm(aRootElm)
|
: TTextAttr<uint32_t>(!aElm), mRootElm(aRootElm) {
|
||||||
{
|
|
||||||
mIsRootDefined = GetValue(mRootElm, &mRootNativeValue);
|
mIsRootDefined = GetValue(mRootElm, &mRootNativeValue);
|
||||||
if (aElm)
|
if (aElm) mIsDefined = GetValue(aElm, &mNativeValue);
|
||||||
mIsDefined = GetValue(aElm, &mNativeValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::InvalidTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::InvalidTextAttr::
|
uint32_t* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, uint32_t* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
return elm ? GetValue(elm, aValue) : false;
|
return elm ? GetValue(elm, aValue) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::InvalidTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::InvalidTextAttr::
|
nsIPersistentProperties* aAttributes, const uint32_t& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const uint32_t& aValue)
|
|
||||||
{
|
|
||||||
switch (aValue) {
|
switch (aValue) {
|
||||||
case eFalse:
|
case eFalse:
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
|
||||||
@@ -295,20 +258,16 @@ TextAttrsMgr::InvalidTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::InvalidTextAttr::GetValue(nsIContent* aElm,
|
||||||
TextAttrsMgr::InvalidTextAttr::
|
uint32_t* aValue) {
|
||||||
GetValue(nsIContent* aElm, uint32_t* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = aElm;
|
nsIContent* elm = aElm;
|
||||||
do {
|
do {
|
||||||
if (nsAccUtils::HasDefinedARIAToken(elm, nsGkAtoms::aria_invalid)) {
|
if (nsAccUtils::HasDefinedARIAToken(elm, nsGkAtoms::aria_invalid)) {
|
||||||
static Element::AttrValuesArray tokens[] =
|
static Element::AttrValuesArray tokens[] = {
|
||||||
{ nsGkAtoms::_false, nsGkAtoms::grammar, nsGkAtoms::spelling,
|
nsGkAtoms::_false, nsGkAtoms::grammar, nsGkAtoms::spelling, nullptr};
|
||||||
nullptr };
|
|
||||||
|
|
||||||
int32_t idx = elm->AsElement()->FindAttrValueIn(kNameSpaceID_None,
|
int32_t idx = elm->AsElement()->FindAttrValueIn(
|
||||||
nsGkAtoms::aria_invalid,
|
kNameSpaceID_None, nsGkAtoms::aria_invalid, tokens, eCaseMatters);
|
||||||
tokens, eCaseMatters);
|
|
||||||
switch (idx) {
|
switch (idx) {
|
||||||
case 0:
|
case 0:
|
||||||
*aValue = eFalse;
|
*aValue = eFalse;
|
||||||
@@ -329,24 +288,19 @@ TextAttrsMgr::InvalidTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// BGColorTextAttr
|
// BGColorTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::BGColorTextAttr::
|
TextAttrsMgr::BGColorTextAttr::BGColorTextAttr(nsIFrame* aRootFrame,
|
||||||
BGColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
nsIFrame* aFrame)
|
||||||
TTextAttr<nscolor>(!aFrame), mRootFrame(aRootFrame)
|
: TTextAttr<nscolor>(!aFrame), mRootFrame(aRootFrame) {
|
||||||
{
|
|
||||||
mIsRootDefined = GetColor(mRootFrame, &mRootNativeValue);
|
mIsRootDefined = GetColor(mRootFrame, &mRootNativeValue);
|
||||||
if (aFrame)
|
if (aFrame) mIsDefined = GetColor(aFrame, &mNativeValue);
|
||||||
mIsDefined = GetColor(aFrame, &mNativeValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::BGColorTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::BGColorTextAttr::
|
nscolor* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, nscolor* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
if (elm) {
|
if (elm) {
|
||||||
nsIFrame* frame = elm->GetPrimaryFrame();
|
nsIFrame* frame = elm->GetPrimaryFrame();
|
||||||
@@ -357,27 +311,23 @@ TextAttrsMgr::BGColorTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::BGColorTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::BGColorTextAttr::
|
nsIPersistentProperties* aAttributes, const nscolor& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const nscolor& aValue)
|
|
||||||
{
|
|
||||||
nsAutoString formattedValue;
|
nsAutoString formattedValue;
|
||||||
StyleInfo::FormatColor(aValue, formattedValue);
|
StyleInfo::FormatColor(aValue, formattedValue);
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::backgroundColor,
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::backgroundColor,
|
||||||
formattedValue);
|
formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::BGColorTextAttr::GetColor(nsIFrame* aFrame,
|
||||||
TextAttrsMgr::BGColorTextAttr::
|
nscolor* aColor) {
|
||||||
GetColor(nsIFrame* aFrame, nscolor* aColor)
|
|
||||||
{
|
|
||||||
nscolor backgroundColor = aFrame->StyleBackground()->BackgroundColor(aFrame);
|
nscolor backgroundColor = aFrame->StyleBackground()->BackgroundColor(aFrame);
|
||||||
if (NS_GET_A(backgroundColor) > 0) {
|
if (NS_GET_A(backgroundColor) > 0) {
|
||||||
*aColor = backgroundColor;
|
*aColor = backgroundColor;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsContainerFrame *parentFrame = aFrame->GetParent();
|
nsContainerFrame* parentFrame = aFrame->GetParent();
|
||||||
if (!parentFrame) {
|
if (!parentFrame) {
|
||||||
*aColor = aFrame->PresContext()->DefaultBackgroundColor();
|
*aColor = aFrame->PresContext()->DefaultBackgroundColor();
|
||||||
return true;
|
return true;
|
||||||
@@ -386,21 +336,18 @@ TextAttrsMgr::BGColorTextAttr::
|
|||||||
// Each frame of parents chain for the initially passed 'aFrame' has
|
// Each frame of parents chain for the initially passed 'aFrame' has
|
||||||
// transparent background color. So background color isn't changed from
|
// transparent background color. So background color isn't changed from
|
||||||
// 'mRootFrame' to initially passed 'aFrame'.
|
// 'mRootFrame' to initially passed 'aFrame'.
|
||||||
if (parentFrame == mRootFrame)
|
if (parentFrame == mRootFrame) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
return GetColor(parentFrame, aColor);
|
return GetColor(parentFrame, aColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// ColorTextAttr
|
// ColorTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::ColorTextAttr::
|
TextAttrsMgr::ColorTextAttr::ColorTextAttr(nsIFrame* aRootFrame,
|
||||||
ColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
nsIFrame* aFrame)
|
||||||
TTextAttr<nscolor>(!aFrame)
|
: TTextAttr<nscolor>(!aFrame) {
|
||||||
{
|
|
||||||
mRootNativeValue = aRootFrame->StyleColor()->mColor;
|
mRootNativeValue = aRootFrame->StyleColor()->mColor;
|
||||||
mIsRootDefined = true;
|
mIsRootDefined = true;
|
||||||
|
|
||||||
@@ -410,10 +357,8 @@ TextAttrsMgr::ColorTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::ColorTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::ColorTextAttr::
|
nscolor* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, nscolor* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
if (elm) {
|
if (elm) {
|
||||||
nsIFrame* frame = elm->GetPrimaryFrame();
|
nsIFrame* frame = elm->GetPrimaryFrame();
|
||||||
@@ -425,34 +370,27 @@ TextAttrsMgr::ColorTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::ColorTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::ColorTextAttr::
|
nsIPersistentProperties* aAttributes, const nscolor& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const nscolor& aValue)
|
|
||||||
{
|
|
||||||
nsAutoString formattedValue;
|
nsAutoString formattedValue;
|
||||||
StyleInfo::FormatColor(aValue, formattedValue);
|
StyleInfo::FormatColor(aValue, formattedValue);
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::color, formattedValue);
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::color, formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// FontFamilyTextAttr
|
// FontFamilyTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::FontFamilyTextAttr::
|
TextAttrsMgr::FontFamilyTextAttr::FontFamilyTextAttr(nsIFrame* aRootFrame,
|
||||||
FontFamilyTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
nsIFrame* aFrame)
|
||||||
TTextAttr<nsString>(!aFrame)
|
: TTextAttr<nsString>(!aFrame) {
|
||||||
{
|
|
||||||
mIsRootDefined = GetFontFamily(aRootFrame, mRootNativeValue);
|
mIsRootDefined = GetFontFamily(aRootFrame, mRootNativeValue);
|
||||||
|
|
||||||
if (aFrame)
|
if (aFrame) mIsDefined = GetFontFamily(aFrame, mNativeValue);
|
||||||
mIsDefined = GetFontFamily(aFrame, mNativeValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::FontFamilyTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::FontFamilyTextAttr::
|
nsString* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, nsString* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
if (elm) {
|
if (elm) {
|
||||||
nsIFrame* frame = elm->GetPrimaryFrame();
|
nsIFrame* frame = elm->GetPrimaryFrame();
|
||||||
@@ -463,17 +401,13 @@ TextAttrsMgr::FontFamilyTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::FontFamilyTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::FontFamilyTextAttr::
|
nsIPersistentProperties* aAttributes, const nsString& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const nsString& aValue)
|
|
||||||
{
|
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_family, aValue);
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_family, aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::FontFamilyTextAttr::GetFontFamily(nsIFrame* aFrame,
|
||||||
TextAttrsMgr::FontFamilyTextAttr::
|
nsString& aFamily) {
|
||||||
GetFontFamily(nsIFrame* aFrame, nsString& aFamily)
|
|
||||||
{
|
|
||||||
RefPtr<nsFontMetrics> fm =
|
RefPtr<nsFontMetrics> fm =
|
||||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
|
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
|
||||||
|
|
||||||
@@ -484,15 +418,13 @@ TextAttrsMgr::FontFamilyTextAttr::
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// FontSizeTextAttr
|
// FontSizeTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::FontSizeTextAttr::
|
TextAttrsMgr::FontSizeTextAttr::FontSizeTextAttr(nsIFrame* aRootFrame,
|
||||||
FontSizeTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
nsIFrame* aFrame)
|
||||||
TTextAttr<nscoord>(!aFrame)
|
: TTextAttr<nscoord>(!aFrame) {
|
||||||
{
|
|
||||||
mDC = aRootFrame->PresContext()->DeviceContext();
|
mDC = aRootFrame->PresContext()->DeviceContext();
|
||||||
|
|
||||||
mRootNativeValue = aRootFrame->StyleFont()->mSize;
|
mRootNativeValue = aRootFrame->StyleFont()->mSize;
|
||||||
@@ -504,10 +436,8 @@ TextAttrsMgr::FontSizeTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::FontSizeTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::FontSizeTextAttr::
|
nscoord* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, nscoord* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* el = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* el = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
if (el) {
|
if (el) {
|
||||||
nsIFrame* frame = el->GetPrimaryFrame();
|
nsIFrame* frame = el->GetPrimaryFrame();
|
||||||
@@ -519,10 +449,8 @@ TextAttrsMgr::FontSizeTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::FontSizeTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::FontSizeTextAttr::
|
nsIPersistentProperties* aAttributes, const nscoord& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const nscoord& aValue)
|
|
||||||
{
|
|
||||||
// Convert from nscoord to pt.
|
// Convert from nscoord to pt.
|
||||||
//
|
//
|
||||||
// Note: according to IA2, "The conversion doesn't have to be exact.
|
// Note: according to IA2, "The conversion doesn't have to be exact.
|
||||||
@@ -531,10 +459,9 @@ TextAttrsMgr::FontSizeTextAttr::
|
|||||||
// ATK does not specify a unit and will likely follow IA2 here.
|
// ATK does not specify a unit and will likely follow IA2 here.
|
||||||
//
|
//
|
||||||
// XXX todo: consider sharing this code with layout module? (bug 474621)
|
// XXX todo: consider sharing this code with layout module? (bug 474621)
|
||||||
float px =
|
float px = NSAppUnitsToFloatPixels(aValue, mozilla::AppUnitsPerCSSPixel());
|
||||||
NSAppUnitsToFloatPixels(aValue, mozilla::AppUnitsPerCSSPixel());
|
|
||||||
// Each pt is 4/3 of a CSS pixel.
|
// Each pt is 4/3 of a CSS pixel.
|
||||||
int pts = NS_lround(px*3/4);
|
int pts = NS_lround(px * 3 / 4);
|
||||||
|
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
value.AppendInt(pts);
|
value.AppendInt(pts);
|
||||||
@@ -543,15 +470,13 @@ TextAttrsMgr::FontSizeTextAttr::
|
|||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_size, value);
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_size, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// FontStyleTextAttr
|
// FontStyleTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::FontStyleTextAttr::
|
TextAttrsMgr::FontStyleTextAttr::FontStyleTextAttr(nsIFrame* aRootFrame,
|
||||||
FontStyleTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
nsIFrame* aFrame)
|
||||||
TTextAttr<FontSlantStyle>(!aFrame)
|
: TTextAttr<FontSlantStyle>(!aFrame) {
|
||||||
{
|
|
||||||
mRootNativeValue = aRootFrame->StyleFont()->mFont.style;
|
mRootNativeValue = aRootFrame->StyleFont()->mFont.style;
|
||||||
mIsRootDefined = true;
|
mIsRootDefined = true;
|
||||||
|
|
||||||
@@ -561,10 +486,8 @@ TextAttrsMgr::FontStyleTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::FontStyleTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::FontStyleTextAttr::
|
FontSlantStyle* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, FontSlantStyle* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
if (elm) {
|
if (elm) {
|
||||||
nsIFrame* frame = elm->GetPrimaryFrame();
|
nsIFrame* frame = elm->GetPrimaryFrame();
|
||||||
@@ -576,25 +499,20 @@ TextAttrsMgr::FontStyleTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::FontStyleTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::FontStyleTextAttr::
|
nsIPersistentProperties* aAttributes, const FontSlantStyle& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes,
|
|
||||||
const FontSlantStyle& aValue)
|
|
||||||
{
|
|
||||||
nsAutoString string;
|
nsAutoString string;
|
||||||
nsStyleUtil::AppendFontSlantStyle(aValue, string);
|
nsStyleUtil::AppendFontSlantStyle(aValue, string);
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_style, string);
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_style, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// FontWeightTextAttr
|
// FontWeightTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::FontWeightTextAttr::
|
TextAttrsMgr::FontWeightTextAttr::FontWeightTextAttr(nsIFrame* aRootFrame,
|
||||||
FontWeightTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
nsIFrame* aFrame)
|
||||||
TTextAttr<FontWeight>(!aFrame)
|
: TTextAttr<FontWeight>(!aFrame) {
|
||||||
{
|
|
||||||
mRootNativeValue = GetFontWeight(aRootFrame);
|
mRootNativeValue = GetFontWeight(aRootFrame);
|
||||||
mIsRootDefined = true;
|
mIsRootDefined = true;
|
||||||
|
|
||||||
@@ -604,10 +522,8 @@ TextAttrsMgr::FontWeightTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::FontWeightTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::FontWeightTextAttr::
|
FontWeight* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, FontWeight* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
if (elm) {
|
if (elm) {
|
||||||
nsIFrame* frame = elm->GetPrimaryFrame();
|
nsIFrame* frame = elm->GetPrimaryFrame();
|
||||||
@@ -619,28 +535,22 @@ TextAttrsMgr::FontWeightTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::FontWeightTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::FontWeightTextAttr::
|
nsIPersistentProperties* aAttributes, const FontWeight& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes,
|
|
||||||
const FontWeight& aValue)
|
|
||||||
{
|
|
||||||
nsAutoString formattedValue;
|
nsAutoString formattedValue;
|
||||||
formattedValue.AppendFloat(aValue.ToFloat());
|
formattedValue.AppendFloat(aValue.ToFloat());
|
||||||
|
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::fontWeight, formattedValue);
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::fontWeight, formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontWeight
|
FontWeight TextAttrsMgr::FontWeightTextAttr::GetFontWeight(nsIFrame* aFrame) {
|
||||||
TextAttrsMgr::FontWeightTextAttr::
|
|
||||||
GetFontWeight(nsIFrame* aFrame)
|
|
||||||
{
|
|
||||||
// nsFont::width isn't suitable here because it's necessary to expose real
|
// nsFont::width isn't suitable here because it's necessary to expose real
|
||||||
// value of font weight (used font might not have some font weight values).
|
// value of font weight (used font might not have some font weight values).
|
||||||
RefPtr<nsFontMetrics> fm =
|
RefPtr<nsFontMetrics> fm =
|
||||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
|
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
|
||||||
|
|
||||||
gfxFontGroup *fontGroup = fm->GetThebesFontGroup();
|
gfxFontGroup* fontGroup = fm->GetThebesFontGroup();
|
||||||
gfxFont *font = fontGroup->GetFirstValidFont();
|
gfxFont* font = fontGroup->GetFirstValidFont();
|
||||||
|
|
||||||
// When there doesn't exist a bold font in the family and so the rendering of
|
// When there doesn't exist a bold font in the family and so the rendering of
|
||||||
// a non-bold font face is changed so that the user sees what looks like a
|
// a non-bold font face is changed so that the user sees what looks like a
|
||||||
@@ -658,48 +568,41 @@ TextAttrsMgr::FontWeightTextAttr::
|
|||||||
// number as getComputedStyle(). fontEntry->Weight() will give the weight
|
// number as getComputedStyle(). fontEntry->Weight() will give the weight
|
||||||
// range supported by the font face used, so we clamp the weight that was
|
// range supported by the font face used, so we clamp the weight that was
|
||||||
// requested by style to what is actually supported by the font.
|
// requested by style to what is actually supported by the font.
|
||||||
gfxFontEntry *fontEntry = font->GetFontEntry();
|
gfxFontEntry* fontEntry = font->GetFontEntry();
|
||||||
return fontEntry->Weight().Clamp(font->GetStyle()->weight);
|
return fontEntry->Weight().Clamp(font->GetStyle()->weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// AutoGeneratedTextAttr
|
// AutoGeneratedTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
TextAttrsMgr::AutoGeneratedTextAttr::
|
TextAttrsMgr::AutoGeneratedTextAttr::AutoGeneratedTextAttr(
|
||||||
AutoGeneratedTextAttr(HyperTextAccessible* aHyperTextAcc,
|
HyperTextAccessible* aHyperTextAcc, Accessible* aAccessible)
|
||||||
Accessible* aAccessible) :
|
: TTextAttr<bool>(!aAccessible) {
|
||||||
TTextAttr<bool>(!aAccessible)
|
|
||||||
{
|
|
||||||
mRootNativeValue = false;
|
mRootNativeValue = false;
|
||||||
mIsRootDefined = false;
|
mIsRootDefined = false;
|
||||||
|
|
||||||
if (aAccessible)
|
if (aAccessible)
|
||||||
mIsDefined = mNativeValue = (aAccessible->NativeRole() == roles::STATICTEXT);
|
mIsDefined = mNativeValue =
|
||||||
|
(aAccessible->NativeRole() == roles::STATICTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::AutoGeneratedTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::AutoGeneratedTextAttr::
|
bool* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, bool* aValue)
|
|
||||||
{
|
|
||||||
return *aValue = (aAccessible->NativeRole() == roles::STATICTEXT);
|
return *aValue = (aAccessible->NativeRole() == roles::STATICTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::AutoGeneratedTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::AutoGeneratedTextAttr::
|
nsIPersistentProperties* aAttributes, const bool& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const bool& aValue)
|
nsAccUtils::SetAccAttr(
|
||||||
{
|
aAttributes, nsGkAtoms::auto_generated,
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::auto_generated,
|
|
||||||
aValue ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"));
|
aValue ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TextDecorTextAttr
|
// TextDecorTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::TextDecorValue::
|
TextAttrsMgr::TextDecorValue::TextDecorValue(nsIFrame* aFrame) {
|
||||||
TextDecorValue(nsIFrame* aFrame)
|
|
||||||
{
|
|
||||||
const nsStyleTextReset* textReset = aFrame->StyleTextReset();
|
const nsStyleTextReset* textReset = aFrame->StyleTextReset();
|
||||||
mStyle = textReset->mTextDecorationStyle;
|
mStyle = textReset->mTextDecorationStyle;
|
||||||
mColor = textReset->mTextDecorationColor.CalcColor(aFrame);
|
mColor = textReset->mTextDecorationColor.CalcColor(aFrame);
|
||||||
@@ -708,10 +611,9 @@ TextAttrsMgr::TextDecorValue::
|
|||||||
NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH);
|
NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextAttrsMgr::TextDecorTextAttr::
|
TextAttrsMgr::TextDecorTextAttr::TextDecorTextAttr(nsIFrame* aRootFrame,
|
||||||
TextDecorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
nsIFrame* aFrame)
|
||||||
TTextAttr<TextDecorValue>(!aFrame)
|
: TTextAttr<TextDecorValue>(!aFrame) {
|
||||||
{
|
|
||||||
mRootNativeValue = TextDecorValue(aRootFrame);
|
mRootNativeValue = TextDecorValue(aRootFrame);
|
||||||
mIsRootDefined = mRootNativeValue.IsDefined();
|
mIsRootDefined = mRootNativeValue.IsDefined();
|
||||||
|
|
||||||
@@ -721,10 +623,8 @@ TextAttrsMgr::TextDecorTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::TextDecorTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::TextDecorTextAttr::
|
TextDecorValue* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, TextDecorValue* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
if (elm) {
|
if (elm) {
|
||||||
nsIFrame* frame = elm->GetPrimaryFrame();
|
nsIFrame* frame = elm->GetPrimaryFrame();
|
||||||
@@ -736,15 +636,12 @@ TextAttrsMgr::TextDecorTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::TextDecorTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::TextDecorTextAttr::
|
nsIPersistentProperties* aAttributes, const TextDecorValue& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const TextDecorValue& aValue)
|
|
||||||
{
|
|
||||||
if (aValue.IsUnderline()) {
|
if (aValue.IsUnderline()) {
|
||||||
nsAutoString formattedStyle;
|
nsAutoString formattedStyle;
|
||||||
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
|
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
|
||||||
nsAccUtils::SetAccAttr(aAttributes,
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textUnderlineStyle,
|
||||||
nsGkAtoms::textUnderlineStyle,
|
|
||||||
formattedStyle);
|
formattedStyle);
|
||||||
|
|
||||||
nsAutoString formattedColor;
|
nsAutoString formattedColor;
|
||||||
@@ -757,8 +654,7 @@ TextAttrsMgr::TextDecorTextAttr::
|
|||||||
if (aValue.IsLineThrough()) {
|
if (aValue.IsLineThrough()) {
|
||||||
nsAutoString formattedStyle;
|
nsAutoString formattedStyle;
|
||||||
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
|
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
|
||||||
nsAccUtils::SetAccAttr(aAttributes,
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textLineThroughStyle,
|
||||||
nsGkAtoms::textLineThroughStyle,
|
|
||||||
formattedStyle);
|
formattedStyle);
|
||||||
|
|
||||||
nsAutoString formattedColor;
|
nsAutoString formattedColor;
|
||||||
@@ -772,10 +668,9 @@ TextAttrsMgr::TextDecorTextAttr::
|
|||||||
// TextPosTextAttr
|
// TextPosTextAttr
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TextAttrsMgr::TextPosTextAttr::
|
TextAttrsMgr::TextPosTextAttr::TextPosTextAttr(nsIFrame* aRootFrame,
|
||||||
TextPosTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
nsIFrame* aFrame)
|
||||||
TTextAttr<TextPosValue>(!aFrame)
|
: TTextAttr<TextPosValue>(!aFrame) {
|
||||||
{
|
|
||||||
mRootNativeValue = GetTextPosValue(aRootFrame);
|
mRootNativeValue = GetTextPosValue(aRootFrame);
|
||||||
mIsRootDefined = mRootNativeValue != eTextPosNone;
|
mIsRootDefined = mRootNativeValue != eTextPosNone;
|
||||||
|
|
||||||
@@ -785,10 +680,8 @@ TextAttrsMgr::TextPosTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextAttrsMgr::TextPosTextAttr::GetValueFor(Accessible* aAccessible,
|
||||||
TextAttrsMgr::TextPosTextAttr::
|
TextPosValue* aValue) {
|
||||||
GetValueFor(Accessible* aAccessible, TextPosValue* aValue)
|
|
||||||
{
|
|
||||||
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aAccessible->GetContent());
|
||||||
if (elm) {
|
if (elm) {
|
||||||
nsIFrame* frame = elm->GetPrimaryFrame();
|
nsIFrame* frame = elm->GetPrimaryFrame();
|
||||||
@@ -800,10 +693,8 @@ TextAttrsMgr::TextPosTextAttr::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextAttrsMgr::TextPosTextAttr::ExposeValue(
|
||||||
TextAttrsMgr::TextPosTextAttr::
|
nsIPersistentProperties* aAttributes, const TextPosValue& aValue) {
|
||||||
ExposeValue(nsIPersistentProperties* aAttributes, const TextPosValue& aValue)
|
|
||||||
{
|
|
||||||
switch (aValue) {
|
switch (aValue) {
|
||||||
case eTextPosBaseline:
|
case eTextPosBaseline:
|
||||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition,
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition,
|
||||||
@@ -825,10 +716,8 @@ TextAttrsMgr::TextPosTextAttr::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextAttrsMgr::TextPosValue
|
TextAttrsMgr::TextPosValue TextAttrsMgr::TextPosTextAttr::GetTextPosValue(
|
||||||
TextAttrsMgr::TextPosTextAttr::
|
nsIFrame* aFrame) const {
|
||||||
GetTextPosValue(nsIFrame* aFrame) const
|
|
||||||
{
|
|
||||||
const nsStyleCoord& styleCoord = aFrame->StyleDisplay()->mVerticalAlign;
|
const nsStyleCoord& styleCoord = aFrame->StyleDisplay()->mVerticalAlign;
|
||||||
switch (styleCoord.GetUnit()) {
|
switch (styleCoord.GetUnit()) {
|
||||||
case eStyleUnit_Enumerated:
|
case eStyleUnit_Enumerated:
|
||||||
@@ -854,20 +743,17 @@ TextAttrsMgr::TextPosTextAttr::
|
|||||||
}
|
}
|
||||||
return eTextPosNone;
|
return eTextPosNone;
|
||||||
|
|
||||||
case eStyleUnit_Percent:
|
case eStyleUnit_Percent: {
|
||||||
{
|
|
||||||
float percentValue = styleCoord.GetPercentValue();
|
float percentValue = styleCoord.GetPercentValue();
|
||||||
return percentValue > 0 ?
|
return percentValue > 0
|
||||||
eTextPosSuper :
|
? eTextPosSuper
|
||||||
(percentValue < 0 ? eTextPosSub : eTextPosBaseline);
|
: (percentValue < 0 ? eTextPosSub : eTextPosBaseline);
|
||||||
}
|
}
|
||||||
|
|
||||||
case eStyleUnit_Coord:
|
case eStyleUnit_Coord: {
|
||||||
{
|
|
||||||
nscoord coordValue = styleCoord.GetCoordValue();
|
nscoord coordValue = styleCoord.GetCoordValue();
|
||||||
return coordValue > 0 ?
|
return coordValue > 0 ? eTextPosSuper
|
||||||
eTextPosSuper :
|
: (coordValue < 0 ? eTextPosSub : eTextPosBaseline);
|
||||||
(coordValue < 0 ? eTextPosSub : eTextPosBaseline);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case eStyleUnit_Null:
|
case eStyleUnit_Null:
|
||||||
@@ -884,10 +770,8 @@ TextAttrsMgr::TextPosTextAttr::
|
|||||||
|
|
||||||
const nsIContent* content = aFrame->GetContent();
|
const nsIContent* content = aFrame->GetContent();
|
||||||
if (content) {
|
if (content) {
|
||||||
if (content->IsHTMLElement(nsGkAtoms::sup))
|
if (content->IsHTMLElement(nsGkAtoms::sup)) return eTextPosSuper;
|
||||||
return eTextPosSuper;
|
if (content->IsHTMLElement(nsGkAtoms::sub)) return eTextPosSub;
|
||||||
if (content->IsHTMLElement(nsGkAtoms::sub))
|
|
||||||
return eTextPosSub;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return eTextPosNone;
|
return eTextPosNone;
|
||||||
|
|||||||
@@ -30,15 +30,16 @@ class HyperTextAccessible;
|
|||||||
* @note "invalid: spelling" text attribute is implemented entirely in
|
* @note "invalid: spelling" text attribute is implemented entirely in
|
||||||
* HyperTextAccessible class.
|
* HyperTextAccessible class.
|
||||||
*/
|
*/
|
||||||
class TextAttrsMgr
|
class TextAttrsMgr {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Used to expose default text attributes.
|
* Constructor. Used to expose default text attributes.
|
||||||
*/
|
*/
|
||||||
explicit TextAttrsMgr(HyperTextAccessible* aHyperTextAcc) :
|
explicit TextAttrsMgr(HyperTextAccessible* aHyperTextAcc)
|
||||||
mOffsetAcc(nullptr), mHyperTextAcc(aHyperTextAcc),
|
: mOffsetAcc(nullptr),
|
||||||
mOffsetAccIdx(-1), mIncludeDefAttrs(true) { }
|
mHyperTextAcc(aHyperTextAcc),
|
||||||
|
mOffsetAccIdx(-1),
|
||||||
|
mIncludeDefAttrs(true) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Used to expose text attributes at the given offset.
|
* Constructor. Used to expose text attributes at the given offset.
|
||||||
@@ -52,12 +53,12 @@ public:
|
|||||||
* should be calculated for
|
* should be calculated for
|
||||||
* @param oOffsetAccIdx [optional] index in parent of offset accessible
|
* @param oOffsetAccIdx [optional] index in parent of offset accessible
|
||||||
*/
|
*/
|
||||||
TextAttrsMgr(HyperTextAccessible* aHyperTextAcc,
|
TextAttrsMgr(HyperTextAccessible* aHyperTextAcc, bool aIncludeDefAttrs,
|
||||||
bool aIncludeDefAttrs,
|
Accessible* aOffsetAcc, int32_t aOffsetAccIdx)
|
||||||
Accessible* aOffsetAcc,
|
: mOffsetAcc(aOffsetAcc),
|
||||||
int32_t aOffsetAccIdx) :
|
mHyperTextAcc(aHyperTextAcc),
|
||||||
mOffsetAcc(aOffsetAcc), mHyperTextAcc(aHyperTextAcc),
|
mOffsetAccIdx(aOffsetAccIdx),
|
||||||
mOffsetAccIdx(aOffsetAccIdx), mIncludeDefAttrs(aIncludeDefAttrs) { }
|
mIncludeDefAttrs(aIncludeDefAttrs) {}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return text attributes and hyper text offsets where these attributes are
|
* Return text attributes and hyper text offsets where these attributes are
|
||||||
@@ -74,7 +75,7 @@ public:
|
|||||||
uint32_t* aStartHTOffset = nullptr,
|
uint32_t* aStartHTOffset = nullptr,
|
||||||
uint32_t* aEndHTOffset = nullptr);
|
uint32_t* aEndHTOffset = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Calculates range (start and end offsets) of text where the text attributes
|
* Calculates range (start and end offsets) of text where the text attributes
|
||||||
* are stretched. New offsets may be smaller if one of text attributes changes
|
* are stretched. New offsets may be smaller if one of text attributes changes
|
||||||
@@ -89,19 +90,17 @@ protected:
|
|||||||
void GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
void GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
||||||
uint32_t* aStartOffset, uint32_t* aEndOffset);
|
uint32_t* aStartOffset, uint32_t* aEndOffset);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Accessible* mOffsetAcc;
|
Accessible* mOffsetAcc;
|
||||||
HyperTextAccessible* mHyperTextAcc;
|
HyperTextAccessible* mHyperTextAcc;
|
||||||
int32_t mOffsetAccIdx;
|
int32_t mOffsetAccIdx;
|
||||||
bool mIncludeDefAttrs;
|
bool mIncludeDefAttrs;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface class of text attribute class implementations.
|
* Interface class of text attribute class implementations.
|
||||||
*/
|
*/
|
||||||
class TextAttr
|
class TextAttr {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Expose the text attribute to the given attribute set.
|
* Expose the text attribute to the given attribute set.
|
||||||
@@ -120,23 +119,19 @@ protected:
|
|||||||
virtual bool Equal(Accessible* aAccessible) = 0;
|
virtual bool Equal(Accessible* aAccessible) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class to work with text attributes. See derived classes below.
|
* Base class to work with text attributes. See derived classes below.
|
||||||
*/
|
*/
|
||||||
template<class T>
|
template <class T>
|
||||||
class TTextAttr : public TextAttr
|
class TTextAttr : public TextAttr {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
explicit TTextAttr(bool aGetRootValue) : mGetRootValue(aGetRootValue) {}
|
explicit TTextAttr(bool aGetRootValue) : mGetRootValue(aGetRootValue) {}
|
||||||
|
|
||||||
// TextAttr
|
// TextAttr
|
||||||
virtual void Expose(nsIPersistentProperties* aAttributes,
|
virtual void Expose(nsIPersistentProperties* aAttributes,
|
||||||
bool aIncludeDefAttrValue) override
|
bool aIncludeDefAttrValue) override {
|
||||||
{
|
|
||||||
if (mGetRootValue) {
|
if (mGetRootValue) {
|
||||||
if (mIsRootDefined)
|
if (mIsRootDefined) ExposeValue(aAttributes, mRootNativeValue);
|
||||||
ExposeValue(aAttributes, mRootNativeValue);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,25 +145,20 @@ protected:
|
|||||||
ExposeValue(aAttributes, mRootNativeValue);
|
ExposeValue(aAttributes, mRootNativeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Equal(Accessible* aAccessible) override
|
virtual bool Equal(Accessible* aAccessible) override {
|
||||||
{
|
|
||||||
T nativeValue;
|
T nativeValue;
|
||||||
bool isDefined = GetValueFor(aAccessible, &nativeValue);
|
bool isDefined = GetValueFor(aAccessible, &nativeValue);
|
||||||
|
|
||||||
if (!mIsDefined && !isDefined)
|
if (!mIsDefined && !isDefined) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
if (mIsDefined && isDefined)
|
if (mIsDefined && isDefined) return nativeValue == mNativeValue;
|
||||||
return nativeValue == mNativeValue;
|
|
||||||
|
|
||||||
if (mIsDefined)
|
if (mIsDefined) return mNativeValue == mRootNativeValue;
|
||||||
return mNativeValue == mRootNativeValue;
|
|
||||||
|
|
||||||
return nativeValue == mRootNativeValue;
|
return nativeValue == mRootNativeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Expose the text attribute with the given value to attribute set.
|
// Expose the text attribute with the given value to attribute set.
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const T& aValue) = 0;
|
const T& aValue) = 0;
|
||||||
@@ -185,27 +175,25 @@ protected:
|
|||||||
MOZ_INIT_OUTSIDE_CTOR T mNativeValue;
|
MOZ_INIT_OUTSIDE_CTOR T mNativeValue;
|
||||||
MOZ_INIT_OUTSIDE_CTOR bool mIsDefined;
|
MOZ_INIT_OUTSIDE_CTOR bool mIsDefined;
|
||||||
|
|
||||||
// Native root value and flag indicating if the value is defined (initialized
|
// Native root value and flag indicating if the value is defined
|
||||||
// in derived classes).
|
// (initialized in derived classes).
|
||||||
MOZ_INIT_OUTSIDE_CTOR T mRootNativeValue;
|
MOZ_INIT_OUTSIDE_CTOR T mRootNativeValue;
|
||||||
MOZ_INIT_OUTSIDE_CTOR bool mIsRootDefined;
|
MOZ_INIT_OUTSIDE_CTOR bool mIsRootDefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is used for the work with 'language' text attribute.
|
* Class is used for the work with 'language' text attribute.
|
||||||
*/
|
*/
|
||||||
class LangTextAttr : public TTextAttr<nsString>
|
class LangTextAttr : public TTextAttr<nsString> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
LangTextAttr(HyperTextAccessible* aRoot, nsIContent* aRootElm,
|
LangTextAttr(HyperTextAccessible* aRoot, nsIContent* aRootElm,
|
||||||
nsIContent* aElm);
|
nsIContent* aElm);
|
||||||
virtual ~LangTextAttr();
|
virtual ~LangTextAttr();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TextAttr
|
// TextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, nsString* aValue) override;
|
virtual bool GetValueFor(Accessible* aAccessible,
|
||||||
|
nsString* aValue) override;
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const nsString& aValue) override;
|
const nsString& aValue) override;
|
||||||
|
|
||||||
@@ -213,30 +201,23 @@ protected:
|
|||||||
nsCOMPtr<nsIContent> mRootContent;
|
nsCOMPtr<nsIContent> mRootContent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is used for the 'invalid' text attribute. Note, it calculated
|
* Class is used for the 'invalid' text attribute. Note, it calculated
|
||||||
* the attribute from aria-invalid attribute only; invalid:spelling attribute
|
* the attribute from aria-invalid attribute only; invalid:spelling attribute
|
||||||
* calculated from misspelled text in the editor is managed by
|
* calculated from misspelled text in the editor is managed by
|
||||||
* HyperTextAccessible and applied on top of the value from aria-invalid.
|
* HyperTextAccessible and applied on top of the value from aria-invalid.
|
||||||
*/
|
*/
|
||||||
class InvalidTextAttr : public TTextAttr<uint32_t>
|
class InvalidTextAttr : public TTextAttr<uint32_t> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
InvalidTextAttr(nsIContent* aRootElm, nsIContent* aElm);
|
InvalidTextAttr(nsIContent* aRootElm, nsIContent* aElm);
|
||||||
virtual ~InvalidTextAttr() { };
|
virtual ~InvalidTextAttr(){};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
enum { eFalse, eGrammar, eSpelling, eTrue };
|
||||||
enum {
|
|
||||||
eFalse,
|
|
||||||
eGrammar,
|
|
||||||
eSpelling,
|
|
||||||
eTrue
|
|
||||||
};
|
|
||||||
|
|
||||||
// TextAttr
|
// TextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, uint32_t* aValue) override;
|
virtual bool GetValueFor(Accessible* aAccessible,
|
||||||
|
uint32_t* aValue) override;
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const uint32_t& aValue) override;
|
const uint32_t& aValue) override;
|
||||||
|
|
||||||
@@ -245,21 +226,17 @@ protected:
|
|||||||
nsIContent* mRootElm;
|
nsIContent* mRootElm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is used for the work with 'background-color' text attribute.
|
* Class is used for the work with 'background-color' text attribute.
|
||||||
*/
|
*/
|
||||||
class BGColorTextAttr : public TTextAttr<nscolor>
|
class BGColorTextAttr : public TTextAttr<nscolor> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BGColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
BGColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||||
virtual ~BGColorTextAttr() { }
|
virtual ~BGColorTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TextAttr
|
// TextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, nscolor* aValue)
|
virtual bool GetValueFor(Accessible* aAccessible, nscolor* aValue) override;
|
||||||
override;
|
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const nscolor& aValue) override;
|
const nscolor& aValue) override;
|
||||||
|
|
||||||
@@ -268,63 +245,51 @@ protected:
|
|||||||
nsIFrame* mRootFrame;
|
nsIFrame* mRootFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is used for the work with 'color' text attribute.
|
* Class is used for the work with 'color' text attribute.
|
||||||
*/
|
*/
|
||||||
class ColorTextAttr : public TTextAttr<nscolor>
|
class ColorTextAttr : public TTextAttr<nscolor> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
ColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
ColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||||
virtual ~ColorTextAttr() { }
|
virtual ~ColorTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TTextAttr
|
// TTextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, nscolor* aValue)
|
virtual bool GetValueFor(Accessible* aAccessible, nscolor* aValue) override;
|
||||||
override;
|
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const nscolor& aValue) override;
|
const nscolor& aValue) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is used for the work with "font-family" text attribute.
|
* Class is used for the work with "font-family" text attribute.
|
||||||
*/
|
*/
|
||||||
class FontFamilyTextAttr : public TTextAttr<nsString>
|
class FontFamilyTextAttr : public TTextAttr<nsString> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FontFamilyTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
FontFamilyTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||||
virtual ~FontFamilyTextAttr() { }
|
virtual ~FontFamilyTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TTextAttr
|
// TTextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, nsString* aValue)
|
virtual bool GetValueFor(Accessible* aAccessible,
|
||||||
override;
|
nsString* aValue) override;
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const nsString& aValue) override;
|
const nsString& aValue) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool GetFontFamily(nsIFrame* aFrame, nsString& aFamily);
|
bool GetFontFamily(nsIFrame* aFrame, nsString& aFamily);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is used for the work with "font-size" text attribute.
|
* Class is used for the work with "font-size" text attribute.
|
||||||
*/
|
*/
|
||||||
class FontSizeTextAttr : public TTextAttr<nscoord>
|
class FontSizeTextAttr : public TTextAttr<nscoord> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FontSizeTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
FontSizeTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||||
virtual ~FontSizeTextAttr() { }
|
virtual ~FontSizeTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TTextAttr
|
// TTextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, nscoord* aValue)
|
virtual bool GetValueFor(Accessible* aAccessible, nscoord* aValue) override;
|
||||||
override;
|
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const nscoord& aValue) override;
|
const nscoord& aValue) override;
|
||||||
|
|
||||||
@@ -332,41 +297,34 @@ protected:
|
|||||||
nsDeviceContext* mDC;
|
nsDeviceContext* mDC;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is used for the work with "font-style" text attribute.
|
* Class is used for the work with "font-style" text attribute.
|
||||||
*/
|
*/
|
||||||
class FontStyleTextAttr : public TTextAttr<mozilla::FontSlantStyle>
|
class FontStyleTextAttr : public TTextAttr<mozilla::FontSlantStyle> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FontStyleTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
FontStyleTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||||
virtual ~FontStyleTextAttr() { }
|
virtual ~FontStyleTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TTextAttr
|
// TTextAttr
|
||||||
virtual bool GetValueFor(Accessible* aContent, mozilla::FontSlantStyle* aValue)
|
virtual bool GetValueFor(Accessible* aContent,
|
||||||
override;
|
mozilla::FontSlantStyle* aValue) override;
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const mozilla::FontSlantStyle& aValue) override;
|
const mozilla::FontSlantStyle& aValue) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is used for the work with "font-weight" text attribute.
|
* Class is used for the work with "font-weight" text attribute.
|
||||||
*/
|
*/
|
||||||
class FontWeightTextAttr : public TTextAttr<mozilla::FontWeight>
|
class FontWeightTextAttr : public TTextAttr<mozilla::FontWeight> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FontWeightTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
FontWeightTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||||
virtual ~FontWeightTextAttr() { }
|
virtual ~FontWeightTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TTextAttr
|
// TTextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible,
|
virtual bool GetValueFor(Accessible* aAccessible,
|
||||||
mozilla::FontWeight* aValue)
|
mozilla::FontWeight* aValue) override;
|
||||||
override;
|
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const mozilla::FontWeight& aValue) override;
|
const mozilla::FontWeight& aValue) override;
|
||||||
|
|
||||||
@@ -377,53 +335,49 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* Class is used for the work with 'auto-generated' text attribute.
|
* Class is used for the work with 'auto-generated' text attribute.
|
||||||
*/
|
*/
|
||||||
class AutoGeneratedTextAttr : public TTextAttr<bool>
|
class AutoGeneratedTextAttr : public TTextAttr<bool> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
AutoGeneratedTextAttr(HyperTextAccessible* aHyperTextAcc,
|
AutoGeneratedTextAttr(HyperTextAccessible* aHyperTextAcc,
|
||||||
Accessible* aAccessible);
|
Accessible* aAccessible);
|
||||||
virtual ~AutoGeneratedTextAttr() { }
|
virtual ~AutoGeneratedTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// TextAttr
|
// TextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, bool* aValue)
|
virtual bool GetValueFor(Accessible* aAccessible, bool* aValue) override;
|
||||||
override;
|
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const bool& aValue) override;
|
const bool& aValue) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TextDecorTextAttr class is used for the work with
|
* TextDecorTextAttr class is used for the work with
|
||||||
* "text-line-through-style", "text-line-through-color",
|
* "text-line-through-style", "text-line-through-color",
|
||||||
* "text-underline-style" and "text-underline-color" text attributes.
|
* "text-underline-style" and "text-underline-color" text attributes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TextDecorValue
|
class TextDecorValue {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
TextDecorValue() :
|
TextDecorValue()
|
||||||
mColor{0}, mLine{NS_STYLE_TEXT_DECORATION_LINE_NONE},
|
: mColor{0},
|
||||||
mStyle{NS_STYLE_TEXT_DECORATION_STYLE_NONE} { }
|
mLine{NS_STYLE_TEXT_DECORATION_LINE_NONE},
|
||||||
|
mStyle{NS_STYLE_TEXT_DECORATION_STYLE_NONE} {}
|
||||||
explicit TextDecorValue(nsIFrame* aFrame);
|
explicit TextDecorValue(nsIFrame* aFrame);
|
||||||
|
|
||||||
nscolor Color() const { return mColor; }
|
nscolor Color() const { return mColor; }
|
||||||
uint8_t Style() const { return mStyle; }
|
uint8_t Style() const { return mStyle; }
|
||||||
|
|
||||||
bool IsDefined() const
|
bool IsDefined() const { return IsUnderline() || IsLineThrough(); }
|
||||||
{ return IsUnderline() || IsLineThrough(); }
|
bool IsUnderline() const {
|
||||||
bool IsUnderline() const
|
return mLine & NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE;
|
||||||
{ return mLine & NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE; }
|
}
|
||||||
bool IsLineThrough() const
|
bool IsLineThrough() const {
|
||||||
{ return mLine & NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH; }
|
return mLine & NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator ==(const TextDecorValue& aValue)
|
bool operator==(const TextDecorValue& aValue) {
|
||||||
{
|
|
||||||
return mColor == aValue.mColor && mLine == aValue.mLine &&
|
return mColor == aValue.mColor && mLine == aValue.mLine &&
|
||||||
mStyle == aValue.mStyle;
|
mStyle == aValue.mStyle;
|
||||||
}
|
}
|
||||||
bool operator !=(const TextDecorValue& aValue)
|
bool operator!=(const TextDecorValue& aValue) { return !(*this == aValue); }
|
||||||
{ return !(*this == aValue); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nscolor mColor;
|
nscolor mColor;
|
||||||
@@ -431,17 +385,15 @@ protected:
|
|||||||
uint8_t mStyle;
|
uint8_t mStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextDecorTextAttr : public TTextAttr<TextDecorValue>
|
class TextDecorTextAttr : public TTextAttr<TextDecorValue> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
TextDecorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
TextDecorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||||
virtual ~TextDecorTextAttr() { }
|
virtual ~TextDecorTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TextAttr
|
// TextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, TextDecorValue* aValue)
|
virtual bool GetValueFor(Accessible* aAccessible,
|
||||||
override;
|
TextDecorValue* aValue) override;
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const TextDecorValue& aValue) override;
|
const TextDecorValue& aValue) override;
|
||||||
};
|
};
|
||||||
@@ -457,17 +409,15 @@ protected:
|
|||||||
eTextPosSuper
|
eTextPosSuper
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextPosTextAttr : public TTextAttr<TextPosValue>
|
class TextPosTextAttr : public TTextAttr<TextPosValue> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
TextPosTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
TextPosTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||||
virtual ~TextPosTextAttr() { }
|
virtual ~TextPosTextAttr() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// TextAttr
|
// TextAttr
|
||||||
virtual bool GetValueFor(Accessible* aAccessible, TextPosValue* aValue)
|
virtual bool GetValueFor(Accessible* aAccessible,
|
||||||
override;
|
TextPosValue* aValue) override;
|
||||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||||
const TextPosValue& aValue) override;
|
const TextPosValue& aValue) override;
|
||||||
|
|
||||||
|
|||||||
@@ -13,16 +13,13 @@
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
inline Accessible*
|
inline Accessible* TextRange::Container() const {
|
||||||
TextRange::Container() const
|
|
||||||
{
|
|
||||||
uint32_t pos1 = 0, pos2 = 0;
|
uint32_t pos1 = 0, pos2 = 0;
|
||||||
AutoTArray<Accessible*, 30> parents1, parents2;
|
AutoTArray<Accessible*, 30> parents1, parents2;
|
||||||
return CommonParent(mStartContainer, mEndContainer,
|
return CommonParent(mStartContainer, mEndContainer, &parents1, &pos1,
|
||||||
&parents1, &pos1, &parents2, &pos2);
|
&parents2, &pos2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,8 @@ namespace a11y {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TextPoint
|
// TextPoint
|
||||||
|
|
||||||
bool
|
bool TextPoint::operator<(const TextPoint& aPoint) const {
|
||||||
TextPoint::operator <(const TextPoint& aPoint) const
|
if (mContainer == aPoint.mContainer) return mOffset < aPoint.mOffset;
|
||||||
{
|
|
||||||
if (mContainer == aPoint.mContainer)
|
|
||||||
return mOffset < aPoint.mOffset;
|
|
||||||
|
|
||||||
// Build the chain of parents
|
// Build the chain of parents
|
||||||
Accessible* p1 = mContainer;
|
Accessible* p1 = mContainer;
|
||||||
@@ -52,15 +49,14 @@ TextPoint::operator <(const TextPoint& aPoint) const
|
|||||||
|
|
||||||
TextRange::TextRange(HyperTextAccessible* aRoot,
|
TextRange::TextRange(HyperTextAccessible* aRoot,
|
||||||
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
|
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
|
||||||
HyperTextAccessible* aEndContainer, int32_t aEndOffset) :
|
HyperTextAccessible* aEndContainer, int32_t aEndOffset)
|
||||||
mRoot(aRoot), mStartContainer(aStartContainer), mEndContainer(aEndContainer),
|
: mRoot(aRoot),
|
||||||
mStartOffset(aStartOffset), mEndOffset(aEndOffset)
|
mStartContainer(aStartContainer),
|
||||||
{
|
mEndContainer(aEndContainer),
|
||||||
}
|
mStartOffset(aStartOffset),
|
||||||
|
mEndOffset(aEndOffset) {}
|
||||||
|
|
||||||
void
|
void TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const {
|
||||||
TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
|
|
||||||
{
|
|
||||||
if (mStartContainer == mEndContainer) {
|
if (mStartContainer == mEndContainer) {
|
||||||
int32_t startIdx = mStartContainer->GetChildIndexAtOffset(mStartOffset);
|
int32_t startIdx = mStartContainer->GetChildIndexAtOffset(mStartOffset);
|
||||||
int32_t endIdx = mStartContainer->GetChildIndexAtOffset(mEndOffset);
|
int32_t endIdx = mStartContainer->GetChildIndexAtOffset(mEndOffset);
|
||||||
@@ -86,7 +82,8 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
|
|||||||
Accessible* parent = parents1[idx + 1];
|
Accessible* parent = parents1[idx + 1];
|
||||||
Accessible* child = parents1[idx];
|
Accessible* child = parents1[idx];
|
||||||
uint32_t childCount = parent->ChildCount();
|
uint32_t childCount = parent->ChildCount();
|
||||||
for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount; childIdx++) {
|
for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount;
|
||||||
|
childIdx++) {
|
||||||
Accessible* next = parent->GetChildAt(childIdx);
|
Accessible* next = parent->GetChildAt(childIdx);
|
||||||
if (!next->IsText()) {
|
if (!next->IsText()) {
|
||||||
aChildren->AppendElement(next);
|
aChildren->AppendElement(next);
|
||||||
@@ -118,37 +115,24 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextRange::Text(nsAString& aText) const {
|
||||||
TextRange::Text(nsAString& aText) const
|
|
||||||
{
|
|
||||||
Accessible* current = mStartContainer->GetChildAtOffset(mStartOffset);
|
Accessible* current = mStartContainer->GetChildAtOffset(mStartOffset);
|
||||||
uint32_t startIntlOffset =
|
uint32_t startIntlOffset =
|
||||||
mStartOffset - mStartContainer->GetChildOffset(current);
|
mStartOffset - mStartContainer->GetChildOffset(current);
|
||||||
|
|
||||||
while (current && TextInternal(aText, current, startIntlOffset)) {
|
while (current && TextInternal(aText, current, startIntlOffset)) {
|
||||||
current = current->Parent();
|
current = current->Parent();
|
||||||
if (!current)
|
if (!current) break;
|
||||||
break;
|
|
||||||
|
|
||||||
current = current->NextSibling();
|
current = current->NextSibling();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextRange::Bounds(nsTArray<nsIntRect> aRects) const {}
|
||||||
TextRange::Bounds(nsTArray<nsIntRect> aRects) const
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void TextRange::Normalize(ETextUnit aUnit) {}
|
||||||
|
|
||||||
void
|
bool TextRange::Crop(Accessible* aContainer) {
|
||||||
TextRange::Normalize(ETextUnit aUnit)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TextRange::Crop(Accessible* aContainer)
|
|
||||||
{
|
|
||||||
uint32_t boundaryPos = 0, containerPos = 0;
|
uint32_t boundaryPos = 0, containerPos = 0;
|
||||||
AutoTArray<Accessible*, 30> boundaryParents, containerParents;
|
AutoTArray<Accessible*, 30> boundaryParents, containerParents;
|
||||||
|
|
||||||
@@ -163,15 +147,14 @@ TextRange::Crop(Accessible* aContainer)
|
|||||||
if (containerPos != 0) {
|
if (containerPos != 0) {
|
||||||
// The container is contained by the start boundary, reduce the range to
|
// The container is contained by the start boundary, reduce the range to
|
||||||
// the point starting at the container.
|
// the point starting at the container.
|
||||||
aContainer->ToTextPoint(mStartContainer.StartAssignment(), &mStartOffset);
|
aContainer->ToTextPoint(mStartContainer.StartAssignment(),
|
||||||
|
&mStartOffset);
|
||||||
static_cast<Accessible*>(mStartContainer)->AddRef();
|
static_cast<Accessible*>(mStartContainer)->AddRef();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// The start boundary and the container are siblings.
|
// The start boundary and the container are siblings.
|
||||||
container = aContainer;
|
container = aContainer;
|
||||||
}
|
}
|
||||||
}
|
} else if (containerPos != 0) {
|
||||||
else if (containerPos != 0) {
|
|
||||||
// The container does not contain the start boundary.
|
// The container does not contain the start boundary.
|
||||||
boundary = boundaryParents[boundaryPos];
|
boundary = boundaryParents[boundaryPos];
|
||||||
container = containerParents[containerPos];
|
container = containerParents[containerPos];
|
||||||
@@ -186,7 +169,8 @@ TextRange::Crop(Accessible* aContainer)
|
|||||||
// If the range starts before the container, then reduce the range to
|
// If the range starts before the container, then reduce the range to
|
||||||
// the point starting at the container.
|
// the point starting at the container.
|
||||||
if (boundary->IndexInParent() < container->IndexInParent()) {
|
if (boundary->IndexInParent() < container->IndexInParent()) {
|
||||||
container->ToTextPoint(mStartContainer.StartAssignment(), &mStartOffset);
|
container->ToTextPoint(mStartContainer.StartAssignment(),
|
||||||
|
&mStartOffset);
|
||||||
mStartContainer.get()->AddRef();
|
mStartContainer.get()->AddRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,14 +191,13 @@ TextRange::Crop(Accessible* aContainer)
|
|||||||
|
|
||||||
if (boundaryPos == 0) {
|
if (boundaryPos == 0) {
|
||||||
if (containerPos != 0) {
|
if (containerPos != 0) {
|
||||||
aContainer->ToTextPoint(mEndContainer.StartAssignment(), &mEndOffset, false);
|
aContainer->ToTextPoint(mEndContainer.StartAssignment(), &mEndOffset,
|
||||||
|
false);
|
||||||
static_cast<Accessible*>(mEndContainer)->AddRef();
|
static_cast<Accessible*>(mEndContainer)->AddRef();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
container = aContainer;
|
container = aContainer;
|
||||||
}
|
}
|
||||||
}
|
} else if (containerPos != 0) {
|
||||||
else if (containerPos != 0) {
|
|
||||||
boundary = boundaryParents[boundaryPos];
|
boundary = boundaryParents[boundaryPos];
|
||||||
container = containerParents[containerPos];
|
container = containerParents[containerPos];
|
||||||
}
|
}
|
||||||
@@ -235,51 +218,27 @@ TextRange::Crop(Accessible* aContainer)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextRange::FindText(const nsAString& aText, EDirection aDirection,
|
||||||
TextRange::FindText(const nsAString& aText, EDirection aDirection,
|
nsCaseTreatment aCaseSensitive,
|
||||||
nsCaseTreatment aCaseSensitive, TextRange* aFoundRange) const
|
TextRange* aFoundRange) const {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void TextRange::FindAttr(EAttr aAttr, nsIVariant* aValue, EDirection aDirection,
|
||||||
|
TextRange* aFoundRange) const {}
|
||||||
|
|
||||||
void
|
void TextRange::AddToSelection() const {}
|
||||||
TextRange::FindAttr(EAttr aAttr, nsIVariant* aValue, EDirection aDirection,
|
|
||||||
TextRange* aFoundRange) const
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void TextRange::RemoveFromSelection() const {}
|
||||||
|
|
||||||
void
|
void TextRange::Select() const {}
|
||||||
TextRange::AddToSelection() const
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void TextRange::ScrollIntoView(EHowToAlign aHow) const {}
|
||||||
|
|
||||||
void
|
|
||||||
TextRange::RemoveFromSelection() const
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextRange::Select() const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextRange::ScrollIntoView(EHowToAlign aHow) const
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// pivate
|
// pivate
|
||||||
|
|
||||||
void
|
void TextRange::Set(HyperTextAccessible* aRoot,
|
||||||
TextRange::Set(HyperTextAccessible* aRoot,
|
|
||||||
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
|
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
|
||||||
HyperTextAccessible* aEndContainer, int32_t aEndOffset)
|
HyperTextAccessible* aEndContainer, int32_t aEndOffset) {
|
||||||
{
|
|
||||||
mRoot = aRoot;
|
mRoot = aRoot;
|
||||||
mStartContainer = aStartContainer;
|
mStartContainer = aStartContainer;
|
||||||
mEndContainer = aEndContainer;
|
mEndContainer = aEndContainer;
|
||||||
@@ -287,19 +246,15 @@ TextRange::Set(HyperTextAccessible* aRoot,
|
|||||||
mEndOffset = aEndOffset;
|
mEndOffset = aEndOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TextRange::TextInternal(nsAString& aText, Accessible* aCurrent,
|
||||||
TextRange::TextInternal(nsAString& aText, Accessible* aCurrent,
|
uint32_t aStartIntlOffset) const {
|
||||||
uint32_t aStartIntlOffset) const
|
|
||||||
{
|
|
||||||
bool moveNext = true;
|
bool moveNext = true;
|
||||||
int32_t endIntlOffset = -1;
|
int32_t endIntlOffset = -1;
|
||||||
if (aCurrent->Parent() == mEndContainer &&
|
if (aCurrent->Parent() == mEndContainer &&
|
||||||
mEndContainer->GetChildAtOffset(mEndOffset) == aCurrent) {
|
mEndContainer->GetChildAtOffset(mEndOffset) == aCurrent) {
|
||||||
|
|
||||||
uint32_t currentStartOffset = mEndContainer->GetChildOffset(aCurrent);
|
uint32_t currentStartOffset = mEndContainer->GetChildOffset(aCurrent);
|
||||||
endIntlOffset = mEndOffset - currentStartOffset;
|
endIntlOffset = mEndOffset - currentStartOffset;
|
||||||
if (endIntlOffset == 0)
|
if (endIntlOffset == 0) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
moveNext = false;
|
moveNext = false;
|
||||||
}
|
}
|
||||||
@@ -307,39 +262,32 @@ TextRange::TextInternal(nsAString& aText, Accessible* aCurrent,
|
|||||||
if (aCurrent->IsTextLeaf()) {
|
if (aCurrent->IsTextLeaf()) {
|
||||||
aCurrent->AppendTextTo(aText, aStartIntlOffset,
|
aCurrent->AppendTextTo(aText, aStartIntlOffset,
|
||||||
endIntlOffset - aStartIntlOffset);
|
endIntlOffset - aStartIntlOffset);
|
||||||
if (!moveNext)
|
if (!moveNext) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible* next = aCurrent->FirstChild();
|
Accessible* next = aCurrent->FirstChild();
|
||||||
if (next) {
|
if (next) {
|
||||||
if (!TextInternal(aText, next, 0))
|
if (!TextInternal(aText, next, 0)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next = aCurrent->NextSibling();
|
next = aCurrent->NextSibling();
|
||||||
if (next) {
|
if (next) {
|
||||||
if (!TextInternal(aText, next, 0))
|
if (!TextInternal(aText, next, 0)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return moveNext;
|
return moveNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextRange::MoveInternal(ETextUnit aUnit, int32_t aCount,
|
||||||
void
|
|
||||||
TextRange::MoveInternal(ETextUnit aUnit, int32_t aCount,
|
|
||||||
HyperTextAccessible& aContainer, int32_t aOffset,
|
HyperTextAccessible& aContainer, int32_t aOffset,
|
||||||
HyperTextAccessible* aStopContainer, int32_t aStopOffset)
|
HyperTextAccessible* aStopContainer,
|
||||||
{
|
int32_t aStopOffset) {}
|
||||||
|
|
||||||
}
|
Accessible* TextRange::CommonParent(Accessible* aAcc1, Accessible* aAcc2,
|
||||||
|
nsTArray<Accessible*>* aParents1,
|
||||||
Accessible*
|
uint32_t* aPos1,
|
||||||
TextRange::CommonParent(Accessible* aAcc1, Accessible* aAcc2,
|
nsTArray<Accessible*>* aParents2,
|
||||||
nsTArray<Accessible*>* aParents1, uint32_t* aPos1,
|
uint32_t* aPos2) const {
|
||||||
nsTArray<Accessible*>* aParents2, uint32_t* aPos2) const
|
|
||||||
{
|
|
||||||
if (aAcc1 == aAcc2) {
|
if (aAcc1 == aAcc2) {
|
||||||
return aAcc1;
|
return aAcc1;
|
||||||
}
|
}
|
||||||
@@ -367,8 +315,7 @@ TextRange::CommonParent(Accessible* aAcc1, Accessible* aAcc2,
|
|||||||
for (len = std::min(*aPos1, *aPos2); len > 0; --len) {
|
for (len = std::min(*aPos1, *aPos2); len > 0; --len) {
|
||||||
Accessible* child1 = aParents1->ElementAt(--(*aPos1));
|
Accessible* child1 = aParents1->ElementAt(--(*aPos1));
|
||||||
Accessible* child2 = aParents2->ElementAt(--(*aPos2));
|
Accessible* child2 = aParents2->ElementAt(--(*aPos2));
|
||||||
if (child1 != child2)
|
if (child1 != child2) break;
|
||||||
break;
|
|
||||||
|
|
||||||
parent = child1;
|
parent = child1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "nsRect.h"
|
#include "nsRect.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
|
|
||||||
class nsIVariant;
|
class nsIVariant;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
@@ -23,39 +23,38 @@ class HyperTextAccessible;
|
|||||||
/**
|
/**
|
||||||
* A text point (hyper text + offset), represents a boundary of text range.
|
* A text point (hyper text + offset), represents a boundary of text range.
|
||||||
*/
|
*/
|
||||||
struct TextPoint final
|
struct TextPoint final {
|
||||||
{
|
TextPoint(HyperTextAccessible* aContainer, int32_t aOffset)
|
||||||
TextPoint(HyperTextAccessible* aContainer, int32_t aOffset) :
|
: mContainer(aContainer), mOffset(aOffset) {}
|
||||||
mContainer(aContainer), mOffset(aOffset) { }
|
TextPoint(const TextPoint& aPoint)
|
||||||
TextPoint(const TextPoint& aPoint) :
|
: mContainer(aPoint.mContainer), mOffset(aPoint.mOffset) {}
|
||||||
mContainer(aPoint.mContainer), mOffset(aPoint.mOffset) { }
|
|
||||||
|
|
||||||
HyperTextAccessible* mContainer;
|
HyperTextAccessible* mContainer;
|
||||||
int32_t mOffset;
|
int32_t mOffset;
|
||||||
|
|
||||||
bool operator ==(const TextPoint& aPoint) const
|
bool operator==(const TextPoint& aPoint) const {
|
||||||
{ return mContainer == aPoint.mContainer && mOffset == aPoint.mOffset; }
|
return mContainer == aPoint.mContainer && mOffset == aPoint.mOffset;
|
||||||
bool operator <(const TextPoint& aPoint) const;
|
}
|
||||||
|
bool operator<(const TextPoint& aPoint) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a text range within the text control or document.
|
* Represents a text range within the text control or document.
|
||||||
*/
|
*/
|
||||||
class TextRange final
|
class TextRange final {
|
||||||
{
|
public:
|
||||||
public:
|
TextRange(HyperTextAccessible* aRoot, HyperTextAccessible* aStartContainer,
|
||||||
TextRange(HyperTextAccessible* aRoot,
|
int32_t aStartOffset, HyperTextAccessible* aEndContainer,
|
||||||
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
|
int32_t aEndOffset);
|
||||||
HyperTextAccessible* aEndContainer, int32_t aEndOffset);
|
|
||||||
TextRange() : mStartOffset{0}, mEndOffset{0} {}
|
TextRange() : mStartOffset{0}, mEndOffset{0} {}
|
||||||
TextRange(TextRange&& aRange) :
|
TextRange(TextRange&& aRange)
|
||||||
mRoot(std::move(aRange.mRoot)),
|
: mRoot(std::move(aRange.mRoot)),
|
||||||
mStartContainer(std::move(aRange.mStartContainer)),
|
mStartContainer(std::move(aRange.mStartContainer)),
|
||||||
mEndContainer(std::move(aRange.mEndContainer)),
|
mEndContainer(std::move(aRange.mEndContainer)),
|
||||||
mStartOffset(aRange.mStartOffset), mEndOffset(aRange.mEndOffset) {}
|
mStartOffset(aRange.mStartOffset),
|
||||||
|
mEndOffset(aRange.mEndOffset) {}
|
||||||
|
|
||||||
TextRange& operator= (TextRange&& aRange)
|
TextRange& operator=(TextRange&& aRange) {
|
||||||
{
|
|
||||||
mRoot = std::move(aRange.mRoot);
|
mRoot = std::move(aRange.mRoot);
|
||||||
mStartContainer = std::move(aRange.mStartContainer);
|
mStartContainer = std::move(aRange.mStartContainer);
|
||||||
mEndContainer = std::move(aRange.mEndContainer);
|
mEndContainer = std::move(aRange.mEndContainer);
|
||||||
@@ -69,14 +68,16 @@ public:
|
|||||||
HyperTextAccessible* EndContainer() const { return mEndContainer; }
|
HyperTextAccessible* EndContainer() const { return mEndContainer; }
|
||||||
int32_t EndOffset() const { return mEndOffset; }
|
int32_t EndOffset() const { return mEndOffset; }
|
||||||
|
|
||||||
bool operator ==(const TextRange& aRange) const
|
bool operator==(const TextRange& aRange) const {
|
||||||
{
|
|
||||||
return mStartContainer == aRange.mStartContainer &&
|
return mStartContainer == aRange.mStartContainer &&
|
||||||
mStartOffset == aRange.mStartOffset &&
|
mStartOffset == aRange.mStartOffset &&
|
||||||
mEndContainer == aRange.mEndContainer && mEndOffset == aRange.mEndOffset;
|
mEndContainer == aRange.mEndContainer &&
|
||||||
|
mEndOffset == aRange.mEndOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextPoint StartPoint() const { return TextPoint(mStartContainer, mStartOffset); }
|
TextPoint StartPoint() const {
|
||||||
|
return TextPoint(mStartContainer, mStartOffset);
|
||||||
|
}
|
||||||
TextPoint EndPoint() const { return TextPoint(mEndContainer, mEndOffset); }
|
TextPoint EndPoint() const { return TextPoint(mEndContainer, mEndOffset); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,30 +101,22 @@ public:
|
|||||||
*/
|
*/
|
||||||
void Bounds(nsTArray<nsIntRect> aRects) const;
|
void Bounds(nsTArray<nsIntRect> aRects) const;
|
||||||
|
|
||||||
enum ETextUnit {
|
enum ETextUnit { eFormat, eWord, eLine, eParagraph, ePage, eDocument };
|
||||||
eFormat,
|
|
||||||
eWord,
|
|
||||||
eLine,
|
|
||||||
eParagraph,
|
|
||||||
ePage,
|
|
||||||
eDocument
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the range or its points on specified amount of given units.
|
* Move the range or its points on specified amount of given units.
|
||||||
*/
|
*/
|
||||||
void Move(ETextUnit aUnit, int32_t aCount)
|
void Move(ETextUnit aUnit, int32_t aCount) {
|
||||||
{
|
|
||||||
MoveEnd(aUnit, aCount);
|
MoveEnd(aUnit, aCount);
|
||||||
MoveStart(aUnit, aCount);
|
MoveStart(aUnit, aCount);
|
||||||
}
|
}
|
||||||
void MoveStart(ETextUnit aUnit, int32_t aCount)
|
void MoveStart(ETextUnit aUnit, int32_t aCount) {
|
||||||
{
|
MoveInternal(aUnit, aCount, *mStartContainer, mStartOffset, mEndContainer,
|
||||||
MoveInternal(aUnit, aCount, *mStartContainer, mStartOffset,
|
mEndOffset);
|
||||||
mEndContainer, mEndOffset);
|
}
|
||||||
|
void MoveEnd(ETextUnit aUnit, int32_t aCount) {
|
||||||
|
MoveInternal(aUnit, aCount, *mEndContainer, mEndOffset);
|
||||||
}
|
}
|
||||||
void MoveEnd(ETextUnit aUnit, int32_t aCount)
|
|
||||||
{ MoveInternal(aUnit, aCount, *mEndContainer, mEndOffset); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the range points to the closest unit boundaries.
|
* Move the range points to the closest unit boundaries.
|
||||||
@@ -136,10 +129,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool Crop(Accessible* aContainer);
|
bool Crop(Accessible* aContainer);
|
||||||
|
|
||||||
enum EDirection {
|
enum EDirection { eBackward, eForward };
|
||||||
eBackward,
|
|
||||||
eForward
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return range enclosing the found text.
|
* Return range enclosing the found text.
|
||||||
@@ -206,10 +196,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Scroll the text range into view.
|
* Scroll the text range into view.
|
||||||
*/
|
*/
|
||||||
enum EHowToAlign {
|
enum EHowToAlign { eAlignToTop, eAlignToBottom };
|
||||||
eAlignToTop,
|
|
||||||
eAlignToBottom
|
|
||||||
};
|
|
||||||
void ScrollIntoView(EHowToAlign aHow) const;
|
void ScrollIntoView(EHowToAlign aHow) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,21 +204,25 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool IsValid() const { return mRoot; }
|
bool IsValid() const { return mRoot; }
|
||||||
|
|
||||||
void SetStartPoint(HyperTextAccessible* aContainer, int32_t aOffset)
|
void SetStartPoint(HyperTextAccessible* aContainer, int32_t aOffset) {
|
||||||
{ mStartContainer = aContainer; mStartOffset = aOffset; }
|
mStartContainer = aContainer;
|
||||||
void SetEndPoint(HyperTextAccessible* aContainer, int32_t aOffset)
|
mStartOffset = aOffset;
|
||||||
{ mStartContainer = aContainer; mStartOffset = aOffset; }
|
}
|
||||||
|
void SetEndPoint(HyperTextAccessible* aContainer, int32_t aOffset) {
|
||||||
|
mStartContainer = aContainer;
|
||||||
|
mStartOffset = aOffset;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextRange(const TextRange& aRange) = delete;
|
TextRange(const TextRange& aRange) = delete;
|
||||||
TextRange& operator=(const TextRange& aRange) = delete;
|
TextRange& operator=(const TextRange& aRange) = delete;
|
||||||
|
|
||||||
friend class HyperTextAccessible;
|
friend class HyperTextAccessible;
|
||||||
friend class xpcAccessibleTextRange;
|
friend class xpcAccessibleTextRange;
|
||||||
|
|
||||||
void Set(HyperTextAccessible* aRoot,
|
void Set(HyperTextAccessible* aRoot, HyperTextAccessible* aStartContainer,
|
||||||
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
|
int32_t aStartOffset, HyperTextAccessible* aEndContainer,
|
||||||
HyperTextAccessible* aEndContainer, int32_t aEndOffset);
|
int32_t aEndOffset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text() method helper.
|
* Text() method helper.
|
||||||
@@ -254,7 +245,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
Accessible* CommonParent(Accessible* aAcc1, Accessible* aAcc2,
|
Accessible* CommonParent(Accessible* aAcc1, Accessible* aAcc2,
|
||||||
nsTArray<Accessible*>* aParents1, uint32_t* aPos1,
|
nsTArray<Accessible*>* aParents1, uint32_t* aPos1,
|
||||||
nsTArray<Accessible*>* aParents2, uint32_t* aPos2) const;
|
nsTArray<Accessible*>* aParents2,
|
||||||
|
uint32_t* aPos2) const;
|
||||||
|
|
||||||
RefPtr<HyperTextAccessible> mRoot;
|
RefPtr<HyperTextAccessible> mRoot;
|
||||||
RefPtr<HyperTextAccessible> mStartContainer;
|
RefPtr<HyperTextAccessible> mStartContainer;
|
||||||
@@ -263,7 +255,6 @@ private:
|
|||||||
int32_t mEndOffset;
|
int32_t mEndOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
|
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
void
|
void TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
|
||||||
TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
|
const nsAString& aNewText) {
|
||||||
const nsAString& aNewText)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aTextLeaf, "No text leaf accessible?");
|
NS_ASSERTION(aTextLeaf, "No text leaf accessible?");
|
||||||
|
|
||||||
const nsString& oldText = aTextLeaf->Text();
|
const nsString& oldText = aTextLeaf->Text();
|
||||||
@@ -25,8 +23,7 @@ TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
|
|||||||
// Skip coinciding begin substrings.
|
// Skip coinciding begin substrings.
|
||||||
uint32_t skipStart = 0;
|
uint32_t skipStart = 0;
|
||||||
for (; skipStart < minLen; skipStart++) {
|
for (; skipStart < minLen; skipStart++) {
|
||||||
if (aNewText[skipStart] != oldText[skipStart])
|
if (aNewText[skipStart] != oldText[skipStart]) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The text was changed. Do update.
|
// The text was changed. Do update.
|
||||||
@@ -36,13 +33,10 @@ TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
||||||
TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
uint32_t aSkipStart) {
|
||||||
uint32_t aSkipStart)
|
|
||||||
{
|
|
||||||
Accessible* parent = mTextLeaf->Parent();
|
Accessible* parent = mTextLeaf->Parent();
|
||||||
if (!parent)
|
if (!parent) return;
|
||||||
return;
|
|
||||||
|
|
||||||
mHyperText = parent->AsHyperText();
|
mHyperText = parent->AsHyperText();
|
||||||
if (!mHyperText) {
|
if (!mHyperText) {
|
||||||
@@ -52,8 +46,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
|||||||
|
|
||||||
// Get the text leaf accessible offset and invalidate cached offsets after it.
|
// Get the text leaf accessible offset and invalidate cached offsets after it.
|
||||||
mTextOffset = mHyperText->GetChildOffset(mTextLeaf, true);
|
mTextOffset = mHyperText->GetChildOffset(mTextLeaf, true);
|
||||||
NS_ASSERTION(mTextOffset != -1,
|
NS_ASSERTION(mTextOffset != -1, "Text leaf hasn't offset within hyper text!");
|
||||||
"Text leaf hasn't offset within hyper text!");
|
|
||||||
|
|
||||||
uint32_t oldLen = aOldText.Length(), newLen = aNewText.Length();
|
uint32_t oldLen = aOldText.Length(), newLen = aNewText.Length();
|
||||||
uint32_t minLen = std::min(oldLen, newLen);
|
uint32_t minLen = std::min(oldLen, newLen);
|
||||||
@@ -77,8 +70,8 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
|||||||
// It could be single insertion or removal or the case of long strings. Do not
|
// It could be single insertion or removal or the case of long strings. Do not
|
||||||
// calculate the difference between long strings and prefer to fire pair of
|
// calculate the difference between long strings and prefer to fire pair of
|
||||||
// insert/remove events as the old string was replaced on the new one.
|
// insert/remove events as the old string was replaced on the new one.
|
||||||
if (strLen1 == 0 || strLen2 == 0 ||
|
if (strLen1 == 0 || strLen2 == 0 || strLen1 > kMaxStrLen ||
|
||||||
strLen1 > kMaxStrLen || strLen2 > kMaxStrLen) {
|
strLen2 > kMaxStrLen) {
|
||||||
if (strLen1 > 0) {
|
if (strLen1 > 0) {
|
||||||
// Fire text change event for removal.
|
// Fire text change event for removal.
|
||||||
RefPtr<AccEvent> textRemoveEvent =
|
RefPtr<AccEvent> textRemoveEvent =
|
||||||
@@ -108,8 +101,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
|||||||
uint32_t len1 = strLen1 + 1, len2 = strLen2 + 1;
|
uint32_t len1 = strLen1 + 1, len2 = strLen2 + 1;
|
||||||
uint32_t* entries = new uint32_t[len1 * len2];
|
uint32_t* entries = new uint32_t[len1 * len2];
|
||||||
|
|
||||||
for (uint32_t colIdx = 0; colIdx < len1; colIdx++)
|
for (uint32_t colIdx = 0; colIdx < len1; colIdx++) entries[colIdx] = colIdx;
|
||||||
entries[colIdx] = colIdx;
|
|
||||||
|
|
||||||
uint32_t* row = entries;
|
uint32_t* row = entries;
|
||||||
for (uint32_t rowIdx = 1; rowIdx < len2; rowIdx++) {
|
for (uint32_t rowIdx = 1; rowIdx < len2; rowIdx++) {
|
||||||
@@ -132,7 +124,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
|||||||
nsTArray<RefPtr<AccEvent> > events;
|
nsTArray<RefPtr<AccEvent> > events;
|
||||||
ComputeTextChangeEvents(str1, str2, entries, events);
|
ComputeTextChangeEvents(str1, str2, entries, events);
|
||||||
|
|
||||||
delete [] entries;
|
delete[] entries;
|
||||||
|
|
||||||
// Fire events.
|
// Fire events.
|
||||||
for (int32_t idx = events.Length() - 1; idx >= 0; idx--)
|
for (int32_t idx = events.Length() - 1; idx >= 0; idx--)
|
||||||
@@ -144,12 +136,9 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
|||||||
mTextLeaf->SetText(aNewText);
|
mTextLeaf->SetText(aNewText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TextUpdater::ComputeTextChangeEvents(
|
||||||
TextUpdater::ComputeTextChangeEvents(const nsAString& aStr1,
|
const nsAString& aStr1, const nsAString& aStr2, uint32_t* aEntries,
|
||||||
const nsAString& aStr2,
|
nsTArray<RefPtr<AccEvent> >& aEvents) {
|
||||||
uint32_t* aEntries,
|
|
||||||
nsTArray<RefPtr<AccEvent> >& aEvents)
|
|
||||||
{
|
|
||||||
int32_t colIdx = aStr1.Length(), rowIdx = aStr2.Length();
|
int32_t colIdx = aStr1.Length(), rowIdx = aStr2.Length();
|
||||||
|
|
||||||
// Point at which strings last matched.
|
// Point at which strings last matched.
|
||||||
@@ -162,12 +151,12 @@ TextUpdater::ComputeTextChangeEvents(const nsAString& aStr1,
|
|||||||
while (rowIdx && colIdx) { // stop when we can't move diagonally
|
while (rowIdx && colIdx) { // stop when we can't move diagonally
|
||||||
if (aStr1[colIdx - 1] == aStr2[rowIdx - 1]) { // match
|
if (aStr1[colIdx - 1] == aStr2[rowIdx - 1]) { // match
|
||||||
if (rowIdx < rowEnd) { // deal with any pending insertion
|
if (rowIdx < rowEnd) { // deal with any pending insertion
|
||||||
FireInsertEvent(Substring(aStr2, rowIdx, rowEnd - rowIdx),
|
FireInsertEvent(Substring(aStr2, rowIdx, rowEnd - rowIdx), rowIdx,
|
||||||
rowIdx, aEvents);
|
aEvents);
|
||||||
}
|
}
|
||||||
if (colIdx < colEnd) { // deal with any pending deletion
|
if (colIdx < colEnd) { // deal with any pending deletion
|
||||||
FireDeleteEvent(Substring(aStr1, colIdx, colEnd - colIdx),
|
FireDeleteEvent(Substring(aStr1, colIdx, colEnd - colIdx), rowIdx,
|
||||||
rowIdx, aEvents);
|
aEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
colEnd = --colIdx; // reset the match point
|
colEnd = --colIdx; // reset the match point
|
||||||
@@ -195,8 +184,6 @@ TextUpdater::ComputeTextChangeEvents(const nsAString& aStr1,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rowEnd)
|
if (rowEnd) FireInsertEvent(Substring(aStr2, 0, rowEnd), 0, aEvents);
|
||||||
FireInsertEvent(Substring(aStr2, 0, rowEnd), 0, aEvents);
|
if (colEnd) FireDeleteEvent(Substring(aStr1, 0, colEnd), 0, aEvents);
|
||||||
if (colEnd)
|
|
||||||
FireDeleteEvent(Substring(aStr1, 0, colEnd), 0, aEvents);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,22 +16,26 @@ namespace a11y {
|
|||||||
* Used to find a difference between old and new text and fire text change
|
* Used to find a difference between old and new text and fire text change
|
||||||
* events.
|
* events.
|
||||||
*/
|
*/
|
||||||
class TextUpdater
|
class TextUpdater {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
/**
|
/**
|
||||||
* Start text of the text leaf update.
|
* Start text of the text leaf update.
|
||||||
*/
|
*/
|
||||||
static void Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
|
static void Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
|
||||||
const nsAString& aNewText);
|
const nsAString& aNewText);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextUpdater(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf) :
|
TextUpdater(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf)
|
||||||
mDocument(aDocument), mTextLeaf(aTextLeaf), mHyperText(nullptr),
|
: mDocument(aDocument),
|
||||||
mTextOffset(-1) { }
|
mTextLeaf(aTextLeaf),
|
||||||
|
mHyperText(nullptr),
|
||||||
|
mTextOffset(-1) {}
|
||||||
|
|
||||||
~TextUpdater()
|
~TextUpdater() {
|
||||||
{ mDocument = nullptr; mTextLeaf = nullptr; mHyperText = nullptr; }
|
mDocument = nullptr;
|
||||||
|
mTextLeaf = nullptr;
|
||||||
|
mHyperText = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update text of the text leaf accessible, fire text change and value change
|
* Update text of the text leaf accessible, fire text change and value change
|
||||||
@@ -40,7 +44,7 @@ private:
|
|||||||
void DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
void DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
||||||
uint32_t aSkipStart);
|
uint32_t aSkipStart);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextUpdater();
|
TextUpdater();
|
||||||
TextUpdater(const TextUpdater&);
|
TextUpdater(const TextUpdater&);
|
||||||
TextUpdater& operator=(const TextUpdater&);
|
TextUpdater& operator=(const TextUpdater&);
|
||||||
@@ -48,8 +52,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Fire text change events based on difference between strings.
|
* Fire text change events based on difference between strings.
|
||||||
*/
|
*/
|
||||||
void ComputeTextChangeEvents(const nsAString& aStr1,
|
void ComputeTextChangeEvents(const nsAString& aStr1, const nsAString& aStr2,
|
||||||
const nsAString& aStr2,
|
|
||||||
uint32_t* aEntries,
|
uint32_t* aEntries,
|
||||||
nsTArray<RefPtr<AccEvent> >& aEvents);
|
nsTArray<RefPtr<AccEvent> >& aEvents);
|
||||||
|
|
||||||
@@ -57,11 +60,9 @@ private:
|
|||||||
* Helper to create text change events for inserted text.
|
* Helper to create text change events for inserted text.
|
||||||
*/
|
*/
|
||||||
inline void FireInsertEvent(const nsAString& aText, uint32_t aAddlOffset,
|
inline void FireInsertEvent(const nsAString& aText, uint32_t aAddlOffset,
|
||||||
nsTArray<RefPtr<AccEvent> >& aEvents)
|
nsTArray<RefPtr<AccEvent> >& aEvents) {
|
||||||
{
|
RefPtr<AccEvent> event = new AccTextChangeEvent(
|
||||||
RefPtr<AccEvent> event =
|
mHyperText, mTextOffset + aAddlOffset, aText, true);
|
||||||
new AccTextChangeEvent(mHyperText, mTextOffset + aAddlOffset,
|
|
||||||
aText, true);
|
|
||||||
aEvents.AppendElement(event);
|
aEvents.AppendElement(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,11 +70,9 @@ private:
|
|||||||
* Helper to create text change events for removed text.
|
* Helper to create text change events for removed text.
|
||||||
*/
|
*/
|
||||||
inline void FireDeleteEvent(const nsAString& aText, uint32_t aAddlOffset,
|
inline void FireDeleteEvent(const nsAString& aText, uint32_t aAddlOffset,
|
||||||
nsTArray<RefPtr<AccEvent> >& aEvents)
|
nsTArray<RefPtr<AccEvent> >& aEvents) {
|
||||||
{
|
RefPtr<AccEvent> event = new AccTextChangeEvent(
|
||||||
RefPtr<AccEvent> event =
|
mHyperText, mTextOffset + aAddlOffset, aText, false);
|
||||||
new AccTextChangeEvent(mHyperText, mTextOffset + aAddlOffset,
|
|
||||||
aText, false);
|
|
||||||
aEvents.AppendElement(event);
|
aEvents.AppendElement(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +82,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
const static uint32_t kMaxStrLen = 1 << 6;
|
const static uint32_t kMaxStrLen = 1 << 6;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DocAccessible* mDocument;
|
DocAccessible* mDocument;
|
||||||
TextLeafAccessible* mTextLeaf;
|
TextLeafAccessible* mTextLeaf;
|
||||||
HyperTextAccessible* mHyperText;
|
HyperTextAccessible* mHyperText;
|
||||||
|
|||||||
@@ -20,58 +20,58 @@ using namespace mozilla::a11y;
|
|||||||
// TreeWalker
|
// TreeWalker
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TreeWalker::
|
TreeWalker::TreeWalker(Accessible* aContext)
|
||||||
TreeWalker(Accessible* aContext) :
|
: mDoc(aContext->Document()),
|
||||||
mDoc(aContext->Document()), mContext(aContext), mAnchorNode(nullptr),
|
mContext(aContext),
|
||||||
|
mAnchorNode(nullptr),
|
||||||
mARIAOwnsIdx(0),
|
mARIAOwnsIdx(0),
|
||||||
mChildFilter(nsIContent::eSkipPlaceholderContent), mFlags(0),
|
mChildFilter(nsIContent::eSkipPlaceholderContent),
|
||||||
mPhase(eAtStart)
|
mFlags(0),
|
||||||
{
|
mPhase(eAtStart) {
|
||||||
mChildFilter |= mContext->NoXBLKids() ?
|
mChildFilter |=
|
||||||
nsIContent::eAllButXBL : nsIContent::eAllChildren;
|
mContext->NoXBLKids() ? nsIContent::eAllButXBL : nsIContent::eAllChildren;
|
||||||
|
|
||||||
mAnchorNode = mContext->IsDoc() ?
|
mAnchorNode = mContext->IsDoc() ? mDoc->DocumentNode()->GetRootElement()
|
||||||
mDoc->DocumentNode()->GetRootElement() : mContext->GetContent();
|
: mContext->GetContent();
|
||||||
|
|
||||||
MOZ_COUNT_CTOR(TreeWalker);
|
MOZ_COUNT_CTOR(TreeWalker);
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeWalker::
|
TreeWalker::TreeWalker(Accessible* aContext, nsIContent* aAnchorNode,
|
||||||
TreeWalker(Accessible* aContext, nsIContent* aAnchorNode, uint32_t aFlags) :
|
uint32_t aFlags)
|
||||||
mDoc(aContext->Document()), mContext(aContext), mAnchorNode(aAnchorNode),
|
: mDoc(aContext->Document()),
|
||||||
|
mContext(aContext),
|
||||||
|
mAnchorNode(aAnchorNode),
|
||||||
mARIAOwnsIdx(0),
|
mARIAOwnsIdx(0),
|
||||||
mChildFilter(nsIContent::eSkipPlaceholderContent), mFlags(aFlags),
|
mChildFilter(nsIContent::eSkipPlaceholderContent),
|
||||||
mPhase(eAtStart)
|
mFlags(aFlags),
|
||||||
{
|
mPhase(eAtStart) {
|
||||||
MOZ_ASSERT(mFlags & eWalkCache, "This constructor cannot be used for tree creation");
|
MOZ_ASSERT(mFlags & eWalkCache,
|
||||||
|
"This constructor cannot be used for tree creation");
|
||||||
MOZ_ASSERT(aAnchorNode, "No anchor node for the accessible tree walker");
|
MOZ_ASSERT(aAnchorNode, "No anchor node for the accessible tree walker");
|
||||||
|
|
||||||
mChildFilter |= mContext->NoXBLKids() ?
|
mChildFilter |=
|
||||||
nsIContent::eAllButXBL : nsIContent::eAllChildren;
|
mContext->NoXBLKids() ? nsIContent::eAllButXBL : nsIContent::eAllChildren;
|
||||||
|
|
||||||
MOZ_COUNT_CTOR(TreeWalker);
|
MOZ_COUNT_CTOR(TreeWalker);
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeWalker::
|
TreeWalker::TreeWalker(DocAccessible* aDocument, nsIContent* aAnchorNode)
|
||||||
TreeWalker(DocAccessible* aDocument, nsIContent* aAnchorNode) :
|
: mDoc(aDocument),
|
||||||
mDoc(aDocument), mContext(nullptr), mAnchorNode(aAnchorNode),
|
mContext(nullptr),
|
||||||
|
mAnchorNode(aAnchorNode),
|
||||||
mARIAOwnsIdx(0),
|
mARIAOwnsIdx(0),
|
||||||
mChildFilter(nsIContent::eSkipPlaceholderContent | nsIContent::eAllChildren),
|
mChildFilter(nsIContent::eSkipPlaceholderContent |
|
||||||
|
nsIContent::eAllChildren),
|
||||||
mFlags(eWalkCache),
|
mFlags(eWalkCache),
|
||||||
mPhase(eAtStart)
|
mPhase(eAtStart) {
|
||||||
{
|
|
||||||
MOZ_ASSERT(aAnchorNode, "No anchor node for the accessible tree walker");
|
MOZ_ASSERT(aAnchorNode, "No anchor node for the accessible tree walker");
|
||||||
MOZ_COUNT_CTOR(TreeWalker);
|
MOZ_COUNT_CTOR(TreeWalker);
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeWalker::~TreeWalker()
|
TreeWalker::~TreeWalker() { MOZ_COUNT_DTOR(TreeWalker); }
|
||||||
{
|
|
||||||
MOZ_COUNT_DTOR(TreeWalker);
|
|
||||||
}
|
|
||||||
|
|
||||||
Accessible*
|
Accessible* TreeWalker::Scope(nsIContent* aAnchorNode) {
|
||||||
TreeWalker::Scope(nsIContent* aAnchorNode)
|
|
||||||
{
|
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
mAnchorNode = aAnchorNode;
|
mAnchorNode = aAnchorNode;
|
||||||
@@ -88,9 +88,7 @@ TreeWalker::Scope(nsIContent* aAnchorNode)
|
|||||||
return skipSubtree ? nullptr : Next();
|
return skipSubtree ? nullptr : Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool TreeWalker::Seek(nsIContent* aChildNode) {
|
||||||
TreeWalker::Seek(nsIContent* aChildNode)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aChildNode, "Child cannot be null");
|
MOZ_ASSERT(aChildNode, "Child cannot be null");
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
@@ -104,8 +102,9 @@ TreeWalker::Seek(nsIContent* aChildNode)
|
|||||||
do {
|
do {
|
||||||
childNode = parentNode->AsContent();
|
childNode = parentNode->AsContent();
|
||||||
parentNode = childNode->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) &&
|
parentNode = childNode->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) &&
|
||||||
(mChildFilter & nsIContent::eAllButXBL) ?
|
(mChildFilter & nsIContent::eAllButXBL)
|
||||||
childNode->GetParentNode() : childNode->GetFlattenedTreeParent();
|
? childNode->GetParentNode()
|
||||||
|
: childNode->GetFlattenedTreeParent();
|
||||||
|
|
||||||
if (!parentNode || !parentNode->IsElement()) {
|
if (!parentNode || !parentNode->IsElement()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -114,7 +113,8 @@ TreeWalker::Seek(nsIContent* aChildNode)
|
|||||||
// If ARIA owned child.
|
// If ARIA owned child.
|
||||||
Accessible* child = mDoc->GetAccessible(childNode);
|
Accessible* child = mDoc->GetAccessible(childNode);
|
||||||
if (child && child->IsRelocated()) {
|
if (child && child->IsRelocated()) {
|
||||||
MOZ_ASSERT(!(mFlags & eScoped),
|
MOZ_ASSERT(
|
||||||
|
!(mFlags & eScoped),
|
||||||
"Walker should not be scoped when seeking into relocated children");
|
"Walker should not be scoped when seeking into relocated children");
|
||||||
if (child->Parent() != mContext) {
|
if (child->Parent() != mContext) {
|
||||||
return false;
|
return false;
|
||||||
@@ -122,7 +122,8 @@ TreeWalker::Seek(nsIContent* aChildNode)
|
|||||||
|
|
||||||
Accessible* ownedChild = nullptr;
|
Accessible* ownedChild = nullptr;
|
||||||
while ((ownedChild = mDoc->ARIAOwnedAt(mContext, mARIAOwnsIdx++)) &&
|
while ((ownedChild = mDoc->ARIAOwnedAt(mContext, mARIAOwnsIdx++)) &&
|
||||||
ownedChild != child);
|
ownedChild != child)
|
||||||
|
;
|
||||||
|
|
||||||
MOZ_ASSERT(ownedChild, "A child has to be in ARIA owned elements");
|
MOZ_ASSERT(ownedChild, "A child has to be in ARIA owned elements");
|
||||||
mPhase = eAtARIAOwns;
|
mPhase = eAtARIAOwns;
|
||||||
@@ -130,7 +131,8 @@ TreeWalker::Seek(nsIContent* aChildNode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Look in DOM.
|
// Look in DOM.
|
||||||
dom::AllChildrenIterator* iter = PrependState(parentNode->AsElement(), true);
|
dom::AllChildrenIterator* iter =
|
||||||
|
PrependState(parentNode->AsElement(), true);
|
||||||
if (!iter->Seek(childNode)) {
|
if (!iter->Seek(childNode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -144,9 +146,7 @@ TreeWalker::Seek(nsIContent* aChildNode)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* TreeWalker::Next() {
|
||||||
TreeWalker::Next()
|
|
||||||
{
|
|
||||||
if (mStateStack.IsEmpty()) {
|
if (mStateStack.IsEmpty()) {
|
||||||
if (mPhase == eAtEnd) {
|
if (mPhase == eAtEnd) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -208,8 +208,7 @@ TreeWalker::Next()
|
|||||||
nsINode* contextNode = mContext->GetNode();
|
nsINode* contextNode = mContext->GetNode();
|
||||||
while (mAnchorNode != contextNode) {
|
while (mAnchorNode != contextNode) {
|
||||||
nsINode* parentNode = mAnchorNode->GetFlattenedTreeParent();
|
nsINode* parentNode = mAnchorNode->GetFlattenedTreeParent();
|
||||||
if (!parentNode || !parentNode->IsElement())
|
if (!parentNode || !parentNode->IsElement()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
nsIContent* parent = parentNode->AsElement();
|
nsIContent* parent = parentNode->AsElement();
|
||||||
top = PushState(parent, true);
|
top = PushState(parent, true);
|
||||||
@@ -228,9 +227,7 @@ TreeWalker::Next()
|
|||||||
return Next();
|
return Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* TreeWalker::Prev() {
|
||||||
TreeWalker::Prev()
|
|
||||||
{
|
|
||||||
if (mStateStack.IsEmpty()) {
|
if (mStateStack.IsEmpty()) {
|
||||||
if (mPhase == eAtStart || mPhase == eAtDOM) {
|
if (mPhase == eAtStart || mPhase == eAtDOM) {
|
||||||
mPhase = eAtStart;
|
mPhase = eAtStart;
|
||||||
@@ -309,9 +306,8 @@ TreeWalker::Prev()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible* TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags,
|
||||||
TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags, bool* aSkipSubtree)
|
bool* aSkipSubtree) {
|
||||||
{
|
|
||||||
// Ignore the accessible and its subtree if it was repositioned by means
|
// Ignore the accessible and its subtree if it was repositioned by means
|
||||||
// of aria-owns.
|
// of aria-owns.
|
||||||
Accessible* child = mDoc->GetAccessible(aNode);
|
Accessible* child = mDoc->GetAccessible(aNode);
|
||||||
@@ -342,9 +338,7 @@ TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags, bool* aSkipSubtree
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
dom::AllChildrenIterator*
|
dom::AllChildrenIterator* TreeWalker::PopState() {
|
||||||
TreeWalker::PopState()
|
|
||||||
{
|
|
||||||
mStateStack.RemoveLastElement();
|
mStateStack.RemoveLastElement();
|
||||||
return mStateStack.IsEmpty() ? nullptr : &mStateStack.LastElement();
|
return mStateStack.IsEmpty() ? nullptr : &mStateStack.LastElement();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,8 @@ class DocAccessible;
|
|||||||
/**
|
/**
|
||||||
* This class is used to walk the DOM tree to create accessible tree.
|
* This class is used to walk the DOM tree to create accessible tree.
|
||||||
*/
|
*/
|
||||||
class TreeWalker final
|
class TreeWalker final {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
enum {
|
enum {
|
||||||
// used to walk the existing tree of the given node
|
// used to walk the existing tree of the given node
|
||||||
eWalkCache = 1,
|
eWalkCache = 1,
|
||||||
@@ -46,7 +45,8 @@ public:
|
|||||||
* @param aAnchorNode [in] the node the search will be prepared relative to
|
* @param aAnchorNode [in] the node the search will be prepared relative to
|
||||||
* @param aFlags [in] flags (see enum above)
|
* @param aFlags [in] flags (see enum above)
|
||||||
*/
|
*/
|
||||||
TreeWalker(Accessible* aContext, nsIContent* aAnchorNode, uint32_t aFlags = eWalkCache);
|
TreeWalker(Accessible* aContext, nsIContent* aAnchorNode,
|
||||||
|
uint32_t aFlags = eWalkCache);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigates the accessible children within the anchor node subtree.
|
* Navigates the accessible children within the anchor node subtree.
|
||||||
@@ -64,8 +64,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Resets the walker state.
|
* Resets the walker state.
|
||||||
*/
|
*/
|
||||||
void Reset()
|
void Reset() {
|
||||||
{
|
|
||||||
mPhase = eAtStart;
|
mPhase = eAtStart;
|
||||||
mStateStack.Clear();
|
mStateStack.Clear();
|
||||||
mARIAOwnsIdx = 0;
|
mARIAOwnsIdx = 0;
|
||||||
@@ -89,10 +88,10 @@ public:
|
|||||||
Accessible* Context() const { return mContext; }
|
Accessible* Context() const { return mContext; }
|
||||||
DocAccessible* Document() const { return mDoc; }
|
DocAccessible* Document() const { return mDoc; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TreeWalker();
|
TreeWalker();
|
||||||
TreeWalker(const TreeWalker&);
|
TreeWalker(const TreeWalker&);
|
||||||
TreeWalker& operator =(const TreeWalker&);
|
TreeWalker& operator=(const TreeWalker&);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an accessible for the given node if any.
|
* Return an accessible for the given node if any.
|
||||||
@@ -108,16 +107,14 @@ private:
|
|||||||
* accessible children search.
|
* accessible children search.
|
||||||
*/
|
*/
|
||||||
dom::AllChildrenIterator* PushState(nsIContent* aContent,
|
dom::AllChildrenIterator* PushState(nsIContent* aContent,
|
||||||
bool aStartAtBeginning)
|
bool aStartAtBeginning) {
|
||||||
{
|
|
||||||
return mStateStack.AppendElement(
|
return mStateStack.AppendElement(
|
||||||
dom::AllChildrenIterator(aContent, mChildFilter, aStartAtBeginning));
|
dom::AllChildrenIterator(aContent, mChildFilter, aStartAtBeginning));
|
||||||
}
|
}
|
||||||
dom::AllChildrenIterator* PrependState(nsIContent* aContent,
|
dom::AllChildrenIterator* PrependState(nsIContent* aContent,
|
||||||
bool aStartAtBeginning)
|
bool aStartAtBeginning) {
|
||||||
{
|
return mStateStack.InsertElementAt(
|
||||||
return mStateStack.InsertElementAt(0,
|
0, dom::AllChildrenIterator(aContent, mChildFilter, aStartAtBeginning));
|
||||||
dom::AllChildrenIterator(aContent, mChildFilter, aStartAtBeginning));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,12 +132,7 @@ private:
|
|||||||
int32_t mChildFilter;
|
int32_t mChildFilter;
|
||||||
uint32_t mFlags;
|
uint32_t mFlags;
|
||||||
|
|
||||||
enum Phase {
|
enum Phase { eAtStart, eAtDOM, eAtARIAOwns, eAtEnd };
|
||||||
eAtStart,
|
|
||||||
eAtDOM,
|
|
||||||
eAtARIAOwns,
|
|
||||||
eAtEnd
|
|
||||||
};
|
|
||||||
Phase mPhase;
|
Phase mPhase;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user