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

Unified Diff: third_party/WebKit/Source/platform/LayoutUnit.h

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - 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
Index: third_party/WebKit/Source/platform/LayoutUnit.h
diff --git a/third_party/WebKit/Source/platform/LayoutUnit.h b/third_party/WebKit/Source/platform/LayoutUnit.h
index 700aef96bd08df3423fe5895456321b7f03893b8..c61c1d297b64c6c29bb7c1477b504b9237d65737 100644
--- a/third_party/WebKit/Source/platform/LayoutUnit.h
+++ b/third_party/WebKit/Source/platform/LayoutUnit.h
@@ -107,8 +107,10 @@ public:
}
unsigned toUnsigned() const { REPORT_OVERFLOW(m_value >= 0); return toInt(); }
- operator int() const { return toInt(); }
- operator unsigned() const { return toUnsigned(); }
+ // Conversion to int or unsigned is lossy. Use toInt() and toUnsigned() instead.
+ operator int() const = delete;
+ operator unsigned() const = delete;
Stephen Chennney 2016/08/22 17:46:10 Am I right that these need to be deleted because o
Xianzhu 2016/08/22 18:14:38 Even worse. To avoid implicit lossy conversion, we
+
operator double() const { return toDouble(); }
operator float() const { return toFloat(); }
operator bool() const { return m_value; }

Powered by Google App Engine
This is Rietveld 408576698