Convert menulist to custom element
Categories
(Toolkit :: UI Widgets, task, P5)
Tracking
()
Tracking | Status | |
---|---|---|
firefox67 | --- | fixed |
People
(Reporter: timdream, Assigned: timdream)
References
Details
Attachments
(2 files, 1 obsolete file)
This might work in the way I intend for bug 1514926 to work; the only child of <menulist>
element should be <menupopup>
, and we will only be inserting things before it, instead of moving the child.
If this works we can land
https://phabricator.services.mozilla.com//D14925
here since I would need it to use for the new custom element to inherit XULMenuElement.
Assignee | ||
Comment 1•5 years ago
|
||
This custom element replaces XBL <content> usage by directly prepend the two needed child nodes when the element is connected. This is doable because a) There isn't any direct access of child nodes under <menulist>. Everyone seems to access via .menupopup, which is usually the only child. (One instance of that indentified is removed) b) We don't need to move the children under <menulist>. If we need to and if the child is a <xbl:children> (which could happen if <menulist> is inside a XBL <content> that just get cloned to the document), the layout will get very confused and crash (see finding in bug 1514926)
Assignee | ||
Comment 2•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 3•5 years ago
|
||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 4•5 years ago
|
||
I am looking at a very strange behavior here:
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=221016360&repo=try&lineNumber=19195
This test calls menulist.appendItem()
to get a <menuitem>
constructed, set its .image
, and assert that the value of the .image
gets set on the menulist
.
The image
property is defined in the basetext XBL binding. Here is the interesting part: how did the <menuitem>
binding gets constructed, if the popup is not opened?
I put a dump(("image" in item) + "\n");
right after the appendChild()
line and it seems that appending a child into existing XBL anonymous content can magically cause the binding to construct, while the CE menulist does not pose this kind of magic. I have not locate the DOM code that does this though so I might be wrong, but this is very troubling if so since I don't have any way in CE to force XBL construction on a non-visible element.
Assignee | ||
Comment 6•5 years ago
|
||
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #4)
... and it's fixed because :bgrins quickly remind me of this:
Assignee | ||
Comment 7•5 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=6562564a8015469d163a0155883a2755b57d4ef9
Failures are mostly fixed. I am not sure about I set up the nsIDOMXULMenuListElement interface right though. a11y test still fails.
Assignee | ||
Comment 8•5 years ago
|
||
There are two more things to note:
- menulist binding seems to be able to keep the menuitem bindings attached even though they are not visible under menupopup. The menulist CE don't have that ability. I had to change instances of
menulist.selectedItem.value
tomenulist.value
for things to work. I don't really know why the previous getter work (other than the fact the selectedItem is kept alive for some unknown reasons. sizetopopup
is a major pain. The value set by the binding can be pick up by layout, while CE can only set it after the fact (it seems) and force layout to pick it up. It would still partially work (see the reftest change). We may want to move the attribute to the caller (there are many 😢) and/or change the default, but I don't think we should address that in this bug (unless we don't want to land the hack.)
Assignee | ||
Comment 9•5 years ago
|
||
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #8)
sizetopopup
is a major pain. The value set by the binding can be pick up by layout, while CE can only set it after the fact (it seems) and force layout to pick it up. It would still partially work (see the reftest change). We may want to move the attribute to the caller (there are many 😢) and/or change the default, but I don't think we should address that in this bug (unless we don't want to land the hack.)
I decided to remove the hack and properly fix this in nsMenuPopupFrame and nsMenuFrame. The fix only conservatively keys to frames generated by <menulist> just to keep the scope in check.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=5ae7a527a659b31ae5622b3a7c2cffab538d89e2
Assignee | ||
Comment 10•5 years ago
|
||
sizetopopup is set to "pref" by default by the menulist XBL binding, however when converting the binding to custom element, it did not set the attribute value at a time that is early enough. This patch updates nsMenuPopupFrame and nsMenuFrame so that it considers <menulist> with unset sizetopopup attribute as equal to "pref" to avoid the problem above. The problem can be detected by the reftest layout/reftests/xul/menulist-shrinkwrap-2.xul in which the parent box won't update its width even when <menulist> reframes with the correct sizetopopup value. The sizetopopup attribute is never meant to be set dynamically; the fix here does not allow us to do so.
Assignee | ||
Comment 11•5 years ago
•
|
||
It turned out I had to explicitly reference Ci.nsIDOMXULSelectControlElement
when calling implementCustomInterface
. Passing Ci.nsIDOMXULMenuListElement
alone is not enough.
Assignee | ||
Comment 12•5 years ago
|
||
... and XULComboboxAccessible
silently ignores XBL children <menulist>
.... 😫
Assignee | ||
Comment 13•5 years ago
|
||
Updated•5 years ago
|
Assignee | ||
Comment 14•5 years ago
|
||
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #13)
https://treeherder.mozilla.org/#/jobs?repo=try&revision=e810c789c59eadfb18afd2f9223aee6303f689e6
This is super weird — it showing test failures that should have been fixed, and shouldn't have been passed on any platforms, but it only fails on some of the platforms. This is going to take a while 😖
Assignee | ||
Comment 15•5 years ago
|
||
Try one more time on a rebased central with a few dump()
s.
Assignee | ||
Comment 16•5 years ago
|
||
Actually, this should fix a11y on Windows so let's see if it could fix something else
https://treeherder.mozilla.org/#/jobs?repo=try&revision=7f9078641ff336999fda160c5e82623683788e39
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 17•5 years ago
|
||
Alright, this should work
https://treeherder.mozilla.org/#/jobs?repo=try&revision=07d42691678d23748b692b53418631a59e50cc23
Assignee | ||
Comment 18•5 years ago
|
||
Assignee | ||
Comment 19•5 years ago
|
||
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #18)
Pushes for talos tests
A little bit more context:
So there are four <menulist>
s in browser.xul
with three hidden. They are WebRTC device selection drop-downs in popup-notifications.inc
. The patch here will make us running extra constructions for these three elements.
What's even worse is that at the time in bug 823443, PopupNotifications.jsm
is implemented such that it will remove and re-append the <popupnotification>
s to show. I can see the menulist XBL binding gets constructed and immediately destructed three times when the popup is first shown. Sadly that useless construction will now happen during start-up.
I would like to avoid creeping this bug too much so unless that's proven to be a performance problem, I will not try to deal with it (as a dependency or in this bug). Nonetheless I will file a bug for this.
Assignee | ||
Comment 20•5 years ago
|
||
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #18)
Pushes for talos tests
It turned out we regressed about:preferences by a lot. That's not unexpected — should have realized that earlier. 😞
I would need to find a way to defer the CE construction in the hidden panels.
Comment 21•5 years ago
|
||
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #20)
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #18)
Pushes for talos tests
It turned out we regressed about:preferences by a lot. That's not unexpected — should have realized that earlier. 😞
I would need to find a way to defer the CE construction in the hidden panels.
Is it possible that we could optimize the connectedCallback (sharing a document fragment that gets cloned, for example) to avoid having to defer construction for hidden elements?
Also, are you seeing similar numbers locally on about:preferences (I guess 6-10ms in the CE)? I've used ./mach talos-test -a about_preferences_basic --cycles 1 --gecko-profile
locally in the past for this (or the --talos-profile
flag in try fuzzy syntax without rebuilds).
Assignee | ||
Comment 22•5 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #21)
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #20)
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #18)
Pushes for talos tests
It turned out we regressed about:preferences by a lot. That's not unexpected — should have realized that earlier. 😞
I would need to find a way to defer the CE construction in the hidden panels.Is it possible that we could optimize the connectedCallback (sharing a document fragment that gets cloned, for example) to avoid having to defer construction for hidden elements?
Just done that, let's see how it goes, thanks for the suggestion.
Also, are you seeing similar numbers locally on about:preferences (I guess 6-10ms in the CE)? I've used
./mach talos-test -a about_preferences_basic --cycles 1 --gecko-profile
locally in the past for this (or the--talos-profile
flag in try fuzzy syntax without rebuilds).
Unfortunately I am using debug build locally so I won't be able to do a meaningful talos measurement.
Assignee | ||
Comment 23•5 years ago
|
||
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #22)
Just done that, let's see how it goes, thanks for the suggestion.
There are improvements but that doesn't look enough though.
Assignee | ||
Comment 24•5 years ago
|
||
New talos pushes
Compare against a new central base.
Compare with patches applied on top of bug 1520350
Assignee | ||
Comment 25•5 years ago
|
||
(In reply to Tim Guan-tin Chien [:timdream] (please needinfo) from comment #24)
Compare with patches applied on top of bug 1520350
This demonstrates bug 1520350 could fix the perf regression here. All of the speed differences returns with low confidence except one. I am retriggering more tests to get the data point for that one.
Assignee | ||
Comment 26•5 years ago
•
|
||
BTW I have removed the use of XPCOMUtils
with small vanilla JS. This is the artifact build test run on top of bug 1520350.
https://treeherder.mozilla.org/#/jobs?repo=try&author=timdream%40gmail.com&selectedJob=222567906
Comment 27•5 years ago
|
||
Pushed by tchien@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b77df8435ab1 Create BaseControlMixin, allowing BaseControl to inherit other native XULElement classes r=bgrins https://hg.mozilla.org/integration/autoland/rev/c1032d34b5e0 Convert menulist to custom element r=paolo
Comment 28•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/b77df8435ab1
https://hg.mozilla.org/mozilla-central/rev/c1032d34b5e0
Updated•5 years ago
|
Description
•