2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
25 #include "CSSPropertyNames.h"
27 #include "RenderStyleConstants.h"
28 #include "TextDirection.h"
29 #include "WritingMode.h"
30 #include <wtf/PassRefPtr.h>
31 #include <wtf/RefPtr.h>
35 struct StylePropertyMetadata {
36 StylePropertyMetadata(CSSPropertyID propertyID, bool isSetFromShorthand, int indexInShorthandsVector, bool important, bool implicit, bool inherited)
37 : m_propertyID(propertyID)
38 , m_isSetFromShorthand(isSetFromShorthand)
39 , m_indexInShorthandsVector(indexInShorthandsVector)
40 , m_important(important)
41 , m_implicit(implicit)
42 , m_inherited(inherited)
46 CSSPropertyID shorthandID() const;
48 uint16_t m_propertyID : 10;
49 uint16_t m_isSetFromShorthand : 1;
50 uint16_t m_indexInShorthandsVector : 2; // If this property was set as part of an ambiguous shorthand, gives the index in the shorthands vector.
51 uint16_t m_important : 1;
52 uint16_t m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
53 uint16_t m_inherited : 1;
58 CSSProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> value, bool important = false, bool isSetFromShorthand = false, int indexInShorthandsVector = 0, bool implicit = false)
59 : m_metadata(propertyID, isSetFromShorthand, indexInShorthandsVector, important, implicit, isInheritedProperty(propertyID))
64 // FIXME: Remove this.
65 CSSProperty(StylePropertyMetadata metadata, CSSValue* value)
66 : m_metadata(metadata)
71 CSSPropertyID id() const { return static_cast<CSSPropertyID>(m_metadata.m_propertyID); }
72 bool isSetFromShorthand() const { return m_metadata.m_isSetFromShorthand; };
73 CSSPropertyID shorthandID() const { return m_metadata.shorthandID(); };
74 bool isImportant() const { return m_metadata.m_important; }
76 CSSValue* value() const { return m_value.get(); }
78 void wrapValueInCommaSeparatedList();
80 static CSSPropertyID resolveDirectionAwareProperty(CSSPropertyID, TextDirection, WritingMode);
81 static bool isInheritedProperty(CSSPropertyID);
83 const StylePropertyMetadata& metadata() const { return m_metadata; }
86 StylePropertyMetadata m_metadata;
87 RefPtr<CSSValue> m_value;
90 inline CSSPropertyID prefixingVariantForPropertyId(CSSPropertyID propId)
92 CSSPropertyID propertyId = CSSPropertyInvalid;
94 case CSSPropertyTransitionDelay:
95 propertyId = CSSPropertyWebkitTransitionDelay;
97 case CSSPropertyTransitionDuration:
98 propertyId = CSSPropertyWebkitTransitionDuration;
100 case CSSPropertyTransitionProperty:
101 propertyId = CSSPropertyWebkitTransitionProperty;
103 case CSSPropertyTransitionTimingFunction:
104 propertyId = CSSPropertyWebkitTransitionTimingFunction;
106 case CSSPropertyTransition:
107 propertyId = CSSPropertyWebkitTransition;
109 case CSSPropertyWebkitTransitionDelay:
110 propertyId = CSSPropertyTransitionDelay;
112 case CSSPropertyWebkitTransitionDuration:
113 propertyId = CSSPropertyTransitionDuration;
115 case CSSPropertyWebkitTransitionProperty:
116 propertyId = CSSPropertyTransitionProperty;
118 case CSSPropertyWebkitTransitionTimingFunction:
119 propertyId = CSSPropertyTransitionTimingFunction;
121 case CSSPropertyWebkitTransition:
122 propertyId = CSSPropertyTransition;
128 ASSERT(propertyId != CSSPropertyInvalid);
132 } // namespace WebCore
135 template <> struct VectorTraits<WebCore::CSSProperty> : VectorTraitsBase<false, WebCore::CSSProperty> {
136 static const bool canInitializeWithMemset = true;
137 static const bool canMoveWithMemcpy = true;
141 #endif // CSSProperty_h