New issue
Advanced search Search tips

Issue 919540 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

selectionStart / selectionEnd not available on focus

Reported by jasonbio...@gmail.com, Jan 7

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36

Steps to reproduce the problem:
1. Click in the textarea (somewhere other than the start)
3. Note the values in immediate vs. after timeout: They differ

What is the expected behavior?
The selectionStart / selectionEnd values should be immediately available upon focus. This is the behavior seen in Firefox (64.0) and Edge (42.17134.1.0).

What went wrong?
The selectionStart / selectionEnd values are only available after a timeout. Due to this, we need to introduce a timeout if we need to reposition the cursor, which introduces visual artifacts.

Did this work before? N/A 

Chrome version: 71.0.3578.98  Channel: stable
OS Version: 10.0
Flash Version: 

Possibly related bug: https://bugs.chromium.org/p/chromium/issues/detail?id=915231
 
selectionTimeout.html
975 bytes View Download
Components: -Blink Blink>Editing
Labels: Needs-Triage-M71
Cc: viswa.karala@chromium.org
Labels: Triaged-ET Needs-Feedback
Tried testing the issue on chrome reported version# 71.0.3578.98 using Windows-10 with steps mentioned below:
1) Launched chrome reported version, dragged and dropped the '.html' file provided in comment# 0
2) Clicked in the text area space, observed "Selection start (immediate):0 and Selection start (after timeout):8"
Observations: Tested the same on Firefox, observed "Selection start (immediate):8 and Selection start (after timeout):8"

@Reporter: Please find above mentioned mentioned information and attached screencast for your reference and let us know if you are pointing the same which i have captured in the screencast. If possible provide screencast of the issue which help in better understanding and further triaging it in better way.

Thanks!
919540.mp4
768 KB View Download
Please note that "Selection start (immediate)" is 0 in Chrome but 8 in Firefox (and also Edge). It is this value which causes problems --it forces us to introduce an arbitrary timeout before we can even retrieve the "current" position, by which time the cursor is already drawn.
Project Member

Comment 5 by sheriffbot@chromium.org, Jan 8

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: Target-73 M-73 FoundIn-71 FoundIn-73 FoundIn-72 OS-Linux OS-Mac
Status: Untriaged (was: Unconfirmed)
Able to reproduce the issue on chrome reported version# 71.0.3578.98 and on latest chrome# 73.0.3665.0 with '.html' file provided in comment# 0 using Mac 10.12.6, Windows-10 and Ubuntu 17.10. As this issue is seen from M-60(60.0.3112.0), hence considering this as Non-Regression and marking it as Untriaged.

Thanks!
 Issue 915231  has been merged into this issue.
Mark WontFix since Safari(WebKit) behaves as Chrome(Blink). Since two major browsers behave same instead of one, not count Edge since it will use Blink.

Please file an issue in w3c/uievent[1] if you want to change current behavior. 
Note: moving focus and updating selection are part of default action of "mousedown" event, and the spec[2] doesn't specify it.


# Blink Implementation
During mouse press processing, Chrome updates selection to mouse pressed point after dispatching "focus" event then selection{Start,End} hold values before setting selection on event point.

Here is code path:
* EventHandler::HandleMousePressEvent()
* ... dispatch "mousedown" event
* MouseEventManager::HandleMouseFocus() -> dispatch "focus" event
* ... execute "focus" event handler
* MouseEventManager::HandleMousePressEvent()
* SelectionController::HandleMousePressEvent() -> update selection then dispatch "click" event

[1] https://github.com/w3c/uievents/issues/
[2] https://www.w3.org/TR/uievents/#event-type-mousedown

Components: -Blink>Editing Blink>Editing>Selection
Status: WontFix (was: Untriaged)
Project Member

Comment 10 by bugdroid1@chromium.org, Jan 10

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

commit ff316f886c168fb26f94e35f3f948b9da2107cd1
Author: Yoshifumi Inoue <yosin@chromium.org>
Date: Thu Jan 10 08:09:03 2019

Simplify MouseEventManager::HandleMouseFocus()

This patch simplifies |MouseEventManager::HandleMouseFocus()| by sharing common
code patch and utilizing early-return style for improving readability.

Bug: 919540
Change-Id: Ie6508d1c508e6d4e2b0ed589d634290e7edc8696
Reviewed-on: https://chromium-review.googlesource.com/c/1404553
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#621496}
[modify] https://crrev.com/ff316f886c168fb26f94e35f3f948b9da2107cd1/third_party/blink/renderer/core/input/mouse_event_manager.cc

Demo for mousedown, focus, click
https://jsfiddle.net/34vcawqk/3
Labels: Needs-Feedback
Able to reproduce the issue on chrome reported version 71.0.3578.98 with '.html' file provided in comment# 0. Tried verifying the fix on latest chrome# 73.0.3668.0, but issue is still seen there(i.e., "Selection start (immediate):0 and Selection start (after timeout):8").

Yoshifumi Inoue@ Please find the attached screencast for your reference and help us in verifying the fix.

Thanks!

919540.mp4
549 KB View Download

Comment 13 by ligimole@google.com, Jan 17 (5 days ago)

Status: Assigned (was: WontFix)

Sign in to add a comment