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

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

Issue 2278203003: DevTools: Allow shadow-editor value manipulation with arrow keys and mousewheel (Closed)
Patch Set: Add return annotations Created 4 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/CSSShadowEditor.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js b/third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js
index c5714f56dc119e77f9722b7264ed33349b319af8..37d6a28f6eeccfe3cda547e76bb4869b29bee365 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js
@@ -387,24 +387,25 @@ WebInspector._valueModificationDirection = function(event)
/**
* @param {string} hexString
* @param {!Event} event
+ * @return {?string}
*/
WebInspector._modifiedHexValue = function(hexString, event)
{
var direction = WebInspector._valueModificationDirection(event);
if (!direction)
- return hexString;
+ return null;
var mouseEvent = /** @type {!MouseEvent} */(event);
var number = parseInt(hexString, 16);
if (isNaN(number) || !isFinite(number))
- return hexString;
+ return null;
var hexStrLen = hexString.length;
var channelLen = hexStrLen / 3;
// Colors are either rgb or rrggbb.
if (channelLen !== 1 && channelLen !== 2)
- return hexString;
+ return null;
// Precision modifier keys work with both mousewheel and up/down keys.
// When ctrl is pressed, increase R by 1.
@@ -438,12 +439,13 @@ WebInspector._modifiedHexValue = function(hexString, event)
/**
* @param {number} number
* @param {!Event} event
+ * @return {?number}
*/
WebInspector._modifiedFloatNumber = function(number, event)
{
var direction = WebInspector._valueModificationDirection(event);
if (!direction)
- return number;
+ return null;
var mouseEvent = /** @type {!MouseEvent} */(event);
@@ -480,32 +482,28 @@ WebInspector._modifiedFloatNumber = function(number, event)
*/
WebInspector.createReplacementString = function(wordString, event, customNumberHandler)
{
- var replacementString;
- var prefix, suffix, number;
-
- var matches;
- matches = /(.*#)([\da-fA-F]+)(.*)/.exec(wordString);
+ var prefix;
+ var suffix;
+ var number;
+ var replacementString = null;
+ var 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;
+ if (number !== null)
+ replacementString = 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;
+ if (number !== null)
+ replacementString = customNumberHandler ? customNumberHandler(prefix, number, suffix) : prefix + number + suffix;
}
}
- return replacementString || null;
+ return replacementString;
}
/**
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/CSSShadowEditor.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698