1 | /* |
2 | * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 | * Copyright (C) 2004, 2005, 2006, 2008, 2013 Apple Inc. All rights reserved. |
4 | * Copyright (C) 2013 Intel Corporation. All rights reserved. |
5 | * |
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. |
10 | * |
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. |
15 | * |
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. |
20 | */ |
21 | |
22 | #pragma once |
23 | |
24 | #include "CSSPropertyNames.h" |
25 | #include <wtf/Vector.h> |
26 | |
27 | namespace WebCore { |
28 | |
29 | class StylePropertyShorthand { |
30 | public: |
31 | StylePropertyShorthand() = default; |
32 | |
33 | template<unsigned numProperties> |
34 | StylePropertyShorthand(CSSPropertyID id, const CSSPropertyID (&properties)[numProperties], const StylePropertyShorthand* propertiesForInitialization = nullptr) |
35 | : m_properties(properties) |
36 | , m_propertiesForInitialization(propertiesForInitialization) |
37 | , m_length(numProperties) |
38 | , m_shorthandID(id) |
39 | { |
40 | } |
41 | |
42 | const CSSPropertyID* properties() const { return m_properties; } |
43 | const StylePropertyShorthand* propertiesForInitialization() const { return m_propertiesForInitialization; } |
44 | unsigned length() const { return m_length; } |
45 | CSSPropertyID id() const { return m_shorthandID; } |
46 | |
47 | private: |
48 | const CSSPropertyID* m_properties { nullptr }; |
49 | const StylePropertyShorthand* m_propertiesForInitialization { nullptr }; |
50 | unsigned m_length { 0 }; |
51 | CSSPropertyID m_shorthandID { CSSPropertyInvalid }; |
52 | }; |
53 | |
54 | // Custom StylePropertyShorthand functions. |
55 | StylePropertyShorthand animationShorthandForParsing(); |
56 | StylePropertyShorthand transitionShorthandForParsing(); |
57 | StylePropertyShorthand borderAbridgedShorthand(); |
58 | |
59 | // Returns empty value if the property is not a shorthand. |
60 | // The implementation is generated in StylePropertyShorthandFunctions.cpp. |
61 | StylePropertyShorthand shorthandForProperty(CSSPropertyID); |
62 | |
63 | // Return the list of shorthands for a given longhand. |
64 | // The implementation is generated in StylePropertyShorthandFunctions.cpp. |
65 | using StylePropertyShorthandVector = Vector<StylePropertyShorthand, 4>; |
66 | StylePropertyShorthandVector matchingShorthandsForLonghand(CSSPropertyID); |
67 | |
68 | unsigned indexOfShorthandForLonghand(CSSPropertyID, const StylePropertyShorthandVector&); |
69 | |
70 | bool isShorthandCSSProperty(CSSPropertyID); |
71 | |
72 | } // namespace WebCore |
73 | |