mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-12 10:17:31 +09:00
Issue #2388 - Part 2: move focus at every selection change when it's called by JS
This commit is contained in:
parent
a83e4b6a34
commit
681193a256
4 changed files with 202 additions and 16 deletions
|
|
@ -998,7 +998,16 @@ nsRange::DoSetRange(nsINode* aStartN, uint32_t aStartOffset,
|
|||
// Notify any selection listeners. This has to occur last because otherwise the world
|
||||
// could be observed by a selection listener while the range was in an invalid state.
|
||||
if (mSelection) {
|
||||
mSelection->NotifySelectionListeners(mCalledByJS);
|
||||
// Our internal code should not move focus with using this instance while
|
||||
// it's calling Selection::NotifySelectionListeners() which may move focus
|
||||
// or calls selection listeners. So, let's set mCalledByJS to false here
|
||||
// since non-*JS() methods don't set it to false.
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = false;
|
||||
// Be aware, this range may be modified or stop being a range for selection
|
||||
// after this call. Additionally, the selection instance may have gone.
|
||||
RefPtr<Selection> selection = mSelection;
|
||||
selection->NotifySelectionListeners(calledByJSRestorer.SavedValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1228,7 +1237,8 @@ nsRange::IsValidBoundary(nsINode* aNode)
|
|||
void
|
||||
nsRange::SetStartJS(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
SetStart(aNode, aOffset, aErr);
|
||||
}
|
||||
|
||||
|
|
@ -1290,7 +1300,8 @@ nsRange::SetStart(nsINode* aParent, uint32_t aOffset)
|
|||
void
|
||||
nsRange::SetStartBeforeJS(nsINode& aNode, ErrorResult& aErr)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
SetStartBefore(aNode, aErr);
|
||||
}
|
||||
|
||||
|
|
@ -1328,7 +1339,8 @@ nsRange::SetStartBefore(nsIDOMNode* aSibling)
|
|||
void
|
||||
nsRange::SetStartAfterJS(nsINode& aNode, ErrorResult& aErr)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
SetStartAfter(aNode, aErr);
|
||||
}
|
||||
|
||||
|
|
@ -1366,7 +1378,8 @@ nsRange::SetStartAfter(nsIDOMNode* aSibling)
|
|||
void
|
||||
nsRange::SetEndJS(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
SetEnd(aNode, aOffset, aErr);
|
||||
}
|
||||
|
||||
|
|
@ -1487,7 +1500,8 @@ nsRange::SetStartAndEnd(nsINode* aStartParent, uint32_t aStartOffset,
|
|||
void
|
||||
nsRange::SetEndBeforeJS(nsINode& aNode, ErrorResult& aErr)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
SetEndBefore(aNode, aErr);
|
||||
}
|
||||
|
||||
|
|
@ -1525,7 +1539,8 @@ nsRange::SetEndBefore(nsIDOMNode* aSibling)
|
|||
void
|
||||
nsRange::SetEndAfterJS(nsINode& aNode, ErrorResult& aErr)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
SetEndAfter(aNode, aErr);
|
||||
}
|
||||
|
||||
|
|
@ -1578,7 +1593,8 @@ nsRange::Collapse(bool aToStart)
|
|||
void
|
||||
nsRange::CollapseJS(bool aToStart)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
Unused << Collapse(aToStart);
|
||||
}
|
||||
|
||||
|
|
@ -1596,7 +1612,8 @@ nsRange::SelectNode(nsIDOMNode* aN)
|
|||
void
|
||||
nsRange::SelectNodeJS(nsINode& aNode, ErrorResult& aErr)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
SelectNode(aNode, aErr);
|
||||
}
|
||||
|
||||
|
|
@ -1642,7 +1659,8 @@ nsRange::SelectNodeContents(nsIDOMNode* aN)
|
|||
void
|
||||
nsRange::SelectNodeContentsJS(nsINode& aNode, ErrorResult& aErr)
|
||||
{
|
||||
AutoCalledByJSSetter markAsCalledByJS(*this);
|
||||
AutoCalledByJSRestore calledByJSRestorer(*this);
|
||||
mCalledByJS = true;
|
||||
SelectNodeContents(aNode, aErr);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue