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

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

Issue 2904453002: Use LayoutUnit for all border-*-width logic (Closed)
Patch Set: shend@ suggestions Created 3 years, 6 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
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
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