зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1633448: part 5) Rename `AreUserSelectedRangesNonEmpty` to `IsUserSelectionNotCollapsed`. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D73233
This commit is contained in:
Родитель
289aa341f5
Коммит
6aabdca219
|
@ -844,19 +844,19 @@ static bool MaybeDispatchSelectstartEvent(
|
|||
}
|
||||
|
||||
// static
|
||||
bool Selection::AreUserSelectedRangesNonEmpty(
|
||||
bool Selection::IsUserSelectionNotCollapsed(
|
||||
const nsRange& aRange, nsTArray<RefPtr<nsRange>>& aTempRangesToAdd) {
|
||||
MOZ_ASSERT(aTempRangesToAdd.IsEmpty());
|
||||
|
||||
RefPtr<nsRange> scratchRange = aRange.CloneRange();
|
||||
UserSelectRangesToAdd(scratchRange, aTempRangesToAdd);
|
||||
const bool newRangesNonEmpty =
|
||||
const bool userSelectionNotCollapsed =
|
||||
aTempRangesToAdd.Length() > 1 ||
|
||||
(aTempRangesToAdd.Length() == 1 && !aTempRangesToAdd[0]->Collapsed());
|
||||
|
||||
aTempRangesToAdd.ClearAndRetainStorage();
|
||||
|
||||
return newRangesNonEmpty;
|
||||
return userSelectionNotCollapsed;
|
||||
}
|
||||
|
||||
nsresult Selection::AddRangesForUserSelectableNodes(
|
||||
|
@ -892,10 +892,11 @@ nsresult Selection::AddRangesForUserSelectableNodes(
|
|||
// the selectstart event could have caused the world to change, and
|
||||
// required ranges to be re-generated
|
||||
|
||||
const bool newRangesNonEmpty =
|
||||
AreUserSelectedRangesNonEmpty(*aRange, rangesToAdd);
|
||||
MOZ_ASSERT(!newRangesNonEmpty || nsContentUtils::IsSafeToRunScript());
|
||||
if (newRangesNonEmpty && nsContentUtils::IsSafeToRunScript()) {
|
||||
const bool userSelectionNotCollapsed =
|
||||
IsUserSelectionNotCollapsed(*aRange, rangesToAdd);
|
||||
MOZ_ASSERT(!userSelectionNotCollapsed ||
|
||||
nsContentUtils::IsSafeToRunScript());
|
||||
if (userSelectionNotCollapsed && nsContentUtils::IsSafeToRunScript()) {
|
||||
// The spec currently doesn't say that we should dispatch this event
|
||||
// on text controls, so for now we only support doing that under a
|
||||
// pref, disabled by default.
|
||||
|
|
|
@ -154,7 +154,7 @@ class Selection final : public nsSupportsWeakReference,
|
|||
ScrollAxis aHorizontal = ScrollAxis(), int32_t aFlags = 0);
|
||||
|
||||
private:
|
||||
static bool AreUserSelectedRangesNonEmpty(
|
||||
static bool IsUserSelectionNotCollapsed(
|
||||
const nsRange& aRange, nsTArray<RefPtr<nsRange>>& aTempRangesToAdd);
|
||||
/**
|
||||
* https://w3c.github.io/selection-api/#selectstart-event.
|
||||
|
|
Загрузка…
Ссылка в новой задаче