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

Side by Side Diff: third_party/WebKit/Source/core/style/BorderEdge.cpp

Issue 2890733002: Make EBorderStyle an enum class. (Closed)
Patch Set: Build for Mac 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
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 #include "core/style/BorderEdge.h" 5 #include "core/style/BorderEdge.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 BorderEdge::BorderEdge(float edge_width, 9 BorderEdge::BorderEdge(float edge_width,
10 const Color& edge_color, 10 const Color& edge_color,
11 EBorderStyle edge_style, 11 EBorderStyle edge_style,
12 bool edge_is_present) 12 bool edge_is_present)
13 : color(edge_color), 13 : color(edge_color),
14 is_present(edge_is_present), 14 is_present(edge_is_present),
15 style(edge_style), 15 style(static_cast<unsigned>(edge_style)),
16 width_(edge_width) { 16 width_(edge_width) {
17 if (style == kBorderStyleDouble && edge_width < 3) 17 if (style == static_cast<unsigned>(EBorderStyle::kDouble) && edge_width < 3)
18 style = kBorderStyleSolid; 18 style = static_cast<unsigned>(EBorderStyle::kSolid);
19 } 19 }
20 20
21 BorderEdge::BorderEdge() : is_present(false), style(kBorderStyleHidden) {} 21 BorderEdge::BorderEdge()
22 : is_present(false), style(static_cast<unsigned>(EBorderStyle::kHidden)) {}
22 23
23 bool BorderEdge::HasVisibleColorAndStyle() const { 24 bool BorderEdge::HasVisibleColorAndStyle() const {
24 return style > kBorderStyleHidden && color.Alpha() > 0; 25 return style > static_cast<unsigned>(EBorderStyle::kHidden) &&
26 color.Alpha() > 0;
25 } 27 }
26 28
27 bool BorderEdge::ShouldRender() const { 29 bool BorderEdge::ShouldRender() const {
28 return is_present && width_ && HasVisibleColorAndStyle(); 30 return is_present && width_ && HasVisibleColorAndStyle();
29 } 31 }
30 32
31 bool BorderEdge::PresentButInvisible() const { 33 bool BorderEdge::PresentButInvisible() const {
32 return UsedWidth() && !HasVisibleColorAndStyle(); 34 return UsedWidth() && !HasVisibleColorAndStyle();
33 } 35 }
34 36
35 bool BorderEdge::ObscuresBackgroundEdge() const { 37 bool BorderEdge::ObscuresBackgroundEdge() const {
36 if (!is_present || color.HasAlpha() || style == kBorderStyleHidden) 38 if (!is_present || color.HasAlpha() ||
39 style == static_cast<unsigned>(EBorderStyle::kHidden))
37 return false; 40 return false;
38 41
39 if (style == kBorderStyleDotted || style == kBorderStyleDashed) 42 if (style == static_cast<unsigned>(EBorderStyle::kDotted) ||
43 style == static_cast<unsigned>(EBorderStyle::kDashed))
40 return false; 44 return false;
41 45
42 return true; 46 return true;
43 } 47 }
44 48
45 bool BorderEdge::ObscuresBackground() const { 49 bool BorderEdge::ObscuresBackground() const {
46 if (!is_present || color.HasAlpha() || style == kBorderStyleHidden) 50 if (!is_present || color.HasAlpha() ||
51 style == static_cast<unsigned>(EBorderStyle::kHidden))
47 return false; 52 return false;
48 53
49 if (style == kBorderStyleDotted || style == kBorderStyleDashed || 54 if (style == static_cast<unsigned>(EBorderStyle::kDotted) ||
50 style == kBorderStyleDouble) 55 style == static_cast<unsigned>(EBorderStyle::kDashed) ||
56 style == static_cast<unsigned>(EBorderStyle::kDouble))
51 return false; 57 return false;
52 58
53 return true; 59 return true;
54 } 60 }
55 61
56 float BorderEdge::UsedWidth() const { 62 float BorderEdge::UsedWidth() const {
57 return is_present ? width_ : 0; 63 return is_present ? width_ : 0;
58 } 64 }
59 65
60 float BorderEdge::GetDoubleBorderStripeWidth(DoubleBorderStripe stripe) const { 66 float BorderEdge::GetDoubleBorderStripeWidth(DoubleBorderStripe stripe) const {
61 DCHECK(stripe == kDoubleBorderStripeOuter || 67 DCHECK(stripe == kDoubleBorderStripeOuter ||
62 stripe == kDoubleBorderStripeInner); 68 stripe == kDoubleBorderStripeInner);
63 69
64 return roundf(stripe == kDoubleBorderStripeOuter ? UsedWidth() / 3 70 return roundf(stripe == kDoubleBorderStripeOuter ? UsedWidth() / 3
65 : (UsedWidth() * 2) / 3); 71 : (UsedWidth() * 2) / 3);
66 } 72 }
67 73
68 bool BorderEdge::SharesColorWith(const BorderEdge& other) const { 74 bool BorderEdge::SharesColorWith(const BorderEdge& other) const {
69 return color == other.color; 75 return color == other.color;
70 } 76 }
71 77
72 } // namespace blink 78 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/TableCellPainter.cpp ('k') | third_party/WebKit/Source/core/style/BorderStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698