Closed Bug 670749 Opened 13 years ago Closed 13 years ago

Have individual methods for cookie/image/popup menus in navigatorOverlay

Categories

(SeaMonkey :: Passwords & Permissions, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
seamonkey2.5

People

(Reporter: iannbugzilla, Assigned: iannbugzilla)

References

Details

Attachments

(1 file, 1 obsolete file)

From bug 669291 comment 3

>+      <menupopup id="taskPopup" onpopupshowing="CheckForVisibility();">
It just occurs to me that this gets called each time the menu or submenu is opened... probably worth removing this in favour of individual methods for each of the permission submenus
This patch:
* Moves the cookie/image code into separate function and calls from relevant menu with a type argument.
* Passes event argument to CheckForVisibility so that the non-mac code can be moved from the onpopupshowing to the function.
* Moves the caller to CheckForVisibility from task menupopup to popup manager menu.
Attachment #545353 - Flags: review?(neil)
Comment on attachment 545353 [details] [diff] [review]
Create separate functions for popup and non-popup permission menus

>+function CheckPermissionsMenu(aType)
> {
>+  // Determine current state and check/uncheck the appropriate menu items.
>+  setRadioButtons(getBrowser().currentURI, aType);
Can you not move the call to get the current URI into setRadioButtons? (You may subsequently want to rename setRadioButtons to CheckPermissionsMenu).

>   var items = document.getElementById("menu_" + aType + "Manager")
>                       .getElementsByAttribute("name", aType);
You could get the target from the popupshowing handler event.

>         <menu id="menu_cookieManager"
>               label="&cookieCookieManager.label;"
>               accesskey="&cookieCookieManager.accesskey;"
>+              onpopupshowing="CheckPermissionsMenu('cookie');"
>               oncommand="if (event.target.id) CookieImageAction(event.target);
>                          else toDataManager('|cookies');">
>           <menupopup>
Nit: Please move the popupshowing event handler to the popup.
Changes since last version:
* As suggested moved currentURI to setRadioButtons and renamed function to CheckPermissionsMenu.
* Passes this as an argument to CheckPermissionsMenu.
* Moved function callers to menupopup from menu element.
Attachment #545353 - Attachment is obsolete: true
Attachment #545401 - Flags: review?(neil)
Attachment #545353 - Flags: review?(neil)
Comment on attachment 545401 [details] [diff] [review]
Moved callers to separate functions [Checked in: Comment 5]

>+  if (!/Mac/.test(navigator.platform))
>+    return popupBlockerMenuShowing(aEvent);
> }
[The return is and has always been unnecessary, and is in fact a JS Strict warning, but I don't know why neither version gets reported.]

>+  var currentPerm = Services.perms.testPermission(getBrowser().currentURI,
>+                                                  aType);
[Hardly worth wrapping this for two characters. If you're really that worried you could try shortening the currentPerm variable.]
Attachment #545401 - Flags: review?(neil) → review+
Comment on attachment 545401 [details] [diff] [review]
Moved callers to separate functions [Checked in: Comment 5]

http://hg.mozilla.org/comm-central/rev/7c0c838f516d
Attachment #545401 - Attachment description: Moved callers to separate functions → Moved callers to separate functions [Checked in: Comment 5]
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → seamonkey2.5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: