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 18 matching lines...) Expand all Loading... |
29 #include "platform/wtf/Allocator.h" | 29 #include "platform/wtf/Allocator.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 class CollapsedBorderValue { | 33 class CollapsedBorderValue { |
34 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 34 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
35 | 35 |
36 public: | 36 public: |
37 CollapsedBorderValue() | 37 CollapsedBorderValue() |
38 : color_(0), | 38 : color_(0), |
39 color_is_current_color_(true), | |
40 width_(0), | 39 width_(0), |
41 style_(kBorderStyleNone), | 40 style_(kBorderStyleNone), |
42 precedence_(kBorderPrecedenceOff), | 41 precedence_(kBorderPrecedenceOff), |
43 transparent_(false) {} | 42 transparent_(false) {} |
44 | 43 |
45 CollapsedBorderValue(const BorderValue& border, | 44 CollapsedBorderValue(const BorderValue& border, |
46 const StyleColor& color, | 45 const Color& color, |
47 EBorderPrecedence precedence) | 46 EBorderPrecedence precedence) |
48 : color_(color.Resolve(Color())), | 47 : color_(color), |
49 color_is_current_color_(color.IsCurrentColor()), | |
50 width_(border.NonZero() ? border.Width() : 0), | 48 width_(border.NonZero() ? border.Width() : 0), |
51 style_(border.Style()), | 49 style_(border.Style()), |
52 precedence_(precedence), | 50 precedence_(precedence), |
53 transparent_(border.IsTransparent()) {} | 51 transparent_(border.IsTransparent()) {} |
54 | 52 |
55 unsigned Width() const { return style_ > kBorderStyleHidden ? width_ : 0; } | 53 unsigned Width() const { return style_ > kBorderStyleHidden ? width_ : 0; } |
56 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } | 54 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } |
57 bool Exists() const { return precedence_ != kBorderPrecedenceOff; } | 55 bool Exists() const { return precedence_ != kBorderPrecedenceOff; } |
58 StyleColor GetColor() const { | 56 Color GetColor() const { return color_; } |
59 return color_is_current_color_ ? StyleColor::CurrentColor() | |
60 : StyleColor(color_); | |
61 } | |
62 bool IsTransparent() const { return transparent_; } | 57 bool IsTransparent() const { return transparent_; } |
63 EBorderPrecedence Precedence() const { | 58 EBorderPrecedence Precedence() const { |
64 return static_cast<EBorderPrecedence>(precedence_); | 59 return static_cast<EBorderPrecedence>(precedence_); |
65 } | 60 } |
66 | 61 |
67 bool IsSameIgnoringColor(const CollapsedBorderValue& o) const { | 62 bool IsSameIgnoringColor(const CollapsedBorderValue& o) const { |
68 return Width() == o.Width() && Style() == o.Style() && | 63 return Width() == o.Width() && Style() == o.Style() && |
69 Precedence() == o.Precedence(); | 64 Precedence() == o.Precedence(); |
70 } | 65 } |
71 | 66 |
72 bool VisuallyEquals(const CollapsedBorderValue& o) const { | 67 bool VisuallyEquals(const CollapsedBorderValue& o) const { |
73 if (!IsVisible() && !o.IsVisible()) | 68 if (!IsVisible() && !o.IsVisible()) |
74 return true; | 69 return true; |
75 return GetColor() == o.GetColor() && IsTransparent() == o.IsTransparent() && | 70 return GetColor() == o.GetColor() && IsTransparent() == o.IsTransparent() && |
76 IsSameIgnoringColor(o); | 71 IsSameIgnoringColor(o); |
77 } | 72 } |
78 | 73 |
79 bool IsVisible() const { | 74 bool IsVisible() const { |
80 return Style() > kBorderStyleHidden && !IsTransparent() && Exists(); | 75 return Style() > kBorderStyleHidden && !IsTransparent() && Exists(); |
81 } | 76 } |
82 | 77 |
83 bool ShouldPaint( | 78 bool ShouldPaint( |
84 const CollapsedBorderValue& table_current_border_value) const { | 79 const CollapsedBorderValue& table_current_border_value) const { |
85 return IsVisible() && IsSameIgnoringColor(table_current_border_value); | 80 return IsVisible() && IsSameIgnoringColor(table_current_border_value); |
86 } | 81 } |
87 | 82 |
88 private: | 83 private: |
89 Color color_; | 84 Color color_; |
90 unsigned color_is_current_color_ : 1; | 85 unsigned width_ : 24; |
91 unsigned width_ : 23; | |
92 unsigned style_ : 4; // EBorderStyle | 86 unsigned style_ : 4; // EBorderStyle |
93 unsigned precedence_ : 3; // EBorderPrecedence | 87 unsigned precedence_ : 3; // EBorderPrecedence |
94 unsigned transparent_ : 1; | 88 unsigned transparent_ : 1; |
95 }; | 89 }; |
96 | 90 |
97 } // namespace blink | 91 } // namespace blink |
98 | 92 |
99 #endif // CollapsedBorderValue_h | 93 #endif // CollapsedBorderValue_h |
OLD | NEW |