summaryrefslogtreecommitdiffstats
path: root/devtools/client
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-02-04 19:51:02 +0100
committerGitHub <noreply@github.com>2018-02-04 19:51:02 +0100
commit34cdbd1366224f040136c3a747709ae5e92f5956 (patch)
tree6fe19ea1a062a5f0e285e2298a92bf642b233594 /devtools/client
parentc0dfa1fdaa3f1135504d81507f61b3fd8dfd25e0 (diff)
parentf34094bae31e216228d5c2da2f2461d03df38302 (diff)
downloadUXP-34cdbd1366224f040136c3a747709ae5e92f5956.tar
UXP-34cdbd1366224f040136c3a747709ae5e92f5956.tar.gz
UXP-34cdbd1366224f040136c3a747709ae5e92f5956.tar.lz
UXP-34cdbd1366224f040136c3a747709ae5e92f5956.tar.xz
UXP-34cdbd1366224f040136c3a747709ae5e92f5956.zip
Merge pull request #6 from janekptacijarabaci/devtools_inspector_copyFullCSSPath_1
Add a "copy full CSS path" option to the inspector's menu
Diffstat (limited to 'devtools/client')
-rw-r--r--devtools/client/inspector/inspector.js32
-rw-r--r--devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js1
-rw-r--r--devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js6
-rw-r--r--devtools/client/locales/en-US/inspector.properties6
-rw-r--r--devtools/client/shared/telemetry.js6
5 files changed, 49 insertions, 2 deletions
diff --git a/devtools/client/inspector/inspector.js b/devtools/client/inspector/inspector.js
index c056c213f..d0458fc1f 100644
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -169,6 +169,10 @@ Inspector.prototype = {
return this._target.client.traits.getUniqueSelector;
},
+ get canGetCssPath() {
+ return this._target.client.traits.getCssPath;
+ },
+
get canGetUsedFontFaces() {
return this._target.client.traits.getUsedFontFaces;
},
@@ -1074,6 +1078,15 @@ Inspector.prototype = {
click: () => this.copyUniqueSelector(),
}));
copySubmenu.append(new MenuItem({
+ id: "node-menu-copycsspath",
+ label: INSPECTOR_L10N.getStr("inspectorCopyCSSPath.label"),
+ accesskey:
+ INSPECTOR_L10N.getStr("inspectorCopyCSSPath.accesskey"),
+ disabled: !isSelectionElement,
+ hidden: !this.canGetCssPath,
+ click: () => this.copyCssPath(),
+ }));
+ copySubmenu.append(new MenuItem({
id: "node-menu-copyimagedatauri",
label: INSPECTOR_L10N.getStr("inspectorImageDataUri.label"),
disabled: !isSelectionElement || !markupContainer ||
@@ -1677,9 +1690,24 @@ Inspector.prototype = {
return;
}
- this.selection.nodeFront.getUniqueSelector().then((selector) => {
+ this.telemetry.toolOpened("copyuniquecssselector");
+ this.selection.nodeFront.getUniqueSelector().then(selector => {
clipboardHelper.copyString(selector);
- }).then(null, console.error);
+ }).catch(e => console.error);
+ },
+
+ /**
+ * Copy the full CSS Path of the selected Node to the clipboard.
+ */
+ copyCssPath: function () {
+ if (!this.selection.isNode()) {
+ return;
+ }
+
+ this.telemetry.toolOpened("copyfullcssselector");
+ this.selection.nodeFront.getCssPath().then(path => {
+ clipboardHelper.copyString(path);
+ }).catch(e => console.error);
},
/**
diff --git a/devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js b/devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js
index 59dbbbcc0..052e9da68 100644
--- a/devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js
@@ -26,6 +26,7 @@ const ALL_MENU_ITEMS = [
"node-menu-copyinner",
"node-menu-copyouter",
"node-menu-copyuniqueselector",
+ "node-menu-copycsspath",
"node-menu-copyimagedatauri",
"node-menu-delete",
"node-menu-pseudo-hover",
diff --git a/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js b/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
index 0c96e9bbe..57a5dbaa0 100644
--- a/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
@@ -26,6 +26,12 @@ const COPY_ITEMS_TEST_DATA = [
text: "body > div:nth-child(1) > p:nth-child(2)",
},
{
+ desc: "copy css path",
+ id: "node-menu-copycsspath",
+ selector: "[data-id=\"copy\"]",
+ text: "html body div p",
+ },
+ {
desc: "copy image data uri",
id: "node-menu-copyimagedatauri",
selector: "#copyimage",
diff --git a/devtools/client/locales/en-US/inspector.properties b/devtools/client/locales/en-US/inspector.properties
index 4f4829678..b6f3e072b 100644
--- a/devtools/client/locales/en-US/inspector.properties
+++ b/devtools/client/locales/en-US/inspector.properties
@@ -154,6 +154,12 @@ inspectorCopyOuterHTML.accesskey=O
inspectorCopyCSSSelector.label=CSS Selector
inspectorCopyCSSSelector.accesskey=S
+# LOCALIZATION NOTE (inspectorCopyCSSPath.label): This is the label
+# shown in the inspector contextual-menu for the item that lets users copy
+# the full CSS path of the current node
+inspectorCopyCSSPath.label=CSS Path
+inspectorCopyCSSPath.accesskey=P
+
# LOCALIZATION NOTE (inspectorPasteOuterHTML.label): This is the label shown
# in the inspector contextual-menu for the item that lets users paste outer
# HTML in the current node
diff --git a/devtools/client/shared/telemetry.js b/devtools/client/shared/telemetry.js
index 64a299581..38a21cef6 100644
--- a/devtools/client/shared/telemetry.js
+++ b/devtools/client/shared/telemetry.js
@@ -163,6 +163,12 @@ Telemetry.prototype = {
toolbareyedropper: {
histogram: "DEVTOOLS_TOOLBAR_EYEDROPPER_OPENED_COUNT",
},
+ copyuniquecssselector: {
+ histogram: "DEVTOOLS_COPY_UNIQUE_CSS_SELECTOR_OPENED_COUNT",
+ },
+ copyfullcssselector: {
+ histogram: "DEVTOOLS_COPY_FULL_CSS_SELECTOR_OPENED_COUNT",
+ },
developertoolbar: {
histogram: "DEVTOOLS_DEVELOPERTOOLBAR_OPENED_COUNT",
timerHistogram: "DEVTOOLS_DEVELOPERTOOLBAR_TIME_ACTIVE_SECONDS"