Closed Bug 290350 Opened 21 years ago Closed 21 years ago

[FIXr]Plaintext editor serialization creates unnecessary selection object

Categories

(Core :: DOM: Editor, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8beta2

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

(Keywords: perf)

Attachments

(2 files)

I'm guessing that this code was originally written before nsIDocumentEncoder had a SetRange method... in any case, we no longer need the selection object here.
Priority: -- → P2
Target Milestone: --- → mozilla1.8beta2
Attached patch Proposed patchSplinter Review
Attachment #180735 - Flags: superreview?(jst)
Attachment #180735 - Flags: review?(sfraser_bugs)
Comment on attachment 180735 [details] [diff] [review] Proposed patch Seems reasonable
Attachment #180735 - Flags: review?(sfraser_bugs) → review+
Comment on attachment 180735 [details] [diff] [review] Proposed patch r=brade (yes, it is old code from before the apis changed)
Attachment #180735 - Flags: superreview?(jst) → superreview+
Summary: [FIX]Plaintext editor serialization creates unnecessary selection object → [FIXr]Plaintext editor serialization creates unnecessary selection object
Comment on attachment 180735 [details] [diff] [review] Proposed patch Requesting 1.8b2 approval for a bit more unneeded code removal.
Attachment #180735 - Flags: approval1.8b2?
Comment on attachment 180735 [details] [diff] [review] Proposed patch a=brendan for 1.8b2. /be
Attachment #180735 - Flags: approval1.8b2? → approval1.8b2+
Fixed.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Are these possible optimizations? Replacing the entire block with docEncoder->SetNode(rootElement); would bypass the encoder's range code too. Failing that, I would have thought the inner block could be replaced with range->SelectNode(rootElement); or range->SelectNodeContents(rootElement);
> Replacing the entire block with docEncoder->SetNode(rootElement) That would also serialize rootElement itself, which the current code doesn't do. > I would have thought the inner block could be replaced with > range->SelectNode(rootElement) That has the same problem. > or range->SelectNodeContents(rootElement); That _should_ work, yes. I'm not sure it's faster, and it definitely uses more memory (SelectNodeContents uses GetChildNodes, instead of nsIContent apis), but it'd make this code shorter, which is probably a good thing... Simon, Jonas, Peter, thoughts?
(In reply to comment #8) >>Replacing the entire block with docEncoder->SetNode(rootElement) >That would also serialize rootElement itself, which the current code doesn't do. Ah, I can see that that might emit an extra newline or something. >SelectNodeContents uses GetChildNodes, instead of nsIContent apis Is there a bug filed on that?
I'm fine with either way. As you note the range code is pretty inefficient, so both ways are not as efficient as they could be :-).
Yeah, I wouldn't worry too much about efficiency. I doubt it'll affect perf much either way, and we should fix the range code to be better in any event.
> Is there a bug filed on that? It's not clear that it's a bug, since the range code needs to handle a wider range of node types than the editor. Jonas, Peter, was that a vote in favor of using SelectNodeContents here?
Doesn't matter much to me, but i think it seems like a good idea yes.
Attachment #181184 - Flags: superreview?(peterv)
Attachment #181184 - Flags: review?(bugmail)
Attachment #181184 - Flags: superreview?(peterv) → superreview+
Comment on attachment 181184 [details] [diff] [review] Use selectNodeContents Requesting 1.8b2 approval for a tiny bit more code removal.
Attachment #181184 - Flags: approval1.8b2?
Comment on attachment 181184 [details] [diff] [review] Use selectNodeContents a=asa
Attachment #181184 - Flags: approval1.8b2? → approval1.8b2+
Checked that second patch in.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: