Bug 209715 - scrollIntoView() erroneously scrolls non-containing block scrollers
Summary: scrollIntoView() erroneously scrolls non-containing block scrollers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Scrolling (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-28 20:41 PDT by Simon Fraser (smfr)
Modified: 2020-03-30 17:08 PDT (History)
10 users (show)

See Also:


Attachments
Testcase (1.50 KB, text/html)
2020-03-28 20:41 PDT, Simon Fraser (smfr)
no flags Details
Patch (14.95 KB, patch)
2020-03-30 11:46 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (14.91 KB, patch)
2020-03-30 14:36 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (14.86 KB, patch)
2020-03-30 14:38 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (16.00 KB, patch)
2020-03-30 14:45 PDT, Simon Fraser (smfr)
zalan: review+
Details | Formatted Diff | Diff
Patch (16.60 KB, patch)
2020-03-30 15:04 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2020-03-28 20:41:28 PDT
Created attachment 394857 [details]
Testcase

RenderLayer::scrollRectToVisible() walks the parent chain and calls scrollIntoView() on each enclosing layer. But this is wrong, because not all parent layers are in the containing block chain.

Attached testcase shows the bug.
Comment 1 Simon Fraser (smfr) 2020-03-28 20:43:28 PDT
Needs to share code with scroll latching ancestor finding.
Comment 2 Simon Fraser (smfr) 2020-03-30 11:46:33 PDT
Created attachment 394941 [details]
Patch
Comment 3 Darin Adler 2020-03-30 13:47:32 PDT
Comment on attachment 394941 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394941&action=review

> Source/WebCore/rendering/RenderLayer.cpp:1922
> +    for (RenderLayer* nextLayer = enclosingContainingBlockLayer(*this, crossFrameBoundaries);nextLayer; nextLayer = enclosingContainingBlockLayer(*nextLayer, crossFrameBoundaries)) {

Missing space after semicolon. Also, why not use auto instead of type name here?

> Source/WebCore/rendering/RenderLayer.cpp:2896
> +                    auto* enclosingLayer = ownerElement->renderer()->enclosingLayer();
> +                    if (enclosingLayer)

Why not put this inside the if?
Comment 4 Simon Fraser (smfr) 2020-03-30 14:36:25 PDT
Created attachment 394963 [details]
Patch
Comment 5 Simon Fraser (smfr) 2020-03-30 14:38:49 PDT
Created attachment 394964 [details]
Patch
Comment 6 Simon Fraser (smfr) 2020-03-30 14:45:35 PDT
Created attachment 394966 [details]
Patch
Comment 7 Darin Adler 2020-03-30 14:50:47 PDT
Comment on attachment 394966 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394966&action=review

> Source/WebKitLegacy/win/WebView.cpp:2041
> +        if (m_gestureTargetNode && m_gestureTargetNode->renderer() && m_gestureTargetNode->renderer()->enclosingLayer()) {
> +            if (auto* layer = m_gestureTargetNode->renderer()->enclosingLayer())

Seems like a double null check on enclosingLayer.
Comment 8 Simon Fraser (smfr) 2020-03-30 14:59:46 PDT
(In reply to Darin Adler from comment #7)
> Comment on attachment 394966 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394966&action=review
> 
> > Source/WebKitLegacy/win/WebView.cpp:2041
> > +        if (m_gestureTargetNode && m_gestureTargetNode->renderer() && m_gestureTargetNode->renderer()->enclosingLayer()) {
> > +            if (auto* layer = m_gestureTargetNode->renderer()->enclosingLayer())
> 
> Seems like a double null check on enclosingLayer.

Oops yeah. Will fix.
Comment 9 Simon Fraser (smfr) 2020-03-30 15:04:43 PDT
Created attachment 394971 [details]
Patch
Comment 10 EWS 2020-03-30 17:03:30 PDT
Committed r259248: <https://trac.webkit.org/changeset/259248>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 394971 [details].
Comment 11 Radar WebKit Bug Importer 2020-03-30 17:08:33 PDT
<rdar://problem/61081100>