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

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

Issue 16161005: Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used inside a ImmutableSty… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 * 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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 } 1401 }
1402 1402
1403 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit) 1403 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit)
1404 { 1404 {
1405 RefPtr<CSSValue> val = value.get(); 1405 RefPtr<CSSValue> val = value.get();
1406 addProperty(propId, value, important, implicit); 1406 addProperty(propId, value, important, implicit);
1407 1407
1408 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); 1408 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId);
1409 if (prefixingVariant == propId) 1409 if (prefixingVariant == propId)
1410 return; 1410 return;
1411 addProperty(prefixingVariant, val.release(), important, implicit); 1411
1412 if (m_currentShorthand) {
1413 // We can't use ShorthandScope here as we can already be inside one (e.g we are parsing CSSTransition).
1414 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
1415 addProperty(prefixingVariant, val.release(), important, implicit);
1416 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
1417 } else {
1418 addProperty(prefixingVariant, val.release(), important, implicit);
1419 }
1412 } 1420 }
1413 1421
1414 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bo ol important, bool implicit) 1422 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bo ol important, bool implicit)
1415 { 1423 {
1416 m_parsedProperties.append(CSSProperty(propId, value, important, m_currentSho rthand, m_implicitShorthand || implicit)); 1424 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value.get()) : 0;
1425 // This property doesn't belong to a shorthand or is a CSS variable (which w ill be resolved later).
1426 if (!m_currentShorthand || (primitiveValue && primitiveValue->isVariableName ())) {
1427 m_parsedProperties.append(CSSProperty(propId, value, important, false, C SSPropertyInvalid, m_implicitShorthand || implicit));
1428 return;
1429 }
1430
1431 const Vector<StylePropertyShorthand> shorthands = matchingShorthandsForLongh and(propId);
1432 // The longhand does not belong to multiple shorthands.
1433 if (shorthands.size() == 1)
1434 m_parsedProperties.append(CSSProperty(propId, value, important, true, CS SPropertyInvalid, m_implicitShorthand || implicit));
1435 else
1436 m_parsedProperties.append(CSSProperty(propId, value, important, true, in dexOfShorthandForLonghand(m_currentShorthand, shorthands), m_implicitShorthand | | implicit));
1417 } 1437 }
1418 1438
1419 void CSSParser::rollbackLastProperties(int num) 1439 void CSSParser::rollbackLastProperties(int num)
1420 { 1440 {
1421 ASSERT(num >= 0); 1441 ASSERT(num >= 0);
1422 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); 1442 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num));
1423 m_parsedProperties.shrink(m_parsedProperties.size() - num); 1443 m_parsedProperties.shrink(m_parsedProperties.size() - num);
1424 } 1444 }
1425 1445
1426 void CSSParser::clearProperties() 1446 void CSSParser::clearProperties()
(...skipping 10377 matching lines...) Expand 10 before | Expand all | Expand 10 after
11804 { 11824 {
11805 // The tokenizer checks for the construct of an+b. 11825 // The tokenizer checks for the construct of an+b.
11806 // However, since the {ident} rule precedes the {nth} rule, some of those 11826 // However, since the {ident} rule precedes the {nth} rule, some of those
11807 // tokens are identified as string literal. Furthermore we need to accept 11827 // tokens are identified as string literal. Furthermore we need to accept
11808 // "odd" and "even" which does not match to an+b. 11828 // "odd" and "even" which does not match to an+b.
11809 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11829 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11810 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11830 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11811 } 11831 }
11812 11832
11813 } 11833 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698