Unify how we cache fragments with parseXULToFragment in our Custom Elements
Categories
(Toolkit :: XUL Widgets, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox77 | --- | fixed |
People
(Reporter: bgrins, Assigned: emmamalysz)
References
(Depends on 3 open bugs)
Details
(Whiteboard: [fxperf:p2])
Attachments
(2 files)
We currently have a few different patterns for caching fragments. At this point we should migrate our chrome custom elements to use the same one.
A bunch of examples can be found from callers https://searchfox.org/mozilla-central/search?q=parseXULToFragment&case=true®exp=false, and usually actually happens with a call to importNode or cloneNode:
- https://searchfox.org/mozilla-central/search?q=importNode&case=true®exp=false&path=toolkit%2Fcontent%2Fwidgets
- https://searchfox.org/mozilla-central/search?q=cloneNode&case=true®exp=false&path=toolkit%2Fcontent%2Fwidgets
The latest elements have been doing something like: https://searchfox.org/mozilla-central/rev/8a63fc190b39ed6951abb4aef4a56487a43962bc/toolkit/content/widgets/arrowscrollbox.js#143-150
get fragment() {
if (!this.constructor.hasOwnProperty("_fragment")) {
this.constructor._fragment = MozXULElement.parseXULToFragment(
this.markup
);
}
return document.importNode(this.constructor._fragment, true);
}
which is good because it caches once per class and also supports subclasses (using hasOwnProperty instead of just checking this.constructor["_fragment"]
).
There are also ideas around caching it per-process and not per window (in a JSM instead of in a Custom Element definition). That may or may not happen here but worth keeping in mind: https://phabricator.services.mozilla.com/D50137#1521553.
Updated•4 years ago
|
Comment 1•4 years ago
|
||
Given the improvements reported in bug 1590554 comment 7, I suspect this is worth doing and could have a positive impact on startup times.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
Pushed by rmaries@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6b7c81561ecc create a unified approach for caching fragments in our Custom Elements r=emilio
Comment 4•3 years ago
|
||
Backed out for marionette perma failures.
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=296738238&repo=autoland&lineNumber=69973
Backout: https://hg.mozilla.org/integration/autoland/rev/33c92ceddf3989a00f40152c15e555989e48b704
Pushed by cbrindusan@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/70b0b35496a5 create a unified approach for caching fragments in our Custom Elements r=emilio
Assignee | ||
Comment 6•3 years ago
|
||
Pushed by cbrindusan@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4ccafa875240 Followup: Revert changes on elements that don't use MozXULElement. CLOSED TREE
Comment 8•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/70b0b35496a5
https://hg.mozilla.org/mozilla-central/rev/4ccafa875240
Assignee | ||
Updated•3 years ago
|
Description
•