Make web document navigation survive live-updating pages
Recreated-node caret recovery, tolerant caret validation, per-root retained document trees and cursors across tab switches, document warm-up, coalesced structural moves, and hung-provider fast-fail with an 'Application is not responding' announcement.
This commit is contained in:
1 parent
8ce5e5cdad
commit
7eef6e8be6
30 files changed
+1484
-174
No files matched your search
@@ -23,12 +23,23 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// WarmDocument captures and syncs the currently focused document in the
|
||||
// background so the first navigation key does not pay for a cold capture.
|
||||
// Best-effort: a full queue or a focus outside web content is ignored by
|
||||
// the worker, and no result is delivered.
|
||||
func (worker *Worker) WarmDocument() {
|
||||
select {
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), documentLoadEpoch: worker.documentLoadEpoch.Load(), warmDocument: true, queuedAt: time.Now()}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func (worker *Worker) MoveDocumentCaret(command DocumentCaretCommand) error {
|
||||
if !command.valid() {
|
||||
return ErrInvalidDirection
|
||||
}
|
||||
select {
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), caretCommand: command, queuedAt: time.Now()}:
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), documentLoadEpoch: worker.documentLoadEpoch.Load(), caretCommand: command, queuedAt: time.Now()}:
|
||||
return nil
|
||||
default:
|
||||
return ErrRequestQueueFull
|
||||
@@ -37,7 +48,7 @@ func (worker *Worker) MoveDocumentCaret(command DocumentCaretCommand) error {
|
||||
|
||||
func (worker *Worker) ActivateDocumentCaret() error {
|
||||
select {
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), activate: true, queuedAt: time.Now()}:
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), documentLoadEpoch: worker.documentLoadEpoch.Load(), activate: true, queuedAt: time.Now()}:
|
||||
return nil
|
||||
default:
|
||||
return ErrRequestQueueFull
|
||||
@@ -49,7 +60,7 @@ func (worker *Worker) ReadAll(ctx context.Context) error {
|
||||
return errors.New("read all: nil context")
|
||||
}
|
||||
select {
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), readAll: ctx, queuedAt: time.Now()}:
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), documentLoadEpoch: worker.documentLoadEpoch.Load(), readAll: ctx, queuedAt: time.Now()}:
|
||||
return nil
|
||||
default:
|
||||
return ErrRequestQueueFull
|
||||
@@ -61,7 +72,7 @@ func (worker *Worker) JumpToDocumentFragment(fragment string) error {
|
||||
return ErrInvalidDirection
|
||||
}
|
||||
select {
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), fragment: fragment, queuedAt: time.Now()}:
|
||||
case worker.requests <- request{documentEpoch: worker.documentEpoch.Load(), documentLoadEpoch: worker.documentLoadEpoch.Load(), fragment: fragment, queuedAt: time.Now()}:
|
||||
return nil
|
||||
default:
|
||||
return ErrRequestQueueFull
|
||||
|
||||
Reference in new issue
Block a user