Bug 174097

Summary: Introduce ScrollingTreeScrollingNodeDelegateIOS to share code between overflow and frame scrolling
Product: WebKit Reporter: Frédéric Wang (:fredw) <fred.wang>
Component: FramesAssignee: Frédéric Wang (:fredw) <fred.wang>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, cmarcelo, commit-queue, darin, fred.wang, jamesr, luiz, simon.fraser, tonikitoo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 176273    
Bug Blocks: 149264, 173833, 174130    
Attachments:
Description Flags
Part 1
none
Patch
none
Patch
none
Patch
none
Patch
simon.fraser: review-
Patch
none
Patch for landing
none
Patch for landing none

Description Frédéric Wang (:fredw) 2017-07-03 08:26:12 PDT
Attempt to move some code out of ScrollingTreeOverflowScrollingNodeIOS so that it can be used for frames.
Comment 1 Frédéric Wang (:fredw) 2017-07-03 08:51:34 PDT
Created attachment 314486 [details]
Part 1

First part. WKOverflowScrollViewDelegate can now be renamed/moved and more code could be extracted from ScrollingTreeOverflowScrollingNodeIOS.
Comment 2 Frédéric Wang (:fredw) 2017-07-04 03:42:58 PDT
Created attachment 314559 [details]
Patch
Comment 3 Frédéric Wang (:fredw) 2017-07-27 02:45:23 PDT
Created attachment 316538 [details]
Patch

Rebasing...
Comment 4 Frédéric Wang (:fredw) 2017-08-04 01:36:09 PDT
Created attachment 317226 [details]
Patch

Rebasing after r220261
Comment 5 Frédéric Wang (:fredw) 2017-08-04 02:19:41 PDT
Created attachment 317228 [details]
Patch
Comment 6 Simon Fraser (smfr) 2017-09-01 13:01:40 PDT
Comment on attachment 317228 [details]
Patch

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

I think this is on the right track.

> Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h:40
> +#if PLATFORM(IOS)
> +namespace WebKit {
> +class ScrollingTreeScrollingNodeDelegateIOS;
> +}
> +#endif

It's wrong for WebCore to know anything about WebKit, so you can't do this.

Maybe there should be a ScrollingTreeScrollingNodeDelegate base class in WebCore, which WebKit subclasses.

> Source/WebKit/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:145
> +    m_scrollingNodeDelegate.reset(new ScrollingTreeScrollingNodeDelegateIOS(*this));

We never use bare 'new'. This should use make_unique<>.
Comment 7 Frédéric Wang (:fredw) 2017-09-04 09:48:07 PDT
Created attachment 319855 [details]
Patch
Comment 8 Frédéric Wang (:fredw) 2017-09-04 09:53:13 PDT
Comment on attachment 317228 [details]
Patch

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

>> Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h:40
>> +#endif
> 
> It's wrong for WebCore to know anything about WebKit, so you can't do this.
> 
> Maybe there should be a ScrollingTreeScrollingNodeDelegate base class in WebCore, which WebKit subclasses.

OK, I've done that in the patch I just uploaded. The drawback is that now we need to make more non-public members of ScrollingTreeScrollingNode accessible to the UIProcess classes, here and in bug 174130 at least. I've done that by adding new members to ScrollingTreeScrollingNodeDelegate but maybe we want to make the corresponding members of ScrollingTreeScrollingNode public, I don't know. WDYT?
Comment 9 Darin Adler 2017-09-04 20:20:00 PDT
Comment on attachment 319855 [details]
Patch

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

Looks OK.

I think I understand the goal, but this looks a bit awkward. Is this really a “delegate”? Why does the delegate need to access private members of ScrollingTreeScrollingNode?

> Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h:30
> +#include "IntRect.h"

Why? This file doesn’t use IntRect. It does use FloatPoint, though.

> Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h:33
> +namespace WebCore {
> +class ScrollingTreeScrollingNode;

Missing blank line.

> Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:64
> +        _scrollingTreeNodeDelegate = delegate;

How does the object lifetime work? What guarantees this delegate won’t be deallocated while WKOverflowScrollViewDelegate is still around and holding a pointer to it?

> Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:30
> +#include <WebCore/IntRect.h>

Why is this included here? This file does not use IntRect.
Comment 10 Frédéric Wang (:fredw) 2017-09-05 01:56:05 PDT
Created attachment 319887 [details]
Patch for landing

This patch addresses Darin's comments.
Comment 11 Frédéric Wang (:fredw) 2017-09-05 02:16:28 PDT
Comment on attachment 319855 [details]
Patch

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

Indeed, this class is really the "iOS scrolling logic" that will be shared between derived classes of ScrollingTreeScrollingNode for iOS: non-main frames and overflow nodes. In C++ that would be multiple inheritance but here I have to introduce this helper class to extract that "iOS scrolling logic". I'm not sure whether "delegate" is the right term and moreover protected members non-accessible to that helper class. As I said in comment 8, I wonder whether we just want instead to make more members of ScrollingTreeScrollingNode public.

>> Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h:30
>> +#include "IntRect.h"
> 
> Why? This file doesn’t use IntRect. It does use FloatPoint, though.

Right, this should just be a "class FloatPoint". Done.

>> Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h:33
>> +class ScrollingTreeScrollingNode;
> 
> Missing blank line.

Done.

>> Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:64
>> +        _scrollingTreeNodeDelegate = delegate;
> 
> How does the object lifetime work? What guarantees this delegate won’t be deallocated while WKOverflowScrollViewDelegate is still around and holding a pointer to it?

The ScrollingTreeScrollingNodeDelegateIOS has the same lifetime as the node and WKOverflowScrollViewDelegate is released in the node's destructor. I've modified the node's destructor to ensure that WKOverflowScrollViewDelegate is destroyed before ScrollingTreeScrollingNodeDelegateIOS.

>> Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:30
>> +#include <WebCore/IntRect.h>
> 
> Why is this included here? This file does not use IntRect.

Done. I've just put a "class FloatPoint". (Not sure why I used a header...)
Comment 12 Frédéric Wang (:fredw) 2017-09-06 05:01:31 PDT
Created attachment 320009 [details]
Patch for landing
Comment 13 WebKit Commit Bot 2017-09-06 05:42:50 PDT
Comment on attachment 320009 [details]
Patch for landing

Clearing flags on attachment: 320009

Committed r221669: <http://trac.webkit.org/changeset/221669>
Comment 14 WebKit Commit Bot 2017-09-06 05:42:52 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 Radar WebKit Bug Importer 2017-09-27 12:51:49 PDT
<rdar://problem/34694163>