Bug 1954394 - Mark some nsFrameSelection methods which change selection r=jjaschke
Even in these days, we notify selection listeners of selection changes **synchronously**. Thus, we need to mark all selection change methods as `MOZ_CAN_RUN_SCRIPT` even though they are safe in the most cases. Depends on D241776 Differential Revision: https://phabricator.services.mozilla.com/D241778
This commit is contained in:
@@ -1503,10 +1503,10 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
||||
// Start selecting in the cell we were in before
|
||||
ParentAndOffset parentAndOffset{
|
||||
*mTableSelection.mClosestInclusiveTableCellAncestor};
|
||||
if (parentAndOffset.mParent) {
|
||||
const nsresult result = HandleTableSelection(
|
||||
parentAndOffset.mParent, parentAndOffset.mOffset,
|
||||
TableSelectionMode::Cell, &event);
|
||||
if (const nsCOMPtr<nsINode> previousParent = parentAndOffset.mParent) {
|
||||
const nsresult result =
|
||||
HandleTableSelection(previousParent, parentAndOffset.mOffset,
|
||||
TableSelectionMode::Cell, &event);
|
||||
if (NS_WARN_IF(NS_FAILED(result))) {
|
||||
return result;
|
||||
}
|
||||
@@ -1518,13 +1518,13 @@ nsresult nsFrameSelection::TakeFocus(nsIContent& aNewFocus,
|
||||
// XXXX We need to REALLY get the current key shift state
|
||||
// (we'd need to add event listener -- let's not bother for now)
|
||||
event.mModifiers &= ~MODIFIER_SHIFT; // aExtendSelection;
|
||||
if (parentAndOffset.mParent) {
|
||||
if (const nsCOMPtr<nsINode> newParent = parentAndOffset.mParent) {
|
||||
mTableSelection.mClosestInclusiveTableCellAncestor =
|
||||
inclusiveTableCellAncestor;
|
||||
// Continue selection into next cell
|
||||
const nsresult result = HandleTableSelection(
|
||||
parentAndOffset.mParent, parentAndOffset.mOffset,
|
||||
TableSelectionMode::Cell, &event);
|
||||
const nsresult result =
|
||||
HandleTableSelection(newParent, parentAndOffset.mOffset,
|
||||
TableSelectionMode::Cell, &event);
|
||||
if (NS_WARN_IF(NS_FAILED(result))) {
|
||||
return result;
|
||||
}
|
||||
@@ -2364,7 +2364,8 @@ nsresult nsFrameSelection::TableSelection::HandleDragSelecting(
|
||||
}
|
||||
|
||||
// Reselect block of cells to new end location
|
||||
return SelectBlockOfCells(mStartSelectedCell, aChildContent,
|
||||
const nsCOMPtr<nsIContent> startSelectedCell = mStartSelectedCell;
|
||||
return SelectBlockOfCells(startSelectedCell, aChildContent,
|
||||
aNormalSelection);
|
||||
}
|
||||
}
|
||||
@@ -2482,7 +2483,9 @@ nsresult nsFrameSelection::TableSelection::HandleMouseUpOrDown(
|
||||
// Shift key is down: append a block selection
|
||||
mDragSelectingCells = false;
|
||||
|
||||
return SelectBlockOfCells(mAppendStartSelectedCell, aChildContent,
|
||||
const OwningNonNull<nsIContent> appendStartSelectedCell =
|
||||
*mAppendStartSelectedCell;
|
||||
return SelectBlockOfCells(appendStartSelectedCell, aChildContent,
|
||||
aNormalSelection);
|
||||
}
|
||||
|
||||
@@ -2892,8 +2895,10 @@ nsresult nsFrameSelection::TableSelection::SelectRowOrColumn(
|
||||
mStartSelectedCell = firstAndLastCell.inspect().mFirst;
|
||||
}
|
||||
|
||||
rv = SelectBlockOfCells(mStartSelectedCell,
|
||||
firstAndLastCell.inspect().mLast, aNormalSelection);
|
||||
const nsCOMPtr<nsIContent> startSelectedCell = mStartSelectedCell;
|
||||
rv = SelectBlockOfCells(startSelectedCell,
|
||||
MOZ_KnownLive(firstAndLastCell.inspect().mLast),
|
||||
aNormalSelection);
|
||||
|
||||
// This gets set to the cell at end of row/col,
|
||||
// but we need it to be the cell under cursor
|
||||
|
||||
Reference in New Issue
Block a user