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

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

Issue 2191233002: Add platform/geometry pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust tests to work around uninteresting cross-platform differences 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) 2012, Google Inc. All rights reserved. 2 * Copyright (c) 2012, Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 20 matching lines...) Expand all
31 #ifndef LayoutSize_h 31 #ifndef LayoutSize_h
32 #define LayoutSize_h 32 #define LayoutSize_h
33 33
34 #include "platform/LayoutUnit.h" 34 #include "platform/LayoutUnit.h"
35 #include "platform/geometry/DoubleSize.h" 35 #include "platform/geometry/DoubleSize.h"
36 #include "platform/geometry/FloatPoint.h" 36 #include "platform/geometry/FloatPoint.h"
37 #include "platform/geometry/FloatSize.h" 37 #include "platform/geometry/FloatSize.h"
38 #include "platform/geometry/IntSize.h" 38 #include "platform/geometry/IntSize.h"
39 #include "wtf/Allocator.h" 39 #include "wtf/Allocator.h"
40 #include "wtf/Forward.h" 40 #include "wtf/Forward.h"
41 #include <iosfwd>
41 42
42 namespace blink { 43 namespace blink {
43 44
44 enum AspectRatioFit { 45 enum AspectRatioFit {
45 AspectRatioFitShrink, 46 AspectRatioFitShrink,
46 AspectRatioFitGrow 47 AspectRatioFitGrow
47 }; 48 };
48 49
49 class PLATFORM_EXPORT LayoutSize { 50 class PLATFORM_EXPORT LayoutSize {
50 DISALLOW_NEW(); 51 DISALLOW_NEW();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if ((widthScale > heightScale) != (fit == AspectRatioFitGrow)) 142 if ((widthScale > heightScale) != (fit == AspectRatioFitGrow))
142 return LayoutSize(height() * aspectRatio.width() / aspectRatio.heigh t(), height()); 143 return LayoutSize(height() * aspectRatio.width() / aspectRatio.heigh t(), height());
143 return LayoutSize(width(), width() * aspectRatio.height() / aspectRatio. width()); 144 return LayoutSize(width(), width() * aspectRatio.height() / aspectRatio. width());
144 } 145 }
145 146
146 LayoutSize fraction() const 147 LayoutSize fraction() const
147 { 148 {
148 return LayoutSize(m_width.fraction(), m_height.fraction()); 149 return LayoutSize(m_width.fraction(), m_height.fraction());
149 } 150 }
150 151
151 #ifndef NDEBUG
152 String toString() const;
153 #endif
154
155 private: 152 private:
156 LayoutUnit m_width, m_height; 153 LayoutUnit m_width, m_height;
157 }; 154 };
158 155
159 inline LayoutSize& operator+=(LayoutSize& a, const LayoutSize& b) 156 inline LayoutSize& operator+=(LayoutSize& a, const LayoutSize& b)
160 { 157 {
161 a.setWidth(a.width() + b.width()); 158 a.setWidth(a.width() + b.width());
162 a.setHeight(a.height() + b.height()); 159 a.setHeight(a.height() + b.height());
163 return a; 160 return a;
164 } 161 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 inline IntSize roundedIntSize(const LayoutSize& s) 222 inline IntSize roundedIntSize(const LayoutSize& s)
226 { 223 {
227 return IntSize(s.width().round(), s.height().round()); 224 return IntSize(s.width().round(), s.height().round());
228 } 225 }
229 226
230 inline LayoutSize roundedLayoutSize(const FloatSize& s) 227 inline LayoutSize roundedLayoutSize(const FloatSize& s)
231 { 228 {
232 return LayoutSize(s); 229 return LayoutSize(s);
233 } 230 }
234 231
232 PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const LayoutSize&);
233
235 } // namespace blink 234 } // namespace blink
236 235
237 #endif // LayoutSize_h 236 #endif // LayoutSize_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698