зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1671768 - Part 2: Use MOZ_CAN_RUN_SCRIPT for Selection::Extend r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D103778
This commit is contained in:
Родитель
03a9abe590
Коммит
e0304db4c3
|
@ -210,8 +210,7 @@ class Selection final : public nsSupportsWeakReference,
|
||||||
CollapseInternal(InLimiter::eYes, aPoint, aRv);
|
CollapseInternal(InLimiter::eYes, aPoint, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT nsresult Extend(nsINode* aContainer, int32_t aOffset);
|
||||||
nsresult Extend(nsINode* aContainer, int32_t aOffset);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See mStyledRanges.mRanges.
|
* See mStyledRanges.mRanges.
|
||||||
|
@ -329,9 +328,8 @@ class Selection final : public nsSupportsWeakReference,
|
||||||
MOZ_CAN_RUN_SCRIPT void CollapseToStartJS(mozilla::ErrorResult& aRv);
|
MOZ_CAN_RUN_SCRIPT void CollapseToStartJS(mozilla::ErrorResult& aRv);
|
||||||
MOZ_CAN_RUN_SCRIPT void CollapseToEndJS(mozilla::ErrorResult& aRv);
|
MOZ_CAN_RUN_SCRIPT void CollapseToEndJS(mozilla::ErrorResult& aRv);
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT void ExtendJS(nsINode& aContainer, uint32_t aOffset,
|
||||||
void ExtendJS(nsINode& aContainer, uint32_t aOffset,
|
mozilla::ErrorResult& aRv);
|
||||||
mozilla::ErrorResult& aRv);
|
|
||||||
|
|
||||||
void SelectAllChildrenJS(nsINode& aNode, mozilla::ErrorResult& aRv);
|
void SelectAllChildrenJS(nsINode& aNode, mozilla::ErrorResult& aRv);
|
||||||
|
|
||||||
|
@ -504,8 +502,8 @@ class Selection final : public nsSupportsWeakReference,
|
||||||
* @param aOffset Where in aContainer to place the offset of the new
|
* @param aOffset Where in aContainer to place the offset of the new
|
||||||
* selection end.
|
* selection end.
|
||||||
*/
|
*/
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT void Extend(nsINode& aContainer, uint32_t aOffset,
|
||||||
void Extend(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT void AddRangeAndSelectFramesAndNotifyListeners(
|
MOZ_CAN_RUN_SCRIPT void AddRangeAndSelectFramesAndNotifyListeners(
|
||||||
nsRange& aRange, mozilla::ErrorResult& aRv);
|
nsRange& aRange, mozilla::ErrorResult& aRv);
|
||||||
|
|
|
@ -1390,10 +1390,12 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
||||||
mBatching; // hack to use the collapse code.
|
mBatching; // hack to use the collapse code.
|
||||||
mBatching.mCounter = 1;
|
mBatching.mCounter = 1;
|
||||||
|
|
||||||
|
RefPtr<Selection> selection = mDomSelections[index];
|
||||||
|
|
||||||
if (aFocusMode == FocusMode::kMultiRangeSelection) {
|
if (aFocusMode == FocusMode::kMultiRangeSelection) {
|
||||||
// Remove existing collapsed ranges as there's no point in having
|
// Remove existing collapsed ranges as there's no point in having
|
||||||
// non-anchor/focus collapsed ranges.
|
// non-anchor/focus collapsed ranges.
|
||||||
mDomSelections[index]->RemoveCollapsedRanges();
|
selection->RemoveCollapsedRanges();
|
||||||
|
|
||||||
ErrorResult error;
|
ErrorResult error;
|
||||||
RefPtr<nsRange> newRange = nsRange::Create(
|
RefPtr<nsRange> newRange = nsRange::Create(
|
||||||
|
@ -1402,14 +1404,12 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
||||||
return error.StealNSResult();
|
return error.StealNSResult();
|
||||||
}
|
}
|
||||||
MOZ_ASSERT(newRange);
|
MOZ_ASSERT(newRange);
|
||||||
const RefPtr<Selection> selection{mDomSelections[index]};
|
|
||||||
selection->AddRangeAndSelectFramesAndNotifyListeners(*newRange,
|
selection->AddRangeAndSelectFramesAndNotifyListeners(*newRange,
|
||||||
IgnoreErrors());
|
IgnoreErrors());
|
||||||
} else {
|
} else {
|
||||||
bool oldDesiredPosSet =
|
bool oldDesiredPosSet =
|
||||||
mDesiredCaretPos.mIsSet; // need to keep old desired
|
mDesiredCaretPos.mIsSet; // need to keep old desired
|
||||||
// position if it was set.
|
// position if it was set.
|
||||||
RefPtr<Selection> selection = mDomSelections[index];
|
|
||||||
selection->CollapseInLimiter(&aNewFocus, aContentOffset);
|
selection->CollapseInLimiter(&aNewFocus, aContentOffset);
|
||||||
mDesiredCaretPos.mIsSet =
|
mDesiredCaretPos.mIsSet =
|
||||||
oldDesiredPosSet; // now reset desired pos back.
|
oldDesiredPosSet; // now reset desired pos back.
|
||||||
|
@ -1418,7 +1418,7 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
||||||
mBatching = saveBatching;
|
mBatching = saveBatching;
|
||||||
|
|
||||||
if (aContentEndOffset != aContentOffset) {
|
if (aContentEndOffset != aContentOffset) {
|
||||||
mDomSelections[index]->Extend(&aNewFocus, aContentEndOffset);
|
selection->Extend(&aNewFocus, aContentEndOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// find out if we are inside a table. if so, find out which one and which
|
// find out if we are inside a table. if so, find out which one and which
|
||||||
|
@ -1487,16 +1487,16 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
RefPtr<Selection> selection = mDomSelections[index];
|
||||||
// XXXX Problem: Shift+click in browser is appending text selection to
|
// XXXX Problem: Shift+click in browser is appending text selection to
|
||||||
// selected table!!!
|
// selected table!!!
|
||||||
// is this the place to erase seleced cells ?????
|
// is this the place to erase selected cells ?????
|
||||||
if (mDomSelections[index]->GetDirection() == eDirNext &&
|
uint32_t offset =
|
||||||
aContentEndOffset > aContentOffset) // didn't go far enough
|
(selection->GetDirection() == eDirNext &&
|
||||||
{
|
aContentEndOffset > aContentOffset) // didn't go far enough
|
||||||
mDomSelections[index]->Extend(
|
? aContentEndOffset // this will only redraw the diff
|
||||||
&aNewFocus, aContentEndOffset); // this will only redraw the diff
|
: aContentOffset;
|
||||||
} else
|
selection->Extend(&aNewFocus, offset);
|
||||||
mDomSelections[index]->Extend(&aNewFocus, aContentOffset);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче