Closed Bug 898040 Opened 11 years ago Closed 11 years ago

Delay adding the event listeners for PanelUI until the panel menu is toggled

Categories

(Firefox :: Toolbars and Customization, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 28

People

(Reporter: jaws, Assigned: jaws)

References

Details

(Whiteboard: [Australis:M8])

Attachments

(2 files)

We shouldn't need to run PanelUI.init until the panel is activated.
We still need the lazy getters, but the event listeners aren't needed and it looks like the retrieval of the panel element is causing the panel constructor to be run.
Summary: Delay initialization of the PanelUI until the panel menu is toggled → Delay adding the event listeners for PanelUI until the panel menu is toggled
Attached patch 898040.patchSplinter Review
I confirmed locally that the PanelUI.xml binding constructor isn't being run with this patch and that the panel opens and functions correctly.
Attachment #781091 - Flags: review?(mconley)
Comment on attachment 781091 [details] [diff] [review]
898040.patch

Review of attachment 781091 [details] [diff] [review]:
-----------------------------------------------------------------

It's a little ugly that we have to run _ensureEventListenersAdded at the start of each of those functions, but I'll take performant code over pretty code at this point.

::: browser/components/customizableui/content/panelUI.js
@@ +25,5 @@
>        panel: "PanelUI-popup"
>      };
>    },
>  
> +  _ensureInitialized: function() {

I guess we should add a 

_initialized: false,

 somewhere here as well.

@@ +65,5 @@
>    uninit: function() {
> +    if (!this._initialized) {
> +      return;
> +    }
> +

And I guess we don't need to remove these if !this._eventListenersAdded.
Attachment #781091 - Flags: review?(mconley) → review+
Oh, I forgot to remove the _initialized business. It's not needed anymore.
Attached patch followup patchSplinter Review
I forgot to add a check in uninit to only remove the event listeners if they were added. Without this check, the PanelUI.xml cstor will run when a window is closed.
Attachment #781242 - Flags: review?(mconley)
Comment on attachment 781242 [details] [diff] [review]
followup patch

Review of attachment 781242 [details] [diff] [review]:
-----------------------------------------------------------------

r=me
Attachment #781242 - Flags: review?(mconley) → review+
Is adding event listeners for begin/end batch updates & showHelpView really needed? For the former, I don't think we need the listeners to be there. For the latter, that can't really be called without the panel having been opened before... right?
I was added them as defensive programming in case they become needed in the future, but we can remove them if you feel strongly about it.
https://hg.mozilla.org/mozilla-central/rev/89dfb5b64ed0
https://hg.mozilla.org/mozilla-central/rev/91c9b0675e2b
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [Australis:M8][fixed-in-ux] → [Australis:M8]
Target Milestone: --- → Firefox 28
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: