Closed
Bug 372086
Opened 18 years ago
Closed 18 years ago
Should ranges observe the common ancestor container instead?
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
(Depends on 2 open bugs, Blocks 1 open bug)
Details
(Keywords: perf, regression)
Attachments
(3 files)
1.35 KB,
patch
|
sicking
:
review+
sicking
:
superreview+
|
Details | Diff | Splinter Review |
1.44 KB,
patch
|
sicking
:
review+
sicking
:
superreview+
|
Details | Diff | Splinter Review |
4.15 KB,
patch
|
Details | Diff | Splinter Review |
Right now ranges in a document observe the document. This means that if you have a lot of ranges, all sorts of DOM manipulations become very slow.
For example, the large testcase in bug 352367 ends up with one range per textfield (the editor's selection). As a result, a partial profile (I killed the app when the log file was nearing a gig) shows that 10% of the time is spent assigning document observers (most of them ranges) into nsCOMPtrs while notifying. Given N textfields, this behavior makes the load O(N^2). The constant is small, but that testcase seems to be big enough that this does not matter anymore...
Now we should work on lazy editor init for sure, but at the same time, it seems like it would make more sense for ranges to observe their common ancestor container, not the document...
Assignee | ||
Comment 1•18 years ago
|
||
Unfortunately, we pass mRoot to nsContentUtils::ContentIsDescendantOf in nsRange::ComparePoint. We also expose it via GetRoot(). Which means we have to notice when it goes away.... :(
I just realized that lots of editor is not the only thing that produces lots of ranges in common browsing. Spellcheck on a large textarea will do the same thing.
Flags: blocking1.9?
Keywords: regression
Assignee | ||
Comment 2•18 years ago
|
||
Nevermind. That wouldn't work well at all -- we want ranges to notice when an ancestor of an endpoint is being removed.
So let me try that in a different way. ;)
Assignee | ||
Comment 3•18 years ago
|
||
After some consideration, perhaps we should do this. I tested with <https://bugzilla.mozilla.org/attachment.cgi?id=143479> and selection with anon content is already broken enough that this won't really break it more. And it makes a lot more sense than what we do now, imo.
Attachment #256771 -
Flags: superreview?(jst)
Attachment #256771 -
Flags: review?(jonas)
Assignee | ||
Comment 4•18 years ago
|
||
With that change, bug 236957 will become more or less moot, I think...
Blocks: 236957
Comment on attachment 256771 [details] [diff] [review]
Maybe like so
Lets try it and see if anything breaks
Attachment #256771 -
Flags: superreview?(jst)
Attachment #256771 -
Flags: superreview+
Attachment #256771 -
Flags: review?(jonas)
Attachment #256771 -
Flags: review+
Updated•18 years ago
|
Assignee: traversal-range → bzbarsky
Assignee | ||
Comment 6•18 years ago
|
||
Checked in. Still need to write tests...
Status: NEW → RESOLVED
Closed: 18 years ago
Flags: blocking1.9? → in-testsuite?
Resolution: --- → FIXED
Comment 7•18 years ago
|
||
(In reply to comment #5)
>(From update of attachment 256771 [details] [diff] [review])
>Lets try it and see if anything breaks
void
nsRange::DoSetRange(nsINode* aStartN, PRInt32 aStartOffset,
nsINode* aEndN, PRInt32 aEndOffset,
nsINode* aRoot)
{
NS_PRECONDITION((aStartN && aEndN && aRoot) ||
(!aStartN && !aEndN && !aRoot),
"Set all or none");
NS_PRECONDITION(!aRoot ||
(!aRoot->GetNodeParent() &&
(aRoot->IsNodeOfType(nsINode::eDOCUMENT) ||
aRoot->IsNodeOfType(nsINode::eATTRIBUTE) ||
aRoot->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT))),
"Bad root");
Assignee | ||
Comment 8•18 years ago
|
||
Attachment #256930 -
Flags: superreview?(jonas)
Attachment #256930 -
Flags: review?(jonas)
Attachment #256930 -
Flags: superreview?(jonas)
Attachment #256930 -
Flags: superreview+
Attachment #256930 -
Flags: review?(jonas)
Attachment #256930 -
Flags: review+
Assignee | ||
Comment 9•18 years ago
|
||
Checked in the assertion check.
Assignee | ||
Comment 10•18 years ago
|
||
Updated•12 years ago
|
Component: DOM: Traversal-Range → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•