diff --git a/source b/source index cd0d47cc723..4f6e8aa5968 100644 --- a/source +++ b/source @@ -2334,10 +2334,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute indices, is empty, item, - iterate, and + iterate, clone sort in ascending order - sort in descending order + sort in descending order + slice (and its + from and + to arguments), and + reverse
Let document be this's node document.
Let hideUntil be the result of running topmost popover ancestor - given this, document's showing hint popover list, null, and - false.
If hideUntil is null, then set hideUntil to the result of running - topmost popover ancestor given this, document's - showing auto popover list, null, and false.
If hideUntil is null, then set hideUntil to - document.
Run hide all popovers until given - hideUntil, false, and true.
Run hide popovers until given document, hideUntil, false, and true.
Run the dialog focusing steps given this.
Let document be subject's node document.
Let hideUntil be the result of running topmost popover ancestor - given subject, document's showing hint popover list, null, and - false.
If hideUntil is null, then set hideUntil to the result of running - topmost popover ancestor given subject, document's - showing auto popover list, null, and false.
If hideUntil is null, then set hideUntil to - document.
Run hide all popovers until given - hideUntil, false, and true.
Run hide popovers until given document, hideUntil, false, and true.
Run the dialog focusing steps given subject.
Every HTML element has a popover trigger, which is an HTML element or null, initially set to null.
-Every HTML element has a popover showing or - hiding, which is a boolean, initially set to false.
+Every HTML element has a popover hiding, which is a boolean, initially set to false.
Every HTML element popover toggle task tracker, which is a toggle task tracker or null, initially null.
@@ -91185,7 +91170,12 @@ dictionary DragEventInit : MouseEventInit { which is a close watcher or null, initially null.Every HTML element has an opened in popover - mode, which is a string or null, initially null.
+ mode, which is "auto", "hint", or null,
+ initially null.
+
+ Every Document has a hiding popover nesting count, which is a number, initially 0.
Every Document has a showing popover, which is a boolean, initially false.
The following attribute change @@ -91249,29 +91239,36 @@ dictionary DragEventInit : MouseEventInit { element or null source:
Let document be element's node document.
If document's showing popover is true, or document's hiding popover nesting count is not 0, then:
+ +If throwExceptions is true, then throw a "InvalidStateError"
+ DOMException.
Return.
This prevents showing a popover during the show or hide of another popover.
+Set document's showing popover to true.
If the result of running check popover validity given element, false, throwExceptions, and null is false, then return.
Let document be element's node document.
Assert: element's popover trigger is null.
Assert: element is not in document's top layer.
Let nestedShow be element's popover showing or - hiding.
Let fireEvents be the boolean negation of nestedShow.
Set element's popover showing or hiding to true.
Let cleanupShowingFlag be the following steps:
+Let cleanupShowingSteps be the following steps:
If nestedShow is false, then set element's popover showing - or hiding to false.
Set document's showing popover to false.
newState attribute
initialized to "open", and the source attribute initialized to source at
- element is false, then run cleanupShowingFlag and return.
+ element is false, then run cleanupShowingSteps and return.
If the result of running check popover validity given element, false, throwExceptions, and document is false, then run - cleanupShowingFlag and return.
+ cleanupShowingSteps and return.Check popover validity is called again because firing the beforetoggle event could have disconnected this element or
@@ -91299,85 +91296,35 @@ dictionary DragEventInit : MouseEventInit {
Let originalType be the current state of element's popover attribute.
Let stackToAppendTo be null.
Let autoAncestor be the result of running the topmost popover - ancestor algorithm given element, document's showing auto - popover list, source, and true.
Let ancestor be the result of running the topmost popover ancestor algorithm given element, source, and true.
Let hintAncestor be the result of running the topmost popover - ancestor algorithm given element, document's showing hint - popover list, source, and true.
Let effectiveType be originalType.
If originalType is the Auto state, - then:
+If all of the following are true:
-Run close entire popover list given document's showing - hint popover list, shouldRestoreFocus, and fireEvents.
ancestor is not null;
Let ancestor be the result of running the topmost popover - ancestor algorithm given element, document's showing auto - popover list, source, and true.
ancestor's opened in popover mode is "hint"; and
If ancestor is null, then set ancestor to - document.
effectiveType is the Auto state,
Run hide all popovers until given - ancestor, shouldRestoreFocus, and fireEvents.
then set effectiveType to the Hint state.
-Set stackToAppendTo to "auto".
Hint popovers are lower priority than Auto popovers, so an Auto popover cannot have a Hint popover as a 'parent'. To resolve this case, the effectiveType is 'downgraded' to Hint.
If originalType is the Hint state, - then:
- -If hintAncestor is not null, then:
+If effectiveType is the Auto or Hint state, then run hide popover stack until given document, ancestor, Hint, shouldRestoreFocus, and true.
Run hide all popovers until given - hintAncestor, shouldRestoreFocus, and fireEvents.
Set stackToAppendTo to "hint".
Otherwise:
- -Run close entire popover list given document's showing - hint popover list, shouldRestoreFocus, and fireEvents.
If autoAncestor is not null, then:
- -Run hide all popovers until given - autoAncestor, shouldRestoreFocus, and fireEvents.
Set stackToAppendTo to "auto".
Otherwise, set stackToAppendTo to "hint".
If effectiveType is the Auto state, then run hide popover stack until given document, ancestor, Auto, shouldRestoreFocus, and true.
If originalType is Auto or If effectiveType is Auto or Hint, then:
Assert: stackToAppendTo is not null.
If originalType is not equal to the value of element's popover attribute, then:
If the result of running check popover validity given element, false, throwExceptions, and document is false, then run - cleanupShowingFlag and return.
+ cleanupShowingSteps and return. -Check popover validity is called again because running hide all popovers until above could have fired the +
Check popover validity is called again because running hide popover stack until above could have fired the
beforetoggle event, and an event handler could have
disconnected this element or changed its popover
attribute.
If the result of running topmost auto or hint
+ If the result of running topmost auto or hint
popover on document is null, then set shouldRestoreFocus to
true.
If stackToAppendTo is "auto":
If effectiveType is Auto:
Assert: document's showing auto popover list does @@ -91425,8 +91371,7 @@ dictionary DragEventInit : MouseEventInit {
Otherwise:
Assert: stackToAppendTo is "hint".
Assert: effectiveType is Hint.
Assert: document's showing hint popover list does not contain element.
Add an element to the top layer given element.
If effectiveType is Hint and ancestor's opened in popover mode is "auto", then set document's hint stack parent to ancestor.
Set element's popover visibility state to showing.
Run cleanupShowingSteps.
Queue a popover toggle event task given element, "closed", "open", and source.
Run cleanupShowingFlag.
Let document be element's node document.
Let nestedHide be element's popover showing or - hiding.
Let nestedHide be element's popover hiding.
Set element's popover showing or hiding to true.
Set element's popover hiding to true.
If nestedHide is true, then set fireEvents to false.
Increment document's hiding popover nesting count.
Let cleanupSteps be the following steps:
If nestedHide is false, then set element's popover showing - or hiding to false.
If nestedHide is false, then set element's popover hiding to false.
If element's popover close watcher is not null, then:
@@ -91575,33 +91522,41 @@ dictionary DragEventInit : MouseEventInit {Set element's popover close watcher to null.
Decrement document's hiding popover nesting count.
Let autoPopoverListContainsElement be true if document's showing auto popover list contains element; otherwise false.
Let hintPopoverListContainsElement be true if document's showing hint popover list contains element; otherwise false.
If element's opened in popover mode is "auto"
or "hint", then:
Run hide all popovers until given - element, focusPreviousElement, and fireEvents.
If hintPopoverListContainsElement is true, then hide popover stack until given document, element, Hint, focusPreviousElement, and fireEvents.
If element is document's hint stack parent, then hide popover stack until given document, null, Hint, focusPreviousElement, and fireEvents.
+ +If the document's hint stack parent is to hide, then all hint popovers are hidden.
+If autoPopoverListContainsElement is true, then hide popover stack until given document, element, Auto, focusPreviousElement, and fireEvents.
If the result of running check popover validity given element, true, throwExceptions, and null is false, then run cleanupSteps and return.
-Check popover validity is called again because running hide all popovers until could have disconnected +
Check popover validity is called again because running hide popover stack until could have disconnected
element or changed its popover attribute.
Let autoPopoverListContainsElement be true if document's - showing auto popover list's last item is element, otherwise - false.
If fireEvents is true:
@@ -91614,11 +91569,6 @@ dictionary DragEventInit : MouseEventInit { data-x="dom-ToggleEvent-source">source attribute set to source at element.If autoPopoverListContainsElement is true and document's - showing auto popover list's last item is not element, then run hide all popovers until given element, - focusPreviousElement, and false.
If the result of running check popover validity given element, true, throwExceptions, and null is false, then run cleanupSteps and @@ -91646,6 +91596,8 @@ dictionary DragEventInit : MouseEventInit {
Set element's popover visibility state to hidden.
If element is document's hint stack parent, or document's showing hint popover list is empty, then set document's hint stack parent to null.
If fireEvents is true, then queue a popover toggle event task
given element, "open", "closed", and
source.
To hide all popovers until, given an HTML element or Document endpoint, a boolean
- focusPreviousElement, and a boolean fireEvents:
To hide popovers until, given a Document document, an HTML element or null endpoint, a boolean focusPreviousElement, and a boolean fireEvents:
If endpoint is an HTML element and - endpoint is not in the popover showing - state, then return.
Let endpointIsHint be true if document's showing hint popover list contains endpoint; otherwise false.
Let document be endpoint's node document.
Run hide popover stack until given document, endpoint, Hint, focusPreviousElement, and fireEvents.
Assert: endpoint is a Document or
- endpoint's popover visibility state is showing.
If endpointIsHint, then return.
Assert: endpoint is a Document or
- endpoint's popover attribute is in the Auto state or endpoint's popover attribute is in the Hint state.
If endpoint is a Document:
Run close entire popover list given document's showing - hint popover list, focusPreviousElement, and fireEvents.
Run close entire popover list given document's showing - auto popover list, focusPreviousElement, and fireEvents.
Return.
If document's showing hint popover list contains - endpoint:
- -Assert: endpoint's popover
- attribute is in the Hint state.
Run hide popover stack until given endpoint, - document's showing hint popover list, focusPreviousElement, - and fireEvents.
Return.
Run close entire popover list given document's showing hint - popover list, focusPreviousElement, and fireEvents.
If document's showing auto popover list does not contain - endpoint, then return.
Run hide popover stack until given endpoint, document's - showing auto popover list, focusPreviousElement, and - fireEvents.
Run hide popover stack until given document, endpoint, Auto, focusPreviousElement, and fireEvents.
To hide popover stack until, given an HTML - element endpoint, a list popoverList, a boolean - focusPreviousElement, and a boolean fireEvents:
+To hide popover stack until, given a Document document, an HTML element or null endpoint, an Auto or Hint stackType, a boolean focusPreviousElement, and a boolean fireEvents:
Let repeatingHide be false.
Perform the following steps at least once:
+Let popoverList be document's showing auto popover list if stackType is Auto; otherwise document's showing hint popover list.
Let lastToHide be null.
Let lastHideIndex be 0 if popoverList does not contain endpoint; otherwise the index of endpoint in popoverList plus 1.
For each popover in popoverList:
+Let toHide be a slice of popoverList from lastHideIndex, in reverse order.
If popover is endpoint, then break.
Let toRemain be a slice of popoverList from 0 to lastHideIndex.
Set lastToHide to popover.
For each popover of toHide: run the hide popover algorithm given popover, focusPreviousElement, fireEvents, false, and null.
If lastToHide is null, then return.
Let newPopoverList be document's showing auto popover list if stackType is Auto; otherwise document's showing hint popover list.
While lastToHide's popover visibility state is showing:
+Reverse newPopoverList.
Assert: popoverList is not empty.
Run the hide popover algorithm given the last item in - popoverList, focusPreviousElement, fireEvents, false, and - null.
For each popover in newPopoverList:
-Assert: repeatingHide is false or popoverList's last - item is endpoint.
If toRemain contains popover, then continue.
Set repeatingHide to true if popoverList contains - endpoint and popoverList's last item is not endpoint, - otherwise false.
Run the hide popover algorithm given popover, focusPreviousElement, false, false, and null.
-If repeatingHide is true, then set fireEvents to false.
This happens if popovers are shown whilst hiding popovers. For example, in beforetoggle events. This is usually a developer error, so user agents are encouraged to show a warning. In this additional hiding phase, fireEvents is ignored, and false is used instead.
and keep performing them while repeatingHide is true.
The hide all popovers until - algorithm is used in several cases to hide all popovers that don't stay open when something +
The hide popover stack until + algorithm is used in several cases to hide all popovers that don't stay open when something happens. For example, during light-dismiss of a popover, this algorithm ensures that we close only the popovers that aren't related to the node clicked by the user.
To find the topmost popover ancestor, given a Node
- newPopoverOrTopLayerElement, a list popoverList, an newPopoverOrTopLayerElement, an HTML element or null source, and a boolean
isPopover, perform the following steps. They return an HTML element or null.
The topmost popover ancestor algorithm will return the topmost (latest in the - showing auto popover list) ancestor popover for the provided popover or top layer +
The topmost popover ancestor algorithm will return the topmost ancestor popover for the provided popover or top layer element. Popovers can be related to each other in several ways, creating a tree of popovers. There are two paths through which one popover (call it the "child" popover) can have a topmost ancestor popover (call it the "parent" popover):
@@ -91856,18 +91737,18 @@ dictionary DragEventInit : MouseEventInit {The popovers are nested within each other in the node tree. In this case, the descendant popover is the "child" and its topmost ancestor popover is the "parent".
A popover trigger element (e.g., a button) has a popovertarget attribute pointing to a popover. In this case,
+
An element is the 'source' of the popover (e.g., a button with command in the Show Popover state). In this case,
the popover is the "child", and the popover subtree the trigger element is in is the
"parent". The trigger element has to be in a popover and reference an open popover.
In each of the relationships formed above, the parent popover has to be strictly earlier in - the showing auto popover list than the child popover, or it does not form a valid + the showing auto popover list or showing hint popover list than the child popover, or it does not form a valid ancestral relationship. This eliminates non-showing popovers and self-pointers (e.g., a popover containing an invoking element that points back to the containing popover), and it allows for the construction of a well-formed tree from the (possibly cyclic) graph of connections. Only Auto popovers are considered.
+ data-x="attr-popover-auto-state">Auto and Hint popovers are considered.If the provided element is a top layer element such as a dialog which is not
showing as a popover, then topmost popover ancestor will only look in the node tree
@@ -91901,81 +91782,21 @@ dictionary DragEventInit : MouseEventInit {
-
Let popoverPositions be an empty ordered map.
Let index be 0.
For each popover of popoverList:
- -Set popoverPositions[popover] to - index.
Increment index by 1.
If isPopover is true, then set - popoverPositions[newPopoverOrTopLayerElement] to index.
Let document be newPopoverOrTopLayerElement's node document.
Increment index by 1.
Let topmostPopoverAncestor be null.
Let checkAncestor be an algorithm which performs the following steps given - candidate:
- -If candidate is null, then return.
Let combinedPopovers be document's showing auto popover list extended with document's showing hint popover list.
Let okNesting be false.
Let candidateAncestor be null.
While okNesting is false:
- -Set candidateAncestor to the result of running nearest inclusive open - popover given candidate.
If candidateAncestor is null or popoverPositions does not - contain candidateAncestor, then return.
Assert: candidateAncestor's popover attribute is not in the Manual or None state.
Set okNesting to true if isPopover is false,
- newPopoverOrTopLayerElement's popover attribute
- is in the Hint state, or
- candidateAncestor's popover attribute is in the
- Auto state.
If okNesting is false, then set candidate to - candidateAncestor's parent in the flat tree.
Let popoverAncestorIndex be the index of the last item in combinedPopovers of which newPopoverOrTopLayerElement is a flat tree descendant, otherwise -1.
Let candidatePosition be - popoverPositions[candidateAncestor].
Let sourceAncestorIndex be -1.
If topmostPopoverAncestor is null or - popoverPositions[topmostPopoverAncestor] is less than - candidatePosition, then set topmostPopoverAncestor to - candidateAncestor.
If source is not null, then set sourceAncestorIndex to the index of the last item in combinedPopovers of which source is a flat tree descendant, otherwise -1.
Run checkAncestor given newPopoverOrTopLayerElement's parent node - within the flat tree.
Let ancestorIndex be the maximum of popoverAncestorIndex and sourceAncestorIndex.
Run checkAncestor given source.
If ancestorIndex is -1, then return null.
Return topmostPopoverAncestor.
Return combinedPopovers[ancestorIndex].
While currentNode is not null:
If currentNode's popover attribute is in
- the Auto state or the Hint state, and currentNode's
- popover visibility state is showing,
- then return currentNode.
If currentNode's opened in popover mode is "auto" or "hint", and currentNode's popover visibility state is showing, then return currentNode.
Set currentNode to currentNode's parent in the flat tree.
To find the topmost auto or hint popover given a +
To find the topmost auto or hint popover given a
Document document, perform the following steps. They return an HTML element or null.
To close entire popover list given a list popoverList, a - boolean focusPreviousElement, and a boolean fireEvents:
+Each Document has a hint stack parent, which is an
+ HTML element or null, initially null.
While popoverList is not empty:
+The hint stack parent tracks which item in the showing auto popover list is the 'parent' of the first item in the showing hint popover list, or null if the first item in showing hint popover list is not 'child' to an item in the showing auto popover list.
-Run the hide popover algorithm given popoverList's last item, - focusPreviousElement, fireEvents, false, and null.
Therefore, when the hint stack parent is not null, it will have an opened in popover mode of "auto".
"Light dismiss" means that clicking outside of a popover whose popover attribute is in the Auto state will close the popover. This is in addition to
+ data-x="attr-popover-auto-state">Auto or Hint state will close the popover. This is in addition to
how such popovers respond to close requests.
Let document be target's node document.
Let topmostPopover be the result of running topmost auto popover - given document.
If topmostPopover is null, then return.
If the result of running topmost auto or hint popover given document is null, then return.
If event's Set document's popover pointerdown target to null. If ancestor is null, then set ancestor to
- document. If sameTarget is false, then return Let endpointIsHint be true if document's showing hint popover list contains ancestor; otherwise false. Run hide popover stack until given document, ancestor, Hint, false, and true. Let autoEndpoint be ancestor. If endpointIsHint, then set autoEndpoint to document's hint stack parent. This means, if a hint popover is clicked, auto popovers are closed, except those that are parent to the clicked hint popover. If sameTarget is true, then run hide
- all popovers until given ancestor, false, and true. Run hide popover stack until given document, autoEndpoint, Auto, false, and true.type is "pointerdown", then: set document's popover
@@ -92411,11 +92218,21 @@ dictionary DragEventInit : MouseEventInit {