Skip to content

Commit

Permalink
Bug 1735970 part 6: Retrieve row/column extent for both local and rem…
Browse files Browse the repository at this point in the history
…ote cells. r=morgan

CachedTableAccessible already knew how to support extents (AKA spans), but it didn't know how to retrieve them yet.

Differential Revision: https://phabricator.services.mozilla.com/D141209
  • Loading branch information
jcsteh committed Apr 1, 2022
1 parent 78f3eb8 commit 1f562c2
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
1 change: 1 addition & 0 deletions accessible/base/CacheConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CacheDomain {
static constexpr uint64_t Style = ((uint64_t)0x1) << 9;
static constexpr uint64_t TransformMatrix = ((uint64_t)0x1) << 10;
static constexpr uint64_t ScrollPosition = ((uint64_t)0x1) << 11;
static constexpr uint64_t Table = ((uint64_t)0x1) << 11;
static constexpr uint64_t All = ~((uint64_t)0x0);
};

Expand Down
36 changes: 34 additions & 2 deletions accessible/base/CachedTableAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "nsAccUtils.h"
#include "nsIAccessiblePivot.h"
#include "Pivot.h"
#include "RemoteAccessible.h"
#include "TableCellAccessible.h"

namespace mozilla::a11y {

Expand Down Expand Up @@ -257,12 +259,42 @@ TableAccessibleBase* CachedTableCellAccessible::Table() const {
}

uint32_t CachedTableCellAccessible::ColExtent() const {
// XXX Implement.
if (RemoteAccessible* remoteAcc = mAcc->AsRemote()) {
if (remoteAcc->mCachedFields) {
if (auto colSpan = remoteAcc->mCachedFields->GetAttribute<int32_t>(
nsGkAtoms::colspan)) {
return *colSpan;
}
}
} else if (LocalAccessible* localAcc = mAcc->AsLocal()) {
// For HTML table cells, we must use the HTMLTableCellAccessible
// GetColExtent method rather than using the DOM attributes directly.
// This is because of things like rowspan="0" which depend on knowing
// about thead, tbody, etc., which is info we don't have in the a11y tree.
TableCellAccessible* cell = localAcc->AsTableCell();
MOZ_ASSERT(cell);
return cell->ColExtent();
}
return 1;
}

uint32_t CachedTableCellAccessible::RowExtent() const {
// XXX Implement.
if (RemoteAccessible* remoteAcc = mAcc->AsRemote()) {
if (remoteAcc->mCachedFields) {
if (auto rowSpan = remoteAcc->mCachedFields->GetAttribute<int32_t>(
nsGkAtoms::rowspan)) {
return *rowSpan;
}
}
} else if (LocalAccessible* localAcc = mAcc->AsLocal()) {
// For HTML table cells, we must use the HTMLTableCellAccessible
// GetRowExtent method rather than using the DOM attributes directly.
// This is because of things like rowspan="0" which depend on knowing
// about thead, tbody, etc., which is info we don't have in the a11y tree.
TableCellAccessible* cell = localAcc->AsTableCell();
MOZ_ASSERT(cell);
return cell->RowExtent();
}
return 1;
}

Expand Down
21 changes: 21 additions & 0 deletions accessible/generic/LocalAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3337,6 +3337,27 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
}
}

if (aCacheDomain & CacheDomain::Table) {
if (TableCellAccessible* cell = AsTableCell()) {
// For HTML table cells, we must use the HTMLTableCellAccessible
// GetRow/ColExtent methods rather than using the DOM attributes directly.
// This is because of things like rowspan="0" which depend on knowing
// about thead, tbody, etc., which is info we don't have in the a11y tree.
int32_t value = static_cast<int32_t>(cell->RowExtent());
if (value != 1) {
fields->SetAttribute(nsGkAtoms::rowspan, value);
} else if (aUpdateType == CacheUpdateType::Update) {
fields->SetAttribute(nsGkAtoms::rowspan, DeleteEntry());
}
value = static_cast<int32_t>(cell->ColExtent());
if (value != 1) {
fields->SetAttribute(nsGkAtoms::colspan, value);
} else if (aUpdateType == CacheUpdateType::Update) {
fields->SetAttribute(nsGkAtoms::colspan, DeleteEntry());
}
}
}

if (aUpdateType == CacheUpdateType::Initial) {
// Add fields which never change and thus only need to be included in the
// initial cache push.
Expand Down
5 changes: 5 additions & 0 deletions accessible/html/HTMLTableAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "AccAttributes.h"
#include "CacheConstants.h"
#include "DocAccessible.h"
#include "LocalAccessible-inl.h"
#include "nsTextEquivUtils.h"
Expand Down Expand Up @@ -151,6 +152,10 @@ void HTMLTableCellAccessible::DOMAttributeChanged(int32_t aNameSpaceID,
mDoc->FireDelayedEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
this);
}
if (aAttribute == nsGkAtoms::rowspan || aAttribute == nsGkAtoms::colspan ||
aAttribute == nsGkAtoms::headers) {
mDoc->QueueCacheUpdate(this, CacheDomain::Table);
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions accessible/ipc/RemoteAccessibleBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
friend Derived;
friend DocAccessibleParent;
friend class xpcAccessible;
friend class CachedTableCellAccessible;

nsTArray<Derived*> mChildren;
DocAccessibleParent* mDoc;
Expand Down

0 comments on commit 1f562c2

Please sign in to comment.