<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26019</bug_id>
          
          <creation_ts>2014-06-09 10:48:33 +0000</creation_ts>
          <short_desc>No way to initialize modifier states except &quot;Alt&quot;, &quot;Control&quot;, &quot;Shift&quot; and &quot;Meta&quot; at constructing DOM event with constructor</short_desc>
          <delta_ts>2015-02-11 01:59:48 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - DOM3 Events</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>27902</dependson>
    
    <dependson>27903</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Masayuki Nakano">masayuki</reporter>
          <assigned_to name="Travis Leithead [MSFT]">travil</assigned_to>
          <cc>annevk</cc>
    
    <cc>crimsteam</cc>
    
    <cc>mike</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>107514</commentid>
    <comment_count>0</comment_count>
    <who name="Masayuki Nakano">masayuki</who>
    <bug_when>2014-06-09 10:48:33 +0000</bug_when>
    <thetext>At creating a DOM event with its constructor, there is no way to initialize some modifier states which is only retrieved with .getModifierState(). E.g., &quot;CapsLock&quot;, &quot;NumLock&quot;, &quot;ScrollLock&quot;, &quot;OS&quot;, &quot;AltGrapsh&quot;, &quot;Super&quot;, &quot;Hyper&quot;, etc.

The reason why they *should* not be initializable with constructor, I think MouseEvent and KeyboardEvent should have .initModifierStates() which can take space separated modifier key name list as a DOMString.

However, even if D3E spec defines such method, it should do nothing while the event is being dispatched. And also, if the event is trusted event, it should never work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107544</commentid>
    <comment_count>1</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-06-09 17:13:19 +0000</bug_when>
    <thetext>Rather than introduce another method similar to the now deprecated init* methods, I would rather extend the initMouseEvent and initKeyboardEvent dictionaries with the relevant modifier initializers.

Perhaps:
* boolean modifierStateCapsLock
* boolean modifierStateNumLock
* boolean modifierStateScrollLock
* boolean modifierStateOS
* boolean modifierStateAltGraph
* boolean modifierStateSuper
* boolean modifierStateHyper
etc.

The dictionary format is perfect for this kind of extensibility.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107547</commentid>
    <comment_count>2</comment_count>
    <who name="Masayuki Nakano">masayuki</who>
    <bug_when>2014-06-09 17:51:58 +0000</bug_when>
    <thetext>Yeah, if they can be initialized with constructor, it&apos;s the best.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107741</commentid>
    <comment_count>3</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-06-12 17:45:45 +0000</bug_when>
    <thetext>(In reply to Masayuki Nakano from comment #2)
&gt; Yeah, if they can be initialized with constructor, it&apos;s the best.

I&apos;ve got a private copy of this change now, and while writing it I made a few assumptions that I&apos;d like to discuss:

1. Some of the getModifierState params duplicate existing attributes, e.g., &quot;Alt&quot; and the altKey IDL attribute. Consequently, I&apos;ve not created the new initializers for &quot;Alt&quot;, but have made it explicit (in the prose for the existing &quot;altKey&quot; initializer on the dictionary) that is also sets the internal modifier state of the event such that calls to getModifierState(&apos;Alt&apos;) also return true. This avoids the duplication.

2. When initializing &quot;ctrlKey&quot; or &quot;metaKey&quot; I define that the internal states for getModifierStates &quot;Control&quot; and &quot;Meta&quot; are set (as described above), but also that the virtual &quot;Accel&quot; modifier is also set. So initializing &quot;ctrlKey&quot; to true will cause calls to getModifierState(&quot;Control&quot;) and getModifierState(&quot;Accel&quot;) to also return true.

3. Given #2 above, I&apos;m going to assume that if either &quot;ctrlKey&quot; OR &quot;metaKey&quot; is true, then &quot;Accel&quot; is also true, rather than using (&quot;ctrlKey&quot; AND &quot;metaKey&quot;) logic.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107744</commentid>
    <comment_count>4</comment_count>
    <who name="Masayuki Nakano">masayuki</who>
    <bug_when>2014-06-12 18:04:42 +0000</bug_when>
    <thetext>(In reply to Travis Leithead [MSFT] from comment #3)
&gt; (In reply to Masayuki Nakano from comment #2)
&gt; 1. Some of the getModifierState params duplicate existing attributes, e.g.,
&gt; &quot;Alt&quot; and the altKey IDL attribute. Consequently, I&apos;ve not created the new
&gt; initializers for &quot;Alt&quot;, but have made it explicit (in the prose for the
&gt; existing &quot;altKey&quot; initializer on the dictionary) that is also sets the
&gt; internal modifier state of the event such that calls to
&gt; getModifierState(&apos;Alt&apos;) also return true. This avoids the duplication.

I believe that it&apos;s right approach. If D3E allows two names for a state, following case is really a problem:

new Event(&quot;&quot;, altKey: true, modifierStateAlt: false);

So, I agree with that modifier states which can be represented by legacy fooKey shouldn&apos;t be initialized with modifierState*.

&gt; 2. When initializing &quot;ctrlKey&quot; or &quot;metaKey&quot; I define that the internal
&gt; states for getModifierStates &quot;Control&quot; and &quot;Meta&quot; are set (as described
&gt; above), but also that the virtual &quot;Accel&quot; modifier is also set. So
&gt; initializing &quot;ctrlKey&quot; to true will cause calls to
&gt; getModifierState(&quot;Control&quot;) and getModifierState(&quot;Accel&quot;) to also return
&gt; true.

I think that it&apos;s not problem. Additionally, web apps can test which modifier is the &quot;Accel&quot;. E.g.,

var ctrlEvent = new KeyboardEvent(&quot;&quot;, { ctrlKey: true });
var metaEvent = new KeyboardEvent(&quot;&quot;, { metaKey: true });

var accelText = ctrlEvent.getModifierState(&quot;Accel&quot;) ? &quot;Ctrl&quot; :
                metaEvent.getModifierState(&quot;Accel&quot;) ? &quot;Command&quot; : ...;

Like this, web apps can show proper modifier key label dynamically.

&gt; 3. Given #2 above, I&apos;m going to assume that if either &quot;ctrlKey&quot; OR &quot;metaKey&quot;
&gt; is true, then &quot;Accel&quot; is also true, rather than using (&quot;ctrlKey&quot; AND
&gt; &quot;metaKey&quot;) logic.

However, depending on the prefs on Firefox. Firefox can also set &quot;Alt&quot; or &quot;OS&quot; (and &quot;Super&quot;, &quot;Hyper&quot; soon) as a modifier for acceleration. Although, it must be rare case. Anyway, modifierStateAccel should not exist in the dictionary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107746</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-06-12 18:14:29 +0000</bug_when>
    <thetext>Travis, note that if your initialization process is not covered by http://dom.spec.whatwg.org/#constructing-events we need to figure out how to make that work. You might have to define the entire constructor yourself.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107818</commentid>
    <comment_count>6</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-06-13 22:34:38 +0000</bug_when>
    <thetext>I landed v1 of this change.

Anne, I need to look and see what magic flags may be available to define this more specifically--I wanted to land this much now, since it refactors some of the event dictionaries...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107819</commentid>
    <comment_count>7</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-06-13 22:34:54 +0000</bug_when>
    <thetext>(In reply to Travis Leithead [MSFT] from comment #6)
&gt; I landed v1 of this change.
&gt; 
&gt; Anne, I need to look and see what magic flags may be available to define
&gt; this more specifically--I wanted to land this much now, since it refactors
&gt; some of the event dictionaries...

https://dvcs.w3.org/hg/dom3events/rev/8034c1f1c711</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107820</commentid>
    <comment_count>8</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-06-13 22:37:47 +0000</bug_when>
    <thetext>(In reply to Anne from comment #5)
&gt; Travis, note that if your initialization process is not covered by
&gt; http://dom.spec.whatwg.org/#constructing-events we need to figure out how to
&gt; make that work. You might have to define the entire constructor yourself.

Mmm. DOM doesn&apos;t seem to have the hooks I need. I need some internal state that can represent the possible values used by the getModifierState function... I should be able to whip that up.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117843</commentid>
    <comment_count>9</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2015-02-11 01:59:48 +0000</bug_when>
    <thetext>(In reply to Travis Leithead [MSFT] from comment #8)
&gt; (In reply to Anne from comment #5)
&gt; &gt; Travis, note that if your initialization process is not covered by
&gt; &gt; http://dom.spec.whatwg.org/#constructing-events we need to figure out how to
&gt; &gt; make that work. You might have to define the entire constructor yourself.
&gt; 
&gt; Mmm. DOM doesn&apos;t seem to have the hooks I need. I need some internal state
&gt; that can represent the possible values used by the getModifierState
&gt; function... I should be able to whip that up.

Committed a rough extension to Anne&apos;s algorithm in the DOM spec.
https://dvcs.w3.org/hg/dom3events/rev/ad15280ceb0c</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>