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

Unified Diff: Source/devtools/front_end/ui/UIUtils.js

Issue 1175113007: Devtools: Fix "unable to change the value of R/G/B/A" in color picker (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename variable Created 5 years, 6 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
« no previous file with comments | « Source/devtools/front_end/elements/Spectrum.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ui/UIUtils.js
diff --git a/Source/devtools/front_end/ui/UIUtils.js b/Source/devtools/front_end/ui/UIUtils.js
index ed3ccd6e56f76eee7721fbdd6260bc750c4cbd4b..9b02e084c65aa0f926ea75e1234ab3c126cb7e9d 100644
--- a/Source/devtools/front_end/ui/UIUtils.js
+++ b/Source/devtools/front_end/ui/UIUtils.js
@@ -361,6 +361,42 @@ WebInspector._modifiedFloatNumber = function(number, event)
}
/**
+ * @param {string} wordString
+ * @param {!Event} event
+ * @param {function(string, number, string):string=} customNumberHandler
+ * @return {?string}
+ */
+WebInspector.createReplacementString = function(wordString, event, customNumberHandler)
+{
+ var replacementString;
+ var prefix, suffix, number;
+
+ var matches;
+ matches = /(.*#)([\da-fA-F]+)(.*)/.exec(wordString);
+ if (matches && matches.length) {
+ prefix = matches[1];
+ suffix = matches[3];
+ number = WebInspector._modifiedHexValue(matches[2], event);
+
+ replacementString = customNumberHandler ? customNumberHandler(prefix, number, suffix) : prefix + number + suffix;
+ } else {
+ matches = /(.*?)(-?(?:\d+(?:\.\d+)?|\.\d+))(.*)/.exec(wordString);
+ if (matches && matches.length) {
+ prefix = matches[1];
+ suffix = matches[3];
+ number = WebInspector._modifiedFloatNumber(parseFloat(matches[2]), event);
+
+ // Need to check for null explicitly.
+ if (number === null)
+ return null;
+
+ replacementString = customNumberHandler ? customNumberHandler(prefix, number, suffix) : prefix + number + suffix;
+ }
+ }
+ return replacementString || null;
+}
+
+/**
* @param {!Event} event
* @param {!Element} element
* @param {function(string,string)=} finishHandler
@@ -399,31 +435,7 @@ WebInspector.handleElementValueModifications = function(event, element, finishHa
if (suggestionHandler && suggestionHandler(wordString))
return false;
- var replacementString;
- var prefix, suffix, number;
-
- var matches;
- matches = /(.*#)([\da-fA-F]+)(.*)/.exec(wordString);
- if (matches && matches.length) {
- prefix = matches[1];
- suffix = matches[3];
- number = WebInspector._modifiedHexValue(matches[2], event);
-
- replacementString = customNumberHandler ? customNumberHandler(prefix, number, suffix) : prefix + number + suffix;
- } else {
- matches = /(.*?)(-?(?:\d+(?:\.\d+)?|\.\d+))(.*)/.exec(wordString);
- if (matches && matches.length) {
- prefix = matches[1];
- suffix = matches[3];
- number = WebInspector._modifiedFloatNumber(parseFloat(matches[2]), event);
-
- // Need to check for null explicitly.
- if (number === null)
- return false;
-
- replacementString = customNumberHandler ? customNumberHandler(prefix, number, suffix) : prefix + number + suffix;
- }
- }
+ var replacementString = WebInspector.createReplacementString(wordString, event, customNumberHandler);
if (replacementString) {
var replacementTextNode = createTextNode(replacementString);
« no previous file with comments | « Source/devtools/front_end/elements/Spectrum.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698