Bug 1463985 - part 23: Rename EditSubAction::htmlPaste and EditSubAction::loadHTML to EditSubAction::ePasteHTMLContent and EditSubAction::eInsertHTMLSource r?m_kato
MozReview-Commit-ID: B1Ag1yP5PXl
--- a/editor/libeditor/EditAction.h
+++ b/editor/libeditor/EditAction.h
@@ -94,18 +94,23 @@ enum class EditSubAction : int32_t
eCreateOrChangeDefinitionList,
// eInsertElement indicates to insert an element.
eInsertElement,
// eInsertQuotation indicates to insert an element and make it "quoted text".
eInsertQuotation,
- htmlPaste = 3012,
- loadHTML,
+ // ePasteHTMLContent indicates to paste HTML content in clipboard.
+ ePasteHTMLContent,
+
+ // eInsertHTMLSource indicates to create a document fragment from given HTML
+ // source and insert into the DOM tree. So, this is similar to innerHTML.
+ eInsertHTMLSource,
+
resetTextProperties,
setAbsolutePosition,
removeAbsolutePosition,
decreaseZIndex,
increaseZIndex,
};
} // namespace mozilla
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -493,19 +493,19 @@ HTMLEditRules::AfterEditInner(EditSubAct
AutoTransactionsConserveSelection dontChangeMySelection(&HTMLEditorRef());
// expand the "changed doc range" as needed
PromoteRange(*mDocChangeRange, aEditSubAction);
// if we did a ranged deletion or handling backspace key, make sure we have
// a place to put caret.
// Note we only want to do this if the overall operation was deletion,
- // not if deletion was done along the way for EditSubAction::loadHTML,
- // EditSubAction::eInsertText, etc. That's why this is here rather than
- // DidDeleteSelection().
+ // not if deletion was done along the way for
+ // EditSubAction::eInsertHTMLSource, EditSubAction::eInsertText, etc.
+ // That's why this is here rather than DidDeleteSelection().
if (aEditSubAction == EditSubAction::eDeleteSelectedContent &&
mDidRangedDelete) {
nsresult rv = InsertBRIfNeeded();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
@@ -535,18 +535,18 @@ HTMLEditRules::AfterEditInner(EditSubAct
return rv;
}
// attempt to transform any unneeded nbsp's into spaces after doing various operations
if (aEditSubAction == EditSubAction::eInsertText ||
aEditSubAction == EditSubAction::eInsertTextComingFromIME ||
aEditSubAction == EditSubAction::eDeleteSelectedContent ||
aEditSubAction == EditSubAction::eInsertParagraphSeparator ||
- aEditSubAction == EditSubAction::htmlPaste ||
- aEditSubAction == EditSubAction::loadHTML) {
+ aEditSubAction == EditSubAction::ePasteHTMLContent ||
+ aEditSubAction == EditSubAction::eInsertHTMLSource) {
rv = AdjustWhitespace();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// also do this for original selection endpoints.
NS_ENSURE_STATE(mRangeItem->mStartContainer);
NS_ENSURE_STATE(mRangeItem->mEndContainer);
@@ -571,18 +571,18 @@ HTMLEditRules::AfterEditInner(EditSubAct
mNewBlock = nullptr;
}
// adjust selection for insert text, html paste, and delete actions
if (aEditSubAction == EditSubAction::eInsertText ||
aEditSubAction == EditSubAction::eInsertTextComingFromIME ||
aEditSubAction == EditSubAction::eDeleteSelectedContent ||
aEditSubAction == EditSubAction::eInsertParagraphSeparator ||
- aEditSubAction == EditSubAction::htmlPaste ||
- aEditSubAction == EditSubAction::loadHTML) {
+ aEditSubAction == EditSubAction::ePasteHTMLContent ||
+ aEditSubAction == EditSubAction::eInsertHTMLSource) {
rv = AdjustSelection(aDirection);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
// check for any styles which were removed inappropriately
if (aEditSubAction == EditSubAction::eInsertText ||
@@ -682,17 +682,17 @@ HTMLEditRules::WillDoAction(Selection* a
switch (aInfo.mEditSubAction) {
case EditSubAction::eInsertText:
case EditSubAction::eInsertTextComingFromIME:
UndefineCaretBidiLevel();
return WillInsertText(aInfo.mEditSubAction, aCancel, aHandled,
aInfo.inString, aInfo.outString,
aInfo.maxLength);
- case EditSubAction::loadHTML:
+ case EditSubAction::eInsertHTMLSource:
return WillLoadHTML();
case EditSubAction::eInsertParagraphSeparator:
UndefineCaretBidiLevel();
return WillInsertBreak(aCancel, aHandled);
case EditSubAction::eDeleteSelectedContent:
return WillDeleteSelection(aInfo.collapsedAction, aInfo.stripWrappers,
aCancel, aHandled);
case EditSubAction::eCreateOrChangeList:
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -88,24 +88,25 @@ nsresult
HTMLEditor::LoadHTML(const nsAString& aInputString)
{
NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
// force IME commit; set up rules sniffing and batching
CommitComposition();
AutoPlaceholderBatch beginBatching(this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
- *this, EditSubAction::loadHTML,
+ *this,
+ EditSubAction::eInsertHTMLSource,
nsIEditor::eNext);
// Get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
- EditSubActionInfo subActionInfo(EditSubAction::loadHTML);
+ EditSubActionInfo subActionInfo(EditSubAction::eInsertHTMLSource);
bool cancel, handled;
// Protect the edit rules object from dying
RefPtr<TextEditRules> rules(mRules);
nsresult rv =
rules->WillDoAction(selection, subActionInfo, &cancel, &handled);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@@ -208,17 +209,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
// Prevent the edit rules object from dying
RefPtr<TextEditRules> rules(mRules);
// force IME commit; set up rules sniffing and batching
CommitComposition();
AutoPlaceholderBatch beginBatching(this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
- *this, EditSubAction::htmlPaste,
+ *this, EditSubAction::ePasteHTMLContent,
nsIEditor::eNext);
// Get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
// create a dom document fragment that represents the structure to paste
nsCOMPtr<nsINode> fragmentAsNode, streamStartParent, streamEndParent;