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

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
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/CSSProperty.h » ('j') | 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 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 } 1387 }
1388 1388
1389 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit) 1389 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit)
1390 { 1390 {
1391 RefPtr<CSSValue> val = value.get(); 1391 RefPtr<CSSValue> val = value.get();
1392 addProperty(propId, value, important, implicit); 1392 addProperty(propId, value, important, implicit);
1393 1393
1394 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); 1394 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId);
1395 if (prefixingVariant == propId) 1395 if (prefixingVariant == propId)
1396 return; 1396 return;
1397 addProperty(prefixingVariant, val.release(), important, implicit); 1397
1398 if (m_currentShorthand) {
1399 // We can't use ShorthandScope here as we can already be inside one (e.g we are parsing CSSTransition).
1400 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
1401 addProperty(prefixingVariant, val.release(), important, implicit);
1402 m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
1403 } else {
1404 addProperty(prefixingVariant, val.release(), important, implicit);
1405 }
1398 } 1406 }
1399 1407
1400 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bo ol important, bool implicit) 1408 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bo ol important, bool implicit)
1401 { 1409 {
1402 m_parsedProperties.append(CSSProperty(propId, value, important, m_currentSho rthand, m_implicitShorthand || implicit)); 1410 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value.get()) : 0;
1411 // This property doesn't belong to a shorthand or is a CSS variable (which w ill be resolved later).
1412 if (!m_currentShorthand || (primitiveValue && primitiveValue->isVariableName ())) {
1413 m_parsedProperties.append(CSSProperty(propId, value, important, false, C SSPropertyInvalid, m_implicitShorthand || implicit));
1414 return;
1415 }
1416
1417 const Vector<StylePropertyShorthand> shorthands = matchingShorthandsForLongh and(propId);
1418 // The longhand does not belong to multiple shorthands.
1419 if (shorthands.size() == 1)
1420 m_parsedProperties.append(CSSProperty(propId, value, important, true, CS SPropertyInvalid, m_implicitShorthand || implicit));
1421 else
1422 m_parsedProperties.append(CSSProperty(propId, value, important, true, in dexOfShorthandForLonghand(m_currentShorthand, shorthands), m_implicitShorthand | | implicit));
1403 } 1423 }
1404 1424
1405 void CSSParser::rollbackLastProperties(int num) 1425 void CSSParser::rollbackLastProperties(int num)
1406 { 1426 {
1407 ASSERT(num >= 0); 1427 ASSERT(num >= 0);
1408 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); 1428 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num));
1409 m_parsedProperties.shrink(m_parsedProperties.size() - num); 1429 m_parsedProperties.shrink(m_parsedProperties.size() - num);
1410 } 1430 }
1411 1431
1412 void CSSParser::clearProperties() 1432 void CSSParser::clearProperties()
(...skipping 10355 matching lines...) Expand 10 before | Expand all | Expand 10 after
11768 { 11788 {
11769 // The tokenizer checks for the construct of an+b. 11789 // The tokenizer checks for the construct of an+b.
11770 // However, since the {ident} rule precedes the {nth} rule, some of those 11790 // However, since the {ident} rule precedes the {nth} rule, some of those
11771 // tokens are identified as string literal. Furthermore we need to accept 11791 // tokens are identified as string literal. Furthermore we need to accept
11772 // "odd" and "even" which does not match to an+b. 11792 // "odd" and "even" which does not match to an+b.
11773 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11793 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11774 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11794 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11775 } 11795 }
11776 11796
11777 } 11797 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/CSSProperty.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698