1 /* 2 * (C) 1999-2003 Lars Knoll (knoll (at) kde.org) 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef CSSProperty_h 22 #define CSSProperty_h 23 24 #include "CSSValue.h" 25 #include <wtf/PassRefPtr.h> 26 #include <wtf/RefPtr.h> 27 28 namespace WebCore { 29 30 class CSSProperty : public FastAllocBase { 31 public: 32 CSSProperty(int propID, PassRefPtr<CSSValue> value, bool important = false, int shorthandID = 0, bool implicit = false) 33 : m_id(propID) 34 , m_shorthandID(shorthandID) 35 , m_important(important) 36 , m_implicit(implicit) 37 , m_value(value) 38 { 39 } 40 41 CSSProperty& operator=(const CSSProperty& other) 42 { 43 m_id = other.m_id; 44 m_shorthandID = other.m_shorthandID; 45 m_important = other.m_important; 46 m_implicit = other.m_implicit; 47 m_value = other.m_value; 48 return *this; 49 } 50 51 int id() const { return m_id; } 52 int shorthandID() const { return m_shorthandID; } 53 54 bool isImportant() const { return m_important; } 55 bool isImplicit() const { return m_implicit; } 56 57 CSSValue* value() const { return m_value.get(); } 58 59 String cssText() const; 60 61 friend bool operator==(const CSSProperty&, const CSSProperty&); 62 63 // Make sure the following fits in 4 bytes. Really. 64 int m_id : 15; 65 int m_shorthandID : 15; // If this property was set as part of a shorthand, gives the shorthand. 66 bool m_important : 1; 67 bool m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand. 68 69 RefPtr<CSSValue> m_value; 70 }; 71 72 } // namespace WebCore 73 74 namespace WTF { 75 // Properties in Vector can be initialized with memset and moved using memcpy. 76 template<> struct VectorTraits<WebCore::CSSProperty> : SimpleClassVectorTraits { }; 77 } 78 79 #endif // CSSProperty_h 80