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

Unified Diff: Source/core/inspector/InjectedScriptSource.js

Issue 82553008: DevTools: Show -0 for negative zero in console. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: added preview test Created 7 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
« no previous file with comments | « LayoutTests/inspector/console/console-object-preview-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InjectedScriptSource.js
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index 1ddcd7f02828f4d93aa8bf90d6c3c868f0905eba..8788757825f9908d079d0a5be1b12667f77f0f6a 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -87,6 +87,15 @@ function bind(func, thisObject, var_args)
}
/**
+ * @param {number} x
+ * @return {boolean}
+ */
+function isNegativeZero(x)
+{
+ return x === 0 && 1 / x < 0;
+}
+
+/**
* @constructor
*/
var InjectedScript = function()
@@ -930,8 +939,12 @@ InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType,
this.subtype = "null";
// Provide user-friendly number values.
- if (this.type === "number")
- this.description = toString(object);
+ if (this.type === "number") {
+ if (isNegativeZero(/** @type {number} */ (object)))
+ this.description = "-0";
+ else
+ this.description = toString(object);
+ }
return;
}
@@ -1029,7 +1042,8 @@ InjectedScript.RemoteObject.prototype = {
value = this._abbreviateString(value, maxLength, true);
preview.lossless = false;
}
- this._appendPropertyPreview(preview, { name: name, type: type, value: toString(value) }, propertiesThreshold);
+ var description = (type === "number" && isNegativeZero(value)) ? "-0" : toString(value);
yurys 2013/11/22 18:00:09 The code for the number serialization repeats twic
+ this._appendPropertyPreview(preview, { name: name, type: type, value: description }, propertiesThreshold);
continue;
}
« no previous file with comments | « LayoutTests/inspector/console/console-object-preview-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698