Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed)

Created:
4 years, 6 months ago by Eric Seckler
Modified:
4 years, 3 months ago
Reviewers:
Ian Vollick, bokan, dgozman, Sami
CC:
Ian Vollick, Sami, apavlov+blink_chromium.org, blink-reviews, blink-reviews-api_chromium.org, caseq+blink_chromium.org, chromium-reviews, darin-cc_chromium.org, devtools-reviews_chromium.org, dglazkov+blink, jam, kinuko+watch, kozyatinskiy+blink_chromium.org, lushnikov+blink_chromium.org, mkwst+moarreviews-renderer_chromium.org, mlamouri+watch-content_chromium.org, pfeldman+blink_chromium.org, pfeldman, sergeyv+blink_chromium.org, alexclarke
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

(Obsolete.) Adds scroll position and scale overrides to DevTools Emulation protocol. This enables resizing and positioning of frame and viewport for (headless) screenshots. For more information, see crbug.com/625577 and the design doc: bit.ly/viewport-screenshots. Depends on crrev.com/2173783002, which adds visual viewport size overrides to DevTools. BUG=625577 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_blink_rel

Patch Set 1 #

Total comments: 8

Patch Set 2 : Separate Emulator class, use min/max positions and PageScaleConstraints. #

Patch Set 3 : Add missing file, fix forbidden include. #

Total comments: 1

Patch Set 4 : Fixes issues with visual viewport scroll override, mainFrameSize on scale override, clamps position… #

Total comments: 1

Patch Set 5 : Fix style and comments. #

Patch Set 6 : Sync changes from patches 2111203004 + 2118773002. #

Total comments: 24

Patch Set 7 : Address reviewer comments, fix computeFinalConstraints() issue. #

Patch Set 8 : setNeedsCompositingUpdate now using InputChange. #

Total comments: 22

Patch Set 9 : Emulator using GC, moved to FrameHost, addressed other comments. #

Total comments: 4

Patch Set 10 : Add C++ tests, clamp visual viewport position. #

Total comments: 6

Patch Set 11 : Address reviewer comments. #

Patch Set 12 : add comment. #

Patch Set 13 : Re-sync. #

Patch Set 14 : Move scroll/scale overrides to separate DevTools command. #

Patch Set 15 : Sync, patch in 2169483002 (+ regression test), add DevTools tests. #

Total comments: 12

Patch Set 16 : Split off size override, address reviewer comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1458 lines, -16 lines) Patch
A third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +171 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +354 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/core.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/FrameHost.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +9 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/FrameHost.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +23 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/FrameView.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 4 chunks +10 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/FrameView.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5 chunks +31 lines, -1 line 0 comments Download
A third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.h View 1 2 3 4 5 6 7 8 1 chunk +87 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +146 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/VisualViewport.h View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +11 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/VisualViewport.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +38 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/inspector/browser_protocol.json View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +15 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/web/DevToolsEmulator.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 4 chunks +3 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/web/InspectorEmulationAgent.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/web/InspectorEmulationAgent.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +69 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/web/WebViewImpl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +5 lines, -1 line 0 comments Download
M third_party/WebKit/Source/web/WebViewImpl.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +25 lines, -1 line 0 comments Download
M third_party/WebKit/Source/web/tests/WebViewTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +451 lines, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 52 (14 generated)
Eric Seckler
Hi Sami and David, This is to demonstrate a first approach to overriding the scroll ...
4 years, 6 months ago (2016-06-23 15:22:59 UTC) #2
Sami
I think the integration points here look reasonable. The logic is kind of spread out ...
4 years, 6 months ago (2016-06-23 17:34:03 UTC) #4
Eric Seckler
https://codereview.chromium.org/2096633002/diff/1/third_party/WebKit/Source/core/frame/FrameView.cpp File third_party/WebKit/Source/core/frame/FrameView.cpp (right): https://codereview.chromium.org/2096633002/diff/1/third_party/WebKit/Source/core/frame/FrameView.cpp#newcode3302 third_party/WebKit/Source/core/frame/FrameView.cpp:3302: if (m_scrollOverridePosition.x() >= 0) On 2016/06/23 at 17:34:03, Sami ...
4 years, 6 months ago (2016-06-23 18:12:43 UTC) #5
bokan
Here's my suggestion: Create a class called ScrollAndScaleOverride or similar, owned by FrameHost. When Blink ...
4 years, 6 months ago (2016-06-24 14:33:54 UTC) #7
Sami
https://codereview.chromium.org/2096633002/diff/1/third_party/WebKit/Source/core/frame/FrameView.cpp File third_party/WebKit/Source/core/frame/FrameView.cpp (right): https://codereview.chromium.org/2096633002/diff/1/third_party/WebKit/Source/core/frame/FrameView.cpp#newcode3302 third_party/WebKit/Source/core/frame/FrameView.cpp:3302: if (m_scrollOverridePosition.x() >= 0) On 2016/06/23 18:12:43, Eric Seckler ...
4 years, 6 months ago (2016-06-24 14:48:26 UTC) #8
Eric Seckler
On 2016/06/24 at 14:33:54, bokan wrote: > Here's my suggestion: > > Create a class ...
4 years, 6 months ago (2016-06-24 15:07:49 UTC) #9
Eric Seckler
On 2016/06/24 at 15:07:49, Eric Seckler wrote: > On 2016/06/24 at 14:33:54, bokan wrote: > ...
4 years, 5 months ago (2016-06-27 17:32:43 UTC) #10
Eric Seckler
https://codereview.chromium.org/2096633002/diff/1/content/browser/devtools/protocol/emulation_handler.cc File content/browser/devtools/protocol/emulation_handler.cc (right): https://codereview.chromium.org/2096633002/diff/1/content/browser/devtools/protocol/emulation_handler.cc#newcode223 content/browser/devtools/protocol/emulation_handler.cc:223: "Scroll position coordinates must be non-negative, not greater than" ...
4 years, 5 months ago (2016-06-27 17:32:58 UTC) #11
Eric Seckler
On 2016/06/27 at 17:32:43, Eric Seckler wrote: > On 2016/06/24 at 15:07:49, Eric Seckler wrote: ...
4 years, 5 months ago (2016-06-28 18:02:50 UTC) #12
bokan
> After another day of trouble shooting, here my findings. > > As reported before, ...
4 years, 5 months ago (2016-06-28 18:41:40 UTC) #13
Eric Seckler
On 2016/06/28 at 18:41:40, bokan wrote: > This is surprising and I'd like to find ...
4 years, 5 months ago (2016-06-28 19:58:38 UTC) #14
Eric Seckler
Another update - I started a doc and described the issues here: https://docs.google.com/document/d/1XdhP0IWEliZHFjPONMHKDbZpcLFevLDFceliExB9yKw/edit#heading=h.igv4orepnkah After experimenting ...
4 years, 5 months ago (2016-06-29 14:01:42 UTC) #15
bokan
https://codereview.chromium.org/2096633002/diff/40001/third_party/WebKit/Source/web/WebViewImpl.cpp File third_party/WebKit/Source/web/WebViewImpl.cpp (right): https://codereview.chromium.org/2096633002/diff/40001/third_party/WebKit/Source/web/WebViewImpl.cpp#newcode3236 third_party/WebKit/Source/web/WebViewImpl.cpp:3236: } My recommendation for the mainFrameSize issue would be ...
4 years, 5 months ago (2016-06-29 15:15:49 UTC) #16
Eric Seckler
On 2016/06/29 at 15:15:49, bokan wrote: > https://codereview.chromium.org/2096633002/diff/40001/third_party/WebKit/Source/web/WebViewImpl.cpp > File third_party/WebKit/Source/web/WebViewImpl.cpp (right): > > https://codereview.chromium.org/2096633002/diff/40001/third_party/WebKit/Source/web/WebViewImpl.cpp#newcode3236 ...
4 years, 5 months ago (2016-06-29 17:35:02 UTC) #17
bokan
On 2016/06/29 17:35:02, Eric Seckler wrote: > On 2016/06/29 at 15:15:49, bokan wrote: > > ...
4 years, 5 months ago (2016-06-29 17:41:57 UTC) #18
Eric Seckler
On 2016/06/29 at 17:41:57, bokan wrote: > On 2016/06/29 17:35:02, Eric Seckler wrote: > > ...
4 years, 5 months ago (2016-06-29 19:37:17 UTC) #19
Eric Seckler
Another day, another problem ;) It's about the scroll position override for the visual viewport ...
4 years, 5 months ago (2016-06-30 14:06:02 UTC) #20
Eric Seckler
On 2016/06/30 14:06:02, Eric Seckler wrote: > Another day, another problem ;) It's about the ...
4 years, 5 months ago (2016-06-30 14:53:43 UTC) #21
bokan
On 2016/06/30 14:53:43, Eric Seckler wrote: > On 2016/06/30 14:06:02, Eric Seckler wrote: > > ...
4 years, 5 months ago (2016-06-30 16:48:13 UTC) #22
Eric Seckler
On 2016/06/30 16:48:13, bokan wrote: > > > Can we get around this somehow, or ...
4 years, 5 months ago (2016-06-30 17:27:13 UTC) #23
bokan
On 2016/06/30 17:27:13, Eric Seckler wrote: > On 2016/06/30 16:48:13, bokan wrote: > > > ...
4 years, 5 months ago (2016-06-30 19:06:40 UTC) #24
Eric Seckler
On 2016/06/30 19:06:40, bokan wrote: > Methinks you're subtracting the scroll origin? You have to ...
4 years, 5 months ago (2016-06-30 20:01:28 UTC) #27
bokan
<cc'ing vollick@ for compositing question inline> Thanks for bearing with me. Overall approach is looking ...
4 years, 5 months ago (2016-07-01 21:05:13 UTC) #28
Eric Seckler
Thanks again, David! https://codereview.chromium.org/2096633002/diff/120001/third_party/WebKit/Source/core/frame/FrameView.cpp File third_party/WebKit/Source/core/frame/FrameView.cpp (right): https://codereview.chromium.org/2096633002/diff/120001/third_party/WebKit/Source/core/frame/FrameView.cpp#newcode3185 third_party/WebKit/Source/core/frame/FrameView.cpp:3185: if (m_scrollAndScaleEmulator) { On 2016/07/01 21:05:12, ...
4 years, 5 months ago (2016-07-04 14:33:08 UTC) #29
Ian Vollick
https://codereview.chromium.org/2096633002/diff/120001/third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp File third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp (right): https://codereview.chromium.org/2096633002/diff/120001/third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp#newcode95 third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp:95: page->scrollingCoordinator()->notifyGeometryChanged(); On 2016/07/04 at 14:33:08, Eric Seckler wrote: > ...
4 years, 5 months ago (2016-07-04 14:48:13 UTC) #31
Eric Seckler
https://codereview.chromium.org/2096633002/diff/120001/third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp File third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp (right): https://codereview.chromium.org/2096633002/diff/120001/third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp#newcode95 third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.cpp:95: page->scrollingCoordinator()->notifyGeometryChanged(); On 2016/07/04 14:48:13, vollick wrote: > On 2016/07/04 ...
4 years, 5 months ago (2016-07-04 15:06:12 UTC) #32
bokan
https://codereview.chromium.org/2096633002/diff/120001/third_party/WebKit/Source/web/WebViewImpl.cpp File third_party/WebKit/Source/web/WebViewImpl.cpp (right): https://codereview.chromium.org/2096633002/diff/120001/third_party/WebKit/Source/web/WebViewImpl.cpp#newcode3236 third_party/WebKit/Source/web/WebViewImpl.cpp:3236: page()->frameHost().setUserAgentPageScaleConstraints(m_scrollAndScaleEmulator->pageScaleConstraints()); On 2016/07/04 14:33:08, Eric Seckler wrote: > On ...
4 years, 5 months ago (2016-07-04 22:44:09 UTC) #33
Eric Seckler
Thanks once again! Will add some tests next. https://codereview.chromium.org/2096633002/diff/160001/third_party/WebKit/Source/core/frame/FrameView.cpp File third_party/WebKit/Source/core/frame/FrameView.cpp (right): https://codereview.chromium.org/2096633002/diff/160001/third_party/WebKit/Source/core/frame/FrameView.cpp#newcode3320 third_party/WebKit/Source/core/frame/FrameView.cpp:3320: IntPoint ...
4 years, 5 months ago (2016-07-05 16:46:51 UTC) #34
bokan
Looks good, I'm happy with this patch. Just awaiting tests. Thanks! https://codereview.chromium.org/2096633002/diff/180001/third_party/WebKit/Source/core/frame/FrameHost.cpp File third_party/WebKit/Source/core/frame/FrameHost.cpp (right): ...
4 years, 5 months ago (2016-07-06 14:26:31 UTC) #35
Eric Seckler
Now with C++ tests for the override functionality in Blink. Will add layout tests for ...
4 years, 5 months ago (2016-07-11 10:38:44 UTC) #36
Eric Seckler
+cc pfeldman@, dgozman@ for devtools protocol changes. +cc auto-cc Adds scroll position/scale + visual viewport ...
4 years, 5 months ago (2016-07-11 11:57:07 UTC) #38
bokan
Thanks, tests look great! Blink-side changes LGTM https://codereview.chromium.org/2096633002/diff/200001/third_party/WebKit/Source/web/tests/WebViewTest.cpp File third_party/WebKit/Source/web/tests/WebViewTest.cpp (right): https://codereview.chromium.org/2096633002/diff/200001/third_party/WebKit/Source/web/tests/WebViewTest.cpp#newcode1146 third_party/WebKit/Source/web/tests/WebViewTest.cpp:1146: frameView->layout(); I ...
4 years, 5 months ago (2016-07-11 13:52:10 UTC) #39
Eric Seckler
Forked the VisualViewport::setScrollPosition() change off into https://codereview.chromium.org/2138823002/ . https://codereview.chromium.org/2096633002/diff/200001/third_party/WebKit/Source/web/tests/WebViewTest.cpp File third_party/WebKit/Source/web/tests/WebViewTest.cpp (right): https://codereview.chromium.org/2096633002/diff/200001/third_party/WebKit/Source/web/tests/WebViewTest.cpp#newcode1146 third_party/WebKit/Source/web/tests/WebViewTest.cpp:1146: frameView->layout(); ...
4 years, 5 months ago (2016-07-11 16:37:13 UTC) #40
Eric Seckler
PTAL. +r: dgozman@ As discussed with dgozman, I split the ScrollAndScale overrides off into a ...
4 years, 5 months ago (2016-07-21 17:00:05 UTC) #42
dgozman
Should we split this up into viewport override vs scroll/scale override? They are semantically different, ...
4 years, 5 months ago (2016-07-21 20:54:09 UTC) #43
commit-bot: I haz the power
Your CL relies on deprecated CQ feature(s): * Specifying master names in CQ_INCLUDE_TRYBOTS part of ...
4 years, 5 months ago (2016-07-22 12:46:41 UTC) #46
Eric Seckler
Thanks, Dmitry. I split off the size override into crrev.com/2173783002. This patch still depends on ...
4 years, 5 months ago (2016-07-22 14:44:48 UTC) #48
dgozman
4 years, 5 months ago (2016-07-25 22:26:17 UTC) #51
Sorry for delay, I was thinking and discussing this a bit.

>
https://codereview.chromium.org/2096633002/diff/300001/third_party/WebKit/Lay...
>
third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-visual-viewport-size.html:27:
> layoutWidth: document.getElementById("layoutViewportDiv").clientWidth,
> On 2016/07/21 20:54:08, dgozman wrote:
> > I don't like that override we use is observable by the page. This defeats
the
> > purpose: let's say we focus on the specific region to take a screenshot of
it,
> > and then position:fixed element covers half of it because we made it
> observable
> > to the web.
> > Since the whole purpose of the visible viewport override is performance, can
> we
> > do something else (like disabling compositing entirely)?
> 
> I noted some of this in the design doc. I think we actually want layout
viewport
> overrides (both size and scroll) to cause a reflow/layout of the page, so they
> should always be observed by the page. I.e., the layout overrides should
resize
> the page, that's what we intend to use them for :)
> 
> For visual viewport overrides, we want to support both (i) page-observable
> changes (e.g. to take a screenshot of "what does my page look like on a mobile
> browser that zoomes in here"), but also (ii) the option to hide the visual
> viewport overrides from the page (e.g. to take a screenshot of an ad - here we
> don't want visual-viewport-fixed elements to pop up). 
> 
> I think it would be fine if we initially only support (i) and add (ii) later,
> particularly since pos-fixed elements are layout-viewport relative and most of
> the visual viewport isn't yet exposed to pages (VisualViewport API is still
> experimental). We can later support (ii) by adding an option to hide the
> overrides of the visual viewport from the page in some way.

For (i) we can just scroll/zoom as the user does it. For example, we can replace
Emulation.setPageScaleFactor with setVisualViewport(scale, scrollX, scrollY).
Won't that be good enough? Since it's going to trigger layout and be observable,
it might as well be regular interaction. WDYT?
And we can figure out (ii) later.

> For the layout viewport (frame), the change of scroll position through the
> override is observable by the page (again, we want that). The page won't be
able
> to change the position, though. So in your example, assuming overriden scroll
> position is (0, 0):
> 
> body.scrollTop = 100; // Will be clamped to 0, so no change in position.
> console.log(body.scrollTop); // Will log 0.
> 
> I'm not sure if this really breaks contracts, since setting body.scrollTop
> outside min/max generally also clamps. We're just enforcing a different
min/max,
> which I'd argue is in the user-agent's right.

I'm not so sure here. This introduces behavior which is "override mode only". We
try to avoid that as much as possible.
If the problem is to prevent page from doing any modifications, we can
separately achieve that by freezing it as we do for debugger pause. This code is
well-tested and will be reused, so we won't run into special cases, as we have
to with these overrides.

Powered by Google App Engine
This is Rietveld 408576698