Bug 136651 - Ensure that layout is up-to-date before hit-testing via RenderView
Summary: Ensure that layout is up-to-date before hit-testing via RenderView
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords:
: 136265 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-09-08 17:41 PDT by Simon Fraser (smfr)
Modified: 2014-09-22 21:39 PDT (History)
6 users (show)

See Also:


Attachments
Patch for feedback (45.57 KB, patch)
2014-09-08 17:45 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (12.68 KB, patch)
2014-09-22 17:32 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) 2014-09-08 17:41:10 PDT
Add a stack-based helper to ensure that layout is up-to-date before getting the RenderView, and use it in places that hit-test
Comment 1 Simon Fraser (smfr) 2014-09-08 17:45:05 PDT
Created attachment 237824 [details]
Patch for feedback
Comment 2 Simon Fraser (smfr) 2014-09-08 17:45:42 PDT
Seeking feedback on the approach.
Comment 3 WebKit Commit Bot 2014-09-08 17:47:00 PDT
Attachment 237824 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/DragImage.cpp:137:  The parameter name "renderView" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 23 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Sam Weinig 2014-09-09 16:54:22 PDT
I'm not completely clear on the nullity of things?  It seems like you sometimes need to null check the RenderView, and sometimes don't.
Comment 5 Simon Fraser (smfr) 2014-09-09 17:01:07 PDT
I null-check the RenderView if the existing code did, but maybe should do it all the time.
Comment 6 Antti Koivisto 2014-09-10 02:55:25 PDT
Comment on attachment 237824 [details]
Patch for feedback

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

Where are you planning to go with this type? The current patch essentially just adds some scattered assertions so it is not clear from it. 

I think this is a great idea but the goal should be to expand it everywhere. That is, you shouldn't be able to get a renderer pointer (from Element for example) without first requesting access. Also we should differentiate between read and write access with the former giving back const renderer reference.

> Source/WebCore/rendering/RenderTreeAccess.h:38
> +class RenderTreeAccess {

What sort of access? Read? Read-write?

> Source/WebCore/rendering/RenderTreeAccess.h:46
> +    RenderTreeAccess(Frame&, LayoutUpdateType = UpdateLayout);
> +    RenderTreeAccess(Document&, LayoutUpdateType = UpdateLayout);

Not a big fan of these default values.

> Source/WebCore/rendering/RenderTreeAccess.h:50
> +    RenderView* renderView();

I think this should be a reference. Constructors should assert document.hasLivingRenderTree(). Clients should not use this class without a living tree and the class should prevent render tree teardown.

> Source/WebCore/rendering/RenderTreeAccess.h:52
> +    void ensureLayoutUpdated(LayoutUpdateType = UpdateLayout);

This is not used externally so should be private. Any client doing tree mutating things should drop and reacquire the render tree (read) access instead of using this.
Comment 7 Antti Koivisto 2014-09-10 03:00:24 PDT
> Not a big fan of these default values.

Specifically with the default values there is nothing indicating this type actually updates the layout.
Comment 8 Darin Adler 2014-09-10 08:24:59 PDT
(In reply to comment #6)
> That is, you shouldn't be able to get a renderer pointer (from Element for example) without first requesting access.

If practical, to go along with this the renderer pointers should be smart pointers that, in debug builds, assert if used after additional DOM mutation. Much like hash table iterators.
Comment 9 Simon Fraser (smfr) 2014-09-10 09:11:12 PDT
All good ideas, thanks!

> I think this should be a reference. Constructors should assert document.hasLivingRenderTree(). Clients should not use this class without a living tree and the class should prevent render tree teardown.

That's an interesting thought.

There are lots of access of RenderView which don't need to force layout; they just get the RenderView's RenderLayer, for example. So I don't think we can say that EVERY access of the render tree should force layout to be updated.
Comment 10 Antti Koivisto 2014-09-10 15:11:03 PDT
(In reply to comment #9)
> There are lots of access of RenderView which don't need to force layout; they just get the RenderView's RenderLayer, for example. So I don't think we can say that EVERY access of the render tree should force layout to be updated.

Right, there should be a way to request access without updating the layout. In that case we can still assert for example that no mutations happens until the access is dropped.
Comment 11 Simon Fraser (smfr) 2014-09-22 12:38:55 PDT
Other places that need this class (and may not have it in the patch)

RenderEmbeddedObject::isReplacementObscured()
RenderWidget::nodeAtPoint()
FrameSelection::contains()
ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture()
WebPage::dynamicViewportSizeUpdate()
Comment 12 Simon Fraser (smfr) 2014-09-22 17:32:23 PDT
Created attachment 238505 [details]
Patch
Comment 13 Simon Fraser (smfr) 2014-09-22 17:32:51 PDT
I went with a watered-down version after chatting with hyatt.
Comment 14 Simon Fraser (smfr) 2014-09-22 17:51:31 PDT
*** Bug 136265 has been marked as a duplicate of this bug. ***
Comment 15 Sam Weinig 2014-09-22 18:59:12 PDT
(In reply to comment #13)
> I went with a watered-down version after chatting with hyatt.

What arguments were made?
Comment 16 Simon Fraser (smfr) 2014-09-22 19:20:26 PDT
He thought that the first patch was ugly, and it was just much simpler to update layout inside RenderView::hitTest.
Comment 17 Dave Hyatt 2014-09-22 20:29:39 PDT
Comment on attachment 238505 [details]
Patch

r=me
Comment 18 WebKit Commit Bot 2014-09-22 21:39:41 PDT
Comment on attachment 238505 [details]
Patch

Clearing flags on attachment: 238505

Committed r173865: <http://trac.webkit.org/changeset/173865>
Comment 19 WebKit Commit Bot 2014-09-22 21:39:49 PDT
All reviewed patches have been landed.  Closing bug.