Skip to content

Instantly share code, notes, and snippets.

@plateaukao
Created November 3, 2023 14:36
Show Gist options
  • Save plateaukao/921ee2f55b66ea3cc29df60ac7843ea2 to your computer and use it in GitHub Desktop.
Save plateaukao/921ee2f55b66ea3cc29df60ac7843ea2 to your computer and use it in GitHub Desktop.
sequence diagram of android webview link text selection
@startuml
autonumber
actor User as user
participant Activity as a
participant WebView as w
w -> w: onPageFinished()\naddSelectionChangeListener()
note over w
Javascript on selectionchange listener:
2. find and return the position of (start and)
end position of the selection range
3. updateSelectionRect() to Activity
The Rect is used to place context menu
according to selection range.
end note
user -> a : long click on link
a --> user : show actionMode menu
user -> a : trigger text selection
activate w
a -> w : selectLinkText()
w -> w : JS: select text of current node
w -> a : simulateLongClick()
a --> user: show text selection context menu
w -> w : add back href attribute
deactivate w
@enduml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment