Closed Bug 74319 Opened 25 years ago Closed 25 years ago

RestoreFrame used in a O(n^2) way

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla0.9

People

(Reporter: bratell, Assigned: bratell)

References

()

Details

(Keywords: perf, Whiteboard: fix in hand waiting for r and sr)

Attachments

(3 files)

In nsPresShell::ContentAppended, RestoreFrame is used in a O(n^2) way. That hurts stuff like the big table stress case a lot (well, it's about 6% of the time). For every time something is appended, the whole frame structure is traversed looking for something to do. It should only be necessary to do this on new frames.
I have fix (structure suggested by waterson).
Status: NEW → ASSIGNED
Keywords: perf
Whiteboard: fix in hand
Can I get some comments on the fix (r and sr?). One question I have is all new frames are guaranteed to be found with this algorithm? Will all new frames be children of the container?
Blocks: 54542
For the black & white table it's a save of 17.5% of the time so it's an even bigger win when the style system isn't as abused as in the colour test case.
> One question I have is all new frames are guaranteed to be found with this > algorithm? Will all new frames be children of the container? Adding hyatt to the cc list; do we need to worry about saved frame state for any anonymous frames that might be created *between* aContainer and its children? I think not, but verify. I think the patch looks good; my only comments are stylistic... + for (PRInt32 i = aNewIndexInContainer; i < count; ++i) { + nsIFrame* frame; Declare `frame' as near as possible to its first use, at [1] below. + nsIContent *newChild; + rv = aContainer->ChildAt(i, newChild); + if (!newChild) { + // We should never get here. + NS_ASSERTION(PR_FALSE, "Got a null child when restoring state!"); Use NS_ERROR(...) instead of NS_ASSERTION(PR_FALSE, ...). + continue; + } [1] Declare `frame' here. + rv = GetPrimaryFrameFor(newChild, &frame); + if (NS_SUCCEEDED(rv) && nsnull != frame) + mFrameManager->RestoreFrameState(mPresContext, frame, mHistoryState); + } This is a great catch! Be sure to give the layout regression tests a whirl. r=waterson, but we should definitely get some feedback from hyatt here...
Keywords: patch
Keywords: mozilla0.9
I would be glad to do the layout regression tests. It's not like I'm know what I'm doing. :-) How do I run them? I'll attach a cleaned up patch so you have something to look at during the time.
OS: Windows 2000 → All
Hardware: PC → All
Target Milestone: --- → mozilla0.9
Attached patch Cleaned up patchSplinter Review
I've found one regression caused by this patch, but I don't understand it. When resizing http://mersenne.org/ips/accounts.html the password chars, "********", don't move with the field. The other text field works great so I'm inclined to believe it to be a bug in the password field code, that has to be fixed before landing this. Can anyone give me directions where to look or who to nag to get further? Waterson?
When I click in the (empty) password field the caret begins to blink among the "******" a little higher up on the page, but as soon as I write anything the stars and the caret moves to its proper position inside the field.
No XBL problem here. The frame tree has already been monkeyed with, so you can walk it normally.
I managed to reproduce the bug on http://mersenne.org/ips/accounts.html in a clean build so it wasn't my change. I'm still going through the layout tests and will continue that tonight. When I think that all fails are benign I will attach the updated patch. Btw, shouldn't someone from session history ok this?
Then I will go for another round of reviews. The newly attached patch fixes the giant memory leak the previous one caused. Thanks to jst who saw it in bug 74328. I have run the regression tests and the only differences I get is in the completely unpredictable image loaded flag which I blame on someone else.
Keywords: review
Whiteboard: fix in hand → fix in hand waiting for r and sr
r=waterson
very nice! sr=attinasi
Daniel, please check this in. Let me know if you don't have CVS access, and I'll check it in for you. This is related to bug 56854.
Blocks: 56854
Now it's in. I've been having time zone problems (you don't want to know how early in the morning it is here right now. :-) ).
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Marking verified per last comments.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: