[html5] r8717 - [e] (0) Reword the menu item builder to make more sense Affected topics: HTML

whatwg at whatwg.org whatwg at whatwg.org
Tue Aug 26 13:44:28 PDT 2014


Author: ianh
Date: 2014-08-26 13:44:24 -0700 (Tue, 26 Aug 2014)
New Revision: 8717

Modified:
   complete.html
   index
   source
Log:
[e] (0) Reword the menu item builder to make more sense
Affected topics: HTML

Modified: complete.html
===================================================================
--- complete.html	2014-08-26 18:59:17 UTC (rev 8716)
+++ complete.html	2014-08-26 20:44:24 UTC (rev 8717)
@@ -37278,7 +37278,7 @@
      active</a>, abort these steps.<li><p>Let <var>menu</var> be the element's <a href=#designated-pop-up-menu id=the-button-element:designated-pop-up-menu-2>designated pop-up menu</a>, if
      any. If there isn't one, then abort these steps.<li><p><a href=#concept-event-fire id=the-button-element:concept-event-fire>Fire</a> a <a href=#concept-events-trusted id=the-button-element:concept-events-trusted>trusted</a> event with the name <code id=the-button-element:event-show><a href=#event-show>show</a></code> at <var>menu</var>, using the <code id=the-button-element:relatedevent><a href=#relatedevent>RelatedEvent</a></code>
      interface, with the <code id=the-button-element:dom-relatedevent-relatedtarget><a href=#dom-relatedevent-relatedtarget>relatedTarget</a></code> attribute
-     initialised to the <code id=the-button-element:the-button-element-6><a href=#the-button-element>button</a></code> element. The event must be cancelable. <li><p>If the event is not canceled, then <a href=#construct-and-show-a-menu id=the-button-element:construct-and-show-a-menu>construct and
+     initialised to the <code id=the-button-element:the-button-element-6><a href=#the-button-element>button</a></code> element. The event must be cancelable. <li><p>If the event is not canceled, then <a href=#build-and-show-a-menu id=the-button-element:build-and-show-a-menu>build and
      show</a> the menu for <var>menu</var>, with the <code id=the-button-element:the-button-element-7><a href=#the-button-element>button</a></code> element as the
      subject.</ol>
 
@@ -42830,50 +42830,54 @@
 
   <hr>
 
-  <p>A pop-up menu consists of a list of zero or more menu items, which can be any of:</p>
+  <p>A <dfn id=menu-construct>menu construct</dfn> consists of an ordered list of zero or more <dfn id=menu-item-construct>menu item constructs</dfn>, which can be any of:</p>
 
-  <ul class=brief><li><a href=#concept-command id=the-menu-element:concept-command>Commands</a>, which can be marked as default commands (<code id=the-menu-element:the-menuitem-element-2><a href=#the-menuitem-element>menuitem</a></code>)<li>Separators (<code id=the-menu-element:the-hr-element-2><a href=#the-hr-element>hr</a></code>)<li>Other menus, which allows the list to be nested (<code id=the-menu-element:the-menu-element-10><a href=#the-menu-element>menu</a></code>)</ul>
+  <ul class=brief><li><a href=#concept-command id=the-menu-element:concept-command>Commands</a>, which can be marked as <dfn id=default-command>default commands</dfn> (<code id=the-menu-element:the-menuitem-element-2><a href=#the-menuitem-element>menuitem</a></code>)<li><dfn id=concept-separator>Separators</dfn> (<code id=the-menu-element:the-hr-element-2><a href=#the-hr-element>hr</a></code>)<li>Other <a href=#menu-construct id=the-menu-element:menu-construct>menu constructs</a>, each with an associated <dfn id=submenu-label>submenu label</dfn>, which allows the list to be nested (<code id=the-menu-element:the-menu-element-10><a href=#the-menu-element>menu</a></code>)</ul>
 
-  <p>To <dfn id=construct-and-show-a-menu>construct and show a menu</dfn> for a particular <code id=the-menu-element:the-menu-element-11><a href=#the-menu-element>menu</a></code> element and with a
-  particular element as a subject, the user agent must run the following steps:</p>
+  <p>To <dfn id=build-and-show-a-menu>build and show a menu</dfn> for a particular <code id=the-menu-element:the-menu-element-11><a href=#the-menu-element>menu</a></code> element
+  <var>source</var> and with a particular element <var>subject</var> as a subject, the user agent
+  must run the following steps:</p>
 
-  <ol><li><p>Let the menu be an empty list of the type described above.<li>
+  <ol><li><p>Let <var>pop-up menu</var> be the <a href=#menu-construct id=the-menu-element:menu-construct-2>menu construct</a> created by the <a href=#build-a-menu-construct id=the-menu-element:build-a-menu-construct>build a
+   menu construct</a> algorithm when passed the <var>source</var> element.</p>
 
-    <p>Run the <a href=#menu-builder id=the-menu-element:menu-builder>menu builder</a> steps for the <code id=the-menu-element:the-menu-element-12><a href=#the-menu-element>menu</a></code> element using the menu
-    prepared in the previous list as the output.</p>
+   <li>
 
-    <p>The <dfn id=menu-builder>menu builder</dfn> steps for a <code id=the-menu-element:the-menu-element-13><a href=#the-menu-element>menu</a></code> element using a specific menu as
-    output are as follows: For each child node of the <code id=the-menu-element:the-menu-element-14><a href=#the-menu-element>menu</a></code> in <a href=#tree-order id=the-menu-element:tree-order>tree order</a>,
-    run the appropriate steps from the following list:</p>
+    <p>Display <var>pop-up menu</var> to the user, and let the algorithm that invoked this one continue.</p>
 
-    <dl class=switch><dt>If the child is a <code id=the-menu-element:the-menuitem-element-3><a href=#the-menuitem-element>menuitem</a></code> element that <a href=#concept-command id=the-menu-element:concept-command-2>defines
-     a command</a><dd>Append the command to the menu, respecting its <a href=#concept-facet id=the-menu-element:concept-facet>facets</a>. If the <code id=the-menu-element:the-menuitem-element-4><a href=#the-menuitem-element>menuitem</a></code> element has a <code id=the-menu-element:attr-menuitem-default><a href=#attr-menuitem-default>default</a></code> attribute, mark the command as being a default
-     command.<dt>If the child is an <code id=the-menu-element:the-hr-element-3><a href=#the-hr-element>hr</a></code> element<dd>Append a separator to the menu.<dt>If the child is a <code id=the-menu-element:the-menu-element-15><a href=#the-menu-element>menu</a></code> element with no <code id=the-menu-element:attr-menu-label-4><a href=#attr-menu-label>label</a></code> attribute<dd>Append a separator to the menu, then run the <a href=#menu-builder id=the-menu-element:menu-builder-2>menu builder</a> steps using this
-     child <code id=the-menu-element:the-menu-element-16><a href=#the-menu-element>menu</a></code> element for the same menu, then append another separator to the
-     menu.<dt>If the child is a <code id=the-menu-element:the-menu-element-17><a href=#the-menu-element>menu</a></code> element with a <code id=the-menu-element:attr-menu-label-5><a href=#attr-menu-label>label</a></code> attribute<dd>Create a new submenu as an empty list of the type described above, and construct it by
-     running the <a href=#menu-builder id=the-menu-element:menu-builder-3>menu builder</a> steps for the child <code id=the-menu-element:the-menu-element-18><a href=#the-menu-element>menu</a></code> element using the
-     new submenu as the output. Then, append the submenu to the menu, using the value of the child
-     <code id=the-menu-element:the-menu-element-19><a href=#the-menu-element>menu</a></code> element's <code id=the-menu-element:attr-menu-label-6><a href=#attr-menu-label>label</a></code> attribute as the label
-     of the submenu.<dt>Otherwise<dd><a href=#ignore id=the-menu-element:ignore>Ignore</a> the child node.</dl>
-
-   <li><p>Remove any submenu with no label, or whose label is the empty string, in the menu or any
-   submenus.<li><p>Remove any menu item with no label, or whose label is the empty string, in the menu or any
-   submenus.<li><p>Collapse all sequences of two or more adjacent separators in the menu or any submenus to a
-   single separator.<li><p>Remove all separators at the start or end of the menu and any submenus.<li>
-
-    <p>Display the menu to the user, and let the algorithm that invoked this one continue.</p>
-
-    <p>If the user selects a menu item that corresponds to an element that still represents a <a href=#concept-command id=the-menu-element:concept-command-3>command</a> when the user selects it, then the UA must invoke that
+    <p>If the user selects a <a href=#menu-item-construct id=the-menu-element:menu-item-construct>menu item construct</a> that corresponds to an element that still represents a <a href=#concept-command id=the-menu-element:concept-command-2>command</a> when the user selects it, then the UA must invoke that
     command's <a href=#command-facet-action id=the-menu-element:command-facet-action>Action</a>. If the command's <a href=#command-facet-action id=the-menu-element:command-facet-action-2>Action</a> is defined as <a href=#fire-a-click-event id=the-menu-element:fire-a-click-event>firing
     a <code>click</code> event</a>, either directly or via the <a href=#run-synthetic-click-activation-steps id=the-menu-element:run-synthetic-click-activation-steps>run
-    synthetic click activation steps</a> algorithm, then the <code id=the-menu-element:dom-mouseevent-relatedtarget><a href=#dom-mouseevent-relatedtarget>relatedTarget</a></code> attribute of that <code id=the-menu-element:event-click><a href=#event-click>click</a></code> event must be initialised to the subject passed to this
-    <a href=#construct-and-show-a-menu id=the-menu-element:construct-and-show-a-menu>construct and show a menu</a> algorithm.</p>
+    synthetic click activation steps</a> algorithm, then the <code id=the-menu-element:dom-mouseevent-relatedtarget><a href=#dom-mouseevent-relatedtarget>relatedTarget</a></code> attribute of that <code id=the-menu-element:event-click><a href=#event-click>click</a></code> event must be initialised to <var>subject</var>.</p>
 
     <p>Pop-up menus must not, while being shown, reflect changes in the DOM. The menu is constructed
     from the DOM before being shown, and is then immutable.</p>
 
    </ol>
 
+  <p>To <dfn id=build-a-menu-construct>build a menu construct</dfn> for an element <var>source</var>, the user agent must run
+  the following steps, which return a <a href=#menu-construct id=the-menu-element:menu-construct-3>menu construct</a>:</p>
+
+  <ol><li><p>Let <var>generated menu</var> be an empty <a href=#menu-construct id=the-menu-element:menu-construct-4>menu construct</a>.<li>
+
+    <p>Run the <a href=#menu-item-generator id=the-menu-element:menu-item-generator>menu item generator</a> steps for the <code id=the-menu-element:the-menu-element-12><a href=#the-menu-element>menu</a></code> element using <var>generated menu</var>
+    as the output.</p>
+
+    <p>The <dfn id=menu-item-generator>menu item generator</dfn> steps for a <code id=the-menu-element:the-menu-element-13><a href=#the-menu-element>menu</a></code> element using a specific <a href=#menu-construct id=the-menu-element:menu-construct-5>menu construct</a> <var>output</var> as
+    output are as follows: For each child node of the <code id=the-menu-element:the-menu-element-14><a href=#the-menu-element>menu</a></code> in <a href=#tree-order id=the-menu-element:tree-order>tree order</a>,
+    run the appropriate steps from the following list:</p>
+
+    <dl class=switch><dt>If the child is a <code id=the-menu-element:the-menuitem-element-3><a href=#the-menuitem-element>menuitem</a></code> element that <a href=#concept-command id=the-menu-element:concept-command-3>defines
+     a command</a><dd>Append the <a href=#concept-command id=the-menu-element:concept-command-4>command</a> to <var>output</var>, respecting the command's <a href=#concept-facet id=the-menu-element:concept-facet>facets</a>. If the <code id=the-menu-element:the-menuitem-element-4><a href=#the-menuitem-element>menuitem</a></code> element has a <code id=the-menu-element:attr-menuitem-default><a href=#attr-menuitem-default>default</a></code> attribute, mark the <span>command</span> as being a <a href=#default-command id=the-menu-element:default-command>default
+     command</a>.<dt>If the child is an <code id=the-menu-element:the-hr-element-3><a href=#the-hr-element>hr</a></code> element<dd>Append a <a href=#concept-separator id=the-menu-element:concept-separator>separator</a> to <var>output</var>.<dt>If the child is a <code id=the-menu-element:the-menu-element-15><a href=#the-menu-element>menu</a></code> element with no <code id=the-menu-element:attr-menu-label-4><a href=#attr-menu-label>label</a></code> attribute<dd>Append a <a href=#concept-separator id=the-menu-element:concept-separator-2>separator</a> to <var>output</var>, then run
+     the <a href=#menu-item-generator id=the-menu-element:menu-item-generator-2>menu item generator</a> steps for this child <code id=the-menu-element:the-menu-element-16><a href=#the-menu-element>menu</a></code> element, using
+     <var>output</var> as the output, then append another <a href=#concept-separator id=the-menu-element:concept-separator-3>separator</a> to <var>output</var>.<dt>If the child is a <code id=the-menu-element:the-menu-element-17><a href=#the-menu-element>menu</a></code> element with a <code id=the-menu-element:attr-menu-label-5><a href=#attr-menu-label>label</a></code> attribute<dd>Let <var>submenu</var> be the result of running the <a href=#build-a-menu-construct id=the-menu-element:build-a-menu-construct-2>build a menu construct</a> steps for the child <code id=the-menu-element:the-menu-element-18><a href=#the-menu-element>menu</a></code> element. Then, append <var>submenu</var> to <var>output</var>, using the value of the child
+     <code id=the-menu-element:the-menu-element-19><a href=#the-menu-element>menu</a></code> element's <code id=the-menu-element:attr-menu-label-6><a href=#attr-menu-label>label</a></code> attribute as the <a href=#submenu-label id=the-menu-element:submenu-label>submenu label</a>.<dt>Otherwise<dd><a href=#ignore id=the-menu-element:ignore>Ignore</a> the child node.</dl>
+
+   <li><p>Remove from <var>output</var> any <a href=#menu-construct id=the-menu-element:menu-construct-6>menu construct</a> whose <a href=#submenu-label id=the-menu-element:submenu-label-2>submenu
+   label</a> is the empty string.<li><p>Remove from <var>output</var> any <a href=#menu-item-construct id=the-menu-element:menu-item-construct-2>menu item construct</a> representing a <a href=#concept-command id=the-menu-element:concept-command-5>command</a> whose <a href=#command-facet-label id=the-menu-element:command-facet-label>Label</a> is
+   the empty string.<li><p>Collapse all sequences of two or more adjacent <a href=#concept-separator id=the-menu-element:concept-separator-4>separators</a> in <var>output</var> to a single <a href=#concept-separator id=the-menu-element:concept-separator-5>separator</a>.<li><p>If the first <a href=#menu-item-construct id=the-menu-element:menu-item-construct-3>menu item construct</a> in <var>output</var> is a <a href=#concept-separator id=the-menu-element:concept-separator-6>separator</a>, then remove it.<li><p>If the last <a href=#menu-item-construct id=the-menu-element:menu-item-construct-4>menu item construct</a> in <var>output</var> is a <a href=#concept-separator id=the-menu-element:concept-separator-7>separator</a>, then remove it.<li><p>Return <var>output</var>.</ol>
+
   <hr>
 
   <p>The <dfn id=dom-menu-type><code>type</code></dfn> IDL attribute must <a href=#reflect id=the-menu-element:reflect>reflect</a>
@@ -43197,7 +43201,7 @@
   to <var>subject</var>. The event must be cancelable. </p>
 
   <p>If <em>this</em> event (the <code id=processing-model-5:event-show-2><a href=#event-show>show</a></code> event) is not canceled, then
-  the user agent must <a href=#construct-and-show-a-menu id=processing-model-5:construct-and-show-a-menu>construct and show</a> the menu for
+  the user agent must <a href=#build-and-show-a-menu id=processing-model-5:build-and-show-a-menu>build and show</a> the menu for
   <var>menu</var> with <var>subject</var> as the subject.</p>
 
   <p>The user agent may also provide access to its default context menu, if any, with the context

Modified: index
===================================================================
--- index	2014-08-26 18:59:17 UTC (rev 8716)
+++ index	2014-08-26 20:44:24 UTC (rev 8717)
@@ -37278,7 +37278,7 @@
      active</a>, abort these steps.<li><p>Let <var>menu</var> be the element's <a href=#designated-pop-up-menu id=the-button-element:designated-pop-up-menu-2>designated pop-up menu</a>, if
      any. If there isn't one, then abort these steps.<li><p><a href=#concept-event-fire id=the-button-element:concept-event-fire>Fire</a> a <a href=#concept-events-trusted id=the-button-element:concept-events-trusted>trusted</a> event with the name <code id=the-button-element:event-show><a href=#event-show>show</a></code> at <var>menu</var>, using the <code id=the-button-element:relatedevent><a href=#relatedevent>RelatedEvent</a></code>
      interface, with the <code id=the-button-element:dom-relatedevent-relatedtarget><a href=#dom-relatedevent-relatedtarget>relatedTarget</a></code> attribute
-     initialised to the <code id=the-button-element:the-button-element-6><a href=#the-button-element>button</a></code> element. The event must be cancelable. <li><p>If the event is not canceled, then <a href=#construct-and-show-a-menu id=the-button-element:construct-and-show-a-menu>construct and
+     initialised to the <code id=the-button-element:the-button-element-6><a href=#the-button-element>button</a></code> element. The event must be cancelable. <li><p>If the event is not canceled, then <a href=#build-and-show-a-menu id=the-button-element:build-and-show-a-menu>build and
      show</a> the menu for <var>menu</var>, with the <code id=the-button-element:the-button-element-7><a href=#the-button-element>button</a></code> element as the
      subject.</ol>
 
@@ -42830,50 +42830,54 @@
 
   <hr>
 
-  <p>A pop-up menu consists of a list of zero or more menu items, which can be any of:</p>
+  <p>A <dfn id=menu-construct>menu construct</dfn> consists of an ordered list of zero or more <dfn id=menu-item-construct>menu item constructs</dfn>, which can be any of:</p>
 
-  <ul class=brief><li><a href=#concept-command id=the-menu-element:concept-command>Commands</a>, which can be marked as default commands (<code id=the-menu-element:the-menuitem-element-2><a href=#the-menuitem-element>menuitem</a></code>)<li>Separators (<code id=the-menu-element:the-hr-element-2><a href=#the-hr-element>hr</a></code>)<li>Other menus, which allows the list to be nested (<code id=the-menu-element:the-menu-element-10><a href=#the-menu-element>menu</a></code>)</ul>
+  <ul class=brief><li><a href=#concept-command id=the-menu-element:concept-command>Commands</a>, which can be marked as <dfn id=default-command>default commands</dfn> (<code id=the-menu-element:the-menuitem-element-2><a href=#the-menuitem-element>menuitem</a></code>)<li><dfn id=concept-separator>Separators</dfn> (<code id=the-menu-element:the-hr-element-2><a href=#the-hr-element>hr</a></code>)<li>Other <a href=#menu-construct id=the-menu-element:menu-construct>menu constructs</a>, each with an associated <dfn id=submenu-label>submenu label</dfn>, which allows the list to be nested (<code id=the-menu-element:the-menu-element-10><a href=#the-menu-element>menu</a></code>)</ul>
 
-  <p>To <dfn id=construct-and-show-a-menu>construct and show a menu</dfn> for a particular <code id=the-menu-element:the-menu-element-11><a href=#the-menu-element>menu</a></code> element and with a
-  particular element as a subject, the user agent must run the following steps:</p>
+  <p>To <dfn id=build-and-show-a-menu>build and show a menu</dfn> for a particular <code id=the-menu-element:the-menu-element-11><a href=#the-menu-element>menu</a></code> element
+  <var>source</var> and with a particular element <var>subject</var> as a subject, the user agent
+  must run the following steps:</p>
 
-  <ol><li><p>Let the menu be an empty list of the type described above.<li>
+  <ol><li><p>Let <var>pop-up menu</var> be the <a href=#menu-construct id=the-menu-element:menu-construct-2>menu construct</a> created by the <a href=#build-a-menu-construct id=the-menu-element:build-a-menu-construct>build a
+   menu construct</a> algorithm when passed the <var>source</var> element.</p>
 
-    <p>Run the <a href=#menu-builder id=the-menu-element:menu-builder>menu builder</a> steps for the <code id=the-menu-element:the-menu-element-12><a href=#the-menu-element>menu</a></code> element using the menu
-    prepared in the previous list as the output.</p>
+   <li>
 
-    <p>The <dfn id=menu-builder>menu builder</dfn> steps for a <code id=the-menu-element:the-menu-element-13><a href=#the-menu-element>menu</a></code> element using a specific menu as
-    output are as follows: For each child node of the <code id=the-menu-element:the-menu-element-14><a href=#the-menu-element>menu</a></code> in <a href=#tree-order id=the-menu-element:tree-order>tree order</a>,
-    run the appropriate steps from the following list:</p>
+    <p>Display <var>pop-up menu</var> to the user, and let the algorithm that invoked this one continue.</p>
 
-    <dl class=switch><dt>If the child is a <code id=the-menu-element:the-menuitem-element-3><a href=#the-menuitem-element>menuitem</a></code> element that <a href=#concept-command id=the-menu-element:concept-command-2>defines
-     a command</a><dd>Append the command to the menu, respecting its <a href=#concept-facet id=the-menu-element:concept-facet>facets</a>. If the <code id=the-menu-element:the-menuitem-element-4><a href=#the-menuitem-element>menuitem</a></code> element has a <code id=the-menu-element:attr-menuitem-default><a href=#attr-menuitem-default>default</a></code> attribute, mark the command as being a default
-     command.<dt>If the child is an <code id=the-menu-element:the-hr-element-3><a href=#the-hr-element>hr</a></code> element<dd>Append a separator to the menu.<dt>If the child is a <code id=the-menu-element:the-menu-element-15><a href=#the-menu-element>menu</a></code> element with no <code id=the-menu-element:attr-menu-label-4><a href=#attr-menu-label>label</a></code> attribute<dd>Append a separator to the menu, then run the <a href=#menu-builder id=the-menu-element:menu-builder-2>menu builder</a> steps using this
-     child <code id=the-menu-element:the-menu-element-16><a href=#the-menu-element>menu</a></code> element for the same menu, then append another separator to the
-     menu.<dt>If the child is a <code id=the-menu-element:the-menu-element-17><a href=#the-menu-element>menu</a></code> element with a <code id=the-menu-element:attr-menu-label-5><a href=#attr-menu-label>label</a></code> attribute<dd>Create a new submenu as an empty list of the type described above, and construct it by
-     running the <a href=#menu-builder id=the-menu-element:menu-builder-3>menu builder</a> steps for the child <code id=the-menu-element:the-menu-element-18><a href=#the-menu-element>menu</a></code> element using the
-     new submenu as the output. Then, append the submenu to the menu, using the value of the child
-     <code id=the-menu-element:the-menu-element-19><a href=#the-menu-element>menu</a></code> element's <code id=the-menu-element:attr-menu-label-6><a href=#attr-menu-label>label</a></code> attribute as the label
-     of the submenu.<dt>Otherwise<dd><a href=#ignore id=the-menu-element:ignore>Ignore</a> the child node.</dl>
-
-   <li><p>Remove any submenu with no label, or whose label is the empty string, in the menu or any
-   submenus.<li><p>Remove any menu item with no label, or whose label is the empty string, in the menu or any
-   submenus.<li><p>Collapse all sequences of two or more adjacent separators in the menu or any submenus to a
-   single separator.<li><p>Remove all separators at the start or end of the menu and any submenus.<li>
-
-    <p>Display the menu to the user, and let the algorithm that invoked this one continue.</p>
-
-    <p>If the user selects a menu item that corresponds to an element that still represents a <a href=#concept-command id=the-menu-element:concept-command-3>command</a> when the user selects it, then the UA must invoke that
+    <p>If the user selects a <a href=#menu-item-construct id=the-menu-element:menu-item-construct>menu item construct</a> that corresponds to an element that still represents a <a href=#concept-command id=the-menu-element:concept-command-2>command</a> when the user selects it, then the UA must invoke that
     command's <a href=#command-facet-action id=the-menu-element:command-facet-action>Action</a>. If the command's <a href=#command-facet-action id=the-menu-element:command-facet-action-2>Action</a> is defined as <a href=#fire-a-click-event id=the-menu-element:fire-a-click-event>firing
     a <code>click</code> event</a>, either directly or via the <a href=#run-synthetic-click-activation-steps id=the-menu-element:run-synthetic-click-activation-steps>run
-    synthetic click activation steps</a> algorithm, then the <code id=the-menu-element:dom-mouseevent-relatedtarget><a href=#dom-mouseevent-relatedtarget>relatedTarget</a></code> attribute of that <code id=the-menu-element:event-click><a href=#event-click>click</a></code> event must be initialised to the subject passed to this
-    <a href=#construct-and-show-a-menu id=the-menu-element:construct-and-show-a-menu>construct and show a menu</a> algorithm.</p>
+    synthetic click activation steps</a> algorithm, then the <code id=the-menu-element:dom-mouseevent-relatedtarget><a href=#dom-mouseevent-relatedtarget>relatedTarget</a></code> attribute of that <code id=the-menu-element:event-click><a href=#event-click>click</a></code> event must be initialised to <var>subject</var>.</p>
 
     <p>Pop-up menus must not, while being shown, reflect changes in the DOM. The menu is constructed
     from the DOM before being shown, and is then immutable.</p>
 
    </ol>
 
+  <p>To <dfn id=build-a-menu-construct>build a menu construct</dfn> for an element <var>source</var>, the user agent must run
+  the following steps, which return a <a href=#menu-construct id=the-menu-element:menu-construct-3>menu construct</a>:</p>
+
+  <ol><li><p>Let <var>generated menu</var> be an empty <a href=#menu-construct id=the-menu-element:menu-construct-4>menu construct</a>.<li>
+
+    <p>Run the <a href=#menu-item-generator id=the-menu-element:menu-item-generator>menu item generator</a> steps for the <code id=the-menu-element:the-menu-element-12><a href=#the-menu-element>menu</a></code> element using <var>generated menu</var>
+    as the output.</p>
+
+    <p>The <dfn id=menu-item-generator>menu item generator</dfn> steps for a <code id=the-menu-element:the-menu-element-13><a href=#the-menu-element>menu</a></code> element using a specific <a href=#menu-construct id=the-menu-element:menu-construct-5>menu construct</a> <var>output</var> as
+    output are as follows: For each child node of the <code id=the-menu-element:the-menu-element-14><a href=#the-menu-element>menu</a></code> in <a href=#tree-order id=the-menu-element:tree-order>tree order</a>,
+    run the appropriate steps from the following list:</p>
+
+    <dl class=switch><dt>If the child is a <code id=the-menu-element:the-menuitem-element-3><a href=#the-menuitem-element>menuitem</a></code> element that <a href=#concept-command id=the-menu-element:concept-command-3>defines
+     a command</a><dd>Append the <a href=#concept-command id=the-menu-element:concept-command-4>command</a> to <var>output</var>, respecting the command's <a href=#concept-facet id=the-menu-element:concept-facet>facets</a>. If the <code id=the-menu-element:the-menuitem-element-4><a href=#the-menuitem-element>menuitem</a></code> element has a <code id=the-menu-element:attr-menuitem-default><a href=#attr-menuitem-default>default</a></code> attribute, mark the <span>command</span> as being a <a href=#default-command id=the-menu-element:default-command>default
+     command</a>.<dt>If the child is an <code id=the-menu-element:the-hr-element-3><a href=#the-hr-element>hr</a></code> element<dd>Append a <a href=#concept-separator id=the-menu-element:concept-separator>separator</a> to <var>output</var>.<dt>If the child is a <code id=the-menu-element:the-menu-element-15><a href=#the-menu-element>menu</a></code> element with no <code id=the-menu-element:attr-menu-label-4><a href=#attr-menu-label>label</a></code> attribute<dd>Append a <a href=#concept-separator id=the-menu-element:concept-separator-2>separator</a> to <var>output</var>, then run
+     the <a href=#menu-item-generator id=the-menu-element:menu-item-generator-2>menu item generator</a> steps for this child <code id=the-menu-element:the-menu-element-16><a href=#the-menu-element>menu</a></code> element, using
+     <var>output</var> as the output, then append another <a href=#concept-separator id=the-menu-element:concept-separator-3>separator</a> to <var>output</var>.<dt>If the child is a <code id=the-menu-element:the-menu-element-17><a href=#the-menu-element>menu</a></code> element with a <code id=the-menu-element:attr-menu-label-5><a href=#attr-menu-label>label</a></code> attribute<dd>Let <var>submenu</var> be the result of running the <a href=#build-a-menu-construct id=the-menu-element:build-a-menu-construct-2>build a menu construct</a> steps for the child <code id=the-menu-element:the-menu-element-18><a href=#the-menu-element>menu</a></code> element. Then, append <var>submenu</var> to <var>output</var>, using the value of the child
+     <code id=the-menu-element:the-menu-element-19><a href=#the-menu-element>menu</a></code> element's <code id=the-menu-element:attr-menu-label-6><a href=#attr-menu-label>label</a></code> attribute as the <a href=#submenu-label id=the-menu-element:submenu-label>submenu label</a>.<dt>Otherwise<dd><a href=#ignore id=the-menu-element:ignore>Ignore</a> the child node.</dl>
+
+   <li><p>Remove from <var>output</var> any <a href=#menu-construct id=the-menu-element:menu-construct-6>menu construct</a> whose <a href=#submenu-label id=the-menu-element:submenu-label-2>submenu
+   label</a> is the empty string.<li><p>Remove from <var>output</var> any <a href=#menu-item-construct id=the-menu-element:menu-item-construct-2>menu item construct</a> representing a <a href=#concept-command id=the-menu-element:concept-command-5>command</a> whose <a href=#command-facet-label id=the-menu-element:command-facet-label>Label</a> is
+   the empty string.<li><p>Collapse all sequences of two or more adjacent <a href=#concept-separator id=the-menu-element:concept-separator-4>separators</a> in <var>output</var> to a single <a href=#concept-separator id=the-menu-element:concept-separator-5>separator</a>.<li><p>If the first <a href=#menu-item-construct id=the-menu-element:menu-item-construct-3>menu item construct</a> in <var>output</var> is a <a href=#concept-separator id=the-menu-element:concept-separator-6>separator</a>, then remove it.<li><p>If the last <a href=#menu-item-construct id=the-menu-element:menu-item-construct-4>menu item construct</a> in <var>output</var> is a <a href=#concept-separator id=the-menu-element:concept-separator-7>separator</a>, then remove it.<li><p>Return <var>output</var>.</ol>
+
   <hr>
 
   <p>The <dfn id=dom-menu-type><code>type</code></dfn> IDL attribute must <a href=#reflect id=the-menu-element:reflect>reflect</a>
@@ -43197,7 +43201,7 @@
   to <var>subject</var>. The event must be cancelable. </p>
 
   <p>If <em>this</em> event (the <code id=processing-model-5:event-show-2><a href=#event-show>show</a></code> event) is not canceled, then
-  the user agent must <a href=#construct-and-show-a-menu id=processing-model-5:construct-and-show-a-menu>construct and show</a> the menu for
+  the user agent must <a href=#build-and-show-a-menu id=processing-model-5:build-and-show-a-menu>build and show</a> the menu for
   <var>menu</var> with <var>subject</var> as the subject.</p>
 
   <p>The user agent may also provide access to its default context menu, if any, with the context

Modified: source
===================================================================
--- source	2014-08-26 18:59:17 UTC (rev 8716)
+++ source	2014-08-26 20:44:24 UTC (rev 8717)
@@ -47892,7 +47892,7 @@
      initialised to the <code>button</code> element. The event must be cancelable. <!-- v2: include
      modifier key information --></p></li>
 
-     <li><p>If the event is not canceled, then <span data-x="construct and show a menu">construct and
+     <li><p>If the event is not canceled, then <span data-x="build and show a menu">build and
      show</span> the menu for <var>menu</var>, with the <code>button</code> element as the
      subject.</p></li>
 
@@ -55508,27 +55508,56 @@
 
   <hr>
 
-  <p>A pop-up menu consists of a list of zero or more menu items, which can be any of:</p>
+  <p>A <dfn>menu construct</dfn> consists of an ordered list of zero or more <dfn data-x="menu item construct">menu item constructs</dfn>, which can be any of:</p>
 
   <ul class="brief">
-   <li><span data-x="concept-command">Commands</span>, which can be marked as default commands (<code>menuitem</code>)</li>
-   <li>Separators (<code>hr</code>)</li>
-   <li>Other menus, which allows the list to be nested (<code>menu</code>)</li>
+   <li><span data-x="concept-command">Commands</span>, which can be marked as <dfn data-x="default command">default commands</dfn> (<code>menuitem</code>)</li>
+   <li><dfn data-x="concept-separator">Separators</dfn> (<code>hr</code>)</li>
+   <li>Other <span data-x="menu construct">menu constructs</span>, each with an associated <dfn>submenu label</dfn>, which allows the list to be nested (<code>menu</code>)</li>
   </ul>
 
-  <p>To <dfn>construct and show a menu</dfn> for a particular <code>menu</code> element and with a
-  particular element as a subject, the user agent must run the following steps:</p>
+  <p>To <dfn>build and show a menu</dfn> for a particular <code>menu</code> element
+  <var>source</var> and with a particular element <var>subject</var> as a subject, the user agent
+  must run the following steps:</p>
 
   <ol>
 
-   <li><p>Let the menu be an empty list of the type described above.</p></li>
+   <li><p>Let <var>pop-up menu</var> be the <span>menu construct</span> created by the <span>build a
+   menu construct</span> algorithm when passed the <var>source</var> element.</p>
 
    <li>
 
-    <p>Run the <span>menu builder</span> steps for the <code>menu</code> element using the menu
-    prepared in the previous list as the output.</p>
+    <p>Display <var>pop-up menu</var> to the user, and let the algorithm that invoked this one continue.</p>
 
-    <p>The <dfn>menu builder</dfn> steps for a <code>menu</code> element using a specific menu as
+    <p>If the user selects a <span>menu item construct</span> that corresponds to an element that still represents a <span
+    data-x="concept-command">command</span> when the user selects it, then the UA must invoke that
+    command's <span data-x="command-facet-Action">Action</span>. If the command's <span
+    data-x="command-facet-Action">Action</span> is defined as <span data-x="fire a click event">firing
+    a <code data-x="event-click">click</code> event</span>, either directly or via the <span>run
+    synthetic click activation steps</span> algorithm, then the <code
+    data-x="dom-MouseEvent-relatedTarget">relatedTarget</code> attribute of that <code
+    data-x="event-click">click</code> event must be initialised to <var>subject</var>.</p>
+
+    <p>Pop-up menus must not, while being shown, reflect changes in the DOM. The menu is constructed
+    from the DOM before being shown, and is then immutable.</p>
+
+   </li>
+
+  </ol>
+
+  <p>To <dfn>build a menu construct</dfn> for an element <var>source</var>, the user agent must run
+  the following steps, which return a <span>menu construct</span>:</p>
+
+  <ol>
+
+   <li><p>Let <var>generated menu</var> be an empty <span>menu construct</span>.</p></li>
+
+   <li>
+
+    <p>Run the <span>menu item generator</span> steps for the <code>menu</code> element using <var>generated menu</var>
+    as the output.</p>
+
+    <p>The <dfn>menu item generator</dfn> steps for a <code>menu</code> element using a specific <span>menu construct</span> <var>output</var> as
     output are as follows: For each child node of the <code>menu</code> in <span>tree order</span>,
     run the appropriate steps from the following list:</p>
 
@@ -55537,7 +55566,7 @@
      <dt>If the child is a <code>menuitem</code> element that <span data-x="concept-command">defines
      a command</span></dt>
 
-     <dd>Append the command to the menu, respecting its <span
+     <dd>Append the <span data-x="concept-command">command</span> to <var>output</var>, respecting the command's <span
      data-x="concept-facet">facets</span><!-- we might need to be explicit about what this means for
      each facet, if testing shows this isn't well-implemented. e.g.: If there's an Icon facet for
      the command, it should be <span data-x="fetch">fetched</span><!- -FETCH- -> (this would be
@@ -55545,29 +55574,27 @@
      that each command only has its image fetched once, to prevent changes to the base URL from
      having effects after the image has been fetched once. (no need to resolve the Icon facet, it's
      an absolute URL) -->. If the <code>menuitem</code> element has a <code
-     data-x="attr-menuitem-default">default</code> attribute, mark the command as being a default
-     command.</dd>
+     data-x="attr-menuitem-default">default</code> attribute, mark the <span>command</span> as being a <span>default
+     command</span>.</dd>
 
 
      <dt>If the child is an <code>hr</code> element</dt>
 
-     <dd>Append a separator to the menu.</dd>
+     <dd>Append a <span data-x="concept-separator">separator</span> to <var>output</var>.</dd>
 
 
      <dt>If the child is a <code>menu</code> element with no <code data-x="attr-menu-label">label</code> attribute</dt>
 
-     <dd>Append a separator to the menu, then run the <span>menu builder</span> steps using this
-     child <code>menu</code> element for the same menu, then append another separator to the
-     menu.</dd>
+     <dd>Append a <span data-x="concept-separator">separator</span> to <var>output</var>, then run
+     the <span>menu item generator</span> steps for this child <code>menu</code> element, using
+     <var>output</var> as the output, then append another <span
+     data-x="concept-separator">separator</span> to <var>output</var>.</dd>
 
 
      <dt>If the child is a <code>menu</code> element with a <code data-x="attr-menu-label">label</code> attribute</dt>
 
-     <dd>Create a new submenu as an empty list of the type described above, and construct it by
-     running the <span>menu builder</span> steps for the child <code>menu</code> element using the
-     new submenu as the output. Then, append the submenu to the menu, using the value of the child
-     <code>menu</code> element's <code data-x="attr-menu-label">label</code> attribute as the label
-     of the submenu.</dd>
+     <dd>Let <var>submenu</var> be the result of running the <span>build a menu construct</span> steps for the child <code>menu</code> element. Then, append <var>submenu</var> to <var>output</var>, using the value of the child
+     <code>menu</code> element's <code data-x="attr-menu-label">label</code> attribute as the <span>submenu label</span>.</dd>
 
 
      <dt>Otherwise</dt>
@@ -55578,36 +55605,25 @@
 
    </li>
 
-   <li><p>Remove any submenu with no label, or whose label is the empty string, in the menu or any
-   submenus.</p></li>
+   <li><p>Remove from <var>output</var> any <span>menu construct</span> whose <span>submenu
+   label</span> is the empty string.</p></li>
 
-   <li><p>Remove any menu item with no label, or whose label is the empty string, in the menu or any
-   submenus.</p></li>
+   <li><p>Remove from <var>output</var> any <span>menu item construct</span> representing a <span
+   data-x="concept-command">command</span> whose <span data-x="command-facet-label">Label</span> is
+   the empty string.</p></li>
 
-   <li><p>Collapse all sequences of two or more adjacent separators in the menu or any submenus to a
-   single separator.</p></li>
+   <li><p>Collapse all sequences of two or more adjacent <span
+   data-x="concept-separator">separators</span> in <var>output</var> to a single <span
+   data-x="concept-separator">separator</span>.</p></li>
 
-   <li><p>Remove all separators at the start or end of the menu and any submenus.</p></li>
+   <li><p>If the first <span>menu item construct</span> in <var>output</var> is a <span
+   data-x="concept-separator">separator</span>, then remove it.</p></li>
 
-   <li>
+   <li><p>If the last <span>menu item construct</span> in <var>output</var> is a <span
+   data-x="concept-separator">separator</span>, then remove it.</p></li>
 
-    <p>Display the menu to the user, and let the algorithm that invoked this one continue.</p>
+   <li><p>Return <var>output</var>.</p></li>
 
-    <p>If the user selects a menu item that corresponds to an element that still represents a <span
-    data-x="concept-command">command</span> when the user selects it, then the UA must invoke that
-    command's <span data-x="command-facet-Action">Action</span>. If the command's <span
-    data-x="command-facet-Action">Action</span> is defined as <span data-x="fire a click event">firing
-    a <code data-x="event-click">click</code> event</span>, either directly or via the <span>run
-    synthetic click activation steps</span> algorithm, then the <code
-    data-x="dom-MouseEvent-relatedTarget">relatedTarget</code> attribute of that <code
-    data-x="event-click">click</code> event must be initialised to the subject passed to this
-    <span>construct and show a menu</span> algorithm.</p>
-
-    <p>Pop-up menus must not, while being shown, reflect changes in the DOM. The menu is constructed
-    from the DOM before being shown, and is then immutable.</p>
-
-   </li>
-
   </ol>
 
   <hr>
@@ -56036,7 +56052,7 @@
   --></p>
 
   <p>If <em>this</em> event (the <code data-x="event-show">show</code> event) is not canceled, then
-  the user agent must <span data-x="construct and show a menu">construct and show</span> the menu for
+  the user agent must <span data-x="build and show a menu">build and show</span> the menu for
   <var>menu</var> with <var>subject</var> as the subject.</p>
 
   <p>The user agent may also provide access to its default context menu, if any, with the context



More information about the Commit-Watchers mailing list