New issue
Advanced search Search tips

Issue 702610 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Changes in ::selection not reflected when changeing class

Reported by m.lewand...@cksource.com, Mar 17 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

Example URL:
http://codepen.io/mlewand/pen/zZPerd

Steps to reproduce the problem:
I made an example where styles are toggled every 1 sec. You'll see that in some cases ::selection styles are not applied.

1. Open http://codepen.io/mlewand/pen/zZPerd
2. Make a ranged (containing multiple chars) selection.
3. Wait about 2 secs for styles to toggle (you can see it based on outline color.

What is the expected behavior?
Background should be changed as in the second input (there I'm changing ::selection background AND font-style, which forces repaint.

What went wrong?
I believe it's some sort of optimization to prevent repaint. Because if you force the repaint selection is displayed correctly.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 56.0.2924.87  Channel: n/a
OS Version: 10.0
Flash Version:
 
Components: -Blink Blink>CSS
Components: -Blink>CSS Blink>Paint
I've tried this on Linux (M57) and it doesn't seem to reproduce. Do you have a screen cap of it occurring?
Labels: Needs-Feedback BugSource-User PaintTeamTriaged-20170317
NextAction: 2017-03-27
Sure - here I'm adding a screen cast. So if you can't repro it on Linux it looks to be a Win-specific issue.
Chrome's __selection style bug - Google Chrome 3_21_2017 4_57_51 PM.mp4
28.5 MB Download
Project Member

Comment 6 by sheriffbot@chromium.org, Mar 21 2017

Cc: schenney@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "schenney@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: wangxianzhu@chromium.org pdr@chromium.org wkorman@chromium.org
Components: -Blink>Paint Blink>Paint>Invalidation
NextAction: ----
Status: Available (was: Unconfirmed)
It does reproduce on Linux with M-58

This appears to be an invalidation problem because mousing over the element causes the background to change, consistent with repainting due to the cursor. Also, we do invalidate if the font changes, also suggesting that the background changing is not resulting in invalidation.
Great, thanks for checking. Since you can repro it also on Linux, could you please update ticket's OS property accordingly?
Labels: OS-Linux OS-Mac
Project Member

Comment 10 by bugdroid1@chromium.org, Feb 27 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/313c77246b3f08392edb2a6d0ac8ba15987725bf

commit 313c77246b3f08392edb2a6d0ac8ba15987725bf
Author: Philip Rogers <pdr@chromium.org>
Date: Tue Feb 27 23:19:53 2018

[PE] Invalidate text control selection when pseudo style changes

In the simplest case, ::selection styles only apply to the selected
children of an element. For example, "second" will not have a
selection background color style in the following example:
<style> .foo::selection { background: red; } </style>
<span class="foo">first <span>second</span> third</span>

Text controls such as <input> and <textarea> are implemented with a
user agent shadow tree so the LayoutText contents are not children
of the text control parent. For example:
<input type="text" value="AAAAAAAAAAAA">
Generates this layout tree:
LayoutTextControl INPUT
  LayoutBlockFlow DIV (editable) <-- part of the user agent shadow tree
    LayoutText #text "AAAAAAAAAAAA"

When painting selection, there is a special-case for text control
contents (see: GetUncachedSelectionStyle in SelectionPaintingUtils.cpp)
which uses the text control's pseudo selection style.

This patch adds a special-case for selection invalidation so changes to
text control pseudo styles invalidate selected text contents too.

Bug:  702610 
Change-Id: I06b549b5b5eff77d71c4ea58ce12eaf00519f538
Reviewed-on: https://chromium-review.googlesource.com/929664
Reviewed-by: Philip Rogers (OOO) <pdr@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Philip Rogers (OOO) <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539575}
[modify] https://crrev.com/313c77246b3f08392edb2a6d0ac8ba15987725bf/third_party/WebKit/Source/core/BUILD.gn
[modify] https://crrev.com/313c77246b3f08392edb2a6d0ac8ba15987725bf/third_party/WebKit/Source/core/layout/LayoutObject.cpp
[modify] https://crrev.com/313c77246b3f08392edb2a6d0ac8ba15987725bf/third_party/WebKit/Source/core/layout/LayoutObject.h
[modify] https://crrev.com/313c77246b3f08392edb2a6d0ac8ba15987725bf/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
[add] https://crrev.com/313c77246b3f08392edb2a6d0ac8ba15987725bf/third_party/WebKit/Source/core/layout/LayoutTextControlTest.cpp

Comment 11 by pdr@chromium.org, Feb 27 2018

Cc: -wkorman@chromium.org
Owner: pdr@chromium.org
Status: Fixed (was: Available)
@m.lewandowski, thanks for taking the time to file this with a nice small testcase.

Sign in to add a comment