New issue
Advanced search Search tips

Issue 850380 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 26
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 1
Type: Bug-Regression

Blocked on:
issue 752095



Sign in to add a comment

opening select element invokes scroll to top.

Reported by k.mor...@gmail.com, Jun 7 2018

Issue description

Chrome Version: <from About Google Chrome/Chromium or
'about:version'> 

Google Chrome	67.0.3396.79 (Official Build) (64-bit) (cohort: 67_win_79)
Revision	161bdad7314804dc8c72f850396fcd696e8863e8-refs/branch-heads/3396@{#755}
OS	Windows
JavaScript	V8 6.7.288.44
Flash	30.0.0.113 C:\Users\kmora\AppData\Local\Google\Chrome\User Data\PepperFlash\30.0.0.113\pepflashplayer.dll
User Agent	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36
Command Line	"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --flag-switches-begin --enable-smooth-scrolling --flag-switches-end
Executable Path	C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Profile Path	C:\Users\kmora\AppData\Local\Google\Chrome\User Data\Default
Variations	c134752e-f3c7849
5f419cc9-ca7d8d80
59aeb88e-3f4a17df
31101bd6-71a713bf
a6674cf-ca7d8d80
3095aa95-3f4a17df
c27fec31-2d5b6ed9
7c1bc906-f55a7974
47e5d3db-3d47f4f4
4dc30737-b8a5ea08
589b4e9f-3f4a17df
f9884634-659882c0
121ae2bc-ca7d8d80
267255c3-ca7d8d80
ceff87ec-3f4a17df
44827ee5-ca7d8d80
5e3a236d-4113a79e
8f1e27f-ca7d8d80
9773d3bd-f23d1dea
9e5c75f1-1039a221
f79cb77b-3d47f4f4
a97bc193-bf75d637
4ea303a6-ecbb250e
bcc34a89-3f4a17df
7aa46da5-c946b150
2b33233e-cc2bd7de
2c1d398c-ca7d8d80
2a32876a-ca7d8d80
ff29b1bd-f1e1957e
da460ac8-3d47f4f4
4bc337ce-69465896
9a2f4e5b-ca7d8d80
17507c76-ca7d8d80
494d8760-52325d43
f47ae82a-746c2ad4
3ac60855-486e2a9c
f296190c-6bdfffe7
4442aae2-7158671e
ed1d377-e1cc0f14
12e17bc5-e1cc0f14
75f0f0a0-d7f6b13c
e2b18481-7158671e
e7e71889-e1cc0f14
f5fff3a2-fe8847a
94e68624-803f8fc4
720f4871-3f4a17df
Linker	link.exe


URL: a general issue



Behavior in Firefox 60.0.2: is correct, as it was before.



Steps to reproduce:
(1) Go to test page http://jsfiddle.net/bsru7q9n/
(2) Scroll down to the bottom of the page. 
(3) Click on the contenteditable content.
(4) Click on the select element.



Expected result: page should stay at the bottom.


Actual result: page scrolls to the top.



Note: This issue is generated after upgrading to chrome 67.
 

Comment 1 by woxxom@gmail.com, Jun 7 2018

Bisect info: 549505 (good) - 549514 (bad)
https://chromium.googlesource.com/chromium/src/+log/fa01f1ef..0bd16722?pretty=fuller
Suspecting r549511 = 348d23ce26e25195a70f0be40f88d72b8fad0955 = https://crrev.com/c/955544 by adithyas@chromium.org
"Skip layout if possible in Element.focus"
Landed in 67.0.3394.0

P.S. Attaching a simplified test.html: 1. click the selector, 2. observe
test.html
397 bytes View Download

Comment 2 by tkent@chromium.org, Jun 7 2018

Components: Blink>Forms>Select Blink>HTML>Focus
Labels: -Type-Bug -Pri-3 Target-68 Pri-1 Type-Bug-Regression
Owner: adithyas@chromium.org
Status: Assigned (was: Unconfirmed)
Status: Fixed (was: Assigned)
This was fixed by https://crrev.com/c/1089042.

Comment 4 by tkent@chromium.org, Jun 15 2018

Cc: bokan@chromium.org
Status: Assigned (was: Fixed)
> This was fixed by https://crrev.com/c/1089042.

This is still reproducible with 69.0.3460.0 canary.

Ahh sorry, I was testing it with an older patchset in the CL. This is definitely related to the UpdateLayout call in SetFocusedElement, removing it from there fixes this.

Comment 6 by k.mor...@gmail.com, Jun 17 2018

Still happens in 69.0.3462.0 canary.
Seems like having the UpdateStyleAndLayout here (https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/core/dom/document.cc#4653) changes the result of BoundingBoxForScrollIntoView for the select element from (8, 0) to (8, -766), which is causing the scroll I think. I'm not really sure why, any ideas bokan@?

Comment 8 by bokan@chromium.org, Jun 18 2018

Cc: adithyas@chromium.org
Owner: bokan@chromium.org
Looks like the scroll position is incorrectly accounted for in the layout. I'll take a closer look tomorrow.
Components: Blink>Scroll
Owner: chaopeng@chromium.org
I'll be OOO for a few weeks so assigning to chaopeng@ to take a look 
Cc: chaopeng@chromium.org
Owner: sunyunjia@chromium.org
I have do some investigation:

1. It calls focus twice.
  1) from HTMLSelectElement::MenuListDefaultEventHandler, focus to <select>
  2) from V8HTMLElement::focusMethod, focus to <select><option>
  Scroll to top happens in the second one.
