зеркало из 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);
|
||||
}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
nsresult Extend(nsINode* aContainer, int32_t aOffset);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult Extend(nsINode* aContainer, int32_t aOffset);
|
||||
|
||||
/**
|
||||
* 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 CollapseToEndJS(mozilla::ErrorResult& aRv);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
void ExtendJS(nsINode& aContainer, uint32_t aOffset,
|
||||
mozilla::ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT void ExtendJS(nsINode& aContainer, uint32_t aOffset,
|
||||
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
|
||||
* selection end.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
void Extend(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT void Extend(nsINode& aContainer, uint32_t aOffset,
|
||||
ErrorResult& aRv);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT void AddRangeAndSelectFramesAndNotifyListeners(
|
||||
nsRange& aRange, mozilla::ErrorResult& aRv);
|
||||
|
|
|
@ -1390,10 +1390,12 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
|||
mBatching; // hack to use the collapse code.
|
||||
mBatching.mCounter = 1;
|
||||
|
||||
RefPtr<Selection> selection = mDomSelections[index];
|
||||
|
||||
if (aFocusMode == FocusMode::kMultiRangeSelection) {
|
||||
// Remove existing collapsed ranges as there's no point in having
|
||||
// non-anchor/focus collapsed ranges.
|
||||
mDomSelections[index]->RemoveCollapsedRanges();
|
||||
selection->RemoveCollapsedRanges();
|
||||
|
||||
ErrorResult error;
|
||||
RefPtr<nsRange> newRange = nsRange::Create(
|
||||
|
@ -1402,14 +1404,12 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
|||
return error.StealNSResult();
|
||||
}
|
||||
MOZ_ASSERT(newRange);
|
||||
const RefPtr<Selection> selection{mDomSelections[index]};
|
||||
selection->AddRangeAndSelectFramesAndNotifyListeners(*newRange,
|
||||
IgnoreErrors());
|
||||
} else {
|
||||
bool oldDesiredPosSet =
|
||||
mDesiredCaretPos.mIsSet; // need to keep old desired
|
||||
// position if it was set.
|
||||
RefPtr<Selection> selection = mDomSelections[index];
|
||||
selection->CollapseInLimiter(&aNewFocus, aContentOffset);
|
||||
mDesiredCaretPos.mIsSet =
|
||||
oldDesiredPosSet; // now reset desired pos back.
|
||||
|
@ -1418,7 +1418,7 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
|||
mBatching = saveBatching;
|
||||
|
||||
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
|
||||
|
@ -1487,16 +1487,16 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
RefPtr<Selection> selection = mDomSelections[index];
|
||||
// XXXX Problem: Shift+click in browser is appending text selection to
|
||||
// selected table!!!
|
||||
// is this the place to erase seleced cells ?????
|
||||
if (mDomSelections[index]->GetDirection() == eDirNext &&
|
||||
aContentEndOffset > aContentOffset) // didn't go far enough
|
||||
{
|
||||
mDomSelections[index]->Extend(
|
||||
&aNewFocus, aContentEndOffset); // this will only redraw the diff
|
||||
} else
|
||||
mDomSelections[index]->Extend(&aNewFocus, aContentOffset);
|
||||
// is this the place to erase selected cells ?????
|
||||
uint32_t offset =
|
||||
(selection->GetDirection() == eDirNext &&
|
||||
aContentEndOffset > aContentOffset) // didn't go far enough
|
||||
? aContentEndOffset // this will only redraw the diff
|
||||
: aContentOffset;
|
||||
selection->Extend(&aNewFocus, offset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче