OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 | 1217 |
1218 // can't use { because tokenizer state switches from mediaquery to initial s
tate when it sees { token. | 1218 // can't use { because tokenizer state switches from mediaquery to initial s
tate when it sees { token. |
1219 // instead insert one " " (which is caught by maybe_space in CSSGrammar.y) | 1219 // instead insert one " " (which is caught by maybe_space in CSSGrammar.y) |
1220 setupParser("@-internal-medialist ", string, ""); | 1220 setupParser("@-internal-medialist ", string, ""); |
1221 cssyyparse(this); | 1221 cssyyparse(this); |
1222 | 1222 |
1223 ASSERT(m_mediaList); | 1223 ASSERT(m_mediaList); |
1224 return m_mediaList.release(); | 1224 return m_mediaList.release(); |
1225 } | 1225 } |
1226 | 1226 |
1227 static inline void filterProperties(bool important, const CSSPropertyParser::Par
sedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntrie
s, BitArray<numCSSProperties>& seenProperties) | 1227 static inline void filterProperties(bool important, const WillBeHeapVector<CSSPr
operty, 256>& input, WillBeHeapVector<CSSProperty, 256>& output, size_t& unusedE
ntries, BitArray<numCSSProperties>& seenProperties) |
1228 { | 1228 { |
1229 // Add properties in reverse order so that highest priority definitions are
reached first. Duplicate definitions can then be ignored when found. | 1229 // Add properties in reverse order so that highest priority definitions are
reached first. Duplicate definitions can then be ignored when found. |
1230 for (int i = input.size() - 1; i >= 0; --i) { | 1230 for (int i = input.size() - 1; i >= 0; --i) { |
1231 const CSSProperty& property = input[i]; | 1231 const CSSProperty& property = input[i]; |
1232 if (property.isImportant() != important) | 1232 if (property.isImportant() != important) |
1233 continue; | 1233 continue; |
1234 const unsigned propertyIDIndex = property.id() - firstCSSProperty; | 1234 const unsigned propertyIDIndex = property.id() - firstCSSProperty; |
1235 if (seenProperties.get(propertyIDIndex)) | 1235 if (seenProperties.get(propertyIDIndex)) |
1236 continue; | 1236 continue; |
1237 seenProperties.set(propertyIDIndex); | 1237 seenProperties.set(propertyIDIndex); |
1238 output[--unusedEntries] = property; | 1238 output[--unusedEntries] = property; |
1239 } | 1239 } |
1240 } | 1240 } |
1241 | 1241 |
1242 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::createStylePropertySet() | 1242 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::createStylePropertySet() |
1243 { | 1243 { |
1244 BitArray<numCSSProperties> seenProperties; | 1244 BitArray<numCSSProperties> seenProperties; |
1245 size_t unusedEntries = m_parsedProperties.size(); | 1245 size_t unusedEntries = m_parsedProperties.size(); |
1246 Vector<CSSProperty, 256> results(unusedEntries); | 1246 WillBeHeapVector<CSSProperty, 256> results(unusedEntries); |
1247 | 1247 |
1248 // Important properties have higher priority, so add them first. Duplicate d
efinitions can then be ignored when found. | 1248 // Important properties have higher priority, so add them first. Duplicate d
efinitions can then be ignored when found. |
1249 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope
rties); | 1249 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope
rties); |
1250 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp
erties); | 1250 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp
erties); |
1251 if (unusedEntries) | 1251 if (unusedEntries) |
1252 results.remove(0, unusedEntries); | 1252 results.remove(0, unusedEntries); |
1253 | 1253 |
1254 CSSParserMode mode = inViewport() ? CSSViewportRuleMode : m_context.mode(); | 1254 CSSParserMode mode = inViewport() ? CSSViewportRuleMode : m_context.mode(); |
1255 | 1255 |
1256 return ImmutableStylePropertySet::create(results.data(), results.size(), mod
e); | 1256 return ImmutableStylePropertySet::create(results.data(), results.size(), mod
e); |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2219 rule->setProperties(createStylePropertySet()); | 2219 rule->setProperties(createStylePropertySet()); |
2220 clearProperties(); | 2220 clearProperties(); |
2221 | 2221 |
2222 StyleRuleViewport* result = rule.get(); | 2222 StyleRuleViewport* result = rule.get(); |
2223 m_parsedRules.append(rule.release()); | 2223 m_parsedRules.append(rule.release()); |
2224 | 2224 |
2225 return result; | 2225 return result; |
2226 } | 2226 } |
2227 | 2227 |
2228 } | 2228 } |
OLD | NEW |