mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1730096 part 5: Push text attributes to the cache. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D129471
This commit is contained in:
parent
5cb3312f64
commit
e2a75ff2ce
@ -3165,26 +3165,36 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
|
||||
}
|
||||
}
|
||||
|
||||
// We only cache text on leaf Accessibles.
|
||||
if ((aCacheDomain & CacheDomain::Text) && !HasChildren()) {
|
||||
// Only text Accessibles can have actual text.
|
||||
if (IsText()) {
|
||||
nsString text;
|
||||
AppendTextTo(text);
|
||||
fields->SetAttribute(nsGkAtoms::text, std::move(text));
|
||||
if (aCacheDomain & CacheDomain::Text) {
|
||||
if (!HasChildren()) {
|
||||
// We only cache text and line offsets on leaf Accessibles.
|
||||
// Only text Accessibles can have actual text.
|
||||
if (IsText()) {
|
||||
nsString text;
|
||||
AppendTextTo(text);
|
||||
fields->SetAttribute(nsGkAtoms::text, std::move(text));
|
||||
TextLeafPoint point(this, 0);
|
||||
RefPtr<AccAttributes> attrs = point.GetTextAttributesLocalAcc(
|
||||
/* aIncludeDefaults */ false);
|
||||
fields->SetAttribute(nsGkAtoms::style, std::move(attrs));
|
||||
}
|
||||
// We cache line start offsets for both text and non-text leaf Accessibles
|
||||
// because non-text leaf Accessibles can still start a line.
|
||||
nsTArray<int32_t> lineStarts;
|
||||
for (TextLeafPoint lineStart =
|
||||
TextLeafPoint(this, 0).FindNextLineStartSameLocalAcc(
|
||||
/* aIncludeOrigin */ true);
|
||||
lineStart;
|
||||
lineStart = lineStart.FindNextLineStartSameLocalAcc(false)) {
|
||||
lineStarts.AppendElement(lineStart.mOffset);
|
||||
}
|
||||
if (!lineStarts.IsEmpty()) {
|
||||
fields->SetAttribute(nsGkAtoms::line, std::move(lineStarts));
|
||||
}
|
||||
}
|
||||
// We cache line start offsets for both text and non-text leaf Accessibles
|
||||
// because non-text leaf Accessibles can still start a line.
|
||||
nsTArray<int32_t> lineStarts;
|
||||
for (TextLeafPoint lineStart =
|
||||
TextLeafPoint(this, 0).FindNextLineStartSameLocalAcc(
|
||||
/* aIncludeOrigin */ true);
|
||||
lineStart;
|
||||
lineStart = lineStart.FindNextLineStartSameLocalAcc(false)) {
|
||||
lineStarts.AppendElement(lineStart.mOffset);
|
||||
}
|
||||
if (!lineStarts.IsEmpty()) {
|
||||
fields->SetAttribute(nsGkAtoms::line, std::move(lineStarts));
|
||||
if (HyperTextAccessible* ht = AsHyperText()) {
|
||||
RefPtr<AccAttributes> attrs = ht->DefaultTextAttributes();
|
||||
fields->SetAttribute(nsGkAtoms::style, std::move(attrs));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user