Closed Bug 409390 Opened 17 years ago Closed 16 years ago

Avoid nsCOMPtr's and some code in nsDocument::FlushPendingNotifications() when possible.

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9beta4

People

(Reporter: jst, Assigned: bent.mozilla)

References

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

nsDocument::FlushPendingNotifications() has code to notify the parent document etc when flushing layout (aType > Flush_ContentAndNotify), but that code is a no-op when mParentDocument is null and should then be avoided. Also, as the comment in the code says, a lot of that code can be replaced with using mParentDocument directly. See attached patch.
+ing for perf impact
Flags: blocking1.9+
Priority: -- → P3
Ben agreed to look into this, reassigning.
Assignee: jst → bent.mozilla
Attached patch Patch, v1 (obsolete) — Splinter Review
This look ok?
Attachment #296618 - Flags: superreview?
Attachment #296618 - Flags: review?(jst)
Attachment #296618 - Flags: superreview? → superreview?(bzbarsky)
Hmm.  Why is the SyncParentSubDocMap call needed?

Also, the assert in FlushPendingNotifications looks wrong; it's possible to have a subdocument have a null mParentDocument but still have a docshell which has a parent.  In those cases we don't want to be flushing the parent docshell...
Comment on attachment 296618 [details] [diff] [review]
Patch, v1

sr- pending answers to my questions
Attachment #296618 - Flags: superreview?(bzbarsky) → superreview-
(In reply to comment #4)
> Hmm.  Why is the SyncParentSubDocMap call needed?

I don't know for a fact that it is, but when Ben and I went through this code that was the one place where mDocument was set and it wasn't obvious that the map would be updated in this case. If you're saying it's not needed, then we'll just not add this.

> Also, the assert in FlushPendingNotifications looks wrong; it's possible to
> have a subdocument have a null mParentDocument but still have a docshell which
> has a parent.  In those cases we don't want to be flushing the parent
> docshell...

Uh? I don't understand what case that would be, but if you say so (and you know this stuff way better than I do, so I'm not going to argue with you)...
> If you're saying it's not needed, then we'll just not add this.

No, I was just wondering what cases it was needed in.  I'll look to see what the effect is of having or not having it here.

> Uh? I don't understand what case that would be,

During paint suppression, we've set the new doc in the subdoc map (so the old one has a null mParentDocument), but not called Show() on the new viewer, so the old viewer hasn't gotten a Destroy(), so its document still has the old container... It's a mess.  :(
OK, looks like the only places where LoadStart() is called in our code on a document viewer with a null mDocument, the container of the document viewer is still null, so SyncParentSubDocMap is effectively a no-op.  I'd say we shouldn't add it here, and instead document the call order here and in the IDL.  Or we could add it (it's not a super-expensive no-op), and file a bug to clean up the document viewer mess.
Attached patch Patch, v2Splinter Review
Ok, this patch loses the unnecessary call and the assertion.
Attachment #296618 - Attachment is obsolete: true
Attachment #301317 - Flags: review?(bzbarsky)
Attachment #296618 - Flags: review?(jst)
Comment on attachment 301317 [details] [diff] [review]
Patch, v2

r=bzbarsky
Attachment #301317 - Flags: review?(bzbarsky) → review+
Attachment #301317 - Flags: superreview?(jst)
Target Milestone: mozilla1.9beta3 → mozilla1.9beta4
Version: unspecified → Trunk
Comment on attachment 301317 [details] [diff] [review]
Patch, v2

- In nsDocument::DispatchContentLoadedEvents():

+    nsIDocument* parent = mParentDocument;
+    while (parent) {
+      parent = parent->GetParentDocument();

It might be worth while to make parent an nsCOMPtr here as dispatching these events could in theory kill a document, which could leave parent dangling here next time through.

bz, if you know for a fact that that can't happen, then please speak up.

sr=jst with that.
Attachment #301317 - Flags: superreview?(jst) → superreview+
Comment on attachment 301317 [details] [diff] [review]
Patch, v2

This patch avoids some needless QI action and simplifies the code a bit.
Attachment #301317 - Flags: approval1.9?
Comment on attachment 301317 [details] [diff] [review]
Patch, v2

Oh, nm, blocking+ already.
Attachment #301317 - Flags: approval1.9?
Yeah, making that a strong ref sounds like a good idea.
Fixed, used a nsCOMPtr.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Depends on: 416487
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: