mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Issue #2388 - Part 1: Mark Selection as "called by JS" when caused by a JS call to the selection API
This commit is contained in:
parent
a2c28b4268
commit
a83e4b6a34
6 changed files with 239 additions and 34 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/dom/Selection.h"
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
|
@ -3473,6 +3474,7 @@ Selection::Selection()
|
|||
, mDirection(eDirNext)
|
||||
, mSelectionType(SelectionType::eNormal)
|
||||
, mUserInitiated(false)
|
||||
, mCalledByJS(false)
|
||||
, mSelectionChangeBlockerCount(0)
|
||||
{
|
||||
}
|
||||
|
|
@ -3483,6 +3485,7 @@ Selection::Selection(nsFrameSelection* aList)
|
|||
, mDirection(eDirNext)
|
||||
, mSelectionType(SelectionType::eNormal)
|
||||
, mUserInitiated(false)
|
||||
, mCalledByJS(false)
|
||||
, mSelectionChangeBlockerCount(0)
|
||||
{
|
||||
}
|
||||
|
|
@ -4966,6 +4969,14 @@ Selection::AddRange(nsIDOMRange* aDOMRange)
|
|||
return result.StealNSResult();
|
||||
}
|
||||
|
||||
void
|
||||
Selection::AddRangeJS(nsRange& aRange, ErrorResult& aRv)
|
||||
{
|
||||
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
|
||||
mCalledByJS = true;
|
||||
AddRange(aRange, aRv);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::AddRange(nsRange& aRange, ErrorResult& aRv)
|
||||
{
|
||||
|
|
@ -5140,6 +5151,14 @@ Selection::CollapseNative(nsINode* aParentNode, int32_t aOffset)
|
|||
return Collapse(aParentNode, aOffset);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::CollapseJS(nsINode& aNode, uint32_t aOffset, ErrorResult& aRv)
|
||||
{
|
||||
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
|
||||
mCalledByJS = true;
|
||||
Collapse(aNode, aOffset, aRv);
|
||||
}
|
||||
|
||||
nsresult
|
||||
Selection::Collapse(nsINode* aParentNode, int32_t aOffset)
|
||||
{
|
||||
|
|
@ -5240,6 +5259,14 @@ Selection::CollapseToStart()
|
|||
return result.StealNSResult();
|
||||
}
|
||||
|
||||
void
|
||||
Selection::CollapseToStartJS(ErrorResult& aRv)
|
||||
{
|
||||
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
|
||||
mCalledByJS = true;
|
||||
CollapseToStart(aRv);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::CollapseToStart(ErrorResult& aRv)
|
||||
{
|
||||
|
|
@ -5281,6 +5308,14 @@ Selection::CollapseToEnd()
|
|||
return result.StealNSResult();
|
||||
}
|
||||
|
||||
void
|
||||
Selection::CollapseToEndJS(ErrorResult& aRv)
|
||||
{
|
||||
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
|
||||
mCalledByJS = true;
|
||||
CollapseToEnd(aRv);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::CollapseToEnd(ErrorResult& aRv)
|
||||
{
|
||||
|
|
@ -5495,6 +5530,14 @@ Selection::ExtendNative(nsINode* aParentNode, int32_t aOffset)
|
|||
return Extend(aParentNode, aOffset);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::ExtendJS(nsINode& aNode, uint32_t aOffset, ErrorResult& aRv)
|
||||
{
|
||||
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
|
||||
mCalledByJS = true;
|
||||
Extend(aNode, aOffset, aRv);
|
||||
}
|
||||
|
||||
nsresult
|
||||
Selection::Extend(nsINode* aParentNode, int32_t aOffset)
|
||||
{
|
||||
|
|
@ -5790,6 +5833,14 @@ Selection::SelectAllChildren(nsIDOMNode* aParentNode)
|
|||
return result.StealNSResult();
|
||||
}
|
||||
|
||||
void
|
||||
Selection::SelectAllChildrenJS(nsINode& aNode, ErrorResult& aRv)
|
||||
{
|
||||
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
|
||||
mCalledByJS = true;
|
||||
SelectAllChildren(aNode, aRv);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::SelectAllChildren(nsINode& aNode, ErrorResult& aRv)
|
||||
{
|
||||
|
|
@ -6239,6 +6290,14 @@ Selection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove,
|
|||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
Selection::NotifySelectionListeners(bool aCalledByJS)
|
||||
{
|
||||
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
|
||||
mCalledByJS = aCalledByJS;
|
||||
return NotifySelectionListeners();
|
||||
}
|
||||
|
||||
nsresult
|
||||
Selection::NotifySelectionListeners()
|
||||
{
|
||||
|
|
@ -6454,6 +6513,19 @@ Selection::Modify(const nsAString& aAlter, const nsAString& aDirection,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Selection::SetBaseAndExtentJS(nsINode& aAnchorNode,
|
||||
uint32_t aAnchorOffset,
|
||||
nsINode& aFocusNode,
|
||||
uint32_t aFocusOffset,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
|
||||
mCalledByJS = true;
|
||||
SetBaseAndExtent(aAnchorNode, aAnchorOffset,
|
||||
aFocusNode, aFocusOffset, aRv);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::SetBaseAndExtent(nsINode& aAnchorNode, uint32_t aAnchorOffset,
|
||||
nsINode& aFocusNode, uint32_t aFocusOffset,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue