diff --git a/source b/source index cd0d47cc723..95d06347d11 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
If the result of running check popover validity given - target, true, false, and null is true, then run the - hide popover algorithm given target, true, true, false, and - element.
Let validity be the result of running check popover validity + given target, true, and null. If this throws an exception, catch it, and let + validity be false.
If validity is true, then run the hide popover algorithm given + target, true, true, false, and element.
If the result of running check popover validity given - target, false, false, and null is true, then run the - show popover algorithm given target, false, and - element.
Let validity be the result of running check popover validity + given target, false, and null. If this throws an exception, catch it, and let + validity be false.
If validity is true, then run the show popover + algorithm given target, false, and element.
Otherwise:
+ +Let validity be the result of running check popover validity + given target, true, and null. If this throws an exception, catch it, and let + validity be false.
Otherwise, if the result of running check popover validity given - target, true, false, and null is true, then run the - hide popover algorithm given target, true, - true, false, and element.
If validity is true, then run the hide popover algorithm + given target, true, true, false, and element.
If the result of running check popover validity given target, - false, false, and null is true, then run the show popover algorithm given target, false, and - element.
Let validity be the result of running check popover validity + given target, false, and null. If this throws an exception, catch it, and let + validity be false.
If validity is true, then run the show popover + algorithm given target, false, and element.
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 +91187,14 @@ 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 +91258,40 @@ dictionary DragEventInit : MouseEventInit { element or null source:
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.
If document's showing popover is true, or document's + hiding popover nesting count is not 0, then:
-Assert: element is not in document's top - layer.
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.
Let nestedShow be element's popover showing or - hiding.
Let validityResult be the result of running check popover validity + given element, false, and null. If this throws an exception, catch it, and let + validityResult be false.
Let fireEvents be the boolean negation of nestedShow.
If validityResult is false, then return.
Set element's popover showing or hiding to true.
Assert: element's popover trigger is null.
Assert: element is not in document's top + layer.
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.
+Set validityResult to the result of running check popover validity + given element, false, and document. If this throws an exception, catch it, + and set validityResult to that exception.
Check popover validity is called again because firing the beforetoggle event could have disconnected this element or
changed its popover attribute.
Let shouldRestoreFocus be false.
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 hintAncestor be the result of running the topmost popover - ancestor algorithm given element, document's showing hint - popover list, source, and true.
If originalType is the Auto state, - then:
+If validityResult is not true:
Run close entire popover list given document's showing - hint popover list, shouldRestoreFocus, and fireEvents.
Let ancestor be the result of running the topmost popover - ancestor algorithm given element, document's showing auto - popover list, source, and true.
If ancestor is null, then set ancestor to - document.
Run cleanupShowingSteps.
Run hide all popovers until given - ancestor, shouldRestoreFocus, and fireEvents.
If throwExceptions is true and validityResult is a + {{DOMException}}, then throw validityResult.
Set stackToAppendTo to "auto".
Otherwise, return.
If originalType is the Hint state, - then:
+Let shouldRestoreFocus be false.
If hintAncestor is not null, then:
+Let originalType be the current state of element's popover attribute.
Run hide all popovers until given - hintAncestor, shouldRestoreFocus, and fireEvents.
Let ancestor be the result of running the topmost popover ancestor + algorithm given element, source, and true.
Set stackToAppendTo to "hint".
Let effectiveType be originalType.
Otherwise:
+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;
If autoAncestor is not null, then:
+ancestor's opened in popover mode is "hint"; and
Run hide all popovers until given - autoAncestor, shouldRestoreFocus, and fireEvents.
effectiveType is the Auto + state,
Set stackToAppendTo to "auto".
then set effectiveType to the Hint + state.
-Otherwise, set stackToAppendTo to "hint".
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 effectiveType is the Auto or + Hint state, then run hide popover stack + until given document, ancestor, Hint, shouldRestoreFocus, and true.
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:
Run cleanupShowingSteps.
If throwExceptions is true, then throw an
"InvalidStateError" DOMException.
If the result of running check popover validity given element, - false, throwExceptions, and document is false, then run - cleanupShowingFlag and return.
+Set validityResult to the result of running check popover validity + given element, false, and document. If this throws an exception, catch + it, and set validityResult to that exception.
-Check popover validity is called again because running hide all popovers until above could have fired the
- beforetoggle event, and an event handler could have
+
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 - popover on document is null, then set shouldRestoreFocus to - true.
+If validityResult is not true:
+ +Run cleanupShowingSteps.
If throwExceptions is true and validityResult is a + {{DOMException}}, then throw validityResult.
Otherwise, return.
If the result of running topmost auto or hint popover on document + is null, then set shouldRestoreFocus to true.
This ensures that focus is returned to the previously-focused element only for the first popover in a stack.
If stackToAppendTo is "auto":
If effectiveType is Auto:
Assert: document's showing auto popover list does @@ -91425,8 +91437,8 @@ 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.
If the result of running check popover validity given element, - true, throwExceptions, and null is false, then return.
Let validityResult be the result of running check popover validity + given element, true, and null. If this throws an exception, catch it, and let + validityResult be that exception.
If validityResult is not true:
+ +If throwExceptions is true and validityResult is a + {{DOMException}}, then throw validityResult.
Otherwise, return.
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 +91604,69 @@ 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 the result of running check popover validity given element, - true, throwExceptions, and null is false, then run cleanupSteps and - return.
+If element is document's hint stack parent, then + hide popover stack until given document, null, Hint, focusPreviousElement, and + fireEvents.
-Check popover validity is called again because running hide all popovers until could have disconnected
- element or changed its popover attribute.
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.
Set validityResult to the result of running check popover validity + given element, true, and null. If this throws an exception, catch it, and set + validityResult to that exception.
+ +Check popover validity is called again because running hide
+ popover stack until could have disconnected element or changed its popover attribute.
If validityResult is not true:
+ +Run cleanupSteps.
If throwExceptions is true and validityResult is a + {{DOMException}}, then throw validityResult.
Otherwise, return.
Let autoPopoverListContainsElement be true if document's - showing auto popover list's last item is element, otherwise - false.
If fireEvents is true:
@@ -91614,21 +91679,29 @@ 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 - return.
+Set validityResult to the result of running check popover validity + given element, true, and null. If this throws an exception, catch it, and set + validityResult to that exception.
Check popover validity is called again because firing the beforetoggle event could have disconnected
element or changed its popover attribute.
If validityResult is not true:
+ +Run cleanupSteps.
If throwExceptions is true and validityResult is a + {{DOMException}}, then throw validityResult.
Otherwise, return.
Request an element to be removed from the top layer given element.
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.
Run check popover validity given expectedToBeShowing, true, and - null.
Run check popover validity given this, + expectedToBeShowing, and null.
To hide all popovers until, given an HTML element or Document endpoint, a boolean
+
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 document be endpoint's node document.
Assert: endpoint is a Document or
- endpoint's popover visibility state is showing.
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.
Let endpointIsHint be true if document's showing hint popover + list contains endpoint; otherwise + false.
Run close entire popover list given document's showing hint - popover list, focusPreviousElement, and fireEvents.
Run hide popover stack until given document, endpoint, + Hint, focusPreviousElement, and + fireEvents.
If document's showing auto popover list does not contain - endpoint, then return.
If endpointIsHint, then return.
Run hide popover stack until given endpoint, document's - showing auto popover list, focusPreviousElement, and +
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 lastToHide be null.
Let popoverList be document's showing auto popover list + if stackType is Auto; otherwise + document's showing hint popover list.
For each popover in popoverList:
+Let lastHideIndex be 0 if popoverList does not contain endpoint; otherwise the index of endpoint in + popoverList plus 1.
If popover is endpoint, then break.
Let toHide be a slice of + popoverList from lastHideIndex, in + reverse order.
Set lastToHide to popover.
Let toRemain be a slice of + popoverList from 0 to lastHideIndex.
If lastToHide is null, then return.
For each popover of toHide: run + the hide popover algorithm given popover, + focusPreviousElement, fireEvents, false, and null.
While lastToHide's popover visibility state is showing:
+Let newPopoverList be document's showing auto popover + list if stackType is Auto; + otherwise document's showing hint popover list.
Assert: popoverList is not empty.
Reverse newPopoverList.
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 - 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.
+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 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 - 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):
+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):
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,
- 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.
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 - 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.
+ 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 + 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 +91939,30 @@ 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.
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 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.
Let document be newPopoverOrTopLayerElement's node + document.
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.
Let combinedPopovers be document's showing auto popover + list extended with document's showing + hint popover list.
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
+
If currentNode's opened in popover mode is "auto" or "hint", and currentNode's
popover visibility state is showing,
then return currentNode.
To find the topmost auto or hint popover given a
- Document document, perform the following steps. They return an To find the topmost auto or hint popover given
+ a Document document, perform the following steps. They return an HTML element or null.
To check popover validity for an HTML element
- element given a boolean expectedToBeShowing, a boolean
- throwExceptions, and a Document or null expectedDocument,
- perform the following steps. They throw an exception or return a boolean.
Document or
+ null expectedDocument, perform the following steps. They throw an exception or return a
+ boolean.
If element's popover attribute is in the No Popover state, then:
If throwExceptions is true, then throw a
- "NotSupportedError" DOMException.
Return false.
NotSupportedError" DOMException.
element's fullscreen flag is set,
then:
- -If throwExceptions is true, then throw an
- "InvalidStateError" DOMException.
Return false.
then throw an "InvalidStateError" DOMException.
Return true.
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".
Otherwise, if popover's popover visibility state is hidden and the result of running check popover - validity given popover, false, false, and null is true, then run show - popover given popover, false, and node.
Otherwise:
+ +Let validity be the result of running check popover validity + given popover, false, and null. If this throws an exception, catch it, and let + validity be false.
If validity is true, then run show popover given + popover, false, and node.
"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
- how such popovers respond to close requests.
To light dismiss open popovers, given a PointerEvent
@@ -92388,10 +92367,8 @@ dictionary DragEventInit : MouseEventInit {
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. If sameTarget is true, then run hide
- all popovers until given ancestor, false, and true. 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. Run hide popover stack until given document,
+ autoEndpoint, Auto, false, and
+ true.type is "pointerdown", then: set document's popover
@@ -92411,11 +92388,29 @@ dictionary DragEventInit : MouseEventInit {