Closed
Bug 243724
Opened 21 years ago
Closed 21 years ago
[FIX]deCOMtaminate nsIWidget::GetChildren
Categories
(Core Graveyard :: GFX, defect, P1)
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla1.8alpha1
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
(Keywords: perf)
Attachments
(2 files, 3 obsolete files)
44.36 KB,
patch
|
Details | Diff | Splinter Review | |
2.00 KB,
patch
|
bzbarsky
:
review+
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
Looking at this DHTML profile, I see us spending nearly 1.5% of the total time
in nsBaseWidget::GetChildren. I don't see any reason this function can't just
return an nsCOMArray<nsIWidget>*, really.... Alternately, we could switch to a
GetChildCount()/GetChildAt() api, which can be made fast.
Thoughts on which is preferable?
![]() |
Assignee | |
Updated•21 years ago
|
Comment 1•21 years ago
|
||
I prefer the latter, myself. Mostly from a style standpoint.
I would actually prefer storing the children in a linked list and providing
GetFirstChild() and GetNextSibling(). Insertion and removal need to be fast, but
indexed access does not.
![]() |
Assignee | |
Comment 3•21 years ago
|
||
Hmm... I guess we always iterate over widgets in a linear order, don't we?
Chris, that sound OK to you? If so, I'll hack this up sometime soon.
Comment 4•21 years ago
|
||
Sure, fine with me.
![]() |
Assignee | |
Comment 5•21 years ago
|
||
Well, looks like Mac code iterates over widgets in reverse order in
nsWindow::FindWidgetHit (widget/src/mac/nsWindow.cpp). So I'll just go and do
something evil with PRCList here... ;)
![]() |
Assignee | |
Comment 6•21 years ago
|
||
Er, or not. It's simpler to just do a straight doubly-linked list and not
bother with evil casting.
![]() |
Assignee | |
Comment 7•21 years ago
|
||
![]() |
Assignee | |
Updated•21 years ago
|
Attachment #148954 -
Flags: superreview?(blizzard)
Attachment #148954 -
Flags: review?(roc)
![]() |
Assignee | |
Comment 8•21 years ago
|
||
Comment 9•21 years ago
|
||
Comment on attachment 148954 [details] [diff] [review]
diff -w, for review only
seems ok to me
Attachment #148954 -
Flags: superreview?(blizzard) → superreview+
why are GetNextSibling etc not nonvirtual and inline?
![]() |
Assignee | |
Comment 11•21 years ago
|
||
Mostly because I didn't want to add members to nsIWidget. If you think adding
such members is fine, I can certainly push them up there...
I don't see a problem with that. I think we've already broken all compilers that
don't handle this case well...
![]() |
Assignee | |
Comment 13•21 years ago
|
||
Alright then. Coming right up. ;)
![]() |
Assignee | |
Comment 14•21 years ago
|
||
The only differences from the first patch are in nsBaseWidget.{h,cpp} and
nsIWidget.h
![]() |
Assignee | |
Updated•21 years ago
|
Attachment #148954 -
Attachment is obsolete: true
Attachment #148955 -
Attachment is obsolete: true
![]() |
Assignee | |
Updated•21 years ago
|
Attachment #149006 -
Flags: superreview?(blizzard)
Attachment #149006 -
Flags: review?(roc)
![]() |
Assignee | |
Updated•21 years ago
|
Attachment #148954 -
Flags: review?(roc)
![]() |
Assignee | |
Updated•21 years ago
|
Summary: deCOMtaminate nsIWidget::GetChildren → [FIX]deCOMtaminate nsIWidget::GetChildren
Comment on attachment 149006 [details] [diff] [review]
Patch updated to that comment
+ nsIWidget* GetFirstChild(void) const {
Don't use (void). Just () is sufficient in C++.
+ for (nsIWidget* kid = mFirstChild; kid; ) {
+ nsIWidget* next = kid->GetNextSibling();
+ kid->Destroy();
+ kid = next;
}
could be just
while (mFirstChild) {
mFirstChild->Destroy();
}
right?
+ parent->RemoveChild(this);
I think you should hold a strong ref to this during this method, just to be on
the safe side. Currently we seem to be assuming that the caller holds a strong
ref.
I'd give you sr+ but you can wait for blizzard if you want :-)
Attachment #149006 -
Flags: review?(roc) → review+
![]() |
Assignee | |
Comment 16•21 years ago
|
||
> Don't use (void). Just () is sufficient in C++.
OK.
> could be just
> while (mFirstChild) {
That assumes they _will_ remove themselves. Is that a good assumption? I guess
that's done by nsBaseWidget, so yes...
If you prefer, I can do it that way.
> I think you should hold a strong ref to this during this method
You're right, since the caller's ref goes away when we remove. Will do.
If you want to sr, go for it.
Comment on attachment 149006 [details] [diff] [review]
Patch updated to that comment
sr+ with those changes.
Hmm, technically I'm not a widget peer or owner. But marshalling all the owners
would be hellish. I won't tell if you won't ;-)
Attachment #149006 -
Flags: superreview?(blizzard) → superreview+
![]() |
Assignee | |
Comment 18•21 years ago
|
||
I've left the Destroy() thing as-is because I actually can't tell whether the
gtk2 nsWindow::Destroy ever calls nsBaseWidget::Destroy and the code as written
works no matter whether it does....
I think blizzard being OK with the basic idea is good enough owner-wise. ;)
Attachment #149006 -
Attachment is obsolete: true
![]() |
Assignee | |
Comment 19•21 years ago
|
||
Checked in with some minor edits to fix mac orange (changing an assert to a
null-check, basically).
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Comment 20•21 years ago
|
||
I checked in a fix for some xlib fallout (visible on boffo) it would have
broken speedracer had it not been awol.
![]() |
Assignee | |
Comment 21•21 years ago
|
||
Doh. I hate changing platform-specific code... Thanks for catching that, Josh!
Comment on attachment 153271 [details] [diff] [review]
fix DEBUG-only leak regression
(I filed bug 251527 on making nsIWidget::GetParent return
already_AddRefed<nsIWidget>.)
Attachment #153271 -
Flags: superreview?(bzbarsky)
Attachment #153271 -
Flags: review?(bzbarsky)
![]() |
Assignee | |
Comment 24•21 years ago
|
||
Comment on attachment 153271 [details] [diff] [review]
fix DEBUG-only leak regression
r+sr=bzbarsky
Attachment #153271 -
Flags: superreview?(bzbarsky)
Attachment #153271 -
Flags: superreview+
Attachment #153271 -
Flags: review?(bzbarsky)
Attachment #153271 -
Flags: review+
Comment on attachment 153271 [details] [diff] [review]
fix DEBUG-only leak regression
Checked in to trunk, 2004-07-15 12:58 -0700.
Updated•16 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•