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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 190633011: Size checking logic is duplicated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
10 * 10 *
(...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 canvas()->didDraw(dirtyRect); 1911 canvas()->didDraw(dirtyRect);
1912 } 1912 }
1913 1913
1914 GraphicsContext* CanvasRenderingContext2D::drawingContext() const 1914 GraphicsContext* CanvasRenderingContext2D::drawingContext() const
1915 { 1915 {
1916 return canvas()->drawingContext(); 1916 return canvas()->drawingContext();
1917 } 1917 }
1918 1918
1919 static PassRefPtr<ImageData> createEmptyImageData(const IntSize& size) 1919 static PassRefPtr<ImageData> createEmptyImageData(const IntSize& size)
1920 { 1920 {
1921 Checked<int, RecordOverflow> dataSize = 4; 1921 if (RefPtr<ImageData> data = ImageData::create(size)) {
1922 dataSize *= size.width(); 1922 data->data()->zeroFill();
1923 dataSize *= size.height(); 1923 return data.release();
1924 if (dataSize.hasOverflowed()) 1924 }
1925 return nullptr;
1926 1925
1927 RefPtr<ImageData> data = ImageData::create(size); 1926 return nullptr;
1928 data->data()->zeroFill();
1929 return data.release();
1930 } 1927 }
1931 1928
1932 PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(PassRefPtr<Image Data> imageData, ExceptionState& exceptionState) const 1929 PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(PassRefPtr<Image Data> imageData, ExceptionState& exceptionState) const
1933 { 1930 {
1934 if (!imageData) { 1931 if (!imageData) {
1935 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "ImageData")); 1932 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "ImageData"));
1936 return nullptr; 1933 return nullptr;
1937 } 1934 }
1938 1935
1939 return createEmptyImageData(imageData->size()); 1936 return createEmptyImageData(imageData->size());
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 const int focusRingWidth = 5; 2545 const int focusRingWidth = 5;
2549 const int focusRingOutline = 0; 2546 const int focusRingOutline = 0;
2550 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); 2547 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor);
2551 2548
2552 c->restore(); 2549 c->restore();
2553 2550
2554 didDraw(dirtyRect); 2551 didDraw(dirtyRect);
2555 } 2552 }
2556 2553
2557 } // namespace WebCore 2554 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698