maildev@lists.thunderbird.net

Thunderbird email developers

View all threads

Custom menulist structure changes

CL
Christopher Leidigh
Mon, Jun 17, 2019 7:23 PM

While working on the import export tools TB68 upgrade I got caught with
a tricky and opaque
problem.  After chasing a variety of things, I discovered that the new
custom menulist widget
as a different structure than the original XUL implementation including
several new interpolated
wrappers or decorators.  I understand and am not surprised that these
new elements are required
to implemented new widget.  The issue I ran into was that the original
authors code traversed the
DOM for menulist with firstChild on the menulist element to get the
menupopup element.  Prior
to the custom element this was okay , but now with interpolated elements
the code obtain one of
the hbox label elements.

I think the new structure should be described in the menulist section of
the development docs.
Even if we do not yet describe any user functionality for these
elements, users should know
what the full overlaid widget it looks like.

I would make the same argument for any other new custom elements where
additional structure
is added.

Christopher

Original import-export-tools menulist snippet from the options page:
(additional IDs added by me)

    <hbox align="center" id="hboxID">
        <menulist id="part1">
            <menupopup id="part1-popup-list">
                <menuitem label="&subject;" value="%s"/>
                <menuitem label="&date;" value="%d"/>
                <menuitem label="&key;" value="%k"/>
                <menuitem label="&name; (&sender;/&recipient;)" value="%n"/>
                <menuitem label="&name; (&sender;)" value="%a"/>
                <menuitem label="&name; (&recipient;)" value="%r"/>
            </menupopup>
        </menulist>

Generated DOM from TB60.7.1:

<menulist
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="part1" sizetopopup="pref" value="%s"
    label="Subject">
    <menupopup id="part1-popup-list">
        <menuitem id="m0" label="Subject" value="%s" selected="true" />
        <menuitem label="Date" value="%d" />
        <menuitem label="Index" value="%k" />
        <menuitem label="Name (Sender/Recipient)" value="%n" />
        <menuitem label="Name (Sender)" value="%a" />
        <menuitem label="Name (Recipient)" value="%r" />
    </menupopup>
</menulist>

Generated DOM from TB68.1: (custom widget)

<menulist
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="part1" value="%s"
    label="Subject">
    <hbox class="menulist-label-box" flex="1" role="none">
        <image class="menulist-icon" role="none" /><label
class="menulist-label" crop="right" flex="1" role="none"
            value="Subject" /><label
class="menulist-highlightable-label" crop="right" flex="1"
            role="none">Subject</label></hbox>
    <dropmarker class="menulist-dropmarker" type="menu" role="none">
        <image class="dropmarker-icon" />
    </dropmarker>
    <menupopup id="part1-popup-list">
        <menuitem id="m0" label="Subject" value="%s" selected="true">
        <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true" selected="true">
            <image class="menu-iconic-icon" />
        </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true" value="Subject" /><label
            class="menu-iconic-highlightable-text" crop="right"
aria-hidden="true">Subject</label></menuitem>
        <menuitem label="Date" value="%d">
        <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">
            <image class="menu-iconic-icon" />
        </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true" value="Date" /><label
            class="menu-iconic-highlightable-text" crop="right"
aria-hidden="true">Date</label></menuitem>
        <menuitem label="Index" value="%k">
        <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">
            <image class="menu-iconic-icon" />
        </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true" value="Index" /><label
            class="menu-iconic-highlightable-text" crop="right"
aria-hidden="true">Index</label></menuitem>
        <menuitem label="Name (Sender/Recipient)" value="%n">
        <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">
            <image class="menu-iconic-icon" />
        </hbox><label class="menu-iconic-text" flex="1" crop="right"
aria-hidden="true"
            value="Name (Sender/Recipient)" /><label
class="menu-iconic-highlightable-text" crop="right"
            aria-hidden="true">Name (Sender/Recipient)</label></menuitem>
        <menuitem label="Name (Sender)" value="%a">
        <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">
            <image class="menu-iconic-icon" />
        </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true" value="Name (Sender)" /><label
            class="menu-iconic-highlightable-text" crop="right"
aria-hidden="true">Name (Sender)</label></menuitem>
        <menuitem label="Name (Recipient)" value="%r">
        <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">
            <image class="menu-iconic-icon" />
        </hbox><label class="menu-iconic-text" flex="1" crop="right"
aria-hidden="true"
            value="Name (Recipient)" /><label
class="menu-iconic-highlightable-text" crop="right"
            aria-hidden="true">Name (Recipient)</label></menuitem>
    </menupopup>
</menulist>

While working on the import export tools TB68 upgrade I got caught with a tricky and opaque problem.  After chasing a variety of things, I discovered that the new custom menulist widget as a different structure than the original XUL implementation including several new interpolated wrappers or decorators.  I understand and am not surprised that these new elements are required to implemented new widget.  The issue I ran into was that the original authors code traversed the DOM for menulist with firstChild on the menulist element to get the menupopup element.  Prior to the custom element this was okay , but now with interpolated elements the code obtain one of the hbox label elements. I think the new structure should be described in the menulist section of the development docs. Even if we do not yet describe any user functionality for these elements, users should know what the full overlaid widget it looks like. I would make the same argument for any other new custom elements where additional structure is added. Christopher Original import-export-tools menulist snippet from the options page: (additional IDs added by me)     <hbox align="center" id="hboxID">         <menulist id="part1">             <menupopup id="part1-popup-list">                 <menuitem label="&subject;" value="%s"/>                 <menuitem label="&date;" value="%d"/>                 <menuitem label="&key;" value="%k"/>                 <menuitem label="&name; (&sender;/&recipient;)" value="%n"/>                 <menuitem label="&name; (&sender;)" value="%a"/>                 <menuitem label="&name; (&recipient;)" value="%r"/>             </menupopup>         </menulist> Generated DOM from TB60.7.1: <menulist xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="part1" sizetopopup="pref" value="%s"     label="Subject">     <menupopup id="part1-popup-list">         <menuitem id="m0" label="Subject" value="%s" selected="true" />         <menuitem label="Date" value="%d" />         <menuitem label="Index" value="%k" />         <menuitem label="Name (Sender/Recipient)" value="%n" />         <menuitem label="Name (Sender)" value="%a" />         <menuitem label="Name (Recipient)" value="%r" />     </menupopup> </menulist> Generated DOM from TB68.1: (custom widget) <menulist xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="part1" value="%s"     label="Subject">     <hbox class="menulist-label-box" flex="1" role="none">         <image class="menulist-icon" role="none" /><label class="menulist-label" crop="right" flex="1" role="none"             value="Subject" /><label class="menulist-highlightable-label" crop="right" flex="1"             role="none">Subject</label></hbox>     <dropmarker class="menulist-dropmarker" type="menu" role="none">         <image class="dropmarker-icon" />     </dropmarker>     <menupopup id="part1-popup-list">         <menuitem id="m0" label="Subject" value="%s" selected="true">         <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true" selected="true">             <image class="menu-iconic-icon" />         </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true" value="Subject" /><label             class="menu-iconic-highlightable-text" crop="right" aria-hidden="true">Subject</label></menuitem>         <menuitem label="Date" value="%d">         <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">             <image class="menu-iconic-icon" />         </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true" value="Date" /><label             class="menu-iconic-highlightable-text" crop="right" aria-hidden="true">Date</label></menuitem>         <menuitem label="Index" value="%k">         <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">             <image class="menu-iconic-icon" />         </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true" value="Index" /><label             class="menu-iconic-highlightable-text" crop="right" aria-hidden="true">Index</label></menuitem>         <menuitem label="Name (Sender/Recipient)" value="%n">         <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">             <image class="menu-iconic-icon" />         </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true"             value="Name (Sender/Recipient)" /><label class="menu-iconic-highlightable-text" crop="right"             aria-hidden="true">Name (Sender/Recipient)</label></menuitem>         <menuitem label="Name (Sender)" value="%a">         <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">             <image class="menu-iconic-icon" />         </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true" value="Name (Sender)" /><label             class="menu-iconic-highlightable-text" crop="right" aria-hidden="true">Name (Sender)</label></menuitem>         <menuitem label="Name (Recipient)" value="%r">         <hbox class="menu-iconic-left" align="center" pack="center" aria-hidden="true">             <image class="menu-iconic-icon" />         </hbox><label class="menu-iconic-text" flex="1" crop="right" aria-hidden="true"             value="Name (Recipient)" /><label class="menu-iconic-highlightable-text" crop="right"             aria-hidden="true">Name (Recipient)</label></menuitem>     </menupopup> </menulist>