OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 | 24 |
25 #ifndef CollapsedBorderValue_h | 25 #ifndef CollapsedBorderValue_h |
26 #define CollapsedBorderValue_h | 26 #define CollapsedBorderValue_h |
27 | 27 |
28 #include "core/style/BorderValue.h" | 28 #include "core/style/BorderValue.h" |
29 #include "platform/wtf/Allocator.h" | 29 #include "platform/wtf/Allocator.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
| 33 enum EBorderPrecedence { |
| 34 kBorderPrecedenceOff, |
| 35 kBorderPrecedenceTable, |
| 36 kBorderPrecedenceColumnGroup, |
| 37 kBorderPrecedenceColumn, |
| 38 kBorderPrecedenceRowGroup, |
| 39 kBorderPrecedenceRow, |
| 40 kBorderPrecedenceCell |
| 41 }; |
| 42 |
33 class CollapsedBorderValue { | 43 class CollapsedBorderValue { |
34 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
35 | 45 |
36 public: | 46 public: |
| 47 // Constructs a CollapsedBorderValue for non-existence border. |
37 CollapsedBorderValue() | 48 CollapsedBorderValue() |
38 : color_(0), | 49 : color_(0), |
39 width_(0), | 50 width_(0), |
40 style_(kBorderStyleNone), | 51 style_(kBorderStyleNone), |
41 precedence_(kBorderPrecedenceOff), | 52 precedence_(kBorderPrecedenceOff), |
42 transparent_(false) {} | 53 transparent_(false) {} |
43 | 54 |
44 CollapsedBorderValue(const BorderValue& border, | 55 CollapsedBorderValue(const BorderValue& border, |
45 const Color& color, | 56 const Color& color, |
46 EBorderPrecedence precedence) | 57 EBorderPrecedence precedence) |
47 : color_(color), | 58 : color_(color), |
48 width_(border.NonZero() ? border.Width() : 0), | 59 width_(border.NonZero() ? border.Width() : 0), |
49 style_(border.Style()), | 60 style_(border.Style()), |
50 precedence_(precedence), | 61 precedence_(precedence), |
51 transparent_(border.IsTransparent()) {} | 62 transparent_(border.IsTransparent()) { |
| 63 DCHECK(precedence != kBorderPrecedenceOff); |
| 64 } |
52 | 65 |
53 unsigned Width() const { return style_ > kBorderStyleHidden ? width_ : 0; } | 66 unsigned Width() const { return style_ > kBorderStyleHidden ? width_ : 0; } |
54 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } | 67 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } |
55 bool Exists() const { return precedence_ != kBorderPrecedenceOff; } | 68 bool Exists() const { return precedence_ != kBorderPrecedenceOff; } |
56 Color GetColor() const { return color_; } | 69 Color GetColor() const { return color_; } |
57 bool IsTransparent() const { return transparent_; } | 70 bool IsTransparent() const { return transparent_; } |
58 EBorderPrecedence Precedence() const { | 71 EBorderPrecedence Precedence() const { |
59 return static_cast<EBorderPrecedence>(precedence_); | 72 return static_cast<EBorderPrecedence>(precedence_); |
60 } | 73 } |
61 | 74 |
62 bool IsSameIgnoringColor(const CollapsedBorderValue& o) const { | 75 bool IsSameIgnoringColor(const CollapsedBorderValue& o) const { |
63 return Width() == o.Width() && Style() == o.Style() && | 76 return Width() == o.Width() && Style() == o.Style() && |
64 Precedence() == o.Precedence(); | 77 Precedence() == o.Precedence(); |
65 } | 78 } |
66 | 79 |
67 bool VisuallyEquals(const CollapsedBorderValue& o) const { | 80 bool VisuallyEquals(const CollapsedBorderValue& o) const { |
68 if (!IsVisible() && !o.IsVisible()) | 81 if (!IsVisible() && !o.IsVisible()) |
69 return true; | 82 return true; |
70 return GetColor() == o.GetColor() && IsTransparent() == o.IsTransparent() && | 83 return GetColor() == o.GetColor() && IsTransparent() == o.IsTransparent() && |
71 IsSameIgnoringColor(o); | 84 IsSameIgnoringColor(o); |
72 } | 85 } |
73 | 86 |
74 bool IsVisible() const { | 87 bool IsVisible() const { return Width() && !IsTransparent(); } |
75 return Style() > kBorderStyleHidden && !IsTransparent() && Exists(); | |
76 } | |
77 | 88 |
78 bool ShouldPaint( | 89 bool ShouldPaint( |
79 const CollapsedBorderValue& table_current_border_value) const { | 90 const CollapsedBorderValue& table_current_border_value) const { |
80 return IsVisible() && IsSameIgnoringColor(table_current_border_value); | 91 return IsVisible() && IsSameIgnoringColor(table_current_border_value); |
81 } | 92 } |
82 | 93 |
83 private: | 94 private: |
84 Color color_; | 95 Color color_; |
85 unsigned width_ : 24; | 96 unsigned width_ : 24; |
86 unsigned style_ : 4; // EBorderStyle | 97 unsigned style_ : 4; // EBorderStyle |
87 unsigned precedence_ : 3; // EBorderPrecedence | 98 unsigned precedence_ : 3; // EBorderPrecedence |
88 unsigned transparent_ : 1; | 99 unsigned transparent_ : 1; |
89 }; | 100 }; |
90 | 101 |
91 } // namespace blink | 102 } // namespace blink |
92 | 103 |
93 #endif // CollapsedBorderValue_h | 104 #endif // CollapsedBorderValue_h |
OLD | NEW |