| 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 |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 * | 22 * |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #ifndef BorderColorAndStyle_h | 25 #ifndef BorderStyle_h |
| 26 #define BorderColorAndStyle_h | 26 #define BorderStyle_h |
| 27 | 27 |
| 28 #include "core/css/StyleColor.h" | 28 #include "core/css/StyleColor.h" |
| 29 #include "core/style/ComputedStyleConstants.h" | 29 #include "core/style/ComputedStyleConstants.h" |
| 30 #include "platform/graphics/Color.h" | 30 #include "platform/graphics/Color.h" |
| 31 #include "platform/wtf/Allocator.h" | 31 #include "platform/wtf/Allocator.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class BorderColorAndStyle { | 35 class BorderStyle { |
| 36 DISALLOW_NEW(); | 36 DISALLOW_NEW(); |
| 37 friend class ComputedStyle; | 37 friend class ComputedStyle; |
| 38 | 38 |
| 39 public: | 39 public: |
| 40 BorderColorAndStyle() | 40 BorderStyle() : style_(kBorderStyleNone), is_auto_(kOutlineIsAutoOff) {} |
| 41 : color_(0), | |
| 42 color_is_current_color_(true), | |
| 43 style_(kBorderStyleNone), | |
| 44 is_auto_(kOutlineIsAutoOff) {} | |
| 45 | 41 |
| 46 bool NonZero() const { return (style_ != kBorderStyleNone); } | 42 bool NonZero() const { return (style_ != kBorderStyleNone); } |
| 47 | 43 |
| 48 bool IsTransparent() const { | 44 bool operator==(const BorderStyle& o) const { return style_ == o.style_; } |
| 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 | 45 |
| 57 // The default width is 3px, but if the style is none we compute a value of 0 | 46 // The default width is 3px, but if the style is none we compute a value of 0 |
| 58 // (in ComputedStyle itself) | 47 // (in ComputedStyle itself) |
| 59 bool VisuallyEqual(const BorderColorAndStyle& o) const { | 48 bool VisuallyEqual(const BorderStyle& o) const { |
| 60 if (style_ == kBorderStyleNone && o.style_ == kBorderStyleNone) | 49 if (style_ == kBorderStyleNone && o.style_ == kBorderStyleNone) |
| 61 return true; | 50 return true; |
| 62 if (style_ == kBorderStyleHidden && o.style_ == kBorderStyleHidden) | 51 if (style_ == kBorderStyleHidden && o.style_ == kBorderStyleHidden) |
| 63 return true; | 52 return true; |
| 64 return *this == o; | 53 return *this == o; |
| 65 } | 54 } |
| 66 | 55 |
| 67 bool operator!=(const BorderColorAndStyle& o) const { return !(*this == o); } | 56 bool operator!=(const BorderStyle& 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 | 57 |
| 79 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } | 58 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } |
| 80 void SetStyle(EBorderStyle style) { style_ = style; } | 59 void SetStyle(EBorderStyle style) { style_ = style; } |
| 81 | 60 |
| 82 OutlineIsAuto IsAuto() const { return static_cast<OutlineIsAuto>(is_auto_); } | 61 OutlineIsAuto IsAuto() const { return static_cast<OutlineIsAuto>(is_auto_); } |
| 83 void SetIsAuto(OutlineIsAuto is_auto) { is_auto_ = is_auto; } | 62 void SetIsAuto(OutlineIsAuto is_auto) { is_auto_ = is_auto; } |
| 84 | 63 |
| 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: | 64 protected: |
| 91 Color color_; | |
| 92 unsigned color_is_current_color_ : 1; | |
| 93 | |
| 94 unsigned style_ : 4; // EBorderStyle | 65 unsigned style_ : 4; // EBorderStyle |
| 95 | 66 |
| 96 // This is only used by OutlineValue but moved here to keep the bits packed. | 67 // This is only used by OutlineValue but moved here to keep the bits packed. |
| 97 unsigned is_auto_ : 1; // OutlineIsAuto | 68 unsigned is_auto_ : 1; // OutlineIsAuto |
| 98 }; | 69 }; |
| 99 | 70 |
| 100 } // namespace blink | 71 } // namespace blink |
| 101 | 72 |
| 102 #endif // BorderColorAndStyle_h | 73 #endif // BorderStyle_h |
| OLD | NEW |