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

Unified Diff: Source/devtools/front_end/elements/Spectrum.js

Issue 475233003: DevTools: front-end part of color picker (behind experiment). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months 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: Source/devtools/front_end/elements/Spectrum.js
diff --git a/Source/devtools/front_end/elements/Spectrum.js b/Source/devtools/front_end/elements/Spectrum.js
index 492424f5992b5f361ca8e7723ab5d1cddd7bf1cf..f831fbb099c5f13b78a040614a018a86122bc1e8 100644
--- a/Source/devtools/front_end/elements/Spectrum.js
+++ b/Source/devtools/front_end/elements/Spectrum.js
@@ -372,7 +372,10 @@ WebInspector.SpectrumPopupHelper.prototype = {
this.reposition(element);
document.addEventListener("mousedown", this._hideProxy, false);
- window.addEventListener("blur", this._hideProxy, false);
+ if (WebInspector.experimentsSettings.colorPicker.isEnabled()) {
+ WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.ColorPicked, this._colorPicked, this);
+ PageAgent.setColorPickerEnabled(true);
+ }
return true;
},
@@ -394,7 +397,11 @@ WebInspector.SpectrumPopupHelper.prototype = {
this._popover.hide();
document.removeEventListener("mousedown", this._hideProxy, false);
- window.removeEventListener("blur", this._hideProxy, false);
+
+ if (WebInspector.experimentsSettings.colorPicker.isEnabled()) {
+ PageAgent.setColorPickerEnabled(false);
+ WebInspector.targetManager.removeModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.ColorPicked, this._colorPicked, this);
+ }
this.dispatchEventToListeners(WebInspector.SpectrumPopupHelper.Events.Hidden, !!commitEdit);
@@ -417,6 +424,18 @@ WebInspector.SpectrumPopupHelper.prototype = {
}
},
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _colorPicked: function(event)
+ {
+ var color = /** @type {!DOMAgent.RGBA} */ (event.data);
+ var rgba = [color.r, color.g, color.b, (color.a / 2.55 | 0) / 100];
+ this._spectrum.setColor(WebInspector.Color.fromRGBA(rgba));
+ this._spectrum._onchange();
+ InspectorFrontendHost.bringToFront();
+ },
+
__proto__: WebInspector.Object.prototype
}

Powered by Google App Engine
This is Rietveld 408576698