1 /* 2 * Copyright (C) 2000 Lars Knoll (knoll (at) kde.org) 3 * (C) 2000 Antti Koivisto (koivisto (at) kde.org) 4 * (C) 2000 Dirk Mueller (mueller (at) kde.org) 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2006 Graham Dennis (graham.dennis (at) 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 CollapsedBorderValue_h 26 #define CollapsedBorderValue_h 27 28 #include "core/rendering/style/BorderValue.h" 29 30 namespace WebCore { 31 32 class CollapsedBorderValue { 33 public: 34 CollapsedBorderValue() 35 : m_color(0) 36 , m_colorIsValid(false) 37 , m_currentColor(false) 38 , m_width(0) 39 , m_style(BNONE) 40 , m_precedence(BOFF) 41 , m_transparent(false) 42 { 43 } 44 45 CollapsedBorderValue(const BorderValue& border, const StyleColor& color, EBorderPrecedence precedence) 46 : m_color(color.color()) 47 , m_colorIsValid(color.isValid()) 48 , m_currentColor(color.isCurrentColor()) 49 , m_width(border.nonZero() ? border.width() : 0) 50 , m_style(border.style()) 51 , m_precedence(precedence) 52 , m_transparent(border.isTransparent()) 53 { 54 } 55 56 unsigned width() const { return m_style > BHIDDEN ? m_width : 0; } 57 EBorderStyle style() const { return static_cast<EBorderStyle>(m_style); } 58 bool exists() const { return m_precedence != BOFF; } 59 StyleColor color() const { return StyleColor(m_color, m_colorIsValid, m_currentColor); } 60 bool isTransparent() const { return m_transparent; } 61 EBorderPrecedence precedence() const { return static_cast<EBorderPrecedence>(m_precedence); } 62 63 bool isSameIgnoringColor(const CollapsedBorderValue& o) const 64 { 65 return width() == o.width() && style() == o.style() && precedence() == o.precedence(); 66 } 67 68 private: 69 Color m_color; 70 unsigned m_colorIsValid : 1; 71 unsigned m_currentColor : 1; 72 unsigned m_width : 22; 73 unsigned m_style : 4; // EBorderStyle 74 unsigned m_precedence : 3; // EBorderPrecedence 75 unsigned m_transparent : 1; 76 }; 77 78 } // namespace WebCore 79 80 #endif // CollapsedBorderValue_h 81