Found a few ways in which the Braille problem with browsers could resurface. Fixed now.
This commit is contained in:
1 parent
0a3d946ffa
commit
a47253d697
13 files changed
+292
-23
No files matched your search
@@ -10,9 +10,10 @@ package atspi
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func nativeError(operation string, nativeError *C.GError) error {
|
||||
@@ -61,6 +62,7 @@ func snapshotFromNativeWithOptions(source *C.AtspiAccessible, text, caretCharact
|
||||
textContent,
|
||||
C.GoString(captured.caretCharacter),
|
||||
)
|
||||
characterCount := int(captured.characterCount)
|
||||
snapshot.TextCaretKnown = captured.text != nil && captured.textStartOffset >= 0
|
||||
if text && snapshot.Role != "password text" {
|
||||
switch snapshot.Role {
|
||||
@@ -71,6 +73,12 @@ func snapshotFromNativeWithOptions(source *C.AtspiAccessible, text, caretCharact
|
||||
if snapshot.TextCaretKnown {
|
||||
captureBrailleLine(&snapshot, textContent, C.GoString(captured.textBeforeCaret), int(captured.textStartOffset))
|
||||
if text := C.atspi_accessible_get_text(source); text != nil {
|
||||
// Caret captures omit whole-document metadata. An incomplete
|
||||
// expansion still needs the native count to know whether a name
|
||||
// can safely replace this entire line.
|
||||
if caretCharacter && strings.ContainsRune(textContent, '\ufffc') && characterCount <= 0 {
|
||||
characterCount = int(C.atspi_text_get_character_count(text, nil))
|
||||
}
|
||||
snapshot.TextAttributeRun = native_text_attribute_run(text, snapshot.BrailleCaret)
|
||||
snapshot.Misspelled = TextAttributesMisspelled(snapshot.TextAttributeRun.Values)
|
||||
if len(captureAttributes) != 0 && captureAttributes[0] {
|
||||
@@ -93,9 +101,12 @@ func snapshotFromNativeWithOptions(source *C.AtspiAccessible, text, caretCharact
|
||||
}
|
||||
}
|
||||
if caretCharacter && captured.editable == 0 && snapshot.Role != "terminal" && strings.ContainsRune(textContent, '\ufffc') {
|
||||
budget := embeddedTextBudget{nodes: 32, characters: maxSnapshotFieldLength, deadline: time.Now().Add(100 * time.Millisecond)}
|
||||
// Hypertext offsets refer to raw characters, before whitespace folding.
|
||||
snapshot.Text = sanitizeSnapshotField(expandNativeEmbeddedText(source, textContent, int(captured.textStartOffset), 0, &budget))
|
||||
start := int(captured.textStartOffset)
|
||||
line := expandNativeDocumentText(context.Background(), source, snapshot, DocumentCaretText{
|
||||
Start: start, End: start + utf8.RuneCountInString(textContent), Text: textContent, CharacterCount: characterCount,
|
||||
})
|
||||
snapshot.Text = sanitizeSnapshotField(line.Text)
|
||||
}
|
||||
snapshot.BusName = sanitizeSnapshotField(C.GoString(captured.busName))
|
||||
if snapshot.Role == "radio button" {
|
||||
@@ -148,7 +159,7 @@ func snapshotFromNativeWithOptions(source *C.AtspiAccessible, text, caretCharact
|
||||
snapshot.TableColumnHeaders = sanitizeSnapshotField(C.GoString(captured.tableColumnHeaders))
|
||||
C.g_free(C.gpointer(captured.tableRowHeaders))
|
||||
C.g_free(C.gpointer(captured.tableColumnHeaders))
|
||||
snapshot.CharacterCount = int(captured.characterCount)
|
||||
snapshot.CharacterCount = characterCount
|
||||
snapshot.EmbeddedObjectCount = int(captured.embeddedObjectCount)
|
||||
snapshot.XMLRoles = sanitizeSnapshotField(C.GoString(captured.xmlRoles))
|
||||
snapshot.HTMLTag = sanitizeSnapshotField(C.GoString(captured.htmlTag))
|
||||
|
||||
Reference in new issue
Block a user