| 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 BorderData_h | |
| 26 #define BorderData_h | |
| 27 | |
| 28 #include "core/layout/style/BorderValue.h" | |
| 29 #include "core/layout/style/NinePieceImage.h" | |
| 30 #include "platform/LengthSize.h" | |
| 31 #include "platform/geometry/IntRect.h" | |
| 32 | |
| 33 namespace blink { | |
| 34 | |
| 35 class BorderData { | |
| 36 friend class ComputedStyle; | |
| 37 public: | |
| 38 BorderData() : m_topLeft(Length(0, Fixed), Length(0, Fixed)) | |
| 39 , m_topRight(Length(0, Fixed), Length(0, Fixed)) | |
| 40 , m_bottomLeft(Length(0, Fixed), Length(0, Fixed)) | |
| 41 , m_bottomRight(Length(0, Fixed), Length(0, Fixed)) | |
| 42 { | |
| 43 } | |
| 44 bool hasBorder() const | |
| 45 { | |
| 46 bool haveImage = m_image.hasImage(); | |
| 47 return m_left.nonZero(!haveImage) || m_right.nonZero(!haveImage) || m_to
p.nonZero(!haveImage) || m_bottom.nonZero(!haveImage); | |
| 48 } | |
| 49 | |
| 50 bool hasBorderRadius() const | |
| 51 { | |
| 52 if (!m_topLeft.width().isZero()) | |
| 53 return true; | |
| 54 if (!m_topRight.width().isZero()) | |
| 55 return true; | |
| 56 if (!m_bottomLeft.width().isZero()) | |
| 57 return true; | |
| 58 if (!m_bottomRight.width().isZero()) | |
| 59 return true; | |
| 60 return false; | |
| 61 } | |
| 62 | |
| 63 unsigned borderLeftWidth() const | |
| 64 { | |
| 65 if (!m_image.hasImage() && (m_left.style() == BNONE || m_left.style() ==
BHIDDEN)) | |
| 66 return 0; | |
| 67 return m_left.width(); | |
| 68 } | |
| 69 | |
| 70 unsigned borderRightWidth() const | |
| 71 { | |
| 72 if (!m_image.hasImage() && (m_right.style() == BNONE || m_right.style()
== BHIDDEN)) | |
| 73 return 0; | |
| 74 return m_right.width(); | |
| 75 } | |
| 76 | |
| 77 unsigned borderTopWidth() const | |
| 78 { | |
| 79 if (!m_image.hasImage() && (m_top.style() == BNONE || m_top.style() == B
HIDDEN)) | |
| 80 return 0; | |
| 81 return m_top.width(); | |
| 82 } | |
| 83 | |
| 84 unsigned borderBottomWidth() const | |
| 85 { | |
| 86 if (!m_image.hasImage() && (m_bottom.style() == BNONE || m_bottom.style(
) == BHIDDEN)) | |
| 87 return 0; | |
| 88 return m_bottom.width(); | |
| 89 } | |
| 90 | |
| 91 bool operator==(const BorderData& o) const | |
| 92 { | |
| 93 return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top &&
m_bottom == o.m_bottom && m_image == o.m_image | |
| 94 && m_topLeft == o.m_topLeft && m_topRight == o.m_topRight && m_bo
ttomLeft == o.m_bottomLeft && m_bottomRight == o.m_bottomRight; | |
| 95 } | |
| 96 | |
| 97 bool visuallyEqual(const BorderData& o) const | |
| 98 { | |
| 99 return m_left.visuallyEqual(o.m_left) | |
| 100 && m_right.visuallyEqual(o.m_right) | |
| 101 && m_top.visuallyEqual(o.m_top) | |
| 102 && m_bottom.visuallyEqual(o.m_bottom) | |
| 103 && m_image == o.m_image | |
| 104 && m_topLeft == o.m_topLeft | |
| 105 && m_topRight == o.m_topRight | |
| 106 && m_bottomLeft == o.m_bottomLeft | |
| 107 && m_bottomRight == o.m_bottomRight; | |
| 108 } | |
| 109 | |
| 110 bool operator!=(const BorderData& o) const | |
| 111 { | |
| 112 return !(*this == o); | |
| 113 } | |
| 114 | |
| 115 const BorderValue& left() const { return m_left; } | |
| 116 const BorderValue& right() const { return m_right; } | |
| 117 const BorderValue& top() const { return m_top; } | |
| 118 const BorderValue& bottom() const { return m_bottom; } | |
| 119 | |
| 120 const NinePieceImage& image() const { return m_image; } | |
| 121 | |
| 122 const LengthSize& topLeft() const { return m_topLeft; } | |
| 123 const LengthSize& topRight() const { return m_topRight; } | |
| 124 const LengthSize& bottomLeft() const { return m_bottomLeft; } | |
| 125 const LengthSize& bottomRight() const { return m_bottomRight; } | |
| 126 | |
| 127 private: | |
| 128 BorderValue m_left; | |
| 129 BorderValue m_right; | |
| 130 BorderValue m_top; | |
| 131 BorderValue m_bottom; | |
| 132 | |
| 133 NinePieceImage m_image; | |
| 134 | |
| 135 LengthSize m_topLeft; | |
| 136 LengthSize m_topRight; | |
| 137 LengthSize m_bottomLeft; | |
| 138 LengthSize m_bottomRight; | |
| 139 }; | |
| 140 | |
| 141 } // namespace blink | |
| 142 | |
| 143 #endif // BorderData_h | |
| OLD | NEW |