Skip to content

Commit c0b6c08

Browse files
committed
Cleanup + Andys feedback.
1 parent 2c40eef commit c0b6c08

File tree

1 file changed

+40
-26
lines changed

1 file changed

+40
-26
lines changed

permission-element.bs

+40-26
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ time providing implementations with a better signal of user intent.
118118
<dd>{{HTMLPermissionElement/type}} — Type of permission this element applies to.</dd>
119119
<dd>{{HTMLPermissionElement/isValid}} — query whether the element can currently be activated.</dd>
120120
<dd>{{HTMLPermissionElement/invalidReason}} — Return a string representation of why the element currently cannot be activated.</dd>
121-
<dd>{{HTMLPermissionElement/ondismiss}} — notifies when the user has dismissed the permission prompt.</dd>
122-
<dd>{{HTMLPermissionElement/onresolve}} — notifies when a permission prompt has been answered by the user (positively or negatively).</dd>
121+
<dd>{{HTMLPermissionElement/onpromptdismiss}} — notifies when the user has dismissed the permission prompt.</dd>
122+
<dd>{{HTMLPermissionElement/onpromptaction}} — notifies when a permission prompt has been answered by the user (positively or negatively).</dd>
123123
<dd>{{HTMLPermissionElement/onvalidationstatuschange}} — notifies when the validation status changes.</dd>
124124
<dt>[=Accessibility considerations=]:</dt>
125125
<dd></dd>
@@ -134,8 +134,8 @@ time providing implementations with a better signal of user intent.
134134
readonly attribute boolean isValid;
135135
readonly attribute PermissionElementBlockerReason invalidReason;
136136

137-
attribute EventHandler onresolve;
138-
attribute EventHandler ondismiss;
137+
attribute EventHandler onpromptaction;
138+
attribute EventHandler onpromptdismiss;
139139
attribute EventHandler onvalidationstatuschange;
140140
};
141141
</pre>
@@ -168,8 +168,8 @@ observed by the <{permission}> element to select localized text.
168168
The following are the [=event handlers=] (and their corresponding [=event handler event types=]) that must be supported on <{permission}> elements [=event handler IDL attributes=]:
169169

170170
<pre class=simpledef>
171-
onresolve: Event
172-
ondismiss: Event
171+
onpromptaction: Event
172+
onpromptdismiss: Event
173173
onvalidationstatuschange: Event
174174
</pre>
175175

@@ -210,9 +210,15 @@ The <{permission}> element has the following internal slots:
210210

211211
* <dfn attribute for="HTMLPermissionElement">\[[LastNotifiedValidState]]</dfn>
212212
is a [=boolean=] that stores the most recently notified state of
213-
{{HTMLPermissionElement/isValid}}. This is used to determine whether
214-
an {{HTMLPermissionElement/onvalidationstatuschange}} event needs to
215-
be thrown.
213+
{{HTMLPermissionElement/isValid}}.
214+
215+
* <dfn attribute for="HTMLPermissionElement">\[[LastNotifiedInvalidReason]]</dfn>
216+
is a [=string=] that stores the most recently notified state of
217+
{{HTMLPermissionElement/invalidReason}}.
218+
{{[[LastNotifiedValidState]]}} and {{[[LastNotifiedInvalidReason]]}} are
219+
used to determine whether an
220+
{{HTMLPermissionElement/onvalidationstatuschange}} event needs to be
221+
dispatches.
216222

217223
## <{permission}>-supporting state at the [=/navigable=] ## {#permission-element-external-state}
218224

@@ -471,6 +477,8 @@ The {{HTMLPermissionElement}} constructor steps are:
471477
1. Initialize the internal {{[[Types]]}} slot to null.
472478
1. Initialize the internal {{[[BlockerList]]}} to &laquo;[]&raquo;.
473479
1. Initialize the internal {{[[LastNotifiedValidState]]}} with false.
480+
1. Initialize the internal {{[[LastNotifiedInvalidReason]]}} with the empty
481+
string.
474482

475483
</div>
476484

@@ -530,20 +538,22 @@ A <{permission}> |element|'s [=EventTarget/activation behavior=] given |event| i
530538
1. If |element|'s {{[[Types]]}} [=list/is empty=], then return.
531539
1. If |event|.{{Event/isTrusted}} is false, then return.
532540
1. If |element|.{{HTMLPermissionElement/isValid}} is false, then return.
533-
1. Let |result| be the result of [=request permission to use=] the
534-
[=powerful features=] named in |element|'s {{[[Types]]}}.
535-
1. If |result| is `cancel`, [=dispatch ondismiss=] on [=this=] and return.
541+
1. [=Request permission to use=] the [=powerful features=] named in
542+
|element|'s {{[[Types]]}}.
543+
1. If the previous step was cancelled or dismissed by the user, then
544+
[=dispatch onpromptdismiss=] on [=this=] and return.
536545

537546
Issue: The [[PERMISSIONS]] spec assumes that [=request permission to use=]
538-
will always succeed. That is, it assumed that the user will always make a
547+
will always succeed. That is, it assumes that the user will always make a
539548
choice and that the algorithm will always deliver a `grant`/`deny`
540549
answer corresponding to that choice. But you can't force a user to do that.
541-
Some (or all?) [=user agents=] will allow a user to just close the dialog
542-
box without making a choice.
543-
Here, we will pretend this non-choice result is represented by the result
544-
`cancel`.
550+
Some [=user agents=] may have different UI affordances for an explicit
551+
denial (e.g. a "deny" button) on one hand, and cancelling or dismissing the
552+
request dialog (e.g. an "X" button in the top right corner). Here, we
553+
distinguish between these two actions, despite no clear hook for this
554+
in the underlying specification.
545555

546-
1. [=Dispatch onresolve=] on [=this=].
556+
1. [=Dispatch onpromptaction=] on [=this=].
547557

548558
</div>
549559

@@ -609,10 +619,14 @@ To <dfn for="HTMLPermissionElement">recheck type permissibility</dfn> for a
609619
<div algorithm>
610620
To <dfn for=HTMLPermissionElement>maybe dispatch onvalidstatechange</dfn> for |element|:
611621

612-
1. Let |old| be {{[[LastNotifiedValidState]]}}.
613-
1. Let |new| be whether |element|’s [=blocker=] is Nothing.
614-
1. Set {{[[LastNotifiedValidState]]}} to |new|.
615-
1. If |old| != |new|, then:
622+
1. Let |oldState| be {{[[LastNotifiedValidState]]}}.
623+
1. Let |newState| be whether |element|’s [=blocker=] is Nothing.
624+
1. Set {{[[LastNotifiedValidState]]}} to |newState|.
625+
1. Let |oldReason| be {{[[LastNotifiedInvalidReason]]}}.
626+
1. Let |newReason| be whether |element|’s
627+
{{HTMLPermissionElement/invalidReason}}.
628+
1. Set {{[[LastNotifiedInvalidReason]]}} to |newReason|.
629+
1. If |oldState| != |newState| or |oldReason| != |newReason|, then:
616630
1. Let |event| be a new {{Event}}.
617631
1. [=Event/Initialize=] |event| with
618632
<a argument for="Event/initEvent(type, bubbles, cancelable)">type</a>
@@ -626,12 +640,12 @@ To <dfn for=HTMLPermissionElement>maybe dispatch onvalidstatechange</dfn> for |e
626640
</div>
627641

628642
<div algorithm>
629-
To <dfn for=HTMLPermisssionElement>dispatch onresolve</dfn> for |element|:
643+
To <dfn for=HTMLPermisssionElement>dispatch onpromptaction</dfn> for |element|:
630644

631645
1. Let |event| be a new {{Event}}.
632646
1. [=Event/Initialize=] |event| with
633647
<a argument for="Event/initEvent(type, bubbles, cancelable)">type</a>
634-
"{{HTMLPermissionElement/onresolve}}",
648+
"{{HTMLPermissionElement/onpromptaction}}",
635649
<a argument for="Event/initEvent(type, bubbles, cancelable)">bubbles</a>
636650
true, and
637651
<a argument for="Event/initEvent(type, bubbles, cancelable)">cancelable</a>
@@ -641,12 +655,12 @@ To <dfn for=HTMLPermisssionElement>dispatch onresolve</dfn> for |element|:
641655
</div>
642656

643657
<div algorithm>
644-
To <dfn for=HTMLPermisssionElement>dispatch ondismiss</dfn> for |element|:
658+
To <dfn for=HTMLPermisssionElement>dispatch onpromptdismiss</dfn> for |element|:
645659

646660
1. Let |event| be a new {{Event}}.
647661
1. [=Event/Initialize=] |event| with
648662
<a argument for="Event/initEvent(type, bubbles, cancelable)">type</a>
649-
"{{HTMLPermissionElement/ondismiss}}",
663+
"{{HTMLPermissionElement/onpromptdismiss}}",
650664
<a argument for="Event/initEvent(type, bubbles, cancelable)">bubbles</a>
651665
true, and
652666
<a argument for="Event/initEvent(type, bubbles, cancelable)">cancelable</a>

0 commit comments

Comments
 (0)