OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BorderWidth_h | |
6 #define BorderWidth_h | |
7 | |
8 #include "core/style/ComputedStyleConstants.h" | |
9 | |
10 namespace blink { | |
11 | |
12 class BorderWidth { | |
13 DISALLOW_NEW(); | |
14 | |
15 public: | |
16 BorderWidth() { SetWidth(3); } | |
17 | |
18 BorderWidth(float width) { SetWidth(width); } | |
19 | |
20 bool operator==(const BorderWidth& o) const { return width_ == o.width_; } | |
21 | |
22 bool operator!=(const BorderWidth& o) const { return !(*this == o); } | |
23 | |
24 float Width() const { | |
25 return static_cast<float>(width_) / kBorderWidthDenominator; | |
alancutter (OOO until 2018)
2017/05/24 01:50:06
I wonder why we don't use LayoutUnit for this. It
nainar1
2017/05/24 01:53:21
Could use LayoutUnit - didn't know it was a thing.
shend
2017/05/24 01:55:08
If it does the same thing and you could get it to
| |
26 } | |
27 void SetWidth(float width) { width_ = WidthToFixedPoint(width); } | |
28 | |
29 // Since precision is lost with fixed point, comparisons also have | |
30 // to be done in fixed point. | |
31 bool WidthEquals(float width) const { | |
32 return WidthToFixedPoint(width) == width_; | |
33 } | |
34 | |
35 private: | |
36 static unsigned WidthToFixedPoint(float width) { | |
37 DCHECK_GE(width, 0); | |
38 return static_cast<unsigned>(std::min<float>(width, kMaxForBorderWidth) * | |
39 kBorderWidthDenominator); | |
40 } | |
41 | |
42 unsigned width_; // Fixed point width | |
43 }; | |
44 | |
45 } // namespace blink | |
46 | |
47 #endif // BorderWidth_h | |
OLD | NEW |