Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/CSSShadowEditor.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/CSSShadowEditor.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/CSSShadowEditor.js b/third_party/WebKit/Source/devtools/front_end/ui/CSSShadowEditor.js
index d0f625f84e936307a726e573f9aa2d614a6db564..f9c613156d353dd55138c9d76def800429e57e12 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/CSSShadowEditor.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/CSSShadowEditor.js
@@ -4,42 +4,42 @@
/**
* @unrestricted
*/
-WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
+UI.CSSShadowEditor = class extends UI.VBox {
constructor() {
super(true);
this.registerRequiredCSS('ui/cssShadowEditor.css');
this.contentElement.tabIndex = 0;
this._typeField = this.contentElement.createChild('div', 'shadow-editor-field');
- this._typeField.createChild('label', 'shadow-editor-label').textContent = WebInspector.UIString('Type');
+ this._typeField.createChild('label', 'shadow-editor-label').textContent = Common.UIString('Type');
this._outsetButton = this._typeField.createChild('button', 'shadow-editor-button-left');
- this._outsetButton.textContent = WebInspector.UIString('Outset');
+ this._outsetButton.textContent = Common.UIString('Outset');
this._outsetButton.addEventListener('click', this._onButtonClick.bind(this), false);
this._insetButton = this._typeField.createChild('button', 'shadow-editor-button-right');
- this._insetButton.textContent = WebInspector.UIString('Inset');
+ this._insetButton.textContent = Common.UIString('Inset');
this._insetButton.addEventListener('click', this._onButtonClick.bind(this), false);
var xField = this.contentElement.createChild('div', 'shadow-editor-field');
- this._xInput = this._createTextInput(xField, WebInspector.UIString('X offset'));
+ this._xInput = this._createTextInput(xField, Common.UIString('X offset'));
var yField = this.contentElement.createChild('div', 'shadow-editor-field');
- this._yInput = this._createTextInput(yField, WebInspector.UIString('Y offset'));
+ this._yInput = this._createTextInput(yField, Common.UIString('Y offset'));
this._xySlider = xField.createChild('canvas', 'shadow-editor-2D-slider');
- this._xySlider.width = WebInspector.CSSShadowEditor.canvasSize;
- this._xySlider.height = WebInspector.CSSShadowEditor.canvasSize;
+ this._xySlider.width = UI.CSSShadowEditor.canvasSize;
+ this._xySlider.height = UI.CSSShadowEditor.canvasSize;
this._xySlider.tabIndex = -1;
- this._halfCanvasSize = WebInspector.CSSShadowEditor.canvasSize / 2;
- this._innerCanvasSize = this._halfCanvasSize - WebInspector.CSSShadowEditor.sliderThumbRadius;
- WebInspector.installDragHandle(
+ this._halfCanvasSize = UI.CSSShadowEditor.canvasSize / 2;
+ this._innerCanvasSize = this._halfCanvasSize - UI.CSSShadowEditor.sliderThumbRadius;
+ UI.installDragHandle(
this._xySlider, this._dragStart.bind(this), this._dragMove.bind(this), null, 'default');
this._xySlider.addEventListener('keydown', this._onCanvasArrowKey.bind(this), false);
this._xySlider.addEventListener('blur', this._onCanvasBlur.bind(this), false);
var blurField = this.contentElement.createChild('div', 'shadow-editor-blur-field');
- this._blurInput = this._createTextInput(blurField, WebInspector.UIString('Blur'));
+ this._blurInput = this._createTextInput(blurField, Common.UIString('Blur'));
this._blurSlider = this._createSlider(blurField);
this._spreadField = this.contentElement.createChild('div', 'shadow-editor-field');
- this._spreadInput = this._createTextInput(this._spreadField, WebInspector.UIString('Spread'));
+ this._spreadInput = this._createTextInput(this._spreadField, Common.UIString('Spread'));
this._spreadSlider = this._createSlider(this._spreadField);
}
@@ -67,7 +67,7 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
* @return {!Element}
*/
_createSlider(field) {
- var slider = createSliderLabel(0, WebInspector.CSSShadowEditor.maxRange, -1);
+ var slider = createSliderLabel(0, UI.CSSShadowEditor.maxRange, -1);
slider.addEventListener('input', this._onSliderInput.bind(this), false);
field.appendChild(slider);
return slider;
@@ -81,7 +81,7 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
}
/**
- * @param {!WebInspector.CSSShadowModel} model
+ * @param {!Common.CSSShadowModel} model
*/
setModel(model) {
this._model = model;
@@ -119,9 +119,9 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
context.strokeStyle = 'rgba(210, 210, 210, 0.8)';
context.beginPath();
context.moveTo(this._halfCanvasSize, 0);
- context.lineTo(this._halfCanvasSize, WebInspector.CSSShadowEditor.canvasSize);
+ context.lineTo(this._halfCanvasSize, UI.CSSShadowEditor.canvasSize);
context.moveTo(0, this._halfCanvasSize);
- context.lineTo(WebInspector.CSSShadowEditor.canvasSize, this._halfCanvasSize);
+ context.lineTo(UI.CSSShadowEditor.canvasSize, this._halfCanvasSize);
context.stroke();
context.restore();
@@ -139,12 +139,12 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
if (drawFocus) {
context.beginPath();
context.fillStyle = 'rgba(66, 133, 244, 0.4)';
- context.arc(thumbPoint.x, thumbPoint.y, WebInspector.CSSShadowEditor.sliderThumbRadius + 2, 0, 2 * Math.PI);
+ context.arc(thumbPoint.x, thumbPoint.y, UI.CSSShadowEditor.sliderThumbRadius + 2, 0, 2 * Math.PI);
context.fill();
}
context.beginPath();
context.fillStyle = '#4285F4';
- context.arc(thumbPoint.x, thumbPoint.y, WebInspector.CSSShadowEditor.sliderThumbRadius, 0, 2 * Math.PI);
+ context.arc(thumbPoint.x, thumbPoint.y, UI.CSSShadowEditor.sliderThumbRadius, 0, 2 * Math.PI);
context.fill();
context.restore();
}
@@ -158,17 +158,17 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
return;
this._model.setInset(insetClicked);
this._updateButtons();
- this.dispatchEventToListeners(WebInspector.CSSShadowEditor.Events.ShadowChanged, this._model);
+ this.dispatchEventToListeners(UI.CSSShadowEditor.Events.ShadowChanged, this._model);
}
/**
* @param {!Event} event
*/
_handleValueModification(event) {
- var modifiedValue = WebInspector.createReplacementString(event.currentTarget.value, event, customNumberHandler);
+ var modifiedValue = UI.createReplacementString(event.currentTarget.value, event, customNumberHandler);
if (!modifiedValue)
return;
- var length = WebInspector.CSSLength.parse(modifiedValue);
+ var length = Common.CSSLength.parse(modifiedValue);
if (!length)
return;
if (event.currentTarget === this._blurInput && length.amount < 0)
@@ -187,7 +187,7 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
*/
function customNumberHandler(prefix, number, suffix) {
if (!suffix.length)
- suffix = WebInspector.CSSShadowEditor.defaultUnit;
+ suffix = UI.CSSShadowEditor.defaultUnit;
return prefix + number + suffix;
}
}
@@ -198,7 +198,7 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
_onTextInput(event) {
this._changedElement = event.currentTarget;
this._changedElement.classList.remove('invalid');
- var length = WebInspector.CSSLength.parse(event.currentTarget.value);
+ var length = Common.CSSLength.parse(event.currentTarget.value);
if (!length || event.currentTarget === this._blurInput && length.amount < 0)
return;
if (event.currentTarget === this._xInput) {
@@ -214,16 +214,16 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
this._model.setSpreadRadius(length);
this._spreadSlider.value = length.amount;
}
- this.dispatchEventToListeners(WebInspector.CSSShadowEditor.Events.ShadowChanged, this._model);
+ this.dispatchEventToListeners(UI.CSSShadowEditor.Events.ShadowChanged, this._model);
}
_onTextBlur() {
if (!this._changedElement)
return;
- var length = !this._changedElement.value.trim() ? WebInspector.CSSLength.zero() :
- WebInspector.CSSLength.parse(this._changedElement.value);
+ var length = !this._changedElement.value.trim() ? Common.CSSLength.zero() :
+ Common.CSSLength.parse(this._changedElement.value);
if (!length)
- length = WebInspector.CSSLength.parse(this._changedElement.value + WebInspector.CSSShadowEditor.defaultUnit);
+ length = Common.CSSLength.parse(this._changedElement.value + UI.CSSShadowEditor.defaultUnit);
if (!length) {
this._changedElement.classList.add('invalid');
this._changedElement = null;
@@ -239,7 +239,7 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
this._updateCanvas(false);
} else if (this._changedElement === this._blurInput) {
if (length.amount < 0)
- length = WebInspector.CSSLength.zero();
+ length = Common.CSSLength.zero();
this._model.setBlurRadius(length);
this._blurInput.value = length.asCSSText();
this._blurSlider.value = length.amount;
@@ -249,7 +249,7 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
this._spreadSlider.value = length.amount;
}
this._changedElement = null;
- this.dispatchEventToListeners(WebInspector.CSSShadowEditor.Events.ShadowChanged, this._model);
+ this.dispatchEventToListeners(UI.CSSShadowEditor.Events.ShadowChanged, this._model);
}
/**
@@ -257,17 +257,17 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
*/
_onSliderInput(event) {
if (event.currentTarget === this._blurSlider) {
- this._model.setBlurRadius(new WebInspector.CSSLength(
- this._blurSlider.value, this._model.blurRadius().unit || WebInspector.CSSShadowEditor.defaultUnit));
+ this._model.setBlurRadius(new Common.CSSLength(
+ this._blurSlider.value, this._model.blurRadius().unit || UI.CSSShadowEditor.defaultUnit));
this._blurInput.value = this._model.blurRadius().asCSSText();
this._blurInput.classList.remove('invalid');
} else if (event.currentTarget === this._spreadSlider) {
- this._model.setSpreadRadius(new WebInspector.CSSLength(
- this._spreadSlider.value, this._model.spreadRadius().unit || WebInspector.CSSShadowEditor.defaultUnit));
+ this._model.setSpreadRadius(new Common.CSSLength(
+ this._spreadSlider.value, this._model.spreadRadius().unit || UI.CSSShadowEditor.defaultUnit));
this._spreadInput.value = this._model.spreadRadius().asCSSText();
this._spreadInput.classList.remove('invalid');
}
- this.dispatchEventToListeners(WebInspector.CSSShadowEditor.Events.ShadowChanged, this._model);
+ this.dispatchEventToListeners(UI.CSSShadowEditor.Events.ShadowChanged, this._model);
}
/**
@@ -277,12 +277,12 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
_dragStart(event) {
this._xySlider.focus();
this._updateCanvas(true);
- this._canvasOrigin = new WebInspector.Geometry.Point(
+ this._canvasOrigin = new Common.Geometry.Point(
this._xySlider.totalOffsetLeft() + this._halfCanvasSize,
this._xySlider.totalOffsetTop() + this._halfCanvasSize);
- var clickedPoint = new WebInspector.Geometry.Point(event.x - this._canvasOrigin.x, event.y - this._canvasOrigin.y);
+ var clickedPoint = new Common.Geometry.Point(event.x - this._canvasOrigin.x, event.y - this._canvasOrigin.y);
var thumbPoint = this._sliderThumbPosition();
- if (clickedPoint.distanceTo(thumbPoint) >= WebInspector.CSSShadowEditor.sliderThumbRadius)
+ if (clickedPoint.distanceTo(thumbPoint) >= UI.CSSShadowEditor.sliderThumbRadius)
this._dragMove(event);
return true;
}
@@ -291,32 +291,32 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
* @param {!MouseEvent} event
*/
_dragMove(event) {
- var point = new WebInspector.Geometry.Point(event.x - this._canvasOrigin.x, event.y - this._canvasOrigin.y);
+ var point = new Common.Geometry.Point(event.x - this._canvasOrigin.x, event.y - this._canvasOrigin.y);
if (event.shiftKey)
point = this._snapToClosestDirection(point);
var constrainedPoint = this._constrainPoint(point, this._innerCanvasSize);
- var newX = Math.round((constrainedPoint.x / this._innerCanvasSize) * WebInspector.CSSShadowEditor.maxRange);
- var newY = Math.round((constrainedPoint.y / this._innerCanvasSize) * WebInspector.CSSShadowEditor.maxRange);
+ var newX = Math.round((constrainedPoint.x / this._innerCanvasSize) * UI.CSSShadowEditor.maxRange);
+ var newY = Math.round((constrainedPoint.y / this._innerCanvasSize) * UI.CSSShadowEditor.maxRange);
if (event.shiftKey) {
this._model.setOffsetX(
- new WebInspector.CSSLength(newX, this._model.offsetX().unit || WebInspector.CSSShadowEditor.defaultUnit));
+ new Common.CSSLength(newX, this._model.offsetX().unit || UI.CSSShadowEditor.defaultUnit));
this._model.setOffsetY(
- new WebInspector.CSSLength(newY, this._model.offsetY().unit || WebInspector.CSSShadowEditor.defaultUnit));
+ new Common.CSSLength(newY, this._model.offsetY().unit || UI.CSSShadowEditor.defaultUnit));
} else {
if (!event.altKey)
this._model.setOffsetX(
- new WebInspector.CSSLength(newX, this._model.offsetX().unit || WebInspector.CSSShadowEditor.defaultUnit));
- if (!WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event))
+ new Common.CSSLength(newX, this._model.offsetX().unit || UI.CSSShadowEditor.defaultUnit));
+ if (!UI.KeyboardShortcut.eventHasCtrlOrMeta(event))
this._model.setOffsetY(
- new WebInspector.CSSLength(newY, this._model.offsetY().unit || WebInspector.CSSShadowEditor.defaultUnit));
+ new Common.CSSLength(newY, this._model.offsetY().unit || UI.CSSShadowEditor.defaultUnit));
}
this._xInput.value = this._model.offsetX().asCSSText();
this._yInput.value = this._model.offsetY().asCSSText();
this._xInput.classList.remove('invalid');
this._yInput.classList.remove('invalid');
this._updateCanvas(true);
- this.dispatchEventToListeners(WebInspector.CSSShadowEditor.Events.ShadowChanged, this._model);
+ this.dispatchEventToListeners(UI.CSSShadowEditor.Events.ShadowChanged, this._model);
}
_onCanvasBlur() {
@@ -345,53 +345,53 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
if (shiftX) {
var offsetX = this._model.offsetX();
var newAmount = Number.constrain(
- offsetX.amount + shiftX, -WebInspector.CSSShadowEditor.maxRange, WebInspector.CSSShadowEditor.maxRange);
+ offsetX.amount + shiftX, -UI.CSSShadowEditor.maxRange, UI.CSSShadowEditor.maxRange);
if (newAmount === offsetX.amount)
return;
this._model.setOffsetX(
- new WebInspector.CSSLength(newAmount, offsetX.unit || WebInspector.CSSShadowEditor.defaultUnit));
+ new Common.CSSLength(newAmount, offsetX.unit || UI.CSSShadowEditor.defaultUnit));
this._xInput.value = this._model.offsetX().asCSSText();
this._xInput.classList.remove('invalid');
}
if (shiftY) {
var offsetY = this._model.offsetY();
var newAmount = Number.constrain(
- offsetY.amount + shiftY, -WebInspector.CSSShadowEditor.maxRange, WebInspector.CSSShadowEditor.maxRange);
+ offsetY.amount + shiftY, -UI.CSSShadowEditor.maxRange, UI.CSSShadowEditor.maxRange);
if (newAmount === offsetY.amount)
return;
this._model.setOffsetY(
- new WebInspector.CSSLength(newAmount, offsetY.unit || WebInspector.CSSShadowEditor.defaultUnit));
+ new Common.CSSLength(newAmount, offsetY.unit || UI.CSSShadowEditor.defaultUnit));
this._yInput.value = this._model.offsetY().asCSSText();
this._yInput.classList.remove('invalid');
}
this._updateCanvas(true);
- this.dispatchEventToListeners(WebInspector.CSSShadowEditor.Events.ShadowChanged, this._model);
+ this.dispatchEventToListeners(UI.CSSShadowEditor.Events.ShadowChanged, this._model);
}
/**
- * @param {!WebInspector.Geometry.Point} point
+ * @param {!Common.Geometry.Point} point
* @param {number} max
- * @return {!WebInspector.Geometry.Point}
+ * @return {!Common.Geometry.Point}
*/
_constrainPoint(point, max) {
if (Math.abs(point.x) <= max && Math.abs(point.y) <= max)
- return new WebInspector.Geometry.Point(point.x, point.y);
+ return new Common.Geometry.Point(point.x, point.y);
return point.scale(max / Math.max(Math.abs(point.x), Math.abs(point.y)));
}
/**
- * @param {!WebInspector.Geometry.Point} point
- * @return {!WebInspector.Geometry.Point}
+ * @param {!Common.Geometry.Point} point
+ * @return {!Common.Geometry.Point}
*/
_snapToClosestDirection(point) {
var minDistance = Number.MAX_VALUE;
var closestPoint = point;
var directions = [
- new WebInspector.Geometry.Point(0, -1), // North
- new WebInspector.Geometry.Point(1, -1), // Northeast
- new WebInspector.Geometry.Point(1, 0), // East
- new WebInspector.Geometry.Point(1, 1) // Southeast
+ new Common.Geometry.Point(0, -1), // North
+ new Common.Geometry.Point(1, -1), // Northeast
+ new Common.Geometry.Point(1, 0), // East
+ new Common.Geometry.Point(1, 1) // Southeast
];
for (var direction of directions) {
@@ -407,25 +407,25 @@ WebInspector.CSSShadowEditor = class extends WebInspector.VBox {
}
/**
- * @return {!WebInspector.Geometry.Point}
+ * @return {!Common.Geometry.Point}
*/
_sliderThumbPosition() {
- var x = (this._model.offsetX().amount / WebInspector.CSSShadowEditor.maxRange) * this._innerCanvasSize;
- var y = (this._model.offsetY().amount / WebInspector.CSSShadowEditor.maxRange) * this._innerCanvasSize;
- return this._constrainPoint(new WebInspector.Geometry.Point(x, y), this._innerCanvasSize);
+ var x = (this._model.offsetX().amount / UI.CSSShadowEditor.maxRange) * this._innerCanvasSize;
+ var y = (this._model.offsetY().amount / UI.CSSShadowEditor.maxRange) * this._innerCanvasSize;
+ return this._constrainPoint(new Common.Geometry.Point(x, y), this._innerCanvasSize);
}
};
/** @enum {symbol} */
-WebInspector.CSSShadowEditor.Events = {
+UI.CSSShadowEditor.Events = {
ShadowChanged: Symbol('ShadowChanged')
};
/** @type {number} */
-WebInspector.CSSShadowEditor.maxRange = 20;
+UI.CSSShadowEditor.maxRange = 20;
/** @type {string} */
-WebInspector.CSSShadowEditor.defaultUnit = 'px';
+UI.CSSShadowEditor.defaultUnit = 'px';
/** @type {number} */
-WebInspector.CSSShadowEditor.sliderThumbRadius = 6;
+UI.CSSShadowEditor.sliderThumbRadius = 6;
/** @type {number} */
-WebInspector.CSSShadowEditor.canvasSize = 88;
+UI.CSSShadowEditor.canvasSize = 88;

Powered by Google App Engine
This is Rietveld 408576698