Closed Bug 891926 Opened 11 years ago Closed 11 years ago

destroyWidget should actually get viewNode before trying to use it

Categories

(Firefox :: Toolbars and Customization, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 28

People

(Reporter: Gijs, Assigned: Gijs)

References

(Blocks 1 open bug)

Details

(Whiteboard: [Australis:M8][Australis:P1])

Attachments

(1 file)

http://hg.mozilla.org/projects/ux/file/fa7675b67853/browser/components/customizableui/src/CustomizableUI.jsm#l1460

  1460   destroyWidget: function(aWidgetId) {
  1461     let widget = gPalette.get(aWidgetId);
  1462     if (!widget) {
  1463       return;
  1464     }
  1465 
  1466     // This will not remove the widget from gPlacements - we want to keep the
  1467     // setting so the widget gets put back in it's old position if/when it
  1468     // returns.
  1469 
  1470     let area = widget.currentArea;
  1471     if (area) {
  1472       let buildArea = gBuildAreas.get(area);
  1473       for (let buildNode of buildArea) {
  1474         let widgetNode = buildNode.ownerDocument.getElementById(aWidgetId);
  1475         if (widgetNode) {
  1476           widgetNode.parentNode.removeChild(widgetNode);
  1477         }
  1478         for (let eventName of kSubviewEvents) {
  1479           let handler = "on" + eventName;
  1480           if (typeof widget[handler] == "function") {
  1481             viewNode.removeEventListener(eventName, widget[handler], false);
  1482           }
  1483         }
  1484       }
  1485     }


Been there for a few months now. Let's not ship that.
Attached patch PatchSplinter Review
Attachment #773343 - Flags: review?(bmcbride)
Comment on attachment 773343 [details] [diff] [review]
Patch

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

::: browser/components/customizableui/src/CustomizableUI.jsm
@@ +1474,5 @@
>          if (widgetNode) {
>            widgetNode.parentNode.removeChild(widgetNode);
>          }
> +        let viewNode = widget.type == "view" &&
> +                       buildNode.ownerDocument.getElementById(widget.viewId);

Nit: I prefer to avoid this construct - it makes it non-obvious what it's doing. Though more verbose, the following makes it more obvious IMO:
  if (widget.type == "view") {
    let viewNode = ...;
    ...

But, that may just simply be my own personal preference.
Attachment #773343 - Flags: review?(bmcbride) → review+
(In reply to Blair McBride [:Unfocused] from comment #2)
> Comment on attachment 773343 [details] [diff] [review]
> Patch
> 
> Review of attachment 773343 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: browser/components/customizableui/src/CustomizableUI.jsm
> @@ +1474,5 @@
> >          if (widgetNode) {
> >            widgetNode.parentNode.removeChild(widgetNode);
> >          }
> > +        let viewNode = widget.type == "view" &&
> > +                       buildNode.ownerDocument.getElementById(widget.viewId);
> 
> Nit: I prefer to avoid this construct - it makes it non-obvious what it's
> doing. Though more verbose, the following makes it more obvious IMO:
>   if (widget.type == "view") {
>     let viewNode = ...;
>     ...
> 
> But, that may just simply be my own personal preference.

I think that's a fair point. Changed, and pushed: https://hg.mozilla.org/projects/ux/rev/5a294331b6b5 .
Whiteboard: [Australis:P1] → [Australis:M8][Australis:P1][fixed-in-ux]
https://hg.mozilla.org/mozilla-central/rev/5a294331b6b5
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [Australis:M8][Australis:P1][fixed-in-ux] → [Australis:M8][Australis:P1]
Target Milestone: --- → Firefox 28
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: