Bug 1504911 - part 1: Make all "input" event dispatcher in C++ use new utility method r=smaug

Currently, a lot of code dispatch "input" event and some of them dispatch
"input" event with wrong interface and/or values.  Therefore this patch
creates nsContentUtils::DispatchInputEvent() to make all of them dispatch
correct event.

Unfortunately, due to bug 1506439, we cannot set pointer to refcountable
classes of MOZ_CAN_RUN_SCRIPT method to nullptr.  Therefore, this patch
creates temporary RefPtr<TextEditor> a lot even though it makes damage to
the performance if it's in a hot path.

This patch makes eEditorInput event dispatched with
InternalEditorInputEvent when "input" event should be dispatched with
dom::InputEvent.  However, this patch uses WidgetEvent whose message is
eUnidentifiedEvent and setting WidgetEvent::mSpecifiedEventType to
nsGkAtoms::oninput when "input" event should be dispatched with
dom::Event because we need to keep that eEditorInput and
InternalEditorInputEvent are mapped each other.

Differential Revision: https://phabricator.services.mozilla.com/D12244
This commit is contained in:
Masayuki Nakano
2018-11-21 03:59:02 +00:00
parent 1b7485d093
commit 8496847b12
30 changed files with 304 additions and 173 deletions

View File

@@ -187,12 +187,18 @@ public:
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
virtual nsresult PreHandleEvent(EventChainVisitor& aVisitor) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY
void PostHandleEventForRangeThumb(EventChainPostVisitor& aVisitor);
MOZ_CAN_RUN_SCRIPT
void StartRangeThumbDrag(WidgetGUIEvent* aEvent);
MOZ_CAN_RUN_SCRIPT
void FinishRangeThumbDrag(WidgetGUIEvent* aEvent = nullptr);
MOZ_CAN_RUN_SCRIPT
void CancelRangeThumbDrag(bool aIsForUserEvent = true);
MOZ_CAN_RUN_SCRIPT
void SetValueOfRangeForUserEvent(Decimal aValue);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
@@ -223,6 +229,7 @@ public:
NS_IMETHOD_(bool) ValueChanged() const override;
NS_IMETHOD_(void) GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const override;
NS_IMETHOD_(mozilla::TextEditor*) GetTextEditor() override;
NS_IMETHOD_(mozilla::TextEditor*) GetTextEditorWithoutCreation() override;
NS_IMETHOD_(nsISelectionController*) GetSelectionController() override;
NS_IMETHOD_(nsFrameSelection*) GetConstFrameSelection() override;
NS_IMETHOD BindToFrame(nsTextControlFrame* aFrame) override;
@@ -891,12 +898,14 @@ public:
};
void StopNumberControlSpinnerSpin(SpinnerStopState aState =
eAllowDispatchingEvents);
MOZ_CAN_RUN_SCRIPT
void StepNumberControlForUserEvent(int32_t aDirection);
/**
* The callback function used by the nsRepeatService that we use to spin the
* spinner for <input type=number>.
*/
MOZ_CAN_RUN_SCRIPT_BOUNDARY
static void HandleNumberControlSpin(void* aData);
bool NumberSpinnerUpButtonIsDepressed() const
@@ -916,6 +925,7 @@ public:
*/
nsIEditor* GetEditor();
MOZ_CAN_RUN_SCRIPT_BOUNDARY
void SetUserInput(const nsAString& aInput,
nsIPrincipal& aSubjectPrincipal);
@@ -1054,6 +1064,7 @@ protected:
/**
* Called when an attribute has just been changed
*/
MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
@@ -1180,6 +1191,7 @@ protected:
/**
* Manages the internal data storage across type changes.
*/
MOZ_CAN_RUN_SCRIPT
void HandleTypeChange(uint8_t aNewType, bool aNotify);
/**