mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 09:49:14 +00:00
Bug 1458749 - Remove checks for old traits in the inspector. r=pbro
This commit is contained in:
parent
6829c469bc
commit
918eb925c8
@ -42,8 +42,6 @@ async function testTarget(client, target) {
|
||||
is(hasMethod, false,
|
||||
"target.actorHasMethod() returns false for undefined params");
|
||||
|
||||
is(target.getTrait("customHighlighters"), true,
|
||||
"target.getTrait() returns boolean when trait exists");
|
||||
is(target.getTrait("giddyup"), undefined,
|
||||
"target.getTrait() returns undefined when trait does not exist");
|
||||
|
||||
|
@ -62,13 +62,6 @@ exports.getHighlighterUtils = function(toolbox) {
|
||||
return target.client.traits.highlightable;
|
||||
};
|
||||
|
||||
/**
|
||||
* Does the target support custom highlighters.
|
||||
*/
|
||||
let supportsCustomHighlighters = exported.supportsCustomHighlighters = () => {
|
||||
return !!target.client.traits.customHighlighters;
|
||||
};
|
||||
|
||||
/**
|
||||
* Make a function that initializes the inspector before it runs.
|
||||
* Since the init of the inspector is asynchronous, the return value will be
|
||||
@ -303,11 +296,7 @@ exports.getHighlighterUtils = function(toolbox) {
|
||||
* @return a promise that resolves to the highlighter
|
||||
*/
|
||||
exported.getHighlighterByType = requireInspector(async function(typeName) {
|
||||
let highlighter = null;
|
||||
|
||||
if (supportsCustomHighlighters()) {
|
||||
highlighter = await toolbox.inspector.getHighlighterByType(typeName);
|
||||
}
|
||||
let highlighter = await toolbox.inspector.getHighlighterByType(typeName);
|
||||
|
||||
return highlighter || promise.reject("The target doesn't support " +
|
||||
`creating highlighters by types or ${typeName} is unknown`);
|
||||
|
@ -188,34 +188,16 @@ Inspector.prototype = {
|
||||
return this._toolbox.highlighter;
|
||||
},
|
||||
|
||||
get isOuterHTMLEditable() {
|
||||
return this._target.client.traits.editOuterHTML;
|
||||
},
|
||||
|
||||
get hasUrlToImageDataResolver() {
|
||||
return this._target.client.traits.urlToImageDataResolver;
|
||||
},
|
||||
|
||||
get canGetUniqueSelector() {
|
||||
return this._target.client.traits.getUniqueSelector;
|
||||
},
|
||||
|
||||
// Added in 53.
|
||||
get canGetCssPath() {
|
||||
return this._target.client.traits.getCssPath;
|
||||
},
|
||||
|
||||
// Added in 56.
|
||||
get canGetXPath() {
|
||||
return this._target.client.traits.getXPath;
|
||||
},
|
||||
|
||||
get canGetUsedFontFaces() {
|
||||
return this._target.client.traits.getUsedFontFaces;
|
||||
},
|
||||
|
||||
get canPasteInnerOrAdjacentHTML() {
|
||||
return this._target.client.traits.pasteHTML;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle promise rejections for various asynchronous actions, and only log errors if
|
||||
* the inspector panel still exists.
|
||||
@ -841,64 +823,60 @@ Inspector.prototype = {
|
||||
defaultTab == "computedview");
|
||||
}
|
||||
|
||||
if (this.target.form.animationsActor) {
|
||||
const animationTitle =
|
||||
INSPECTOR_L10N.getStr("inspector.sidebar.animationInspectorTitle");
|
||||
const animationTitle =
|
||||
INSPECTOR_L10N.getStr("inspector.sidebar.animationInspectorTitle");
|
||||
|
||||
if (Services.prefs.getBoolPref("devtools.new-animationinspector.enabled")) {
|
||||
const animationId = "newanimationinspector";
|
||||
if (Services.prefs.getBoolPref("devtools.new-animationinspector.enabled")) {
|
||||
const animationId = "newanimationinspector";
|
||||
|
||||
this.sidebar.addTab(
|
||||
animationId,
|
||||
animationTitle,
|
||||
{
|
||||
props: {
|
||||
id: animationId,
|
||||
title: animationTitle
|
||||
},
|
||||
panel: () => {
|
||||
const AnimationInspector =
|
||||
this.browserRequire("devtools/client/inspector/animation/animation");
|
||||
this.animationinspector = new AnimationInspector(this, this.panelWin);
|
||||
return this.animationinspector.provider;
|
||||
}
|
||||
},
|
||||
defaultTab == animationId);
|
||||
} else {
|
||||
this.sidebar.addFrameTab(
|
||||
"animationinspector",
|
||||
animationTitle,
|
||||
"chrome://devtools/content/inspector/animation-old/animation-inspector.xhtml",
|
||||
defaultTab == "animationinspector");
|
||||
}
|
||||
}
|
||||
|
||||
if (this.canGetUsedFontFaces) {
|
||||
// Inject a lazy loaded react tab by exposing a fake React object
|
||||
// with a lazy defined Tab thanks to `panel` being a function
|
||||
let fontId = "fontinspector";
|
||||
let fontTitle = INSPECTOR_L10N.getStr("inspector.sidebar.fontInspectorTitle");
|
||||
this.sidebar.addTab(
|
||||
fontId,
|
||||
fontTitle,
|
||||
animationId,
|
||||
animationTitle,
|
||||
{
|
||||
props: {
|
||||
id: fontId,
|
||||
title: fontTitle
|
||||
id: animationId,
|
||||
title: animationTitle
|
||||
},
|
||||
panel: () => {
|
||||
if (!this.fontinspector) {
|
||||
const FontInspector =
|
||||
this.browserRequire("devtools/client/inspector/fonts/fonts");
|
||||
this.fontinspector = new FontInspector(this, this.panelWin);
|
||||
}
|
||||
|
||||
return this.fontinspector.provider;
|
||||
const AnimationInspector =
|
||||
this.browserRequire("devtools/client/inspector/animation/animation");
|
||||
this.animationinspector = new AnimationInspector(this, this.panelWin);
|
||||
return this.animationinspector.provider;
|
||||
}
|
||||
},
|
||||
defaultTab == fontId);
|
||||
defaultTab == animationId);
|
||||
} else {
|
||||
this.sidebar.addFrameTab(
|
||||
"animationinspector",
|
||||
animationTitle,
|
||||
"chrome://devtools/content/inspector/animation-old/animation-inspector.xhtml",
|
||||
defaultTab == "animationinspector");
|
||||
}
|
||||
|
||||
// Inject a lazy loaded react tab by exposing a fake React object
|
||||
// with a lazy defined Tab thanks to `panel` being a function
|
||||
let fontId = "fontinspector";
|
||||
let fontTitle = INSPECTOR_L10N.getStr("inspector.sidebar.fontInspectorTitle");
|
||||
this.sidebar.addTab(
|
||||
fontId,
|
||||
fontTitle,
|
||||
{
|
||||
props: {
|
||||
id: fontId,
|
||||
title: fontTitle
|
||||
},
|
||||
panel: () => {
|
||||
if (!this.fontinspector) {
|
||||
const FontInspector =
|
||||
this.browserRequire("devtools/client/inspector/fonts/fonts");
|
||||
this.fontinspector = new FontInspector(this, this.panelWin);
|
||||
}
|
||||
|
||||
return this.fontinspector.provider;
|
||||
}
|
||||
},
|
||||
defaultTab == fontId);
|
||||
|
||||
// Persist splitter state in preferences.
|
||||
this.sidebar.on("show", this.onSidebarShown);
|
||||
this.sidebar.on("hide", this.onSidebarHidden);
|
||||
@ -1201,8 +1179,7 @@ Inspector.prototype = {
|
||||
|
||||
// On any new selection made by the user, store the unique css selector
|
||||
// of the selected node so it can be restored after reload of the same page
|
||||
if (this.canGetUniqueSelector &&
|
||||
this.selection.isElementNode()) {
|
||||
if (this.selection.isElementNode()) {
|
||||
selection.getUniqueSelector().then(selector => {
|
||||
this.selectionCssSelector = selector;
|
||||
}, this._handleRejectionIfNotDestroyed);
|
||||
@ -1420,7 +1397,6 @@ Inspector.prototype = {
|
||||
!this.selection.isAnonymousNode() &&
|
||||
!this.selection.isRoot();
|
||||
let isScreenshotable = isSelectionElement &&
|
||||
this.canGetUniqueSelector &&
|
||||
this.selection.nodeFront.isTreeDisplayed;
|
||||
|
||||
let menu = new Menu();
|
||||
@ -1428,7 +1404,7 @@ Inspector.prototype = {
|
||||
id: "node-menu-edithtml",
|
||||
label: INSPECTOR_L10N.getStr("inspectorHTMLEdit.label"),
|
||||
accesskey: INSPECTOR_L10N.getStr("inspectorHTMLEdit.accesskey"),
|
||||
disabled: !isEditableElement || !this.isOuterHTMLEditable,
|
||||
disabled: !isEditableElement,
|
||||
click: () => this.editHTML(),
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
@ -1616,7 +1592,6 @@ Inspector.prototype = {
|
||||
accesskey:
|
||||
INSPECTOR_L10N.getStr("inspectorCopyCSSSelector.accesskey"),
|
||||
disabled: !isSelectionElement,
|
||||
hidden: !this.canGetUniqueSelector,
|
||||
click: () => this.copyUniqueSelector(),
|
||||
}));
|
||||
copySubmenu.append(new MenuItem({
|
||||
@ -1650,26 +1625,24 @@ Inspector.prototype = {
|
||||
|
||||
_getPasteSubmenu: function(isEditableElement) {
|
||||
let isPasteable = isEditableElement && this._getClipboardContentForPaste();
|
||||
let disableAdjacentPaste = !isPasteable ||
|
||||
!this.canPasteInnerOrAdjacentHTML || this.selection.isRoot() ||
|
||||
let disableAdjacentPaste = !isPasteable || this.selection.isRoot() ||
|
||||
this.selection.isBodyNode() || this.selection.isHeadNode();
|
||||
let disableFirstLastPaste = !isPasteable ||
|
||||
!this.canPasteInnerOrAdjacentHTML || (this.selection.isHTMLNode() &&
|
||||
this.selection.isRoot());
|
||||
(this.selection.isHTMLNode() && this.selection.isRoot());
|
||||
|
||||
let pasteSubmenu = new Menu();
|
||||
pasteSubmenu.append(new MenuItem({
|
||||
id: "node-menu-pasteinnerhtml",
|
||||
label: INSPECTOR_L10N.getStr("inspectorPasteInnerHTML.label"),
|
||||
accesskey: INSPECTOR_L10N.getStr("inspectorPasteInnerHTML.accesskey"),
|
||||
disabled: !isPasteable || !this.canPasteInnerOrAdjacentHTML,
|
||||
disabled: !isPasteable,
|
||||
click: () => this.pasteInnerHTML(),
|
||||
}));
|
||||
pasteSubmenu.append(new MenuItem({
|
||||
id: "node-menu-pasteouterhtml",
|
||||
label: INSPECTOR_L10N.getStr("inspectorPasteOuterHTML.label"),
|
||||
accesskey: INSPECTOR_L10N.getStr("inspectorPasteOuterHTML.accesskey"),
|
||||
disabled: !isPasteable || !this.isOuterHTMLEditable,
|
||||
disabled: !isPasteable,
|
||||
click: () => this.pasteOuterHTML(),
|
||||
}));
|
||||
pasteSubmenu.append(new MenuItem({
|
||||
|
@ -239,16 +239,12 @@ CssRuleView.prototype = {
|
||||
return null;
|
||||
}
|
||||
|
||||
let utils = this.inspector.toolbox.highlighterUtils;
|
||||
if (!utils.supportsCustomHighlighters()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.selectorHighlighter) {
|
||||
return this.selectorHighlighter;
|
||||
}
|
||||
|
||||
try {
|
||||
let utils = this.inspector.toolbox.highlighterUtils;
|
||||
let h = await utils.getHighlighterByType("SelectorHighlighter");
|
||||
this.selectorHighlighter = h;
|
||||
return h;
|
||||
@ -545,13 +541,8 @@ CssRuleView.prototype = {
|
||||
_onAddRule: function() {
|
||||
let elementStyle = this._elementStyle;
|
||||
let element = elementStyle.element;
|
||||
let client = this.inspector.target.client;
|
||||
let pseudoClasses = element.pseudoClassLocks;
|
||||
|
||||
if (!client.traits.addNewRule) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.pageStyle.supportsAuthoredStyles) {
|
||||
// We're talking to an old server.
|
||||
this._onAddNewRuleNonAuthored();
|
||||
|
@ -48,9 +48,6 @@ class HighlightersOverlay {
|
||||
this.highlighterUtils = this.inspector.toolbox.highlighterUtils;
|
||||
this.store = this.inspector.store;
|
||||
|
||||
// Only initialize the overlay if at least one of the highlighter types is supported.
|
||||
this.supportsHighlighters = this.highlighterUtils.supportsCustomHighlighters();
|
||||
|
||||
// NodeFront of the flexbox container that is highlighted.
|
||||
this.flexboxHighlighterShown = null;
|
||||
// NodeFront of element that is highlighted by the geometry editor.
|
||||
@ -112,10 +109,6 @@ class HighlightersOverlay {
|
||||
* Either the rule-view or computed-view panel to add the highlighters overlay.
|
||||
*/
|
||||
addToView(view) {
|
||||
if (!this.supportsHighlighters) {
|
||||
return;
|
||||
}
|
||||
|
||||
let el = view.element;
|
||||
el.addEventListener("click", this.onClick, true);
|
||||
el.addEventListener("mousemove", this.onMouseMove);
|
||||
@ -132,10 +125,6 @@ class HighlightersOverlay {
|
||||
* overlay.
|
||||
*/
|
||||
removeFromView(view) {
|
||||
if (!this.supportsHighlighters) {
|
||||
return;
|
||||
}
|
||||
|
||||
let el = view.element;
|
||||
el.removeEventListener("click", this.onClick, true);
|
||||
el.removeEventListener("mousemove", this.onMouseMove);
|
||||
@ -994,7 +983,6 @@ class HighlightersOverlay {
|
||||
|
||||
this.inspector = null;
|
||||
this.highlighterUtils = null;
|
||||
this.supportsHighlighters = null;
|
||||
this.state = null;
|
||||
this.store = null;
|
||||
|
||||
|
@ -162,11 +162,9 @@ TooltipsOverlay.prototype = {
|
||||
*/
|
||||
_getTooltipType: function({type, value: prop}) {
|
||||
let tooltipType = null;
|
||||
let inspector = this.view.inspector;
|
||||
|
||||
// Image preview tooltip
|
||||
if (type === VIEW_NODE_IMAGE_URL_TYPE &&
|
||||
inspector.hasUrlToImageDataResolver) {
|
||||
if (type === VIEW_NODE_IMAGE_URL_TYPE) {
|
||||
tooltipType = TOOLTIP_IMAGE_TYPE;
|
||||
}
|
||||
|
||||
|
@ -128,17 +128,16 @@ StyleEditorUI.prototype = {
|
||||
this._walker = toolbox.walker;
|
||||
|
||||
let hUtils = toolbox.highlighterUtils;
|
||||
if (hUtils.supportsCustomHighlighters()) {
|
||||
try {
|
||||
this._highlighter =
|
||||
await hUtils.getHighlighterByType(SELECTOR_HIGHLIGHTER_TYPE);
|
||||
} catch (e) {
|
||||
// The selectorHighlighter can't always be instantiated, for example
|
||||
// it doesn't work with XUL windows (until bug 1094959 gets fixed);
|
||||
// or the selectorHighlighter doesn't exist on the backend.
|
||||
console.warn("The selectorHighlighter couldn't be instantiated, " +
|
||||
"elements matching hovered selectors will not be highlighted");
|
||||
}
|
||||
|
||||
try {
|
||||
this._highlighter =
|
||||
await hUtils.getHighlighterByType(SELECTOR_HIGHLIGHTER_TYPE);
|
||||
} catch (e) {
|
||||
// The selectorHighlighter can't always be instantiated, for example
|
||||
// it doesn't work with XUL windows (until bug 1094959 gets fixed);
|
||||
// or the selectorHighlighter doesn't exist on the backend.
|
||||
console.warn("The selectorHighlighter couldn't be instantiated, " +
|
||||
"elements matching hovered selectors will not be highlighted");
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -112,21 +112,9 @@ RootActor.prototype = {
|
||||
|
||||
traits: {
|
||||
sources: true,
|
||||
// Whether the inspector actor allows modifying outer HTML.
|
||||
editOuterHTML: true,
|
||||
// Whether the inspector actor allows modifying innerHTML and inserting
|
||||
// adjacent HTML.
|
||||
pasteHTML: true,
|
||||
// Whether the server-side highlighter actor exists and can be used to
|
||||
// remotely highlight nodes (see server/actors/highlighters.js)
|
||||
highlightable: true,
|
||||
// Which custom highlighter does the server-side highlighter actor supports?
|
||||
// (see server/actors/highlighters.js)
|
||||
customHighlighters: true,
|
||||
// Whether the inspector actor implements the getImageDataFromURL
|
||||
// method that returns data-uris for image URLs. This is used for image
|
||||
// tooltips for instance
|
||||
urlToImageDataResolver: true,
|
||||
networkMonitor: true,
|
||||
// Whether the storage inspector actor to inspect cookies, etc.
|
||||
storageInspector: true,
|
||||
@ -143,14 +131,9 @@ RootActor.prototype = {
|
||||
// Whether the style rule actor implements the modifySelector method
|
||||
// that modifies the rule's selector
|
||||
selectorEditable: true,
|
||||
// Whether the page style actor implements the addNewRule method that
|
||||
// adds new rules to the page
|
||||
addNewRule: true,
|
||||
// Whether the dom node actor implements the getUniqueSelector method
|
||||
getUniqueSelector: true,
|
||||
// Whether the dom node actor implements the getCssPath method
|
||||
// Whether the dom node actor implements the getCssPath method. Added in 53.
|
||||
getCssPath: true,
|
||||
// Whether the dom node actor implements the getXPath method
|
||||
// Whether the dom node actor implements the getXPath method. Added in 56.
|
||||
getXPath: true,
|
||||
// Whether the director scripts are supported
|
||||
directorScripts: true,
|
||||
@ -158,9 +141,6 @@ RootActor.prototype = {
|
||||
// blackboxing/pretty-printing (not supported in Fever Dream yet)
|
||||
noBlackBoxing: false,
|
||||
noPrettyPrinting: false,
|
||||
// Whether the page style actor implements the getUsedFontFaces method
|
||||
// that returns the font faces used on a node
|
||||
getUsedFontFaces: true,
|
||||
// Trait added in Gecko 38, indicating that all features necessary for
|
||||
// grabbing allocations from the MemoryActor are available for the performance tool
|
||||
memoryActorAllocations: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user