Closed Bug 376802 Opened 17 years ago Closed 17 years ago

One Tooltip Listener to rule them all

Categories

(Core :: XUL, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: neil, Assigned: neil)

References

Details

Attachments

(1 file, 1 obsolete file)

Currently we create a tooltip listener for every XUL tree and every XUL element with either the tooltip or tooltiptext attribute. However the listener's source node is always the same as the event's current target and the listener only has to store state for the currently hovered element.
Attached patch Proposed patch (obsolete) — Splinter Review
The only bit I'm not sure about is the change to nsLayoutStatics.cpp
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #260910 - Flags: superreview?(jst)
Attachment #260910 - Flags: review?(Olli.Pettay)
I wonder if someone tries to get the review faster using Tolkien
quotations ;) That is ofc always the easy way get my attention.
Comment on attachment 260910 [details] [diff] [review]
Proposed patch


>+++ layout/xul/base/src/nsRootBoxFrame.cpp	7 Apr 2007 12:34:01 -0000
>@@ -317,10 +317,8 @@
> {
>   nsXULTooltipListener* listener =
>     NS_STATIC_CAST(nsXULTooltipListener*, aPropertyValue);
>-  if (listener) {
>+  if (listener)
>     listener->RemoveTooltipSupport(NS_STATIC_CAST(nsIContent*, aObject));
>-    NS_RELEASE(listener);
>-  }
> }

Are you sure that this is always called before ReleaseInstance()?
Would it be safer to keep NS_RELEASE here and NS_ADDREF when adding tooltip.

> #ifdef MOZ_XUL
>   // titletips should just use the default tooltip
>-  if (mIsSourceTree && mNeedTitletip) {
>+  if (mNeedTitletip) {

Could you explain this change?
(In reply to comment #3)
>Are you sure that this is always called before ReleaseInstance()?
>Would it be safer to keep NS_RELEASE here and NS_ADDREF when adding tooltip.
Actually I was wondering why you added it - I thought AddTooltipSupport addrefed the listener anyway.

>>-  if (mIsSourceTree && mNeedTitletip) {
>>+  if (mNeedTitletip) {
>Could you explain this change?
Sure. mNeedTitletip can only be set if the source is a tree (but even then it is cleared by a tooltip or tooltiptext attribute).
Ok, http://lxr.mozilla.org/seamonkey/source/content/base/src/nsNodeUtils.cpp#202
::LastRelease deletes properties before releasing event listeners.
Attachment #260910 - Flags: review?(Olli.Pettay) → review+
Attached patch Revised patchSplinter Review
Well that was weird. I had to back out attachment 207282 [details] [diff] [review] to fix the regression that the proposed patch reintroduces...

I reverted that condition that Smaug asked about amongst other things to try to fix the above regression and I left it so as not to fiddle too much.

I also removed the tooltiplistener property, it was only there to avoid adding multiple tooltip listeners to the same element, but since there is only one...

I felt like making the callbacks use the global instance, so I did.

I also removed the static nsRefPtr, it bit me ;-)
Attachment #260910 - Attachment is obsolete: true
Attachment #261046 - Flags: superreview?(jst)
Attachment #261046 - Flags: review?(Olli.Pettay)
Attachment #260910 - Flags: superreview?(jst)
(In reply to comment #6)
>Well that was weird. I had to back out attachment 207282 [details] [diff] [review]
OK, so I overlooked the fact that the tooltip listener checks the mouse moves between events, and ignores all events that don't change the mouse position.
Comment on attachment 261046 [details] [diff] [review]
Revised patch

Make the XULTooltipListener constructor private if possible.
Attachment #261046 - Flags: review?(Olli.Pettay) → review+
Comment on attachment 261046 [details] [diff] [review]
Revised patch

sr=jst
Attachment #261046 - Flags: superreview?(jst) → superreview+
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Depends on: 377473
Depends on: 377495
No longer depends on: 377495
nsLayoutStatics::Shutdown is only called after all windows and documents are released. nsXULTooltipListener holds nodes, which can easily keep windows and documents alive. This change seems to make it very easy for bad shutdown leaks to happen.
nsXULTooltipListener could use nsWeakPtrs to nodes or
maybe even boxObjects.
Though, I guess shutdown leaks were possible even without the patch.
Peter, do you have a testcase?
(In reply to comment #11)
>nsXULTooltipListener holds nodes
It's not supposed to. At least, I tried to make sure that it cleared out mSourceNode. Feel free to file bugs on me for any demonstratable "leaks".
Depends on: 377899
(In reply to comment #14)
> Feel free to file bugs on me for any demonstratable "leaks".

Bug 417534 :)
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: xptoolkit.xul → xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: