Expand embedded objects in braille document lines
Structural navigation to a heading whose native text is a single embedded-object placeholder for its child link showed only that placeholder in braille while speech used the expanded title. Braille line reads now expand embedded objects like speech capture, preserving RawText and native offsets; expanded lines carry no cell routes or native selection/attribute dots and only a line-start cursor. Frame assembly strips any remaining placeholders and falls back to displayed text so a placeholder never reaches the display. Regression tests cover placeholder-only, mixed, expanded, assembled, and empty headings plus native linked-heading and Firefox mixed-line braille. Maintainer confirms physical braille and speech agree on YouTube headings.
This commit is contained in:
1 parent
60f7f7a2e9
commit
8ce5e5cdad
7 files changed
+245
-21
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -328,6 +329,19 @@ func (adapter *Adapter) readNativeDocumentCaret(ctx context.Context, position Ob
|
||||
return DocumentCaretText{}, err
|
||||
}
|
||||
line.RawText = line.Text
|
||||
// Braille must show the same descendant text speech expands, not
|
||||
// embedded-object placeholders. RawText and native offsets stay
|
||||
// unexpanded; Expanded tells consumers the mapping is degraded.
|
||||
if unit == DocumentCaretBrailleLine && !snapshot.Editable && strings.ContainsRune(line.Text, '\ufffc') {
|
||||
deadline := time.Now().Add(100 * time.Millisecond)
|
||||
if ctxDeadline, ok := ctx.Deadline(); ok && ctxDeadline.Before(deadline) {
|
||||
deadline = ctxDeadline
|
||||
}
|
||||
budget := embeddedTextBudget{nodes: 32, characters: maxSnapshotFieldLength, deadline: deadline}
|
||||
if expanded := expandNativeEmbeddedText(source, line.Text, line.Start, 0, &budget); expanded != line.Text {
|
||||
line.Text, line.Expanded = expanded, true
|
||||
}
|
||||
}
|
||||
if unit == DocumentCaretBrailleLine && adapter.captureTextAttributes.Load() {
|
||||
line.TextAttributeRuns = native_text_attribute_runs(text, line.Start, line.End, TextAttributeRun{})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user