gecko-dev/dom
Emilio Cobos Álvarez ac8c134eb5 Bug 1555133 - Add some heuristics about visible content in a document. r=bzbarsky
This is intended to give a reasonable number that scales with the amount of
content in a website during page load, for scheduling purposes.

This effectively counts the amount of text connected to a document that isn't
likely to be inline style or script.

Potential improvements:

 * Maybe have some more heuristics for hidden elements, like presence of the
   `hidden` attribute?

 * Maybe skip whitespace-only text? This does a pretty good job anyways because
   whitespace nodes are usually pretty small (like a couple newlines and
   spaces), so they don't add too much to the number. This could be done cheaply if
   looking at sSpaceSharedString / sTabSharedString.

 * Add some weight to some elements? Maybe images should have a fixed weight,
   for example. Though you don't want 0x0 images and such to count... Maybe we
   should add to this heuristic out of band when processing image loads or some
   such.

 * Handle shadow DOM and such better? Right now Shadow DOM and XBL are always
   assumed visible as long as they're connected. You _can_ in theory do
   something like stash a `<div>` inside a `<style>` element, attach a
   ShadowRoot and such, and append a bunch of stuff inside. But I don't think
   it's something we should be particularly worried about.

 * Probably add some check to CharacterData::AppendText as well?  Otherwise this
   undercounts when loading big amount of text arrives via the network, for
   example, but also I'm not sure we're optimizing for log files and such so it
   might be ok.

In any case, this gives us a heuristic that we can iterate on later. This does a
pretty good job at representing the amount of content in the examples over here:

 * https://faraday.basschouten.com/mozilla/executionorder/

For example for:

 * https://faraday.basschouten.com/mozilla/executionorder/allinlinedual.html

You get an output like the following if you print the heuristic after each bind
operation (and de-duplicating them):

```
0
3 // Some whitespace in <head>
4 // Some whitespace in the <body>.
5
6
7
8
9
10
65547 // Actual content injected by the first script.
65548 // Some more whitespace.
131085 // Actual content injected by the second script.
131087 // Some more whitespace.
```

I'm not a fan of what clang-format has done to my code btw :)

Differential Revision: https://phabricator.services.mozilla.com/D34397

--HG--
extra : moz-landing-system : lando
2019-06-11 10:00:46 +00:00
..
abort
animation Bug 1556855 part 2: Update tests to assume that 'layout.css.prefixes.webkit' is already true. r=mats 2019-06-05 18:22:39 +00:00
audiochannel
base Bug 1555133 - Add some heuristics about visible content in a document. r=bzbarsky 2019-06-11 10:00:46 +00:00
battery
bindings Bug 1557141 - IsRemoteObjectProxy shouldn't be static top level functions. r=bzbarsky 2019-06-07 20:27:40 +00:00
broadcastchannel
browser-element Bug 1557237. Stop using [array] in nsIPrompt and nsIPromptService. r=Gijs 2019-06-06 08:03:56 +00:00
cache
canvas Merge mozilla-inbound to mozilla-central. a=merge 2019-06-07 19:19:50 +03:00
chrome-webidl Bug 1556483 - Expose isInitialDocument on WindowGlobalParent, r=bzbarsky 2019-06-06 14:57:32 +00:00
clients Bug 1534681 Use ReferrerInfo class in document r=ckerschb,baku,Gijs 2019-06-06 07:23:37 +00:00
commandhandler
console
credentialmanagement
crypto
docs
encoding
events Bug 1557847. Stop using [array] in nsIClipboard. r=NeilDeakin 2019-06-09 01:06:39 +00:00
fetch Bug 1557121 - Implement Blob.text()/Blob.arrayBuffer()/Blob.stream() - part 3 - Rename FetchBodyConsumer to BodyConsumer, r=smaug 2019-06-07 14:16:59 +00:00
file Bug 1557121 - Implement Blob.text()/Blob.arrayBuffer()/Blob.stream() - part 6 - tests, r=smaug 2019-06-07 13:10:55 +00:00
filehandle
filesystem
flex Bug 1532937 - Enable ESLint for dom/flex and dom/grid (automatic changes). r=Standard8,smaug 2019-06-03 10:42:12 +00:00
gamepad Merge inbound to mozilla-central. a=merge 2019-06-09 12:06:26 +03:00
geolocation
grid Bug 1532937 - Enable ESLint for dom/flex and dom/grid (automatic changes). r=Standard8,smaug 2019-06-03 10:42:12 +00:00
html Merge inbound to mozilla-central. a=merge 2019-06-11 00:47:19 +03:00
imptests
indexedDB Bug 1557997 - IDB: Add more IsShuttingDown checks to database maintenance; r=asuth 2019-06-09 09:20:49 +02:00
interfaces Bug 1534681 Use ReferrerInfo class in document r=ckerschb,baku,Gijs 2019-06-06 07:23:37 +00:00
ipc Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld 2019-06-11 02:01:34 +00:00
jsurl Bug 1555050: Always (if non null) set any CSP as cspToInherit on the loadinfo of new document load. Update documentation for GetCSP, GetPreloadCSP() and GetCSPToInherit and update two callsites which called GetCSP instead of GetCSPToInherit. r=bzbarsky 2019-06-06 20:19:56 +00:00
l10n Bug 1552714 - Fix tests to compare the result of getAttributes against L10nKeys. r=smaug 2019-06-06 16:33:09 +00:00
locales Bug 1557223 - Remove deprecated op r=Ehsan 2019-06-10 15:02:02 +00:00
localstorage Bug 1558112 - LSNG: Connection::FlushOp::DoDatastoreWork needs to automatically detach the shadow database on an error; r=asuth 2019-06-10 08:41:13 +02:00
manifest
mathml Bug 1556095 - Make BindContext carry a bit more information. r=bzbarsky 2019-06-01 14:40:33 +00:00
media Backed out 9 changesets (bug 1554075) for reftest failures in Intervals.h and MP4Interval.h on a CLOSED TREE 2019-06-11 09:52:43 +03:00
messagechannel
midi
network
notification Bug 1553769 - Have a single way of requesting window focus and switching to a tab. r=NeilDeakin,snorp 2019-06-03 19:42:28 +00:00
offline
payments
performance
permission
plugins Merge mozilla-central to autoland. a=merge CLOSED TREE 2019-06-06 13:51:59 +03:00
power
presentation
prio
promise
prototype Bug 836176 - Part 3: Remove nsIHTMLDocument; r=farre 2019-06-04 17:27:43 +00:00
push Bug 1545421 - New nsresult error codes for 407, 502 and 504 http response codes returned by proxies + test, r=dragana 2019-05-31 17:29:53 +00:00
quota Bug 1516333 - Part 1: Move group and origin re-escaping from QuotaManager::GetQuotaObject to GetQuotaObjectFromNameAndParameters in TelemetryVFS.cpp; r=janv,asuth 2019-06-07 08:04:57 +02:00
reporting
res
script Bug 1534681 Use ReferrerInfo class in document r=ckerschb,baku,Gijs 2019-06-06 07:23:37 +00:00
security Bug 1555050: Write test for large-allocation. r=bzbarsky 2019-06-07 11:07:28 +00:00
serviceworkers Bug 1555050: Always (if non null) set any CSP as cspToInherit on the loadinfo of new document load. Update documentation for GetCSP, GetPreloadCSP() and GetCSPToInherit and update two callsites which called GetCSP instead of GetCSPToInherit. r=bzbarsky 2019-06-06 20:19:56 +00:00
simpledb
smil
storage Bug 1556812 - Only notify same-origin actors in LocalStorageCacheParent::RecvNotify(); r=baku 2019-06-07 15:09:21 +00:00
svg Bug 1557430 - Add memory reporters for SVG mapped attribute declarations. r=njn,heycam 2019-06-08 18:58:57 +00:00
system Bug 1555374. Use StaticPrefs accessors for various prefs that moved to StaticPrefs recently. r=edgar 2019-06-01 02:29:26 +00:00
tests Bug 1555488 - Part 2: Add initial tests for WindowProxy cache clearing, r=mccr8 2019-06-06 14:57:25 +00:00
u2f
url Bug 1555302 - Ensure that nsStandardURL::Resolve() doesn't parse URLs with a different scheme as relative r=mayhemer 2019-06-04 13:42:37 +00:00
vr
webauthn
webbrowserpersist
webgpu
webidl Bug 1557121 - Implement Blob.text()/Blob.arrayBuffer()/Blob.stream() - part 5 - blob.stream(), r=smaug 2019-06-07 13:10:33 +00:00
websocket
workers Bug 1555050: Always (if non null) set any CSP as cspToInherit on the loadinfo of new document load. Update documentation for GetCSP, GetPreloadCSP() and GetCSPToInherit and update two callsites which called GetCSP instead of GetCSPToInherit. r=bzbarsky 2019-06-06 20:19:56 +00:00
worklet
xbl Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky 2019-05-31 23:31:52 +02:00
xhr Bug 1534681 Use ReferrerInfo class in document r=ckerschb,baku,Gijs 2019-06-06 07:23:37 +00:00
xml Bug 836176 - Part 3: Remove nsIHTMLDocument; r=farre 2019-06-04 17:27:43 +00:00
xslt Bug 836176 - Part 3: Remove nsIHTMLDocument; r=farre 2019-06-04 17:27:43 +00:00
xul Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan 2019-06-08 08:26:37 +00:00
jar.mn
moz.build