Closed
Bug 877450
Opened 12 years ago
Closed 12 years ago
Create Developer Tool widget with subview
Categories
(Firefox :: Toolbars and Customization, defect)
Firefox
Toolbars and Customization
Tracking
()
RESOLVED
FIXED
Firefox 28
People
(Reporter: zfang, Assigned: mconley)
References
(Blocks 1 open bug)
Details
(Keywords: addon-compat, Whiteboard: [Australis:M?][Australis:P1])
Attachments
(1 file, 2 obsolete files)
|
7.32 KB,
patch
|
Gijs
:
review+
|
Details | Diff | Splinter Review |
We kind of decided to just open the Web Console when "Developer Tools" is dragged into the menu panel - but that was before we had the subview model. Now that we have a model for subview, we should use that for Developer tools.
| Assignee | ||
Updated•12 years ago
|
OS: Mac OS X → All
Hardware: x86 → All
| Assignee | ||
Comment 1•12 years ago
|
||
Tentatively, this is a want for M7 - but it wouldn't be the end of the world if it slipped to M8.
Whiteboard: [Australis:M?] → [Australis:M7]
Comment 4•12 years ago
|
||
So, basically adding this list http://cl.ly/image/0d202R1Q1X1S as a subpanel? Any adjustments while we're in there?
Comment 5•12 years ago
|
||
Will add-ons be able to extend the list like they can currently add items to the Web Developer menu?
Comment 6•12 years ago
|
||
(In reply to Dão Gottwald [:dao] from comment #5)
> Will add-ons be able to extend the list like they can currently add items to
> the Web Developer menu?
We *could* implement it the same way as the Help subview, which simply copies the menu items over each time the subview is opened.
Comment 7•12 years ago
|
||
I'm calling this P5 because comment 0 is a "we'd like to", and AFAIK we're ok with the current widget. If we actually _need_ to implement the subview, then this should be P1/P2.
Flags: needinfo?(zfang)
Whiteboard: [Australis:M?] → [Australis:M?][Australis:P5]
Comment 8•12 years ago
|
||
We need the subview if we want to expose add-on items from the Web Developer menu. There's also the "Get More Tools" item that isn't exposed anywhere else.
Keywords: addon-compat
Comment 9•12 years ago
|
||
(In reply to Justin Dolske [:Dolske] from comment #7)
> I'm calling this P5 because comment 0 is a "we'd like to", and AFAIK we're
> ok with the current widget. If we actually _need_ to implement the subview,
> then this should be P1/P2.
As discussed on IRC a couple of days ago, not having a subview really isn't working. We need this fixed.
Whiteboard: [Australis:M?][Australis:P5] → [Australis:M?][Australis:P1]
Comment 10•12 years ago
|
||
Can the DevTools team help? (and what is a subview?)
Comment 11•12 years ago
|
||
(In reply to Paul Rouget [:paul] from comment #10)
> Can the DevTools team help? (and what is a subview?)
Yes, help would be appreciated :-). A subview is a simple menu that appears when the user clicks on the button in the menu panel. The menu slides over to reveal the submenu, which we are calling a subview.
If you run the UX Nightly, you can see one today by clicking on the History button in the menu panel.
| Assignee | ||
Comment 12•12 years ago
|
||
I'll take a crack at this one today. I'm going to try to use the same approach that the Help menu uses.
| Assignee | ||
Updated•12 years ago
|
Assignee: nobody → mconley
| Assignee | ||
Comment 13•12 years ago
|
||
Doing some self review and testing on Windows and OSX before requesting review.
| Assignee | ||
Comment 14•12 years ago
|
||
Comment on attachment 772754 [details] [diff] [review]
Patch v1
What do you think of this, Gijs?
Attachment #772754 -
Flags: review?(gijskruitbosch+bugs)
Comment 15•12 years ago
|
||
Comment on attachment 772754 [details] [diff] [review]
Patch v1
Review of attachment 772754 [details] [diff] [review]:
-----------------------------------------------------------------
I'm very happy you figured out a fix for the Firebug issues we discussed on IRC, but I became very nitpicky on the actual implementation, so feedback+ and let me know what you think of some of my points? I don't feel strongly about all of them, necessarily, but there were enough that I guess it makes sense to do another patch and see where we end up.
::: browser/components/customizableui/content/panelUI.inc.xul
@@ +48,5 @@
> <vbox id="PanelUI-helpItems"/>
> </panelview>
> +
> + <panelview id="PanelUI-developer" flex="1">
> + <label value="&webDeveloperMenu.label;"/>
I wonder if this is going to be an issue for localizers (reusing the same string in a different place). But we're doing this in various places, so let's hope it's OK unless told otherwise.
::: browser/components/customizableui/content/panelUI.js
@@ +190,5 @@
> tempPanel.addEventListener("popuphidden", function panelRemover() {
> tempPanel.removeEventListener("popuphidden", panelRemover);
> tempPanel.removeEventListener("command", PanelUI._onWidgetPanelCommand);
> + let evt = document.createEvent("CustomEvent");
> + evt.initCustomEvent("ViewHiding", true, true, viewNode);
Nit: please use new CustomEvent("ViewHiding"), and only specify cancelable/bubbles on the parameter object if they're necessary. I'm not sure why we need to send viewNode if it's also the target of the event...
::: browser/components/customizableui/src/CustomizableWidgets.jsm
@@ +193,5 @@
> + onViewShowing: function(aEvent) {
> + // Populate the subview with whatever menuitems are in the developer
> + // menu. We skip menu elements, because the menu panel has no way
> + // of dealing with those right now.
> + let doc = aEvent.target.ownerDocument;
You removed a lot of nullchecks. Why were those there and/or can we really get rid of them? :-)
@@ +196,5 @@
> + // of dealing with those right now.
> + let doc = aEvent.target.ownerDocument;
> + let win = doc.defaultView;
> +
> + let items = this.getElementsByTagName("vbox")[0];
Nit: This node has an ID. Why can't we use that? It's also the lastChild of the view node, and that's probably still better than getElementsByTagName()[0]...
@@ +200,5 @@
> + let items = this.getElementsByTagName("vbox")[0];
> + let menu = doc.getElementById("menuWebDeveloperPopup");
> + let attrs = ["oncommand", "onclick", "label", "key", "disabled",
> + "command"];
> + let menuItems = menu.querySelectorAll("menuitem,menuseparator");
This is recursive, so it'll extract menuitems/separators from submenus if they're included in the menu. Seeing as we're walking through this list later anyway, how about making that for loop just walk:
for (let node of menu.children) {
if (node.hidden)
continue;
if (node.localName == "menuseparator") {
item = doc.createElementNS(...);
} else if (node.localName == "menuitem") {
item = doc.createElementNS(...);
} else {
continue;
}
...
That'll also save us a querySelectorAll call and I suspect it won't really be any slower.
@@ +213,5 @@
> + item = doc.createElementNS(kNSXUL, "menuseparator");
> + } else {
> + item = doc.createElementNS(kNSXUL, "toolbarbutton");
> + }
> + for (let attrName of attrs) {
Nit: let attr of attrs or let attrName of attrNames
@@ +216,5 @@
> + }
> + for (let attrName of attrs) {
> + if (!node.hasAttribute(attrName))
> + continue;
> + item.setAttribute(attrName, node.getAttribute(attrName));
Nit: I *think* this can be:
let attrVal = node.getAttribute(attrName);
if (attrVal)
item.setAttribute(attrName, attrVal);
Which I find slightly neater, but hey, either works, and I'm not actually that fussed.
@@ +223,5 @@
> }
> + items.appendChild(fragment);
> +
> + aEvent.originalTarget
> + .addEventListener("command", win.PanelUI.onCommandHandler);
What's originalTarget here, and could we use plain target? Or is that a dumb idea?
@@ +228,5 @@
> + },
> + onViewHiding: function(aEvent) {
> + let doc = aEvent.target.ownerDocument;
> + let win = doc.defaultView;
> + let items = this.getElementsByTagName("vbox")[0];
See above.
@@ +231,5 @@
> + let win = doc.defaultView;
> + let items = this.getElementsByTagName("vbox")[0];
> + while (items.firstChild) {
> + items.firstChild.remove();
> + }
Hrm. Can we just items.remove(), and reappend? I think that might be slightly faster... but I'm not sure.
Attachment #772754 -
Flags: review?(gijskruitbosch+bugs) → feedback+
| Assignee | ||
Comment 16•12 years ago
|
||
(In reply to :Gijs Kruitbosch from comment #15)
> Comment on attachment 772754 [details] [diff] [review]
> Patch v1
>
> Review of attachment 772754 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: browser/components/customizableui/content/panelUI.inc.xul
> @@ +48,5 @@
> > <vbox id="PanelUI-helpItems"/>
> > </panelview>
> > +
> > + <panelview id="PanelUI-developer" flex="1">
> > + <label value="&webDeveloperMenu.label;"/>
>
> I wonder if this is going to be an issue for localizers (reusing the same
> string in a different place). But we're doing this in various places, so
> let's hope it's OK unless told otherwise.
>
Yep.
> ::: browser/components/customizableui/content/panelUI.js
> @@ +190,5 @@
> > tempPanel.addEventListener("popuphidden", function panelRemover() {
> > tempPanel.removeEventListener("popuphidden", panelRemover);
> > tempPanel.removeEventListener("command", PanelUI._onWidgetPanelCommand);
> > + let evt = document.createEvent("CustomEvent");
> > + evt.initCustomEvent("ViewHiding", true, true, viewNode);
>
> Nit: please use new CustomEvent("ViewHiding"), and only specify
> cancelable/bubbles on the parameter object if they're necessary. I'm not
> sure why we need to send viewNode if it's also the target of the event...
>
Ok, switched to new CustomEvent constructor. I like that new way of doing it - didn't realize I was using the old-school method. :)
As for the viewNode detail - I don't recall why that's being passed. You're right - it's the target of the event, so it's not providing any new information. I've filed bug 891939 to investigate.
> ::: browser/components/customizableui/src/CustomizableWidgets.jsm
> @@ +193,5 @@
> > + onViewShowing: function(aEvent) {
> > + // Populate the subview with whatever menuitems are in the developer
> > + // menu. We skip menu elements, because the menu panel has no way
> > + // of dealing with those right now.
> > + let doc = aEvent.target.ownerDocument;
>
> You removed a lot of nullchecks. Why were those there and/or can we really
> get rid of them? :-)
>
Not 100% sure. It seems overcautious to me - if an Event is fired and heard by onViewShowing, it must have had a target (in the case of onViewShowing and onViewHiding, that target would be a subview). And the ViewShowing and ViewHiding events should only be fired on items that are about to show, or about to hide - so they must still belong to a document. And that document must have a window, shouldn't it?
> @@ +196,5 @@
> > + // of dealing with those right now.
> > + let doc = aEvent.target.ownerDocument;
> > + let win = doc.defaultView;
> > +
> > + let items = this.getElementsByTagName("vbox")[0];
>
> Nit: This node has an ID. Why can't we use that? It's also the lastChild of
> the view node, and that's probably still better than
> getElementsByTagName()[0]...
>
Good call.
> @@ +200,5 @@
> > + let items = this.getElementsByTagName("vbox")[0];
> > + let menu = doc.getElementById("menuWebDeveloperPopup");
> > + let attrs = ["oncommand", "onclick", "label", "key", "disabled",
> > + "command"];
> > + let menuItems = menu.querySelectorAll("menuitem,menuseparator");
>
> This is recursive, so it'll extract menuitems/separators from submenus if
> they're included in the menu.
D'oh! Good catch.
> Seeing as we're walking through this list
> later anyway, how about making that for loop just walk:
>
> for (let node of menu.children) {
> if (node.hidden)
> continue;
> if (node.localName == "menuseparator") {
> item = doc.createElementNS(...);
> } else if (node.localName == "menuitem") {
> item = doc.createElementNS(...);
> } else {
> continue;
> }
> ...
>
> That'll also save us a querySelectorAll call and I suspect it won't really
> be any slower.
>
Yep, done.
> @@ +213,5 @@
> > + item = doc.createElementNS(kNSXUL, "menuseparator");
> > + } else {
> > + item = doc.createElementNS(kNSXUL, "toolbarbutton");
> > + }
> > + for (let attrName of attrs) {
>
> Nit: let attr of attrs or let attrName of attrNames
>
Done.
> @@ +216,5 @@
> > + }
> > + for (let attrName of attrs) {
> > + if (!node.hasAttribute(attrName))
> > + continue;
> > + item.setAttribute(attrName, node.getAttribute(attrName));
>
> Nit: I *think* this can be:
>
> let attrVal = node.getAttribute(attrName);
> if (attrVal)
> item.setAttribute(attrName, attrVal);
>
> Which I find slightly neater, but hey, either works, and I'm not actually
> that fussed.
>
Sure, changed.
> @@ +223,5 @@
> > }
> > + items.appendChild(fragment);
> > +
> > + aEvent.originalTarget
> > + .addEventListener("command", win.PanelUI.onCommandHandler);
>
> What's originalTarget here, and could we use plain target? Or is that a dumb
> idea?
>
Target is just fine, I believe. Fixed.
> @@ +228,5 @@
> > + },
> > + onViewHiding: function(aEvent) {
> > + let doc = aEvent.target.ownerDocument;
> > + let win = doc.defaultView;
> > + let items = this.getElementsByTagName("vbox")[0];
>
> See above.
>
Fixed.
> @@ +231,5 @@
> > + let win = doc.defaultView;
> > + let items = this.getElementsByTagName("vbox")[0];
> > + while (items.firstChild) {
> > + items.firstChild.remove();
> > + }
>
> Hrm. Can we just items.remove(), and reappend? I think that might be
> slightly faster... but I'm not sure.
Good idea.
Attachment #772754 -
Attachment is obsolete: true
| Assignee | ||
Comment 17•12 years ago
|
||
Er, no idea why my generated patch swaps out all of panelUI.js....lemme fix that.
| Assignee | ||
Comment 18•12 years ago
|
||
My editor was doing something strange. Fixed it.
Attachment #773346 -
Attachment is obsolete: true
| Assignee | ||
Comment 19•12 years ago
|
||
Comment on attachment 773362 [details] [diff] [review]
Patch v1.2
Ok, how's this?
Attachment #773362 -
Flags: review?(gijskruitbosch+bugs)
Comment 20•12 years ago
|
||
Comment on attachment 773362 [details] [diff] [review]
Patch v1.2
Review of attachment 773362 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good to me, thanks!
Attachment #773362 -
Flags: review?(gijskruitbosch+bugs) → review+
| Assignee | ||
Comment 21•12 years ago
|
||
Thanks! Landed on UX as https://hg.mozilla.org/projects/ux/rev/0f07f81c289f
Status: NEW → ASSIGNED
Flags: needinfo?(zfang)
Whiteboard: [Australis:M?][Australis:P1] → [Australis:M?][Australis:P1][fixed-in-ux]
Comment 22•12 years ago
|
||
You should probably change the tooltip to Developer Tools, not Toggle Developer Tools right ?
| Assignee | ||
Comment 23•12 years ago
|
||
(In reply to ntim007 from comment #22)
> You should probably change the tooltip to Developer Tools, not Toggle
> Developer Tools right ?
That's a good idea. I'll file a bug.
| Assignee | ||
Comment 24•12 years ago
|
||
Filed bug 894375.
Comment 25•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [Australis:M?][Australis:P1][fixed-in-ux] → [Australis:M?][Australis:P1]
Target Milestone: --- → Firefox 28
You need to log in
before you can comment on or make changes to this bug.
Description
•