Commit Graph

142 Commits

Author SHA1 Message Date
Martin Robinson
b5d910a0ca Bug 1791759 - Add support for content-visibility: auto r=emilio
This change adds support for `content-visibilty: auto` as well as
showing and hiding content based on the relevancy of the content as
defined in the specification. Changes to relevancy are handled by
triggering updates in a set of `content-visibility: auto` frames stored
in PresShell at the appropriate time in the document lifecycle.

Some tests are now failing due to this feature exposing the failures,
but they will be fixed in later changes.

This change is a reland of an earlier version that properly updates
intrinsic sizes and triggers an update of remembered size for the
purposes of contain-intrinsic-size when content relevancy changes.

Co-authored-by: Jihye Hong <jihye@igalia.com>

Differential Revision: https://phabricator.services.mozilla.com/D159693
2022-11-30 18:00:27 +00:00
Marian-Vasile Laza
3f33580c27 Backed out changeset c428c3ad7725 (bug 1791759) for causing wpt failures on auto-012.html. CLOSED TREE 2022-11-28 13:31:05 +02:00
Martin Robinson
92b6a75ea4 Bug 1791759 - Add support for content-visibility: auto r=emilio
This change adds support for `content-visibilty: auto` as well as
showing and hiding content based on the relevancy of the content as
defined in the specification. Changes to relevancy are handled by
triggering updates in a set of `content-visibility: auto` frames stored
in PresShell at the appropriate time in the document lifecycle.

Some tests are now failing due to this feature exposing the failures,
but they will be fixed in later changes.

Co-authored-by: Jihye Hong <jihye@igalia.com>

Differential Revision: https://phabricator.services.mozilla.com/D159693
2022-11-28 09:53:06 +00:00
Emilio Cobos Álvarez
b63597150e Bug 1795815 - Fix cursor intersection detection on OOP iframes. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D159783
2022-10-20 10:16:58 +00:00
Martin Robinson
d6b19e86ff Bug 1789255: Anonymous children of elements with content-visibility should not be skipped for layout r=emilio
Some anonymous children are important for properly sizing their parents
even when those parents hide content with `content-visibility`. This is
shown by regressions in the proper layout of some form elements with
`content-visibility`.

This change introduces a more conservative approach for avoiding layout
of hidden content. Instead of leaving all children dirty during reflow,
reflow anonymous frames (and nsComboboxDisplayFrame, a specialized kind
of anonymous frame). This change means that frames may only lay out some
of their children, so it must introduce some more changes to assumptions
during line layout.

In addition, this change renames `content-visibility` related methods in
nsIFrame in order to make it more obvious what they do.

Differential Revision: https://phabricator.services.mozilla.com/D157306
2022-09-15 20:32:27 +00:00
Norisz Fay
59f059dd2d Backed out changeset c3780baf6f24 (bug 1789255) for causing build bustages CLOSED TREE 2022-09-15 21:14:04 +03:00
Martin Robinson
a7d2990285 Bug 1789255: Anonymous children of elements with content-visibility should not be skipped for layout r=emilio
Some anonymous children are important for properly sizing their parents
even when those parents hide content with `content-visibility`. This is
shown by regressions in the proper layout of some form elements with
`content-visibility`.

This change introduces a more conservative approach for avoiding layout
of hidden content. Instead of leaving all children dirty during reflow,
reflow anonymous frames (and nsComboboxDisplayFrame, a specialized kind
of anonymous frame). This change means that frames may only lay out some
of their children, so it must introduce some more changes to assumptions
during line layout.

In addition, this change renames `content-visibility` related methods in
nsIFrame in order to make it more obvious what they do.

Differential Revision: https://phabricator.services.mozilla.com/D157306
2022-09-15 17:56:42 +00:00
Sandor Molnar
12e1fb9746 Backed out changeset 3a5759eabb42 (bug 1789255) for causing wpt failures in netwerk/protocol/http/Http2Session.cpp CLOSED TREE 2022-09-14 02:01:36 +03:00
Martin Robinson
00e3cff6d7 Bug 1789255: Anonymous children of elements with content-visibility should not be skipped for layout r=emilio
Some anonymous children are important for properly sizing their parents
even when those parents hide content with `content-visibility`. This is
shown by regressions in the proper layout of some form elements with
`content-visibility`.

