Bug 1953415 - [devtools] Remove CM5 code related to the Column Breakpoints r=devtools-reviewers,ochameau
Differential Revision: https://phabricator.services.mozilla.com/D250291
This commit is contained in:
committed by
hmanilla@mozilla.com
parent
cd08e9afd6
commit
62ee3a82be
@@ -1,130 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { PureComponent } from "devtools/client/shared/vendor/react";
|
||||
import PropTypes from "devtools/client/shared/vendor/react-prop-types";
|
||||
|
||||
import { getDocument } from "../../utils/editor/index";
|
||||
const classnames = require("resource://devtools/client/shared/classnames.js");
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
|
||||
const breakpointButton = document.createElement("button");
|
||||
breakpointButton.innerHTML =
|
||||
'<svg viewBox="0 0 11 13" width="11" height="13"><path d="M5.07.5H1.5c-.54 0-1 .46-1 1v10c0 .54.46 1 1 1h3.57c.58 0 1.15-.26 1.53-.7l3.7-5.3-3.7-5.3C6.22.76 5.65.5 5.07.5z"/></svg>';
|
||||
|
||||
function makeBookmark({ breakpoint }, { onClick, onContextMenu }) {
|
||||
const bp = breakpointButton.cloneNode(true);
|
||||
|
||||
const isActive = breakpoint && !breakpoint.disabled;
|
||||
const isDisabled = breakpoint?.disabled;
|
||||
const condition = breakpoint?.options.condition;
|
||||
const logValue = breakpoint?.options.logValue;
|
||||
|
||||
bp.className = classnames("column-breakpoint", {
|
||||
"has-condition": condition,
|
||||
"has-log": logValue,
|
||||
active: isActive,
|
||||
disabled: isDisabled,
|
||||
});
|
||||
|
||||
bp.setAttribute("title", logValue || condition || "");
|
||||
bp.onclick = onClick;
|
||||
bp.oncontextmenu = onContextMenu;
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
export default class ColumnBreakpoint extends PureComponent {
|
||||
bookmark;
|
||||
|
||||
static get propTypes() {
|
||||
return {
|
||||
columnBreakpoint: PropTypes.object.isRequired,
|
||||
source: PropTypes.object.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
addColumnBreakpoint = nextProps => {
|
||||
const { columnBreakpoint, source } = nextProps || this.props;
|
||||
|
||||
const sourceId = source.id;
|
||||
const doc = getDocument(sourceId);
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { line, column } = columnBreakpoint.location;
|
||||
const widget = makeBookmark(columnBreakpoint, {
|
||||
onClick: this.onClick,
|
||||
onContextMenu: this.onContextMenu,
|
||||
});
|
||||
|
||||
this.bookmark = doc.setBookmark({ line: line - 1, ch: column }, { widget });
|
||||
};
|
||||
|
||||
clearColumnBreakpoint = () => {
|
||||
if (this.bookmark) {
|
||||
this.bookmark.clear();
|
||||
this.bookmark = null;
|
||||
}
|
||||
};
|
||||
|
||||
onClick = event => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
const {
|
||||
columnBreakpoint,
|
||||
toggleDisabledBreakpoint,
|
||||
removeBreakpoint,
|
||||
addBreakpoint,
|
||||
setSkipPausing,
|
||||
} = this.props;
|
||||
|
||||
// disable column breakpoint on shift-click.
|
||||
if (event.shiftKey) {
|
||||
toggleDisabledBreakpoint(columnBreakpoint.breakpoint);
|
||||
return;
|
||||
}
|
||||
|
||||
if (columnBreakpoint.breakpoint) {
|
||||
removeBreakpoint(columnBreakpoint.breakpoint);
|
||||
} else {
|
||||
setSkipPausing(false);
|
||||
addBreakpoint(columnBreakpoint.location);
|
||||
}
|
||||
};
|
||||
|
||||
onContextMenu = event => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
const {
|
||||
columnBreakpoint: { breakpoint, location },
|
||||
} = this.props;
|
||||
|
||||
if (breakpoint) {
|
||||
this.props.showEditorEditBreakpointContextMenu(event, breakpoint);
|
||||
} else {
|
||||
this.props.showEditorCreateBreakpointContextMenu(event, location);
|
||||
}
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.addColumnBreakpoint();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.clearColumnBreakpoint();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.clearColumnBreakpoint();
|
||||
this.addColumnBreakpoint();
|
||||
}
|
||||
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,11 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import React, { Component } from "devtools/client/shared/vendor/react";
|
||||
import { div } from "devtools/client/shared/vendor/react-dom-factories";
|
||||
import { Component } from "devtools/client/shared/vendor/react";
|
||||
import PropTypes from "devtools/client/shared/vendor/react-prop-types";
|
||||
|
||||
import { features } from "../../utils/prefs";
|
||||
const classnames = require("resource://devtools/client/shared/classnames.js");
|
||||
|
||||
import ColumnBreakpoint from "./ColumnBreakpoint";
|
||||
|
||||
import {
|
||||
getSelectedSource,
|
||||
visibleColumnBreakpoints,
|
||||
@@ -19,7 +15,6 @@ import {
|
||||
import actions from "../../actions/index";
|
||||
import { markerTypes } from "../../constants";
|
||||
import { connect } from "devtools/client/shared/vendor/react-redux";
|
||||
import { makeBreakpointId } from "../../utils/breakpoint/index";
|
||||
|
||||
const breakpointButton = document.createElement("button");
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
@@ -55,11 +50,6 @@ class ColumnBreakpoints extends Component {
|
||||
componentDidUpdate() {
|
||||
const { selectedSource, columnBreakpoints, editor } = this.props;
|
||||
|
||||
// Only for codemirror 6
|
||||
if (!features.codemirrorNext) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selectedSource || !editor) {
|
||||
return;
|
||||
}
|
||||
@@ -155,44 +145,7 @@ class ColumnBreakpoints extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
editor,
|
||||
columnBreakpoints,
|
||||
selectedSource,
|
||||
showEditorCreateBreakpointContextMenu,
|
||||
showEditorEditBreakpointContextMenu,
|
||||
toggleDisabledBreakpoint,
|
||||
removeBreakpoint,
|
||||
addBreakpoint,
|
||||
setSkipPausing,
|
||||
} = this.props;
|
||||
|
||||
if (features.codemirrorNext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!selectedSource || columnBreakpoints.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let breakpoints;
|
||||
editor.codeMirror.operation(() => {
|
||||
breakpoints = columnBreakpoints.map(columnBreakpoint =>
|
||||
React.createElement(ColumnBreakpoint, {
|
||||
key: makeBreakpointId(columnBreakpoint.location),
|
||||
columnBreakpoint,
|
||||
editor,
|
||||
source: selectedSource,
|
||||
showEditorCreateBreakpointContextMenu,
|
||||
showEditorEditBreakpointContextMenu,
|
||||
toggleDisabledBreakpoint,
|
||||
removeBreakpoint,
|
||||
addBreakpoint,
|
||||
setSkipPausing,
|
||||
})
|
||||
);
|
||||
});
|
||||
return div(null, breakpoints);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ DIRS += [
|
||||
CompiledModules(
|
||||
"BlackboxLines.js",
|
||||
"Breakpoints.js",
|
||||
"ColumnBreakpoint.js",
|
||||
"ColumnBreakpoints.js",
|
||||
"ConditionalPanel.js",
|
||||
"DebugLine.js",
|
||||
|
||||
@@ -14,25 +14,15 @@ import { getVisibleBreakpoints } from "./visibleBreakpoints";
|
||||
import { getSelectedLocation } from "../utils/selected-location";
|
||||
import { sortSelectedLocations } from "../utils/location";
|
||||
import { getLineText } from "../utils/source";
|
||||
import { features } from "../utils/prefs";
|
||||
|
||||
function contains(location, range) {
|
||||
if (features.codemirrorNext) {
|
||||
// If the location is within the viewport lines or if the location is on the first or last line
|
||||
// and the columns are within the start or end line content.
|
||||
return (
|
||||
(location.line > range.start.line && location.line < range.end.line) ||
|
||||
(location.line == range.start.line &&
|
||||
location.column >= range.start.column) ||
|
||||
(location.line == range.end.line && location.column <= range.end.column)
|
||||
);
|
||||
}
|
||||
// If the location is within the viewport lines or if the location is on the first or last line
|
||||
// and the columns are within the start or end line content.
|
||||
return (
|
||||
location.line >= range.start.line &&
|
||||
location.line <= range.end.line &&
|
||||
(!location.column ||
|
||||
(location.column >= range.start.column &&
|
||||
location.column <= range.end.column))
|
||||
(location.line > range.start.line && location.line < range.end.line) ||
|
||||
(location.line == range.start.line &&
|
||||
location.column >= range.start.column) ||
|
||||
(location.line == range.end.line && location.column <= range.end.column)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user