Bug 1463985 - part 9: Rename EditSubAction::insertIMEText to EditSubAction::eInsertTextComingFromIME r?m_kato
MozReview-Commit-ID: 1TmryMStB7H
--- a/editor/libeditor/EditAction.h
+++ b/editor/libeditor/EditAction.h
@@ -40,17 +40,20 @@ enum class EditSubAction : int32_t
eJoinNodes,
// eDeleteText indicates to delete some characters form a text node.
eDeleteText,
// eInsertText indicates to insert some characters.
eInsertText,
- insertIMEText,
+ // eInsertTextComingFromIME indicates to insert or update composition string
+ // with new text which is new composition string or commit string.
+ eInsertTextComingFromIME,
+
deleteSelection,
setTextProperty,
removeTextProperty,
outputText,
setText,
// HTML editor only actions
insertBreak = 3000,
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -366,17 +366,17 @@ HTMLEditRules::BeforeEdit(EditSubAction
}
if (mUtilRange) {
// Ditto for mUtilRange.
mUtilRange->Reset();
}
// Remember current inline styles for deletion and normal insertion ops
if (aEditSubAction == EditSubAction::eInsertText ||
- aEditSubAction == EditSubAction::insertIMEText ||
+ aEditSubAction == EditSubAction::eInsertTextComingFromIME ||
aEditSubAction == EditSubAction::deleteSelection ||
IsStyleCachePreservingSubAction(aEditSubAction)) {
nsCOMPtr<nsINode> selNode =
aDirection == nsIEditor::eNext ? selEndNode : selStartNode;
nsresult rv = CacheInlineStyles(selNode);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@@ -513,17 +513,17 @@ HTMLEditRules::AfterEditInner(EditSubAct
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
return NS_ERROR_EDITOR_DESTROYED;
}
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"Failed to insert <br> elements to empty list items and table cells");
// merge any adjacent text nodes
if (aEditSubAction != EditSubAction::eInsertText &&
- aEditSubAction != EditSubAction::insertIMEText) {
+ aEditSubAction != EditSubAction::eInsertTextComingFromIME) {
nsresult rv = HTMLEditorRef().CollapseAdjacentTextNodes(mDocChangeRange);
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
@@ -531,17 +531,17 @@ HTMLEditRules::AfterEditInner(EditSubAct
// clean up any empty nodes in the selection
rv = RemoveEmptyNodesInChangedRange();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// attempt to transform any unneeded nbsp's into spaces after doing various operations
if (aEditSubAction == EditSubAction::eInsertText ||
- aEditSubAction == EditSubAction::insertIMEText ||
+ aEditSubAction == EditSubAction::eInsertTextComingFromIME ||
aEditSubAction == EditSubAction::deleteSelection ||
aEditSubAction == EditSubAction::insertBreak ||
aEditSubAction == EditSubAction::htmlPaste ||
aEditSubAction == EditSubAction::loadHTML) {
rv = AdjustWhitespace();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@@ -567,30 +567,30 @@ HTMLEditRules::AfterEditInner(EditSubAct
}
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"Failed to pin selection to the new block");
mNewBlock = nullptr;
}
// adjust selection for insert text, html paste, and delete actions
if (aEditSubAction == EditSubAction::eInsertText ||
- aEditSubAction == EditSubAction::insertIMEText ||
+ aEditSubAction == EditSubAction::eInsertTextComingFromIME ||
aEditSubAction == EditSubAction::deleteSelection ||
aEditSubAction == EditSubAction::insertBreak ||
aEditSubAction == EditSubAction::htmlPaste ||
aEditSubAction == EditSubAction::loadHTML) {
rv = AdjustSelection(aDirection);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
// check for any styles which were removed inappropriately
if (aEditSubAction == EditSubAction::eInsertText ||
- aEditSubAction == EditSubAction::insertIMEText ||
+ aEditSubAction == EditSubAction::eInsertTextComingFromIME ||
aEditSubAction == EditSubAction::deleteSelection ||
IsStyleCachePreservingSubAction(aEditSubAction)) {
HTMLEditorRef().mTypeInState->UpdateSelState(&SelectionRef());
rv = ReapplyCachedStyles();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
ClearCachedStyles();
@@ -676,17 +676,17 @@ HTMLEditRules::WillDoAction(Selection* a
if (!HTMLEditorRef().IsModifiableNode(range->GetCommonAncestor())) {
*aCancel = true;
return NS_OK;
}
}
switch (aInfo.mEditSubAction) {
case EditSubAction::eInsertText:
- case EditSubAction::insertIMEText:
+ case EditSubAction::eInsertTextComingFromIME:
UndefineCaretBidiLevel();
return WillInsertText(aInfo.mEditSubAction, aCancel, aHandled,
aInfo.inString, aInfo.outString,
aInfo.maxLength);
case EditSubAction::loadHTML:
return WillLoadHTML();
case EditSubAction::insertBreak:
UndefineCaretBidiLevel();
@@ -753,17 +753,17 @@ HTMLEditRules::DidDoAction(Selection* aS
return NS_ERROR_EDITOR_DESTROYED;
}
AutoSafeEditorData setData(*this, *mHTMLEditor, *aSelection);
switch (aInfo.mEditSubAction) {
case EditSubAction::eInsertText:
case EditSubAction::insertBreak:
- case EditSubAction::insertIMEText:
+ case EditSubAction::eInsertTextComingFromIME:
return NS_OK;
case EditSubAction::deleteSelection:
return DidDeleteSelection();
case EditSubAction::makeBasicBlock:
case EditSubAction::indent:
case EditSubAction::outdent:
case EditSubAction::align:
return DidMakeBasicBlock();
@@ -1410,17 +1410,17 @@ HTMLEditRules::WillInsert(bool* aCancel)
if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult();
}
}
}
if (mDidDeleteSelection &&
(mTopLevelEditSubAction == EditSubAction::eInsertText ||
- mTopLevelEditSubAction == EditSubAction::insertIMEText ||
+ mTopLevelEditSubAction == EditSubAction::eInsertTextComingFromIME ||
mTopLevelEditSubAction == EditSubAction::deleteSelection)) {
nsresult rv = ReapplyCachedStyles();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
// For most actions we want to clear the cached styles, but there are
// exceptions
@@ -1494,17 +1494,17 @@ HTMLEditRules::WillInsertText(EditSubAct
// dont put text in places that can't have it
if (!EditorBase::IsTextNode(pointToInsert.GetContainer()) &&
!HTMLEditorRef().CanContainTag(*pointToInsert.GetContainer(),
*nsGkAtoms::textTagName)) {
return NS_ERROR_FAILURE;
}
- if (aEditSubAction == EditSubAction::insertIMEText) {
+ if (aEditSubAction == EditSubAction::eInsertTextComingFromIME) {
// Right now the WSRunObject code bails on empty strings, but IME needs
// the InsertTextWithTransaction() call to still happen since empty strings
// are meaningful there.
// If there is one or more IME selections, its minimum offset should be
// the insertion point.
int32_t IMESelectionOffset =
HTMLEditorRef().GetIMESelectionStartOffsetIn(
pointToInsert.GetContainer());
@@ -7126,17 +7126,17 @@ HTMLEditRules::GetPromotedPoint(RulesEnd
int32_t aOffset,
EditSubAction aEditSubAction)
{
MOZ_ASSERT(IsEditorDataAvailable());
// we do one thing for text actions, something else entirely for other
// actions
if (aEditSubAction == EditSubAction::eInsertText ||
- aEditSubAction == EditSubAction::insertIMEText ||
+ aEditSubAction == EditSubAction::eInsertTextComingFromIME ||
aEditSubAction == EditSubAction::insertBreak ||
aEditSubAction == EditSubAction::eDeleteText) {
bool isSpace, isNBSP;
nsCOMPtr<nsIContent> content =
aNode.IsContent() ? aNode.AsContent() : nullptr;
nsCOMPtr<nsIContent> temp;
int32_t newOffset = aOffset;
// for text actions, we want to look backwards (or forwards, as
@@ -7375,17 +7375,17 @@ HTMLEditRules::PromoteRange(nsRange& aRa
endNode = block;
startOffset = 0;
endOffset = block->Length();
}
}
}
if (aEditSubAction == EditSubAction::eInsertText ||
- aEditSubAction == EditSubAction::insertIMEText ||
+ aEditSubAction == EditSubAction::eInsertTextComingFromIME ||
aEditSubAction == EditSubAction::insertBreak ||
aEditSubAction == EditSubAction::eDeleteText) {
if (!startNode->IsContent() ||
!endNode->IsContent()) {
// GetPromotedPoint cannot promote node when action type is text
// operation and selected node isn't content node.
return;
}
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -182,18 +182,18 @@ protected:
*/
MOZ_MUST_USE nsresult WillInsert(bool* aCancel = nullptr);
/**
* Called before inserting text.
* This method may actually inserts text into the editor. Therefore, this
* might cause destroying the editor.
*
- * @param aEditSubAction Must be EditSubAction::insertIMEText or
- * EditSubAction::eInsertText.
+ * @param aEditSubAction Must be EditSubAction::eInsertTextComingFromIME
+ * or EditSubAction::eInsertText.
* @param aCancel Returns true if the operation is canceled.
* @param aHandled Returns true if the edit action is handled.
* @param inString String to be inserted.
* @param outString String actually inserted.
* @param aMaxLength The maximum string length which the editor
* allows to set.
*/
MOZ_MUST_USE nsresult
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -326,17 +326,17 @@ TextEditRules::WillDoAction(Selection* a
AutoSafeEditorData setData(*this, *mTextEditor, *aSelection);
// my kingdom for dynamic cast
switch (aInfo.mEditSubAction) {
case EditSubAction::insertBreak:
UndefineCaretBidiLevel();
return WillInsertBreak(aCancel, aHandled, aInfo.maxLength);
case EditSubAction::eInsertText:
- case EditSubAction::insertIMEText:
+ case EditSubAction::eInsertTextComingFromIME:
UndefineCaretBidiLevel();
return WillInsertText(aInfo.mEditSubAction, aCancel, aHandled,
aInfo.inString, aInfo.outString,
aInfo.maxLength);
case EditSubAction::setText:
UndefineCaretBidiLevel();
return WillSetText(aCancel, aHandled, aInfo.inString,
aInfo.maxLength);
@@ -676,17 +676,18 @@ TextEditRules::WillInsertText(EditSubAct
int32_t aMaxLength)
{
MOZ_ASSERT(IsEditorDataAvailable());
if (NS_WARN_IF(!aCancel) || NS_WARN_IF(!aHandled)) {
return NS_ERROR_INVALID_ARG;
}
- if (inString->IsEmpty() && aEditSubAction != EditSubAction::insertIMEText) {
+ if (inString->IsEmpty() &&
+ aEditSubAction != EditSubAction::eInsertTextComingFromIME) {
// HACK: this is a fix for bug 19395
// I can't outlaw all empty insertions
// because IME transaction depend on them
// There is more work to do to make the
// world safe for IME.
*aCancel = true;
*aHandled = false;
return NS_OK;
@@ -702,17 +703,17 @@ TextEditRules::WillInsertText(EditSubAct
nsresult rv =
TruncateInsertionIfNeeded(inString, outString, aMaxLength, &truncated);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// If we're exceeding the maxlength when composing IME, we need to clean up
// the composing text, so we shouldn't return early.
if (truncated && outString->IsEmpty() &&
- aEditSubAction != EditSubAction::insertIMEText) {
+ aEditSubAction != EditSubAction::eInsertTextComingFromIME) {
*aCancel = true;
return NS_OK;
}
uint32_t start = 0;
uint32_t end = 0;
// handle password field docs
@@ -738,17 +739,17 @@ TextEditRules::WillInsertText(EditSubAct
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// handle password field data
// this has the side effect of changing all the characters in aOutString
// to the replacement character
if (IsPasswordEditor() &&
- aEditSubAction == EditSubAction::insertIMEText) {
+ aEditSubAction == EditSubAction::eInsertTextComingFromIME) {
RemoveIMETextFromPWBuf(start, outString);
}
// People have lots of different ideas about what text fields
// should do with multiline pastes. See bugs 21032, 23485, 23485, 50935.
// The six possible options are:
// 0. paste newlines intact
// 1. paste up to the first newline (default)
@@ -805,17 +806,17 @@ TextEditRules::WillInsertText(EditSubAct
}
// we need to get the doc
nsCOMPtr<nsIDocument> doc = TextEditorRef().GetDocument();
if (NS_WARN_IF(!doc)) {
return NS_ERROR_NOT_INITIALIZED;
}
- if (aEditSubAction == EditSubAction::insertIMEText) {
+ if (aEditSubAction == EditSubAction::eInsertTextComingFromIME) {
// Find better insertion point to insert text.
EditorRawDOMPoint betterInsertionPoint =
TextEditorRef().FindBetterInsertionPoint(atStartOfSelection);
// If there is one or more IME selections, its minimum offset should be
// the insertion point.
int32_t IMESelectionOffset =
TextEditorRef().GetIMESelectionStartOffsetIn(
betterInsertionPoint.GetContainer());
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -150,18 +150,18 @@ protected:
// TextEditRules implementation methods
/**
* Called before inserting text.
* This method may actually inserts text into the editor. Therefore, this
* might cause destroying the editor.
*
- * @param aEditSubAction Must be EditSubAction::insertIMEText or
- * EditSubAction::eInsertText.
+ * @param aEditSubAction Must be EditSubAction::eInsertTextComingFromIME
+ * or EditSubAction::eInsertText.
* @param aCancel Returns true if the operation is canceled.
* @param aHandled Returns true if the edit action is handled.
* @param inString String to be inserted.
* @param outString String actually inserted.
* @param aMaxLength The maximum string length which the editor
* allows to set.
*/
MOZ_MUST_USE nsresult
@@ -530,17 +530,17 @@ public:
, entireList(false)
, bulletType(nullptr)
, alignType(nullptr)
, blockType(nullptr)
{}
EditSubAction mEditSubAction;
- // EditSubAction::eInsertText / EditSubAction::insertIMEText
+ // EditSubAction::eInsertText / EditSubAction::eInsertTextComingFromIME
const nsAString* inString;
nsAString* outString;
const nsAString* outputFormat;
int32_t maxLength;
// EditSubAction::outputText
uint32_t flags;
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -945,17 +945,19 @@ TextEditor::InsertTextAsAction(const nsA
return NS_ERROR_NOT_INITIALIZED;
}
// Protect the edit rules object from dying
RefPtr<TextEditRules> rules(mRules);
EditSubAction editSubAction = EditSubAction::eInsertText;
if (ShouldHandleIMEComposition()) {
- editSubAction = EditSubAction::insertIMEText;
+ // So, the string must come from IME as new composition string or
+ // commit string.
+ editSubAction = EditSubAction::eInsertTextComingFromIME;
}
AutoPlaceholderBatch batch(this, nullptr);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
*this, editSubAction, nsIEditor::eNext);
RefPtr<Selection> selection = GetSelection();
if (NS_WARN_IF(!selection)) {
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -123,17 +123,17 @@ mozInlineSpellStatus::InitForEditorChang
// save the anchor point as a range so we can find the current word later
mAnchorRange = PositionToCollapsedRange(aAnchorNode, aAnchorOffset);
if (NS_WARN_IF(!mAnchorRange)) {
return NS_ERROR_FAILURE;
}
bool deleted = aEditSubAction == EditSubAction::deleteSelection;
- if (aEditSubAction == EditSubAction::insertIMEText) {
+ if (aEditSubAction == EditSubAction::eInsertTextComingFromIME) {
// IME may remove the previous node if it cancels composition when
// there is no text around the composition.
deleted = !aPreviousNode->IsInComposedDoc();
}
if (deleted) {
// Deletes are easy, the range is just the current anchor. We set the range
// to check to be empty, FinishInitOnEvent will fill in the range to be