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

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

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 unified diff | Download patch
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 24 matching lines...) Expand all
35 35
36 namespace blink { 36 namespace blink {
37 37
38 IntRect::IntRect(const FloatRect& r) 38 IntRect::IntRect(const FloatRect& r)
39 : m_location(clampTo<int>(r.x()), clampTo<int>(r.y())) 39 : m_location(clampTo<int>(r.x()), clampTo<int>(r.y()))
40 , m_size(clampTo<int>(r.width()), clampTo<int>(r.height())) 40 , m_size(clampTo<int>(r.width()), clampTo<int>(r.height()))
41 { 41 {
42 } 42 }
43 43
44 IntRect::IntRect(const LayoutRect& r) 44 IntRect::IntRect(const LayoutRect& r)
45 : m_location(r.x(), r.y()) 45 : m_location(r.x().toInt(), r.y().toInt())
46 , m_size(r.width(), r.height()) 46 , m_size(r.width().toInt(), r.height().toInt())
47 { 47 {
48 } 48 }
49 49
50 bool IntRect::intersects(const IntRect& other) const 50 bool IntRect::intersects(const IntRect& other) const
51 { 51 {
52 // Checking emptiness handles negative widths as well as zero. 52 // Checking emptiness handles negative widths as well as zero.
53 return !isEmpty() && !other.isEmpty() 53 return !isEmpty() && !other.isEmpty()
54 && x() < other.maxX() && other.x() < maxX() 54 && x() < other.maxX() && other.x() < maxX()
55 && y() < other.maxY() && other.y() < maxY(); 55 && y() < other.maxY() && other.y() < maxY();
56 } 56 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 188 }
189 189
190 String IntRect::toString() const 190 String IntRect::toString() const
191 { 191 {
192 return String::format("%s %s", 192 return String::format("%s %s",
193 location().toString().ascii().data(), 193 location().toString().ascii().data(),
194 size().toString().ascii().data()); 194 size().toString().ascii().data());
195 } 195 }
196 196
197 } // namespace blink 197 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/LengthFunctions.cpp ('k') | third_party/WebKit/Source/web/RotationViewportAnchor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698