Open Bug 358275 Opened 18 years ago Updated 2 years ago

Severe performance problem in nsHTMLEditor::InsertAsPlaintextQuotation

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

References

Details

(Keywords: perf)

BUILD: Current trunk

STEPS TO REPRODUCE:  Follow steps in bug 358124.

ACTUAL RESULTS: Browser freezes up

EXPECTED RESULTS: No freeze

I profiled this, and got:  Total hit count: 253550.  Of these, 122162 are under nsEditor::IsEditable, called by nsHTMLEditor::CollapseAdjacentTextNodes, called by nsHTMLEditRules::AfterEditInner, called by nsHTMLEditRules::AfterEdit, called by nsHTMLEditor::EndOperation, called by nsHTMLEditor::InsertAsPlaintextQuotation.

More than 70% of the time under nsHTMLEditor::InsertAsPlaintextQuotation is spent under nsEditor::IsEditable.

The problem is that IsEditable gets frames for the nodes, and getting frames for text nodes is expensive, since they're not hashed by default.  In this case it makes the whole algorithm O(N^2) or worse.

What I don't understand is why CollapseAdjacentTextNodes() is calling IsEditable().  That seems like an odd thing for it to be doing, imo, given what IsEditable() actually tests for textnodes...  The CVS log is useless, in the usual way; jfrancis' checkin comment just says "making editor hip to inline style changes on collapsed selections. plus lots of removal of unused code".
QA Contact: editor
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.