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:
@@ -167,8 +167,8 @@ class Selection final : public nsSupportsWeakReference,
|
||||
* @param aReasons potentially multiple of the reasons defined in
|
||||
* nsISelectionListener.idl
|
||||
*/
|
||||
void EndBatchChanges(const char* aDetails,
|
||||
int16_t aReason = nsISelectionListener::NO_REASON);
|
||||
MOZ_CAN_RUN_SCRIPT void EndBatchChanges(
|
||||
const char* aDetails, int16_t aReason = nsISelectionListener::NO_REASON);
|
||||
|
||||
/**
|
||||
* NotifyAutoCopy() starts to notify AutoCopyListener of selection changes.
|
||||
@@ -781,8 +781,8 @@ class Selection final : public nsSupportsWeakReference,
|
||||
const TextRangeStyle& aTextRangeStyle);
|
||||
|
||||
// Methods to manipulate our mFrameSelection's ancestor limiter.
|
||||
Element* GetAncestorLimiter() const;
|
||||
void SetAncestorLimiter(Element* aLimiter);
|
||||
[[nodiscard]] Element* GetAncestorLimiter() const;
|
||||
MOZ_CAN_RUN_SCRIPT void SetAncestorLimiter(Element* aLimiter);
|
||||
|
||||
/*
|
||||
* Frame Offset cache can be used just during calling
|
||||
@@ -1172,15 +1172,13 @@ class MOZ_STACK_CLASS SelectionBatcher final {
|
||||
* This won't be stored nor exposed to selection listeners etc, used only for
|
||||
* logging. This MUST be living when the destructor runs.
|
||||
*/
|
||||
// TODO: Mark these constructors `MOZ_CAN_RUN_SCRIPT` because the destructor
|
||||
// may run script via nsISelectionListener.
|
||||
explicit SelectionBatcher(Selection& aSelectionRef,
|
||||
const char* aRequesterFuncName,
|
||||
int16_t aReasons = nsISelectionListener::NO_REASON)
|
||||
MOZ_CAN_RUN_SCRIPT explicit SelectionBatcher(
|
||||
Selection& aSelectionRef, const char* aRequesterFuncName,
|
||||
int16_t aReasons = nsISelectionListener::NO_REASON)
|
||||
: SelectionBatcher(&aSelectionRef, aRequesterFuncName, aReasons) {}
|
||||
explicit SelectionBatcher(Selection* aSelection,
|
||||
const char* aRequesterFuncName,
|
||||
int16_t aReasons = nsISelectionListener::NO_REASON)
|
||||
MOZ_CAN_RUN_SCRIPT explicit SelectionBatcher(
|
||||
Selection* aSelection, const char* aRequesterFuncName,
|
||||
int16_t aReasons = nsISelectionListener::NO_REASON)
|
||||
: mSelection(aSelection),
|
||||
mReasons(aReasons),
|
||||
mRequesterFuncName(aRequesterFuncName) {
|
||||
@@ -1189,9 +1187,9 @@ class MOZ_STACK_CLASS SelectionBatcher final {
|
||||
}
|
||||
}
|
||||
|
||||
~SelectionBatcher() {
|
||||
MOZ_CAN_RUN_SCRIPT ~SelectionBatcher() {
|
||||
if (mSelection) {
|
||||
mSelection->EndBatchChanges(mRequesterFuncName, mReasons);
|
||||
MOZ_KnownLive(mSelection)->EndBatchChanges(mRequesterFuncName, mReasons);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -122,10 +122,9 @@ class nsSelectionCommandsBase : public nsIControllerCommand {
|
||||
NS_IMETHOD GetCommandStateParams(const char* aCommandName,
|
||||
nsICommandParams* aParams,
|
||||
nsISupports* aCommandContext) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
NS_IMETHOD DoCommandParams(const char* aCommandName,
|
||||
nsICommandParams* aParams,
|
||||
nsISupports* aCommandContext) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD
|
||||
DoCommandParams(const char* aCommandName, nsICommandParams* aParams,
|
||||
nsISupports* aCommandContext) override;
|
||||
|
||||
protected:
|
||||
virtual ~nsSelectionCommandsBase() = default;
|
||||
@@ -142,8 +141,8 @@ class nsSelectionCommandsBase : public nsIControllerCommand {
|
||||
// caret' setting
|
||||
class nsSelectMoveScrollCommand : public nsSelectionCommandsBase {
|
||||
public:
|
||||
NS_IMETHOD DoCommand(const char* aCommandName,
|
||||
nsISupports* aCommandContext) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD
|
||||
DoCommand(const char* aCommandName, nsISupports* aCommandContext) override;
|
||||
|
||||
// no member variables, please, we're stateless!
|
||||
};
|
||||
@@ -151,8 +150,8 @@ class nsSelectMoveScrollCommand : public nsSelectionCommandsBase {
|
||||
// this class implements physical-movement versions of the above
|
||||
class nsPhysicalSelectMoveScrollCommand : public nsSelectionCommandsBase {
|
||||
public:
|
||||
NS_IMETHOD DoCommand(const char* aCommandName,
|
||||
nsISupports* aCommandContext) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD
|
||||
DoCommand(const char* aCommandName, nsISupports* aCommandContext) override;
|
||||
|
||||
// no member variables, please, we're stateless!
|
||||
};
|
||||
@@ -160,8 +159,8 @@ class nsPhysicalSelectMoveScrollCommand : public nsSelectionCommandsBase {
|
||||
// this class implements other selection commands
|
||||
class nsSelectCommand : public nsSelectionCommandsBase {
|
||||
public:
|
||||
NS_IMETHOD DoCommand(const char* aCommandName,
|
||||
nsISupports* aCommandContext) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD
|
||||
DoCommand(const char* aCommandName, nsISupports* aCommandContext) override;
|
||||
|
||||
// no member variables, please, we're stateless!
|
||||
};
|
||||
@@ -169,8 +168,8 @@ class nsSelectCommand : public nsSelectionCommandsBase {
|
||||
// this class implements physical-movement versions of selection commands
|
||||
class nsPhysicalSelectCommand : public nsSelectionCommandsBase {
|
||||
public:
|
||||
NS_IMETHOD DoCommand(const char* aCommandName,
|
||||
nsISupports* aCommandContext) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD
|
||||
DoCommand(const char* aCommandName, nsISupports* aCommandContext) override;
|
||||
|
||||
// no member variables, please, we're stateless!
|
||||
};
|
||||
|
||||
@@ -147,6 +147,7 @@ interface nsISelectionController : nsISelectionDisplay
|
||||
* @param aRegion the region inside the selection to scroll into view. //SelectionRegion
|
||||
* @param aFlags the scroll flags.
|
||||
*/
|
||||
[can_run_script]
|
||||
void scrollSelectionIntoView(in short type, in short region, in nsISelectionController_ControllerScrollFlags flags);
|
||||
|
||||
/**
|
||||
@@ -203,6 +204,7 @@ interface nsISelectionController : nsISelectionDisplay
|
||||
* @param aForward forward or backward if false
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
[can_run_script]
|
||||
void characterMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** PhysicalMove will move the selection one "unit" in a given direction
|
||||
@@ -214,6 +216,7 @@ interface nsISelectionController : nsISelectionDisplay
|
||||
* @param aAmount character/line; word/lineBoundary
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
[can_run_script]
|
||||
void physicalMove(in short direction, in short amount, in boolean extend);
|
||||
|
||||
/**
|
||||
@@ -232,6 +235,7 @@ interface nsISelectionController : nsISelectionDisplay
|
||||
* @param aForward forward or backward if false
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
[can_run_script]
|
||||
void wordMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** LineMove will move the selection one line forward/backward in the document.
|
||||
@@ -241,6 +245,7 @@ interface nsISelectionController : nsISelectionDisplay
|
||||
* @param aForward forward or backward if false
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
[can_run_script]
|
||||
void lineMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** IntraLineMove will move the selection to the front of the line or end of the line
|
||||
@@ -251,6 +256,7 @@ interface nsISelectionController : nsISelectionDisplay
|
||||
* @param aForward forward or backward if false
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
[can_run_script]
|
||||
void intraLineMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** PageMove will move the selection one page forward/backward in the document.
|
||||
|
||||
@@ -357,9 +357,9 @@ class TextInputSelectionController final : public nsSupportsWeakReference,
|
||||
NS_IMETHOD GetSelectionFromScript(RawSelectionType aRawSelectionType,
|
||||
Selection** aSelection) override;
|
||||
Selection* GetSelection(RawSelectionType aRawSelectionType) override;
|
||||
NS_IMETHOD ScrollSelectionIntoView(RawSelectionType aRawSelectionType,
|
||||
SelectionRegion aRegion,
|
||||
ControllerScrollFlags aFlags) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD ScrollSelectionIntoView(
|
||||
RawSelectionType aRawSelectionType, SelectionRegion aRegion,
|
||||
ControllerScrollFlags aFlags) override;
|
||||
NS_IMETHOD RepaintSelection(RawSelectionType aRawSelectionType) override;
|
||||
nsresult RepaintSelection(nsPresContext* aPresContext,
|
||||
SelectionType aSelectionType);
|
||||
@@ -368,15 +368,16 @@ class TextInputSelectionController final : public nsSupportsWeakReference,
|
||||
NS_IMETHOD GetCaretEnabled(bool* _retval) override;
|
||||
NS_IMETHOD GetCaretVisible(bool* _retval) override;
|
||||
NS_IMETHOD SetCaretVisibilityDuringSelection(bool aVisibility) override;
|
||||
NS_IMETHOD PhysicalMove(int16_t aDirection, int16_t aAmount,
|
||||
bool aExtend) override;
|
||||
NS_IMETHOD CharacterMove(bool aForward, bool aExtend) override;
|
||||
NS_IMETHOD WordMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD LineMove(bool aForward,
|
||||
bool aExtend) override;
|
||||
NS_IMETHOD IntraLineMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
NS_IMETHOD PageMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD PhysicalMove(int16_t aDirection,
|
||||
int16_t aAmount,
|
||||
bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD CharacterMove(bool aForward,
|
||||
bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD WordMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD LineMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD IntraLineMove(bool aForward,
|
||||
bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD PageMove(bool aForward, bool aExtend) override;
|
||||
NS_IMETHOD CompleteScroll(bool aForward) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD CompleteMove(bool aForward,
|
||||
bool aExtend) override;
|
||||
@@ -2296,7 +2297,9 @@ void TextControlState::SetRangeText(const nsAString& aReplacement,
|
||||
Selection* selection =
|
||||
mSelCon ? mSelCon->GetSelection(SelectionType::eNormal) : nullptr;
|
||||
SelectionBatcher selectionBatcher(
|
||||
selection, __FUNCTION__,
|
||||
// `selection` will be grabbed by selectionBatcher itself. Thus, we don't
|
||||
// need to grab it by ourselves.
|
||||
MOZ_KnownLive(selection), __FUNCTION__,
|
||||
nsISelectionListener::JS_REASON); // no-op if nullptr
|
||||
|
||||
MOZ_ASSERT(aStart <= aEnd);
|
||||
@@ -2791,7 +2794,10 @@ bool TextControlState::SetValueWithTextEditor(
|
||||
// FYI: It's safe to use raw pointer for selection here because
|
||||
// SelectionBatcher will grab it with RefPtr.
|
||||
Selection* selection = mSelCon->GetSelection(SelectionType::eNormal);
|
||||
SelectionBatcher selectionBatcher(selection, __FUNCTION__);
|
||||
SelectionBatcher selectionBatcher(
|
||||
// `selection` will be grabbed by selectionBatcher itself. Thus, we don't
|
||||
// need to grab it by ourselves.
|
||||
MOZ_KnownLive(selection), __FUNCTION__);
|
||||
|
||||
// get the flags, remove readonly, disabled and max-length,
|
||||
// set the value, restore flags
|
||||
|
||||
@@ -2534,7 +2534,7 @@ void nsGenericHTMLElement::ChangeEditableState(int32_t aChange) {
|
||||
// in shadow DOM and the composed document is in design mode.
|
||||
if (IsInDesignMode() && !IsInShadowTree() && aChange > 0 &&
|
||||
previousEditingState == Document::EditingState::eContentEditable) {
|
||||
if (HTMLEditor* htmlEditor =
|
||||
if (const RefPtr<HTMLEditor> htmlEditor =
|
||||
nsContentUtils::GetHTMLEditor(document->GetPresContext())) {
|
||||
htmlEditor->NotifyEditingHostMaybeChanged();
|
||||
}
|
||||
|
||||
@@ -971,7 +971,7 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
|
||||
already_AddRefed<nsIURI> GetHrefURIForAnchors() const;
|
||||
|
||||
private:
|
||||
void ChangeEditableState(int32_t aChange);
|
||||
MOZ_CAN_RUN_SCRIPT void ChangeEditableState(int32_t aChange);
|
||||
};
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
@@ -16,12 +16,8 @@ nsresult NS_NewSVGSVGElement(
|
||||
mozilla::dom::FromParser aFromParser);
|
||||
|
||||
// {4b83982c-e5e9-4ca1-abd4-14d27e8b3531}
|
||||
#define MOZILLA_SVGSVGELEMENT_IID \
|
||||
{ \
|
||||
0x4b83982c, 0xe5e9, 0x4ca1, { \
|
||||
0xab, 0xd4, 0x14, 0xd2, 0x7e, 0x8b, 0x35, 0x31 \
|
||||
} \
|
||||
}
|
||||
#define MOZILLA_SVGSVGELEMENT_IID \
|
||||
{0x4b83982c, 0xe5e9, 0x4ca1, {0xab, 0xd4, 0x14, 0xd2, 0x7e, 0x8b, 0x35, 0x31}}
|
||||
|
||||
namespace mozilla {
|
||||
class AutoSVGViewHandler;
|
||||
@@ -112,7 +108,7 @@ class SVGSVGElement final : public SVGSVGElementBase {
|
||||
bool AnimationsPaused();
|
||||
float GetCurrentTimeAsFloat();
|
||||
void SetCurrentTime(float seconds);
|
||||
void DeselectAll();
|
||||
MOZ_CAN_RUN_SCRIPT void DeselectAll();
|
||||
already_AddRefed<DOMSVGNumber> CreateSVGNumber();
|
||||
already_AddRefed<DOMSVGLength> CreateSVGLength();
|
||||
already_AddRefed<DOMSVGAngle> CreateSVGAngle();
|
||||
|
||||
@@ -5694,7 +5694,7 @@ void EditorBase::InitializeSelectionAncestorLimit(
|
||||
Element& aAncestorLimit) const {
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
SelectionRef().SetAncestorLimiter(&aAncestorLimit);
|
||||
MOZ_KnownLive(SelectionRef()).SetAncestorLimiter(&aAncestorLimit);
|
||||
}
|
||||
|
||||
nsresult EditorBase::InitializeSelection(
|
||||
@@ -6616,19 +6616,20 @@ void EditorBase::AutoEditActionDataSetter::UpdateSelectionCache(
|
||||
MOZ_ASSERT_UNREACHABLE("You do something wrong");
|
||||
}();
|
||||
|
||||
RefPtr<Selection> previousSelection = mSelection;
|
||||
|
||||
// Keep grabbing the old selection in the top level edit action data until the
|
||||
// all owners end handling it.
|
||||
if (mSelection) {
|
||||
topLevelEditActionData.mRetiredSelections.AppendElement(*mSelection);
|
||||
if (previousSelection) {
|
||||
topLevelEditActionData.mRetiredSelections.AppendElement(*previousSelection);
|
||||
}
|
||||
|
||||
// If the old selection is in batch, we should end the batch which
|
||||
// `EditorBase::BeginUpdateViewBatch` started.
|
||||
if (mEditorBase.mUpdateCount && mSelection) {
|
||||
mSelection->EndBatchChanges(__FUNCTION__);
|
||||
if (mEditorBase.mUpdateCount && previousSelection) {
|
||||
previousSelection->EndBatchChanges(__FUNCTION__);
|
||||
}
|
||||
|
||||
Selection* previousSelection = mSelection;
|
||||
mSelection = &aSelection;
|
||||
for (AutoEditActionDataSetter* parentActionData = mParentData;
|
||||
parentActionData; parentActionData = parentActionData->mParentData) {
|
||||
|
||||
@@ -1340,7 +1340,7 @@ class EditorBase : public nsIEditor,
|
||||
return mParentData ? mParentData->RangeUpdaterRef() : mRangeUpdater;
|
||||
}
|
||||
|
||||
void UpdateSelectionCache(Selection& aSelection);
|
||||
MOZ_CAN_RUN_SCRIPT void UpdateSelectionCache(Selection& aSelection);
|
||||
|
||||
bool IsDispatchingInputEvent() const {
|
||||
return mDispatchingInputEvent ||
|
||||
@@ -2548,7 +2548,8 @@ class EditorBase : public nsIEditor,
|
||||
* has parent node. So, it's always safe to
|
||||
* call SetAncestorLimit() with this node.
|
||||
*/
|
||||
virtual void InitializeSelectionAncestorLimit(Element& aAncestorLimit) const;
|
||||
MOZ_CAN_RUN_SCRIPT virtual void InitializeSelectionAncestorLimit(
|
||||
Element& aAncestorLimit) const;
|
||||
|
||||
/**
|
||||
* Initializes selection and caret for the editor at getting focus. If
|
||||
|
||||
@@ -726,7 +726,7 @@ class HTMLEditor final : public EditorBase,
|
||||
* NotifyEditingHostMaybeChanged() is called when new element becomes
|
||||
* contenteditable when the document already had contenteditable elements.
|
||||
*/
|
||||
void NotifyEditingHostMaybeChanged();
|
||||
MOZ_CAN_RUN_SCRIPT void NotifyEditingHostMaybeChanged();
|
||||
|
||||
/** Insert a string as quoted text
|
||||
* (whose representation is dependant on the editor type),
|
||||
|
||||
@@ -1260,9 +1260,9 @@ class PresShell final : public nsStubDocumentObserver,
|
||||
|
||||
NS_IMETHOD SetDisplaySelection(int16_t aToggle) override;
|
||||
NS_IMETHOD GetDisplaySelection(int16_t* aToggle) override;
|
||||
NS_IMETHOD ScrollSelectionIntoView(RawSelectionType aRawSelectionType,
|
||||
SelectionRegion aRegion,
|
||||
ControllerScrollFlags aFlags) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD ScrollSelectionIntoView(
|
||||
RawSelectionType aRawSelectionType, SelectionRegion aRegion,
|
||||
ControllerScrollFlags aFlags) override;
|
||||
using nsISelectionController::ScrollSelectionIntoView;
|
||||
NS_IMETHOD RepaintSelection(RawSelectionType aRawSelectionType) override;
|
||||
void SelectionWillTakeFocus() override;
|
||||
@@ -1360,16 +1360,16 @@ class PresShell final : public nsStubDocumentObserver,
|
||||
|
||||
// nsISelectionController
|
||||
|
||||
NS_IMETHOD PhysicalMove(int16_t aDirection, int16_t aAmount,
|
||||
bool aExtend) override;
|
||||
NS_IMETHOD CharacterMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD WordMove(bool aForward,
|
||||
bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD LineMove(bool aForward,
|
||||
bool aExtend) override;
|
||||
NS_IMETHOD IntraLineMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
NS_IMETHOD PageMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD PhysicalMove(int16_t aDirection,
|
||||
int16_t aAmount,
|
||||
bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD CharacterMove(bool aForward,
|
||||
bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD WordMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD LineMove(bool aForward, bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD IntraLineMove(bool aForward,
|
||||
bool aExtend) override;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD PageMove(bool aForward, bool aExtend) override;
|
||||
NS_IMETHOD ScrollPage(bool aForward) override;
|
||||
NS_IMETHOD ScrollLine(bool aForward) override;
|
||||
NS_IMETHOD ScrollCharacter(bool aRight) override;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -354,8 +354,7 @@ class nsFrameSelection final {
|
||||
* @param aMouseEvent passed in so we can get where event occurred
|
||||
* and what keys are pressed
|
||||
*/
|
||||
// TODO: replace with `MOZ_CAN_RUN_SCRIPT`.
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
|
||||
HandleTableSelection(nsINode* aParentContent, int32_t aContentOffset,
|
||||
mozilla::TableSelectionMode aTarget,
|
||||
mozilla::WidgetMouseEvent* aMouseEvent);
|
||||
@@ -377,12 +376,9 @@ class nsFrameSelection final {
|
||||
* @param aEndRowIndex [in] row index where the cells range ends
|
||||
* @param aEndColumnIndex [in] column index where the cells range ends
|
||||
*/
|
||||
// TODO: annotate this with `MOZ_CAN_RUN_SCRIPT` instead.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
nsresult RemoveCellsFromSelection(nsIContent* aTable, int32_t aStartRowIndex,
|
||||
int32_t aStartColumnIndex,
|
||||
int32_t aEndRowIndex,
|
||||
int32_t aEndColumnIndex);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult RemoveCellsFromSelection(
|
||||
nsIContent* aTable, int32_t aStartRowIndex, int32_t aStartColumnIndex,
|
||||
int32_t aEndRowIndex, int32_t aEndColumnIndex);
|
||||
|
||||
/**
|
||||
* Remove cells from selection outside of the given cell range.
|
||||
@@ -393,12 +389,9 @@ class nsFrameSelection final {
|
||||
* @param aEndRowIndex [in] row index where the cells range ends
|
||||
* @param aEndColumnIndex [in] column index where the cells range ends
|
||||
*/
|
||||
// TODO: annotate this with `MOZ_CAN_RUN_SCRIPT` instead.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
nsresult RestrictCellsToSelection(nsIContent* aTable, int32_t aStartRowIndex,
|
||||
int32_t aStartColumnIndex,
|
||||
int32_t aEndRowIndex,
|
||||
int32_t aEndColumnIndex);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult RestrictCellsToSelection(
|
||||
nsIContent* aTable, int32_t aStartRowIndex, int32_t aStartColumnIndex,
|
||||
int32_t aEndRowIndex, int32_t aEndColumnIndex);
|
||||
|
||||
/**
|
||||
* StartAutoScrollTimer is responsible for scrolling frames so that
|
||||
@@ -414,9 +407,9 @@ class nsFrameSelection final {
|
||||
*
|
||||
* @param aDelay is the timer's interval.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult StartAutoScrollTimer(nsIFrame* aFrame, const nsPoint& aPoint,
|
||||
uint32_t aDelay);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult StartAutoScrollTimer(nsIFrame* aFrame,
|
||||
const nsPoint& aPoint,
|
||||
uint32_t aDelay);
|
||||
|
||||
/**
|
||||
* Stops any active auto scroll timer.
|
||||
@@ -442,20 +435,19 @@ class nsFrameSelection final {
|
||||
*
|
||||
* @param aState is the new state of drag
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void SetDragState(bool aState);
|
||||
MOZ_CAN_RUN_SCRIPT void SetDragState(bool aState);
|
||||
|
||||
/**
|
||||
* Gets the drag state to aState for resons of drag state.
|
||||
*
|
||||
* @param aState will hold the state of drag
|
||||
*/
|
||||
bool GetDragState() const { return mDragState; }
|
||||
[[nodiscard]] bool GetDragState() const { return mDragState; }
|
||||
|
||||
/**
|
||||
* If we are in table cell selection mode. aka ctrl click in table cell
|
||||
*/
|
||||
bool IsInTableSelectionMode() const {
|
||||
[[nodiscard]] bool IsInTableSelectionMode() const {
|
||||
return mTableSelection.mMode != mozilla::TableSelectionMode::None;
|
||||
}
|
||||
void ClearTableCellSelection() {
|
||||
@@ -467,27 +459,28 @@ class nsFrameSelection final {
|
||||
*
|
||||
* @param aSelectionType The selection type what you want.
|
||||
*/
|
||||
mozilla::dom::Selection* GetSelection(
|
||||
[[nodiscard]] mozilla::dom::Selection* GetSelection(
|
||||
mozilla::SelectionType aSelectionType) const;
|
||||
|
||||
/**
|
||||
* Convenience method to access the `eNormal` Selection.
|
||||
*/
|
||||
mozilla::dom::Selection& NormalSelection() const {
|
||||
[[nodiscard]] mozilla::dom::Selection& NormalSelection() const {
|
||||
return *GetSelection(mozilla::SelectionType::eNormal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of highlight selections.
|
||||
*/
|
||||
size_t HighlightSelectionCount() const {
|
||||
[[nodiscard]] size_t HighlightSelectionCount() const {
|
||||
return mHighlightSelections.Length();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a highlight selection by index. The index must be valid.
|
||||
*/
|
||||
RefPtr<mozilla::dom::Selection> HighlightSelection(size_t aIndex) const {
|
||||
[[nodiscard]] RefPtr<mozilla::dom::Selection> HighlightSelection(
|
||||
size_t aIndex) const {
|
||||
return mHighlightSelections[aIndex].second();
|
||||
}
|
||||
|
||||
@@ -531,8 +524,7 @@ class nsFrameSelection final {
|
||||
* * SCROLL_FIRST_ANCESTOR_ONLY: if set, only the first ancestor will be
|
||||
* scrolled into view.
|
||||
*/
|
||||
// TODO: replace with `MOZ_CAN_RUN_SCRIPT`.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
|
||||
MOZ_CAN_RUN_SCRIPT nsresult
|
||||
ScrollSelectionIntoView(mozilla::SelectionType aSelectionType,
|
||||
SelectionRegion aRegion, int16_t aFlags) const;
|
||||
|
||||
@@ -566,7 +558,7 @@ class nsFrameSelection final {
|
||||
* when selection ancestor limit is set to a frame of an editing host of
|
||||
* contenteditable element and it's not scrollable.
|
||||
*/
|
||||
nsIFrame* GetFrameToPageSelect() const;
|
||||
[[nodiscard]] nsIFrame* GetFrameToPageSelect() const;
|
||||
|
||||
/**
|
||||
* This method moves caret (if aExtend is false) or expands selection (if
|
||||
@@ -590,7 +582,7 @@ class nsFrameSelection final {
|
||||
SelectionIntoView aSelectionIntoView);
|
||||
|
||||
void SetHint(CaretAssociationHint aHintRight) { mCaret.mHint = aHintRight; }
|
||||
CaretAssociationHint GetHint() const { return mCaret.mHint; }
|
||||
[[nodiscard]] CaretAssociationHint GetHint() const { return mCaret.mHint; }
|
||||
|
||||
void SetCaretBidiLevelAndMaybeSchedulePaint(
|
||||
mozilla::intl::BidiEmbeddingLevel aLevel);
|
||||
@@ -598,7 +590,7 @@ class nsFrameSelection final {
|
||||
/**
|
||||
* GetCaretBidiLevel gets the caret bidi level.
|
||||
*/
|
||||
mozilla::intl::BidiEmbeddingLevel GetCaretBidiLevel() const;
|
||||
[[nodiscard]] mozilla::intl::BidiEmbeddingLevel GetCaretBidiLevel() const;
|
||||
|
||||
/**
|
||||
* UndefineCaretBidiLevel sets the caret bidi level to "undefined".
|
||||
@@ -613,10 +605,8 @@ class nsFrameSelection final {
|
||||
* @param aAmount amount of movement (char/line; word/page; eol/doc)
|
||||
* @param aExtend continue selection
|
||||
*/
|
||||
// TODO: replace with `MOZ_CAN_RUN_SCRIPT`.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult PhysicalMove(int16_t aDirection,
|
||||
int16_t aAmount,
|
||||
bool aExtend);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult PhysicalMove(int16_t aDirection, int16_t aAmount,
|
||||
bool aExtend);
|
||||
|
||||
/**
|
||||
* CharacterMove will generally be called from the nsiselectioncontroller
|
||||
@@ -625,9 +615,7 @@ class nsFrameSelection final {
|
||||
* @param aForward move forward in document.
|
||||
* @param aExtend continue selection
|
||||
*/
|
||||
// TODO: replace with `MOZ_CAN_RUN_SCRIPT`.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult CharacterMove(bool aForward,
|
||||
bool aExtend);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult CharacterMove(bool aForward, bool aExtend);
|
||||
|
||||
/**
|
||||
* WordMove will generally be called from the nsiselectioncontroller
|
||||
@@ -636,8 +624,7 @@ class nsFrameSelection final {
|
||||
* @param aForward move forward in document.
|
||||
* @param aExtend continue selection
|
||||
*/
|
||||
// TODO: replace with `MOZ_CAN_RUN_SCRIPT`.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult WordMove(bool aForward, bool aExtend);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult WordMove(bool aForward, bool aExtend);
|
||||
|
||||
/**
|
||||
* LineMove will generally be called from the nsiselectioncontroller
|
||||
@@ -646,8 +633,7 @@ class nsFrameSelection final {
|
||||
* @param aForward move forward in document.
|
||||
* @param aExtend continue selection
|
||||
*/
|
||||
// TODO: replace with `MOZ_CAN_RUN_SCRIPT`.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult LineMove(bool aForward, bool aExtend);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult LineMove(bool aForward, bool aExtend);
|
||||
|
||||
/**
|
||||
* IntraLineMove will generally be called from the nsiselectioncontroller
|
||||
@@ -656,9 +642,7 @@ class nsFrameSelection final {
|
||||
* @param aForward move forward in document.
|
||||
* @param aExtend continue selection
|
||||
*/
|
||||
// TODO: replace with `MOZ_CAN_RUN_SCRIPT`.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult IntraLineMove(bool aForward,
|
||||
bool aExtend);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult IntraLineMove(bool aForward, bool aExtend);
|
||||
|
||||
/**
|
||||
* CreateRangeExtendedToNextGraphemeClusterBoundary() returns range which is
|
||||
@@ -803,7 +787,9 @@ class nsFrameSelection final {
|
||||
/** Sets/Gets The display selection enum.
|
||||
*/
|
||||
void SetDisplaySelection(int16_t aState) { mDisplaySelection = aState; }
|
||||
int16_t GetDisplaySelection() const { return mDisplaySelection; }
|
||||
[[nodiscard]] int16_t GetDisplaySelection() const {
|
||||
return mDisplaySelection;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can be used to store the data received during a MouseDown
|
||||
@@ -823,17 +809,19 @@ class nsFrameSelection final {
|
||||
* by the selection during MouseDown processing. It can be nullptr
|
||||
* if the data is no longer valid.
|
||||
*/
|
||||
bool HasDelayedCaretData() const { return mDelayedMouseEvent.mIsValid; }
|
||||
bool IsShiftDownInDelayedCaretData() const {
|
||||
[[nodiscard]] bool HasDelayedCaretData() const {
|
||||
return mDelayedMouseEvent.mIsValid;
|
||||
}
|
||||
[[nodiscard]] bool IsShiftDownInDelayedCaretData() const {
|
||||
NS_ASSERTION(mDelayedMouseEvent.mIsValid, "No valid delayed caret data");
|
||||
return mDelayedMouseEvent.mIsShift;
|
||||
}
|
||||
uint32_t GetClickCountInDelayedCaretData() const {
|
||||
[[nodiscard]] uint32_t GetClickCountInDelayedCaretData() const {
|
||||
NS_ASSERTION(mDelayedMouseEvent.mIsValid, "No valid delayed caret data");
|
||||
return mDelayedMouseEvent.mClickCount;
|
||||
}
|
||||
|
||||
bool MouseDownRecorded() const {
|
||||
[[nodiscard]] bool MouseDownRecorded() const {
|
||||
return !GetDragState() && HasDelayedCaretData() &&
|
||||
GetClickCountInDelayedCaretData() < 2;
|
||||
}
|
||||
@@ -851,7 +839,7 @@ class nsFrameSelection final {
|
||||
* Get the independent selection root parent which is usually a text control
|
||||
* element which hosts the anonymous subtree managed by this frame selection.
|
||||
*/
|
||||
Element* GetIndependentSelectionRootParentElement() const {
|
||||
[[nodiscard]] Element* GetIndependentSelectionRootParentElement() const {
|
||||
MOZ_DIAGNOSTIC_ASSERT(IsIndependentSelection());
|
||||
return Element::FromNodeOrNull(
|
||||
mLimiters.mIndependentSelectionRootElement
|
||||
@@ -879,7 +867,7 @@ class nsFrameSelection final {
|
||||
* selection ranges into the limiter element. Thus, calling this may run
|
||||
* the selection listeners.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void SetAncestorLimiter(Element* aLimiter);
|
||||
MOZ_CAN_RUN_SCRIPT void SetAncestorLimiter(Element* aLimiter);
|
||||
|
||||
/**
|
||||
* GetPrevNextBidiLevels will return the frames and associated Bidi levels of
|
||||
@@ -900,9 +888,8 @@ class nsFrameSelection final {
|
||||
* In these cases the before frame and after frame respectively will be
|
||||
* nullptr.
|
||||
*/
|
||||
nsPrevNextBidiLevels GetPrevNextBidiLevels(nsIContent* aNode,
|
||||
uint32_t aContentOffset,
|
||||
bool aJumpLines) const;
|
||||
[[nodiscard]] nsPrevNextBidiLevels GetPrevNextBidiLevels(
|
||||
nsIContent* aNode, uint32_t aContentOffset, bool aJumpLines) const;
|
||||
|
||||
/**
|
||||
* MaintainSelection will track the normal selection as being "sticky".
|
||||
@@ -947,14 +934,14 @@ class nsFrameSelection final {
|
||||
* @param aReasons potentially multiple of the reasons defined in
|
||||
* nsISelectionListener.idl
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void EndBatchChanges(
|
||||
MOZ_CAN_RUN_SCRIPT void EndBatchChanges(
|
||||
const char* aRequesterFuncName,
|
||||
int16_t aReasons = nsISelectionListener::NO_REASON);
|
||||
|
||||
mozilla::PresShell* GetPresShell() const { return mPresShell; }
|
||||
[[nodiscard]] mozilla::PresShell* GetPresShell() const { return mPresShell; }
|
||||
|
||||
void DisconnectFromPresShell();
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult ClearNormalSelection();
|
||||
MOZ_CAN_RUN_SCRIPT nsresult ClearNormalSelection();
|
||||
|
||||
// Table selection support.
|
||||
static nsITableCellLayout* GetCellLayout(const nsIContent* aCellContent);
|
||||
@@ -1023,15 +1010,17 @@ class nsFrameSelection final {
|
||||
* @return potentially multiple of the reasons defined in
|
||||
* nsISelectionListener.idl.
|
||||
*/
|
||||
int16_t PopChangeReasons() {
|
||||
[[nodiscard]] int16_t PopChangeReasons() {
|
||||
int16_t retval = mSelectionChangeReasons;
|
||||
mSelectionChangeReasons = nsISelectionListener::NO_REASON;
|
||||
return retval;
|
||||
}
|
||||
|
||||
nsSelectionAmount GetCaretMoveAmount() { return mCaretMoveAmount; }
|
||||
[[nodiscard]] nsSelectionAmount GetCaretMoveAmount() {
|
||||
return mCaretMoveAmount;
|
||||
}
|
||||
|
||||
bool IsUserSelectionReason() const {
|
||||
[[nodiscard]] bool IsUserSelectionReason() const {
|
||||
return (mSelectionChangeReasons &
|
||||
(nsISelectionListener::DRAG_REASON |
|
||||
nsISelectionListener::MOUSEDOWN_REASON |
|
||||
@@ -1062,7 +1051,7 @@ class nsFrameSelection final {
|
||||
* @param aMovementStyle The `CaretMovementStyle` (logical or visual)
|
||||
* @return mozilla::Result<mozilla::PeekOffsetOptions, nsresult>
|
||||
*/
|
||||
mozilla::Result<mozilla::PeekOffsetOptions, nsresult>
|
||||
[[nodiscard]] mozilla::Result<mozilla::PeekOffsetOptions, nsresult>
|
||||
CreatePeekOffsetOptionsForCaretMove(mozilla::dom::Selection* aSelection,
|
||||
ExtendSelection aExtendSelection,
|
||||
CaretMovementStyle aMovementStyle) const {
|
||||
@@ -1074,7 +1063,7 @@ class nsFrameSelection final {
|
||||
}
|
||||
|
||||
enum class ForceEditableRegion : bool { No, Yes };
|
||||
static mozilla::Result<mozilla::PeekOffsetOptions, nsresult>
|
||||
[[nodiscard]] static mozilla::Result<mozilla::PeekOffsetOptions, nsresult>
|
||||
CreatePeekOffsetOptionsForCaretMove(const Element* aSelectionLimiter,
|
||||
ForceEditableRegion aForceEditableRegion,
|
||||
ExtendSelection aExtendSelection,
|
||||
@@ -1089,8 +1078,8 @@ class nsFrameSelection final {
|
||||
* @param aSelection The selection object. Must be non-null
|
||||
* @return The ancestor limiter, or nullptr.
|
||||
*/
|
||||
mozilla::Result<Element*, nsresult> GetAncestorLimiterForCaretMove(
|
||||
mozilla::dom::Selection* aSelection) const;
|
||||
[[nodiscard]] mozilla::Result<Element*, nsresult>
|
||||
GetAncestorLimiterForCaretMove(mozilla::dom::Selection* aSelection) const;
|
||||
|
||||
/**
|
||||
* CreateRangeExtendedToSomewhere() is common method to implement
|
||||
@@ -1121,26 +1110,26 @@ class nsFrameSelection final {
|
||||
void InvalidateDesiredCaretPos(); // do not listen to mDesiredCaretPos.mValue
|
||||
// you must get another.
|
||||
|
||||
bool IsBatching() const { return mBatching.mCounter > 0; }
|
||||
[[nodiscard]] bool IsBatching() const { return mBatching.mCounter > 0; }
|
||||
|
||||
enum class IsBatchingEnd : bool { No, Yes };
|
||||
|
||||
// nsFrameSelection may get deleted when calling this,
|
||||
// so remember to use nsCOMPtr when needed.
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult NotifySelectionListeners(
|
||||
mozilla::SelectionType aSelectionType,
|
||||
IsBatchingEnd aEndBatching = IsBatchingEnd::No);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult
|
||||
NotifySelectionListeners(mozilla::SelectionType aSelectionType,
|
||||
IsBatchingEnd aEndBatching = IsBatchingEnd::No);
|
||||
|
||||
static nsresult GetCellIndexes(const nsIContent* aCell, int32_t& aRowIndex,
|
||||
int32_t& aColIndex);
|
||||
|
||||
static nsIContent* GetFirstCellNodeInRange(const nsRange* aRange);
|
||||
[[nodiscard]] static nsIContent* GetFirstCellNodeInRange(
|
||||
const nsRange* aRange);
|
||||
// Returns non-null table if in same table, null otherwise
|
||||
static nsIContent* IsInSameTable(const nsIContent* aContent1,
|
||||
const nsIContent* aContent2);
|
||||
[[nodiscard]] static nsIContent* IsInSameTable(const nsIContent* aContent1,
|
||||
const nsIContent* aContent2);
|
||||
// Might return null
|
||||
static nsIContent* GetParentTable(const nsIContent* aCellNode);
|
||||
[[nodiscard]] static nsIContent* GetParentTable(const nsIContent* aCellNode);
|
||||
|
||||
////////////BEGIN nsFrameSelection members
|
||||
|
||||
@@ -1174,16 +1163,16 @@ class nsFrameSelection final {
|
||||
* (https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor) of
|
||||
* aContent, if it is actively editable.
|
||||
*/
|
||||
static nsINode* IsContentInActivelyEditableTableCell(
|
||||
[[nodiscard]] static nsINode* IsContentInActivelyEditableTableCell(
|
||||
nsPresContext* aContext, nsIContent* aContent);
|
||||
|
||||
// TODO: annotate this with `MOZ_CAN_RUN_SCRIPT` instead.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
nsresult SelectBlockOfCells(nsIContent* aStartCell, nsIContent* aEndCell,
|
||||
mozilla::dom::Selection& aNormalSelection);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult
|
||||
SelectBlockOfCells(nsIContent* aStartCell, nsIContent* aEndCell,
|
||||
mozilla::dom::Selection& aNormalSelection);
|
||||
|
||||
nsresult SelectRowOrColumn(nsIContent* aCellContent,
|
||||
mozilla::dom::Selection& aNormalSelection);
|
||||
MOZ_CAN_RUN_SCRIPT nsresult SelectRowOrColumn(
|
||||
nsIContent* aCellContent, mozilla::dom::Selection& aNormalSelection);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT nsresult
|
||||
UnselectCells(const nsIContent* aTable, int32_t aStartRowIndex,
|
||||
@@ -1207,10 +1196,10 @@ class nsFrameSelection final {
|
||||
nsCOMPtr<nsIContent> mLast;
|
||||
};
|
||||
|
||||
mozilla::Result<FirstAndLastCell, nsresult>
|
||||
[[nodiscard]] mozilla::Result<FirstAndLastCell, nsresult>
|
||||
FindFirstAndLastCellOfRowOrColumn(const nsIContent& aCellContent) const;
|
||||
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult HandleDragSelecting(
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult HandleDragSelecting(
|
||||
mozilla::TableSelectionMode aTarget, nsIContent* aChildContent,
|
||||
const mozilla::WidgetMouseEvent* aMouseEvent,
|
||||
mozilla::dom::Selection& aNormalSelection);
|
||||
@@ -1285,8 +1274,8 @@ class nsFrameSelection final {
|
||||
CaretAssociationHint mHint = CaretAssociationHint::Before;
|
||||
mozilla::intl::BidiEmbeddingLevel mBidiLevel = BIDI_LEVEL_UNDEFINED;
|
||||
|
||||
static bool IsVisualMovement(ExtendSelection aExtendSelection,
|
||||
CaretMovementStyle aMovementStyle);
|
||||
[[nodiscard]] static bool IsVisualMovement(
|
||||
ExtendSelection aExtendSelection, CaretMovementStyle aMovementStyle);
|
||||
};
|
||||
|
||||
Caret mCaret;
|
||||
@@ -1339,14 +1328,14 @@ class nsFrameSelection final {
|
||||
*/
|
||||
class MOZ_RAII AutoFrameSelectionBatcher final {
|
||||
public:
|
||||
explicit AutoFrameSelectionBatcher(const char* aFunctionName,
|
||||
size_t aEstimatedSize = 1)
|
||||
MOZ_CAN_RUN_SCRIPT explicit AutoFrameSelectionBatcher(
|
||||
const char* aFunctionName, size_t aEstimatedSize = 1)
|
||||
: mFunctionName(aFunctionName) {
|
||||
mFrameSelections.SetCapacity(aEstimatedSize);
|
||||
}
|
||||
~AutoFrameSelectionBatcher() {
|
||||
MOZ_CAN_RUN_SCRIPT ~AutoFrameSelectionBatcher() {
|
||||
for (const auto& frameSelection : mFrameSelections) {
|
||||
frameSelection->EndBatchChanges(mFunctionName);
|
||||
MOZ_KnownLive(frameSelection)->EndBatchChanges(mFunctionName);
|
||||
}
|
||||
}
|
||||
void AddFrameSelection(nsFrameSelection* aFrameSelection) {
|
||||
|
||||
Reference in New Issue
Block a user