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);
|
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.
|
* 6. Return shadow.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ AsyncEventDispatcher::Run()
|
||||||
}
|
}
|
||||||
mTarget->AsyncEventRunning(this);
|
mTarget->AsyncEventRunning(this);
|
||||||
if (mEventMessage != eUnidentifiedEvent) {
|
if (mEventMessage != eUnidentifiedEvent) {
|
||||||
|
MOZ_ASSERT(mComposed == Composed::eDefault);
|
||||||
return nsContentUtils::DispatchTrustedEvent<WidgetEvent>
|
return nsContentUtils::DispatchTrustedEvent<WidgetEvent>
|
||||||
(node->OwnerDoc(), mTarget, mEventMessage, mCanBubble,
|
(node->OwnerDoc(), mTarget, mEventMessage, mCanBubble,
|
||||||
Cancelable::eNo, nullptr /* aDefaultAction */, mOnlyChromeDispatch);
|
Cancelable::eNo, nullptr /* aDefaultAction */, mOnlyChromeDispatch);
|
||||||
|
|
@ -60,6 +61,10 @@ AsyncEventDispatcher::Run()
|
||||||
event->InitEvent(mEventType, mCanBubble, Cancelable::eNo);
|
event->InitEvent(mEventType, mCanBubble, Cancelable::eNo);
|
||||||
event->SetTrusted(true);
|
event->SetTrusted(true);
|
||||||
}
|
}
|
||||||
|
if (mComposed != Composed::eDefault) {
|
||||||
|
event->WidgetEventPtr()->mFlags.mComposed =
|
||||||
|
mComposed == Composed::eYes;
|
||||||
|
}
|
||||||
if (mOnlyChromeDispatch == ChromeOnlyDispatch::eYes) {
|
if (mOnlyChromeDispatch == ChromeOnlyDispatch::eYes) {
|
||||||
MOZ_ASSERT(event->IsTrusted());
|
MOZ_ASSERT(event->IsTrusted());
|
||||||
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
|
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,15 @@ public:
|
||||||
AsyncEventDispatcher(nsINode* aTarget,
|
AsyncEventDispatcher(nsINode* aTarget,
|
||||||
const nsAString& aEventType,
|
const nsAString& aEventType,
|
||||||
CanBubble aCanBubble,
|
CanBubble aCanBubble,
|
||||||
ChromeOnlyDispatch aOnlyChromeDispatch)
|
ChromeOnlyDispatch aOnlyChromeDispatch,
|
||||||
|
Composed aComposed = Composed::eDefault)
|
||||||
: CancelableRunnable("AsyncEventDispatcher")
|
: CancelableRunnable("AsyncEventDispatcher")
|
||||||
, mTarget(aTarget)
|
, mTarget(aTarget)
|
||||||
, mEventType(aEventType)
|
, mEventType(aEventType)
|
||||||
, mEventMessage(eUnidentifiedEvent)
|
, mEventMessage(eUnidentifiedEvent)
|
||||||
, mCanBubble(aCanBubble)
|
, mCanBubble(aCanBubble)
|
||||||
, mOnlyChromeDispatch(aOnlyChromeDispatch)
|
, mOnlyChromeDispatch(aOnlyChromeDispatch)
|
||||||
|
, mComposed(aComposed)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,6 +123,7 @@ public:
|
||||||
EventMessage mEventMessage;
|
EventMessage mEventMessage;
|
||||||
CanBubble mCanBubble = CanBubble::eNo;
|
CanBubble mCanBubble = CanBubble::eNo;
|
||||||
ChromeOnlyDispatch mOnlyChromeDispatch = ChromeOnlyDispatch::eNo;
|
ChromeOnlyDispatch mOnlyChromeDispatch = ChromeOnlyDispatch::eNo;
|
||||||
|
Composed mComposed = Composed::eDefault;
|
||||||
bool mCanceled = false;
|
bool mCanceled = false;
|
||||||
bool mCheckStillInDoc = false;
|
bool mCheckStillInDoc = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,13 @@ enum class Trusted
|
||||||
eNo
|
eNo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class Composed
|
||||||
|
{
|
||||||
|
eYes,
|
||||||
|
eNo,
|
||||||
|
eDefault
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event messages
|
* Event messages
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue