Closed Bug 582863 Opened 14 years ago Closed 14 years ago

Spell checker shouldn't copy the text node contents unnecessarily

Categories

(Core :: Spelling checker, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b4
Tracking Status
blocking2.0 --- beta4+

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

References

Details

(Keywords: perf)

Attachments

(1 file, 3 obsolete files)

Our spell checking code is pretty stupid!  (Well, that we all know!)

It just copies the text node around needlessly, which causes serious perf hits when editing textareas after bug 240933.  We can certainly do better than that, and I have a patch which does exactly that.
Attached patch Patch (v1) (obsolete) — Splinter Review
Attachment #461140 - Flags: review?(roc)
Summary: Spell checker shouldn't copy the text node unnecessarily → Spell checker shouldn't copy the text node contents unnecessarily
> mSoftText.AppendASCII(textFragment->Get1b() + firstOffsetInNode, len);

This is not correct. Get1b does not necessarily return ASCII. Why don't you use nsTextFragment::AppendTo here?
(ASCII only allows characters 0-127, but Get1b can contain characters 0-255.)

Seems like spellcheck (and editor!) need a general change from nsIDOMNode to nsIContent all over the place.
Attached patch Patch (v2) (obsolete) — Splinter Review
(In reply to comment #2)
> > mSoftText.AppendASCII(textFragment->Get1b() + firstOffsetInNode, len);
> 
> This is not correct. Get1b does not necessarily return ASCII. Why don't you use
> nsTextFragment::AppendTo here?

It fails to link (because spell checker is not linked into libgklayout).  :(

But I switched to using AppendASCIItoUTF16 which seems to work (i.e. passes the reftests).  Is that good enough?
Attachment #461140 - Attachment is obsolete: true
Attachment #461704 - Flags: review?(roc)
Attachment #461140 - Flags: review?(roc)
(In reply to comment #3)
> Seems like spellcheck (and editor!) need a general change from nsIDOMNode to
> nsIContent all over the place.

Yes!  But that is a huge project, which I've put off until after 2.0 for now... :/
How about just moving them into the header file so they can be inlined?
The definitions of AppendTo I mean
Attached patch Patch (v3) (obsolete) — Splinter Review
Moved AppendTo to the header and started using it.
Attachment #461704 - Attachment is obsolete: true
Attachment #462483 - Flags: review?(roc)
Attachment #461704 - Flags: review?(roc)
Attachment #462483 - Flags: approval2.0?
Attached patch Patch (v4)Splinter Review
I actually made a mistake of appending the text to |str| instead of |mSoftText|.  This patch fixes that mistake (which was caught by unit tests on the try server).
Attachment #462483 - Attachment is obsolete: true
Attachment #462925 - Flags: approval2.0?
Attachment #462483 - Flags: approval2.0?
blocking2.0: --- → beta4+
Attachment #462925 - Flags: approval2.0?
I landed the fix:

http://hg.mozilla.org/mozilla-central/rev/b64704446120

And then backed it out:

http://hg.mozilla.org/mozilla-central/rev/6941899e01f1

The problem (which the try server failed to catch) is that TestWinTSF.cpp #defines nsReadableUtils_h_, which prevents that header which declares AppendASCIItoUTF16 from being #included.  I'm testing the patch in bug 497812 to see if it fixes this problem.  If it doesn't, I think we need to go with the approach in attachment 461704 [details] [diff] [review].
Or disable that test..
(In reply to comment #11)
> Or disable that test..

Given the way that test is written, I'd very much like to do that!  :-)

BTW, the patch in bug 497812 didn't help with this error, so I guess our choices are between disabling that test or taking attachment 461704 [details] [diff] [review].
roc: ping?
Sure, disable it. We're not shipping TSF enabled at the moment.
TestWinTSF test disabled:

http://hg.mozilla.org/mozilla-central/rev/12c4a1f5f22e

Patch landed again:

http://hg.mozilla.org/mozilla-central/rev/f8a0bd477fd3
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: