зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1677253 - Part 2: Detect direction change in SelectionChangeEventDispatcher r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D101246
This commit is contained in:
Родитель
7bb3355218
Коммит
1a8150e79d
|
@ -86,12 +86,13 @@ void SelectionChangeEventDispatcher::OnSelectionChange(Document* aDoc,
|
||||||
// Don't bother checking this if we are hiding changes.
|
// Don't bother checking this if we are hiding changes.
|
||||||
if (mOldRanges.Length() == aSel->RangeCount() &&
|
if (mOldRanges.Length() == aSel->RangeCount() &&
|
||||||
!aSel->IsBlockingSelectionChangeEvents()) {
|
!aSel->IsBlockingSelectionChangeEvents()) {
|
||||||
bool changed = false;
|
bool changed = mOldDirection != aSel->GetDirection();
|
||||||
|
if (!changed) {
|
||||||
for (size_t i = 0; i < mOldRanges.Length(); i++) {
|
for (size_t i = 0; i < mOldRanges.Length(); i++) {
|
||||||
if (!mOldRanges[i].Equals(aSel->GetRangeAt(i))) {
|
if (!mOldRanges[i].Equals(aSel->GetRangeAt(static_cast<int32_t>(i)))) {
|
||||||
changed = true;
|
changed = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +106,7 @@ void SelectionChangeEventDispatcher::OnSelectionChange(Document* aDoc,
|
||||||
for (size_t i = 0; i < aSel->RangeCount(); i++) {
|
for (size_t i = 0; i < aSel->RangeCount(); i++) {
|
||||||
mOldRanges.AppendElement(RawRangeData(aSel->GetRangeAt(i)));
|
mOldRanges.AppendElement(RawRangeData(aSel->GetRangeAt(i)));
|
||||||
}
|
}
|
||||||
|
mOldDirection = aSel->GetDirection();
|
||||||
|
|
||||||
if (doc) {
|
if (doc) {
|
||||||
nsPIDOMWindowInner* inner = doc->GetInnerWindow();
|
nsPIDOMWindowInner* inner = doc->GetInnerWindow();
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsDirection.h"
|
||||||
|
|
||||||
class nsINode;
|
class nsINode;
|
||||||
class nsRange;
|
class nsRange;
|
||||||
|
@ -58,6 +59,7 @@ class SelectionChangeEventDispatcher final {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsTArray<RawRangeData> mOldRanges;
|
nsTArray<RawRangeData> mOldRanges;
|
||||||
|
nsDirection mOldDirection;
|
||||||
|
|
||||||
~SelectionChangeEventDispatcher() = default;
|
~SelectionChangeEventDispatcher() = default;
|
||||||
};
|
};
|
||||||
|
|
|
@ -876,12 +876,9 @@ nsresult nsTextControlFrame::SetSelectionInternal(
|
||||||
direction = (aDirection == eBackward) ? eDirPrevious : eDirNext;
|
direction = (aDirection == eBackward) ? eDirPrevious : eDirNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorResult error;
|
MOZ_TRY(selection->SetStartAndEndInLimiter(*aStartNode, aStartOffset,
|
||||||
selection->SetStartAndEndInLimiter(*aStartNode, aStartOffset, *aEndNode,
|
*aEndNode, aEndOffset, direction,
|
||||||
aEndOffset, error);
|
nsISelectionListener::JS_REASON));
|
||||||
MOZ_TRY(error.StealNSResult());
|
|
||||||
|
|
||||||
selection->SetDirection(direction);
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче