LibWeb: Skip user-select:none in selection highlight and copy#9709
Merged
AtkinsSJ merged 2 commits intoMay 28, 2026
Conversation
Problem: Select All (Ctrl+A or the context menu) followed by Ctrl+C unexpectedly copies text from elements with user-select:none — breaking compat with Chrome and Firefox, which both exclude user-select:none content from the clipboard. Cause: Navigable::selected_text() walks the selection range via visible_text_in_range() and concatenates each text node’s data. The walk filters out nodes without a layout, but not nodes whose used value of user-select is ‘none’. Fix: Add a user-select check at each visible_text_in_range() walk point. The Selection range itself is left unchanged. Selection.toString() still returns the full text per spec — but the clipboard-extraction path now excludes user-select: none subtrees, per spec
Problem: Select All draws the selection highlight across user-select:none content — breaking compat with Chrome and Firefox, which leave such content unhighlighted. Cause: ViewportPaintable::recompute_selection_states walks the Range and assigns SelectionState::Start|::Full|::End to each layout node within. The walk filters out is_inert() nodes — but not user-select: none nodes. Fix: Extend the existing inert-only guards into a helper that also rejects nodes whose used value of user-select is ‘none’. Such nodes stay at SelectionState::None from the initial reset — so the selection highlight skips them. Fixes LadybirdBrowser#9695
AtkinsSJ
approved these changes
May 28, 2026
AtkinsSJ
enabled auto-merge (rebase)
May 28, 2026 11:03
sideshowbarker
deleted the
sideshowbarker/fix-9695-user-select-none-select-all
branch
May 28, 2026 13:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: Select All (Ctrl+A or the context menu) doesn’t honor
user-select:none— breaking compat with Chrome and Firefox. Two visible symptoms:user-select:nonecontent.Mouse double-click already skips
user-select:nonecorrectly; only the keyboard / context-menu path was broken.Cause: Both Ctrl+A and right-click “Select All” flow through
Selection::select_all_children(body), which sets a singleRangefrom(body, 0)to(body, childCount)— including anyuser-select:nonesubtrees. Two downstream functions then fail to filter:ViewportPaintable::recompute_selection_stateswalks the range and assignsSelectionState::Start,::Full, or::Endto each layout node within. The walk filters outis_inert()nodes — but notuser-select:nonenodes.Navigable::selected_text()walks the range viavisible_text_in_range()and concatenates each text node’s data. Filters out nodes without a layout — but notuser-select:none.Fix: Add a
user-select:nonecheck at each walk point in both functions. The Selection range itself is left unchanged —Selection.toString()still returns the full text per spec — but:user-select:nonenodes atSelectionState::Nonefrom the initial reset, so the highlight skips them.user-select:nonesubtrees.This implements https://drafts.csswg.org/css-ui/#valdef-user-select-none (“The content of the element must be excluded from selection by [...] the selection methods of the Selection API and the like”) at the highlight and clipboard boundaries — matching Chrome and Firefox. Fixes #9695.