Severe performance problem in nsHTMLEditor::InsertAsPlaintextQuotation

NEW
Unassigned

Status

()

Core
Editor
12 years ago
6 years ago

People

(Reporter: bz, Unassigned)

Tracking

({perf})

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

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
You need to log in before you can comment on or make changes to this bug.