This change introduces a more conservative approach for avoiding layout
of hidden content. Instead of leaving all children dirty during reflow,
reflow anonymous frames (and nsComboboxDisplayFrame, a specialized kind
of anonymous frame). This change means that frames may only lay out some
of their children, so it must introduce some more changes to assumptions
during line layout.

In addition, this change renames `content-visibility` related methods in
nsIFrame in order to make it more obvious what they do.

Differential Revision: https://phabricator.services.mozilla.com/D156473
2022-09-13 20:01:35 +00:00
Sean Feng
27b1c54544 Bug 1750034 - Remove lazyload telemetry related code r=emilio
We have decided to use 600px in all directions, there's no need
to keep the telemetry stuff around.

Differential Revision: https://phabricator.services.mozilla.com/D155879
2022-08-30 16:00:11 +00:00
Emilio Cobos Álvarez
76ed3cad16 Bug 1785186 - Use zero threshold for lazyload observer. r=hiro
This matches WebKit, and the spec:

  https://html.spec.whatwg.org/#lazy-load-intersection-observer

Blink has very weird behavior where it treats a zero-area intersection
in this particular case with an intersectionRatio of one:
https://bugs.chromium.org/p/chromium/issues/detail?id=1356250

Which causes them to load the image even though they have a
numeric_limits::min threshold.

So this works in Chromium by chance, but should work per spec.

Differential Revision: https://phabricator.services.mozilla.com/D155501
2022-08-25 02:34:37 +00:00
Emilio Cobos Álvarez
b69fa6464e Bug 1772083 - Downgrade an assertion for now while we try to find STR. r=smaug
The only URLs in the crash reports are internal networks, so it's not
clear to me how it can happen. But given it can, handle it gracefully.

Differential Revision: https://phabricator.services.mozilla.com/D147856
2022-06-01 14:03:04 +00:00
Emilio Cobos Álvarez
31e4efa801 Bug 1730284 - Use whether the embedder element intersects the viewport to decide whether to throttle in-process iframes. r=smaug
This is more likely to be understandable by developers, matches other
browsers more closely (see bug comments), and seems more in-line with
what we do for OOP iframes.

Add a pref to not do this throttling at all (which would match Chrome),
though this is probably good enough for now.

Differential Revision: https://phabricator.services.mozilla.com/D146574
2022-05-26 15:45:01 +00:00
Emilio Cobos Álvarez
657914334f Bug 1730284 - Factor out some IntersectionObserver code. r=smaug,sefeng
Differential Revision: https://phabricator.services.mozilla.com/D146573
2022-05-25 20:45:55 +00:00
Noemi Erli
7c6784310f Backed out 2 changesets (bug 1730284) for causing devtools,web-platform and mochitest failures CLOSED TREE
Backed out changeset 98834b863104 (bug 1730284)
Backed out changeset 1ec157459e8c (bug 1730284)
2022-05-25 22:51:20 +03:00
Emilio Cobos Álvarez
bd6f693097 Bug 1730284 - Factor out some IntersectionObserver code. r=smaug,sefeng
Differential Revision: https://phabricator.services.mozilla.com/D146573
2022-05-25 17:54:22 +00:00
Emilio Cobos Álvarez
ec93df4236 Bug 1770729 - Fix IntersectionObserver overflow: clip on zero-sized elements. r=jwatt
I realized my fix in bug 1769512 (using IsEmpty()) wasn't quite correct
in this case, because IntersectionObserver preserves edge-inclusive
intersections.

Differential Revision: https://phabricator.services.mozilla.com/D147078
2022-05-23 13:52:48 +00:00
Emilio Cobos Álvarez
a7bd900b89 Bug 1769512 - Apply overflow: clip to IntersectionObserver. r=hiro
Differential Revision: https://phabricator.services.mozilla.com/D146433
2022-05-23 07:21:43 +00:00
Martin Robinson
89ce051128 Bug 1766265 - Content hidden by content-visibility should not trigger intersection observers r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D144584
2022-04-26 08:40:26 +00:00
David Shin
3bc7313e07 Bug 1755770 - Ensure TextRenderedRun::GetRunUserSpaceRect casts float to int without invoking Undefined Behavior r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D142223
2022-03-28 21:07:58 +00:00
Emilio Cobos Álvarez
16bdd386b6 Bug 1760965 - Remove IntersectionObserver prefs that have been enabled by default for a long time. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D141830
2022-03-23 09:59:13 +00:00
Sylvestre Ledru
35a175aa33 Bug 1754767 - Remove duplicate includes r=media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D138441
2022-02-11 10:01:15 +00:00
Emilio Cobos Álvarez
5481ccb748 Bug 1754579 - Don't keep so much alive when returning DOMRects & co. r=smaug
We keep the parent alive for wrapping. It's unnecessary to keep alive
the individual element / range / etc. Pass the relevant global /
document.

Differential Revision: https://phabricator.services.mozilla.com/D138357
2022-02-10 00:38:45 +00:00
Emilio Cobos Álvarez
946ca76d93 Bug 1724719- Ensure IntersectionObserver.observe is O(1), not O(targetCount). r=smaug
And that IntersectionObserver.unobserve is O(targetCount) worst case,
not O(2*targetCount).

Differential Revision: https://phabricator.services.mozilla.com/D122119
2021-08-09 16:10:07 +00:00
Hiroyuki Ikezoe
aa7268d6c1 Bug 1700245 - Replace IsAncestorFrameCrossDoc with IsAncestorFrameCrossDocInProcess in DOMIntersectionObserver::Update. r=emilio
Our IntersectionObserver has been working in OOP iframe since bug 1599795.

Differential Revision: https://phabricator.services.mozilla.com/D117500
2021-06-13 22:02:22 +00:00
Emilio Cobos Álvarez
b7f648be74 Bug 1709577 - Check list of available images before deciding to defer a lazy load. r=edgar
As per https://html.spec.whatwg.org/#updating-the-image-data step 6.

Differential Revision: https://phabricator.services.mozilla.com/D114353
2021-05-07 13:56:33 +00:00
Dorel Luca
3eacfad31f Backed out 2 changesets (bug 1709577) for WPT Failures in /html/semantics/embedded-content/the-img-element/image-loading-lazy-base-url.html. CLOSED TREE
Backed out changeset ceed6d7fca1c (bug 1709577)
Backed out changeset bb44c14b754f (bug 1709577)
2021-05-07 16:46:48 +03:00
Emilio Cobos Álvarez
6302e3acc0 Bug 1709577 - Check list of available images before deciding to defer a lazy load. r=edgar
As per https://html.spec.whatwg.org/#updating-the-image-data step 6.

Differential Revision: https://phabricator.services.mozilla.com/D114353
2021-05-07 11:44:15 +00:00
Sandor Molnar
c7dc20560e Backed out 2 changesets (bug 1709577) for causing wpt failures. CLOSED TREE
Backed out changeset 0da1dba1749c (bug 1709577)
Backed out changeset bab974107b3b (bug 1709577)
2021-05-07 05:34:43 +03:00
Emilio Cobos Álvarez
62bc311075 Bug 1709577 - Check list of available images before deciding to defer a lazy load. r=edgar
As per https://html.spec.whatwg.org/#updating-the-image-data step 6.

Differential Revision: https://phabricator.services.mozilla.com/D114353
2021-05-07 00:11:06 +00:00
Edgar Chen
1bb16b15ba Bug 1709200 - Rename nsContentUtils::GetRootDocument to GetInProcessSubtreeRootDocument; r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D114177
2021-05-05 09:42:20 +00:00
Daniel Holbert
e49e7b9ab2 Bug 1699853: Use "InProcess" version of GetCrossDocParentFrame() in DOMIntersectionObserver.cpp. r=emilio
This patch doesn't change behavior; it's just switching us between two
functions that do the same thing. (One is literally a trivial wrapper for the
other.)

We're using the new "InProcess" version of this API as a way of annotating
callsites that have been vetted as behaving properly in out-of-process iframes.

These two callsites in DOMIntersectionObserver.cpp are part of an algorithm
that was already modernized to work with fission in bug 1599795.  In a
fission-enabled scenario: when we end up with null `containerFrame` due to
hitting an oop-iframe boundary, we should end up handling things properly via
our subsequent application of the passed-in `aRemoteDocumentVisibleRect` arg.

Differential Revision: https://phabricator.services.mozilla.com/D109169
2021-03-19 23:58:30 +00:00
Emilio Cobos Álvarez
49bdf16db5 Bug 941356 - Fix start offset of transformed drag images. r=botond
I'm not sure whether we should deal with ancestor scales and such. There
seemed to be a discussion about that in D77436 but dealing with
partially-3d-transformed content sounds like a massive pain. For now
this fixes the start point, which is a progression.

Differential Revision: https://phabricator.services.mozilla.com/D106896
2021-03-04 10:56:22 +00:00
Emilio Cobos Álvarez
28b6ccc4e5 Bug 1682915 - Deal with root == target in intersection observer code. r=dholbert
The "compute the intersection" algorithm could deal with this case
easily (right now it doesn't), but the spec doesn't, so let's match the
spec and Safari lacking a compelling use case for this.

Chrome doesn't send a notification in this case, which is definitely
wrong.

Differential Revision: https://phabricator.services.mozilla.com/D104386
2021-02-11 14:08:06 +00:00
Sean Feng
461677cdfb Bug 1687358 - Implement telemetry probes to determine the best possible threshold for <lazyload> r=emilio
This patch implements five telemetry probes to help us learn how
lazyload thresholds perform in the wild.

Differential Revision: https://phabricator.services.mozilla.com/D102845
2021-01-29 17:03:25 +00:00
Bogdan Tara
cea3638c90 Backed out changeset a77ccd1c1659 (bug 1687358) for browser_lazyload_telemetry.js failures CLOSED TREE 2021-01-27 02:46:06 +02:00
Sean Feng
2b4f1850d6 Bug 1687358 - Implement telemetry probes to determine the best possible threshold for <lazyload> r=emilio
This patch implements five telemetry probes to help us learn how
lazyload thresholds perform in the wild.

Differential Revision: https://phabricator.services.mozilla.com/D102845
2021-01-26 21:54:33 +00:00
Emilio Cobos Álvarez
4b14f559c4 Bug 1686386 - Make DOMIntersectionObserver check docgroup rather than principal base domain. r=mstange
This is similar effectively, and should be more correct and faster, as per:

  https://github.com/w3c/IntersectionObserver/issues/161#issuecomment-492539452

Differential Revision: https://phabricator.services.mozilla.com/D101636
2021-01-14 14:31:46 +00:00
Emilio Cobos Álvarez
fe2b95e111 Bug 1682003 - Avoid UTF-8 -> UTF-16 conversion during CSSOM serialization. r=heycam
This lifts a bunch of string conversions higher up the stack, but allows
us to make the servo code use utf-8 unconditionally, and seemed faster
in my benchmarking (see comment 0).

It should also make a bunch of attribute setters faster too (like
setting .cssText), now that we use UTF8String for them (we couldn't
because we couldn't specify different string types for the getter and
setters).

Differential Revision: https://phabricator.services.mozilla.com/D99590
2020-12-17 14:04:35 +00:00
Simon Giesecke
eae3689379 Bug 1673931 - Avoid including Document.h from header files. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D95046

Depends on D95045
2020-11-23 16:07:43 +00:00
Simon Giesecke
46908cfb51 Bug 1660470 - Add missing include directives/forward declarations. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D87865
2020-11-23 16:21:38 +00:00
Sylvestre Ledru
68b806d604 Bug 1674637 - Use nested namespaces in dom/ r=sg,andi
Also add some missing namespace qualifications

Done with:
./mach static-analysis check --checks="-*,modernize-concat-nested-namespaces" --fix dom/
./mach clang-format -p $(hg status dom/|grep ^M|awk '{print $2}')

Differential Revision: https://phabricator.services.mozilla.com/D95456
2020-11-04 17:04:01 +00:00
Butkovits Atila
a6e7dcc53f Backed out changeset c0adbf7522dc (bug 1674637) for bustage on GMPParent.cpp. CLOSED TREE 2020-11-04 10:54:36 +02:00
Sylvestre Ledru
8f709b39e8 Bug 1674637 - Use nested namespaces in dom/ r=sg,andi
Also add some missing namespace qualifications

Done with:
./mach static-analysis check --checks="-*,modernize-concat-nested-namespaces" --fix dom/
./mach clang-format -p $(hg status dom/|grep ^M|awk '{print $2}')

Differential Revision: https://phabricator.services.mozilla.com/D95456
2020-11-04 08:29:00 +00:00
Emilio Cobos Álvarez
3bd76fc16f Bug 1670327 - Fix more IntersectionObserver issues. r=hiro
Two spec issues here.

https://github.com/w3c/IntersectionObserver/issues/457: I think this is
just a spec bug and I've made us match other browsers, but since the
tests don't match the spec for now I've added them as .tentative.html

https://github.com/w3c/IntersectionObserver/issues/456: I've aligned
with WebKit here. There was a (disabled) test for this which tests
chrome behavior and which after this patch shouldn't be flaky. This is
what was causing the assertion.

Differential Revision: https://phabricator.services.mozilla.com/D93166
2020-10-12 10:58:35 +00:00
Mihai Alexandru Michis
6683297ddc Backed out changeset a083e04138aa (bug 1670327) for causing wpt failures in intersection-observer/root-margin.html
CLOSED TREE
2020-10-12 13:35:28 +03:00
Emilio Cobos Álvarez
f565092b39 Bug 1670327 - Fix more IntersectionObserver issues. r=hiro
Two spec issues here.

https://github.com/w3c/IntersectionObserver/issues/457: I think this is
just a spec bug and I've made us match other browsers, but since the
tests don't match the spec for now I've added them as .tentative.html

https://github.com/w3c/IntersectionObserver/issues/456: I've aligned
with WebKit here. There was a (disabled) test for this which tests
chrome behavior and which after this patch shouldn't be flaky. This is
what was causing the assertion.

Differential Revision: https://phabricator.services.mozilla.com/D93166
2020-10-12 09:52:22 +00:00
Emilio Cobos Álvarez
869f3bcf09 Bug 1668784 - Return empty oop iframe metrics rather than no metrics for OOP iframes that we still haven't positioned and such. r=hiro
This is the right thing to do. If the compositor still hasn't sent
BrowserChild its visible position, then we should just be
non-intersecting, not carry on with the root document state.

Fix the test to not be racy, as the layout / positioning of the iframe
is async with Fission / Chromium site isolation enabled.

Differential Revision: https://phabricator.services.mozilla.com/D92240
2020-10-02 21:30:37 +00:00
Emilio Cobos Álvarez
56cd679ea1 Bug 1668156 - Fix some IntersectionObserver edge cases, and enable the assertion for good. r=hiro
This patch fixes two issues, described below:

First, the GetTopLevelDocument function was looking at the browsing
context tree. It should look at the window context tree, as looking at
the browsing context tree means that if you're in a discarded or
about-to-get-discarded document, you can end up with a document from a
different tree. Computing intersections between those of course makes no
sense and triggers the assertion we're enabling.

Second, this patch fixes an issue when you have fission enabled, and a
setup such as:

  A1 -> B1 -> A2

If you try to use IntersectionObserver from A2 with the implicit root,
we'd end up with:

  * rootRect: A1's root scrollport rect (this is fine, because it's only
              used to compute the root margin and bounds and so on, not
              to compute geometry).

  * rootFrame: A1's root scroll frame (this is _not_ fine, see below).

Then, we'd try to map rects from A2's target to A1's viewport, and we
can't really do that sensibly with the existing nsLayoutUtils functions,
because we're not accounting for all the OOP iframe transforms that may
be going on. This also triggers the assertion that this patch enables in
same-origin-grand-child-iframe.sub.html.

To fix it, for the A2 case, use the same code that we have for other OOP
iframes. The test tweaks fails with fission enabled without the patch
(because we don't account for the OOP iframe clip).

Differential Revision: https://phabricator.services.mozilla.com/D92089
2020-10-01 22:41:55 +00:00
Simon Giesecke
1f29cc4393 Bug 1656117 - Reduce include dependencies on nsRefreshDriver.h. r=mstange
The abstract observer base classes are moved to a separate header file
nsRefreshObservers.h and the includes are adjusted accordingly.

Some method implementations are moved to the corresponding implementation files
to avoid the need to include the nsRefreshDriver.h file in the header.

Differential Revision: https://phabricator.services.mozilla.com/D85764
2020-08-04 21:17:50 +00:00