Fix some issues with disabled edit fields.

This commit is contained in:
lilmike committed 2026-10-27 09:20:20 -07:00
1 parent d8b59aa05b
commit 7d720e131d
7 files changed
+240 -11

No files matched your search

+34 -9
View File
@@ -14,18 +14,22 @@ import (
)
func wholeCaretNode(snapshot atspi.Snapshot) bool {
if wholeCaretControl(snapshot) {
return true
}
// An explicitly named custom clickable is an atomic stop just like a
// named link. Ordinary clickable text remains readable by character/word.
return snapshot.SupportsClick && snapshot.ExplicitName && strings.TrimSpace(snapshot.Name) != "" &&
!snapshot.Editable && !atspi.IsWebDocumentRole(snapshot.Role)
}
func wholeCaretControl(snapshot atspi.Snapshot) bool {
if snapshot.Role == "link" {
return snapshot.ExplicitName && strings.TrimSpace(snapshot.Name) != ""
}
if snapshot.Role == "image" {
return snapshot.Name != "" || snapshot.Description != ""
}
// An explicitly named custom clickable is an atomic stop just like a
// named link. Ordinary clickable text remains readable by character/word.
if snapshot.SupportsClick && snapshot.ExplicitName && strings.TrimSpace(snapshot.Name) != "" &&
!snapshot.Editable && !atspi.IsWebDocumentRole(snapshot.Role) {
return true
}
switch snapshot.Role {
case "button", "check box", "check menu item", "list box", "menu item", "page tab",
"radio menu item", "radio button", "push button", "toggle button":
@@ -44,7 +48,7 @@ func passive_caret_tooltip(snapshot atspi.Snapshot) bool {
// caret_node_indices preserves provider order and treats whole controls as one
// stop. MoveCaret holds the document cursor lock while using these indices.
func caret_node_indices(nodes []atspi.DocumentNode, object atspi.ObjectReference) ([]int, int) {
func caret_node_indices(nodes []atspi.DocumentNode, object atspi.ObjectReference) ([]int, int, map[atspi.ObjectID]bool) {
// Container text normally embeds its child text. Whole controls are one
// caret stop even when their label is a child or they have no text interface.
// Python's web _treatObjectAsWhole makes the same distinction.
@@ -52,6 +56,25 @@ func caret_node_indices(nodes []atspi.DocumentNode, object atspi.ObjectReference
current := -1
skipped := make(map[atspi.ObjectID]bool)
protected := make(map[atspi.ObjectID]bool, len(nodes))
// Named custom clickables can contain independent controls, including
// disabled entries. Keep the container's label as a stop without pruning
// those controls. Ordinary labels and semantic controls remain atomic.
controls := make(map[atspi.ObjectID]bool)
for index := len(nodes) - 1; index >= 0; index-- {
node := nodes[index]
snapshot := node.Snapshot
field := documentFormFieldRole(snapshot) &&
(snapshot.Role != "text" || snapshot.Editable || snapshot.Focusable || snapshot.ReadOnly)
if !node.Hidden && (controls[node.Reference.ID()] || field || snapshot.Editable || snapshot.Role == "link") {
controls[node.Parent] = true
}
}
expanded := make(map[atspi.ObjectID]bool)
for _, node := range nodes {
if controls[node.Reference.ID()] && wholeCaretNode(node.Snapshot) && !wholeCaretControl(node.Snapshot) {
expanded[node.Reference.ID()] = true
}
}
var skipChildren func([]atspi.ObjectID)
children := make(map[atspi.ObjectID][]atspi.ObjectID, len(nodes))
for _, node := range nodes {
@@ -90,7 +113,9 @@ func caret_node_indices(nodes []atspi.DocumentNode, object atspi.ObjectReference
}
if wholeCaretNode(node.Snapshot) {
indices = append(indices, index)
skipChildren(node.Children)
if !expanded[node.Reference.ID()] {
skipChildren(node.Children)
}
} else if node.Snapshot.Editable &&
(node.Snapshot.Role == "entry" || node.Snapshot.Role == "text") &&
(node.Snapshot.CharacterCount == 0 || len(node.Children) == 0) {
@@ -102,7 +127,7 @@ func caret_node_indices(nodes []atspi.DocumentNode, object atspi.ObjectReference
indices = append(indices, index)
}
}
return indices, current
return indices, current, expanded
}
// Python's web hasValidName/isUselessEmptyElement rejects standalone unnamed