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

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

Issue 1278143002: Oilpan: tidy StylePropertySerializer's handling of GCed objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « Source/core/css/StylePropertySerializer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
(...skipping 22 matching lines...) Expand all
33 namespace blink { 33 namespace blink {
34 34
35 static bool isInitialOrInherit(const String& value) 35 static bool isInitialOrInherit(const String& value)
36 { 36 {
37 DEFINE_STATIC_LOCAL(String, initial, ("initial")); 37 DEFINE_STATIC_LOCAL(String, initial, ("initial"));
38 DEFINE_STATIC_LOCAL(String, inherit, ("inherit")); 38 DEFINE_STATIC_LOCAL(String, inherit, ("inherit"));
39 return value.length() == 7 && (value == initial || value == inherit); 39 return value.length() == 7 && (value == initial || value == inherit);
40 } 40 }
41 41
42 StylePropertySerializer::StylePropertySetForSerializer::StylePropertySetForSeria lizer(const StylePropertySet& properties) 42 StylePropertySerializer::StylePropertySetForSerializer::StylePropertySetForSeria lizer(const StylePropertySet& properties)
43 : m_propertySet(properties) 43 : m_propertySet(&properties)
44 , m_allIndex(m_propertySet.findPropertyIndex(CSSPropertyAll)) 44 , m_allIndex(m_propertySet->findPropertyIndex(CSSPropertyAll))
45 , m_needToExpandAll(false) 45 , m_needToExpandAll(false)
46 { 46 {
47 if (!hasAllProperty()) 47 if (!hasAllProperty())
48 return; 48 return;
49 49
50 StylePropertySet::PropertyReference allProperty = m_propertySet.propertyAt(m _allIndex); 50 StylePropertySet::PropertyReference allProperty = m_propertySet->propertyAt( m_allIndex);
51 for (unsigned i = 0; i < m_propertySet.propertyCount(); ++i) { 51 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) {
52 StylePropertySet::PropertyReference property = m_propertySet.propertyAt( i); 52 StylePropertySet::PropertyReference property = m_propertySet->propertyAt (i);
53 if (CSSProperty::isAffectedByAllProperty(property.id())) { 53 if (CSSProperty::isAffectedByAllProperty(property.id())) {
54 if (allProperty.isImportant() && !property.isImportant()) 54 if (allProperty.isImportant() && !property.isImportant())
55 continue; 55 continue;
56 if (static_cast<unsigned>(m_allIndex) >= i) 56 if (static_cast<unsigned>(m_allIndex) >= i)
57 continue; 57 continue;
58 if (property.value()->equals(*allProperty.value()) 58 if (property.value()->equals(*allProperty.value())
59 && property.isImportant() == allProperty.isImportant()) 59 && property.isImportant() == allProperty.isImportant())
60 continue; 60 continue;
61 m_needToExpandAll = true; 61 m_needToExpandAll = true;
62 } 62 }
63 m_longhandPropertyUsed.set(property.id() - firstCSSProperty); 63 m_longhandPropertyUsed.set(property.id() - firstCSSProperty);
64 } 64 }
65 } 65 }
66 66
67 DEFINE_TRACE(StylePropertySerializer::StylePropertySetForSerializer)
68 {
69 visitor->trace(m_propertySet);
70 }
71
67 unsigned StylePropertySerializer::StylePropertySetForSerializer::propertyCount() const 72 unsigned StylePropertySerializer::StylePropertySetForSerializer::propertyCount() const
68 { 73 {
69 if (!hasExpandedAllProperty()) 74 if (!hasExpandedAllProperty())
70 return m_propertySet.propertyCount(); 75 return m_propertySet->propertyCount();
71 return lastCSSProperty - firstCSSProperty + 1; 76 return lastCSSProperty - firstCSSProperty + 1;
72 } 77 }
73 78
74 StylePropertySerializer::PropertyValueForSerializer StylePropertySerializer::Sty lePropertySetForSerializer::propertyAt(unsigned index) const 79 StylePropertySerializer::PropertyValueForSerializer StylePropertySerializer::Sty lePropertySetForSerializer::propertyAt(unsigned index) const
75 { 80 {
76 if (!hasExpandedAllProperty()) 81 if (!hasExpandedAllProperty())
77 return StylePropertySerializer::PropertyValueForSerializer(m_propertySet .propertyAt(index)); 82 return StylePropertySerializer::PropertyValueForSerializer(m_propertySet ->propertyAt(index));
78 83
79 CSSPropertyID propertyID = static_cast<CSSPropertyID>(index + firstCSSProper ty); 84 CSSPropertyID propertyID = static_cast<CSSPropertyID>(index + firstCSSProper ty);
80 ASSERT(firstCSSProperty <= propertyID && propertyID <= lastCSSProperty); 85 ASSERT(firstCSSProperty <= propertyID && propertyID <= lastCSSProperty);
81 if (m_longhandPropertyUsed.get(index)) { 86 if (m_longhandPropertyUsed.get(index)) {
82 int index = m_propertySet.findPropertyIndex(propertyID); 87 int index = m_propertySet->findPropertyIndex(propertyID);
83 ASSERT(index != -1); 88 ASSERT(index != -1);
84 return StylePropertySerializer::PropertyValueForSerializer(m_propertySet .propertyAt(index)); 89 return StylePropertySerializer::PropertyValueForSerializer(m_propertySet ->propertyAt(index));
85 } 90 }
86 91
87 StylePropertySet::PropertyReference property = m_propertySet.propertyAt(m_al lIndex); 92 StylePropertySet::PropertyReference property = m_propertySet->propertyAt(m_a llIndex);
88 return StylePropertySerializer::PropertyValueForSerializer(propertyID, prope rty.value(), property.isImportant()); 93 return StylePropertySerializer::PropertyValueForSerializer(propertyID, prope rty.value(), property.isImportant());
89 } 94 }
90 95
91 bool StylePropertySerializer::StylePropertySetForSerializer::shouldProcessProper tyAt(unsigned index) const 96 bool StylePropertySerializer::StylePropertySetForSerializer::shouldProcessProper tyAt(unsigned index) const
92 { 97 {
93 // StylePropertySet has all valid longhands. We should process. 98 // StylePropertySet has all valid longhands. We should process.
94 if (!hasAllProperty()) 99 if (!hasAllProperty())
95 return true; 100 return true;
96 101
97 // If all is not expanded, we need to process "all" and properties which 102 // If all is not expanded, we need to process "all" and properties which
98 // are not overwritten by "all". 103 // are not overwritten by "all".
99 if (!m_needToExpandAll) { 104 if (!m_needToExpandAll) {
100 StylePropertySet::PropertyReference property = m_propertySet.propertyAt( index); 105 StylePropertySet::PropertyReference property = m_propertySet->propertyAt (index);
101 if (property.id() == CSSPropertyAll || !CSSProperty::isAffectedByAllProp erty(property.id())) 106 if (property.id() == CSSPropertyAll || !CSSProperty::isAffectedByAllProp erty(property.id()))
102 return true; 107 return true;
103 return m_longhandPropertyUsed.get(property.id() - firstCSSProperty); 108 return m_longhandPropertyUsed.get(property.id() - firstCSSProperty);
104 } 109 }
105 110
106 CSSPropertyID propertyID = static_cast<CSSPropertyID>(index + firstCSSProper ty); 111 CSSPropertyID propertyID = static_cast<CSSPropertyID>(index + firstCSSProper ty);
107 ASSERT(firstCSSProperty <= propertyID && propertyID <= lastCSSProperty); 112 ASSERT(firstCSSProperty <= propertyID && propertyID <= lastCSSProperty);
108 113
109 // Since "all" is expanded, we don't need to process "all". 114 // Since "all" is expanded, we don't need to process "all".
110 // We should not process expanded shorthands (e.g. font, background, 115 // We should not process expanded shorthands (e.g. font, background,
111 // and so on) either. 116 // and so on) either.
112 if (isShorthandProperty(propertyID) || propertyID == CSSPropertyAll) 117 if (isShorthandProperty(propertyID) || propertyID == CSSPropertyAll)
113 return false; 118 return false;
114 119
115 // The all property is a shorthand that resets all CSS properties except 120 // The all property is a shorthand that resets all CSS properties except
116 // direction and unicode-bidi. It only accepts the CSS-wide keywords. 121 // direction and unicode-bidi. It only accepts the CSS-wide keywords.
117 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand 122 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand
118 if (!CSSProperty::isAffectedByAllProperty(propertyID)) 123 if (!CSSProperty::isAffectedByAllProperty(propertyID))
119 return m_longhandPropertyUsed.get(index); 124 return m_longhandPropertyUsed.get(index);
120 125
121 return true; 126 return true;
122 } 127 }
123 128
124 int StylePropertySerializer::StylePropertySetForSerializer::findPropertyIndex(CS SPropertyID propertyID) const 129 int StylePropertySerializer::StylePropertySetForSerializer::findPropertyIndex(CS SPropertyID propertyID) const
125 { 130 {
126 if (!hasExpandedAllProperty()) 131 if (!hasExpandedAllProperty())
127 return m_propertySet.findPropertyIndex(propertyID); 132 return m_propertySet->findPropertyIndex(propertyID);
128 return propertyID - firstCSSProperty; 133 return propertyID - firstCSSProperty;
129 } 134 }
130 135
131 const CSSValue* StylePropertySerializer::StylePropertySetForSerializer::getPrope rtyCSSValue(CSSPropertyID propertyID) const 136 const CSSValue* StylePropertySerializer::StylePropertySetForSerializer::getPrope rtyCSSValue(CSSPropertyID propertyID) const
132 { 137 {
133 int index = findPropertyIndex(propertyID); 138 int index = findPropertyIndex(propertyID);
134 if (index == -1) 139 if (index == -1)
135 return 0; 140 return 0;
136 StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index ); 141 StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index );
137 return value.value(); 142 return value.value();
138 } 143 }
139 144
140 String StylePropertySerializer::StylePropertySetForSerializer::getPropertyValue( CSSPropertyID propertyID) const 145 String StylePropertySerializer::StylePropertySetForSerializer::getPropertyValue( CSSPropertyID propertyID) const
141 { 146 {
142 if (!hasExpandedAllProperty()) 147 if (!hasExpandedAllProperty())
143 return m_propertySet.getPropertyValue(propertyID); 148 return m_propertySet->getPropertyValue(propertyID);
144 149
145 const CSSValue* value = getPropertyCSSValue(propertyID); 150 const CSSValue* value = getPropertyCSSValue(propertyID);
146 if (!value) 151 if (!value)
147 return String(); 152 return String();
148 return value->cssText(); 153 return value->cssText();
149 } 154 }
150 155
151 bool StylePropertySerializer::StylePropertySetForSerializer::isPropertyImplicit( CSSPropertyID propertyID) const 156 bool StylePropertySerializer::StylePropertySetForSerializer::isPropertyImplicit( CSSPropertyID propertyID) const
152 { 157 {
153 int index = findPropertyIndex(propertyID); 158 int index = findPropertyIndex(propertyID);
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 isInitialValue = false; 969 isInitialValue = false;
965 if (!value->isInheritedValue()) 970 if (!value->isInheritedValue())
966 isInheritedValue = false; 971 isInheritedValue = false;
967 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i])) 972 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i]))
968 return false; 973 return false;
969 } 974 }
970 return isInitialValue || isInheritedValue; 975 return isInitialValue || isInheritedValue;
971 } 976 }
972 977
973 } 978 }
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySerializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698