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

Side by Side Diff: third_party/WebKit/Source/core/style/BorderWidth.h

Issue 2904453002: Use LayoutUnit for all border-*-width logic (Closed)
Patch Set: Created 3 years, 7 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
(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 friend class ComputedStyle;
shend 2017/05/23 08:05:32 does this need to be a friend?
nainar 2017/05/23 08:10:04 nope artifact of BorderValue which I blatantly cop
15
16 public:
17 BorderWidth() { SetWidth(3); }
18
19 BorderWidth(float width) { SetWidth(width); }
20
21 bool operator==(const BorderWidth& o) const { return width_ == o.width_; }
22
23 bool operator!=(const BorderWidth& o) const { return !(*this == o); }
24
25 float Width() const {
26 return static_cast<float>(width_) / kBorderWidthDenominator;
27 }
28 void SetWidth(float width) { width_ = WidthToFixedPoint(width); }
29
30 // Since precision is lost with fixed point, comparisons also have
31 // to be done in fixed point.
32 bool WidthEquals(float width) const {
33 return WidthToFixedPoint(width) == width_;
34 }
35
36 protected:
shend 2017/05/23 08:05:32 I would just do private.
nainar 2017/05/23 08:10:04 Done.
37 static unsigned WidthToFixedPoint(float width) {
38 DCHECK_GE(width, 0);
39 return static_cast<unsigned>(std::min<float>(width, kMaxForBorderWidth) *
40 kBorderWidthDenominator);
41 }
42
43 unsigned width_ : 26; // Fixed point width
shend 2017/05/23 08:05:32 there's probably no need to bit pack this anymore,
nainar 2017/05/23 08:10:04 Yup. Done
44 };
45
46 } // namespace blink
47
48 #endif // BorderWidth_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSProperties.json5 ('k') | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698