Selection.collapse fails with NS_ERROR_FAILURE if called for two different editable blocks
Categories
(Core :: DOM: Selection, defect, P3)
Tracking
()
People
(Reporter: saschanaz, Assigned: saschanaz)
References
Details
Attachments
(4 files)
Loading the attached file throws with NS_ERROR_FAILURE.
Comment 1•5 years ago
|
||
Interesting, this indeed only happens when there are two div
s. For the error to occur, it suffices if the first div
is contenteditable
. Works on Chrome.
Updated•5 years ago
|
Assignee | ||
Comment 2•5 years ago
|
||
!frameSelection->IsValidSelectionPoint(aPoint.Container())
check fails inside Selection::Collapse()
.
Internally, the first collapse()
call gets null
from GetAncestorLimit()
while the second call gets the parent div (the grandparent of the text node bar
) and then fails aNode->IsInclusiveDescendantOf(limiter)
check.
Not sure what an ancestor limit is here, could you give me a thought?
Comment 3•5 years ago
|
||
(In reply to Kagami :saschanaz from comment #2)
!frameSelection->IsValidSelectionPoint(aPoint.Container())
check fails insideSelection::Collapse()
.Internally, the first
collapse()
call getsnull
fromGetAncestorLimit()
while the second call gets the parent div (the grandparent of the text nodebar
) and then failsaNode->IsInclusiveDescendantOf(limiter)
check.Not sure what an ancestor limit is here, could you give me a thought?
The idea seems to be, that the ancestor-limiter limits a Selection to the ancestor-limiter's descendants (https://searchfox.org/mozilla-central/rev/6cd54550a27e2f6ca0755a25328f769e41e524f4/layout/generic/nsFrameSelection.h#892-893). However, the comment in the code has to be taken with a grain of salt, because it's potentially outdated.
Assignee | ||
Comment 4•5 years ago
|
||
Weird that this bug doesn't happen when refreshing the page with the focus on the browser chrome. GetAncestorLimit()
returns null
for both <div>
and passes IsValidSelectionPoint()
.
The comment of IsValidSelectionPoint says:
In the case of NO limiter all points are valid since you are in a topmost iframe. (browser or composer)
But in this case a <div>
gets no limiter. Is this expected?
Comment 5•5 years ago
|
||
Well, navigation (e.g., ArrowDown
key press) should be limited in the ancestor limit, but it might be better Selection API calls to ignore it especially when the caller is content script. If Selection
allows any callers to ignore it, I guess that editor would be broken. For example, editor would collapse selection to outside of active editing host and that causes focus move.
(In reply to Kagami :saschanaz from comment #4)
Weird that this bug doesn't happen when refreshing the page with the focus on the browser chrome.
GetAncestorLimit()
returnsnull
for both<div>
and passesIsValidSelectionPoint()
.The comment of IsValidSelectionPoint says:
In the case of NO limiter all points are valid since you are in a topmost iframe. (browser or composer)
But in this case a
<div>
gets no limiter. Is this expected?
Well, not expected, but I guess that the reason is focus
event is not fired on non-focused DOM window:
https://searchfox.org/mozilla-central/rev/202a285024f174c2d2bf2152d9cba90a03723eab/dom/base/nsFocusManager.cpp#1454-1455,1459-1460,1464-1470,1517-1519
Updated•5 years ago
|
Comment 6•5 years ago
|
||
Because this bug's Severity has not been changed from the default since it was filed, and it's Priority is P3
(Backlog,) indicating it has been triaged, the bug's Severity is being updated to S3
(normal.)
Assignee | ||
Comment 8•4 years ago
|
||
This keeps happening whenever I write test cases...
Assignee | ||
Comment 9•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 10•4 years ago
|
||
Depends on D88702
Assignee | ||
Comment 11•4 years ago
|
||
Comment 12•4 years ago
|
||
Comment 14•4 years ago
|
||
Backed out 3 changesets (Bug 1623413) for causing failures in Selection_collapse.html
Backout link: https://hg.mozilla.org/integration/autoland/rev/271f918d32bf8e4fb80065b37eeeb647e97e527b
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=314761630&repo=autoland&lineNumber=2168
Comment 15•4 years ago
|
||
Comment 16•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/6f419d6b635a
https://hg.mozilla.org/mozilla-central/rev/5d57d36010c1
https://hg.mozilla.org/mozilla-central/rev/aa032cbc9455
Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Description
•