diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp index 383e9f2ff6b8..f173388d4209 100644 --- a/dom/base/Selection.cpp +++ b/dom/base/Selection.cpp @@ -519,11 +519,12 @@ nsresult Selection::MaybeAddTableCellRange(nsRange& aRange, bool* aDidAddRange, return AddRangesForSelectableNodes(&aRange, aOutIndex); } -Selection::Selection(nsFrameSelection* aFrameSelection) +Selection::Selection(SelectionType aSelectionType, + nsFrameSelection* aFrameSelection) : mFrameSelection(aFrameSelection), mCachedOffsetForFrame(nullptr), mDirection(eDirNext), - mSelectionType(SelectionType::eNormal), + mSelectionType(aSelectionType), mCustomColors(nullptr), mSelectionChangeBlockerCount(0), mUserInitiated(false), diff --git a/dom/base/Selection.h b/dom/base/Selection.h index b334e8bf068e..1c3a9d03905a 100644 --- a/dom/base/Selection.h +++ b/dom/base/Selection.h @@ -63,7 +63,8 @@ class Selection final : public nsSupportsWeakReference, /** * @param aFrameSelection can be nullptr. */ - explicit Selection(nsFrameSelection* aFrameSelection); + explicit Selection(SelectionType aSelectionType, + nsFrameSelection* aFrameSelection); MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Selection) @@ -645,9 +646,6 @@ class Selection final : public nsSupportsWeakReference, public: SelectionType GetType() const { return mSelectionType; } - void SetType(SelectionType aSelectionType) { - mSelectionType = aSelectionType; - } SelectionCustomColors* GetCustomColors() const { return mCustomColors.get(); } @@ -834,7 +832,7 @@ class Selection final : public nsSupportsWeakReference, nsRevocableEventPtr mScrollEvent; CachedOffsetForFrame* mCachedOffsetForFrame; nsDirection mDirection; - SelectionType mSelectionType; + const SelectionType mSelectionType; UniquePtr mCustomColors; // Non-zero if we don't want any changes we make to the selection to be diff --git a/dom/base/nsCopySupport.cpp b/dom/base/nsCopySupport.cpp index 73f62884738e..b6f57eff3d72 100644 --- a/dom/base/nsCopySupport.cpp +++ b/dom/base/nsCopySupport.cpp @@ -406,7 +406,7 @@ nsresult nsCopySupport::GetTransferableForNode( // Make a temporary selection with aNode in a single range. // XXX We should try to get rid of the Selection object here. // XXX bug 1245883 - RefPtr selection = new Selection(nullptr); + RefPtr selection = new Selection(SelectionType::eNormal, nullptr); RefPtr range = nsRange::Create(aNode); ErrorResult result; range->SelectNode(*aNode, result); diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp index 85eb83d60346..028828286114 100644 --- a/dom/base/nsDocumentEncoder.cpp +++ b/dom/base/nsDocumentEncoder.cpp @@ -1378,7 +1378,7 @@ nsHTMLCopyEncoder::SetSelection(Selection* aSelection) { // there's no Clone() for selection! fix... // nsresult rv = aSelection->Clone(getter_AddRefs(mSelection); // NS_ENSURE_SUCCESS(rv, rv); - mEncodingScope.mSelection = new Selection(nullptr); + mEncodingScope.mSelection = new Selection(SelectionType::eNormal, nullptr); // loop thru the ranges in the selection for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) { diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp index 41498c50e3f8..850751de30f7 100644 --- a/layout/generic/nsFrameSelection.cpp +++ b/layout/generic/nsFrameSelection.cpp @@ -304,8 +304,7 @@ struct MOZ_RAII AutoPrepareFocusRange { nsFrameSelection::nsFrameSelection(PresShell* aPresShell, nsIContent* aLimiter, const bool aAccessibleCaretEnabled) { for (size_t i = 0; i < ArrayLength(mDomSelections); i++) { - mDomSelections[i] = new Selection(this); - mDomSelections[i]->SetType(kPresentSelectionTypes[i]); + mDomSelections[i] = new Selection(kPresentSelectionTypes[i], this); } #ifdef XP_MACOSX