More flat review improvement.

This commit is contained in:
Storm Dragon committed 2026-10-21 20:56:18 -04:00
1 parent 50e32f24df
commit e88de5ee66
41 files changed
+2167 -73

No files matched your search

+28 -12
View File
@@ -127,7 +127,7 @@ func captureNativeTree(ctx context.Context, root *C.AtspiAccessible, reviewBusNa
pending = pending[:last]
sourceID := nativeObjectID(source)
cached, known := cache.nodes[sourceID]
refresh := !known || cached.snapshotInvalid || cached.textInvalid || cached.geometryInvalid || cached.childrenInvalid
refresh := !known || cached.snapshotInvalid || cached.textInvalid || cached.geometryInvalid || cached.childrenInvalid || cached.childrenUnavailable
snapshot := cached.snapshot
trace.begin_stage("snapshot", sourceID, snapshot.Role)
if refresh {
@@ -206,7 +206,7 @@ func captureNativeTree(ctx context.Context, root *C.AtspiAccessible, reviewBusNa
childClip, childClipped = item.clip, item.clipped
}
trace.begin_stage("visible-text", snapshot.ID(), snapshot.Role)
text := VisibleText{Limited: true}
text := VisibleText{Limited: true, Issue: TextTreeLimit}
if (!document || documentText) && textBytes < maxTreeTextBytes {
if known && !cached.textInvalid && !cached.geometryInvalid && !item.clipChanged {
text = cached.text
@@ -224,7 +224,8 @@ func captureNativeTree(ctx context.Context, root *C.AtspiAccessible, reviewBusNa
size += len(r.Text)
}
if textBytes+size > maxTreeTextBytes {
text = VisibleText{Limited: true}
text = VisibleText{Limited: true, Issue: TextTreeLimit}
trace.text_issue(TextTreeLimit)
} else {
textBytes += size
}
@@ -239,7 +240,8 @@ func captureNativeTree(ctx context.Context, root *C.AtspiAccessible, reviewBusNa
(geometry.Visible && geometry.Showing) || snapshot.Role == "application" || snapshot.Role == "desktop frame"
// A visibility change can reveal children omitted by an earlier review
// capture, even when the provider emits no children-changed event.
cachedChildren := known && !cached.childrenInvalid && (!reviewOnly || !cached.geometryInvalid)
cachedChildren := known && !cached.childrenInvalid && !cached.childrenUnavailable && (!reviewOnly || !cached.geometryInvalid)
childrenUnavailable := false
for _, id := range cached.children {
if cache.sources[id] == nil {
cachedChildren = false
@@ -279,15 +281,22 @@ func captureNativeTree(ctx context.Context, root *C.AtspiAccessible, reviewBusNa
err := fmt.Errorf("%w (bus %q path %q role %q captured_nodes %d)",
nativeError("query AT-SPI child count", childCountError), snapshot.BusName, snapshot.Path, snapshot.Role, len(nodes))
C.g_error_free(childCountError)
C.g_object_unref(C.gpointer(source))
releasePending()
return ObjectID{}, nil, err
if !reviewOnly || item.parentIndex < 0 || ctx.Err() != nil {
C.g_object_unref(C.gpointer(source))
releasePending()
return ObjectID{}, nil, err
}
childCount, childrenUnavailable = 0, true
}
if childCount < 0 {
C.g_object_unref(C.gpointer(source))
releasePending()
return ObjectID{}, nil, fmt.Errorf("query AT-SPI child count: negative result (bus %q path %q role %q captured_nodes %d)",
snapshot.BusName, snapshot.Path, snapshot.Role, len(nodes))
if reviewOnly && item.parentIndex >= 0 && ctx.Err() == nil {
childCount, childrenUnavailable = 0, true
} else {
C.g_object_unref(C.gpointer(source))
releasePending()
return ObjectID{}, nil, fmt.Errorf("query AT-SPI child count: negative result (bus %q path %q role %q captured_nodes %d)",
snapshot.BusName, snapshot.Path, snapshot.Role, len(nodes))
}
}
if reviewBusName == "" && len(scheduled)+childCount > maxTreeNodes {
C.g_object_unref(C.gpointer(source))
@@ -318,6 +327,10 @@ func captureNativeTree(ctx context.Context, root *C.AtspiAccessible, reviewBusNa
if child != nil {
C.g_object_unref(C.gpointer(child))
}
if reviewOnly && ctx.Err() == nil {
childrenUnavailable = true
continue
}
C.g_object_unref(C.gpointer(source))
releasePending()
return ObjectID{}, nil, err
@@ -362,7 +375,7 @@ func captureNativeTree(ctx context.Context, root *C.AtspiAccessible, reviewBusNa
if document && refresh {
snapshot.TextChildren = nativeTextChildren(ctx, source, snapshot.CharacterCount, children)
}
nodes = append(nodes, TreeNode{Snapshot: snapshot, Children: children, Geometry: geometry, Text: text})
nodes = append(nodes, TreeNode{Snapshot: snapshot, Children: children, Geometry: geometry, Text: text, ChildrenUnavailable: childrenUnavailable})
trace.progress(snapshot.Role, len(nodes), len(pending), textBytes)
C.g_object_unref(C.gpointer(source))
}
@@ -412,6 +425,9 @@ func cthulhuAtspiTreeCaptureCallback(userData unsafe.Pointer) {
} else if request.setFocusedCaret {
err := adapter.setNativeFocusedTextCaret(request.ctx, request.reviewFocus, request.positionOffset)
request.result <- treeCaptureResult{err: err}
} else if request.readFocusedLine {
content, err := adapter.read_native_focused_line(request.ctx, request.reviewFocus)
request.result <- treeCaptureResult{content: content, err: err}
} else if request.readFocusedText {
content, err := adapter.readNativeFocusedText(request.ctx, request.reviewFocus)
request.result <- treeCaptureResult{content: content, err: err}