Bug 1620952: part 6) Group mDesiredPos and mDesiredPosSet. r=jfkthame

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mirko Brodesser 2020-03-11 09:17:55 +00:00
parent 2ab206b6d4
commit c1d76e9941
2 changed files with 24 additions and 18 deletions

View File

@ -330,7 +330,7 @@ nsFrameSelection::nsFrameSelection(PresShell* aPresShell, nsIContent* aLimiter,
mPresShell = aPresShell;
mDragState = false;
mDesiredPosSet = false;
mDesiredPos.mIsSet = false;
mLimiters.mLimiter = aLimiter;
mCaret.mMovementStyle =
Preferences::GetInt("bidi.edit.caret_movement_style", 2);
@ -416,8 +416,8 @@ nsresult nsFrameSelection::FetchDesiredPos(nsPoint& aDesiredPos) {
NS_ERROR("fetch desired position failed");
return NS_ERROR_FAILURE;
}
if (mDesiredPosSet) {
aDesiredPos = mDesiredPos;
if (mDesiredPos.mIsSet) {
aDesiredPos = mDesiredPos.mValue;
return NS_OK;
}
@ -444,15 +444,16 @@ nsresult nsFrameSelection::FetchDesiredPos(nsPoint& aDesiredPos) {
return NS_OK;
}
void nsFrameSelection::InvalidateDesiredPos() // do not listen to mDesiredPos;
// you must get another.
void nsFrameSelection::InvalidateDesiredPos() // do not listen to
// mDesiredPos.mValue; you must
// get another.
{
mDesiredPosSet = false;
mDesiredPos.mIsSet = false;
}
void nsFrameSelection::SetDesiredPos(nsPoint aPos) {
mDesiredPos = aPos;
mDesiredPosSet = true;
mDesiredPos.mValue = aPos;
mDesiredPos.mIsSet = true;
}
nsresult nsFrameSelection::ConstrainFrameAndPointToAnchorSubtree(
@ -1325,10 +1326,10 @@ nsresult nsFrameSelection::TakeFocus(nsIContent* aNewFocus,
mBatching = batching;
mChangesDuringBatching = changes;
} else {
bool oldDesiredPosSet = mDesiredPosSet; // need to keep old desired
// position if it was set.
bool oldDesiredPosSet = mDesiredPos.mIsSet; // need to keep old desired
// position if it was set.
mDomSelections[index]->Collapse(aNewFocus, aContentOffset);
mDesiredPosSet = oldDesiredPosSet; // now reset desired pos back.
mDesiredPos.mIsSet = oldDesiredPosSet; // now reset desired pos back.
mBatching = batching;
mChangesDuringBatching = changes;
}
@ -1735,8 +1736,8 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
}
// find out where the caret is.
// we should know mDesiredPos value of nsFrameSelection, but I havent seen
// that behavior in other windows applications yet.
// we should know mDesiredPos.mValue value of nsFrameSelection, but I havent
// seen that behavior in other windows applications yet.
RefPtr<Selection> selection = GetSelection(SelectionType::eNormal);
if (!selection) {
return NS_OK;

View File

@ -776,9 +776,9 @@ class nsFrameSelection final {
nsresult FetchDesiredPos(
nsPoint& aDesiredPos); // the position requested by the Key Handling for
// up down
void
InvalidateDesiredPos(); // do not listen to mDesiredPos you must get another.
void SetDesiredPos(nsPoint aPos); // set the mDesiredPos
void InvalidateDesiredPos(); // do not listen to mDesiredPos.mValue you must
// get another.
void SetDesiredPos(nsPoint aPos); // set the mDesiredPos.mValue
uint32_t GetBatching() const { return mBatching; }
void SetDirty(bool aDirty = true) {
@ -906,7 +906,13 @@ class nsFrameSelection final {
nsBidiLevel mKbdBidiLevel = NSBIDI_LTR;
nsPoint mDesiredPos;
// TODO: could presumably be transformed to a `mozilla::Maybe`.
struct DesiredPos {
nsPoint mValue;
bool mIsSet = false;
};
DesiredPos mDesiredPos;
struct DelayedMouseEvent {
bool mIsValid = false;
@ -920,7 +926,6 @@ class nsFrameSelection final {
bool mChangesDuringBatching = false;
bool mDragState = false; // for drag purposes
bool mDesiredPosSet = false;
bool mAccessibleCaretEnabled = false;
static bool sSelectionEventsOnTextControlsEnabled;