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

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

Issue 16020007: CSSParser should return ImmutableStylePropertySets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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
« no previous file with comments | « Source/core/css/CSSParser.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 * 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 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 { 1291 {
1292 m_selectorListForParseSelector = &selectorList; 1292 m_selectorListForParseSelector = &selectorList;
1293 1293
1294 setupParser("@-internal-selector{", string, "}"); 1294 setupParser("@-internal-selector{", string, "}");
1295 1295
1296 cssyyparse(this); 1296 cssyyparse(this);
1297 1297
1298 m_selectorListForParseSelector = 0; 1298 m_selectorListForParseSelector = 0;
1299 } 1299 }
1300 1300
1301 PassRefPtr<StylePropertySet> CSSParser::parseInlineStyleDeclaration(const String & string, Element* element) 1301 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(con st String& string, Element* element)
1302 { 1302 {
1303 Document* document = element->document(); 1303 Document* document = element->document();
1304 CSSParserContext context = document->elementSheet()->contents()->parserConte xt(); 1304 CSSParserContext context = document->elementSheet()->contents()->parserConte xt();
1305 context.mode = strictToCSSParserMode(element->isHTMLElement() && !document-> inQuirksMode()); 1305 context.mode = strictToCSSParserMode(element->isHTMLElement() && !document-> inQuirksMode());
1306 return CSSParser(context, UseCounter::getFrom(document)).parseDeclaration(st ring, document->elementSheet()->contents()); 1306 return CSSParser(context, UseCounter::getFrom(document)).parseDeclaration(st ring, document->elementSheet()->contents());
1307 } 1307 }
1308 1308
1309 PassRefPtr<StylePropertySet> CSSParser::parseDeclaration(const String& string, S tyleSheetContents* contextStyleSheet) 1309 PassRefPtr<ImmutableStylePropertySet> CSSParser::parseDeclaration(const String& string, StyleSheetContents* contextStyleSheet)
1310 { 1310 {
1311 setStyleSheet(contextStyleSheet); 1311 setStyleSheet(contextStyleSheet);
1312 1312
1313 setupParser("@-internal-decls{", string, "} "); 1313 setupParser("@-internal-decls{", string, "} ");
1314 cssyyparse(this); 1314 cssyyparse(this);
1315 m_rule = 0; 1315 m_rule = 0;
1316 1316
1317 if (m_hasFontFaceOnlyValues) 1317 if (m_hasFontFaceOnlyValues)
1318 deleteFontFaceOnlyValues(); 1318 deleteFontFaceOnlyValues();
1319 1319
1320 RefPtr<StylePropertySet> style = createStylePropertySet(); 1320 RefPtr<ImmutableStylePropertySet> style = createStylePropertySet();
1321 clearProperties(); 1321 clearProperties();
1322 return style.release(); 1322 return style.release();
1323 } 1323 }
1324 1324
1325 1325
1326 bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& st ring, SourceDataHandler* sourceDataHandler, StyleSheetContents* contextStyleShee t) 1326 bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& st ring, SourceDataHandler* sourceDataHandler, StyleSheetContents* contextStyleShee t)
1327 { 1327 {
1328 setStyleSheet(contextStyleSheet); 1328 setStyleSheet(contextStyleSheet);
1329 1329
1330 m_sourceDataHandler = sourceDataHandler; 1330 m_sourceDataHandler = sourceDataHandler;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 continue; 1385 continue;
1386 } 1386 }
1387 const unsigned propertyIDIndex = property.id() - firstCSSProperty; 1387 const unsigned propertyIDIndex = property.id() - firstCSSProperty;
1388 if (seenProperties.get(propertyIDIndex)) 1388 if (seenProperties.get(propertyIDIndex))
1389 continue; 1389 continue;
1390 seenProperties.set(propertyIDIndex); 1390 seenProperties.set(propertyIDIndex);
1391 output[--unusedEntries] = property; 1391 output[--unusedEntries] = property;
1392 } 1392 }
1393 } 1393 }
1394 1394
1395 PassRefPtr<StylePropertySet> CSSParser::createStylePropertySet() 1395 PassRefPtr<ImmutableStylePropertySet> CSSParser::createStylePropertySet()
1396 { 1396 {
1397 BitArray<numCSSProperties> seenProperties; 1397 BitArray<numCSSProperties> seenProperties;
1398 size_t unusedEntries = m_parsedProperties.size(); 1398 size_t unusedEntries = m_parsedProperties.size();
1399 Vector<CSSProperty, 256> results(unusedEntries); 1399 Vector<CSSProperty, 256> results(unusedEntries);
1400 1400
1401 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found. 1401 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found.
1402 HashSet<AtomicString> seenVariables; 1402 HashSet<AtomicString> seenVariables;
1403 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables); 1403 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables);
1404 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables); 1404 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables);
1405 if (unusedEntries) 1405 if (unusedEntries)
(...skipping 10331 matching lines...) Expand 10 before | Expand all | Expand 10 after
11737 { 11737 {
11738 // The tokenizer checks for the construct of an+b. 11738 // The tokenizer checks for the construct of an+b.
11739 // However, since the {ident} rule precedes the {nth} rule, some of those 11739 // However, since the {ident} rule precedes the {nth} rule, some of those
11740 // tokens are identified as string literal. Furthermore we need to accept 11740 // tokens are identified as string literal. Furthermore we need to accept
11741 // "odd" and "even" which does not match to an+b. 11741 // "odd" and "even" which does not match to an+b.
11742 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11742 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11743 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11743 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11744 } 11744 }
11745 11745
11746 } 11746 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698