<?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>24971</bug_id>
          
          <creation_ts>2014-03-07 13:11:05 +0000</creation_ts>
          <short_desc>Should got/lostpointercapture be dispatched asynchronously or synchronously</short_desc>
          <delta_ts>2014-06-03 05:25:28 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>PointerEventsWG</product>
          <component>Pointer Events specification</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Olli Pettay">bugs</reporter>
          <assigned_to name="Jacob Rossi [MSFT]">jrossi</assigned_to>
          <cc>nekr.fabula</cc>
    
    <cc>public-pointer-events</cc>
          
          <qa_contact name="Pointer Events Bugzilla list">public-pointer-events-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>102062</commentid>
    <comment_count>0</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-03-07 13:11:05 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/pointerevents/raw-file/tip/pointerEvents.html#list-of-pointer-events says those events are asynchronous
and so does https://dvcs.w3.org/hg/pointerevents/raw-file/tip/pointerEvents.html#the-gotpointercapture-event and 
https://dvcs.w3.org/hg/pointerevents/raw-file/tip/pointerEvents.html#the-lostpointercapture-event

But the algorithm in https://dvcs.w3.org/hg/pointerevents/raw-file/tip/pointerEvents.html#pointer-capture
doesn&apos;t talk about tasks or async dispatching.
It just says 
&quot;Fire a gotpointercapture event at the Element on which this method was invoked.&quot;
and &quot;Fire a lostpointercapture event at the Element on which this method was invoked.&quot;

The algorithm should probably say something like
&quot;...queue a task to fire a pointer event named &apos;got/lostpointercapture on element&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102063</commentid>
    <comment_count>1</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-03-07 13:17:47 +0000</bug_when>
    <thetext>Actually, I don&apos;t understand what the spec tries to say
&quot;A user agent MUST queue a task to fire a pointer event named lostpointercapture after pointer capture is released for a pointer. This event MUST be fired prior to any subsequent events for the pointer after capture was released.&quot;

So queue a task to fire event, but that firing must happen before something else.
That makes no sense. We can&apos;t prioritize event dispatching task in the 
task queue to happen before something else.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102064</commentid>
    <comment_count>2</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-03-07 14:36:15 +0000</bug_when>
    <thetext>Or should we dispatch got/lost async, but if we&apos;re about to get some new event for that particular pointer, then sync right before dispatching that new event?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102191</commentid>
    <comment_count>3</comment_count>
    <who name="Jacob Rossi [MSFT]">jrossi</who>
    <bug_when>2014-03-11 05:42:29 +0000</bug_when>
    <thetext>I&apos;m checking out implementation. But I think it&apos;s actually as Olli describes in Comment 2. The main thing I think we&apos;re trying to avoid here is overflowing the stack (calling setPointerCapture in a gotpointercapture listener repeatedly).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102373</commentid>
    <comment_count>4</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-03-14 14:09:23 +0000</bug_when>
    <thetext>What should happen in case some pointer event listener
does first releasePointerCapture(X) and then immediately setPointerCapture(X)?
What should be the order of the various events and when should they happen,
sync or async.

Do we actually just need synchronous event dispatching here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103857</commentid>
    <comment_count>5</comment_count>
    <who name="Jacob Rossi [MSFT]">jrossi</who>
    <bug_when>2014-04-15 04:32:28 +0000</bug_when>
    <thetext>It&apos;s not truly &quot;async&quot; in the &quot;queue a task&quot; sense. The way IE does this is to set a &quot;pending capture node&quot; when setPointerCapture() is called.  When it comes time to fire the next pointer event, we check to see if the pointer has a pending capture node. If it does, then we fire the gotpointercapture event prior to firing the next pointer event.

We could make the spec capture this behavior more succinctly with a relatively simple change:

1. Remove step 4 from sections 10.1 and 10.2
2. Change step 3 of 10.1 and 10.2 to set and clear the &apos;pending pointer capture&apos; node for the pointer, respectively
3. In section 5.2.1, add a step such that when you are to fire a pointer event, you first:
   &quot;1. If the &apos;pointer capture target override&apos; for this pointer is set and is not equal to the &apos;pending pointer capture&apos; node, then fire a pointer event named lostpointercapture at the &apos;pointer capture target override&apos; node.
   2. If the &apos;pending pointer capture&apos; node for this pointer is set and is not equal to the &apos;pointer capture target override&apos;, then fire a pointer event named gotpointercapture at the &apos;pending pointer capture&apos; node.
   3. Set the &apos;pointer capture target override&apos; to the &apos;pending pointer capture&apos; node, if set. Otherwise, clear the &apos;pointer capture target override&apos;.&quot;
4. Remove &quot;queue a task to&quot; from sections 5.2.11 and 5.2.12


This would also effectively resolve Bug 25147, I believe:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=25147</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107174</commentid>
    <comment_count>6</comment_count>
    <who name="Jacob Rossi [MSFT]">jrossi</who>
    <bug_when>2014-06-03 05:25:28 +0000</bug_when>
    <thetext>Fixed as described (modulo some tweaks) above:
https://dvcs.w3.org/hg/pointerevents/rev/06a63f400a2a</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>