Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: Source/core/css/StylePropertySerializer.h

Issue 341033003: StylePropertySerializer should expand all property if needed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. 5 * Copyright (C) 2013 Intel Corporation. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 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 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, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #ifndef StylePropertySerializer_h 23 #ifndef StylePropertySerializer_h
24 #define StylePropertySerializer_h 24 #define StylePropertySerializer_h
25 25
26 #include "core/css/CSSValueList.h" 26 #include "core/css/CSSValueList.h"
27 #include "core/css/StylePropertySet.h" 27 #include "core/css/StylePropertySet.h"
28 #include "wtf/BitArray.h"
28 29
29 namespace blink { 30 namespace blink {
30 31
31 class StylePropertySet; 32 class StylePropertySet;
32 33
34 class PropertyValueForSerializer {
esprehn 2014/09/02 19:41:57 Put this in its own file.
tasak 2014/09/04 06:08:38 I put this into class StylePropertySerializer, bec
35 public:
36 PropertyValueForSerializer(StylePropertySet::PropertyReference property)
esprehn 2014/09/02 19:41:56 explicit
tasak 2014/09/04 06:08:38 Done.
37 : m_id(property.id())
38 , m_value(property.value())
39 , m_isImportant(property.isImportant())
40 , m_isImplicit(property.isImplicit())
41 , m_isInherited(property.isInherited()) { }
42
43 PropertyValueForSerializer(CSSPropertyID id, const CSSValue* value, bool isI mportant)
44 : m_id(id)
45 , m_value(value)
46 , m_isImportant(isImportant)
47 , m_isImplicit(value->isImplicitInitialValue())
48 , m_isInherited(value->isInheritedValue()) { }
49
50 CSSPropertyID id() const { return m_id; }
51 const CSSValue* value() const { return m_value; }
52 bool isImportant() const { return m_isImportant; }
53 bool isImplicit() const { return m_isImplicit; }
54 bool isInherited() const { return m_isInherited; }
55 bool isValid() const { return m_value; }
56
57 private:
58 CSSPropertyID m_id;
rune 2014/09/02 20:13:17 I think I would've put this member below m_value a
tasak 2014/09/04 06:08:38 Done.
59 const CSSValue* m_value;
60 bool m_isImportant;
61 bool m_isImplicit;
62 bool m_isInherited;
63 };
64
65 class StylePropertySetForSerializer {
esprehn 2014/09/02 19:41:57 ditto
tasak 2014/09/04 06:08:38 I put this into class StylePropertySerializer too.
66 public:
67 StylePropertySetForSerializer(const StylePropertySet&);
esprehn 2014/09/02 19:41:57 explicit
tasak 2014/09/04 06:08:38 Done.
68
69 unsigned propertyCount() const;
70 PropertyValueForSerializer propertyAt(unsigned index) const;
71 bool shouldProcessPropertyAt(unsigned index) const;
72 int findPropertyIndex(CSSPropertyID) const;
73 const CSSValue* getPropertyCSSValue(CSSPropertyID) const;
74 String getPropertyValue(CSSPropertyID) const;
75 bool isPropertyImplicit(CSSPropertyID) const;
76 bool propertyIsImportant(CSSPropertyID) const;
77
78 private:
79 bool hasExpandedAllProperty() const { return hasAllProperty() && m_needToExp andAll; }
80 bool hasAllProperty() const { return m_allIndex != -1; }
81
82 const StylePropertySet& m_propertySet;
83 int m_allIndex;
84 BitArray<numCSSProperties> m_longhandPropertyUsed;
85 bool m_needToExpandAll;
86 };
87
33 class StylePropertySerializer { 88 class StylePropertySerializer {
34 public: 89 public:
35 StylePropertySerializer(const StylePropertySet&); 90 StylePropertySerializer(const StylePropertySet&);
36 String asText() const; 91 String asText() const;
37 String getPropertyValue(CSSPropertyID) const; 92 String getPropertyValue(CSSPropertyID) const;
38 private: 93 private:
39 String getCommonValue(const StylePropertyShorthand&) const; 94 String getCommonValue(const StylePropertyShorthand&) const;
40 enum CommonValueMode { OmitUncommonValues, ReturnNullOnUncommonValues }; 95 enum CommonValueMode { OmitUncommonValues, ReturnNullOnUncommonValues };
41 String borderPropertyValue(CommonValueMode) const; 96 String borderPropertyValue(CommonValueMode) const;
42 String getLayeredShorthandValue(const StylePropertyShorthand&) const; 97 String getLayeredShorthandValue(const StylePropertyShorthand&) const;
43 String get4Values(const StylePropertyShorthand&) const; 98 String get4Values(const StylePropertyShorthand&) const;
44 String borderSpacingValue(const StylePropertyShorthand&) const; 99 String borderSpacingValue(const StylePropertyShorthand&) const;
45 String getShorthandValue(const StylePropertyShorthand&) const; 100 String getShorthandValue(const StylePropertyShorthand&) const;
46 String fontValue() const; 101 String fontValue() const;
47 void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result, String& value) const; 102 void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result, String& value) const;
48 String backgroundRepeatPropertyValue() const; 103 String backgroundRepeatPropertyValue() const;
49 String getPropertyText(CSSPropertyID, const String& value, bool isImportant, bool isNotFirstDecl) const; 104 String getPropertyText(CSSPropertyID, const String& value, bool isImportant, bool isNotFirstDecl) const;
50 bool isPropertyShorthandAvailable(const StylePropertyShorthand&) const; 105 bool isPropertyShorthandAvailable(const StylePropertyShorthand&) const;
51 bool shorthandHasOnlyInitialOrInheritedValue(const StylePropertyShorthand&) const; 106 bool shorthandHasOnlyInitialOrInheritedValue(const StylePropertyShorthand&) const;
52 void appendBackgroundPropertyAsText(StringBuilder& result, unsigned& numDecl s) const; 107 void appendBackgroundPropertyAsText(StringBuilder& result, unsigned& numDecl s) const;
53 108
54 const StylePropertySet& m_propertySet; 109 const StylePropertySetForSerializer m_propertySet;
55 }; 110 };
56 111
57 } // namespace blink 112 } // namespace blink
58 113
59 #endif 114 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698