Closed Bug 1292063 Opened 8 years ago Closed 8 years ago

Support Event.composed

Categories

(Core :: DOM: Events, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: stone, Assigned: stone)

References

Details

(Keywords: dev-doc-complete)

Attachments

(6 files, 5 obsolete files)

778 bytes, text/html
Details
32.92 KB, patch
stone
: review+
Details | Diff | Splinter Review
15.56 KB, patch
stone
: review+
Details | Diff | Splinter Review
4.33 KB, patch
stone
: review+
Details | Diff | Splinter Review
3.42 KB, patch
stone
: review+
Details | Diff | Splinter Review
1.00 KB, patch
stone
: review+
Details | Diff | Splinter Review
Add the composed attribute for pointer events

References
https://github.com/w3c/uievents/pull/91
https://github.com/w3c/pointerevents/pull/92
Blocks: 1292062
Priority: -- → P3
Summary: [Pointer Event] Support Event.composed in Pointer Events → Support Event.composed
See Also: → 1298725
Blocks: 1264769
Assignee: nobody → sshih
I found there are some events should also be clarified if they are also composed, such as
1) clipboard events (eCopy, ePaste, eCut)
2) scroll event (eScroll)
   I'm not sure whether other scroll related events should be composed, such as
     eLegacyMouseLineOrPageScroll,
     eLegacyMousePixelScroll,
     eScrolledAreaChanged,
     eScrollPortOverflow,
     eScrollPortUnderflow

I also found that some existed test cases depend on the event fired by anonymous element, such as
layout/reftests/ogg-video/poster-4.html and poster-7.html. In these two test case, they want to be notified the when image poster is loaded.
Attached file input_test.html
About scroll behavior, tested the attached test case on different browsers. The test procedures are press mouse left button and hold inside the input element, then move mouse down or left.

Edge 25.10586.0.0
scroll events are fired to listener(capture) of window and input

Chrome 52.0.2743.116(Windows10) and Canary 55.0.2853.0 (Windows10)
scroll events aren't fire to listeners of window and input
<textarea> is more important to test.
Attached patch Part1 Add Event.composed (V2) (obsolete) — Splinter Review
Some test cases need to check whether the event target chain is correct. The event target chain depends on whether the event is composed. So I add one more argument to getEventTargetChainFor
Some tests in shadow-dom/event-composed.html are passed when we support Event.composed.

Other failures need the interface 'Element.attachShadow'
Attachment #8792454 - Flags: review?(bugs)
Attachment #8792455 - Flags: review?(bugs)
Attachment #8792456 - Flags: review?(bugs)
Attachment #8792457 - Flags: review?(bugs)
Attachment #8792739 - Flags: review?(bugs)
Comment on attachment 8792454 [details] [diff] [review]
Part1 Add Event.composed (V2)



>+    switch (mClass) {
>+      case eMouseEventClass:
>+        mFlags.mComposed = mMessage == eMouseClick ||
>+                           mMessage == eMouseDoubleClick ||
>+                           mMessage == eMouseDown || mMessage == eMouseDown ||
eMouseDown twice here


>+                           mMessage == eMouseEnter || mMessage == eMouseEnter ||
Same with eMouseEnter


>+  void SetComposed(const nsAString& aEventTypeArg)
>+  {
>+    mFlags.mComposed = // mouse events
>+                       aEventTypeArg.EqualsLiteral("click") ||
>+                       aEventTypeArg.EqualsLiteral("dblclick") ||
>+                       aEventTypeArg.EqualsLiteral("mousedown") ||
>+                       aEventTypeArg.EqualsLiteral("mouseenter") ||
>+                       aEventTypeArg.EqualsLiteral("mouseleave") ||
>+                       aEventTypeArg.EqualsLiteral("mousemove") ||
>+                       aEventTypeArg.EqualsLiteral("mouseout") ||
>+                       aEventTypeArg.EqualsLiteral("mouseover") ||
>+                       aEventTypeArg.EqualsLiteral("mouseup") ||
You're missing contextmenu here, but you have it as eContextMenu


Those fixed, r+
Attachment #8792454 - Flags: review?(bugs) → review+
Comment on attachment 8792455 [details] [diff] [review]
Part2 Add composed argument to getEventTargetChainFor and refine test cases (V2)


>+++ b/dom/events/nsIEventListenerService.idl
>@@ -73,16 +73,17 @@ interface nsIEventListenerService : nsIS
>    * Returns an array of event targets.
>    * aEventTarget will be at index 0.
>    * The objects are the ones that would be used as DOMEvent.currentTarget while
>    * dispatching an event to aEventTarget
>    * @note Some events, especially 'load', may actually have a shorter
>    *       event target chain than what this methods returns.
>    */
>   void getEventTargetChainFor(in nsIDOMEventTarget aEventTarget,
>+                              in boolean composed,
I wonder if composed should be optional. Maybe not. Maybe better to be explicit here.
Attachment #8792455 - Flags: review?(bugs) → review+
Comment on attachment 8792456 [details] [diff] [review]
Part3 Add mComposedInNativeAnonymousContent to determine which events can cross the boundary of native anonymous content (V2)




>+  void SetDefaultComposedInNativeAnonymousContent()
>+  {
>+    // For compatibility concerns, we explicitly set all events (except those
>+    // events we want to stop propagation) currently we have to true and default
>+    // value to false in case we forget to set the flag to false for new events.
>+    switch (mClass) {
>+      case eAnimationEventClass:
>+      case eBeforeAfterKeyboardEventClass:
>+      case eClipboardEventClass:
>+      case eCommandEventClass:
>+      case eCompositionEventClass:
>+      case eDragEventClass:
>+      case eEditorInputEventClass:
>+      case eFocusEventClass:
>+      case eFormEventClass:
>+      case eGestureNotifyEventClass:
>+      case eGUIEventClass:
>+      case eInputEventClass:
>+      case eKeyboardEventClass:
>+      case eTouchEventClass:
>+      case eMouseScrollEventClass:
>+      case eMutationEventClass:
>+      case ePluginEventClass:
>+      case ePointerEventClass:
>+      case eQueryContentEventClass:
>+      case eSelectionEventClass:
>+      case eScrollAreaEventClass:
>+      case eScrollPortEventClass:
>+      case eSimpleGestureEventClass:
>+      case eSMILTimeEventClass:
>+      case eTransitionEventClass:
>+      case eUIEventClass:
>+      case eWheelEventClass:
>+      case eSVGZoomEventClass:
>+      case eMouseEventClass:
>+        mFlags.mComposedInNativeAnonymousContent = true;
>+        break;
>+      case eBasicEventClass:
>+        // nsVideoFrame may create anonymous image element which fires eLoad,
>+        // eLoadStart, eLoadEnd, eLoadError. We don't want these events cross
>+        // the boundary of NAC
>+        mFlags.mComposedInNativeAnonymousContent = mMessage != eLoad &&
>+                                                   mMessage != eLoadStart &&
>+                                                   mMessage != eLoadEnd &&
>+                                                   mMessage != eLoadError;
>+        break;
>+      default:
>+        mFlags.mComposedInNativeAnonymousContent = false;
>+        break;
>+    }
>+  }
I don't quite understand this. Why list all the e*EventClasses here, and have different behavior for
default case?
I would expect this to just have check for eLoad/eLoadStart/eLoadEnd/eLoadError and otherwise have 
mComposedInNativeAnonymousContent true.
That fixed, r+
Attachment #8792456 - Flags: review?(bugs) → review+
Comment on attachment 8792457 [details] [diff] [review]
Part4 Refine test case to listen body load event instead of video load event (V2)

I assume you tested other browsers that they don't fire load either for poster.
If not, please test.
(and if they do, we'll need to file some spec bugs)
Attachment #8792457 - Flags: review?(bugs) → review+
Attachment #8792739 - Flags: review?(bugs) → review+
(In reply to Olli Pettay [:smaug] (reviewing overload) from comment #13)
> Comment on attachment 8792457 [details] [diff] [review]
> I assume you tested other browsers that they don't fire load either for
> poster.
> If not, please test.
> (and if they do, we'll need to file some spec bugs)

Yes, tested on Edge (windows10, 25.10586.0.0) and Chrome Canary (55.0.2875.0 canary (64-bit)) and they don't fire load event for poster.
Followed review comments to refine patch and updated the patch summary
Attachment #8792454 - Attachment is obsolete: true
Attachment #8796452 - Flags: review+
Followed review comments to refine patch and updated the patch summary
Attachment #8792456 - Attachment is obsolete: true
Attachment #8796473 - Flags: review+
Updated the patch summary
Attachment #8792739 - Attachment is obsolete: true
Attachment #8796475 - Flags: review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/22cf15bb84d4
Part 1: Add Event.composed. r=smaug
https://hg.mozilla.org/integration/mozilla-inbound/rev/79c5fa0ce1c6
Part 2: Add composed argument to getEventTargetChainFor and refine test cases. r=smaug
https://hg.mozilla.org/integration/mozilla-inbound/rev/a36f68c2886b
Part 3: Add mComposedInNativeAnonymousContent to determine which events can cross the boundary of native anonymous content. r=smaug
https://hg.mozilla.org/integration/mozilla-inbound/rev/2c3aadf10c99
Part 4: Refine test case to listen body load event instead of video load event. r=smaug
https://hg.mozilla.org/integration/mozilla-inbound/rev/06f519962c12
Part 5: Update the meta file of shadow-dom/event-composed.html. r=smaug
Keywords: checkin-needed
Depends on: 1307388
Because the spec isn’t very detailed on this issue, and finding other information was difficult, I had to piece this together a bit. I believe I have documented this correctly but I’d appreciate it if someone would please verify. If I’m mistaken, please put dev-doc-needed back on this bug and let me know what I got wrong. Thanks!

We had an existing article on Event.scoped, which I’ve renamed to Event.composed, with the appropriate redirect in place. I then updated the article, which didn’t make much sense, to match what appears to be the function of this property.

From what I can tell reading the spec and the code, this basically reports whether or not an event can bubble across the shadow root into the standard DOM.

If that’s untrue, please let me know what I’ve got wrong so I can fix it.

https://developer.mozilla.org/en-US/docs/Web/API/Event/composed

https://developer.mozilla.org/en-US/docs/Web/API/Event and Firefox 52 for developers have been similarly updated.
Flags: needinfo?(sshih)
Not bubble but propagate. Bubble is just one of the event propagation phases.
Looks good to me, thanks.
Flags: needinfo?(sshih)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: