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

Unified Diff: third_party/WebKit/Source/core/html/canvas/OffScreenCanvas.cpp

Issue 1488763002: Start an empty interface OffScreenCanvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle unsigned->int potential overflow Created 5 years 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/core/html/canvas/OffScreenCanvas.cpp
diff --git a/third_party/WebKit/Source/core/html/canvas/OffScreenCanvas.cpp b/third_party/WebKit/Source/core/html/canvas/OffScreenCanvas.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..82d0d76df8428f83e07aa6802251f4b30ba9543e
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/canvas/OffScreenCanvas.cpp
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/html/canvas/OffScreenCanvas.h"
+
+namespace blink {
+
+OffScreenCanvas* OffScreenCanvas::create(unsigned width, unsigned height)
+{
+ if (width > INT_MAX)
+ width = INT_MAX;
+ if (height > INT_MAX)
+ height = INT_MAX;
+ return new OffScreenCanvas(IntSize(width, height));
+}
+
+void OffScreenCanvas::setWidth(unsigned width)
+{
+ if (width > INT_MAX)
Justin Novosad 2015/12/03 17:05:55 use clampTo<int>, defined in wtf/MathExtras.h
xidachen 2015/12/03 18:41:40 Done.
+ m_size.setWidth(INT_MAX);
+ m_size.setWidth(width);
+}
+
+void OffScreenCanvas::setHeight(unsigned height)
+{
+ if (height > INT_MAX)
+ m_size.setHeight(INT_MAX);
+ m_size.setHeight(height);
+}
+
+OffScreenCanvas::OffScreenCanvas(const IntSize& size)
+ : m_size(size)
+{
+}
+
+DEFINE_TRACE(OffScreenCanvas)
+{
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698