Skip to content

Commit

Permalink
Bug 1501983 - Add onslotchange event handler.r=smaug
Browse files Browse the repository at this point in the history
Reflects following spec changes:
- whatwg/html#4129
- whatwg/dom#785

Those new spec addition is already implemented in Safari and Chromium is working on it.

Differential Revision: https://phabricator.services.mozilla.com/D123775
  • Loading branch information
Sonia Singla committed Aug 27, 2021
1 parent f66a40e commit 6950ee5
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 85 deletions.
3 changes: 3 additions & 0 deletions dom/base/ShadowRoot.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef mozilla_dom_shadowroot_h__
#define mozilla_dom_shadowroot_h__

#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/DocumentBinding.h"
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/dom/DocumentOrShadowRoot.h"
Expand Down Expand Up @@ -163,6 +164,8 @@ class ShadowRoot final : public DocumentFragment,
void PartAdded(const Element&);
void PartRemoved(const Element&);

IMPL_EVENT_HANDLER(slotchange);

const nsTArray<const Element*>& Parts() const { return mParts; }

const RawServoAuthorStyles* GetServoStyles() const {
Expand Down
1 change: 1 addition & 0 deletions dom/events/EventNameList.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ EVENT(seeked, eSeeked, EventNameType_HTML, eBasicEventClass)
EVENT(seeking, eSeeking, EventNameType_HTML, eBasicEventClass)
EVENT(select, eFormSelect, EventNameType_HTMLXUL, eBasicEventClass)
EVENT(show, eShow, EventNameType_HTML, eBasicEventClass)
EVENT(slotchange, eSlotChange, EventNameType_All, eBasicEventClass)
EVENT(stalled, eStalled, EventNameType_HTML, eBasicEventClass)
EVENT(start, eMarqueeStart, EventNameType_HTMLMarqueeOnly, eBasicEventClass)
EVENT(submit, eFormSubmit, EventNameType_HTMLXUL, eBasicEventClass)
Expand Down
1 change: 1 addition & 0 deletions dom/webidl/EventHandler.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ interface mixin GlobalEventHandlers {
attribute EventHandler onselect;
[Pref="dom.menuitem.enabled"]
attribute EventHandler onshow;
attribute EventHandler onslotchange;
//(Not implemented)attribute EventHandler onsort;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
Expand Down
1 change: 1 addition & 0 deletions dom/webidl/ShadowRoot.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface ShadowRoot : DocumentFragment
[Pref="dom.shadowdom.slot.assign.enabled"]
readonly attribute SlotAssignmentMode slotAssignment;
readonly attribute Element host;
attribute EventHandler onslotchange;

Element? getElementById(DOMString elementId);

Expand Down
3 changes: 0 additions & 3 deletions testing/web-platform/meta/dom/idlharness.window.js.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
[Document interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[ShadowRoot interface: attribute onslotchange]
expected: FAIL
[Stringification of document.createNSResolver(document.body)]
expected: FAIL
Expand Down
27 changes: 0 additions & 27 deletions testing/web-platform/meta/html/dom/idlharness.https.html.ini
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,6 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[SVGElement interface: attribute autofocus]
expected: FAIL

[SVGElement interface: attribute onslotchange]
expected: FAIL

[FormDataEvent interface object length]
expected: FAIL

Expand Down Expand Up @@ -750,24 +747,6 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[Window interface: attribute oncancel]
expected: FAIL

[Document interface: new Document() must inherit property "onslotchange" with the proper type]
expected: FAIL

[Document interface: documentWithHandlers must inherit property "onslotchange" with the proper type]
expected: FAIL

[Window interface: window must inherit property "onslotchange" with the proper type]
expected: FAIL

[Document interface: attribute onslotchange]
expected: FAIL

[Window interface: attribute onslotchange]
expected: FAIL

[Document interface: iframe.contentDocument must inherit property "onslotchange" with the proper type]
expected: FAIL

[Window interface: operation print()]
expected:
if os == "android": FAIL
Expand Down Expand Up @@ -947,12 +926,6 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[HTMLElement interface: attribute autofocus]
expected: FAIL

[HTMLElement interface: attribute onslotchange]
expected: FAIL

[HTMLElement interface: document.createElement("noscript") must inherit property "onslotchange" with the proper type]
expected: FAIL

[HTMLIFrameElement interface: attribute loading]
expected: FAIL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,3 @@

[onsecuritypolicyviolation: the content attribute must execute when an event is dispatched]
expected: FAIL

[onslotchange: must be on the appropriate locations for GlobalEventHandlers]
expected: FAIL

[onslotchange: the content attribute must be compiled into a function as the corresponding property]
expected: FAIL

[onslotchange: the default value must be null]
expected: FAIL

[onslotchange: the content attribute must execute when an event is dispatched]
expected: FAIL

Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,3 @@
if not debug and e10s and (os == "linux") and (processor == "x86_64"): FAIL
if not debug and (os == "mac"): FAIL
if not debug and (os == "win") and (version == "6.1.7601"): FAIL

[not shadowed slotchange (window)]
expected: FAIL

[not shadowed slotchange (document.createElement("body"))]
expected: FAIL

[not shadowed slotchange (document.body)]
expected: FAIL

Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,3 @@
disabled: Bug 1485887
expected:
if not debug and not webrender and e10s and (os == "linux"): FAIL

[not shadowed slotchange (window)]
expected: FAIL

[not shadowed slotchange (document.createElement("frameset"))]
expected: FAIL

[not shadowed slotchange (document.body)]
expected: FAIL

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@
[securitypolicyviolation is unaffected on a windowless frameset]
expected: FAIL

[slotchange is unaffected on a windowless frameset]
expected: FAIL

[slotchange is unaffected on a windowless body]
expected: FAIL

Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,12 @@
[oncancel: the default value must be null]
expected: FAIL

[onslotchange: the default value must be null]
expected: FAIL

[oncancel: the content attribute must be compiled into a function as the corresponding property]
expected: FAIL

[onslotchange: dynamic changes on the attribute]
expected: FAIL

[oncancel: dispatching an Event at a <math> element must trigger element.oncancel]
expected: FAIL

[onslotchange: must be on the appropriate locations for GlobalEventHandlers]
expected: FAIL

[onslotchange: the content attribute must be compiled into a function as the corresponding property]
expected: FAIL

[oncancel: must be on the appropriate locations for GlobalEventHandlers]
expected: FAIL

Expand All @@ -40,7 +28,3 @@

[onsecuritypolicyviolation: the content attribute must be compiled into a function as the corresponding property]
expected: FAIL

[onslotchange: dispatching an Event at a <math> element must trigger element.onslotchange]
expected: FAIL

1 change: 1 addition & 0 deletions widget/EventMessageList.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ NS_EVENT_MESSAGE(eEditorBeforeInput)
// selection events
NS_EVENT_MESSAGE(eSelectStart)
NS_EVENT_MESSAGE(eSelectionChange)
NS_EVENT_MESSAGE(eSlotChange)

// visibility change
NS_EVENT_MESSAGE(eVisibilityChange)
Expand Down
1 change: 1 addition & 0 deletions xpcom/ds/StaticAtoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@
Atom("onshippingaddresschange", "onshippingaddresschange"),
Atom("onshippingoptionchange", "onshippingoptionchange"),
Atom("onshow", "onshow"),
Atom("onslotchange", "onslotchange"),
Atom("onsqueeze", "onsqueeze"),
Atom("onsqueezeend", "onsqueezeend"),
Atom("onsqueezestart", "onsqueezestart"),
Expand Down

0 comments on commit 6950ee5

Please sign in to comment.