зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1539884 - Part 20: Mark XULBroadcastManager::ExecuteOnBroadcastHandlerFor as CAN_RUN_SCRIPT r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D134111
This commit is contained in:
Родитель
593535bad1
Коммит
d99a294a3b
|
@ -87,8 +87,8 @@ class XULBroadcastManager::nsDelayedBroadcastUpdate {
|
|||
nsDelayedBroadcastUpdate(const nsDelayedBroadcastUpdate& aOther) = delete;
|
||||
nsDelayedBroadcastUpdate(nsDelayedBroadcastUpdate&& aOther) = default;
|
||||
|
||||
nsCOMPtr<Element> mBroadcaster;
|
||||
nsCOMPtr<Element> mListener;
|
||||
RefPtr<Element> mBroadcaster;
|
||||
RefPtr<Element> mListener;
|
||||
// Note if mAttrName isn't used, this is the name of the attr, otherwise
|
||||
// this is the value of the attribute.
|
||||
nsString mAttr;
|
||||
|
@ -300,7 +300,7 @@ nsresult XULBroadcastManager::ExecuteOnBroadcastHandlerFor(
|
|||
// observer. We need to find the observer in order to
|
||||
// execute the handler.
|
||||
|
||||
for (nsIContent* child = aListener->GetFirstChild(); child;
|
||||
for (nsCOMPtr<nsIContent> child = aListener->GetFirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
// Look for an <observes> element beneath the listener. This
|
||||
// ought to have an |element| attribute that refers to
|
||||
|
@ -333,8 +333,7 @@ nsresult XULBroadcastManager::ExecuteOnBroadcastHandlerFor(
|
|||
// |onbroadcast| event handler
|
||||
WidgetEvent event(true, eXULBroadcast);
|
||||
|
||||
RefPtr<nsPresContext> presContext = mDocument->GetPresContext();
|
||||
if (presContext) {
|
||||
if (RefPtr<nsPresContext> presContext = mDocument->GetPresContext()) {
|
||||
// Handle the DOM event
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
EventDispatcher::Dispatch(child, presContext, &event, nullptr, &status);
|
||||
|
@ -416,10 +415,9 @@ void XULBroadcastManager::MaybeBroadcast() {
|
|||
if (!mHandlingDelayedAttrChange) {
|
||||
mHandlingDelayedAttrChange = true;
|
||||
for (uint32_t i = 0; i < mDelayedAttrChangeBroadcasts.Length(); ++i) {
|
||||
nsAtom* attrName = mDelayedAttrChangeBroadcasts[i].mAttrName;
|
||||
RefPtr<nsAtom> attrName = mDelayedAttrChangeBroadcasts[i].mAttrName;
|
||||
RefPtr<Element> listener = mDelayedAttrChangeBroadcasts[i].mListener;
|
||||
if (mDelayedAttrChangeBroadcasts[i].mNeedsAttrChange) {
|
||||
nsCOMPtr<Element> listener =
|
||||
mDelayedAttrChangeBroadcasts[i].mListener;
|
||||
const nsString& value = mDelayedAttrChangeBroadcasts[i].mAttr;
|
||||
if (mDelayedAttrChangeBroadcasts[i].mSetAttr) {
|
||||
listener->SetAttr(kNameSpaceID_None, attrName, value, true);
|
||||
|
@ -427,9 +425,9 @@ void XULBroadcastManager::MaybeBroadcast() {
|
|||
listener->UnsetAttr(kNameSpaceID_None, attrName, true);
|
||||
}
|
||||
}
|
||||
ExecuteOnBroadcastHandlerFor(
|
||||
mDelayedAttrChangeBroadcasts[i].mBroadcaster,
|
||||
mDelayedAttrChangeBroadcasts[i].mListener, attrName);
|
||||
RefPtr<Element> broadcaster =
|
||||
mDelayedAttrChangeBroadcasts[i].mBroadcaster;
|
||||
ExecuteOnBroadcastHandlerFor(broadcaster, listener, attrName);
|
||||
}
|
||||
mDelayedAttrChangeBroadcasts.Clear();
|
||||
mHandlingDelayedAttrChange = false;
|
||||
|
|
|
@ -40,7 +40,8 @@ class XULBroadcastManager final {
|
|||
nsresult RemoveListener(Element* aElement);
|
||||
void AttributeChanged(Element* aElement, int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute);
|
||||
void MaybeBroadcast();
|
||||
// TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230)
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void MaybeBroadcast();
|
||||
void DropDocumentReference(); // notification that doc is going away
|
||||
protected:
|
||||
enum HookupAction { eHookupAdd = 0, eHookupRemove };
|
||||
|
@ -52,8 +53,8 @@ class XULBroadcastManager final {
|
|||
void AddListenerFor(Element& aBroadcaster, Element& aListener,
|
||||
const nsAString& aAttr, ErrorResult& aRv);
|
||||
|
||||
nsresult ExecuteOnBroadcastHandlerFor(Element* aBroadcaster,
|
||||
Element* aListener, nsAtom* aAttr);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult ExecuteOnBroadcastHandlerFor(
|
||||
Element* aBroadcaster, Element* aListener, nsAtom* aAttr);
|
||||
// The out params of FindBroadcaster only have values that make sense when
|
||||
// the method returns NS_FINDBROADCASTER_FOUND. In all other cases, the
|
||||
// values of the out params should not be relied on (though *aListener and
|
||||
|
|
Загрузка…
Ссылка в новой задаче