Open
Bug 520221
Opened 15 years ago
Updated 2 years ago
Investigate how to handle changes to range objects which are used in selection
Categories
(Core :: DOM: Selection, defect)
Tracking
()
NEW
People
(Reporter: smaug, Assigned: smaug)
Details
Attachments
(4 files, 1 obsolete file)
1.08 KB,
text/html
|
Details | |
15.82 KB,
patch
|
Details | Diff | Splinter Review | |
1.21 KB,
text/html
|
Details | |
21.41 KB,
patch
|
Details | Diff | Splinter Review |
There are at least two options: (1) Set a flag to those range objects which are used in a selection and make those range objects readonly for scripts. (2) Add a pointer to the selection to those range objects which are used in a selection and update selection whenever script changes the range. I think (1) may break some websites, so I'd prefer (2). It could be implemented so that at least when nsRange::DoSetRange is called, range objects in the selection get re-ordered.
Comment 1•15 years ago
|
||
> I think (1) may break some websites
The ability to modify ranges in a selection is mozilla-specific, right? How much is it used?
Assignee | ||
Comment 2•15 years ago
|
||
Don't know how much. But in any case, (2) might be even simpler to implement.
I think a fair number of sites modify selection, but do so using different UA-specific APIs in different UAs. Often time for modifying selection in editable areas to for example select the whole area of a text input when it gains focus. Of course, what would be really nice is a real API to modify selection, then I'd imagine we can phase out whatever hacks work now.
Assignee | ||
Comment 4•15 years ago
|
||
Making ranges (which are in selection) to update selection properly would be, IMHO, pretty nice and simple API. And web developers are already pretty familiar with ranges.
Assignee | ||
Updated•15 years ago
|
Assignee: nobody → Olli.Pettay
Assignee | ||
Comment 5•15 years ago
|
||
Trunk doesn't repaint the changed selection range automatically.
Assignee | ||
Comment 6•15 years ago
|
||
Something like this should work. nsTypedSelection::CopyRangeToAnchorFocus a bit ugly, but it is ugly even now :/ Needs lots of automated tests.
What's supposed to happen if a script adds two ranges to a selection, then modifies the ranges so they're the same? We'll reduce the selection to one range, I assume, so one of those ranges will just be removed from the selection as a side effect? That's a bit weird but I guess it's OK.
Assignee | ||
Comment 8•15 years ago
|
||
(In reply to comment #7) > What's supposed to happen if a script adds two ranges to a selection, then > modifies the ranges so they're the same? We'll reduce the selection to one > range, I assume, so one of those ranges will just be removed from the selection > as a side effect? Right, the patch doesn't change the how nsTypedSelection::AddItem handles overlaps. Adding an overlapping range may also just modify existing ranges. There are two cases I especially want to fix (1) Prevent problems like bug 520070. (2) invalidation of modified ranges Both cases are handled by the change to nsRange::DoSetRange: (1) because adding a detached range to selection isn't allowed, (2) because adding a valid range to selection calls nsTypedSelection::selectFrames, which then marks frames selected. And one not so important case is using the same range in several selections. Better to just prevent that by removing the range from the old selection before adding to new one. IMO.
Assignee | ||
Comment 9•15 years ago
|
||
Attachment #404439 -
Attachment is obsolete: true
Assignee | ||
Updated•15 years ago
|
Attachment #404589 -
Flags: review?(jonas)
Assignee | ||
Comment 10•15 years ago
|
||
jonas, ping.
Will this work even when the mutations happen in a node that is fully inside the range? Such as if a child is added to <bar> in the following tree: <foo>|<bar>text here<span/></bar>|</foo>
Assignee | ||
Comment 12•15 years ago
|
||
Assignee | ||
Updated•15 years ago
|
Attachment #404589 -
Flags: review?(jonas)
Assignee | ||
Comment 13•15 years ago
|
||
This handles also the 2nd testcase, but this is not the way it should be handled. Frame construction or something should take care of marking right frames to be selected, I think.
Comment on attachment 417990 [details] [diff] [review] v2 >+ nsContentUtils::ContentIsDescendantOf(aChangedNode, >+ aRange->GetStartParent()) || >+ nsContentUtils::ContentIsDescendantOf(aChangedNode, >+ aRange->GetEndParent()))) { This doesn't seem correct either. Consider: <div><foo>text|here</foo><bar>more text</bar><foo>fi|nal</foo></div> And the modification to the <bar> element. This element isn't a decedent of either the start or end parent.
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•