forked from mirrors/gecko-dev
Bug 1470545: Add chromeonly "shadowrootattached" event for devtools. r=smaug
Summary:
document.addEventListener("shadowrootattached", e => {
// Do stuff with composedTarget.
});
I didn't bother to add tests for the event itself since this is going to get
tested in bug 1449333, but I can look into writing a chrome mochitest if you
want.
Test Plan: See above.
Reviewers: smaug
Bug #: 1470545
Differential Revision: https://phabricator.services.mozilla.com/D1777
MozReview-Commit-ID: 55cVMSsznMS
This commit is contained in:
parent
89fd549c61
commit
a24ebbee4e
4 changed files with 27 additions and 1 deletions
|
|
@ -1263,6 +1263,17 @@ Element::AttachShadowWithoutNameChecks(ShadowRootMode aMode)
|
|||
*/
|
||||
SetShadowRoot(shadowRoot);
|
||||
|
||||
// Dispatch a "shadowrootattached" event for devtools.
|
||||
{
|
||||
AsyncEventDispatcher* dispatcher =
|
||||
new AsyncEventDispatcher(this,
|
||||
NS_LITERAL_STRING("shadowrootattached"),
|
||||
CanBubble::eYes,
|
||||
ChromeOnlyDispatch::eYes,
|
||||
Composed::eYes);
|
||||
dispatcher->PostDOMEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 6. Return shadow.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ AsyncEventDispatcher::Run()
|
|||
}
|
||||
mTarget->AsyncEventRunning(this);
|
||||
if (mEventMessage != eUnidentifiedEvent) {
|
||||
MOZ_ASSERT(mComposed == Composed::eDefault);
|
||||
return nsContentUtils::DispatchTrustedEvent<WidgetEvent>
|
||||
(node->OwnerDoc(), mTarget, mEventMessage, mCanBubble,
|
||||
Cancelable::eNo, nullptr /* aDefaultAction */, mOnlyChromeDispatch);
|
||||
|
|
@ -60,6 +61,10 @@ AsyncEventDispatcher::Run()
|
|||
event->InitEvent(mEventType, mCanBubble, Cancelable::eNo);
|
||||
event->SetTrusted(true);
|
||||
}
|
||||
if (mComposed != Composed::eDefault) {
|
||||
event->WidgetEventPtr()->mFlags.mComposed =
|
||||
mComposed == Composed::eYes;
|
||||
}
|
||||
if (mOnlyChromeDispatch == ChromeOnlyDispatch::eYes) {
|
||||
MOZ_ASSERT(event->IsTrusted());
|
||||
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
|
||||
|
|
|
|||
|
|
@ -39,13 +39,15 @@ public:
|
|||
AsyncEventDispatcher(nsINode* aTarget,
|
||||
const nsAString& aEventType,
|
||||
CanBubble aCanBubble,
|
||||
ChromeOnlyDispatch aOnlyChromeDispatch)
|
||||
ChromeOnlyDispatch aOnlyChromeDispatch,
|
||||
Composed aComposed = Composed::eDefault)
|
||||
: CancelableRunnable("AsyncEventDispatcher")
|
||||
, mTarget(aTarget)
|
||||
, mEventType(aEventType)
|
||||
, mEventMessage(eUnidentifiedEvent)
|
||||
, mCanBubble(aCanBubble)
|
||||
, mOnlyChromeDispatch(aOnlyChromeDispatch)
|
||||
, mComposed(aComposed)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -121,6 +123,7 @@ public:
|
|||
EventMessage mEventMessage;
|
||||
CanBubble mCanBubble = CanBubble::eNo;
|
||||
ChromeOnlyDispatch mOnlyChromeDispatch = ChromeOnlyDispatch::eNo;
|
||||
Composed mComposed = Composed::eDefault;
|
||||
bool mCanceled = false;
|
||||
bool mCheckStillInDoc = false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -57,6 +57,13 @@ enum class Trusted
|
|||
eNo
|
||||
};
|
||||
|
||||
enum class Composed
|
||||
{
|
||||
eYes,
|
||||
eNo,
|
||||
eDefault
|
||||
};
|
||||
|
||||
/**
|
||||
* Event messages
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue