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

Side by Side Diff: Source/platform/geometry/DoubleSize.h

Issue 610423004: Preserve fractional scroll offset for JS scrolling API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 2 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 | « Source/platform/geometry/DoublePoint.h ('k') | Source/platform/scroll/ScrollView.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DoubleSize_h 5 #ifndef DoubleSize_h
6 #define DoubleSize_h 6 #define DoubleSize_h
7 7
8 #include "platform/geometry/FloatSize.h" 8 #include "platform/geometry/FloatSize.h"
9 #include "platform/geometry/IntSize.h" 9 #include "platform/geometry/IntSize.h"
10 #include "wtf/MathExtras.h" 10 #include "wtf/MathExtras.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class PLATFORM_EXPORT DoubleSize { 14 class PLATFORM_EXPORT DoubleSize {
15 public: 15 public:
16 DoubleSize() : m_width(0), m_height(0) { } 16 DoubleSize() : m_width(0), m_height(0) { }
17 DoubleSize(double width, double height) : m_width(width), m_height(height) { } 17 DoubleSize(double width, double height) : m_width(width), m_height(height) { }
18 DoubleSize(const IntSize& p) : m_width(p.width()), m_height(p.height()) { }
18 19
19 double width() const { return m_width; } 20 double width() const { return m_width; }
20 double height() const { return m_height; } 21 double height() const { return m_height; }
21 22
22 void setWidth(double width) { m_width = width; } 23 void setWidth(double width) { m_width = width; }
23 void setHeight(double height) { m_height = height; } 24 void setHeight(double height) { m_height = height; }
24 25
25 bool isEmpty() const { return m_width <= 0 || m_height <= 0; } 26 bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
26 27
27 bool isZero() const; 28 bool isZero() const;
28 29
29 private: 30 private:
30 double m_width, m_height; 31 double m_width, m_height;
31 }; 32 };
32 33
33 inline DoubleSize& operator+=(DoubleSize& a, const DoubleSize& b) 34 inline DoubleSize& operator+=(DoubleSize& a, const DoubleSize& b)
34 { 35 {
35 a.setWidth(a.width() + b.width()); 36 a.setWidth(a.width() + b.width());
36 a.setHeight(a.height() + b.height()); 37 a.setHeight(a.height() + b.height());
37 return a; 38 return a;
38 } 39 }
39 40
41 inline DoubleSize operator+(const DoubleSize& a, const DoubleSize& b)
42 {
43 return DoubleSize(a.width() + b.width(), a.height() + b.height());
44 }
45
40 inline DoubleSize operator-(const DoubleSize& a, const DoubleSize& b) 46 inline DoubleSize operator-(const DoubleSize& a, const DoubleSize& b)
41 { 47 {
42 return DoubleSize(a.width() - b.width(), a.height() - b.height()); 48 return DoubleSize(a.width() - b.width(), a.height() - b.height());
43 } 49 }
44 50
45 inline bool operator==(const DoubleSize& a, const DoubleSize& b) 51 inline bool operator==(const DoubleSize& a, const DoubleSize& b)
46 { 52 {
47 return a.width() == b.width() && a.height() == b.height(); 53 return a.width() == b.width() && a.height() == b.height();
48 } 54 }
49 55
56 inline bool operator!=(const DoubleSize& a, const DoubleSize& b)
57 {
58 return a.width() != b.width() || a.height() != b.height();
59 }
60
50 inline IntSize flooredIntSize(const DoubleSize& p) 61 inline IntSize flooredIntSize(const DoubleSize& p)
51 { 62 {
52 return IntSize(clampTo<int>(floor(p.width())), clampTo<int>(floor(p.height() ))); 63 return IntSize(clampTo<int>(floor(p.width())), clampTo<int>(floor(p.height() )));
53 } 64 }
54 65
55 inline FloatSize toFloatSize(const DoubleSize& p) 66 inline FloatSize toFloatSize(const DoubleSize& p)
56 { 67 {
57 return FloatSize(p.width(), p.height()); 68 return FloatSize(p.width(), p.height());
58 } 69 }
59 70
60 } // namespace blink 71 } // namespace blink
61 72
62 #endif // DoubleSize_h 73 #endif // DoubleSize_h
OLDNEW
« no previous file with comments | « Source/platform/geometry/DoublePoint.h ('k') | Source/platform/scroll/ScrollView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698