New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 7 users

Issue metadata

Status: Fixed
Closed: May 2017
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 1
Type: Bug-Regression

issue 715889

Sign in to add a comment

FOCUS: Broken autoscroll around focus/selecting

Reported by, Apr 19 2017 Back to list

Issue description

Chrome Version:60.0.3074.0 (Official Build) 147bd1eedea8ce66f162faa43535d60137817d91-refs/heads/master@{#465085}
OS: Windows (7,8,8.1,10),Linux (14.04 LTS),Mac OS X(10.11.6,10.12.1)

1. Enable ‘Show Home button’ and set any page(chrome://settings/) as a Home.
2. Resize the browser window such that first radio button of home page is seen at the end OR
3. Sign-in the browser with validate credentials (no need to resize the browser window)

What steps will reproduce the problem?
1. Launch chrome and navigate to chrome://md-settings/
2. Press ‘Tab’ key till focus reaches to ‘Show bookmarks bar’ toggle button and then press ‘Shift+Tab’ such that focus reaches back to ‘Sign into chrome’
3. Again press ‘Tab’ key till focus reaches second radio button of Home button, again press ‘Tab’ key once and Observe scrollbar.

Actual: Page get Auto scrolled upwards after step 3.
Expected: Page should not Auto scrolled upwards after step 3.(i.e. Scrollbar should be at the mid of the page and Tab focus should be seen)

This is regression issue, broken in ‘M 60’ and below is Manual bisect info:
Good build:59.0.3071.9
Bad build:60.0.3072.0
4.1 MB Download
4.0 MB Download
Labels: Needs-Bisect
Status: Untriaged
Labels: -Needs-Bisect hasbisect-per-revision Proj-MaterialDesign-WebUI
Status: Assigned
Able to reproduce this issue on windows 7, Mac 10.11.4,Linux Ubuntu 14.04 with Chrome Canary-60.0.3074.0 
Manual Bisect:
Good build:59.0.3071.9-Revision-464641
Bad build:60.0.3072.0-Revision-464836

Per Revision Bisect Tool Info:
You are probably looking for a change made after 464697 (known good), but no later than 464698 (first known bad).
The script might not always return single CL as suspect as some perf builds might get missing due to failure.


Yosin@ assigning to you, as you were listed as one of the reviewers for this CL.

Kindly take a look and please help us to reassign this issue to a right owner if not with respect to this change.

Comment 3 by, Apr 20 2017

I think this is the minimal test case:

<div style="background: green; padding: 20%;">
  <a href="www">a focusable link</a>
  <div style="height: 70%;"></div>

  <div style="background: orange; padding: 20%;">
    <input value="hola">

1. Use tab key to cycle through all focusable items.
2. In the >= second cycle, notice:
Actual: No scrolling (viewport shows top of page).
Expected: Scroll to <input> when it gets the focus.

Labels: Hotlist-MD-Settings-General

Comment 5 by, Apr 25 2017

Components: -UI>Settings Blink>Editing
Labels: -Proj-MaterialDesign-WebUI -Hotlist-MD-Settings-General
Summary: Broken autoscroll when focusing hidden selection (was: Regression: Weird behaviour is seen of scrollbar on [MD-settings] page using Tab key.)
yosin@, do you know how to fix this one?

Comment 6 by, Apr 25 2017

Components: -Blink>Editing Blink>Editing>Selection
Layout Test:

<input value="hola" id="hola" style="margin-top: 150%">
<script type="text/javascript">
  document.getElementById("hola").select(); // Does focus but doesn't scroll.
  document.getElementById("hola").blur(); // Hides selection.
  window.scrollTo(0,document.body.scrollHeight); // Scrolls to bottom.
  document.getElementById("hola").focus(); // Should not trigger scroll to top.

Comment 7 by, Apr 27 2017

Blocking: 715889

Comment 8 by, Apr 27 2017

Labels: -M-60

Comment 9 by, Apr 27 2017

Labels: M-60
Summary: FOCUS Broken autoscroll when focusing hidden selection (was: Broken autoscroll when focusing hidden selection )

Comment 10 by, Apr 27 2017

Owner: ----
Status: Available
Status: Started
Summary: FOCUS: Broken autoscroll around focus/selecting (was: FOCUS Broken autoscroll when focusing hidden selection )
 Issue 714535  has been merged into this issue.
 Issue 718395  has been merged into this issue.
Status: Available

Comment 16 by, May 11 2017

Owner: ----
Status: Started
Status: WontFix
Not reproduced on Version 60.0.3100.0.

Comment 20 by, May 16 2017

I see that the steps in #3 and #6 no longer reproduce the bug.

But I found another way to trigger it on ToT, 60.0.3102.0. Again, cycle focus with tab key:

<input value="hola" style="margin-top: 150%"> // No autoscroll.

Interestingly, when the field is empty, autoscroll works:

<input style="margin-top: 150%"> // Tab cycling triggers autoscroll OK. 

yochio@, do you see this too ?

Status: Unconfirmed
Owner: ----
Status: Available
I see, tab cycling on
 <input value="hola" style="margin-top: 150%"> 

Comment 23 by, May 17 2017

Status: Started

Comment 24 by, May 17 2017

The root cause is using FrameSelection::UnclippedBounds() returns empty rect in FrameSelection::RevealSelection() during TAB navigation.

In #c6, when INPUT element gets focus by TAB navigation, FS::RevalSelection() is called in
Document::SetFocusedElement() before calling FS::DidChangeFocus(), see stack trace below.

Here is stack trace:
FrameSelection::RevealSelection(const blink::ScrollAlignment & alignment, blink::RevealExtentOption reveal_extent_option) Line 1020
HTMLInputElement::UpdateFocusAppearance(blink::SelectionBehaviorOnFocus selection_behavior) Line 314
Document::SetFocusedElement(blink::Element * new_focused_element, const blink::FocusParams & params) Line 4255
FocusController::SetFocusedElement(blink::Element * element, blink::Frame * new_focused_frame, const blink::FocusParams & params) Line 1130
Element::focus(const blink::FocusParams & params) Line 2731
FocusController::AdvanceFocusInDocumentOrder(blink::LocalFrame * frame, blink::Element * start, blink::WebFocusType type, bool initial_focus, blink::InputDeviceCapabilities * source_capabilities) Line 1058
FocusController::AdvanceFocus(blink::WebFocusType type, bool initial_focus, blink::InputDeviceCapabilities * source_capabilities) Line 908
FocusController::AdvanceFocus(blink::WebFocusType type, blink::InputDeviceCapabilities * source_capabilities) Line 78
KeyboardEventManager::DefaultTabEventHandler(blink::KeyboardEvent * event) Line 416
KeyboardEventManager::DefaultKeyboardEventHandler(blink::KeyboardEvent * event, blink::Node * possible_focused_node) Line 291
EventHandler::DefaultKeyboardEventHandler(blink::KeyboardEvent * event) Line 1990
Node::DefaultEventHandler(blink::Event * event) Line 2291
HTMLElement::DefaultEventHandler(blink::Event * event) Line 1119
EventDispatcher::DispatchEventPostProcess(blink::EventDispatchHandlingState * pre_dispatch_event_handler_result) Line 288
EventDispatcher::Dispatch() Line 163
EventDispatchMediator::DispatchEvent(blink::EventDispatcher & dispatcher) Line 52
EventDispatcher::DispatchEvent(blink::Node & node, blink::EventDispatchMediator * mediator) Line 59
Node::DispatchEventInternal(blink::Event * event) Line 2162
EventTarget::DispatchEvent(blink::Event * event) Line 484
KeyboardEventManager::KeyEvent(const blink::WebKeyboardEvent & initial_key_event) Line 226
EventHandler::KeyEvent(const blink::WebKeyboardEvent & initial_key_event) Line 1985
blink_web.dll!blink::WebViewImpl::HandleKeyEvent(const blink::WebKeyboardEvent & event) Line 1165
blink_web.dll!blink::PageWidgetDelegate::HandleInputEvent(blink::PageWidgetEventHandler & handler, const blink::WebCoalescedInputEvent & coalesced_event, blink::LocalFrame * root) Line 181
blink_web.dll!blink::WebViewImpl::HandleInputEvent(const blink::WebCoalescedInputEvent & coalesced_event) Line 2249
blink_web.dll!blink::WebViewFrameWidget::HandleInputEvent(const blink::WebCoalescedInputEvent & event) Line 95

Comment 25 by, May 19 2017


Comment 26 by, May 19 2017

The root cause is we called FS::UnclippedBounds() without dirty selection flag 
in FS::RevealSelection() called by Document::SetFocusedElement().

Note: Document::SetFocusdElement() sets dirty selection flag at end of function
instead of updating |fcosued_element_|. This is why FS::UnclipedBounds() returns
empty rect.

Hence, the solution is using ComputeTextRect() in FS::UnclippedBounds() instead
of LayoutSelection::Bounds().

Note: We should update LayoutSelection just before paint instead of layout clean[1].

[1] we should update LayoutSelection just before paint instead of LayoutClean

Project Member

Comment 27 by, May 19 2017

The following revision refers to this bug:

commit d77cd716740a94334fc7c98749876f4a013b8322
Author: yoichio <>
Date: Fri May 19 14:44:20 2017

Make VisibleUnits::ComputeTextRect() return unified IntRect

Only Range uses Vector<IntRect> but it unifies and return a IntRect.
Just unify in VisibleUnits::ComputeTextRect() directly.

TEST=No change in behavior
BUG= 712986 

Cr-Commit-Position: refs/heads/master@{#473185}


Project Member

Comment 28 by, May 22 2017

Status: Fixed
Labels: TE-Verified-60.0.3112.7 TE-Verified-M60
Verified the issue on windows 10, Mac 10.12.4 and Ubuntu 14.04 using chrome dev version #60.0.3112.7 as per comment #0.

Observed that scrollbar stayed at the mid of the page and tab focus was seen. Hence, the fix is working as expected.

Attaching screen cast for reference.

Hence, adding the verified labels.


1.0 MB View Download

Sign in to add a comment