2. I also see the BoundingBoxForScrollIntoView changed after UpdateStyleAndLayoutIgnorePendingStylesheetsForNode[1] in Document::SetFocusedElement: "0,0 30.4063x333.875" -> "0,0 47x36"

[1] https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/dom/document.cc?rcl=7a5feed58d4c2e2e8870d1dbd9e05e61039b9d27&l=4591

Assign to sunyunjia@. She may know this since it is related to ScrollIntoView.
Cc: flackr@chromium.org
Dug into this a bit, it's caused by LayoutObject::AbsoluteBoundingBoxRectForScrollIntoView for the select dropdown returning the wrong value. When the page is scrolled down and we ask for its absolute bounding box location, the value we get is (0px, -4848px) (for e.g.). This is wrong because the select is sticky and appears at the top of the viewport so it's absolute bounding box should be ~(0px, 0px).

It looks like the fault is in LayoutBox::MapLocalToAncestor. There we have:

bool is_fixed_pos = Style()->GetPosition() == EPosition::kFixed;
if (CanContainFixedPositionObjects() && !is_fixed_pos)
    mode &= ~kIsFixed;
  else if (is_fixed_pos)
    mode |= kIsFixed;

And sure enough, switching to position: fixed doesn't have the same issue. Presumably we should be checking for sticky and doing something similar.

flackr@, how do we correctly handle scroll-offset for sticky objects? 
ping, flackr@ - do you know how we should do this?
Cc: smcgruer@chromium.org
This sounds like another bug similar to several that Stephen has worked on fixing. As sticky constraints are updated during the compositing inputs / prepaint walk, we can't correctly calculate sticky position until that is clean. Stephen added Document::EnsurePaintLocationDataValidForNode for this purpose which is called when we require a node have correct paint location. You may be able to resolve by ensuring that this is called.

In general, these issues would be fixed by issue 752095 except that we haven't had time to prioritize it, but my understanding is that layoutng is going to aim to move sticky constraint calculation.
This bug still exists in the latest stable chrome Version 69.0.3497.100 (Official Build) (64-bit).
Blockedon: 752095
Owner: adithyas@chromium.org
Seems like a real solution will require fixing issue 752095. In the mean time, adithyas@, could you look into mitigating the issue for sticky Elements since this is a regression?
Project Member

Comment 16 by bugdroid1@chromium.org, Sep 19

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

commit e1aa11528e75bad7d7676d44970338a8e1c12a6b
Author: Adithya Srinivasan <adithyas@chromium.org>
Date: Wed Sep 19 16:42:14 2018

Fix focus for sticky elements

As per discussion in the associated bug, we call
EnsurePaintLocationDataValidForNode, which ensures that the document
lifecycle is advanced to kCompositingInputsClean for sticky elements in
order to correctly calculate its position.

Bug:  850380 
Change-Id: I27665028393cee6f330fda747b4a344e994fe8fe
Reviewed-on: https://chromium-review.googlesource.com/1231378
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592440}
[add] https://crrev.com/e1aa11528e75bad7d7676d44970338a8e1c12a6b/third_party/WebKit/LayoutTests/fast/css/sticky/sticky-focus-after-scroll.html
[modify] https://crrev.com/e1aa11528e75bad7d7676d44970338a8e1c12a6b/third_party/blink/renderer/core/dom/document.cc

I checked Chrome Canary 71.0.3557.0 and the bug is fixed. 
Thanks a lot!
Labels: Target-71
Status: Fixed (was: Assigned)
Cc: vamshi.kommuri@chromium.org
 Issue 908898  has been merged into this issue.
Cc: susan.boorgula@chromium.org
 Issue 910052  has been merged into this issue.

Sign in to add a comment