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

Side by Side Diff: third_party/WebKit/Source/platform/geometry/IntRect.h

Issue 2264723002: Fix int overflow in window.moveBy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 3 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 | « third_party/WebKit/Source/platform/geometry/IntPoint.h ('k') | 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) 2003, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 bool isEmpty() const { return m_size.isEmpty(); } 86 bool isEmpty() const { return m_size.isEmpty(); }
87 87
88 // NOTE: The result is rounded to integer values, and thus may be not the ex act 88 // NOTE: The result is rounded to integer values, and thus may be not the ex act
89 // center point. 89 // center point.
90 IntPoint center() const { return IntPoint(x() + width() / 2, y() + height() / 2); } 90 IntPoint center() const { return IntPoint(x() + width() / 2, y() + height() / 2); }
91 91
92 void move(const IntSize& size) { m_location += size; } 92 void move(const IntSize& size) { m_location += size; }
93 void moveBy(const IntPoint& offset) { m_location.move(offset.x(), offset.y() ); } 93 void moveBy(const IntPoint& offset) { m_location.move(offset.x(), offset.y() ); }
94 void move(int dx, int dy) { m_location.move(dx, dy); } 94 void move(int dx, int dy) { m_location.move(dx, dy); }
95 void saturatedMove(int dx, int dy) { m_location.saturatedMove(dx, dy); }
95 96
96 void expand(const IntSize& size) { m_size += size; } 97 void expand(const IntSize& size) { m_size += size; }
97 void expand(int dw, int dh) { m_size.expand(dw, dh); } 98 void expand(int dw, int dh) { m_size.expand(dw, dh); }
98 void expand(const IntRectOutsets& outsets) 99 void expand(const IntRectOutsets& outsets)
99 { 100 {
100 m_location.move(-outsets.left(), -outsets.top()); 101 m_location.move(-outsets.left(), -outsets.top());
101 m_size.expand(outsets.left() + outsets.right(), outsets.top() + outsets. bottom()); 102 m_size.expand(outsets.left() + outsets.right(), outsets.top() + outsets. bottom());
102 } 103 }
103 104
104 void contract(const IntSize& size) { m_size -= size; } 105 void contract(const IntSize& size) { m_size -= size; }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 235
235 // Redeclared here to avoid ODR issues. 236 // Redeclared here to avoid ODR issues.
236 // See platform/testing/GeometryPrinters.h. 237 // See platform/testing/GeometryPrinters.h.
237 void PrintTo(const IntRect&, std::ostream*); 238 void PrintTo(const IntRect&, std::ostream*);
238 239
239 } // namespace blink 240 } // namespace blink
240 241
241 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::IntRect); 242 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::IntRect);
242 243
243 #endif // IntRect_h 244 #endif // IntRect_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/geometry/IntPoint.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698