| 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 BorderData_h | 25 #ifndef BorderData_h |
| 26 #define BorderData_h | 26 #define BorderData_h |
| 27 | 27 |
| 28 #include "core/style/BorderValue.h" | 28 #include "core/style/BorderColorAndStyle.h" |
| 29 #include "core/style/NinePieceImage.h" | 29 #include "core/style/NinePieceImage.h" |
| 30 #include "platform/LengthSize.h" | 30 #include "platform/LengthSize.h" |
| 31 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
| 32 #include "platform/wtf/Allocator.h" | 32 #include "platform/wtf/Allocator.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class BorderData { | 36 class BorderData { |
| 37 DISALLOW_NEW(); | 37 DISALLOW_NEW(); |
| 38 friend class ComputedStyle; | 38 friend class ComputedStyle; |
| 39 | 39 |
| 40 public: | 40 public: |
| 41 BorderData() {} | 41 BorderData() {} |
| 42 | 42 |
| 43 bool HasBorder() const { | 43 bool HasBorder() const { |
| 44 return left_.NonZero() || right_.NonZero() || top_.NonZero() || | 44 return left_.NonZero() || right_.NonZero() || top_.NonZero() || |
| 45 bottom_.NonZero(); | 45 bottom_.NonZero(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool HasBorderFill() const { return image_.HasImage() && image_.Fill(); } | 48 bool HasBorderFill() const { return image_.HasImage() && image_.Fill(); } |
| 49 | 49 |
| 50 bool HasBorderColorReferencingCurrentColor() const { | 50 bool HasBorderColorReferencingCurrentColor() const { |
| 51 return (left_.NonZero() && left_.GetColor().IsCurrentColor()) || | 51 return (left_.NonZero() && left_.GetColor().IsCurrentColor()) || |
| 52 (right_.NonZero() && right_.GetColor().IsCurrentColor()) || | 52 (right_.NonZero() && right_.GetColor().IsCurrentColor()) || |
| 53 (top_.NonZero() && top_.GetColor().IsCurrentColor()) || | 53 (top_.NonZero() && top_.GetColor().IsCurrentColor()) || |
| 54 (bottom_.NonZero() && bottom_.GetColor().IsCurrentColor()); | 54 (bottom_.NonZero() && bottom_.GetColor().IsCurrentColor()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 float BorderLeftWidth() const { | |
| 58 if (left_.Style() == kBorderStyleNone || | |
| 59 left_.Style() == kBorderStyleHidden) | |
| 60 return 0; | |
| 61 return left_.Width(); | |
| 62 } | |
| 63 | |
| 64 float BorderRightWidth() const { | |
| 65 if (right_.Style() == kBorderStyleNone || | |
| 66 right_.Style() == kBorderStyleHidden) | |
| 67 return 0; | |
| 68 return right_.Width(); | |
| 69 } | |
| 70 | |
| 71 float BorderTopWidth() const { | |
| 72 if (top_.Style() == kBorderStyleNone || top_.Style() == kBorderStyleHidden) | |
| 73 return 0; | |
| 74 return top_.Width(); | |
| 75 } | |
| 76 | |
| 77 float BorderBottomWidth() const { | |
| 78 if (bottom_.Style() == kBorderStyleNone || | |
| 79 bottom_.Style() == kBorderStyleHidden) | |
| 80 return 0; | |
| 81 return bottom_.Width(); | |
| 82 } | |
| 83 | |
| 84 bool operator==(const BorderData& o) const { | 57 bool operator==(const BorderData& o) const { |
| 85 return left_ == o.left_ && right_ == o.right_ && top_ == o.top_ && | 58 return left_ == o.left_ && right_ == o.right_ && top_ == o.top_ && |
| 86 bottom_ == o.bottom_ && image_ == o.image_; | 59 bottom_ == o.bottom_ && image_ == o.image_; |
| 87 } | 60 } |
| 88 | 61 |
| 89 bool VisuallyEqual(const BorderData& o) const { | 62 bool VisuallyEqual(const BorderData& o) const { |
| 90 return left_.VisuallyEqual(o.left_) && right_.VisuallyEqual(o.right_) && | 63 return left_.VisuallyEqual(o.left_) && right_.VisuallyEqual(o.right_) && |
| 91 top_.VisuallyEqual(o.top_) && bottom_.VisuallyEqual(o.bottom_) && | 64 top_.VisuallyEqual(o.top_) && bottom_.VisuallyEqual(o.bottom_) && |
| 92 image_ == o.image_; | 65 image_ == o.image_; |
| 93 } | 66 } |
| 94 | 67 |
| 95 bool VisualOverflowEqual(const BorderData& o) const { | 68 bool VisualOverflowEqual(const BorderData& o) const { |
| 96 return image_.Outset() == o.image_.Outset(); | 69 return image_.Outset() == o.image_.Outset(); |
| 97 } | 70 } |
| 98 | 71 |
| 99 bool operator!=(const BorderData& o) const { return !(*this == o); } | 72 bool operator!=(const BorderData& o) const { return !(*this == o); } |
| 100 | 73 |
| 101 bool SizeEquals(const BorderData& o) const { | 74 const BorderColorAndStyle& Left() const { return left_; } |
| 102 return BorderLeftWidth() == o.BorderLeftWidth() && | 75 const BorderColorAndStyle& Right() const { return right_; } |
| 103 BorderTopWidth() == o.BorderTopWidth() && | 76 const BorderColorAndStyle& Top() const { return top_; } |
| 104 BorderRightWidth() == o.BorderRightWidth() && | 77 const BorderColorAndStyle& Bottom() const { return bottom_; } |
| 105 BorderBottomWidth() == o.BorderBottomWidth(); | |
| 106 } | |
| 107 | |
| 108 const BorderValue& Left() const { return left_; } | |
| 109 const BorderValue& Right() const { return right_; } | |
| 110 const BorderValue& Top() const { return top_; } | |
| 111 const BorderValue& Bottom() const { return bottom_; } | |
| 112 | 78 |
| 113 const NinePieceImage& GetImage() const { return image_; } | 79 const NinePieceImage& GetImage() const { return image_; } |
| 114 | 80 |
| 115 private: | 81 private: |
| 116 BorderValue left_; | 82 BorderColorAndStyle left_; |
| 117 BorderValue right_; | 83 BorderColorAndStyle right_; |
| 118 BorderValue top_; | 84 BorderColorAndStyle top_; |
| 119 BorderValue bottom_; | 85 BorderColorAndStyle bottom_; |
| 120 | 86 |
| 121 NinePieceImage image_; | 87 NinePieceImage image_; |
| 122 }; | 88 }; |
| 123 | 89 |
| 124 } // namespace blink | 90 } // namespace blink |
| 125 | 91 |
| 126 #endif // BorderData_h | 92 #endif // BorderData_h |
| OLD | NEW |