--- a/editor/libeditor/EditorUtils.cpp
+++ b/editor/libeditor/EditorUtils.cpp
@@ -19,57 +19,63 @@
#include "nsIDocument.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsINode.h"
#include "nsISimpleEnumerator.h"
class nsISupports;
class nsRange;
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
/******************************************************************************
- * nsAutoSelectionReset
+ * AutoSelectionRestorer
*****************************************************************************/
-nsAutoSelectionReset::nsAutoSelectionReset(Selection* aSel, nsEditor* aEd
- MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
- : mSel(nullptr), mEd(nullptr)
+AutoSelectionRestorer::AutoSelectionRestorer(
+ Selection* aSelection,
+ nsEditor* aEditor
+ MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
+ : mEditor(nullptr)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
- if (!aSel || !aEd) return; // not much we can do, bail.
- if (aEd->ArePreservingSelection()) return; // we already have initted mSavedSel, so this must be nested call.
- mSel = aSel;
- mEd = aEd;
- if (mSel)
- {
- mEd->PreserveSelectionAcrossActions(mSel);
+ if (NS_WARN_IF(!aSelection) || NS_WARN_IF(!aEditor)) {
+ return;
}
+ if (aEditor->ArePreservingSelection()) {
+ // We already have initialized mSavedSel, so this must be nested call.
+ return;
+ }
+ mSelection = aSelection;
+ mEditor = aEditor;
+ mEditor->PreserveSelectionAcrossActions(mSelection);
}
-nsAutoSelectionReset::~nsAutoSelectionReset()
+AutoSelectionRestorer::~AutoSelectionRestorer()
{
- NS_ASSERTION(!mSel || mEd, "mEd should be non-null when mSel is");
- if (mSel && mEd->ArePreservingSelection()) // mSel will be null if this was nested call
- {
- mEd->RestorePreservedSelection(mSel);
+ NS_ASSERTION(!mSelection || mEditor,
+ "mEditor should be non-null when mSelection is");
+ // mSelection will be null if this was nested call.
+ if (mSelection && mEditor->ArePreservingSelection()) {
+ mEditor->RestorePreservedSelection(mSelection);
}
}
void
-nsAutoSelectionReset::Abort()
+AutoSelectionRestorer::Abort()
{
- NS_ASSERTION(!mSel || mEd, "mEd should be non-null when mSel is");
- if (mSel)
- mEd->StopPreservingSelection();
+ NS_ASSERTION(!mSelection || mEditor,
+ "mEditor should be non-null when mSelection is");
+ if (mSelection) {
+ mEditor->StopPreservingSelection();
+ }
}
-namespace mozilla {
-
/******************************************************************************
* some helper classes for iterating the dom tree
*****************************************************************************/
DOMIterator::DOMIterator(nsINode& aNode MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
mIter = NS_NewContentIterator();
--- a/editor/libeditor/EditorUtils.h
+++ b/editor/libeditor/EditorUtils.h
@@ -67,41 +67,50 @@ class MOZ_RAII nsAutoEditBatch : public
explicit nsAutoEditBatch(nsIEditor *aEd MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: nsAutoPlaceHolderBatch(aEd, nullptr)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
~nsAutoEditBatch() {}
};
+namespace mozilla {
+
/***************************************************************************
* stack based helper class for saving/restoring selection. Note that this
* assumes that the nodes involved are still around afterwards!
*/
-class MOZ_RAII nsAutoSelectionReset
+class MOZ_RAII AutoSelectionRestorer final
{
- private:
- /** ref-counted reference to the selection that we are supposed to restore */
- RefPtr<mozilla::dom::Selection> mSel;
- nsEditor *mEd; // non-owning ref to nsEditor
- MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+private:
+ // Ref-counted reference to the selection that we are supposed to restore.
+ RefPtr<dom::Selection> mSelection;
+ nsEditor* mEditor; // Non-owning ref to nsEditor.
+ MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
- public:
- /** constructor responsible for remembering all state needed to restore aSel */
- nsAutoSelectionReset(mozilla::dom::Selection* aSel, nsEditor* aEd MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
+public:
+ /**
+ * Constructor responsible for remembering all state needed to restore
+ * aSelection.
+ */
+ AutoSelectionRestorer(dom::Selection* aSelection,
+ nsEditor* aEditor
+ MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
- /** destructor restores mSel to its former state */
- ~nsAutoSelectionReset();
+ /**
+ * Destructor restores mSelection to its former state
+ */
+ ~AutoSelectionRestorer();
- /** Abort: cancel selection saver */
- void Abort();
+ /**
+ * Abort() cancels to restore the selection.
+ */
+ void Abort();
};
-namespace mozilla {
-
/***************************************************************************
* stack based helper class for StartOperation()/EndOperation() sandwich
*/
class MOZ_RAII AutoRules final
{
public:
AutoRules(nsEditor* aEditor, EditAction aAction,
nsIEditor::EDirection aDirection
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -1563,17 +1563,17 @@ nsEditor::ReplaceContainer(Element* aOld
res = ret->SetAttr(kNameSpaceID_None, aAttribute, *aValue, true);
NS_ENSURE_SUCCESS(res, nullptr);
}
if (aCloneAttributes == eCloneAttributes) {
CloneAttributes(ret, aOldContainer);
}
// notify our internal selection state listener
- // (Note: A nsAutoSelectionReset object must be created
+ // (Note: An AutoSelectionRestorer object must be created
// before calling this to initialize mRangeUpdater)
AutoReplaceContainerSelNotify selStateNotify(mRangeUpdater, aOldContainer,
ret);
{
AutoTransactionsConserveSelection conserveSelection(this);
while (aOldContainer->HasChildren()) {
nsCOMPtr<nsIContent> child = aOldContainer->GetFirstChild();
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -50,16 +50,17 @@ class nsISupports;
class nsITransaction;
class nsIWidget;
class nsRange;
class nsString;
class nsTransactionManager;
namespace mozilla {
class AutoRules;
+class AutoSelectionRestorer;
class AutoTransactionsConserveSelection;
class ErrorResult;
class TextComposition;
struct EditorDOMPoint;
namespace dom {
class ChangeAttributeTxn;
class CreateElementTxn;
@@ -853,17 +854,18 @@ protected:
// various listeners
// Listens to all low level actions on the doc
nsTArray<OwningNonNull<nsIEditActionListener>> mActionListeners;
// Just notify once per high level change
nsTArray<OwningNonNull<nsIEditorObserver>> mEditorObservers;
// Listen to overall doc state (dirty or not, just created, etc)
nsTArray<OwningNonNull<nsIDocumentStateListener>> mDocStateListeners;
- nsSelectionState mSavedSel; // cached selection for nsAutoSelectionReset
+ // cached selection for AutoSelectionRestorer
+ nsSelectionState mSavedSel;
nsRangeUpdater mRangeUpdater; // utility class object for maintaining preserved ranges
uint32_t mModCount; // number of modifications (for undo/redo stack)
uint32_t mFlags; // behavior flags. See nsIPlaintextEditor.idl for the flags we use.
int32_t mUpdateCount;
int32_t mPlaceHolderBatch; // nesting count for batching
@@ -882,15 +884,15 @@ protected:
bool mDidPreDestroy; // whether PreDestroy has been called
bool mDidPostCreate; // whether PostCreate has been called
bool mDispatchInputEvent;
bool mIsInEditAction; // true while the instance is handling an edit action
bool mHidingCaret; // whether caret is hidden forcibly.
friend bool NSCanUnload(nsISupports* serviceMgr);
friend class mozilla::AutoRules;
+ friend class mozilla::AutoSelectionRestorer;
friend class mozilla::AutoTransactionsConserveSelection;
- friend class nsAutoSelectionReset;
friend class nsRangeUpdater;
};
#endif
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -347,20 +347,22 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
nsCOMPtr<nsINode> tmpNode = selection->GetAnchorNode();
int32_t tmpOffset = static_cast<int32_t>(selection->AnchorOffset());
rv = ClearStyle(address_of(tmpNode), &tmpOffset, nullptr, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
}
}
else
{
- // delete whole cells: we will replace with new table content
- { // Braces for artificial block to scope nsAutoSelectionReset.
- // Save current selection since DeleteTableCell perturbs it
- nsAutoSelectionReset selectionResetter(selection, this);
+ // Delete whole cells: we will replace with new table content.
+
+ // Braces for artificial block to scope AutoSelectionRestorer.
+ // Save current selection since DeleteTableCell() perturbs it.
+ {
+ AutoSelectionRestorer selectionRestorer(selection, this);
rv = DeleteTableCell(1);
NS_ENSURE_SUCCESS(rv, rv);
}
// collapse selection to beginning of deleted table content
selection->CollapseToStart();
}
// give rules a chance to handle or cancel
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -2991,17 +2991,17 @@ nsHTMLEditRules::WillMakeList(Selection*
// block parent, and then further expands to include any ancestors
// whose children are all in the range
*aHandled = true;
nsresult res = NormalizeSelection(aSelection);
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_STATE(mHTMLEditor);
- nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(aSelection, mHTMLEditor);
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
res = GetListActionNodes(arrayOfNodes,
aEntireList ? EntireList::yes : EntireList::no);
NS_ENSURE_SUCCESS(res, res);
// check if all our nodes are <br>s, or empty inlines
bool bOnlyBreaks = true;
@@ -3049,18 +3049,18 @@ nsHTMLEditRules::WillMakeList(Selection*
nsCOMPtr<Element> theListItem =
mHTMLEditor->CreateNode(itemType, theList, 0);
NS_ENSURE_STATE(theListItem);
// remember our new block for postprocessing
mNewBlock = theListItem;
// put selection in new list item
res = aSelection->Collapse(theListItem, 0);
- // to prevent selection resetter from overriding us
- selectionResetter.Abort();
+ // Don't restore the selection
+ selectionRestorer.Abort();
*aHandled = true;
return res;
}
// if there is only one node in the array, and it is a list, div, or
// blockquote, then look inside of it until we find inner list or content.
LookInsideDivBQandList(arrayOfNodes);
@@ -3271,17 +3271,17 @@ nsHTMLEditRules::WillRemoveList(Selectio
if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
// initialize out param
*aCancel = false;
*aHandled = true;
nsresult res = NormalizeSelection(aSelection);
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_STATE(mHTMLEditor);
- nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(aSelection, mHTMLEditor);
nsTArray<RefPtr<nsRange>> arrayOfRanges;
GetPromotedRanges(*aSelection, arrayOfRanges, EditAction::makeList);
// use these ranges to contruct a list of nodes to act on.
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
res = GetListActionNodes(arrayOfNodes, EntireList::no);
NS_ENSURE_SUCCESS(res, res);
@@ -3351,17 +3351,17 @@ nsHTMLEditRules::WillMakeBasicBlock(Sele
WillInsert(aSelection, aCancel);
// We want to ignore result of WillInsert()
*aCancel = false;
*aHandled = false;
nsresult res = NormalizeSelection(&aSelection);
NS_ENSURE_SUCCESS(res, res);
- nsAutoSelectionReset selectionResetter(&aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(&aSelection, mHTMLEditor);
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
*aHandled = true;
// Contruct a list of nodes to act on.
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
res = GetNodesFromSelection(aSelection, EditAction::makeBasicBlock,
arrayOfNodes);
NS_ENSURE_SUCCESS(res, res);
@@ -3402,18 +3402,18 @@ nsHTMLEditRules::WillMakeBasicBlock(Sele
offset,
nsHTMLEditor::EmptyContainers::no);
NS_ENSURE_STATE(offset != -1);
// Put a br at the split point
brNode = mHTMLEditor->CreateBR(curBlock->GetParentNode(), offset);
NS_ENSURE_STATE(brNode);
// Put selection at the split point
res = aSelection.Collapse(curBlock->GetParentNode(), offset);
- // To prevent selection resetter from overriding us.
- selectionResetter.Abort();
+ // Don't restore the selection
+ selectionRestorer.Abort();
*aHandled = true;
NS_ENSURE_SUCCESS(res, res);
}
// Else nothing to do!
} else {
// We are making a block. Consume a br, if needed.
nsCOMPtr<nsIContent> brNode =
mHTMLEditor->GetNextHTMLNode(parent, offset, true);
@@ -3435,18 +3435,18 @@ nsHTMLEditRules::WillMakeBasicBlock(Sele
while (!arrayOfNodes.IsEmpty()) {
OwningNonNull<nsINode> curNode = arrayOfNodes[0];
res = mHTMLEditor->DeleteNode(curNode);
NS_ENSURE_SUCCESS(res, res);
arrayOfNodes.RemoveElementAt(0);
}
// Put selection in new block
res = aSelection.Collapse(block, 0);
- // To prevent selection resetter from overriding us.
- selectionResetter.Abort();
+ // Don't restore the selection
+ selectionRestorer.Abort();
*aHandled = true;
NS_ENSURE_SUCCESS(res, res);
}
return NS_OK;
}
// Okay, now go through all the nodes and make the right kind of blocks, or
// whatever is approriate. Woohoo! Note: blockquote is handled a little
// differently.
@@ -3508,17 +3508,17 @@ nsHTMLEditRules::WillCSSIndent(Selection
// initialize out param
// we want to ignore result of WillInsert()
*aCancel = false;
*aHandled = true;
nsresult res = NormalizeSelection(aSelection);
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_STATE(mHTMLEditor);
- nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(aSelection, mHTMLEditor);
nsTArray<OwningNonNull<nsRange>> arrayOfRanges;
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
// short circuit: detect case of collapsed selection inside an <li>.
// just sublist that <li>. This prevents bug 97797.
nsCOMPtr<Element> liNode;
if (aSelection->Collapsed()) {
@@ -3570,17 +3570,18 @@ nsHTMLEditRules::WillCSSIndent(Selection
OwningNonNull<nsINode> curNode = arrayOfNodes[0];
NS_ENSURE_STATE(mHTMLEditor);
res = mHTMLEditor->DeleteNode(curNode);
NS_ENSURE_SUCCESS(res, res);
arrayOfNodes.RemoveElementAt(0);
}
// put selection in new block
res = aSelection->Collapse(theBlock,0);
- selectionResetter.Abort(); // to prevent selection reseter from overriding us.
+ // Don't restore the selection
+ selectionRestorer.Abort();
*aHandled = true;
return res;
}
// Ok, now go through all the nodes and put them in a blockquote,
// or whatever is appropriate. Wohoo!
int32_t i;
nsCOMPtr<nsINode> curParent;
@@ -3711,17 +3712,17 @@ nsHTMLEditRules::WillHTMLIndent(Selectio
// initialize out param
// we want to ignore result of WillInsert()
*aCancel = false;
*aHandled = true;
nsresult res = NormalizeSelection(aSelection);
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_STATE(mHTMLEditor);
- nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(aSelection, mHTMLEditor);
// convert the selection ranges into "promoted" selection ranges:
// this basically just expands the range to include the immediate
// block parent, and then further expands to include any ancestors
// whose children are all in the range
nsTArray<RefPtr<nsRange>> arrayOfRanges;
GetPromotedRanges(*aSelection, arrayOfRanges, EditAction::indent);
@@ -3754,17 +3755,18 @@ nsHTMLEditRules::WillHTMLIndent(Selectio
OwningNonNull<nsINode> curNode = arrayOfNodes[0];
NS_ENSURE_STATE(mHTMLEditor);
res = mHTMLEditor->DeleteNode(curNode);
NS_ENSURE_SUCCESS(res, res);
arrayOfNodes.RemoveElementAt(0);
}
// put selection in new block
res = aSelection->Collapse(theBlock,0);
- selectionResetter.Abort(); // to prevent selection reseter from overriding us.
+ // Don't restore the selection
+ selectionRestorer.Abort();
*aHandled = true;
return res;
}
// Ok, now go through all the nodes and put them in a blockquote,
// or whatever is appropriate. Wohoo!
int32_t i;
nsCOMPtr<nsINode> curParent;
@@ -3944,17 +3946,17 @@ nsHTMLEditRules::WillOutdent(Selection&
nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
bool useCSS = mHTMLEditor->IsCSSEnabled();
nsresult res = NormalizeSelection(&aSelection);
NS_ENSURE_SUCCESS(res, res);
// Some scoping for selection resetting - we may need to tweak it
{
- nsAutoSelectionReset selectionResetter(&aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(&aSelection, mHTMLEditor);
// Convert the selection ranges into "promoted" selection ranges: this
// basically just expands the range to include the immediate block parent,
// and then further expands to include any ancestors whose children are all
// in the range
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
res = GetNodesFromSelection(aSelection, EditAction::outdent,
arrayOfNodes);
@@ -4481,17 +4483,17 @@ nsHTMLEditRules::WillAlign(Selection& aS
WillInsert(aSelection, aCancel);
// Initialize out param. We want to ignore result of WillInsert().
*aCancel = false;
*aHandled = false;
nsresult rv = NormalizeSelection(&aSelection);
NS_ENSURE_SUCCESS(rv, rv);
- nsAutoSelectionReset selectionResetter(&aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(&aSelection, mHTMLEditor);
// Convert the selection ranges into "promoted" selection ranges: This
// basically just expands the range to include the immediate block parent,
// and then further expands to include any ancestors whose children are all
// in the range
*aHandled = true;
nsTArray<OwningNonNull<nsINode>> nodeArray;
rv = GetNodesFromSelection(aSelection, EditAction::align, nodeArray);
@@ -4568,18 +4570,18 @@ nsHTMLEditRules::WillAlign(Selection& aS
// Set up the alignment on the div, using HTML or CSS
rv = AlignBlock(*div, aAlignType, ContentsOnly::yes);
NS_ENSURE_SUCCESS(rv, rv);
*aHandled = true;
// Put in a moz-br so that it won't get deleted
rv = CreateMozBR(div->AsDOMNode(), 0);
NS_ENSURE_SUCCESS(rv, rv);
rv = aSelection.Collapse(div, 0);
- // Don't reset our selection in this case.
- selectionResetter.Abort();
+ // Don't restore the selection
+ selectionRestorer.Abort();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
// Next we detect all the transitions in the array, where a transition
// means that adjacent nodes in the array don't have the same parent.
nsTArray<bool> transitionList;
@@ -8502,17 +8504,17 @@ nsHTMLEditRules::WillAbsolutePosition(Se
nsCOMPtr<Element> focusElement = mHTMLEditor->GetSelectionContainer();
if (focusElement && nsHTMLEditUtils::IsImage(focusElement)) {
mNewBlock = focusElement;
return NS_OK;
}
nsresult res = NormalizeSelection(&aSelection);
NS_ENSURE_SUCCESS(res, res);
- nsAutoSelectionReset selectionResetter(&aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(&aSelection, mHTMLEditor);
// Convert the selection ranges into "promoted" selection ranges: this
// basically just expands the range to include the immediate block parent,
// and then further expands to include any ancestors whose children are all
// in the range.
nsTArray<RefPtr<nsRange>> arrayOfRanges;
GetPromotedRanges(aSelection, arrayOfRanges,
@@ -8545,18 +8547,18 @@ nsHTMLEditRules::WillAbsolutePosition(Se
while (!arrayOfNodes.IsEmpty()) {
OwningNonNull<nsINode> curNode = arrayOfNodes[0];
res = mHTMLEditor->DeleteNode(curNode);
NS_ENSURE_SUCCESS(res, res);
arrayOfNodes.RemoveElementAt(0);
}
// Put selection in new block
res = aSelection.Collapse(positionedDiv, 0);
- // Prevent selection resetter from overriding us.
- selectionResetter.Abort();
+ // Don't restore the selection
+ selectionRestorer.Abort();
*aHandled = true;
NS_ENSURE_SUCCESS(res, res);
return NS_OK;
}
// Okay, now go through all the nodes and put them in a blockquote, or
// whatever is appropriate. Woohoo!
nsCOMPtr<Element> curList, curPositionedDiv, indentedLI;
@@ -8702,17 +8704,17 @@ nsHTMLEditRules::WillRemoveAbsolutePosit
nsCOMPtr<nsIDOMElement> elt;
NS_ENSURE_STATE(mHTMLEditor);
nsresult res =
mHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_STATE(mHTMLEditor);
- nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(aSelection, mHTMLEditor);
NS_ENSURE_STATE(mHTMLEditor);
nsCOMPtr<nsIHTMLAbsPosEditor> absPosHTMLEditor = mHTMLEditor;
return absPosHTMLEditor->AbsolutelyPositionElement(elt, false);
}
nsresult
nsHTMLEditRules::WillRelativeChangeZIndex(Selection* aSelection,
@@ -8730,17 +8732,17 @@ nsHTMLEditRules::WillRelativeChangeZInde
nsCOMPtr<nsIDOMElement> elt;
NS_ENSURE_STATE(mHTMLEditor);
nsresult res =
mHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_STATE(mHTMLEditor);
- nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
+ AutoSelectionRestorer selectionRestorer(aSelection, mHTMLEditor);
NS_ENSURE_STATE(mHTMLEditor);
nsCOMPtr<nsIHTMLAbsPosEditor> absPosHTMLEditor = mHTMLEditor;
int32_t zIndex;
return absPosHTMLEditor->RelativeChangeElementZIndex(elt, aChange, &zIndex);
}
NS_IMETHODIMP
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -3329,17 +3329,17 @@ SetSelectionAroundHeadChildren(Selection
NS_IMETHODIMP
nsHTMLEditor::GetHeadContentsAsHTML(nsAString& aOutputString)
{
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
// Save current selection
- nsAutoSelectionReset selectionResetter(selection, this);
+ AutoSelectionRestorer selectionRestorer(selection, this);
nsresult res = SetSelectionAroundHeadChildren(selection, mDocWeak);
NS_ENSURE_SUCCESS(res, res);
res = OutputToString(NS_LITERAL_STRING("text/html"),
nsIDocumentEncoder::OutputSelectionOnly,
aOutputString);
if (NS_SUCCEEDED(res))
@@ -4529,17 +4529,17 @@ nsHTMLEditor::SetCSSBackgroundColor(cons
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
bool isCollapsed = selection->Collapsed();
nsAutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
- nsAutoSelectionReset selectionResetter(selection, this);
+ AutoSelectionRestorer selectionRestorer(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(EditAction::setTextProperty);
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(res, res);
if (!cancel && !handled) {
// Loop through the ranges in the selection
--- a/editor/libeditor/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/nsHTMLEditorStyle.cpp
@@ -122,17 +122,17 @@ nsHTMLEditor::SetInlineProperty(nsIAtom*
// for the next text insertion
mTypeInState->SetProp(aProperty, aAttribute, aValue);
return NS_OK;
}
nsAutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
- nsAutoSelectionReset selectionResetter(selection, this);
+ AutoSelectionRestorer selectionRestorer(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(EditAction::setTextProperty);
// Protect the edit rules object from dying
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(res, res);
if (!cancel && !handled) {
@@ -1209,17 +1209,17 @@ nsHTMLEditor::RemoveInlinePropertyImpl(n
mTypeInState->ClearAllProps();
}
return NS_OK;
}
nsAutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::removeTextProperty,
nsIEditor::eNext);
- nsAutoSelectionReset selectionResetter(selection, this);
+ AutoSelectionRestorer selectionRestorer(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(EditAction::removeTextProperty);
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(res, res);
@@ -1358,17 +1358,17 @@ nsHTMLEditor::RelativeFontChange(FontSiz
mTypeInState->SetProp(&atom, EmptyString(), EmptyString());
return NS_OK;
}
// Wrap with txn batching, rules sniffing, and selection preservation code
nsAutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::setTextProperty,
nsIEditor::eNext);
- nsAutoSelectionReset selectionResetter(selection, this);
+ AutoSelectionRestorer selectionRestorer(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this);
// Loop through the ranges in the selection
uint32_t rangeCount = selection->RangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
RefPtr<nsRange> range = selection->GetRangeAt(rangeIdx);
// Adjust range to include any ancestors with entirely selected children
--- a/editor/libeditor/nsTableEditor.cpp
+++ b/editor/libeditor/nsTableEditor.cpp
@@ -1922,17 +1922,17 @@ nsHTMLEditor::SwitchTableCellHeaderType(
// Prevent auto insertion of BR in new cell created by ReplaceContainer
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
// Save current selection to restore when done
// This is needed so ReplaceContainer can monitor selection
// when replacing nodes
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
- nsAutoSelectionReset selectionResetter(selection, this);
+ AutoSelectionRestorer selectionRestorer(selection, this);
// Set to the opposite of current type
nsCOMPtr<nsIAtom> atom = nsEditor::GetTag(aSourceCell);
nsIAtom* newCellType = atom == nsGkAtoms::td ? nsGkAtoms::th : nsGkAtoms::td;
// This creates new node, moves children, copies attributes (true)
// and manages the selection!
nsCOMPtr<Element> newNode = ReplaceContainer(sourceCell, newCellType,
@@ -2469,17 +2469,17 @@ nsHTMLEditor::NormalizeTable(nsIDOMEleme
// Don't fail if we didn't find a table
NS_ENSURE_TRUE(table, NS_OK);
int32_t rowCount, colCount, rowIndex, colIndex;
res = GetTableSize(table, &rowCount, &colCount);
NS_ENSURE_SUCCESS(res, res);
// Save current selection
- nsAutoSelectionReset selectionResetter(selection, this);
+ AutoSelectionRestorer selectionRestorer(selection, this);
nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> cell;
int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
bool isSelected;