Backed out changeset 183b9d08d264 (Bug 1297100) reverting feature r=gl

This commit is contained in:
Gabriel Luong 2016-10-20 23:31:02 -07:00
Родитель e50268f472
Коммит 235258f136
2 изменённых файлов: 11 добавлений и 74 удалений

Просмотреть файл

@ -4,10 +4,8 @@
"use strict";
const { Cu } = require("chrome");
const { extend } = require("sdk/core/heritage");
const { AutoRefreshHighlighter } = require("./auto-refresh");
const { CssGridHighlighter } = require("./css-grid");
const {
CanvasFrameAnonymousContentHelper,
createNode,
@ -20,7 +18,6 @@ const {
const { setIgnoreLayoutChanges } = require("devtools/shared/layout/utils");
const inspector = require("devtools/server/actors/inspector");
const nodeConstants = require("devtools/shared/dom-node-constants");
const Services = require("Services");
// Note that the order of items in this array is important because it is used
// for drawing the BoxModelHighlighter's path elements correctly.
@ -31,8 +28,6 @@ const GUIDE_STROKE_WIDTH = 1;
// FIXME: add ":visited" and ":link" after bug 713106 is fixed
const PSEUDO_CLASSES = [":hover", ":active", ":focus"];
const GRID_ENABLED_PREF = "layout.css.grid.enabled";
/**
* The BoxModelHighlighter draws the box model regions on top of a node.
* If the node is a block box, then each region will be displayed as 1 polygon.
@ -97,10 +92,6 @@ const GRID_ENABLED_PREF = "layout.css.grid.enabled";
function BoxModelHighlighter(highlighterEnv) {
AutoRefreshHighlighter.call(this, highlighterEnv);
if (Services.prefs.getBoolPref(GRID_ENABLED_PREF)) {
this.cssGridHighlighter = new CssGridHighlighter(this.highlighterEnv);
}
this.markup = new CanvasFrameAnonymousContentHelper(this.highlighterEnv,
this._buildMarkup.bind(this));
@ -263,11 +254,6 @@ BoxModelHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
destroy: function () {
AutoRefreshHighlighter.prototype.destroy.call(this);
this.markup.destroy();
if (this.cssGridHighlighter) {
this.cssGridHighlighter.destroy();
this.cssGridHighlighter = null;
}
},
getElement: function (id) {
@ -292,28 +278,6 @@ BoxModelHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
this.options.region = "content";
}
// Show the CSS grid highlighter if the current node is a grid container or grid item.
if (this.cssGridHighlighter) {
this.cssGridHighlighter.hide();
let gridNode;
if (this.currentNode &&
this.currentNode.getGridFragments &&
this.currentNode.getGridFragments().length) {
gridNode = this.currentNode;
} else if (this.currentNode.parentNode &&
this.currentNode.parentNode.getGridFragments &&
this.currentNode.parentNode.getGridFragments().length) {
gridNode = this.currentNode.parentNode;
}
if (gridNode) {
// Display the grid highlighter for the grid container and
// hide the box model guides.
this.cssGridHighlighter.show(gridNode);
this.options.hideGuides = true;
}
}
let shown = this._update();
this._trackMutations();
this.emit("ready");
@ -380,10 +344,6 @@ BoxModelHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
this._hideBoxModel();
this._hideInfobar();
if (this.cssGridHighlighter) {
this.cssGridHighlighter.hide();
}
setIgnoreLayoutChanges(false, this.currentNode.ownerDocument.documentElement);
},

Просмотреть файл

@ -4,7 +4,6 @@
"use strict";
const { Cu } = require("chrome");
const { extend } = require("sdk/core/heritage");
const { AutoRefreshHighlighter } = require("./auto-refresh");
const {
@ -46,11 +45,7 @@ const GRID_GAP_PATTERN_STROKE_STYLE = "#9370DB";
/**
* Cached used by `CssGridHighlighter.getGridGapPattern`.
*/
const gCachedGridPattern = new WeakMap();
// WeakMap key for the Row grid pattern.
const ROW_KEY = {};
// WeakMap key for the Column grid pattern.
const COLUMN_KEY = {};
const gCachedGridPattern = new Map();
/**
* The CssGridHighlighter is the class that overlays a visual grid on top of
@ -98,9 +93,6 @@ function CssGridHighlighter(highlighterEnv) {
this.markup = new CanvasFrameAnonymousContentHelper(this.highlighterEnv,
this._buildMarkup.bind(this));
this.onNavigate = this.onNavigate.bind(this);
this.highlighterEnv.on("navigate", this.onNavigate);
}
CssGridHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
@ -211,9 +203,9 @@ CssGridHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
},
destroy() {
this.highlighterEnv.off("navigate", this.onNavigate);
this.markup.destroy();
AutoRefreshHighlighter.prototype.destroy.call(this);
this.markup.destroy();
gCachedGridPattern.clear();
},
getElement(id) {
@ -231,14 +223,13 @@ CssGridHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
/**
* Gets the grid gap pattern used to render the gap regions.
*
* @param {Object} dimension
* Refers to the WeakMap key for the grid dimension type which is either the
* constant COLUMN or ROW.
* @param {String} dimensionType
* The grid dimension type which is either the constant COLUMNS or ROWS.
* @return {CanvasPattern} grid gap pattern.
*/
getGridGapPattern(dimension) {
if (gCachedGridPattern.has(dimension)) {
return gCachedGridPattern.get(dimension);
getGridGapPattern(dimensionType) {
if (gCachedGridPattern.has(dimensionType)) {
return gCachedGridPattern.get(dimensionType);
}
// Create the diagonal lines pattern for the rendering the grid gaps.
@ -251,7 +242,7 @@ CssGridHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
ctx.beginPath();
ctx.translate(.5, .5);
if (dimension === COLUMN_KEY) {
if (dimensionType === COLUMNS) {
ctx.moveTo(0, 0);
ctx.lineTo(GRID_GAP_PATTERN_WIDTH, GRID_GAP_PATTERN_HEIGHT);
} else {
@ -263,19 +254,10 @@ CssGridHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
ctx.stroke();
let pattern = ctx.createPattern(canvas, "repeat");
gCachedGridPattern.set(dimension, pattern);
gCachedGridPattern.set(dimensionType, pattern);
return pattern;
},
/**
* Called when the page navigates. Used to clear the cached gap patterns and avoid
* using DeadWrapper objects as gap patterns the next time.
*/
onNavigate() {
gCachedGridPattern.delete(ROW_KEY);
gCachedGridPattern.delete(COLUMN_KEY);
},
_show() {
if (Services.prefs.getBoolPref(CSS_GRID_ENABLED_PREF) && !this.isGrid()) {
this.hide();
@ -620,12 +602,11 @@ CssGridHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
*/
renderGridGap(linePos, startPos, endPos, breadth, dimensionType) {
this.ctx.save();
this.ctx.fillStyle = this.getGridGapPattern(dimensionType);
if (dimensionType === COLUMNS) {
this.ctx.fillStyle = this.getGridGapPattern(COLUMN_KEY);
this.ctx.fillRect(linePos, startPos, breadth, endPos - startPos);
} else {
this.ctx.fillStyle = this.getGridGapPattern(ROW_KEY);
this.ctx.fillRect(startPos, linePos, endPos - startPos, breadth);
}
@ -729,10 +710,6 @@ exports.CssGridHighlighter = CssGridHighlighter;
* @return {String} representation of the CSS grid fragment data.
*/
function stringifyGridFragments(fragments = []) {
if (fragments[0] && Cu.isDeadWrapper(fragments[0])) {
return {};
}
return JSON.stringify(fragments.map(getStringifiableFragment));
}