Bug 1572685 - part 11: Move `HTMLEditRules::JoinOffset` to `EditorBase::EditSubActionData` r=m_kato

The members of `HTMLEditRules` which are used only while `WillDoAction()` and
`DidDoAction()` are called should be moved to specific stack only struct
`EditorBase::EditSubActionData`.

Differential Revision: https://phabricator.services.mozilla.com/D42106

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-08-20 01:52:50 +00:00
Родитель f3a6c9590b
Коммит d741d7dbe7
11 изменённых файлов: 110 добавлений и 72 удалений

Просмотреть файл

@ -1354,7 +1354,7 @@ already_AddRefed<Element> EditorBase::CreateNodeWithTransaction(
// we need to redesign RangeUpdaterRef() as avoiding using indices.
Unused << aPointToInsert.Offset();
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eCreateNode, nsIEditor::eNext);
RefPtr<Element> newElement;
@ -1431,7 +1431,7 @@ nsresult EditorBase::InsertNodeWithTransaction(
}
MOZ_ASSERT(aPointToInsert.IsSetAndValid());
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertNode, nsIEditor::eNext);
RefPtr<InsertNodeTransaction> transaction =
@ -1566,7 +1566,7 @@ already_AddRefed<nsIContent> EditorBase::SplitNodeWithTransaction(
}
MOZ_ASSERT(aStartOfRightNode.IsSetAndValid());
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eSplitNode, nsIEditor::eNext);
// XXX Unfortunately, storing offset of the split point in
@ -1636,7 +1636,7 @@ nsresult EditorBase::JoinNodesWithTransaction(nsINode& aLeftNode,
nsCOMPtr<nsINode> parent = aLeftNode.GetParentNode();
MOZ_ASSERT(parent);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eJoinNodes, nsIEditor::ePrevious);
// Remember some values; later used for saved selection updating.
@ -1708,7 +1708,7 @@ EditorBase::DeleteNode(nsINode* aNode) {
nsresult EditorBase::DeleteNodeWithTransaction(nsINode& aNode) {
MOZ_ASSERT(IsEditActionDataAvailable());
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::ePrevious);
if (mRules && mRules->AsHTMLEditRules()) {
@ -2908,7 +2908,7 @@ nsresult EditorBase::SetTextImpl(const nsAString& aString, Text& aTextNode) {
const uint32_t length = aTextNode.Length();
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eSetText, nsIEditor::eNext);
// Let listeners know what's up
@ -2977,7 +2977,7 @@ nsresult EditorBase::DeleteTextWithTransaction(Text& aTextNode,
return NS_ERROR_FAILURE;
}
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteText, nsIEditor::ePrevious);
// Let listeners know what's up
@ -4060,7 +4060,7 @@ nsresult EditorBase::MaybeCreatePaddingBRElementForEmptyEditor() {
return NS_OK;
}
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eCreatePaddingBRElementForEmptyEditor,
nsIEditor::eNone);

Просмотреть файл

@ -697,6 +697,15 @@ class EditorBase : public nsIEditor,
TopLevelEditSubActionData(const TopLevelEditSubActionData& aOther) = delete;
};
struct MOZ_STACK_CLASS EditSubActionData final {
uint32_t mJoinedLeftNodeLength;
private:
void Clear() { mJoinedLeftNodeLength = 0; }
friend EditorBase;
};
protected: // AutoEditActionDataSetter, this shouldn't be accessed by friends.
/**
* SettingDataTransfer enum class is used to specify whether DataTransfer
@ -859,6 +868,11 @@ class EditorBase : public nsIEditor,
: mTopLevelEditSubActionData;
}
const EditSubActionData& EditSubActionDataRef() const {
return mEditSubActionData;
}
EditSubActionData& EditSubActionDataRef() { return mEditSubActionData; }
SelectionState& SavedSelectionRef() {
return mParentData ? mParentData->SavedSelectionRef() : mSavedSelection;
}
@ -912,6 +926,10 @@ class EditorBase : public nsIEditor,
// want to pay the copying cost and sync cost.
TopLevelEditSubActionData mTopLevelEditSubActionData;
// Different from mTopLevelEditSubActionData, this stores temporaly data
// for current edit sub action.
EditSubActionData mEditSubActionData;
EditAction mEditAction;
// Different from its data, you can refer "current" AutoEditActionDataSetter
@ -1056,6 +1074,15 @@ class EditorBase : public nsIEditor,
return mEditActionData->TopLevelEditSubActionDataRef();
}
const EditSubActionData& EditSubActionDataRef() const {
MOZ_ASSERT(IsEditActionDataAvailable());
return mEditActionData->EditSubActionDataRef();
}
EditSubActionData& EditSubActionDataRef() {
MOZ_ASSERT(IsEditActionDataAvailable());
return mEditActionData->EditSubActionDataRef();
}
/**
* GetCompositionStartPoint() and GetCompositionEndPoint() returns start and
* end point of composition string if there is. Otherwise, returns non-set
@ -2014,6 +2041,14 @@ class EditorBase : public nsIEditor,
MOZ_CAN_RUN_SCRIPT
virtual void OnEndHandlingTopLevelEditSubAction();
/**
* OnStartToHandleEditSubAction() and OnEndHandlingEditSubAction() are called
* when starting to handle an edit sub action and ending handling an edit
* sub action.
*/
void OnStartToHandleEditSubAction() { EditSubActionDataRef().Clear(); }
void OnEndHandlingEditSubAction() { EditSubActionDataRef().Clear(); }
/**
* Routines for managing the preservation of selection across
* various editor actions.
@ -2389,15 +2424,15 @@ class EditorBase : public nsIEditor,
};
/**
* AutoTopLevelEditSubActionNotifier notifies editor of start to handle
* AutoEditSubActionNotifier notifies editor of start to handle
* top level edit sub-action and end handling top level edit sub-action.
*/
class MOZ_RAII AutoTopLevelEditSubActionNotifier final {
class MOZ_RAII AutoEditSubActionNotifier final {
public:
AutoTopLevelEditSubActionNotifier(
AutoEditSubActionNotifier(
EditorBase& aEditorBase, EditSubAction aEditSubAction,
nsIEditor::EDirection aDirection MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mEditorBase(aEditorBase), mDoNothing(false) {
: mEditorBase(aEditorBase), mIsTopLevel(true) {
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
// The top level edit sub action has already be set if this is nested call
// XXX Looks like that this is not aware of unexpected nested edit action
@ -2407,20 +2442,22 @@ class EditorBase : public nsIEditor,
mEditorBase.OnStartToHandleTopLevelEditSubAction(aEditSubAction,
aDirection);
} else {
mDoNothing = true; // nested calls will end up here
mIsTopLevel = false;
}
mEditorBase.OnStartToHandleEditSubAction();
}
MOZ_CAN_RUN_SCRIPT_BOUNDARY
~AutoTopLevelEditSubActionNotifier() {
if (!mDoNothing) {
~AutoEditSubActionNotifier() {
mEditorBase.OnEndHandlingEditSubAction();
if (mIsTopLevel) {
MOZ_KnownLive(mEditorBase).OnEndHandlingTopLevelEditSubAction();
}
}
protected:
EditorBase& mEditorBase;
bool mDoNothing;
bool mIsTopLevel;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};

Просмотреть файл

@ -56,7 +56,7 @@ nsresult HTMLEditor::SetSelectionToAbsoluteOrStaticAsAction(
}
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this,
aEnabled ? EditSubAction::eSetPositionToAbsolute
: EditSubAction::eSetPositionToStatic,
@ -155,7 +155,7 @@ nsresult HTMLEditor::AddZIndexAsAction(int32_t aChange,
}
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this,
aChange < 0 ? EditSubAction::eDecreaseZIndex
: EditSubAction::eIncreaseZIndex,

Просмотреть файл

@ -191,8 +191,7 @@ HTMLEditRules::HTMLEditRules()
: mHTMLEditor(nullptr),
mInitialized(false),
mListenerEnabled(false),
mReturnInEmptyLIKillsList(false),
mJoinOffset(0) {
mReturnInEmptyLIKillsList(false) {
mIsHTMLEditRules = true;
InitFields();
}
@ -200,7 +199,6 @@ HTMLEditRules::HTMLEditRules()
void HTMLEditRules::InitFields() {
mHTMLEditor = nullptr;
mReturnInEmptyLIKillsList = true;
mJoinOffset = 0;
}
nsresult HTMLEditRules::Init(TextEditor* aTextEditor) {
@ -10248,8 +10246,11 @@ void HTMLEditRules::WillJoinNodes(nsINode& aLeftNode, nsINode& aRightNode) {
return;
}
AutoSafeEditorData setData(*this, *mHTMLEditor);
// remember split point
mJoinOffset = aLeftNode.Length();
HTMLEditorRef().EditSubActionDataRef().mJoinedLeftNodeLength =
aLeftNode.Length();
}
void HTMLEditRules::DidJoinNodes(nsINode& aLeftNode, nsINode& aRightNode) {
@ -10265,7 +10266,10 @@ void HTMLEditRules::DidJoinNodes(nsINode& aLeftNode, nsINode& aRightNode) {
DebugOnly<nsresult> rv =
HTMLEditorRef().TopLevelEditSubActionDataRef().AddPointToChangedRange(
HTMLEditorRef(), EditorRawDOMPoint(&aRightNode, mJoinOffset));
HTMLEditorRef(),
EditorRawDOMPoint(
&aRightNode,
HTMLEditorRef().EditSubActionDataRef().mJoinedLeftNodeLength));
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "AddPointToChangedRange() failed");
}

Просмотреть файл

@ -1326,8 +1326,6 @@ class HTMLEditRules : public TextEditRules {
bool mInitialized;
bool mListenerEnabled;
bool mReturnInEmptyLIKillsList;
// Need to remember an int across willJoin/didJoin...
uint32_t mJoinOffset;
};
} // namespace mozilla

Просмотреть файл

@ -1012,7 +1012,7 @@ nsresult HTMLEditor::InsertParagraphSeparatorAsSubAction() {
// Protect the edit rules object from dying
RefPtr<TextEditRules> rules(mRules);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertParagraphSeparator, nsIEditor::eNext);
EditSubActionInfo subActionInfo(EditSubAction::eInsertParagraphSeparator);
@ -1134,7 +1134,7 @@ nsresult HTMLEditor::InsertBrElementAtSelectionWithTransaction() {
// XXX Why do we use EditSubAction::eInsertText here? Looks like
// EditSubAction::eInsertLineBreak or EditSubAction::eInsertNode
// is better.
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertText, nsIEditor::eNext);
if (!SelectionRefPtr()->IsCollapsed()) {
@ -1184,7 +1184,7 @@ nsresult HTMLEditor::ReplaceHeadContentsWithSourceWithTransaction(
MOZ_ASSERT(IsEditActionDataAvailable());
// don't do any post processing, rules get confused
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eReplaceHeadWithHTMLSource, nsIEditor::eNone);
CommitComposition();
@ -1535,7 +1535,7 @@ nsresult HTMLEditor::InsertElementAtSelectionAsAction(
CommitComposition();
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertElement, nsIEditor::eNext);
// hand off to the rules system, see if it has anything to say about this
@ -2091,7 +2091,7 @@ nsresult HTMLEditor::MakeOrChangeListAsAction(const nsAString& aListType,
bool cancel, handled;
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eCreateOrChangeList, nsIEditor::eNext);
EditSubActionInfo subActionInfo(EditSubAction::eCreateOrChangeList);
@ -2203,7 +2203,7 @@ nsresult HTMLEditor::RemoveListAsAction(const nsAString& aListType,
RefPtr<TextEditRules> rules(mRules);
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eRemoveList, nsIEditor::eNext);
EditSubActionInfo subActionInfo(EditSubAction::eRemoveList);
@ -2237,7 +2237,7 @@ nsresult HTMLEditor::MakeDefinitionListItemWithTransaction(nsAtom& aTagName) {
bool cancel, handled;
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eCreateOrChangeDefinitionList, nsIEditor::eNext);
nsDependentAtomString tagName(&aTagName);
@ -2274,7 +2274,7 @@ nsresult HTMLEditor::InsertBasicBlockWithTransaction(nsAtom& aTagName) {
bool cancel, handled;
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eCreateOrRemoveBlock, nsIEditor::eNext);
nsDependentAtomString tagName(&aTagName);
@ -2413,8 +2413,8 @@ nsresult HTMLEditor::IndentOrOutdentAsSubAction(
RefPtr<TextEditRules> rules(mRules);
bool cancel, handled;
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
*this, aIndentOrOutdent, nsIEditor::eNext);
AutoEditSubActionNotifier startToHandleEditSubAction(*this, aIndentOrOutdent,
nsIEditor::eNext);
EditSubActionInfo subActionInfo(aIndentOrOutdent);
nsresult rv = rules->WillDoAction(subActionInfo, &cancel, &handled);
@ -2519,7 +2519,7 @@ nsresult HTMLEditor::AlignAsAction(const nsAString& aAlignType,
RefPtr<TextEditRules> rules(mRules);
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eSetOrClearAlignment, nsIEditor::eNext);
bool cancel, handled;
@ -3379,7 +3379,7 @@ nsresult HTMLEditor::DeleteAllChildrenWithTransaction(Element& aElement) {
MOZ_ASSERT(IsEditActionDataAvailable());
// Prevent rules testing until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::eNext);
while (nsCOMPtr<nsINode> child = aElement.GetLastChild()) {
@ -4518,7 +4518,7 @@ nsresult HTMLEditor::SetCSSBackgroundColorWithTransaction(
bool isCollapsed = SelectionRefPtr()->IsCollapsed();
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertElement, nsIEditor::eNext);
AutoSelectionRestorer restoreSelectionLater(*this);
AutoTransactionsConserveSelection dontChangeMySelection(*this);

Просмотреть файл

@ -103,7 +103,7 @@ nsresult HTMLEditor::LoadHTML(const nsAString& aInputString) {
}
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertHTMLSource, nsIEditor::eNext);
nsresult rv = EnsureNoPaddingBRElementForEmptyEditor();
@ -202,7 +202,7 @@ nsresult HTMLEditor::DoInsertHTMLWithContext(
// force IME commit; set up rules sniffing and batching
CommitComposition();
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::ePasteHTMLContent, nsIEditor::eNext);
// create a dom document fragment that represents the structure to paste
@ -1739,7 +1739,7 @@ nsresult HTMLEditor::PasteAsQuotationAsAction(int32_t aClipboardType,
// <blockquote type="cite"> element after removing selection.
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertQuotation, nsIEditor::eNext);
// Adjust Selection and clear cached style before inserting <blockquote>.
@ -1985,7 +1985,7 @@ nsresult HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
*aNodeInserted = nullptr;
}
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertQuotation, nsIEditor::eNext);
// give rules a chance to handle or cancel
@ -2168,7 +2168,7 @@ nsresult HTMLEditor::InsertAsCitedQuotationInternal(
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(!IsPlaintextEditor());
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertQuotation, nsIEditor::eNext);
// give rules a chance to handle or cancel

Просмотреть файл

@ -161,7 +161,7 @@ nsresult HTMLEditor::SetInlinePropertyInternal(nsAtom& aProperty,
}
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertElement, nsIEditor::eNext);
AutoSelectionRestorer restoreSelectionLater(*this);
AutoTransactionsConserveSelection dontChangeMySelection(*this);
@ -1255,7 +1255,7 @@ nsresult HTMLEditor::RemoveAllInlinePropertiesAsAction(
}
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eRemoveAllTextProperties, nsIEditor::eNext);
nsresult rv = RemoveInlinePropertyInternal(nullptr, nullptr);
@ -1354,7 +1354,7 @@ nsresult HTMLEditor::RemoveInlinePropertyInternal(nsAtom* aProperty,
}
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eRemoveTextProperty, nsIEditor::eNext);
AutoSelectionRestorer restoreSelectionLater(*this);
AutoTransactionsConserveSelection dontChangeMySelection(*this);
@ -1556,7 +1556,7 @@ nsresult HTMLEditor::RelativeFontChange(FontSize aDir) {
// Wrap with txn batching, rules sniffing, and selection preservation code
AutoPlaceholderBatch treatAsOneTransaction(*this);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eSetTextProperty, nsIEditor::eNext);
AutoSelectionRestorer restoreSelectionLater(*this);
AutoTransactionsConserveSelection dontChangeMySelection(*this);

Просмотреть файл

@ -212,7 +212,7 @@ nsresult HTMLEditor::InsertTableCellsWithTransaction(
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent auto insertion of BR in new cell until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertNode, nsIEditor::eNext);
// We control selection resetting after the insert.
@ -437,7 +437,7 @@ nsresult HTMLEditor::InsertTableColumnsWithTransaction(
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent auto insertion of <br> element in new cell until we're done.
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertNode, nsIEditor::eNext);
switch (aInsertPosition) {
@ -626,7 +626,7 @@ nsresult HTMLEditor::InsertTableRowsWithTransaction(
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent auto insertion of BR in new cell until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertNode, nsIEditor::eNext);
switch (aInsertPosition) {
@ -893,7 +893,7 @@ nsresult HTMLEditor::DeleteTableCellWithTransaction(
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent rules testing until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::eNext);
ErrorResult error;
@ -1162,7 +1162,7 @@ nsresult HTMLEditor::DeleteTableCellContentsWithTransaction() {
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent rules testing until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::eNext);
// Don't let Rules System change the selection
AutoTransactionsConserveSelection dontChangeSelection(*this);
@ -1249,7 +1249,7 @@ nsresult HTMLEditor::DeleteSelectedTableColumnsWithTransaction(
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent rules testing until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::eNext);
// Shortcut the case of deleting all columns in table
@ -1474,7 +1474,7 @@ nsresult HTMLEditor::DeleteSelectedTableRowsWithTransaction(
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent rules testing until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::eNext);
// Shortcut the case of deleting all rows in table
@ -1584,7 +1584,7 @@ nsresult HTMLEditor::DeleteTableRowWithTransaction(Element& aTableElement,
}
// Prevent rules testing until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::eNext);
// Scan through cells in row to do rowspan adjustments
@ -2118,7 +2118,7 @@ HTMLEditor::SplitTableCell() {
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent auto insertion of BR in new cell until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertNode, nsIEditor::eNext);
// We reset selection
@ -2370,7 +2370,7 @@ HTMLEditor::SwitchTableCellHeaderType(Element* aSourceCell,
AutoPlaceholderBatch treatAsOneTransaction(*this);
// Prevent auto insertion of BR in new cell created by
// ReplaceContainerAndCloneAttributesWithTransaction().
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertNode, nsIEditor::eNext);
// Save current selection to restore when done.
@ -2633,7 +2633,7 @@ HTMLEditor::JoinTableCells(bool aMergeNonContiguousContents) {
// All cell contents are merged. Delete the empty cells we accumulated
// Prevent rules testing until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::eNext);
for (uint32_t i = 0, n = deleteList.Length(); i < n; i++) {
@ -2776,7 +2776,7 @@ nsresult HTMLEditor::MergeCells(RefPtr<Element> aTargetCell,
}
// Prevent rules testing until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteNode, nsIEditor::eNext);
// Don't need to merge if cell is empty
@ -3026,7 +3026,7 @@ nsresult HTMLEditor::NormalizeTableInternal(Element& aTableOrElementInTable) {
AutoPlaceholderBatch treateAsOneTransaction(*this);
// Prevent auto insertion of BR in new cell until we're done
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertNode, nsIEditor::eNext);
// XXX If there is a cell which has bigger or smaller "rowspan" or "colspan"

Просмотреть файл

@ -56,8 +56,7 @@ class Selection;
class TextEditRules {
protected:
typedef EditorBase::AutoSelectionRestorer AutoSelectionRestorer;
typedef EditorBase::AutoTopLevelEditSubActionNotifier
AutoTopLevelEditSubActionNotifier;
typedef EditorBase::AutoEditSubActionNotifier AutoEditSubActionNotifier;
typedef EditorBase::AutoTransactionsConserveSelection
AutoTransactionsConserveSelection;

Просмотреть файл

@ -654,7 +654,7 @@ nsresult TextEditor::DeleteSelectionAsSubAction(EDirection aDirection,
// Protect the edit rules object from dying
RefPtr<TextEditRules> rules(mRules);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteSelectedContent, aDirection);
EditSubActionInfo subActionInfo(EditSubAction::eDeleteSelectedContent);
subActionInfo.collapsedAction = aDirection;
@ -696,7 +696,7 @@ nsresult TextEditor::DeleteSelectionWithTransaction(
RefPtr<CharacterData> deleteCharData =
CharacterData::FromNodeOrNull(deleteNode);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eDeleteSelectedContent, aDirection);
if (mRules && mRules->AsHTMLEditRules()) {
@ -915,8 +915,8 @@ nsresult TextEditor::InsertTextAsSubAction(const nsAString& aStringToInsert) {
? EditSubAction::eInsertTextComingFromIME
: EditSubAction::eInsertText;
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
*this, editSubAction, nsIEditor::eNext);
AutoEditSubActionNotifier startToHandleEditSubAction(*this, editSubAction,
nsIEditor::eNext);
nsAutoString resultString;
// XXX can we trust instring to outlive subActionInfo,
@ -975,7 +975,7 @@ nsresult TextEditor::InsertLineBreakAsSubAction() {
// Protect the edit rules object from dying
RefPtr<TextEditRules> rules(mRules);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertLineBreak, nsIEditor::eNext);
EditSubActionInfo subActionInfo(EditSubAction::eInsertLineBreak);
@ -1031,7 +1031,7 @@ nsresult TextEditor::ReplaceTextAsAction(const nsAString& aString,
AutoPlaceholderBatch treatAsOneTransaction(*this);
// This should emulates inserting text for better undo/redo behavior.
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertText, nsIEditor::eNext);
if (!aReplaceRange) {
@ -1082,7 +1082,7 @@ nsresult TextEditor::SetTextAsSubAction(const nsAString& aString) {
// Protect the edit rules object from dying
RefPtr<TextEditRules> rules(mRules);
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eSetText, nsIEditor::eNext);
EditSubActionInfo subActionInfo(EditSubAction::eSetText);
@ -1545,7 +1545,7 @@ nsresult TextEditor::UndoAsAction(uint32_t aCount, nsIPrincipal* aPrincipal) {
nsresult rv = NS_OK;
{
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eUndo, nsIEditor::eNone);
RefPtr<TransactionManager> transactionManager(mTransactionManager);
@ -1617,7 +1617,7 @@ nsresult TextEditor::RedoAsAction(uint32_t aCount, nsIPrincipal* aPrincipal) {
nsresult rv = NS_OK;
{
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eRedo, nsIEditor::eNone);
RefPtr<TransactionManager> transactionManager(mTransactionManager);
@ -1999,7 +1999,7 @@ nsresult TextEditor::InsertWithQuotationsAsSubAction(
quotedStuff.Append(char16_t('\n'));
}
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
AutoEditSubActionNotifier startToHandleEditSubAction(
*this, EditSubAction::eInsertText, nsIEditor::eNext);
EditSubActionInfo subActionInfo(EditSubAction::eInsertQuotedText);