Bug 1623333: part 2) Declare `Selection::mSelectionType` `const`. r=smaug

Simplifies reasoning about it.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mirko Brodesser 2020-03-19 09:25:02 +00:00
Родитель 8a11f12378
Коммит d252ed1175
5 изменённых файлов: 9 добавлений и 11 удалений

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

@ -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),

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

@ -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<ScrollSelectionIntoViewEvent> mScrollEvent;
CachedOffsetForFrame* mCachedOffsetForFrame;
nsDirection mDirection;
SelectionType mSelectionType;
const SelectionType mSelectionType;
UniquePtr<SelectionCustomColors> mCustomColors;
// Non-zero if we don't want any changes we make to the selection to be

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

@ -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> selection = new Selection(nullptr);
RefPtr<Selection> selection = new Selection(SelectionType::eNormal, nullptr);
RefPtr<nsRange> range = nsRange::Create(aNode);
ErrorResult result;
range->SelectNode(*aNode, result);

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

@ -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) {

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

@ -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