Skip to content

Instantly share code, notes, and snippets.

@xonecas
Last active Dec 14, 2015
Embed
What would you like to do?
Playing around with the firefox dev tools source.
diff -r e6215e0357fa browser/devtools/responsivedesign/responsivedesign.jsm
--- a/browser/devtools/responsivedesign/responsivedesign.jsm Fri Mar 08 13:53:43 2013 -0800
+++ b/browser/devtools/responsivedesign/responsivedesign.jsm Fri Mar 08 19:12:13 2013 -0800
@@ -13,6 +13,7 @@
Cu.import("resource:///modules/devtools/FloatingScrollbars.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/Target.jsm");
+Cu.import("resource:///modules/devtools/BuiltinCommands.jsm");
this.EXPORTED_SYMBOLS = ["ResponsiveUIManager"];
@@ -158,6 +159,7 @@
this.bound_stopResizing = this.stopResizing.bind(this);
this.bound_onDrag = this.onDrag.bind(this);
this.bound_onKeypress = this.onKeypress.bind(this);
+ this.bound_takeScreenshot = this.takeScreenshot.bind(this);
// Events
this.tab.addEventListener("TabClose", this);
@@ -224,6 +226,7 @@
this.rotatebutton.removeEventListener("command", this.bound_rotate, true);
this.addbutton.removeEventListener("command", this.bound_addPreset, true);
this.removebutton.removeEventListener("command", this.bound_removePreset, true);
+ this.screenshotbutton.removeEventListener("command", this.bound_takeScreenshot, true);
// Removed elements.
this.container.removeChild(this.toolbar);
@@ -334,8 +337,15 @@
this.rotatebutton.className = "devtools-toolbarbutton";
this.rotatebutton.addEventListener("command", this.bound_rotate, true);
+ this.screenshotbutton = this.chromeDoc.createElement("toolbarbutton");
+ this.screenshotbutton.setAttribute("tabindex", "1");
+ this.screenshotbutton.setAttribute("label", "screenshot"); // this.strings.GetStringFromName("responsiveUI.screenshot")
+ this.screenshotbutton.className = "devtools-toolbarbutton";
+ this.screenshotbutton.addEventListener("command", this.bound_takeScreenshot, true);
+
this.toolbar.appendChild(this.menulist);
this.toolbar.appendChild(this.rotatebutton);
+ this.toolbar.appendChild(this.screenshotbutton);
// Resizers
this.resizer = this.chromeDoc.createElement("box");
@@ -687,6 +697,16 @@
Services.prefs.setCharPref("devtools.responsiveUI.presets", JSON.stringify(registeredPresets));
},
+
+ /**
+ * Take a screenshot
+ */
+ takeScreenshot: function RUI_takeScreenshot() {
+ // this should bridge commandline > screenshot. How do I reference that
+ // method?
+ // this does nothing
+ BuiltinCommands.screenshot();
+ }
}
XPCOMUtils.defineLazyGetter(ResponsiveUI.prototype, "strings", function () {
@xonecas
Copy link
Author

xonecas commented Mar 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment