Bug 1470930: Use enums for passing arguments for event dispatch. r=smaug

MozReview-Commit-ID: DsNuF7GAflJ
This commit is contained in:
Emilio Cobos Álvarez
2018-06-25 18:23:50 +02:00
parent fa36e67ff5
commit 0348c342b8
73 changed files with 438 additions and 277 deletions

View File

@@ -257,14 +257,16 @@ public:
nsresult rv = NS_OK;
rv = nsContentUtils::DispatchTrustedEvent(mInputElement->OwnerDoc(),
static_cast<Element*>(mInputElement.get()),
NS_LITERAL_STRING("input"), true,
false);
NS_LITERAL_STRING("input"),
CanBubble::eYes,
Cancelable::eNo);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
rv = nsContentUtils::DispatchTrustedEvent(mInputElement->OwnerDoc(),
static_cast<Element*>(mInputElement.get()),
NS_LITERAL_STRING("change"), true,
false);
NS_LITERAL_STRING("change"),
CanBubble::eYes,
Cancelable::eNo);
return rv;
}
@@ -636,8 +638,9 @@ nsColorPickerShownCallback::UpdateInternal(const nsAString& aColor,
mValueChanged = true;
return nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
static_cast<Element*>(mInput.get()),
NS_LITERAL_STRING("input"), true,
false);
NS_LITERAL_STRING("input"),
CanBubble::eYes,
Cancelable::eNo);
}
return NS_OK;
@@ -670,8 +673,9 @@ nsColorPickerShownCallback::Done(const nsAString& aColor)
if (mValueChanged) {
rv = nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
static_cast<Element*>(mInput.get()),
NS_LITERAL_STRING("change"), true,
false);
NS_LITERAL_STRING("change"),
CanBubble::eYes,
Cancelable::eNo);
}
return rv;
@@ -2254,7 +2258,8 @@ HTMLInputElement::OpenDateTimePicker(const DateTimeValue& aInitialValue)
nsContentUtils::DispatchChromeEvent(OwnerDoc(),
static_cast<Element*>(this),
NS_LITERAL_STRING("MozOpenDateTimePicker"),
true, true);
CanBubble::eYes,
Cancelable::eYes);
}
void
@@ -2268,7 +2273,8 @@ HTMLInputElement::UpdateDateTimePicker(const DateTimeValue& aValue)
nsContentUtils::DispatchChromeEvent(OwnerDoc(),
static_cast<Element*>(this),
NS_LITERAL_STRING("MozUpdateDateTimePicker"),
true, true);
CanBubble::eYes,
Cancelable::eYes);
}
void
@@ -2281,7 +2287,7 @@ HTMLInputElement::CloseDateTimePicker()
nsContentUtils::DispatchChromeEvent(OwnerDoc(),
static_cast<Element*>(this),
NS_LITERAL_STRING("MozCloseDateTimePicker"),
true, true);
CanBubble::eYes, Cancelable::eYes);
}
void
@@ -2365,10 +2371,13 @@ HTMLInputElement::SetUserInput(const nsAString& aValue,
nsTextEditorState::eSetValue_MoveCursorToEndIfValueChanged);
NS_ENSURE_SUCCESS_VOID(rv);
// FIXME: We're inconsistent about whether "input" events are cancelable or
// not.
nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
static_cast<Element*>(this),
NS_LITERAL_STRING("input"), true,
true);
NS_LITERAL_STRING("input"),
CanBubble::eYes,
Cancelable::eYes);
// If this element is not currently focused, it won't receive a change event for this
// update through the normal channels. So fire a change event immediately, instead.
@@ -2695,8 +2704,9 @@ HTMLInputElement::FireChangeEventIfNeeded()
mFocusedValue = value;
nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
static_cast<nsIContent*>(this),
NS_LITERAL_STRING("change"), true,
false);
NS_LITERAL_STRING("change"),
CanBubble::eYes,
Cancelable::eNo);
}
FileList*
@@ -3753,7 +3763,10 @@ HTMLInputElement::CancelRangeThumbDrag(bool aIsForUserEvent)
frame->UpdateForValueChange();
}
RefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(this, NS_LITERAL_STRING("input"), true, false);
new AsyncEventDispatcher(this,
NS_LITERAL_STRING("input"),
CanBubble::eYes,
ChromeOnlyDispatch::eNo);
asyncDispatcher->RunDOMEventWhenSafe();
}
}
@@ -3779,8 +3792,9 @@ HTMLInputElement::SetValueOfRangeForUserEvent(Decimal aValue)
if (GetValueAsDecimal() != oldValue) {
nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
static_cast<Element*>(this),
NS_LITERAL_STRING("input"), true,
false);
NS_LITERAL_STRING("input"),
CanBubble::eYes,
Cancelable::eNo);
}
}
@@ -3877,8 +3891,9 @@ HTMLInputElement::StepNumberControlForUserEvent(int32_t aDirection)
nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
static_cast<Element*>(this),
NS_LITERAL_STRING("input"), true,
false);
NS_LITERAL_STRING("input"),
CanBubble::eYes,
Cancelable::eNo);
}
static bool
@@ -4089,11 +4104,11 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
// Fire input event and then change event.
nsContentUtils::DispatchTrustedEvent<InternalEditorInputEvent>
(OwnerDoc(), static_cast<Element*>(this),
eEditorInput, true, false);
eEditorInput, CanBubble::eYes, Cancelable::eNo);
nsContentUtils::DispatchTrustedEvent<WidgetEvent>
(OwnerDoc(), static_cast<Element*>(this),
eFormChange, true, false);
eFormChange, CanBubble::eYes, Cancelable::eNo);
#ifdef ACCESSIBILITY
// Fire an event to notify accessibility
if (mType == NS_FORM_INPUT_CHECKBOX) {
@@ -4646,8 +4661,8 @@ HTMLInputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
AsyncEventDispatcher* dispatcher =
new AsyncEventDispatcher(this,
NS_LITERAL_STRING("DOMInputPasswordAdded"),
true,
true);
CanBubble::eYes,
ChromeOnlyDispatch::eYes);
dispatcher->PostDOMEvent();
}
@@ -4835,8 +4850,8 @@ HTMLInputElement::HandleTypeChange(uint8_t aNewType, bool aNotify)
AsyncEventDispatcher* dispatcher =
new AsyncEventDispatcher(this,
NS_LITERAL_STRING("DOMInputPasswordAdded"),
true,
true);
CanBubble::eYes,
ChromeOnlyDispatch::eYes);
dispatcher->PostDOMEvent();
}
}
@@ -6005,7 +6020,8 @@ FireEventForAccessibility(HTMLInputElement* aTarget,
{
Element* element = static_cast<Element*>(aTarget);
return nsContentUtils::DispatchTrustedEvent<WidgetEvent>
(element->OwnerDoc(), element, aEventMessage, true, true);
(element->OwnerDoc(), element, aEventMessage,
CanBubble::eYes, Cancelable::eYes);
}
#endif