Skip to content

script/layout: Show visible selection on images - #48149

Merged
mrobinson merged 1 commit into
servo:mainfrom
mrobinson:selection-images
Sep 18, 2026
Merged

mrobinson merged 1 commit into
servo:mainfrom
mrobinson:selection-images

Conversation

@mrobinson

@mrobinson mrobinson commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

This change adds support for visible selection of images. Now when an
image is selected a transparent overlay (based on the ::selection
color is drawn over it).

Testing: This change adds two Servo-specific WPT-style tests. Two more
WPT tests start to pass and one starts to fail (due to not fully supporting
SVG).

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 17, 2026
@mrobinson mrobinson mentioned this pull request Sep 17, 2026
25 of 40 tasks
Comment thread components/shared/layout/lib.rs Outdated
Comment on lines +87 to +88
/// Set whether or not this node is selected when it is an element.
fn set_element_selection(&self, selected: bool) -> bool;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the meaning of the return value, it looks like it’s not the same as for set_text_run_selection?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This is done now.

});
self.set_character_data_selection(character_data, range);
} else if node.set_element_selection(flat_tree_selection.is_some()) {
self.needs_new_display_list = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VisibleSelectionFlagUpdate::set_character_data_selection above has a code path calling Node::dirty, is something similar not necessary for replaced elements?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Node::dirty call is only necessary for ::first-letter. Normally if there's no box, the node is already marked as dirty for layout. We still need the Node::dirty call when selection changes on something with ::first-letter.

Comment on lines +59 to +61
/// Whether or not this replaced element is selected by the document selection.
#[conditional_malloc_size_of]
pub selected: Arc<AtomicBool>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Arc is for sharing the same mutable AtomicBool with ImageFragment, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct.

Comment on lines +894 to +895
// Selected style resolution falls back to the style of the element itself,
// and in that case we don't want to paint any overlay.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should text selection background have the same special case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, probably, though the failure mode is less severe.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Sep 17, 2026
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 18, 2026
@mrobinson
mrobinson enabled auto-merge September 18, 2026 13:58
@mrobinson
mrobinson added this pull request to the merge queue Sep 18, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Sep 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 18, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Sep 18, 2026
This change adds support for visible selection of images. Now when an
image is selected a transparent overlay (based on the `::selection`
color is drawn over it).

Signed-off-by: Martin Robinson <[email protected]>
@servo-highfive servo-highfive removed the S-tests-failed The changes caused existing tests to fail. label Sep 18, 2026
@mrobinson
mrobinson enabled auto-merge September 18, 2026 16:53
@mrobinson
mrobinson added this pull request to the merge queue Sep 18, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Sep 18, 2026
Merged via the queue into servo:main with commit 58c86d0 Sep 18, 2026
34 checks passed
@mrobinson
mrobinson deleted the selection-images branch September 18, 2026 18:34
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Sep 18, 2026
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
This change adds support for visible selection of images. Now when an
image is selected a transparent overlay (based on the `::selection`
color is drawn over it).

Testing: This change adds two Servo-specific WPT-style tests. Two more
WPT tests start to pass and one starts to fail (due to not fully
supporting
SVG).

Signed-off-by: Martin Robinson <[email protected]>
hhhwsqhhh pushed a commit to hhhwsqhhh/servo that referenced this pull request Oct 12, 2026
This change adds support for visible selection of images. Now when an
image is selected a transparent overlay (based on the `::selection`
color is drawn over it).

Testing: This change adds two Servo-specific WPT-style tests. Two more
WPT tests start to pass and one starts to fail (due to not fully
supporting
SVG).

Signed-off-by: Martin Robinson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants