OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * |
| 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. |
| 12 * |
| 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. |
| 17 * |
| 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. |
| 22 * |
| 23 */ |
| 24 |
| 25 #ifndef BorderColorAndStyle_h |
| 26 #define BorderColorAndStyle_h |
| 27 |
| 28 #include "core/css/StyleColor.h" |
| 29 #include "core/style/ComputedStyleConstants.h" |
| 30 #include "platform/graphics/Color.h" |
| 31 #include "platform/wtf/Allocator.h" |
| 32 |
| 33 namespace blink { |
| 34 |
| 35 class BorderColorAndStyle { |
| 36 DISALLOW_NEW(); |
| 37 friend class ComputedStyle; |
| 38 |
| 39 public: |
| 40 BorderColorAndStyle() |
| 41 : color_(0), |
| 42 color_is_current_color_(true), |
| 43 style_(kBorderStyleNone), |
| 44 is_auto_(kOutlineIsAutoOff) {} |
| 45 |
| 46 bool NonZero() const { return (style_ != kBorderStyleNone); } |
| 47 |
| 48 bool IsTransparent() const { |
| 49 return !color_is_current_color_ && !color_.Alpha(); |
| 50 } |
| 51 |
| 52 bool operator==(const BorderColorAndStyle& o) const { |
| 53 return style_ == o.style_ && color_ == o.color_ && |
| 54 color_is_current_color_ == o.color_is_current_color_; |
| 55 } |
| 56 |
| 57 // The default width is 3px, but if the style is none we compute a value of 0 |
| 58 // (in ComputedStyle itself) |
| 59 bool VisuallyEqual(const BorderColorAndStyle& o) const { |
| 60 if (style_ == kBorderStyleNone && o.style_ == kBorderStyleNone) |
| 61 return true; |
| 62 if (style_ == kBorderStyleHidden && o.style_ == kBorderStyleHidden) |
| 63 return true; |
| 64 return *this == o; |
| 65 } |
| 66 |
| 67 bool operator!=(const BorderColorAndStyle& o) const { return !(*this == o); } |
| 68 |
| 69 void SetColor(const StyleColor& color) { |
| 70 color_ = color.Resolve(Color()); |
| 71 color_is_current_color_ = color.IsCurrentColor(); |
| 72 } |
| 73 |
| 74 StyleColor GetColor() const { |
| 75 return color_is_current_color_ ? StyleColor::CurrentColor() |
| 76 : StyleColor(color_); |
| 77 } |
| 78 |
| 79 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } |
| 80 void SetStyle(EBorderStyle style) { style_ = style; } |
| 81 |
| 82 OutlineIsAuto IsAuto() const { return static_cast<OutlineIsAuto>(is_auto_); } |
| 83 void SetIsAuto(OutlineIsAuto is_auto) { is_auto_ = is_auto; } |
| 84 |
| 85 bool ColorIsCurrentColor() const { return color_is_current_color_; } |
| 86 void SetColorIsCurrentColor(bool color_is_current_color) { |
| 87 color_is_current_color_ = static_cast<unsigned>(color_is_current_color); |
| 88 } |
| 89 |
| 90 protected: |
| 91 Color color_; |
| 92 unsigned color_is_current_color_ : 1; |
| 93 |
| 94 unsigned style_ : 4; // EBorderStyle |
| 95 |
| 96 // This is only used by OutlineValue but moved here to keep the bits packed. |
| 97 unsigned is_auto_ : 1; // OutlineIsAuto |
| 98 }; |
| 99 |
| 100 } // namespace blink |
| 101 |
| 102 #endif // BorderColorAndStyle_h |
OLD | NEW |