Thunderbird HTML messages expose readable text on containers around embedded objects. The browse cursor previously considered only text leaves, and native document capture omitted heading/link character counts. This skipped message content, headings and link text. A caret event following Tab could also replace a complete link announcement with its first character. Capture owned hypertext child identities and native placeholder offsets on the GLib thread, releasing native interfaces before returning. Require every child to occupy one embedded-object character so providers exposing duplicate text through static descendants retain their ordinary traversal. Traverse native text ranges before and after embedded children without changing their offset domains. Preserve character, word, line and document-boundary navigation; normalize native caret and Braille routing positions at adjacent embedded links. Keep the Braille cursor on the correct fragment when a parent contributes text more than once to an assembled line. Ignore same-input link caret echoes after focus while retaining subsequent arrow and selection feedback. Add regression tests, extend the private Firefox fixture, and record behavior and remaining acceptance in the parity ledger. Validation: - Full Go test suite with count=1; focused app/atspi/review race checks. - go vet ./...; reader and brlapi helper builds. - Private Firefox baseline, mixed-parent offsets and tab navigation. - Private Chromium fragments, named links, document navigation and selection. - Parity ledger validation and whitespace checks. The existing Firefox tab test intermittently timed out on both an untouched HEAD copy and the changed tree; the final run passed. The unchanged TestRunReachesSoundStopAfterEarlierServiceStopError also failed once during startup cancellation and passed in subsequent full-suite and race runs. Both installed binaries were verified and the reader reloaded in its original desktop session. The maintainer confirmed readable message text and later working links after an earlier intermittent omission. That omission remains untraced; repeat live acceptance and physical Braille verification remain open.
134 lines
4.5 KiB
Go
134 lines
4.5 KiB
Go
package review
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.stormux.org/storm/cthulhu/internal/atspi"
|
|
)
|
|
|
|
type documentBrailleRequest struct {
|
|
ctx context.Context
|
|
focus, document, target atspi.ObjectID
|
|
line string
|
|
start, offset int
|
|
done chan error
|
|
}
|
|
|
|
// RouteDocumentBraille shares the navigation FIFO. The display session may
|
|
// wait, but input and event callbacks never wait for native caret placement.
|
|
func (worker *Worker) RouteDocumentBraille(ctx context.Context, epoch uint64, focus, document, target atspi.ObjectID, line string, start, offset int) error {
|
|
if err := ctx.Err(); err != nil {
|
|
return err
|
|
}
|
|
route := &documentBrailleRequest{ctx: ctx, focus: focus, document: document, target: target, line: line, start: start, offset: offset, done: make(chan error, 1)}
|
|
select {
|
|
case worker.requests <- request{brailleRoute: route, documentEpoch: epoch, queuedAt: time.Now()}:
|
|
default:
|
|
return ErrRequestQueueFull
|
|
}
|
|
select {
|
|
case err := <-route.done:
|
|
return err
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
}
|
|
}
|
|
|
|
func (worker *Worker) route_document_braille(ctx context.Context, cursor *DocumentCursor, request request) (result Result) {
|
|
route := request.brailleRoute
|
|
result = Result{DocumentBrailleRoute: true, DocumentCaretCommand: CaretReadLine, DocumentFocus: route.focus, DocumentEpoch: request.documentEpoch}
|
|
defer func() { route.done <- result.Err }()
|
|
if cursor == nil || worker.focus() != route.focus || !worker.CurrentDocumentResult(result) {
|
|
result.Err = atspi.ErrStaleObject
|
|
return
|
|
}
|
|
ctx, cancel := context.WithTimeout(ctx, worker.captureTimeout)
|
|
stop := context.AfterFunc(route.ctx, cancel)
|
|
defer stop()
|
|
defer cancel()
|
|
if result.Err = route.ctx.Err(); result.Err != nil {
|
|
return
|
|
}
|
|
target, err := cursor.tree.Reference(route.target)
|
|
if err != nil {
|
|
result.Err = err
|
|
return
|
|
}
|
|
owner, err := cursor.tree.DocumentContext(target)
|
|
if err != nil || owner.TopLevel.ID() != route.document {
|
|
result.Err = atspi.ErrStaleObject
|
|
return
|
|
}
|
|
router, ok := worker.nativeCapturerFor(route.focus).(interface {
|
|
RouteBraille(context.Context, atspi.BrailleRoute) error
|
|
})
|
|
if !ok {
|
|
result.Err = atspi.ErrNoDocumentCaret
|
|
return
|
|
}
|
|
reader, ok := worker.nativeCapturerFor(route.focus).(DocumentCaretReader)
|
|
if !ok {
|
|
result.Err = atspi.ErrNoDocumentCaret
|
|
return
|
|
}
|
|
doc, err := cursor.tree.Document(ctx, target)
|
|
if err != nil {
|
|
result.Err = err
|
|
return
|
|
}
|
|
node, caretOffset, err := native_caret_node(ctx, reader, doc, route.target, route.offset)
|
|
if err != nil {
|
|
result.Err = err
|
|
return
|
|
}
|
|
if node.Hidden {
|
|
result.Err = atspi.ErrStaleObject
|
|
return
|
|
}
|
|
result.Err = router.RouteBraille(ctx, atspi.BrailleRoute{Focus: route.focus, Position: target, Line: route.line, Start: route.start, Offset: route.offset})
|
|
if result.Err != nil || worker.focus() != route.focus || !worker.CurrentDocumentResult(result) {
|
|
if result.Err == nil {
|
|
result.Err = atspi.ErrStaleObject
|
|
}
|
|
return
|
|
}
|
|
// Keep the document anchor; a routed inline child is not native focus.
|
|
cursor.mu.Lock()
|
|
if len(cursor.places) == 0 || cursor.active.ID() != route.document {
|
|
cursor.mu.Unlock()
|
|
result.Err = atspi.ErrStaleObject
|
|
return
|
|
}
|
|
place := &cursor.places[len(cursor.places)-1]
|
|
place.object, place.offset, place.origin = node.Reference, caretOffset, CaretNavigation
|
|
place.tableCell = atspi.ObjectID{}
|
|
snapshot, err := cursor.tree.Resolve(node.Reference)
|
|
result.DocumentPosition = DocumentPosition{Document: owner.TopLevel, Object: node.Reference, Snapshot: snapshot, Offset: caretOffset, Origin: CaretNavigation}
|
|
cursor.mu.Unlock()
|
|
result.Err, result.Moved = err, err == nil
|
|
result.DocumentCaretContext = owner.Ancestors
|
|
if result.Moved && worker.documentBraille.Load() {
|
|
// Optional assembly refresh preserves surrounding inline fragments while
|
|
// retaining the exact routed offset. It never repeats caret placement.
|
|
deadline, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
|
|
defer cancel()
|
|
indices := caretNodeRanges(doc.Nodes)
|
|
position := -1
|
|
for index, candidate := range indices {
|
|
if doc.Nodes[candidate.index].Reference == node.Reference && caretOffset >= candidate.start && caretOffset < candidate.end {
|
|
position = index
|
|
break
|
|
}
|
|
}
|
|
if position >= 0 {
|
|
parts, err := collect_visual_line(deadline, reader, doc, indices, visual_line_owners(doc.Nodes), position, caretOffset, true)
|
|
if err == nil && len(parts) > 1 {
|
|
line, _, _ := assemble_visual_line(cursor.tree, doc, parts)
|
|
result.DocumentCaretLine = &line
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|