Bug 1599971 - part 5: Mark TextControlState::UnbindFromFrame() as MOZ_CAN_RUN_SCRIPT r=m_kato,emilio

Note that `TextControlState::BindToFrame()` may also run script if it's
called without script blocker.  However, it shouldn't occur.  Therefore,
we don't need to mark it `MOZ_CAN_RUN_SCRIPT`, but we should check
script blocker existence with `MOZ_ASSERT`.

Differential Revision: https://phabricator.services.mozilla.com/D55776
This commit is contained in:
Masayuki Nakano
2019-12-11 03:04:20 +00:00
parent d217c0e1ac
commit 33564b47db
9 changed files with 28 additions and 9 deletions

View File

@@ -1080,6 +1080,7 @@ enum class TextControlAction {
SetRangeText,
SetSelectionRange,
SetValue,
UnbindFromFrame,
Unlink,
};
@@ -1545,7 +1546,7 @@ class PrepareEditorEvent : public Runnable {
aState.mValueTransferInProgress = true;
}
NS_IMETHOD Run() override {
MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD Run() override {
if (NS_WARN_IF(!mState)) {
return NS_ERROR_NULL_POINTER;
}
@@ -1572,6 +1573,9 @@ class PrepareEditorEvent : public Runnable {
};
nsresult TextControlState::BindToFrame(nsTextControlFrame* aFrame) {
MOZ_ASSERT(
!nsContentUtils::IsSafeToRunScript(),
"TextControlState::BindToFrame() has to be called with script blocker");
NS_ASSERTION(aFrame, "The frame to bind to should be valid");
if (!aFrame) {
return NS_ERROR_INVALID_ARG;
@@ -2399,6 +2403,9 @@ void TextControlState::UnbindFromFrame(nsTextControlFrame* aFrame) {
return;
}
AutoTextControlHandlingState handlingUnbindFromFrame(
*this, TextControlAction::UnbindFromFrame);
// We need to start storing the value outside of the editor if we're not
// going to use it anymore, so retrieve it for now.
nsAutoString value;