OSDN Git Service

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