Bug 1598944 - Allow to copy innerHTML of document fragments (including ShadowRoot). r=jdescottes

As they have an innerHTML property, and it is useful.

I didn't find relevant tests for this. browser_inspector-traversal.js tests only
the server bits.

Differential Revision: https://phabricator.services.mozilla.com/D54422
This commit is contained in:
Emilio Cobos Álvarez
2019-11-28 12:02:43 +00:00
parent 5aa9dfa089
commit c20909433d

View File

@@ -472,14 +472,14 @@ class MarkupContextMenu {
return null;
}
_getCopySubmenu(markupContainer, isSelectionElement) {
_getCopySubmenu(markupContainer, isSelectionElement, isFragment) {
const copySubmenu = new Menu();
copySubmenu.append(
new MenuItem({
id: "node-menu-copyinner",
label: INSPECTOR_L10N.getStr("inspectorCopyInnerHTML.label"),
accesskey: INSPECTOR_L10N.getStr("inspectorCopyInnerHTML.accesskey"),
disabled: !isSelectionElement,
disabled: !isSelectionElement && !isFragment,
click: () => this._copyInnerHTML(),
})
);
@@ -743,6 +743,7 @@ class MarkupContextMenu {
this.nodeMenuTriggerInfo =
markupContainer && markupContainer.editor.getInfoAtNode(target);
const isFragment = this.selection.isDocumentFragmentNode();
const isSelectionElement =
this.selection.isElementNode() && !this.selection.isPseudoElementNode();
const isEditableElement =
@@ -816,6 +817,9 @@ class MarkupContextMenu {
menu.append(
new MenuItem({
label: INSPECTOR_L10N.getStr("inspectorBreakpointSubmenu.label"),
// FIXME(bug 1598952): This doesn't work in shadow trees at all, but
// we still display the active menu. Also, this should probably be
// enabled for ShadowRoot, at least the non-attribute breakpoints.
submenu: this._getDOMBreakpointSubmenu(isSelectionElement),
id: "node-menu-mutation-breakpoint",
})
@@ -895,7 +899,11 @@ class MarkupContextMenu {
menu.append(
new MenuItem({
label: INSPECTOR_L10N.getStr("inspectorCopyHTMLSubmenu.label"),
submenu: this._getCopySubmenu(markupContainer, isSelectionElement),
submenu: this._getCopySubmenu(
markupContainer,
isSelectionElement,
isFragment
),
})
);