mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibWeb: Implement user-select
This implements all values of user-select.
This commit is contained in:
parent
ba43dfe49a
commit
9370990ff2
Notes:
github-actions[bot]
2025-01-08 14:38:35 +00:00
Author: https://github.com/Psychpsyo
Commit: 9370990ff2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3176
Reviewed-by: https://github.com/AtkinsSJ ✅
11 changed files with 274 additions and 29 deletions
|
@ -315,14 +315,18 @@ void ViewportPaintable::recompute_selection_states(DOM::Range& range)
|
|||
|
||||
// 4. Mark the selection end node as End (if text) or Full (if anything else).
|
||||
if (auto* paintable = end_container->paintable()) {
|
||||
if (is<DOM::Text>(*end_container))
|
||||
if (is<DOM::Text>(*end_container) || end_container->is_ancestor_of(start_container)) {
|
||||
paintable->set_selection_state(SelectionState::End);
|
||||
else
|
||||
paintable->set_selection_state(SelectionState::Full);
|
||||
} else {
|
||||
paintable->for_each_in_inclusive_subtree([&](auto& layout_node) {
|
||||
layout_node.set_selection_state(SelectionState::Full);
|
||||
return TraversalDecision::Continue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Mark the nodes between start node and end node (in tree order) as Full.
|
||||
for (auto* node = start_container->next_in_pre_order(); node && node != end_container; node = node->next_in_pre_order()) {
|
||||
for (auto* node = start_container->next_in_pre_order(); node && (node->is_before(end_container) || node->is_descendant_of(end_container)); node = node->next_in_pre_order()) {
|
||||
if (auto* paintable = node->paintable())
|
||||
paintable->set_selection_state(SelectionState::Full);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue