Commit Graph

152 Commits

Author SHA1 Message Date
Hiroyuki Ikezoe
fcaede7cb9 Bug 1663000 - Send the composition size without the dynamic toolbar height to the compositor. r=botond
Also add AsyncPanZoomController::CanScrollDownwardsWithDynamicToolbar to tell
whether the root APZC is scrollable or there is room covered by the dynamic
toolbar so that we can tell GeckoView to move the dynamic toolbar in such cases.

Differential Revision: https://phabricator.services.mozilla.com/D93914
2020-11-04 03:16:04 +00:00
Kartikaya Gupta
d0dee34b9b Bug 1671217 - Ensure we clear mIsFirstPaint in the visual-viewport-only MVM case. r=tnikkel
There should be no user-visible correctness change here, just doing less
unnecessary work.

Differential Revision: https://phabricator.services.mozilla.com/D93540
2020-10-14 19:26:27 +00:00
Kartikaya Gupta
163eebadcf Bug 1667863 - Replace AppendToString of SizeTyped with ostream usage. r=mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D91655
2020-09-29 11:54:33 +00:00
Razvan Maries
9cd99353fc Backed out changeset b5d0e150491e (bug 1661544) for perma failures on HTMLBody-ScrollArea_quirksmode.html. 2020-09-12 09:48:34 +03:00
Botond Ballo
8c28bf105c Bug 1661544 - Ensure initial viewport is computed before reporting innerWidth. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D88947
2020-09-09 21:14:31 +00:00
Hiroyuki Ikezoe
e1cc862d00 Bug 1652190 - Don't expand the composition size including the dynamic toolbar height if the root content is not scrollable. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D83601
2020-07-21 02:53:09 +00:00
Simon Giesecke
a69d79b6db Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
Kartikaya Gupta
65f8b63a7f Bug 1647034 - Change how the visual viewport is updated to eliminate spurious reflows. r=tnikkel
There's two code changes in this patch:

- The update to the visual viewport that was happening just before positioning
  the fixed items gets moved to happen after determining the scrollbars for
  the root scrollframe. This moves it a little bit earlier, to basically the
  earliest point at which the visual viewport can actually be computed, since
  it depends on the presence of the root scrollframe's scrollbars.

  More importantly, this change sets the visual viewport without checking to
  see if one was already set, as the old code did. This means every reflow
  of the root scrollframe on a presShell with an MVM will now have a visual
  viewport set. Previously the visual viewport would only get set for the first
  time when the MVM got a load or first-paint event, and then would get updated
  for subsequent reflows. The net effect here is that the visual viewport is
  set earlier, and this can sometimes eliminate extra reflows from after the
  load event, because everything is already in a consistent state.

- The NotifyResizeReflow call to MVM is replaced by a NotifyReflow call that
  runs before every reflow, instead of just on resizes. Note that the
  NotifyReflow also doesn't update the visual viewport like NotifyResizeReflow
  used to do, because that is taken care of by the above-mentioned code change
  to set the visual viewport.

  This is desirable because there are things that run during reflow that attempt
  to read the display size from the MVM, and they were getting a zero size
  for reflows that happened before the first resize or load/first-paint events.
  Now they get a valid display size on every reflow, and so again this allows
  fewer overall reflows as the code converges to a stable state faster.

Together these changes ensure that every reflow has access to up-to-date
properties (display size, mobile viewport size, visual viewport size) from the
MVM. This eliminates unnecessary reflows because of out-of-order computations
based on stale values and such. Therefore the number of reflows goes down,
which is reflected by the changes to the crashtest assertion counts.

Differential Revision: https://phabricator.services.mozilla.com/D81375
2020-06-29 18:39:57 +00:00
Kartikaya Gupta
e250158506 Bug 1648305 - Use the scrollable rect size for first-paint intrinsic scale calculation. r=hiro
When meta-viewport support is enabled, the call to UpdateResolutionForFirstPaint
from RefreshViewportSize is followed by a call to ShrinkToDispalySizeIfNeeded,
which calls UpdateResolutionForContentSizeChange and uses the scrollable rect
size for the intrinsic scale computation. So the intrinsic scale computation
in UpdateResolutionForFirstPaint causes a transient state where the resolution
and visual viewport size is wrong. It is corrected immediately after, but
changing the visual viewport size like that ends up marking frames dirty for
reflow. Avoiding the transient state avoids those reflows, which is a nice
optimization.

Differential Revision: https://phabricator.services.mozilla.com/D80996
2020-06-25 08:41:24 +00:00
Kartikaya Gupta
4c38b4c3bf Bug 1648193 - Additional minor cleanup. r=hiro
Instead of having callers compute the cssToDev and pass it to the zoom/
resolution conversion functions, we can just do it in those functions directly.

Differential Revision: https://phabricator.services.mozilla.com/D80939
2020-06-24 23:48:51 +00:00
Kartikaya Gupta
9eeacbea9b Bug 1648193 - Split UpdateResolution into three different functions. r=hiro
This is a hard diff to read but fundamentally a pretty simple patch. The old
UpdateResolution function had a giant if condition in the middle conditioned
on the update type. Inside the ViewportSize branch there was a further nested
if conditioned on mIsFirstPaint. The function got split into three, with each
new function holding one of the three main blocks of code, along with a copy
of the stuff before and after the if condition. And then I simplified each
function individually to remove unnecessary variables, add some early-exits
and reduce nesting levels, etc.

Depends on D80937

Differential Revision: https://phabricator.services.mozilla.com/D80938
2020-06-24 23:45:00 +00:00
Kartikaya Gupta
74fe096892 Bug 1648193 - Stop passing things to MVM that it already knows how to compute. r=hiro
This removes the two parameters to ShrinkToDisplaySizeIfNeeded and corresponding
parameters passed to UpdateResolution. The call site in nsGfxScrollFrame
gets the arguments from the MVM itself, so it seems silly to be getting things
from the MVM just to pass it back in. The other call sites are already in theMVM.
This change might be slightly less efficient because it re-computes the viewport
info when the caller might already have it but this isn't a hot code path so
I'm not too concerned.

Differential Revision: https://phabricator.services.mozilla.com/D80937
2020-06-24 22:22:17 +00:00
Kartikaya Gupta
2742cb1743 Bug 1644271 - Enable setting the visual viewport size for VisualViewportOnly-type MVM instances. r=tnikkel
Depends on D80090

Differential Revision: https://phabricator.services.mozilla.com/D80091
2020-06-21 20:48:28 +00:00
Kartikaya Gupta
79c7c2a79a Bug 1644271 - Block some codepaths that try to use a zero display size. r=tnikkel
This fixes a number of scroll-anchoring WPT tests that otherwise fail with the
final patch in this patchset. This patch also fixes a pre-existing failure on
Android, so we remove the corresponding failure annotation here.  The guard
being added already exists on some of the codepaths leading to this function,
and is used to short-circuit other bits of code. However, there are still some
codepaths that end up in this function with a zero display size, and it's better
to leave the visual viewport unset in the presShell than to set it to a zero
size.

Depends on D80086

Differential Revision: https://phabricator.services.mozilla.com/D80087
2020-06-21 20:48:37 +00:00
Razvan Maries
e11758116a Backed out 6 changesets (bug 1644271) for perma failures on browser_bug1170531.js.
Backed out changeset 9d4e746c732d (bug 1644271)
Backed out changeset 681a48643a84 (bug 1644271)
Backed out changeset 3cf3176c45d4 (bug 1644271)
Backed out changeset efaddcd67a33 (bug 1644271)
Backed out changeset 03aaac05c759 (bug 1644271)
Backed out changeset a780f5111efa (bug 1644271)
2020-06-21 23:44:04 +03:00
Kartikaya Gupta
dba5f7077c Bug 1644271 - Enable setting the visual viewport size for VisualViewportOnly-type MVM instances. r=tnikkel
Depends on D80090

Differential Revision: https://phabricator.services.mozilla.com/D80091
2020-06-18 09:21:36 +00:00
Kartikaya Gupta
d4627f52c1 Bug 1644271 - Block some codepaths that try to use a zero display size. r=tnikkel
This fixes a number of scroll-anchoring WPT tests that otherwise fail with the
final patch in this patchset. This patch also fixes a pre-existing failure on
Android, so we remove the corresponding failure annotation here.  The guard
being added already exists on some of the codepaths leading to this function,
and is used to short-circuit other bits of code. However, there are still some
codepaths that end up in this function with a zero display size, and it's better
to leave the visual viewport unset in the presShell than to set it to a zero
size.

Depends on D80086

Differential Revision: https://phabricator.services.mozilla.com/D80087
2020-06-18 11:20:55 +00:00
Kartikaya Gupta
d5d460ae92 Bug 1646385 - Ensure we recompute the visual viewport size when the root scrollframe's scrollbars get added or removed. r=tnikkel
There are two parts here. One is the "backstop" in the scrollframe's
ReflowFinished callback, that recomputes the visual viewport size if layout
scrollbars are being used in the root scrollframe. This ensures that the
visual viewport gets resized properly after a reflow, possibly at the expense
of a second reflow to reposition fixed-pos items.

There is also an update to the visual viewport during the reflow itself, after
we have reflowed the in-flow contents (including the root scrollframe) but
before we reflow the fixed-pos items. This allows us to avoid the second reflow
by using the new visual viewport for positioning the fixed-pos items correctly.
This early reflow also skips marking things for a second reflow.

This patch fixes a problem described in bug 1644271 comment 2, among other
things. Specifically, it ensures that when the scrollbar properties (e.g.
maxpos, minpos) are computed, they are computed using an up-to-date visual
viewport size. The up-to-date visual viewport size correctly excludes the space
taken up by non-overlay scrollbars, which wasn't happening without this patch.

Depends on D80039

Differential Revision: https://phabricator.services.mozilla.com/D80040
2020-06-18 22:30:00 +00:00
Kartikaya Gupta
a2b10183a9 Bug 1645520 - Ensure an MVM operating in VisualViewportOnly mode knows about display resizes. r=tnikkel
This is important because if the apz.allow_zooming pref is enabled (and
eventually even without that pref), VisualViewportOnly-type MVMs do set
the visual viewport size based on the display size and zoom, and so need
to be updated when those change.

It's also important to keep the mMobileViewportSize updated and in sync
with the display size, because it may get used via ComputeIntrinsicResolution
when fullscreening.

Differential Revision: https://phabricator.services.mozilla.com/D79594
2020-06-15 13:32:44 +00:00
Bogdan Tara
395fba9f3d Backed out changeset b44a56033fc8 (bug 1645520) for test_fullscreen-api.html failures CLOSED TREE 2020-06-13 17:16:24 +03:00
Kartikaya Gupta
beca45d3b6 Bug 1645520 - Ensure an MVM operating in VisualViewportOnly mode knows about display resizes. r=tnikkel
This is important because if the apz.allow_zooming pref is enabled (and
eventually even without that pref), VisualViewportOnly-type MVMs do set
the visual viewport size based on the display size and zoom, and so need
to be updated when those change.

Differential Revision: https://phabricator.services.mozilla.com/D79594
2020-06-13 11:41:40 +00:00
Kartikaya Gupta
74925a8f03 Bug 1644271 - Add an early-exit to temporarily disable an MVM codepath. r=tnikkel
This is a short-term step to ensure all tests pass with the mvm pref
turned on. It disables the visual viewport setting codepath for visual-only
MVM instances, unless the APZ zooming pref is also set (because other APZ
zooming code relies on this).

Differential Revision: https://phabricator.services.mozilla.com/D79229
2020-06-12 01:15:05 +00:00
Kartikaya Gupta
f9c7506ec7 Bug 1644271 - Add some more MVM_LOG statements. r=tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D79227
2020-06-12 01:15:48 +00:00
Kartikaya Gupta
1e66f31183 Bug 1644271 - Don't let the MVM do reflows or change the resolution unless we're using mobile viewport sizing. r=tnikkel
If there's no meta-viewport handling, the MVM shouldn't need to do reflows
because it shouldn't be changing the layout viewport. Also there should be
no need for the MVM to adjust the resolution on the presShell since the
user will be driving those changes via user input. The MVM now just updates
the visual viewport sizing in response to changes.

It may turn out that some these conditions need to be tweaked later, but for
now this seems like a reasonable starting point.

Differential Revision: https://phabricator.services.mozilla.com/D79226
2020-06-12 01:15:46 +00:00
Kartikaya Gupta
3969b349de Bug 1644271 - Add a ManagerType field to the MVM, to allow conditional behaviour. r=tnikkel
The MVM is needed for both handling of meta-viewport tags and APZ zooming.
However, the set of functionality needed in the two modes are not the same.
This patch adds a mechanism to create an MVM with a flag that lets it know
which mode it is operating in. Eventually we may want to split this into two
or more classes but for now this seems like a reasonable way forward.

The flag is currently set on the MVM on creation based on whether or not the
meta-viewport support is needed. There's no code that meaningfully *uses* the
flag yet, so this patch should have no functional change. The bulk of the
patch is ensuring that we appropriately destroy and re-create the MVM if the
flag required changes.

Differential Revision: https://phabricator.services.mozilla.com/D79224
2020-06-12 01:15:42 +00:00
Timothy Nikkel
1e5991f4bb Bug 1642088. Use a ResolutionChangeOrigin for when the resolution is changing by tests that overides and sets the restore resolution. r=kats
Differential Revision: https://phabricator.services.mozilla.com/D77582
2020-05-30 21:34:39 +00:00
Kartikaya Gupta
53bef08bce Bug 1627010 - Disallow user from zooming out past initial zoom on desktop. r=botond
THis should continue allowing users to zoom out in RDM mode, or any time that
we are respecting the meta-viewport tag. It's only when we don't respect the
meta-viewport tag that we disable zooming out past initial zoom.

Differential Revision: https://phabricator.services.mozilla.com/D73461
2020-05-06 14:40:23 +00:00
Emilio Cobos Álvarez
feac96b059 Bug 1633488 - Stop listening for FullZoomChange in MobileViewportManager. r=botond
When the full zoom changes, it affects the layout viewport, and thus
RefreshViewportSize(false) gets called via PresShell::ResizeReflow, so
it's not needed.

This is in preparation to firing FullZoomChange only in the browser
element.

Differential Revision: https://phabricator.services.mozilla.com/D72711
2020-04-28 05:06:44 +00:00
Simon Giesecke
e613597e90 Bug 1613985 - Use default for equivalent-to-default constructors/destructors in layout. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D66016
2020-03-17 09:38:32 +00:00
Kartikaya Gupta
b0e5b55db7 Bug 1617565 - Convert additional compile-conditional logging bits to MOZ_LOG. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D63868
2020-02-24 16:31:04 +00:00
Hiroyuki Ikezoe
f0987efb21 Bug 1586986 - Fire visual viewport resize events and flush position:fixed elements' layout in the same way what Chrome does. r=botond
On Chrome, visual viewport resize event is fired repeatedly during dynamic
toolbar transitions and visual viewport height obtained by the VisualViewport
API is also changed, but in terms of layout the height value is never used
until the dynamic toolbar height reaches to zero or is changed from zero.
The height used at the time is the height for vh units when the toolbar height
reaches to zero and the ICB height when the toolbar height is changed from zero.
To do so, we need to have another visual viewport size in parallel to the
original one and use them depending on situations.

Differential Revision: https://phabricator.services.mozilla.com/D52338
2019-11-21 21:36:59 +00:00
Hiroyuki Ikezoe
5c30994474 Bug 1586144 - Factor dynamic toolbar max height into layout metrics. r=emilio,botond
Now
* nsPresContext::mVisibleArea is excluding the toolbar max height so that
  ICB is now static regardless of the dynamic toolbar transition
* nsPresContext::mSizeForViewportUnits is introduced to resolve viewport units
  which is including the toolbar max height

That means that with the dynamic toolbar max height;

  mVisibleArea < mSizeForViewportUnits

See https://github.com/bokand/URLBarSizing for more detail backgrounds of this
change.

Depends on D50417

Differential Revision: https://phabricator.services.mozilla.com/D50418
2019-11-14 06:00:05 +00:00
Emilio Cobos Álvarez
126ad6dd75 Bug 1551659 - Remove MVMContext::ResizeEventFlag and related code. r=botond,hiro
D46944 / bug 1583534 is what fixes the root cause of bug 1528052 by not
having the first call to ResizeReflow have a wrong old size of 0x0.

This removes the code that bug introduces to suppress resize events, which
fixes this bug. I think our behavior now is pretty sane.

In particular, consider the test-case:

<!doctype html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<a href="" target="_blank">Open me in a separate tab</a>
<pre id="log"></pre>
<script>
  // This shouldn't be needed, but otherwise Fenix doesn't show the tooltip on
  // longpress...
  document.querySelector("a").href = location.href;

  function logSize() {
    log.innerText += window.innerWidth + "x" + window.innerHeight + "\n";
  }
  logSize();
  onresize = logSize;
</script>

(Hosted at https://crisal.io/tmp/gecko-mobile-resize.html for convenience)

Right now on trunk, when you click the link from GVE or Fenix, we're only
getting an initial size of 0x0 (which is not great, btw), and only after first
paint we get the real device size, but content doesn't get a resize event.

This is obviously wrong, every time the layout viewport changes we should fire
resize events.

Pages that get opened in new tabs and get refreshed when resized may get an
extra reload with this approach, but this seems not avoidable unless widget sets
the viewport size right in advance (which from discussion with snorp and agi
doesn't seem possible in the general case).

What used to happen is that we were triggering a redundant resize reflow from
the initial paint which didn't update the layout viewport (because the content
viewer and co had the right viewport from the previous navigation).

Now that we optimize those away, I think our behavior should be correct.

Differential Revision: https://phabricator.services.mozilla.com/D46956
2019-09-25 19:35:29 +00:00
Emilio Cobos Álvarez
c1bd815761 Bug 1583534 - Further simplify PresShell::ResizeReflow. r=botond
In particular, not let ResizeReflow take the old and new size. Most of the
callers pass dummy values anyway.

Instead, use the old size of the layout viewport. This ensures we fire resize
events only if the layout viewport actually changes.

This is important because the first resize of the mobile viewport manager
after a navigation has an "old size" of 0x0, even though the layout viewport
is initialized on presshell initialization to the right size.

Thus, we fire resize events unnecessarily in that case, which is the root cause
for bug 1528052.

To do this, we need to shuffle a bit of code in nsDocumentViewer that deals with
delayed resizes, to set the visible area _and_ invalidate layout, rather than
setting the visible area and _then_ relying on doing a resize reflow.

Further cleanup is possible, though not required for my android resizing fix, so
will do separately.

Differential Revision: https://phabricator.services.mozilla.com/D46944
2019-09-25 19:12:44 +00:00
Botond Ballo
57624505ab Bug 1573014 - Early-exit ShrinkToDisplaySizeIfNeeded() in reader mode. r=hiro
Differential Revision: https://phabricator.services.mozilla.com/D42967
2019-08-21 23:33:14 +00:00
Botond Ballo
ac8697c2dc Bug 1575093 - Ensure initial-scale in a meta viewport tag is respected. r=hiro
Differential Revision: https://phabricator.services.mozilla.com/D42949
2019-08-21 22:00:43 +00:00
Botond Ballo
8371f68357 Bug 1523844 Part 5: Add a test case to TestMobileViewportManager. r=bradwerth
Depends on D41104

Differential Revision: https://phabricator.services.mozilla.com/D41453
2019-08-12 22:13:38 +00:00
Brad Werth
360abd97a3 Bug 1523844 Part 3: Make the MVM set resolution only as an adjustment, not a restore resolution. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D41632
2019-08-12 22:23:34 +00:00
Brad Werth
5105aaa747 Bug 1523844 Part 2: Make MVMContext::SetResolutionAndScaleTo accept a ResolutionChangeOrigin. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D41631
2019-08-12 22:22:12 +00:00
Daniel Holbert
ce5eb24e7a Bug 1569475: Adjust MobileViewportManager::ClampZoom to check for NaN zoom values and use 1.0 instead. r=botond
Also spam a NS_ERROR whenever this happens (in debug builds), so that we
know to fix the caller to avoid division by zero.

Differential Revision: https://phabricator.services.mozilla.com/D39801
2019-07-31 16:59:51 +00:00
Daniel Holbert
73ac413199 Bug 1568673 part 2: Add a few more assertions to validate that mobile viewport zoom factors are positive. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D39244
2019-07-26 23:38:18 +00:00
Daniel Holbert
bfb4ef8afa Bug 1568673 part 1: Adjust MobileViewportManager::ComputeIntrinsicScale to prevent divide-by-zero and to allow for meaningful min/max clamping. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D39577
2019-07-27 00:11:20 +00:00
Daniel Varga
018bbce7cf Backed out changeset 70404a86aea8 (bug 1568673) for gv-unit6 failure at org.mozilla.geckoview.test.MediaElementTest.webmFullscreenMedia 2019-07-25 05:15:58 +03:00
Daniel Holbert
db3e5c9fbd Bug 1568673: Add a few more assertions to validate that mobile viewport zoom factors are positive. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D39244
2019-07-25 00:14:43 +00:00
Daniel Holbert
9c8d84e1b1 Bug 1566991: Add some assertions to sanity-check that our mobile viewport zoom factors are positive. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D38419
2019-07-23 18:07:26 +00:00
Brindusan Cristian
d195e7723f Backed out changeset 58eb45e75568 (bug 1566991) for build bustages at MobileViewportManager.cpp:400:24. CLOSED TREE 2019-07-23 20:36:44 +03:00
Daniel Holbert
f399e4871b Bug 1566991: Add some assertions to sanity-check that our mobile viewport zoom factors are positive. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D38419
2019-07-22 17:16:23 +00:00
Brad Werth
de139c7b45 Bug 1555511 Part 2: Remove a float division in MVM::ScaleZoomWithDisplayWidth. r=botond
This is a drive-by fix to turn a division into a multiplication. It also
is more correct in that the existing code attempts a divide-by-zero if
aNewViewport.width is zero. The updated code will instead return a zoom
of zero in such a case.

Differential Revision: https://phabricator.services.mozilla.com/D32909
2019-06-04 22:25:06 +00:00
Brad Werth
16cbbe0314 Bug 1555511 Part 1: Make MVM::UpdateResolution clamp viewport zoom for the new display size later in the calculation. r=botond
The existing math is attempting to adjust the display scale ratio to
prevent the new size from landing outside the min/max zoom bounds. This
introduces unwanted side effects that can be avoided by simply clamping
to min/max at the end. The remaining math correctly handles the case
where the zoom has ALREADY been clamped, which is the only important
case.

Differential Revision: https://phabricator.services.mozilla.com/D32908
2019-06-04 22:23:47 +00:00
Andreea Pavel
78a7cf71f7 Backed out 4 changesets (bug 1555511) for failing dt at browser_boxmodel_pseudo-element.js on a CLOSED TREE
Backed out changeset e0cd61fa79ed (bug 1555511)
Backed out changeset 8c6e5561abed (bug 1555511)
Backed out changeset 2a85e3af81bb (bug 1555511)
Backed out changeset 262d2cad6407 (bug 1555511)
2019-06-05 11:53:38 +03:00