| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 class CollapsedBorderValue { | 43 class CollapsedBorderValue { |
| 44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 45 | 45 |
| 46 public: | 46 public: |
| 47 // Constructs a CollapsedBorderValue for non-existence border. | 47 // Constructs a CollapsedBorderValue for non-existence border. |
| 48 CollapsedBorderValue() | 48 CollapsedBorderValue() |
| 49 : color_(0), | 49 : color_(0), |
| 50 width_(0), | 50 width_(0), |
| 51 style_(kBorderStyleNone), | 51 style_(kBorderStyleNone), |
| 52 precedence_(kBorderPrecedenceOff), | 52 precedence_(kBorderPrecedenceOff) {} |
| 53 transparent_(false) {} | |
| 54 | 53 |
| 55 CollapsedBorderValue(const BorderValue& border, | 54 CollapsedBorderValue(const BorderValue& border, |
| 56 const Color& color, | 55 const Color& color, |
| 57 EBorderPrecedence precedence) | 56 EBorderPrecedence precedence) |
| 58 : color_(color), | 57 : color_(color), |
| 59 width_(border.NonZero() ? border.Width() : 0), | 58 width_(border.Style() > kBorderStyleHidden ? border.Width() : 0), |
| 60 style_(border.Style()), | 59 style_(border.Style()), |
| 61 precedence_(precedence), | 60 precedence_(precedence) { |
| 62 transparent_(border.IsTransparent()) { | |
| 63 DCHECK(precedence != kBorderPrecedenceOff); | 61 DCHECK(precedence != kBorderPrecedenceOff); |
| 64 } | 62 } |
| 65 | 63 |
| 66 unsigned Width() const { return style_ > kBorderStyleHidden ? width_ : 0; } | 64 unsigned Width() const { return width_; } |
| 67 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } | 65 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } |
| 68 bool Exists() const { return precedence_ != kBorderPrecedenceOff; } | 66 bool Exists() const { return precedence_ != kBorderPrecedenceOff; } |
| 69 Color GetColor() const { return color_; } | 67 Color GetColor() const { return color_; } |
| 70 bool IsTransparent() const { return transparent_; } | 68 bool IsTransparent() const { return !color_.Alpha(); } |
| 71 EBorderPrecedence Precedence() const { | 69 EBorderPrecedence Precedence() const { |
| 72 return static_cast<EBorderPrecedence>(precedence_); | 70 return static_cast<EBorderPrecedence>(precedence_); |
| 73 } | 71 } |
| 74 | 72 |
| 75 bool IsSameIgnoringColor(const CollapsedBorderValue& o) const { | 73 bool IsSameIgnoringColor(const CollapsedBorderValue& o) const { |
| 76 return Width() == o.Width() && Style() == o.Style() && | 74 return Width() == o.Width() && Style() == o.Style() && |
| 77 Precedence() == o.Precedence(); | 75 Precedence() == o.Precedence(); |
| 78 } | 76 } |
| 79 | 77 |
| 80 bool VisuallyEquals(const CollapsedBorderValue& o) const { | 78 bool VisuallyEquals(const CollapsedBorderValue& o) const { |
| 81 if (!IsVisible() && !o.IsVisible()) | 79 if (!IsVisible() && !o.IsVisible()) |
| 82 return true; | 80 return true; |
| 83 return GetColor() == o.GetColor() && IsTransparent() == o.IsTransparent() && | 81 return GetColor() == o.GetColor() && Width() == o.Width() && |
| 84 IsSameIgnoringColor(o); | 82 Style() == o.Style(); |
| 85 } | 83 } |
| 86 | 84 |
| 87 bool IsVisible() const { return Width() && !IsTransparent(); } | 85 bool IsVisible() const { return Width() && !IsTransparent(); } |
| 88 | 86 |
| 89 bool ShouldPaint( | 87 bool ShouldPaint( |
| 90 const CollapsedBorderValue& table_current_border_value) const { | 88 const CollapsedBorderValue& table_current_border_value) const { |
| 91 return IsVisible() && IsSameIgnoringColor(table_current_border_value); | 89 return IsVisible() && IsSameIgnoringColor(table_current_border_value); |
| 92 } | 90 } |
| 93 | 91 |
| 94 private: | 92 private: |
| 95 Color color_; | 93 Color color_; |
| 96 unsigned width_ : 24; | 94 unsigned width_ : 25; |
| 97 unsigned style_ : 4; // EBorderStyle | 95 unsigned style_ : 4; // EBorderStyle |
| 98 unsigned precedence_ : 3; // EBorderPrecedence | 96 unsigned precedence_ : 3; // EBorderPrecedence |
| 99 unsigned transparent_ : 1; | |
| 100 }; | 97 }; |
| 101 | 98 |
| 102 } // namespace blink | 99 } // namespace blink |
| 103 | 100 |
| 104 #endif // CollapsedBorderValue_h | 101 #endif // CollapsedBorderValue_h |
| OLD | NEW |