Bug 1397791 - Move StartBatchChanges and EndBatchChanges from nsISelectionPrivate to Selection. r?smaug
There is no reason to keep StartBatchChanges and EndBatchChanges in nsISelectionPrivate since this is noscript method. And if moving it to Selection, we can remove virtual keyword.
MozReview-Commit-ID: Go6njiW3r2x
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -3874,42 +3874,32 @@ Selection::NotifySelectionListeners()
short reason = frameSelection->PopReason();
for (auto& listener : selectionListeners) {
listener->NotifySelectionChanged(domdoc, this, reason);
}
return NS_OK;
}
-NS_IMETHODIMP
+void
Selection::StartBatchChanges()
{
if (mFrameSelection) {
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
frameSelection->StartBatchChanges();
}
- return NS_OK;
}
-
-
-NS_IMETHODIMP
-Selection::EndBatchChanges()
-{
- return EndBatchChangesInternal();
-}
-
-nsresult
-Selection::EndBatchChangesInternal(int16_t aReason)
+void
+Selection::EndBatchChanges(int16_t aReason)
{
if (mFrameSelection) {
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
frameSelection->EndBatchChanges(aReason);
}
- return NS_OK;
}
void
Selection::AddSelectionChangeBlocker()
{
mSelectionChangeBlockerCount++;
}
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -67,17 +67,22 @@ public:
Selection();
explicit Selection(nsFrameSelection *aList);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Selection, nsISelectionPrivate)
NS_DECL_NSISELECTION
NS_DECL_NSISELECTIONPRIVATE
- nsresult EndBatchChangesInternal(int16_t aReason = nsISelectionListener::NO_REASON);
+ // match this up with EndbatchChanges. will stop ui updates while multiple
+ // selection methods are called
+ void StartBatchChanges();
+
+ // match this up with StartBatchChanges
+ void EndBatchChanges(int16_t aReason = nsISelectionListener::NO_REASON);
nsIDocument* GetParentObject() const;
// utility methods for scrolling the selection into view
nsPresContext* GetPresContext() const;
nsIPresShell* GetPresShell() const;
nsFrameSelection* GetFrameSelection() const { return mFrameSelection; }
// Returns a rect containing the selection region, and frame that that
@@ -528,17 +533,17 @@ public:
if (mSelection) {
mSelection->StartBatchChanges();
}
}
~SelectionBatcher()
{
if (mSelection) {
- mSelection->EndBatchChangesInternal();
+ mSelection->EndBatchChanges();
}
}
};
class MOZ_RAII AutoHideSelectionChanges final
{
private:
RefPtr<Selection> mSelection;
--- a/dom/base/nsISelectionPrivate.idl
+++ b/dom/base/nsISelectionPrivate.idl
@@ -31,26 +31,16 @@ native ScrollAxis(nsIPresShell::ScrollAx
interface nsISelectionPrivate : nsISelection
{
const short ENDOFPRECEDINGLINE=0;
const short STARTOFNEXTLINE=1;
attribute boolean interlinePosition;
[noscript] attribute nsIContent ancestorLimiter;
- /* startBatchChanges
- match this up with endbatchChanges. will stop ui updates while multiple selection methods are called
- */
- [noscript] void startBatchChanges();
-
- /* endBatchChanges
- match this up with startBatchChanges
- */
- [noscript] void endBatchChanges();
-
DOMString toStringWithFormat(in string formatType, in unsigned long flags, in int32_t wrapColumn);
void addSelectionListener(in nsISelectionListener newListener);
void removeSelectionListener(in nsISelectionListener listenerToRemove);
/* Table selection stuff
We should probably move this and table-related
items in nsFrameSelection to a
new nsITableSelection interface
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -3247,17 +3247,17 @@ ContentEventHandler::OnSelectionEvent(Wi
} else {
rv = mSelection->Extend(endNode, endNodeOffset);
}
}
}
// Pass the eSetSelection events reason along with the BatchChange-end
// selection change notifications.
- mSelection->EndBatchChangesInternal(aEvent->mReason);
+ mSelection->EndBatchChanges(aEvent->mReason);
NS_ENSURE_SUCCESS(rv, rv);
mSelection->ScrollIntoViewInternal(
nsISelectionController::SELECTION_FOCUS_REGION,
false, nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis());
aEvent->mSucceeded = true;
return NS_OK;
}