Changeset 80463 in webkit


Ignore:
Timestamp:
Mar 7, 2011 3:19:12 AM (13 years ago)
Author:
Antti Koivisto
Message:

Source/WebCore: REGRESSION (r79574): fast/dom/global-constructors.html failing on Windows 7 Release (Tests) bots
https://bugs.webkit.org/show_bug.cgi?id=55166
<rdar://problem/9050430>

Reviewed by Oliver Hunt.

Make CSS primitive value cache per-document.

Test: http/tests/security/cross-origin-css-primitive.html

  • Android.mk:
  • CMakeLists.txt:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueForNinePieceImage):
(WebCore::zoomAdjustedPixelValue):
(WebCore::zoomAdjustedNumberValue):
(WebCore::zoomAdjustedPixelValueForLength):
(WebCore::valueForReflection):
(WebCore::getPositionOffsetValue):
(WebCore::CSSComputedStyleDeclaration::currentColorOrValidColor):
(WebCore::getBorderRadiusCornerValue):
(WebCore::computedTransform):
(WebCore::getDelayValue):
(WebCore::getDurationValue):
(WebCore::CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword):
(WebCore::CSSComputedStyleDeclaration::valueForShadow):
(WebCore::valueForFamily):
(WebCore::renderTextDecorationFlagsToCSSValue):
(WebCore::fillRepeatToCSSValue):
(WebCore::fillSizeToCSSValue):
(WebCore::contentToCSSValue):
(WebCore::counterToCSSValue):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseSheet):
(WebCore::CSSParser::parseRule):
(WebCore::CSSParser::parseKeyframeRule):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseColor):
(WebCore::CSSParser::parseSelector):
(WebCore::CSSParser::parseDeclaration):
(WebCore::CSSParser::setStyleSheet):
(WebCore::CSSParser::parseWCSSInputProperty):
(WebCore::parseBackgroundClip):
(WebCore::CSSParser::parseFillShorthand):
(WebCore::CSSParser::parsePage):
(WebCore::CSSParser::parseSizeParameter):
(WebCore::CSSParser::parseContent):
(WebCore::CSSParser::parseAttr):
(WebCore::CSSParser::parseBackgroundColor):
(WebCore::CSSParser::parseFillPositionXY):
(WebCore::CSSParser::parseFillPosition):
(WebCore::CSSParser::parseFillRepeat):
(WebCore::CSSParser::parseFillSize):
(WebCore::CSSParser::parseFillProperty):
(WebCore::CSSParser::parseAnimationDelay):
(WebCore::CSSParser::parseAnimationDirection):
(WebCore::CSSParser::parseAnimationDuration):
(WebCore::CSSParser::parseAnimationFillMode):
(WebCore::CSSParser::parseAnimationIterationCount):
(WebCore::CSSParser::parseAnimationName):
(WebCore::CSSParser::parseAnimationPlayState):
(WebCore::CSSParser::parseAnimationProperty):
(WebCore::CSSParser::parseTransformOriginShorthand):
(WebCore::CSSParser::parseAnimationTimingFunction):
(WebCore::CSSParser::parseDashboardRegions):
(WebCore::CSSParser::parseCounterContent):
(WebCore::CSSParser::parseShape):
(WebCore::CSSParser::parseFont):
(WebCore::CSSParser::parseFontFamily):
(WebCore::CSSParser::parseFontStyle):
(WebCore::CSSParser::parseFontVariant):
(WebCore::CSSParser::parseFontWeight):
(WebCore::ShadowParseContext::ShadowParseContext):
(WebCore::ShadowParseContext::commitLength):
(WebCore::ShadowParseContext::commitStyle):
(WebCore::CSSParser::parseShadow):
(WebCore::CSSParser::parseReflect):
(WebCore::BorderImageParseContext::BorderImageParseContext):
(WebCore::BorderImageParseContext::commitNumber):
(WebCore::BorderImageParseContext::commitBorderImage):
(WebCore::CSSParser::parseBorderImage):
(WebCore::CSSParser::parseBorderRadius):
(WebCore::CSSParser::parseCounter):
(WebCore::parseDeprecatedGradientPoint):
(WebCore::parseDeprecatedGradientColorStop):
(WebCore::CSSParser::parseDeprecatedGradient):
(WebCore::valueFromSideKeyword):
(WebCore::parseGradientColorOrKeyword):
(WebCore::CSSParser::parseLinearGradient):
(WebCore::CSSParser::parseRadialGradient):
(WebCore::CSSParser::parseGradientColorStops):
(WebCore::CSSParser::parseTransform):
(WebCore::CSSParser::parseTransformOrigin):
(WebCore::CSSParser::parseTextEmphasisStyle):

  • css/CSSParser.h:

(WebCore::CSSParser::primitiveValueCache):

  • css/CSSPrimitiveValue.cpp:
  • css/CSSPrimitiveValue.h:

(WebCore::CSSPrimitiveValue::createIdentifier):
(WebCore::CSSPrimitiveValue::createColor):
(WebCore::CSSPrimitiveValue::create):

  • css/CSSPrimitiveValueCache.cpp: Added.

(WebCore::CSSPrimitiveValueCache::CSSPrimitiveValueCache):
(WebCore::CSSPrimitiveValueCache::~CSSPrimitiveValueCache):
(WebCore::CSSPrimitiveValueCache::createIdentifierValue):
(WebCore::CSSPrimitiveValueCache::createColorValue):
(WebCore::CSSPrimitiveValueCache::createValue):

  • css/CSSPrimitiveValueCache.h: Added.

(WebCore::CSSPrimitiveValueCache::create):
(WebCore::CSSPrimitiveValueCache::createValue):

  • dom/Document.cpp:

(WebCore::Document::cssPrimitiveValueCache):

  • dom/Document.h:

LayoutTests: REGRESSION (r79574): fast/dom/global-constructors.html failing on Windows 7 Release (Tests) bots
https://bugs.webkit.org/show_bug.cgi?id=55166
<rdar://problem/9050430>

Reviewed by Oliver Hunt.

  • http/tests/security/cross-origin-css-primitive-expected.txt: Added.
  • http/tests/security/cross-origin-css-primitive.html: Added.
  • http/tests/security/resources/cross-origin-css-primitive-iframe.html: Added.
Location:
trunk
Files:
5 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80462 r80463  
     12011-03-07  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        REGRESSION (r79574): fast/dom/global-constructors.html failing on Windows 7 Release (Tests) bots
     6        https://bugs.webkit.org/show_bug.cgi?id=55166
     7        <rdar://problem/9050430>
     8
     9        * http/tests/security/cross-origin-css-primitive-expected.txt: Added.
     10        * http/tests/security/cross-origin-css-primitive.html: Added.
     11        * http/tests/security/resources/cross-origin-css-primitive-iframe.html: Added.
     12
    1132011-03-07  Alejandro G. Castro  <alex@igalia.com>
    214
  • trunk/Source/WebCore/Android.mk

    r80210 r80463  
    5151        css/CSSParserValues.cpp \
    5252        css/CSSPrimitiveValue.cpp \
     53        css/CSSPrimitiveValueCache.cpp \
    5354        css/CSSProperty.cpp \
    5455        css/CSSPropertyLonghand.cpp \
  • trunk/Source/WebCore/CMakeLists.txt

    r80210 r80463  
    640640    css/CSSParserValues.cpp
    641641    css/CSSPrimitiveValue.cpp
     642    css/CSSPrimitiveValueCache.cpp
    642643    css/CSSProperty.cpp
    643644    css/CSSPropertyLonghand.cpp
  • trunk/Source/WebCore/ChangeLog

    r80459 r80463  
     12011-03-07  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        REGRESSION (r79574): fast/dom/global-constructors.html failing on Windows 7 Release (Tests) bots
     6        https://bugs.webkit.org/show_bug.cgi?id=55166
     7        <rdar://problem/9050430>
     8       
     9        Make CSS primitive value cache per-document.
     10       
     11        Test: http/tests/security/cross-origin-css-primitive.html
     12
     13        * Android.mk:
     14        * CMakeLists.txt:
     15        * GNUmakefile.am:
     16        * WebCore.gypi:
     17        * WebCore.pro:
     18        * WebCore.vcproj/WebCore.vcproj:
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * css/CSSComputedStyleDeclaration.cpp:
     21        (WebCore::valueForNinePieceImage):
     22        (WebCore::zoomAdjustedPixelValue):
     23        (WebCore::zoomAdjustedNumberValue):
     24        (WebCore::zoomAdjustedPixelValueForLength):
     25        (WebCore::valueForReflection):
     26        (WebCore::getPositionOffsetValue):
     27        (WebCore::CSSComputedStyleDeclaration::currentColorOrValidColor):
     28        (WebCore::getBorderRadiusCornerValue):
     29        (WebCore::computedTransform):
     30        (WebCore::getDelayValue):
     31        (WebCore::getDurationValue):
     32        (WebCore::CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword):
     33        (WebCore::CSSComputedStyleDeclaration::valueForShadow):
     34        (WebCore::valueForFamily):
     35        (WebCore::renderTextDecorationFlagsToCSSValue):
     36        (WebCore::fillRepeatToCSSValue):
     37        (WebCore::fillSizeToCSSValue):
     38        (WebCore::contentToCSSValue):
     39        (WebCore::counterToCSSValue):
     40        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     41        * css/CSSParser.cpp:
     42        (WebCore::CSSParser::parseSheet):
     43        (WebCore::CSSParser::parseRule):
     44        (WebCore::CSSParser::parseKeyframeRule):
     45        (WebCore::CSSParser::parseValue):
     46        (WebCore::CSSParser::parseColor):
     47        (WebCore::CSSParser::parseSelector):
     48        (WebCore::CSSParser::parseDeclaration):
     49        (WebCore::CSSParser::setStyleSheet):
     50        (WebCore::CSSParser::parseWCSSInputProperty):
     51        (WebCore::parseBackgroundClip):
     52        (WebCore::CSSParser::parseFillShorthand):
     53        (WebCore::CSSParser::parsePage):
     54        (WebCore::CSSParser::parseSizeParameter):
     55        (WebCore::CSSParser::parseContent):
     56        (WebCore::CSSParser::parseAttr):
     57        (WebCore::CSSParser::parseBackgroundColor):
     58        (WebCore::CSSParser::parseFillPositionXY):
     59        (WebCore::CSSParser::parseFillPosition):
     60        (WebCore::CSSParser::parseFillRepeat):
     61        (WebCore::CSSParser::parseFillSize):
     62        (WebCore::CSSParser::parseFillProperty):
     63        (WebCore::CSSParser::parseAnimationDelay):
     64        (WebCore::CSSParser::parseAnimationDirection):
     65        (WebCore::CSSParser::parseAnimationDuration):
     66        (WebCore::CSSParser::parseAnimationFillMode):
     67        (WebCore::CSSParser::parseAnimationIterationCount):
     68        (WebCore::CSSParser::parseAnimationName):
     69        (WebCore::CSSParser::parseAnimationPlayState):
     70        (WebCore::CSSParser::parseAnimationProperty):
     71        (WebCore::CSSParser::parseTransformOriginShorthand):
     72        (WebCore::CSSParser::parseAnimationTimingFunction):
     73        (WebCore::CSSParser::parseDashboardRegions):
     74        (WebCore::CSSParser::parseCounterContent):
     75        (WebCore::CSSParser::parseShape):
     76        (WebCore::CSSParser::parseFont):
     77        (WebCore::CSSParser::parseFontFamily):
     78        (WebCore::CSSParser::parseFontStyle):
     79        (WebCore::CSSParser::parseFontVariant):
     80        (WebCore::CSSParser::parseFontWeight):
     81        (WebCore::ShadowParseContext::ShadowParseContext):
     82        (WebCore::ShadowParseContext::commitLength):
     83        (WebCore::ShadowParseContext::commitStyle):
     84        (WebCore::CSSParser::parseShadow):
     85        (WebCore::CSSParser::parseReflect):
     86        (WebCore::BorderImageParseContext::BorderImageParseContext):
     87        (WebCore::BorderImageParseContext::commitNumber):
     88        (WebCore::BorderImageParseContext::commitBorderImage):
     89        (WebCore::CSSParser::parseBorderImage):
     90        (WebCore::CSSParser::parseBorderRadius):
     91        (WebCore::CSSParser::parseCounter):
     92        (WebCore::parseDeprecatedGradientPoint):
     93        (WebCore::parseDeprecatedGradientColorStop):
     94        (WebCore::CSSParser::parseDeprecatedGradient):
     95        (WebCore::valueFromSideKeyword):
     96        (WebCore::parseGradientColorOrKeyword):
     97        (WebCore::CSSParser::parseLinearGradient):
     98        (WebCore::CSSParser::parseRadialGradient):
     99        (WebCore::CSSParser::parseGradientColorStops):
     100        (WebCore::CSSParser::parseTransform):
     101        (WebCore::CSSParser::parseTransformOrigin):
     102        (WebCore::CSSParser::parseTextEmphasisStyle):
     103        * css/CSSParser.h:
     104        (WebCore::CSSParser::primitiveValueCache):
     105        * css/CSSPrimitiveValue.cpp:
     106        * css/CSSPrimitiveValue.h:
     107        (WebCore::CSSPrimitiveValue::createIdentifier):
     108        (WebCore::CSSPrimitiveValue::createColor):
     109        (WebCore::CSSPrimitiveValue::create):
     110        * css/CSSPrimitiveValueCache.cpp: Added.
     111        (WebCore::CSSPrimitiveValueCache::CSSPrimitiveValueCache):
     112        (WebCore::CSSPrimitiveValueCache::~CSSPrimitiveValueCache):
     113        (WebCore::CSSPrimitiveValueCache::createIdentifierValue):
     114        (WebCore::CSSPrimitiveValueCache::createColorValue):
     115        (WebCore::CSSPrimitiveValueCache::createValue):
     116        * css/CSSPrimitiveValueCache.h: Added.
     117        (WebCore::CSSPrimitiveValueCache::create):
     118        (WebCore::CSSPrimitiveValueCache::createValue):
     119        * dom/Document.cpp:
     120        (WebCore::Document::cssPrimitiveValueCache):
     121        * dom/Document.h:
     122
    11232011-03-06  Adam Barth  <abarth@webkit.org>
    2124
  • trunk/Source/WebCore/GNUmakefile.am

    r80210 r80463  
    10161016        Source/WebCore/css/CSSPrimitiveValue.cpp \
    10171017        Source/WebCore/css/CSSPrimitiveValue.h \
     1018        Source/WebCore/css/CSSPrimitiveValueCache.cpp \
     1019        Source/WebCore/css/CSSPrimitiveValueCache.h \
    10181020        Source/WebCore/css/CSSPrimitiveValueMappings.h \
    10191021        Source/WebCore/css/CSSProperty.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r80459 r80463  
    10841084            'css/CSSPrimitiveValue.cpp',
    10851085            'css/CSSPrimitiveValue.h',
     1086            'css/CSSPrimitiveValueCache.cpp',
     1087            'css/CSSPrimitiveValueCache.h',
    10861088            'css/CSSPrimitiveValueMappings.h',
    10871089            'css/CSSProperty.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r80274 r80463  
    397397    css/CSSParserValues.cpp \
    398398    css/CSSPrimitiveValue.cpp \
     399    css/CSSPrimitiveValueCache.cpp \
    399400    css/CSSProperty.cpp \
    400401    css/CSSPropertyLonghand.cpp \
     
    13471348    css/CSSParserValues.h \
    13481349    css/CSSPrimitiveValue.h \
     1350    css/CSSPrimitiveValueCache.h \
    13491351    css/CSSProperty.h \
    13501352    css/CSSPropertyLonghand.h \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r80210 r80463  
    3149531495                        </File>
    3149631496                        <File
     31497                                RelativePath="..\css\CSSPrimitiveValueCache.cpp"
     31498                                >
     31499                        </File>
     31500                        <File
     31501                                RelativePath="..\css\CSSPrimitiveValueCache.h"
     31502                                >
     31503                        </File>
     31504                        <File
    3149731505                                RelativePath="..\css\CSSProperty.cpp"
    3149831506                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r80367 r80463  
    55685568                E47B4BE80E71241600038854 /* CachedResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = E47B4BE60E71241600038854 /* CachedResourceHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
    55695569                E47B4BE90E71241600038854 /* CachedResourceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47B4BE70E71241600038854 /* CachedResourceHandle.cpp */; };
     5570                E49BD9FA131FD2ED003C56F0 /* CSSPrimitiveValueCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSPrimitiveValueCache.h */; };
     5571                E49BDA0B131FD3E5003C56F0 /* CSSPrimitiveValueCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49BDA0A131FD3E5003C56F0 /* CSSPrimitiveValueCache.cpp */; };
    55705572                E4AFCFA50DAF29A300F5F55C /* UnitBezier.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */; };
    55715573                E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4AFD0050DAF335400F5F55C /* SMILTime.cpp */; };
     
    1196611968                E47B4BE60E71241600038854 /* CachedResourceHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedResourceHandle.h; sourceTree = "<group>"; };
    1196711969                E47B4BE70E71241600038854 /* CachedResourceHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceHandle.cpp; sourceTree = "<group>"; };
     11970                E49BD9F9131FD2ED003C56F0 /* CSSPrimitiveValueCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPrimitiveValueCache.h; sourceTree = "<group>"; };
     11971                E49BDA0A131FD3E5003C56F0 /* CSSPrimitiveValueCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPrimitiveValueCache.cpp; sourceTree = "<group>"; };
    1196811972                E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnitBezier.h; sourceTree = "<group>"; };
    1196911973                E4AFD0050DAF335400F5F55C /* SMILTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SMILTime.cpp; sourceTree = "<group>"; };
     
    1861318617                                A80E6CBC0A1989CA007FB8C5 /* CSSPrimitiveValue.h */,
    1861418618                                9307059009E0C75800B17FE4 /* CSSPrimitiveValue.idl */,
     18619                                E49BD9F9131FD2ED003C56F0 /* CSSPrimitiveValueCache.h */,
     18620                                E49BDA0A131FD3E5003C56F0 /* CSSPrimitiveValueCache.cpp */,
    1861518621                                E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */,
    1861618622                                A80E6CCD0A1989CA007FB8C5 /* CSSProperty.cpp */,
     
    2252222528                                E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
    2252322529                                977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */,
     22530                                E49BD9FA131FD2ED003C56F0 /* CSSPrimitiveValueCache.h in Headers */,
    2252422531                                5A574F25131DB93900471B88 /* RenderQuote.h in Headers */,
    2252522532                                5A574F29131DB96D00471B88 /* QuotesData.h in Headers */,
     
    2517425181                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
    2517525182                                977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */,
     25183                                E49BDA0B131FD3E5003C56F0 /* CSSPrimitiveValueCache.cpp in Sources */,
    2517625184                                5A574F24131DB93900471B88 /* RenderQuote.cpp in Sources */,
    2517725185                                5A574F28131DB96D00471B88 /* QuotesData.cpp in Sources */,
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r80438 r80463  
    3232#include "CSSMutableStyleDeclaration.h"
    3333#include "CSSPrimitiveValue.h"
     34#include "CSSPrimitiveValueCache.h"
    3435#include "CSSPrimitiveValueMappings.h"
    3536#include "CSSProperty.h"
     
    300301}
    301302       
    302 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
     303static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image, CSSPrimitiveValueCache* primitiveValueCache)
    303304{
    304305    if (!image.hasImage())
    305         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     306        return primitiveValueCache->createIdentifierValue(CSSValueNone);
    306307   
    307308    // Image first.
     
    313314    RefPtr<CSSPrimitiveValue> top;
    314315    if (image.slices().top().isPercent())
    315         top = CSSPrimitiveValue::create(image.slices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
     316        top = primitiveValueCache->createValue(image.slices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
    316317    else
    317         top = CSSPrimitiveValue::create(image.slices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
     318        top = primitiveValueCache->createValue(image.slices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
    318319       
    319320    RefPtr<CSSPrimitiveValue> right;
    320321    if (image.slices().right().isPercent())
    321         right = CSSPrimitiveValue::create(image.slices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
     322        right = primitiveValueCache->createValue(image.slices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
    322323    else
    323         right = CSSPrimitiveValue::create(image.slices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
     324        right = primitiveValueCache->createValue(image.slices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
    324325       
    325326    RefPtr<CSSPrimitiveValue> bottom;
    326327    if (image.slices().bottom().isPercent())
    327         bottom = CSSPrimitiveValue::create(image.slices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
     328        bottom = primitiveValueCache->createValue(image.slices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
    328329    else
    329         bottom = CSSPrimitiveValue::create(image.slices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
     330        bottom = primitiveValueCache->createValue(image.slices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
    330331   
    331332    RefPtr<CSSPrimitiveValue> left;
    332333    if (image.slices().left().isPercent())
    333         left = CSSPrimitiveValue::create(image.slices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
     334        left = primitiveValueCache->createValue(image.slices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
    334335    else
    335         left = CSSPrimitiveValue::create(image.slices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
     336        left = primitiveValueCache->createValue(image.slices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
    336337
    337338    RefPtr<Rect> rect = Rect::create();
     
    344345}
    345346
    346 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(int value, const RenderStyle* style)
    347 {
    348     return CSSPrimitiveValue::create(adjustForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
    349 }
    350 
    351 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
    352 {
    353     return CSSPrimitiveValue::create(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
    354 }
    355 
    356 static PassRefPtr<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style)
     347inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(int value, const RenderStyle* style, CSSPrimitiveValueCache* primitiveValueCache)
     348{
     349    return primitiveValueCache->createValue(adjustForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
     350}
     351
     352inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style, CSSPrimitiveValueCache* primitiveValueCache)
     353{
     354    return primitiveValueCache->createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
     355}
     356
     357static PassRefPtr<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style, CSSPrimitiveValueCache* primitiveValueCache)
    357358{
    358359    if (length.isFixed())
    359         return zoomAdjustedPixelValue(length.value(), style);
    360     return CSSPrimitiveValue::create(length);
    361 }
    362 
    363 static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style)
     360        return zoomAdjustedPixelValue(length.value(), style, primitiveValueCache);
     361    return primitiveValueCache->createValue(length);
     362}
     363
     364static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style, CSSPrimitiveValueCache* primitiveValueCache)
    364365{
    365366    if (!reflection)
    366         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     367        return primitiveValueCache->createIdentifierValue(CSSValueNone);
    367368
    368369    RefPtr<CSSPrimitiveValue> offset;
    369370    if (reflection->offset().isPercent())
    370         offset = CSSPrimitiveValue::create(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
     371        offset = primitiveValueCache->createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
    371372    else
    372         offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
     373        offset = zoomAdjustedPixelValue(reflection->offset().value(), style, primitiveValueCache);
    373374   
    374     return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask()));
    375 }
    376 
    377 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID)
     375    return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask(), primitiveValueCache));
     376}
     377
     378static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID, CSSPrimitiveValueCache* primitiveValueCache)
    378379{
    379380    if (!style)
     
    400401    if (style->position() == AbsolutePosition || style->position() == FixedPosition) {
    401402        if (l.type() == WebCore::Fixed)
    402             return zoomAdjustedPixelValue(l.value(), style);
    403         return CSSPrimitiveValue::create(l);
     403            return zoomAdjustedPixelValue(l.value(), style, primitiveValueCache);
     404        return primitiveValueCache->createValue(l);
    404405    }
    405406
     
    408409        // In other words if left is auto and right is not auto, then left's computed value is negative right().
    409410        // So we should get the opposite length unit and see if it is auto.
    410         return CSSPrimitiveValue::create(l);
    411 
    412     return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     411        return primitiveValueCache->createValue(l);
     412
     413    return primitiveValueCache->createIdentifierValue(CSSValueAuto);
    413414}
    414415
     
    416417{
    417418    // This function does NOT look at visited information, so that computed style doesn't expose that.
     419    CSSPrimitiveValueCache* primitiveValueCache = m_node->document()->cssPrimitiveValueCache().get();
    418420    if (!color.isValid())
    419         return CSSPrimitiveValue::createColor(style->color().rgb());
    420     return CSSPrimitiveValue::createColor(color.rgb());
    421 }
    422 
    423 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(LengthSize radius, const RenderStyle* style)
     421        return primitiveValueCache->createColorValue(style->color().rgb());
     422    return primitiveValueCache->createColorValue(color.rgb());
     423}
     424
     425static PassRefPtr<CSSValue> getBorderRadiusCornerValue(LengthSize radius, const RenderStyle* style, CSSPrimitiveValueCache* primitiveValueCache)
    424426{
    425427    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    426428    if (radius.width() == radius.height()) {
    427429        if (radius.width().type() == Percent)
    428             return CSSPrimitiveValue::create(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
    429         return zoomAdjustedPixelValue(radius.width().value(), style);
     430            return primitiveValueCache->createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
     431        return zoomAdjustedPixelValue(radius.width().value(), style, primitiveValueCache);
    430432    }
    431433    if (radius.width().type() == Percent)
    432         list->append(CSSPrimitiveValue::create(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
     434        list->append(primitiveValueCache->createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
    433435    else
    434         list->append(zoomAdjustedPixelValue(radius.width().value(), style));
     436        list->append(zoomAdjustedPixelValue(radius.width().value(), style, primitiveValueCache));
    435437    if (radius.height().type() == Percent)
    436         list->append(CSSPrimitiveValue::create(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
     438        list->append(primitiveValueCache->createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
    437439    else
    438         list->append(zoomAdjustedPixelValue(radius.height().value(), style));
     440        list->append(zoomAdjustedPixelValue(radius.height().value(), style, primitiveValueCache));
    439441    return list.release();
    440442}
     
    454456}
    455457
    456 static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
     458static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style, CSSPrimitiveValueCache* primitiveValueCache)
    457459{
    458460    if (!renderer || style->transform().operations().isEmpty())
    459         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     461        return primitiveValueCache->createIdentifierValue(CSSValueNone);
    460462   
    461463    IntRect box = sizingBox(renderer);
     
    471473        transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
    472474
    473         transformVal->append(CSSPrimitiveValue::create(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
    474         transformVal->append(CSSPrimitiveValue::create(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
    475         transformVal->append(CSSPrimitiveValue::create(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
    476         transformVal->append(CSSPrimitiveValue::create(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
    477         transformVal->append(zoomAdjustedNumberValue(transform.e(), style));
    478         transformVal->append(zoomAdjustedNumberValue(transform.f(), style));
     475        transformVal->append(primitiveValueCache->createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
     476        transformVal->append(primitiveValueCache->createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
     477        transformVal->append(primitiveValueCache->createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
     478        transformVal->append(primitiveValueCache->createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
     479        transformVal->append(zoomAdjustedNumberValue(transform.e(), style, primitiveValueCache));
     480        transformVal->append(zoomAdjustedNumberValue(transform.f(), style, primitiveValueCache));
    479481    } else {
    480482        transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
    481483
    482         transformVal->append(CSSPrimitiveValue::create(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
    483         transformVal->append(CSSPrimitiveValue::create(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
    484         transformVal->append(CSSPrimitiveValue::create(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
    485         transformVal->append(CSSPrimitiveValue::create(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
    486 
    487         transformVal->append(CSSPrimitiveValue::create(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
    488         transformVal->append(CSSPrimitiveValue::create(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
    489         transformVal->append(CSSPrimitiveValue::create(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
    490         transformVal->append(CSSPrimitiveValue::create(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
    491 
    492         transformVal->append(CSSPrimitiveValue::create(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
    493         transformVal->append(CSSPrimitiveValue::create(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
    494         transformVal->append(CSSPrimitiveValue::create(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
    495         transformVal->append(CSSPrimitiveValue::create(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
    496 
    497         transformVal->append(zoomAdjustedNumberValue(transform.m41(), style));
    498         transformVal->append(zoomAdjustedNumberValue(transform.m42(), style));
    499         transformVal->append(zoomAdjustedNumberValue(transform.m43(), style));
    500         transformVal->append(CSSPrimitiveValue::create(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
     484        transformVal->append(primitiveValueCache->createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
     485        transformVal->append(primitiveValueCache->createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
     486        transformVal->append(primitiveValueCache->createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
     487        transformVal->append(primitiveValueCache->createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
     488
     489        transformVal->append(primitiveValueCache->createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
     490        transformVal->append(primitiveValueCache->createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
     491        transformVal->append(primitiveValueCache->createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
     492        transformVal->append(primitiveValueCache->createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
     493
     494        transformVal->append(primitiveValueCache->createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
     495        transformVal->append(primitiveValueCache->createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
     496        transformVal->append(primitiveValueCache->createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
     497        transformVal->append(primitiveValueCache->createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
     498
     499        transformVal->append(zoomAdjustedNumberValue(transform.m41(), style, primitiveValueCache));
     500        transformVal->append(zoomAdjustedNumberValue(transform.m42(), style, primitiveValueCache));
     501        transformVal->append(zoomAdjustedNumberValue(transform.m43(), style, primitiveValueCache));
     502        transformVal->append(primitiveValueCache->createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
    501503    }
    502504
     
    507509}
    508510
    509 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
     511static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList, CSSPrimitiveValueCache* primitiveValueCache)
    510512{
    511513    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    512514    if (animList) {
    513515        for (size_t i = 0; i < animList->size(); ++i)
    514             list->append(CSSPrimitiveValue::create(animList->animation(i)->delay(), CSSPrimitiveValue::CSS_S));
     516            list->append(primitiveValueCache->createValue(animList->animation(i)->delay(), CSSPrimitiveValue::CSS_S));
    515517    } else {
    516518        // Note that initialAnimationDelay() is used for both transitions and animations
    517         list->append(CSSPrimitiveValue::create(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
     519        list->append(primitiveValueCache->createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
    518520    }
    519521    return list.release();
    520522}
    521523
    522 static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList)
     524static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList, CSSPrimitiveValueCache* primitiveValueCache)
    523525{
    524526    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    525527    if (animList) {
    526528        for (size_t i = 0; i < animList->size(); ++i)
    527             list->append(CSSPrimitiveValue::create(animList->animation(i)->duration(), CSSPrimitiveValue::CSS_S));
     529            list->append(primitiveValueCache->createValue(animList->animation(i)->duration(), CSSPrimitiveValue::CSS_S));
    528530    } else {
    529531        // Note that initialAnimationDuration() is used for both transitions and animations
    530         list->append(CSSPrimitiveValue::create(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
     532        list->append(primitiveValueCache->createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
    531533    }
    532534    return list.release();
     
    616618    if (!style)
    617619        return 0;
     620   
     621    CSSPrimitiveValueCache* primitiveValueCache = m_node->document()->cssPrimitiveValueCache().get();
    618622
    619623    if (int keywordSize = style->fontDescription().keywordSize())
    620         return CSSPrimitiveValue::createIdentifier(cssIdentifierForFontSizeKeyword(keywordSize));
    621 
    622 
    623     return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
     624        return primitiveValueCache->createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
     625
     626
     627    return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get(), primitiveValueCache);
    624628}
    625629
     
    638642PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, int id, RenderStyle* style) const
    639643{
     644    CSSPrimitiveValueCache* primitiveValueCache = m_node->document()->cssPrimitiveValueCache().get();
    640645    if (!shadow)
    641         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     646        return primitiveValueCache->createIdentifierValue(CSSValueNone);
    642647
    643648    CSSPropertyID propertyID = static_cast<CSSPropertyID>(id);
     
    645650    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    646651    for (const ShadowData* s = shadow; s; s = s->next()) {
    647         RefPtr<CSSPrimitiveValue> x = zoomAdjustedPixelValue(s->x(), style);
    648         RefPtr<CSSPrimitiveValue> y = zoomAdjustedPixelValue(s->y(), style);
    649         RefPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(s->blur(), style);
    650         RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? 0 : zoomAdjustedPixelValue(s->spread(), style);
    651         RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset);
    652         RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(s->color().rgb());
     652        RefPtr<CSSPrimitiveValue> x = zoomAdjustedPixelValue(s->x(), style, primitiveValueCache);
     653        RefPtr<CSSPrimitiveValue> y = zoomAdjustedPixelValue(s->y(), style, primitiveValueCache);
     654        RefPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(s->blur(), style, primitiveValueCache);
     655        RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? 0 : zoomAdjustedPixelValue(s->spread(), style, primitiveValueCache);
     656        RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? 0 : primitiveValueCache->createIdentifierValue(CSSValueInset);
     657        RefPtr<CSSPrimitiveValue> color = primitiveValueCache->createColorValue(s->color().rgb());
    653658        list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
    654659    }
     
    681686}
    682687
    683 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
     688static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family, CSSPrimitiveValueCache* primitiveValueCache)
    684689{
    685690    if (int familyIdentifier = identifierForFamily(family))
    686         return CSSPrimitiveValue::createIdentifier(familyIdentifier);
    687     return CSSPrimitiveValue::create(family.string(), CSSPrimitiveValue::CSS_STRING);
    688 }
    689 
    690 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
     691        return primitiveValueCache->createIdentifierValue(familyIdentifier);
     692    return primitiveValueCache->createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
     693}
     694
     695static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration, CSSPrimitiveValueCache* primitiveValueCache)
    691696{
    692697    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    693698    if (textDecoration & UNDERLINE)
    694         list->append(CSSPrimitiveValue::createIdentifier(CSSValueUnderline));
     699        list->append(primitiveValueCache->createIdentifierValue(CSSValueUnderline));
    695700    if (textDecoration & OVERLINE)
    696         list->append(CSSPrimitiveValue::createIdentifier(CSSValueOverline));
     701        list->append(primitiveValueCache->createIdentifierValue(CSSValueOverline));
    697702    if (textDecoration & LINE_THROUGH)
    698         list->append(CSSPrimitiveValue::createIdentifier(CSSValueLineThrough));
     703        list->append(primitiveValueCache->createIdentifierValue(CSSValueLineThrough));
    699704    if (textDecoration & BLINK)
    700         list->append(CSSPrimitiveValue::createIdentifier(CSSValueBlink));
     705        list->append(primitiveValueCache->createIdentifierValue(CSSValueBlink));
    701706
    702707    if (!list->length())
    703         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     708        return primitiveValueCache->createIdentifierValue(CSSValueNone);
    704709    return list;
    705710}
    706711
    707 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
     712static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat, CSSPrimitiveValueCache* primitiveValueCache)
    708713{
    709714    // For backwards compatibility, if both values are equal, just return one of them. And
    710715    // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
    711716    if (xRepeat == yRepeat)
    712         return CSSPrimitiveValue::create(xRepeat);
     717        return primitiveValueCache->createValue(xRepeat);
    713718    if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
    714         return CSSPrimitiveValue::createIdentifier(CSSValueRepeatX);
     719        return primitiveValueCache->createIdentifierValue(CSSValueRepeatX);
    715720    if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
    716         return CSSPrimitiveValue::createIdentifier(CSSValueRepeatY);
     721        return primitiveValueCache->createIdentifierValue(CSSValueRepeatY);
    717722
    718723    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    719     list->append(CSSPrimitiveValue::create(xRepeat));
    720     list->append(CSSPrimitiveValue::create(yRepeat));
     724    list->append(primitiveValueCache->createValue(xRepeat));
     725    list->append(primitiveValueCache->createValue(yRepeat));
    721726    return list.release();
    722727}
    723728
    724 static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize)
     729static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, CSSPrimitiveValueCache* primitiveValueCache)
    725730{
    726731    if (fillSize.type == Contain)
    727         return CSSPrimitiveValue::createIdentifier(CSSValueContain);
     732        return primitiveValueCache->createIdentifierValue(CSSValueContain);
    728733
    729734    if (fillSize.type == Cover)
    730         return CSSPrimitiveValue::createIdentifier(CSSValueCover);
     735        return primitiveValueCache->createIdentifierValue(CSSValueCover);
    731736
    732737    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    733     list->append(CSSPrimitiveValue::create(fillSize.size.width()));
    734     list->append(CSSPrimitiveValue::create(fillSize.size.height()));
     738    list->append(primitiveValueCache->createValue(fillSize.size.width()));
     739    list->append(primitiveValueCache->createValue(fillSize.size.height()));
    735740    return list.release();
    736741}
    737742
    738 static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
     743static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style, CSSPrimitiveValueCache* primitiveValueCache)
    739744{
    740745    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     
    743748            const CounterContent* counter = contentData->counter();
    744749            ASSERT(counter);
    745             list->append(CSSPrimitiveValue::create(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
     750            list->append(primitiveValueCache->createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
    746751        } else if (contentData->isImage()) {
    747752            const StyleImage* image = contentData->image();
     
    749754            list->append(image->cssValue());
    750755        } else if (contentData->isText())
    751             list->append(CSSPrimitiveValue::create(contentData->text(), CSSPrimitiveValue::CSS_STRING));
     756            list->append(primitiveValueCache->createValue(contentData->text(), CSSPrimitiveValue::CSS_STRING));
    752757    }
    753758    return list.release();
    754759}
    755760
    756 static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, int propertyID)
     761static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, int propertyID, CSSPrimitiveValueCache* primitiveValueCache)
    757762{
    758763    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    759764    const CounterDirectiveMap* map = style->counterDirectives();
    760765    for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
    761         list->append(CSSPrimitiveValue::create(it->first.get(), CSSPrimitiveValue::CSS_STRING));
     766        list->append(primitiveValueCache->createValue(it->first.get(), CSSPrimitiveValue::CSS_STRING));
    762767        short number = propertyID == CSSPropertyCounterIncrement ? it->second.m_incrementValue : it->second.m_resetValue;
    763         list->append(CSSPrimitiveValue::create((double)number, CSSPrimitiveValue::CSS_NUMBER));
     768        list->append(primitiveValueCache->createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
    764769    }
    765770    return list.release();
     
    799804    if (!style)
    800805        return 0;
     806   
     807    CSSPrimitiveValueCache* primitiveValueCache = node->document()->cssPrimitiveValueCache().get();
    801808
    802809    propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
     
    807814
    808815        case CSSPropertyBackgroundColor:
    809             return CSSPrimitiveValue::createColor(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
     816            return primitiveValueCache->createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
    810817        case CSSPropertyBackgroundImage:
    811818        case CSSPropertyWebkitMaskImage: {
    812819            const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
    813820            if (!layers)
    814                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     821                return primitiveValueCache->createIdentifierValue(CSSValueNone);
    815822
    816823            if (!layers->next()) {
     
    818825                    return layers->image()->cssValue();
    819826
    820                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     827                return primitiveValueCache->createIdentifierValue(CSSValueNone);
    821828            }
    822829
     
    826833                    list->append(currLayer->image()->cssValue());
    827834                else
    828                     list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
     835                    list->append(primitiveValueCache->createIdentifierValue(CSSValueNone));
    829836            }
    830837            return list.release();
     
    835842            const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
    836843            if (!layers->next())
    837                 return fillSizeToCSSValue(layers->size());
     844                return fillSizeToCSSValue(layers->size(), primitiveValueCache);
    838845
    839846            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    840847            for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
    841                 list->append(fillSizeToCSSValue(currLayer->size()));
     848                list->append(fillSizeToCSSValue(currLayer->size(), primitiveValueCache));
    842849
    843850            return list.release();
     
    847854            const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
    848855            if (!layers->next())
    849                 return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
     856                return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY(), primitiveValueCache);
    850857
    851858            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    852859            for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
    853                 list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
     860                list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY(), primitiveValueCache));
    854861
    855862            return list.release();
     
    859866            const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
    860867            if (!layers->next())
    861                 return CSSPrimitiveValue::create(layers->composite());
     868                return primitiveValueCache->createValue(layers->composite());
    862869
    863870            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    864871            for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
    865                 list->append(CSSPrimitiveValue::create(currLayer->composite()));
     872                list->append(primitiveValueCache->createValue(currLayer->composite()));
    866873
    867874            return list.release();
     
    871878            const FillLayer* layers = propertyID == CSSPropertyWebkitMaskAttachment ? style->maskLayers() : style->backgroundLayers();
    872879            if (!layers->next())
    873                 return CSSPrimitiveValue::create(layers->attachment());
     880                return primitiveValueCache->createValue(layers->attachment());
    874881
    875882            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    876883            for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
    877                 list->append(CSSPrimitiveValue::create(currLayer->attachment()));
     884                list->append(primitiveValueCache->createValue(currLayer->attachment()));
    878885
    879886            return list.release();
     
    889896            if (!layers->next()) {
    890897                EFillBox box = isClip ? layers->clip() : layers->origin();
    891                 return CSSPrimitiveValue::create(box);
     898                return primitiveValueCache->createValue(box);
    892899            }
    893900           
     
    895902            for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
    896903                EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
    897                 list->append(CSSPrimitiveValue::create(box));
     904                list->append(primitiveValueCache->createValue(box));
    898905            }
    899906
     
    905912            if (!layers->next()) {
    906913                RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    907                 list->append(CSSPrimitiveValue::create(layers->xPosition()));
    908                 list->append(CSSPrimitiveValue::create(layers->yPosition()));
     914                list->append(primitiveValueCache->createValue(layers->xPosition()));
     915                list->append(primitiveValueCache->createValue(layers->yPosition()));
    909916                return list.release();
    910917            }
     
    913920            for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
    914921                RefPtr<CSSValueList> positionList = CSSValueList::createSpaceSeparated();
    915                 positionList->append(CSSPrimitiveValue::create(currLayer->xPosition()));
    916                 positionList->append(CSSPrimitiveValue::create(currLayer->yPosition()));
     922                positionList->append(primitiveValueCache->createValue(currLayer->xPosition()));
     923                positionList->append(primitiveValueCache->createValue(currLayer->yPosition()));
    917924                list->append(positionList);
    918925            }
     
    924931            const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
    925932            if (!layers->next())
    926                 return CSSPrimitiveValue::create(layers->xPosition());
     933                return primitiveValueCache->createValue(layers->xPosition());
    927934
    928935            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    929936            for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
    930                 list->append(CSSPrimitiveValue::create(currLayer->xPosition()));
     937                list->append(primitiveValueCache->createValue(currLayer->xPosition()));
    931938
    932939            return list.release();
     
    936943            const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
    937944            if (!layers->next())
    938                 return CSSPrimitiveValue::create(layers->yPosition());
     945                return primitiveValueCache->createValue(layers->yPosition());
    939946
    940947            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    941948            for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
    942                 list->append(CSSPrimitiveValue::create(currLayer->yPosition()));
     949                list->append(primitiveValueCache->createValue(currLayer->yPosition()));
    943950
    944951            return list.release();
     
    946953        case CSSPropertyBorderCollapse:
    947954            if (style->borderCollapse())
    948                 return CSSPrimitiveValue::createIdentifier(CSSValueCollapse);
    949             return CSSPrimitiveValue::createIdentifier(CSSValueSeparate);
     955                return primitiveValueCache->createIdentifierValue(CSSValueCollapse);
     956            return primitiveValueCache->createIdentifierValue(CSSValueSeparate);
    950957        case CSSPropertyBorderSpacing: {
    951958            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    952             list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
    953             list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
     959            list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get(), primitiveValueCache));
     960            list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get(), primitiveValueCache));
    954961            return list.release();
    955962        } 
    956963        case CSSPropertyWebkitBorderHorizontalSpacing:
    957             return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
     964            return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get(), primitiveValueCache);
    958965        case CSSPropertyWebkitBorderVerticalSpacing:
    959             return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
     966            return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get(), primitiveValueCache);
    960967        case CSSPropertyBorderTopColor:
    961             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
     968            return m_allowVisitedStyle ? primitiveValueCache->createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
    962969        case CSSPropertyBorderRightColor:
    963             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
     970            return m_allowVisitedStyle ? primitiveValueCache->createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
    964971        case CSSPropertyBorderBottomColor:
    965             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
     972            return m_allowVisitedStyle ? primitiveValueCache->createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
    966973        case CSSPropertyBorderLeftColor:
    967             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
     974            return m_allowVisitedStyle ? primitiveValueCache->createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
    968975        case CSSPropertyBorderTopStyle:
    969             return CSSPrimitiveValue::create(style->borderTopStyle());
     976            return primitiveValueCache->createValue(style->borderTopStyle());
    970977        case CSSPropertyBorderRightStyle:
    971             return CSSPrimitiveValue::create(style->borderRightStyle());
     978            return primitiveValueCache->createValue(style->borderRightStyle());
    972979        case CSSPropertyBorderBottomStyle:
    973             return CSSPrimitiveValue::create(style->borderBottomStyle());
     980            return primitiveValueCache->createValue(style->borderBottomStyle());
    974981        case CSSPropertyBorderLeftStyle:
    975             return CSSPrimitiveValue::create(style->borderLeftStyle());
     982            return primitiveValueCache->createValue(style->borderLeftStyle());
    976983        case CSSPropertyBorderTopWidth:
    977             return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
     984            return zoomAdjustedPixelValue(style->borderTopWidth(), style.get(), primitiveValueCache);
    978985        case CSSPropertyBorderRightWidth:
    979             return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
     986            return zoomAdjustedPixelValue(style->borderRightWidth(), style.get(), primitiveValueCache);
    980987        case CSSPropertyBorderBottomWidth:
    981             return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
     988            return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get(), primitiveValueCache);
    982989        case CSSPropertyBorderLeftWidth:
    983             return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
     990            return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get(), primitiveValueCache);
    984991        case CSSPropertyBottom:
    985             return getPositionOffsetValue(style.get(), CSSPropertyBottom);
     992            return getPositionOffsetValue(style.get(), CSSPropertyBottom, primitiveValueCache);
    986993        case CSSPropertyWebkitBoxAlign:
    987             return CSSPrimitiveValue::create(style->boxAlign());
     994            return primitiveValueCache->createValue(style->boxAlign());
    988995        case CSSPropertyWebkitBoxDirection:
    989             return CSSPrimitiveValue::create(style->boxDirection());
     996            return primitiveValueCache->createValue(style->boxDirection());
    990997        case CSSPropertyWebkitBoxFlex:
    991             return CSSPrimitiveValue::create(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
     998            return primitiveValueCache->createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
    992999        case CSSPropertyWebkitBoxFlexGroup:
    993             return CSSPrimitiveValue::create(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
     1000            return primitiveValueCache->createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
    9941001        case CSSPropertyWebkitBoxLines:
    995             return CSSPrimitiveValue::create(style->boxLines());
     1002            return primitiveValueCache->createValue(style->boxLines());
    9961003        case CSSPropertyWebkitBoxOrdinalGroup:
    997             return CSSPrimitiveValue::create(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
     1004            return primitiveValueCache->createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
    9981005        case CSSPropertyWebkitBoxOrient:
    999             return CSSPrimitiveValue::create(style->boxOrient());
     1006            return primitiveValueCache->createValue(style->boxOrient());
    10001007        case CSSPropertyWebkitBoxPack: {
    10011008            EBoxAlignment boxPack = style->boxPack();
     
    10041011            if (boxPack == BJUSTIFY || boxPack== BBASELINE)
    10051012                return 0;
    1006             return CSSPrimitiveValue::create(boxPack);
     1013            return primitiveValueCache->createValue(boxPack);
    10071014        }
    10081015        case CSSPropertyWebkitBoxReflect:
    1009             return valueForReflection(style->boxReflect(), style.get());
     1016            return valueForReflection(style->boxReflect(), style.get(), primitiveValueCache);
    10101017        case CSSPropertyBoxShadow:
    10111018        case CSSPropertyWebkitBoxShadow:
    10121019            return valueForShadow(style->boxShadow(), propertyID, style.get());
    10131020        case CSSPropertyCaptionSide:
    1014             return CSSPrimitiveValue::create(style->captionSide());
     1021            return primitiveValueCache->createValue(style->captionSide());
    10151022        case CSSPropertyClear:
    1016             return CSSPrimitiveValue::create(style->clear());
     1023            return primitiveValueCache->createValue(style->clear());
    10171024        case CSSPropertyColor:
    1018             return CSSPrimitiveValue::createColor(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
     1025            return primitiveValueCache->createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
    10191026        case CSSPropertyWebkitColumnCount:
    10201027            if (style->hasAutoColumnCount())
    1021                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    1022             return CSSPrimitiveValue::create(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
     1028                return primitiveValueCache->createIdentifierValue(CSSValueAuto);
     1029            return primitiveValueCache->createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
    10231030        case CSSPropertyWebkitColumnGap:
    10241031            if (style->hasNormalColumnGap())
    1025                 return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
    1026             return CSSPrimitiveValue::create(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER);
     1032                return primitiveValueCache->createIdentifierValue(CSSValueNormal);
     1033            return primitiveValueCache->createValue(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER);
    10271034        case CSSPropertyWebkitColumnRuleColor:
    1028             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
     1035            return m_allowVisitedStyle ? primitiveValueCache->createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
    10291036        case CSSPropertyWebkitColumnRuleStyle:
    1030             return CSSPrimitiveValue::create(style->columnRuleStyle());
     1037            return primitiveValueCache->createValue(style->columnRuleStyle());
    10311038        case CSSPropertyWebkitColumnRuleWidth:
    1032             return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
     1039            return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get(), primitiveValueCache);
    10331040        case CSSPropertyWebkitColumnSpan:
    10341041            if (style->columnSpan())
    1035                 return CSSPrimitiveValue::createIdentifier(CSSValueAll);
    1036             return CSSPrimitiveValue::create(1, CSSPrimitiveValue::CSS_NUMBER);
     1042                return primitiveValueCache->createIdentifierValue(CSSValueAll);
     1043            return primitiveValueCache->createValue(1, CSSPrimitiveValue::CSS_NUMBER);
    10371044        case CSSPropertyWebkitColumnBreakAfter:
    1038             return CSSPrimitiveValue::create(style->columnBreakAfter());
     1045            return primitiveValueCache->createValue(style->columnBreakAfter());
    10391046        case CSSPropertyWebkitColumnBreakBefore:
    1040             return CSSPrimitiveValue::create(style->columnBreakBefore());
     1047            return primitiveValueCache->createValue(style->columnBreakBefore());
    10411048        case CSSPropertyWebkitColumnBreakInside:
    1042             return CSSPrimitiveValue::create(style->columnBreakInside());
     1049            return primitiveValueCache->createValue(style->columnBreakInside());
    10431050        case CSSPropertyWebkitColumnWidth:
    10441051            if (style->hasAutoColumnWidth())
    1045                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    1046             return CSSPrimitiveValue::create(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER);
     1052                return primitiveValueCache->createIdentifierValue(CSSValueAuto);
     1053            return primitiveValueCache->createValue(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER);
    10471054        case CSSPropertyCursor: {
    10481055            RefPtr<CSSValueList> list;
     
    10541061                        list->append(image->cssValue());
    10551062            }
    1056             RefPtr<CSSValue> value = CSSPrimitiveValue::create(style->cursor());
     1063            RefPtr<CSSValue> value = primitiveValueCache->createValue(style->cursor());
    10571064            if (list) {
    10581065                list->append(value);
     
    10621069        }
    10631070        case CSSPropertyDirection:
    1064             return CSSPrimitiveValue::create(style->direction());
     1071            return primitiveValueCache->createValue(style->direction());
    10651072        case CSSPropertyDisplay:
    1066             return CSSPrimitiveValue::create(style->display());
     1073            return primitiveValueCache->createValue(style->display());
    10671074        case CSSPropertyEmptyCells:
    1068             return CSSPrimitiveValue::create(style->emptyCells());
     1075            return primitiveValueCache->createValue(style->emptyCells());
    10691076        case CSSPropertyFloat:
    1070             return CSSPrimitiveValue::create(style->floating());
     1077            return primitiveValueCache->createValue(style->floating());
    10711078        case CSSPropertyFontFamily: {
    10721079            const FontFamily& firstFamily = style->fontDescription().family();
    10731080            if (!firstFamily.next())
    1074                 return valueForFamily(firstFamily.family());
     1081                return valueForFamily(firstFamily.family(), primitiveValueCache);
    10751082            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    10761083            for (const FontFamily* family = &firstFamily; family; family = family->next())
    1077                 list->append(valueForFamily(family->family()));
     1084                list->append(valueForFamily(family->family(), primitiveValueCache));
    10781085            return list.release();
    10791086        }
    10801087        case CSSPropertyFontSize:
    1081             return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
     1088            return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get(), primitiveValueCache);
    10821089        case CSSPropertyFontStyle:
    10831090            if (style->fontDescription().italic())
    1084                 return CSSPrimitiveValue::createIdentifier(CSSValueItalic);
    1085             return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     1091                return primitiveValueCache->createIdentifierValue(CSSValueItalic);
     1092            return primitiveValueCache->createIdentifierValue(CSSValueNormal);
    10861093        case CSSPropertyFontVariant:
    10871094            if (style->fontDescription().smallCaps())
    1088                 return CSSPrimitiveValue::createIdentifier(CSSValueSmallCaps);
    1089             return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     1095                return primitiveValueCache->createIdentifierValue(CSSValueSmallCaps);
     1096            return primitiveValueCache->createIdentifierValue(CSSValueNormal);
    10901097        case CSSPropertyFontWeight:
    10911098            switch (style->fontDescription().weight()) {
    10921099                case FontWeight100:
    1093                     return CSSPrimitiveValue::createIdentifier(CSSValue100);
     1100                    return primitiveValueCache->createIdentifierValue(CSSValue100);
    10941101                case FontWeight200:
    1095                     return CSSPrimitiveValue::createIdentifier(CSSValue200);
     1102                    return primitiveValueCache->createIdentifierValue(CSSValue200);
    10961103                case FontWeight300:
    1097                     return CSSPrimitiveValue::createIdentifier(CSSValue300);
     1104                    return primitiveValueCache->createIdentifierValue(CSSValue300);
    10981105                case FontWeightNormal:
    1099                     return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     1106                    return primitiveValueCache->createIdentifierValue(CSSValueNormal);
    11001107                case FontWeight500:
    1101                     return CSSPrimitiveValue::createIdentifier(CSSValue500);
     1108                    return primitiveValueCache->createIdentifierValue(CSSValue500);
    11021109                case FontWeight600:
    1103                     return CSSPrimitiveValue::createIdentifier(CSSValue600);
     1110                    return primitiveValueCache->createIdentifierValue(CSSValue600);
    11041111                case FontWeightBold:
    1105                     return CSSPrimitiveValue::createIdentifier(CSSValueBold);
     1112                    return primitiveValueCache->createIdentifierValue(CSSValueBold);
    11061113                case FontWeight800:
    1107                     return CSSPrimitiveValue::createIdentifier(CSSValue800);
     1114                    return primitiveValueCache->createIdentifierValue(CSSValue800);
    11081115                case FontWeight900:
    1109                     return CSSPrimitiveValue::createIdentifier(CSSValue900);
     1116                    return primitiveValueCache->createIdentifierValue(CSSValue900);
    11101117            }
    11111118            ASSERT_NOT_REACHED();
    1112             return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     1119            return primitiveValueCache->createIdentifierValue(CSSValueNormal);
    11131120        case CSSPropertyHeight:
    11141121            if (renderer)
    1115                 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
    1116             return zoomAdjustedPixelValueForLength(style->height(), style.get());
     1122                return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get(), primitiveValueCache);
     1123            return zoomAdjustedPixelValueForLength(style->height(), style.get(), primitiveValueCache);
    11171124        case CSSPropertyWebkitHighlight:
    11181125            if (style->highlight() == nullAtom)
    1119                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
    1120             return CSSPrimitiveValue::create(style->highlight(), CSSPrimitiveValue::CSS_STRING);
     1126                return primitiveValueCache->createIdentifierValue(CSSValueNone);
     1127            return primitiveValueCache->createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
    11211128        case CSSPropertyWebkitHyphens:
    1122             return CSSPrimitiveValue::create(style->hyphens());
     1129            return primitiveValueCache->createValue(style->hyphens());
    11231130        case CSSPropertyWebkitHyphenateCharacter:
    11241131            if (style->hyphenationString().isNull())
    1125                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    1126             return CSSPrimitiveValue::create(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
     1132                return primitiveValueCache->createIdentifierValue(CSSValueAuto);
     1133            return primitiveValueCache->createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
    11271134        case CSSPropertyWebkitHyphenateLimitAfter:
    11281135            if (style->hyphenationLimitAfter() < 0)
     
    11351142        case CSSPropertyWebkitBorderFit:
    11361143            if (style->borderFit() == BorderFitBorder)
    1137                 return CSSPrimitiveValue::createIdentifier(CSSValueBorder);
    1138             return CSSPrimitiveValue::createIdentifier(CSSValueLines);
     1144                return primitiveValueCache->createIdentifierValue(CSSValueBorder);
     1145            return primitiveValueCache->createIdentifierValue(CSSValueLines);
    11391146        case CSSPropertyLeft:
    1140             return getPositionOffsetValue(style.get(), CSSPropertyLeft);
     1147            return getPositionOffsetValue(style.get(), CSSPropertyLeft, primitiveValueCache);
    11411148        case CSSPropertyLetterSpacing:
    11421149            if (!style->letterSpacing())
    1143                 return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
    1144             return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
     1150                return primitiveValueCache->createIdentifierValue(CSSValueNormal);
     1151            return zoomAdjustedPixelValue(style->letterSpacing(), style.get(), primitiveValueCache);
    11451152        case CSSPropertyWebkitLineClamp:
    11461153            if (style->lineClamp().isNone())
    1147                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
    1148             return CSSPrimitiveValue::create(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
     1154                return primitiveValueCache->createIdentifierValue(CSSValueNone);
     1155            return primitiveValueCache->createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
    11491156        case CSSPropertyLineHeight: {
    11501157            Length length = style->lineHeight();
    11511158            if (length.isNegative())
    1152                 return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     1159                return primitiveValueCache->createIdentifierValue(CSSValueNormal);
    11531160            if (length.isPercent())
    11541161                // This is imperfect, because it doesn't include the zoom factor and the real computation
     
    11561163                // On the other hand, since font-size doesn't include the zoom factor, we really can't do
    11571164                // that here either.
    1158                 return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style.get());
    1159             return zoomAdjustedPixelValue(length.value(), style.get());
     1165                return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style.get(), primitiveValueCache);
     1166            return zoomAdjustedPixelValue(length.value(), style.get(), primitiveValueCache);
    11601167        }
    11611168        case CSSPropertyListStyleImage:
    11621169            if (style->listStyleImage())
    11631170                return style->listStyleImage()->cssValue();
    1164             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     1171            return primitiveValueCache->createIdentifierValue(CSSValueNone);
    11651172        case CSSPropertyListStylePosition:
    1166             return CSSPrimitiveValue::create(style->listStylePosition());
     1173            return primitiveValueCache->createValue(style->listStylePosition());
    11671174        case CSSPropertyListStyleType:
    1168             return CSSPrimitiveValue::create(style->listStyleType());
     1175            return primitiveValueCache->createValue(style->listStyleType());
    11691176        case CSSPropertyWebkitLocale:
    11701177            if (style->locale().isNull())
    1171                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    1172             return CSSPrimitiveValue::create(style->locale(), CSSPrimitiveValue::CSS_STRING);
     1178                return primitiveValueCache->createIdentifierValue(CSSValueAuto);
     1179            return primitiveValueCache->createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
    11731180        case CSSPropertyMarginTop: {
    11741181            Length marginTop = style->marginTop();
    11751182            if (marginTop.isPercent())
    1176                 return CSSPrimitiveValue::create(marginTop);
    1177             return zoomAdjustedPixelValue(marginTop.value(), style.get());
     1183                return primitiveValueCache->createValue(marginTop);
     1184            return zoomAdjustedPixelValue(marginTop.value(), style.get(), primitiveValueCache);
    11781185        }
    11791186        case CSSPropertyMarginRight: {
    11801187            Length marginRight = style->marginRight();
    11811188            if (marginRight.isPercent())
    1182                 return CSSPrimitiveValue::create(marginRight);
    1183             return zoomAdjustedPixelValue(marginRight.value(), style.get());
     1189                return primitiveValueCache->createValue(marginRight);
     1190            return zoomAdjustedPixelValue(marginRight.value(), style.get(), primitiveValueCache);
    11841191        }
    11851192        case CSSPropertyMarginBottom: {
    11861193            Length marginBottom = style->marginBottom();
    11871194            if (marginBottom.isPercent())
    1188                 return CSSPrimitiveValue::create(marginBottom);
    1189             return zoomAdjustedPixelValue(marginBottom.value(), style.get());
     1195                return primitiveValueCache->createValue(marginBottom);
     1196            return zoomAdjustedPixelValue(marginBottom.value(), style.get(), primitiveValueCache);
    11901197        }
    11911198        case CSSPropertyMarginLeft: {
    11921199            Length marginLeft = style->marginLeft();
    11931200            if (marginLeft.isPercent())
    1194                 return CSSPrimitiveValue::create(marginLeft);
    1195             return zoomAdjustedPixelValue(marginLeft.value(), style.get());
     1201                return primitiveValueCache->createValue(marginLeft);
     1202            return zoomAdjustedPixelValue(marginLeft.value(), style.get(), primitiveValueCache);
    11961203        }
    11971204        case CSSPropertyWebkitMarqueeDirection:
    1198             return CSSPrimitiveValue::create(style->marqueeDirection());
     1205            return primitiveValueCache->createValue(style->marqueeDirection());
    11991206        case CSSPropertyWebkitMarqueeIncrement:
    1200             return CSSPrimitiveValue::create(style->marqueeIncrement());
     1207            return primitiveValueCache->createValue(style->marqueeIncrement());
    12011208        case CSSPropertyWebkitMarqueeRepetition:
    12021209            if (style->marqueeLoopCount() < 0)
    1203                 return CSSPrimitiveValue::createIdentifier(CSSValueInfinite);
    1204             return CSSPrimitiveValue::create(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
     1210                return primitiveValueCache->createIdentifierValue(CSSValueInfinite);
     1211            return primitiveValueCache->createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
    12051212        case CSSPropertyWebkitMarqueeStyle:
    1206             return CSSPrimitiveValue::create(style->marqueeBehavior());
     1213            return primitiveValueCache->createValue(style->marqueeBehavior());
    12071214        case CSSPropertyWebkitUserModify:
    1208             return CSSPrimitiveValue::create(style->userModify());
     1215            return primitiveValueCache->createValue(style->userModify());
    12091216        case CSSPropertyMaxHeight: {
    12101217            const Length& maxHeight = style->maxHeight();
    12111218            if (maxHeight.isFixed() && maxHeight.value() == undefinedLength)
    1212                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
    1213             return CSSPrimitiveValue::create(maxHeight);
     1219                return primitiveValueCache->createIdentifierValue(CSSValueNone);
     1220            return primitiveValueCache->createValue(maxHeight);
    12141221        }
    12151222        case CSSPropertyMaxWidth: {
    12161223            const Length& maxWidth = style->maxWidth();
    12171224            if (maxWidth.isFixed() && maxWidth.value() == undefinedLength)
    1218                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
    1219             return CSSPrimitiveValue::create(maxWidth);
     1225                return primitiveValueCache->createIdentifierValue(CSSValueNone);
     1226            return primitiveValueCache->createValue(maxWidth);
    12201227        }
    12211228        case CSSPropertyMinHeight:
    1222             return CSSPrimitiveValue::create(style->minHeight());
     1229            return primitiveValueCache->createValue(style->minHeight());
    12231230        case CSSPropertyMinWidth:
    1224             return CSSPrimitiveValue::create(style->minWidth());
     1231            return primitiveValueCache->createValue(style->minWidth());
    12251232        case CSSPropertyOpacity:
    1226             return CSSPrimitiveValue::create(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
     1233            return primitiveValueCache->createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
    12271234        case CSSPropertyOrphans:
    1228             return CSSPrimitiveValue::create(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
     1235            return primitiveValueCache->createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
    12291236        case CSSPropertyOutlineColor:
    1230             return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
     1237            return m_allowVisitedStyle ? primitiveValueCache->createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
    12311238        case CSSPropertyOutlineOffset:
    1232             return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
     1239            return zoomAdjustedPixelValue(style->outlineOffset(), style.get(), primitiveValueCache);
    12331240        case CSSPropertyOutlineStyle:
    12341241            if (style->outlineStyleIsAuto())
    1235                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    1236             return CSSPrimitiveValue::create(style->outlineStyle());
     1242                return primitiveValueCache->createIdentifierValue(CSSValueAuto);
     1243            return primitiveValueCache->createValue(style->outlineStyle());
    12371244        case CSSPropertyOutlineWidth:
    1238             return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
     1245            return zoomAdjustedPixelValue(style->outlineWidth(), style.get(), primitiveValueCache);
    12391246        case CSSPropertyOverflow:
    1240             return CSSPrimitiveValue::create(max(style->overflowX(), style->overflowY()));
     1247            return primitiveValueCache->createValue(max(style->overflowX(), style->overflowY()));
    12411248        case CSSPropertyOverflowX:
    1242             return CSSPrimitiveValue::create(style->overflowX());
     1249            return primitiveValueCache->createValue(style->overflowX());
    12431250        case CSSPropertyOverflowY:
    1244             return CSSPrimitiveValue::create(style->overflowY());
     1251            return primitiveValueCache->createValue(style->overflowY());
    12451252        case CSSPropertyPaddingTop:
    12461253            if (renderer && renderer->isBox())
    1247                 return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingTop(false), style.get());
    1248             return CSSPrimitiveValue::create(style->paddingTop());
     1254                return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingTop(false), style.get(), primitiveValueCache);
     1255            return primitiveValueCache->createValue(style->paddingTop());
    12491256        case CSSPropertyPaddingRight:
    12501257            if (renderer && renderer->isBox())
    1251                 return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingRight(false), style.get());
    1252             return CSSPrimitiveValue::create(style->paddingRight());
     1258                return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingRight(false), style.get(), primitiveValueCache);
     1259            return primitiveValueCache->createValue(style->paddingRight());
    12531260        case CSSPropertyPaddingBottom:
    12541261            if (renderer && renderer->isBox())
    1255                 return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingBottom(false), style.get());
    1256             return CSSPrimitiveValue::create(style->paddingBottom());
     1262                return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingBottom(false), style.get(), primitiveValueCache);
     1263            return primitiveValueCache->createValue(style->paddingBottom());
    12571264        case CSSPropertyPaddingLeft:
    12581265            if (renderer && renderer->isBox())
    1259                 return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingLeft(false), style.get());
    1260             return CSSPrimitiveValue::create(style->paddingLeft());
     1266                return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingLeft(false), style.get(), primitiveValueCache);
     1267            return primitiveValueCache->createValue(style->paddingLeft());
    12611268        case CSSPropertyPageBreakAfter:
    1262             return CSSPrimitiveValue::create(style->pageBreakAfter());
     1269            return primitiveValueCache->createValue(style->pageBreakAfter());
    12631270        case CSSPropertyPageBreakBefore:
    1264             return CSSPrimitiveValue::create(style->pageBreakBefore());
     1271            return primitiveValueCache->createValue(style->pageBreakBefore());
    12651272        case CSSPropertyPageBreakInside: {
    12661273            EPageBreak pageBreak = style->pageBreakInside();
     
    12681275            if (pageBreak == PBALWAYS)
    12691276                return 0;
    1270             return CSSPrimitiveValue::create(style->pageBreakInside());
     1277            return primitiveValueCache->createValue(style->pageBreakInside());
    12711278        }
    12721279        case CSSPropertyPosition:
    1273             return CSSPrimitiveValue::create(style->position());
     1280            return primitiveValueCache->createValue(style->position());
    12741281        case CSSPropertyRight:
    1275             return getPositionOffsetValue(style.get(), CSSPropertyRight);
     1282            return getPositionOffsetValue(style.get(), CSSPropertyRight, primitiveValueCache);
    12761283        case CSSPropertyTableLayout:
    1277             return CSSPrimitiveValue::create(style->tableLayout());
     1284            return primitiveValueCache->createValue(style->tableLayout());
    12781285        case CSSPropertyTextAlign:
    1279             return CSSPrimitiveValue::create(style->textAlign());
     1286            return primitiveValueCache->createValue(style->textAlign());
    12801287        case CSSPropertyTextDecoration:
    1281             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
     1288            return renderTextDecorationFlagsToCSSValue(style->textDecoration(), primitiveValueCache);
    12821289        case CSSPropertyWebkitTextDecorationsInEffect:
    1283             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
     1290            return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect(), primitiveValueCache);
    12841291        case CSSPropertyWebkitTextFillColor:
    12851292            return currentColorOrValidColor(style.get(), style->textFillColor());
     
    12871294            return currentColorOrValidColor(style.get(), style->textEmphasisColor());
    12881295        case CSSPropertyWebkitTextEmphasisPosition:
    1289             return CSSPrimitiveValue::create(style->textEmphasisPosition());
     1296            return primitiveValueCache->createValue(style->textEmphasisPosition());
    12901297        case CSSPropertyWebkitTextEmphasisStyle:
    12911298            switch (style->textEmphasisMark()) {
    12921299            case TextEmphasisMarkNone:
    1293                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     1300                return primitiveValueCache->createIdentifierValue(CSSValueNone);
    12941301            case TextEmphasisMarkCustom:
    1295                 return CSSPrimitiveValue::create(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
     1302                return primitiveValueCache->createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
    12961303            case TextEmphasisMarkAuto:
    12971304                ASSERT_NOT_REACHED();
     
    13031310            case TextEmphasisMarkSesame: {
    13041311                RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    1305                 list->append(CSSPrimitiveValue::create(style->textEmphasisFill()));
    1306                 list->append(CSSPrimitiveValue::create(style->textEmphasisMark()));
     1312                list->append(primitiveValueCache->createValue(style->textEmphasisFill()));
     1313                list->append(primitiveValueCache->createValue(style->textEmphasisMark()));
    13071314                return list.release();
    13081315            }
    13091316            }
    13101317        case CSSPropertyTextIndent:
    1311             return CSSPrimitiveValue::create(style->textIndent());
     1318            return primitiveValueCache->createValue(style->textIndent());
    13121319        case CSSPropertyTextShadow:
    13131320            return valueForShadow(style->textShadow(), propertyID, style.get());
    13141321        case CSSPropertyTextRendering:
    1315             return CSSPrimitiveValue::create(style->fontDescription().textRenderingMode());
     1322            return primitiveValueCache->createValue(style->fontDescription().textRenderingMode());
    13161323        case CSSPropertyTextOverflow:
    13171324            if (style->textOverflow())
    1318                 return CSSPrimitiveValue::createIdentifier(CSSValueEllipsis);
    1319             return CSSPrimitiveValue::createIdentifier(CSSValueClip);
     1325                return primitiveValueCache->createIdentifierValue(CSSValueEllipsis);
     1326            return primitiveValueCache->createIdentifierValue(CSSValueClip);
    13201327        case CSSPropertyWebkitTextSecurity:
    1321             return CSSPrimitiveValue::create(style->textSecurity());
     1328            return primitiveValueCache->createValue(style->textSecurity());
    13221329        case CSSPropertyWebkitTextSizeAdjust:
    13231330            if (style->textSizeAdjust())
    1324                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    1325             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     1331                return primitiveValueCache->createIdentifierValue(CSSValueAuto);
     1332            return primitiveValueCache->createIdentifierValue(CSSValueNone);
    13261333        case CSSPropertyWebkitTextStrokeColor:
    13271334            return currentColorOrValidColor(style.get(), style->textStrokeColor());
    13281335        case CSSPropertyWebkitTextStrokeWidth:
    1329             return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
     1336            return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get(), primitiveValueCache);
    13301337        case CSSPropertyTextTransform:
    1331             return CSSPrimitiveValue::create(style->textTransform());
     1338            return primitiveValueCache->createValue(style->textTransform());
    13321339        case CSSPropertyTop:
    1333             return getPositionOffsetValue(style.get(), CSSPropertyTop);
     1340            return getPositionOffsetValue(style.get(), CSSPropertyTop, primitiveValueCache);
    13341341        case CSSPropertyUnicodeBidi:
    1335             return CSSPrimitiveValue::create(style->unicodeBidi());
     1342            return primitiveValueCache->createValue(style->unicodeBidi());
    13361343        case CSSPropertyVerticalAlign:
    13371344            switch (style->verticalAlign()) {
    13381345                case BASELINE:
    1339                     return CSSPrimitiveValue::createIdentifier(CSSValueBaseline);
     1346                    return primitiveValueCache->createIdentifierValue(CSSValueBaseline);
    13401347                case MIDDLE:
    1341                     return CSSPrimitiveValue::createIdentifier(CSSValueMiddle);
     1348                    return primitiveValueCache->createIdentifierValue(CSSValueMiddle);
    13421349                case SUB:
    1343                     return CSSPrimitiveValue::createIdentifier(CSSValueSub);
     1350                    return primitiveValueCache->createIdentifierValue(CSSValueSub);
    13441351                case SUPER:
    1345                     return CSSPrimitiveValue::createIdentifier(CSSValueSuper);
     1352                    return primitiveValueCache->createIdentifierValue(CSSValueSuper);
    13461353                case TEXT_TOP:
    1347                     return CSSPrimitiveValue::createIdentifier(CSSValueTextTop);
     1354                    return primitiveValueCache->createIdentifierValue(CSSValueTextTop);
    13481355                case TEXT_BOTTOM:
    1349                     return CSSPrimitiveValue::createIdentifier(CSSValueTextBottom);
     1356                    return primitiveValueCache->createIdentifierValue(CSSValueTextBottom);
    13501357                case TOP:
    1351                     return CSSPrimitiveValue::createIdentifier(CSSValueTop);
     1358                    return primitiveValueCache->createIdentifierValue(CSSValueTop);
    13521359                case BOTTOM:
    1353                     return CSSPrimitiveValue::createIdentifier(CSSValueBottom);
     1360                    return primitiveValueCache->createIdentifierValue(CSSValueBottom);
    13541361                case BASELINE_MIDDLE:
    1355                     return CSSPrimitiveValue::createIdentifier(CSSValueWebkitBaselineMiddle);
     1362                    return primitiveValueCache->createIdentifierValue(CSSValueWebkitBaselineMiddle);
    13561363                case LENGTH:
    1357                     return CSSPrimitiveValue::create(style->verticalAlignLength());
     1364                    return primitiveValueCache->createValue(style->verticalAlignLength());
    13581365            }
    13591366            ASSERT_NOT_REACHED();
    13601367            return 0;
    13611368        case CSSPropertyVisibility:
    1362             return CSSPrimitiveValue::create(style->visibility());
     1369            return primitiveValueCache->createValue(style->visibility());
    13631370        case CSSPropertyWhiteSpace:
    1364             return CSSPrimitiveValue::create(style->whiteSpace());
     1371            return primitiveValueCache->createValue(style->whiteSpace());
    13651372        case CSSPropertyWidows:
    1366             return CSSPrimitiveValue::create(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
     1373            return primitiveValueCache->createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
    13671374        case CSSPropertyWidth:
    13681375            if (renderer)
    1369                 return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
    1370             return zoomAdjustedPixelValueForLength(style->width(), style.get());
     1376                return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get(), primitiveValueCache);
     1377            return zoomAdjustedPixelValueForLength(style->width(), style.get(), primitiveValueCache);
    13711378        case CSSPropertyWordBreak:
    1372             return CSSPrimitiveValue::create(style->wordBreak());
     1379            return primitiveValueCache->createValue(style->wordBreak());
    13731380        case CSSPropertyWordSpacing:
    1374             return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
     1381            return zoomAdjustedPixelValue(style->wordSpacing(), style.get(), primitiveValueCache);
    13751382        case CSSPropertyWordWrap:
    1376             return CSSPrimitiveValue::create(style->wordWrap());
     1383            return primitiveValueCache->createValue(style->wordWrap());
    13771384        case CSSPropertyWebkitLineBreak:
    1378             return CSSPrimitiveValue::create(style->khtmlLineBreak());
     1385            return primitiveValueCache->createValue(style->khtmlLineBreak());
    13791386        case CSSPropertyWebkitNbspMode:
    1380             return CSSPrimitiveValue::create(style->nbspMode());
     1387            return primitiveValueCache->createValue(style->nbspMode());
    13811388        case CSSPropertyWebkitMatchNearestMailBlockquoteColor:
    1382             return CSSPrimitiveValue::create(style->matchNearestMailBlockquoteColor());
     1389            return primitiveValueCache->createValue(style->matchNearestMailBlockquoteColor());
    13831390        case CSSPropertyResize:
    1384             return CSSPrimitiveValue::create(style->resize());
     1391            return primitiveValueCache->createValue(style->resize());
    13851392        case CSSPropertyWebkitFontSmoothing:
    1386             return CSSPrimitiveValue::create(style->fontDescription().fontSmoothing());
     1393            return primitiveValueCache->createValue(style->fontDescription().fontSmoothing());
    13871394        case CSSPropertyZIndex:
    13881395            if (style->hasAutoZIndex())
    1389                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    1390             return CSSPrimitiveValue::create(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
     1396                return primitiveValueCache->createIdentifierValue(CSSValueAuto);
     1397            return primitiveValueCache->createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
    13911398        case CSSPropertyZoom:
    1392             return CSSPrimitiveValue::create(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
     1399            return primitiveValueCache->createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
    13931400        case CSSPropertyBoxSizing:
    13941401            if (style->boxSizing() == CONTENT_BOX)
    1395                 return CSSPrimitiveValue::createIdentifier(CSSValueContentBox);
    1396             return CSSPrimitiveValue::createIdentifier(CSSValueBorderBox);
     1402                return primitiveValueCache->createIdentifierValue(CSSValueContentBox);
     1403            return primitiveValueCache->createIdentifierValue(CSSValueBorderBox);
    13971404#if ENABLE(DASHBOARD_SUPPORT)
    13981405        case CSSPropertyWebkitDashboardRegion:
     
    14011408            unsigned count = regions.size();
    14021409            if (count == 1 && regions[0].type == StyleDashboardRegion::None)
    1403                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     1410                return primitiveValueCache->createIdentifierValue(CSSValueNone);
    14041411
    14051412            RefPtr<DashboardRegion> firstRegion;
     
    14111418                region->m_label = styleRegion.label;
    14121419                LengthBox offset = styleRegion.offset;
    1413                 region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
    1414                 region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
    1415                 region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
    1416                 region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
     1420                region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get(), primitiveValueCache));
     1421                region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get(), primitiveValueCache));
     1422                region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get(), primitiveValueCache));
     1423                region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get(), primitiveValueCache));
    14171424                region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
    14181425                region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
     
    14241431                previousRegion = region.get();
    14251432            }
    1426             return CSSPrimitiveValue::create(firstRegion.release());
     1433            return primitiveValueCache->createValue(firstRegion.release());
    14271434        }
    14281435#endif
    14291436        case CSSPropertyWebkitAnimationDelay:
    1430             return getDelayValue(style->animations());
     1437            return getDelayValue(style->animations(), primitiveValueCache);
    14311438        case CSSPropertyWebkitAnimationDirection: {
    14321439            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     
    14351442                for (size_t i = 0; i < t->size(); ++i) {
    14361443                    if (t->animation(i)->direction())
    1437                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueAlternate));
     1444                        list->append(primitiveValueCache->createIdentifierValue(CSSValueAlternate));
    14381445                    else
    1439                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueNormal));
     1446                        list->append(primitiveValueCache->createIdentifierValue(CSSValueNormal));
    14401447                }
    14411448            } else
    1442                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNormal));
     1449                list->append(primitiveValueCache->createIdentifierValue(CSSValueNormal));
    14431450            return list.release();
    14441451        }
    14451452        case CSSPropertyWebkitAnimationDuration:
    1446             return getDurationValue(style->animations());
     1453            return getDurationValue(style->animations(), primitiveValueCache);
    14471454        case CSSPropertyWebkitAnimationFillMode: {
    14481455            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     
    14521459                    switch (t->animation(i)->fillMode()) {
    14531460                    case AnimationFillModeNone:
    1454                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
     1461                        list->append(primitiveValueCache->createIdentifierValue(CSSValueNone));
    14551462                        break;
    14561463                    case AnimationFillModeForwards:
    1457                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueForwards));
     1464                        list->append(primitiveValueCache->createIdentifierValue(CSSValueForwards));
    14581465                        break;
    14591466                    case AnimationFillModeBackwards:
    1460                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueBackwards));
     1467                        list->append(primitiveValueCache->createIdentifierValue(CSSValueBackwards));
    14611468                        break;
    14621469                    case AnimationFillModeBoth:
    1463                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueBoth));
     1470                        list->append(primitiveValueCache->createIdentifierValue(CSSValueBoth));
    14641471                        break;
    14651472                    }
    14661473                }
    14671474            } else
    1468                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
     1475                list->append(primitiveValueCache->createIdentifierValue(CSSValueNone));
    14691476            return list.release();
    14701477        }
     
    14761483                    int iterationCount = t->animation(i)->iterationCount();
    14771484                    if (iterationCount == Animation::IterationCountInfinite)
    1478                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueInfinite));
     1485                        list->append(primitiveValueCache->createIdentifierValue(CSSValueInfinite));
    14791486                    else
    1480                         list->append(CSSPrimitiveValue::create(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
     1487                        list->append(primitiveValueCache->createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
    14811488                }
    14821489            } else
    1483                 list->append(CSSPrimitiveValue::create(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
     1490                list->append(primitiveValueCache->createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
    14841491            return list.release();
    14851492        }
     
    14891496            if (t) {
    14901497                for (size_t i = 0; i < t->size(); ++i)
    1491                     list->append(CSSPrimitiveValue::create(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING));
     1498                    list->append(primitiveValueCache->createValue(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING));
    14921499            } else
    1493                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
     1500                list->append(primitiveValueCache->createIdentifierValue(CSSValueNone));
    14941501            return list.release();
    14951502        }
     
    15011508                    int prop = t->animation(i)->playState();
    15021509                    if (prop == AnimPlayStatePlaying)
    1503                         list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning));
     1510                        list->append(primitiveValueCache->createIdentifierValue(CSSValueRunning));
    15041511                    else
    1505                         list->append(CSSPrimitiveValue::createIdentifier(CSSValuePaused));
     1512                        list->append(primitiveValueCache->createIdentifierValue(CSSValuePaused));
    15061513                }
    15071514            } else
    1508                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning));
     1515                list->append(primitiveValueCache->createIdentifierValue(CSSValueRunning));
    15091516            return list.release();
    15101517        }
     
    15121519            return getTimingFunctionValue(style->animations());
    15131520        case CSSPropertyWebkitAppearance:
    1514             return CSSPrimitiveValue::create(style->appearance());
     1521            return primitiveValueCache->createValue(style->appearance());
    15151522        case CSSPropertyWebkitBackfaceVisibility:
    1516             return CSSPrimitiveValue::createIdentifier((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
     1523            return primitiveValueCache->createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
    15171524        case CSSPropertyWebkitBorderImage:
    1518             return valueForNinePieceImage(style->borderImage());
     1525            return valueForNinePieceImage(style->borderImage(), primitiveValueCache);
    15191526        case CSSPropertyWebkitMaskBoxImage:
    1520             return valueForNinePieceImage(style->maskBoxImage());
     1527            return valueForNinePieceImage(style->maskBoxImage(), primitiveValueCache);
    15211528        case CSSPropertyWebkitFontSizeDelta:
    15221529            // Not a real style property -- used by the editing engine -- so has no computed value.
     
    15241531        case CSSPropertyWebkitMarginBottomCollapse:
    15251532        case CSSPropertyWebkitMarginAfterCollapse:
    1526             return CSSPrimitiveValue::create(style->marginAfterCollapse());
     1533            return primitiveValueCache->createValue(style->marginAfterCollapse());
    15271534        case CSSPropertyWebkitMarginTopCollapse:
    15281535        case CSSPropertyWebkitMarginBeforeCollapse:
    1529             return CSSPrimitiveValue::create(style->marginBeforeCollapse());
     1536            return primitiveValueCache->createValue(style->marginBeforeCollapse());
    15301537        case CSSPropertyWebkitPerspective:
    15311538            if (!style->hasPerspective())
    1532                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
    1533             return CSSPrimitiveValue::create(style->perspective(), CSSPrimitiveValue::CSS_NUMBER);
     1539                return primitiveValueCache->createIdentifierValue(CSSValueNone);
     1540            return primitiveValueCache->createValue(style->perspective(), CSSPrimitiveValue::CSS_NUMBER);
    15341541        case CSSPropertyWebkitPerspectiveOrigin: {
    15351542            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    15361543            if (renderer) {
    15371544                IntRect box = sizingBox(renderer);
    1538                 list->append(zoomAdjustedPixelValue(style->perspectiveOriginX().calcMinValue(box.width()), style.get()));
    1539                 list->append(zoomAdjustedPixelValue(style->perspectiveOriginY().calcMinValue(box.height()), style.get()));
     1545                list->append(zoomAdjustedPixelValue(style->perspectiveOriginX().calcMinValue(box.width()), style.get(), primitiveValueCache));
     1546                list->append(zoomAdjustedPixelValue(style->perspectiveOriginY().calcMinValue(box.height()), style.get(), primitiveValueCache));
    15401547            }
    15411548            else {
    1542                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
    1543                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
     1549                list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get(), primitiveValueCache));
     1550                list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get(), primitiveValueCache));
    15441551               
    15451552            }
     
    15481555        case CSSPropertyWebkitRtlOrdering:
    15491556            if (style->visuallyOrdered())
    1550                 return CSSPrimitiveValue::createIdentifier(CSSValueVisual);
    1551             return CSSPrimitiveValue::createIdentifier(CSSValueLogical);
     1557                return primitiveValueCache->createIdentifierValue(CSSValueVisual);
     1558            return primitiveValueCache->createIdentifierValue(CSSValueLogical);
    15521559        case CSSPropertyWebkitUserDrag:
    1553             return CSSPrimitiveValue::create(style->userDrag());
     1560            return primitiveValueCache->createValue(style->userDrag());
    15541561        case CSSPropertyWebkitUserSelect:
    1555             return CSSPrimitiveValue::create(style->userSelect());
     1562            return primitiveValueCache->createValue(style->userSelect());
    15561563        case CSSPropertyBorderBottomLeftRadius:
    1557             return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get());
     1564            return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), primitiveValueCache);
    15581565        case CSSPropertyBorderBottomRightRadius:
    1559             return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get());
     1566            return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), primitiveValueCache);
    15601567        case CSSPropertyBorderTopLeftRadius:
    1561             return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get());
     1568            return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), primitiveValueCache);
    15621569        case CSSPropertyBorderTopRightRadius:
    1563             return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get());
     1570            return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), primitiveValueCache);
    15641571        case CSSPropertyClip: {
    15651572            if (!style->hasClip())
    1566                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     1573                return primitiveValueCache->createIdentifierValue(CSSValueAuto);
    15671574            RefPtr<Rect> rect = Rect::create();
    1568             rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
    1569             rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
    1570             rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
    1571             rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
    1572             return CSSPrimitiveValue::create(rect.release());
     1575            rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get(), primitiveValueCache));
     1576            rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get(), primitiveValueCache));
     1577            rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get(), primitiveValueCache));
     1578            rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get(), primitiveValueCache));
     1579            return primitiveValueCache->createValue(rect.release());
    15731580        }
    15741581        case CSSPropertySpeak:
    1575             return CSSPrimitiveValue::create(style->speak());
     1582            return primitiveValueCache->createValue(style->speak());
    15761583        case CSSPropertyWebkitTransform:
    1577             return computedTransform(renderer, style.get());
     1584            return computedTransform(renderer, style.get(), primitiveValueCache);
    15781585        case CSSPropertyWebkitTransformOrigin: {
    15791586            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    15801587            if (renderer) {
    15811588                IntRect box = sizingBox(renderer);
    1582                 list->append(zoomAdjustedPixelValue(style->transformOriginX().calcMinValue(box.width()), style.get()));
    1583                 list->append(zoomAdjustedPixelValue(style->transformOriginY().calcMinValue(box.height()), style.get()));
     1589                list->append(zoomAdjustedPixelValue(style->transformOriginX().calcMinValue(box.width()), style.get(), primitiveValueCache));
     1590                list->append(zoomAdjustedPixelValue(style->transformOriginY().calcMinValue(box.height()), style.get(), primitiveValueCache));
    15841591                if (style->transformOriginZ() != 0)
    1585                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
     1592                    list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get(), primitiveValueCache));
    15861593            } else {
    1587                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
    1588                 list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
     1594                list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get(), primitiveValueCache));
     1595                list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get(), primitiveValueCache));
    15891596                if (style->transformOriginZ() != 0)
    1590                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
     1597                    list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get(), primitiveValueCache));
    15911598            }
    15921599            return list.release();
    15931600        }
    15941601        case CSSPropertyWebkitTransformStyle:
    1595             return CSSPrimitiveValue::createIdentifier((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
     1602            return primitiveValueCache->createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
    15961603        case CSSPropertyWebkitTransitionDelay:
    1597             return getDelayValue(style->transitions());
     1604            return getDelayValue(style->transitions(), primitiveValueCache);
    15981605        case CSSPropertyWebkitTransitionDuration:
    1599             return getDurationValue(style->transitions());
     1606            return getDurationValue(style->transitions(), primitiveValueCache);
    16001607        case CSSPropertyWebkitTransitionProperty: {
    16011608            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     
    16061613                    RefPtr<CSSValue> propertyValue;
    16071614                    if (prop == cAnimateNone)
    1608                         propertyValue = CSSPrimitiveValue::createIdentifier(CSSValueNone);
     1615                        propertyValue = primitiveValueCache->createIdentifierValue(CSSValueNone);
    16091616                    else if (prop == cAnimateAll)
    1610                         propertyValue = CSSPrimitiveValue::createIdentifier(CSSValueAll);
     1617                        propertyValue = primitiveValueCache->createIdentifierValue(CSSValueAll);
    16111618                    else
    1612                         propertyValue = CSSPrimitiveValue::create(getPropertyName(static_cast<CSSPropertyID>(prop)), CSSPrimitiveValue::CSS_STRING);
     1619                        propertyValue = primitiveValueCache->createValue(getPropertyName(static_cast<CSSPropertyID>(prop)), CSSPrimitiveValue::CSS_STRING);
    16131620                    list->append(propertyValue);
    16141621                }
    16151622            } else
    1616                 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAll));
     1623                list->append(primitiveValueCache->createIdentifierValue(CSSValueAll));
    16171624            return list.release();
    16181625        }
     
    16201627            return getTimingFunctionValue(style->transitions());
    16211628        case CSSPropertyPointerEvents:
    1622             return CSSPrimitiveValue::create(style->pointerEvents());
     1629            return primitiveValueCache->createValue(style->pointerEvents());
    16231630        case CSSPropertyWebkitColorCorrection:
    1624             return CSSPrimitiveValue::create(style->colorSpace());
     1631            return primitiveValueCache->createValue(style->colorSpace());
    16251632        case CSSPropertyWebkitWritingMode:
    1626             return CSSPrimitiveValue::create(style->writingMode());
     1633            return primitiveValueCache->createValue(style->writingMode());
    16271634        case CSSPropertyWebkitTextCombine:
    1628             return CSSPrimitiveValue::create(style->textCombine());
     1635            return primitiveValueCache->createValue(style->textCombine());
    16291636
    16301637        case CSSPropertyContent:
    1631             return contentToCSSValue(style.get());
     1638            return contentToCSSValue(style.get(), primitiveValueCache);
    16321639        case CSSPropertyCounterIncrement:
    1633             return counterToCSSValue(style.get(), propertyID);
     1640            return counterToCSSValue(style.get(), propertyID, primitiveValueCache);
    16341641        case CSSPropertyCounterReset:
    1635             return counterToCSSValue(style.get(), propertyID);
     1642            return counterToCSSValue(style.get(), propertyID, primitiveValueCache);
    16361643       
    16371644        /* Shorthand properties, currently not supported see bug 13658*/
  • trunk/Source/WebCore/css/CSSParser.cpp

    r80438 r80463  
    4141#include "CSSPageRule.h"
    4242#include "CSSPrimitiveValue.h"
     43#include "CSSPrimitiveValueCache.h"
    4344#include "CSSProperty.h"
    4445#include "CSSPropertyNames.h"
     
    222223void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
    223224{
    224     m_styleSheet = sheet;
     225    setStyleSheet(sheet);
    225226    m_defaultNamespace = starAtom; // Reset the default namespace.
    226227    m_ruleRangeMap = ruleRangeMap;
     
    240241PassRefPtr<CSSRule> CSSParser::parseRule(CSSStyleSheet* sheet, const String& string)
    241242{
    242     m_styleSheet = sheet;
     243    setStyleSheet(sheet);
    243244    m_allowNamespaceDeclarations = false;
    244245    setupParser("@-webkit-rule{", string, "} ");
     
    249250PassRefPtr<CSSRule> CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string)
    250251{
    251     m_styleSheet = sheet;
     252    setStyleSheet(sheet);
    252253    setupParser("@-webkit-keyframe-rule{ ", string, "} ");
    253254    cssyyparse(this);
     
    258259{
    259260    ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
    260     m_styleSheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
     261    setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
    261262
    262263    setupParser("@-webkit-value{", string, "} ");
     
    311312{
    312313    ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
    313     m_styleSheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
     314    setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
    314315
    315316    setupParser("@-webkit-decls{color:", string, "} ");
     
    340341    RefPtr<CSSStyleSheet> dummyStyleSheet = CSSStyleSheet::create(doc);
    341342
    342     m_styleSheet = dummyStyleSheet.get();
     343    setStyleSheet(dummyStyleSheet.get());
    343344    m_selectorListForParseSelector = &selectorList;
    344345
     
    359360
    360361    ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
    361     m_styleSheet = static_cast<CSSStyleSheet*>(declaration->stylesheet());
     362    setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
    362363    if (styleSourceData) {
    363364        m_currentRuleData = CSSRuleSourceData::create();
     
    447448    m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES;
    448449    m_hasFontFaceOnlyValues = false;
     450}
     451   
     452void CSSParser::setStyleSheet(CSSStyleSheet* styleSheet)
     453{
     454    m_styleSheet = styleSheet;
     455    m_primitiveValueCache = document() ? document()->cssPrimitiveValueCache() : CSSPrimitiveValueCache::create();
    449456}
    450457
     
    907914                    return false;
    908915            } else if (!m_strict && value->id == CSSValueHand) // MSIE 5 compatibility :/
    909                 list->append(CSSPrimitiveValue::createIdentifier(CSSValuePointer));
     916                list->append(primitiveValueCache()->createIdentifierValue(CSSValuePointer));
    910917            else if (value && ((value->id >= CSSValueAuto && value->id <= CSSValueWebkitGrabbing) || value->id == CSSValueCopy || value->id == CSSValueNone))
    911                 list->append(CSSPrimitiveValue::createIdentifier(value->id));
     918                list->append(primitiveValueCache()->createIdentifierValue(value->id));
    912919            m_valueList->next();
    913920            parsedValue = list.release();
     
    11661173                case CSSValueOverline:
    11671174                case CSSValueLineThrough:
    1168                     list->append(CSSPrimitiveValue::createIdentifier(value->id));
     1175                    list->append(primitiveValueCache()->createIdentifierValue(value->id));
    11691176                    break;
    11701177                default:
     
    12251232        if (!validPrimitive)
    12261233            return false;
    1227         RefPtr<CSSPrimitiveValue> parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     1234        RefPtr<CSSPrimitiveValue> parsedValue1 = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
    12281235        RefPtr<CSSPrimitiveValue> parsedValue2;
    12291236        if (num == 2) {
     
    12321239            if (!validPrimitive)
    12331240                return false;
    1234             parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     1241            parsedValue2 = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
    12351242        } else
    12361243            parsedValue2 = parsedValue1;
    12371244
    12381245        RefPtr<Pair> pair = Pair::create(parsedValue1.release(), parsedValue2.release());
    1239         RefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(pair.release());
     1246        RefPtr<CSSPrimitiveValue> val = primitiveValueCache()->createValue(pair.release());
    12401247        addProperty(propId, val.release(), important);
    12411248        return true;
     
    14161423            // Accepting valueless numbers is a quirk of the -webkit prefixed version of the property.
    14171424            if (validUnit(value, FNumber | FLength | FNonNeg, m_strict)) {
    1418                 RefPtr<CSSValue> val = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     1425                RefPtr<CSSValue> val = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
    14191426                if (val) {
    14201427                    addProperty(propId, val.release(), important);
     
    18341841    if (validPrimitive) {
    18351842        if (id != 0)
    1836             parsedValue = CSSPrimitiveValue::createIdentifier(id);
     1843            parsedValue = primitiveValueCache()->createIdentifierValue(id);
    18371844        else if (value->unit == CSSPrimitiveValue::CSS_STRING)
    1838             parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
     1845            parsedValue = primitiveValueCache()->createValue(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
    18391846        else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
    1840             parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     1847            parsedValue = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
    18411848        else if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
    1842             parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     1849            parsedValue = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
    18431850        else if (value->unit >= CSSParserValue::Q_EMS)
    18441851            parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
     
    18641871
    18651872    if (!inputProperty.isEmpty())
    1866        parsedValue = CSSPrimitiveValue::create(inputProperty, CSSPrimitiveValue::CSS_STRING);
     1873       parsedValue = primitiveValueCache()->createValue(inputProperty, CSSPrimitiveValue::CSS_STRING);
    18671874
    18681875    while (m_valueList->next()) {
     
    18921899}
    18931900
    1894 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr<CSSValue>& cssValue)
     1901static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr<CSSValue>& cssValue, CSSPrimitiveValueCache* primitiveValueCache)
    18951902{
    18961903    if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddingBox
    18971904        || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueWebkitText) {
    1898         cssValue = CSSPrimitiveValue::createIdentifier(parserValue->id);
     1905        cssValue = primitiveValueCache->createIdentifierValue(parserValue->id);
    18991906        return true;
    19001907    }
     
    19641971                    if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) {
    19651972                        // Reparse the value as a clip, and see if we succeed.
    1966                         if (parseBackgroundClip(parserValue, val1))
     1973                        if (parseBackgroundClip(parserValue, val1, primitiveValueCache()))
    19671974                            addFillValue(clipValue, val1.release()); // The property parsed successfully.
    19681975                        else
     
    22812288
    22822289    if (value->id == CSSValueAuto) {
    2283         addProperty(propId, CSSPrimitiveValue::createIdentifier(value->id), important);
     2290        addProperty(propId, primitiveValueCache()->createIdentifierValue(value->id), important);
    22842291        return true;
    22852292    } else if (value->id == 0 && value->unit == CSSPrimitiveValue::CSS_IDENT) {
    2286         addProperty(propId, CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_STRING), important);
     2293        addProperty(propId, primitiveValueCache()->createValue(value->string, CSSPrimitiveValue::CSS_STRING), important);
    22872294        return true;
    22882295    }
     
    23262333    case CSSValueAuto:
    23272334        if (prevParamType == None) {
    2328             parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id));
     2335            parsedValues->append(primitiveValueCache()->createIdentifierValue(value->id));
    23292336            return Auto;
    23302337        }
     
    23332340    case CSSValuePortrait:
    23342341        if (prevParamType == None || prevParamType == PageSize) {
    2335             parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id));
     2342            parsedValues->append(primitiveValueCache()->createIdentifierValue(value->id));
    23362343            return Orientation;
    23372344        }
     
    23482355            // Normalize to Page Size then Orientation order by prepending.
    23492356            // This is not specified by the CSS3 Paged Media specification, but for simpler processing later (CSSStyleSelector::applyPageSizeProperty).
    2350             parsedValues->prepend(CSSPrimitiveValue::createIdentifier(value->id));
     2357            parsedValues->prepend(primitiveValueCache()->createIdentifierValue(value->id));
    23512358            return PageSize;
    23522359        }
     
    23542361    case 0:
    23552362        if (validUnit(value, FLength | FNonNeg, m_strict) && (prevParamType == None || prevParamType == Length)) {
    2356             parsedValues->append(CSSPrimitiveValue::create(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit)));
     2363            parsedValues->append(primitiveValueCache()->createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit)));
    23572364            return Length;
    23582365        }
     
    24372444            case CSSValueNone:
    24382445            case CSSValueNormal:
    2439                 parsedValue = CSSPrimitiveValue::createIdentifier(val->id);
     2446                parsedValue = primitiveValueCache()->createIdentifierValue(val->id);
    24402447            }
    24412448        } else if (val->unit == CSSPrimitiveValue::CSS_STRING) {
    2442             parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue::CSS_STRING);
     2449            parsedValue = primitiveValueCache()->createValue(val->string, CSSPrimitiveValue::CSS_STRING);
    24432450        }
    24442451        if (!parsedValue)
     
    24772484        attrName = attrName.lower();
    24782485
    2479     return CSSPrimitiveValue::create(attrName, CSSPrimitiveValue::CSS_ATTR);
     2486    return primitiveValueCache()->createValue(attrName, CSSPrimitiveValue::CSS_ATTR);
    24802487}
    24812488
     
    24852492    if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu || id == CSSValueCurrentcolor ||
    24862493        (id >= CSSValueGrey && id < CSSValueWebkitText && !m_strict))
    2487        return CSSPrimitiveValue::createIdentifier(id);
     2494       return primitiveValueCache()->createIdentifierValue(id);
    24882495    return parseColor();
    24892496}
     
    25312538            // Center is ambiguous, so we're not sure which position we've found yet, an x or a y.
    25322539            percent = 50;
    2533         return CSSPrimitiveValue::create(percent, CSSPrimitiveValue::CSS_PERCENTAGE);
     2540        return primitiveValueCache()->createValue(percent, CSSPrimitiveValue::CSS_PERCENTAGE);
    25342541    }
    25352542    if (validUnit(valueList->current(), FPercent | FLength, m_strict))
    2536         return CSSPrimitiveValue::create(valueList->current()->fValue,
     2543        return primitiveValueCache()->createValue(valueList->current()->fValue,
    25372544                                         (CSSPrimitiveValue::UnitTypes)valueList->current()->unit);
    25382545
     
    25772584        // For keywords, the keyword was either an x-keyword (left/right), a y-keyword (top/bottom), or an ambiguous keyword (center).
    25782585        // For left/right/center, the default of 50% in the y is still correct.
    2579         value2 = CSSPrimitiveValue::create(50, CSSPrimitiveValue::CSS_PERCENTAGE);
     2586        value2 = primitiveValueCache()->createValue(50, CSSPrimitiveValue::CSS_PERCENTAGE);
    25802587
    25812588    if (value1IsY || value2IsX)
     
    25902597    if (id == CSSValueRepeatX) {
    25912598        m_implicitShorthand = true;
    2592         value1 = CSSPrimitiveValue::createIdentifier(CSSValueRepeat);
    2593         value2 = CSSPrimitiveValue::createIdentifier(CSSValueNoRepeat);
     2599        value1 = primitiveValueCache()->createIdentifierValue(CSSValueRepeat);
     2600        value2 = primitiveValueCache()->createIdentifierValue(CSSValueNoRepeat);
    25942601        m_valueList->next();
    25952602        return;
     
    25972604    if (id == CSSValueRepeatY) {
    25982605        m_implicitShorthand = true;
    2599         value1 = CSSPrimitiveValue::createIdentifier(CSSValueNoRepeat);
    2600         value2 = CSSPrimitiveValue::createIdentifier(CSSValueRepeat);
     2606        value1 = primitiveValueCache()->createIdentifierValue(CSSValueNoRepeat);
     2607        value2 = primitiveValueCache()->createIdentifierValue(CSSValueRepeat);
    26012608        m_valueList->next();
    26022609        return;
    26032610    }
    26042611    if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRound || id == CSSValueSpace)
    2605         value1 = CSSPrimitiveValue::createIdentifier(id);
     2612        value1 = primitiveValueCache()->createIdentifierValue(id);
    26062613    else {
    26072614        value1 = 0;
     
    26192626
    26202627    if (value && (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRound || id == CSSValueSpace)) {
    2621         value2 = CSSPrimitiveValue::createIdentifier(id);
     2628        value2 = primitiveValueCache()->createIdentifierValue(id);
    26222629        m_valueList->next();
    26232630    } else {
    26242631        // If only one value was specified, value2 is the same as value1.
    26252632        m_implicitShorthand = true;
    2626         value2 = CSSPrimitiveValue::createIdentifier(static_cast<CSSPrimitiveValue*>(value1.get())->getIdent());
     2633        value2 = primitiveValueCache()->createIdentifierValue(static_cast<CSSPrimitiveValue*>(value1.get())->getIdent());
    26272634    }
    26282635}
     
    26342641
    26352642    if (value->id == CSSValueContain || value->id == CSSValueCover)
    2636         return CSSPrimitiveValue::createIdentifier(value->id);
     2643        return primitiveValueCache()->createIdentifierValue(value->id);
    26372644
    26382645    RefPtr<CSSPrimitiveValue> parsedValue1;
    26392646
    26402647    if (value->id == CSSValueAuto)
    2641         parsedValue1 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
     2648        parsedValue1 = primitiveValueCache()->createValue(0, CSSPrimitiveValue::CSS_UNKNOWN);
    26422649    else {
    26432650        if (!validUnit(value, FLength | FPercent, m_strict))
    26442651            return 0;
    2645         parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     2652        parsedValue1 = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
    26462653    }
    26472654
     
    26502657    if ((value = m_valueList->next())) {
    26512658        if (value->id == CSSValueAuto)
    2652             parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
     2659            parsedValue2 = primitiveValueCache()->createValue(0, CSSPrimitiveValue::CSS_UNKNOWN);
    26532660        else if (value->unit == CSSParserValue::Operator && value->iValue == ',')
    26542661            allowComma = false;
     
    26562663            if (!validUnit(value, FLength | FPercent, m_strict))
    26572664                return 0;
    2658             parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     2665            parsedValue2 = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
    26592666        }
    26602667    }
     
    26632670            parsedValue2 = parsedValue1;
    26642671        else
    2665             parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
    2666     }
    2667 
    2668     return CSSPrimitiveValue::create(Pair::create(parsedValue1.release(), parsedValue2.release()));
     2672            parsedValue2 = primitiveValueCache()->createValue(0, CSSPrimitiveValue::CSS_UNKNOWN);
     2673    }
     2674
     2675    return primitiveValueCache()->createValue(Pair::create(parsedValue1.release(), parsedValue2.release()));
    26692676}
    26702677
     
    27172724                case CSSPropertyWebkitMaskAttachment:
    27182725                    if (val->id == CSSValueScroll || val->id == CSSValueFixed || val->id == CSSValueLocal) {
    2719                         currValue = CSSPrimitiveValue::createIdentifier(val->id);
     2726                        currValue = primitiveValueCache()->createIdentifierValue(val->id);
    27202727                        m_valueList->next();
    27212728                    }
     
    27362743                        ((propId == CSSPropertyWebkitBackgroundClip || propId == CSSPropertyWebkitMaskClip) &&
    27372744                         (val->id == CSSValueText || val->id == CSSValueWebkitText))) {
    2738                         currValue = CSSPrimitiveValue::createIdentifier(val->id);
     2745                        currValue = primitiveValueCache()->createIdentifierValue(val->id);
    27392746                        m_valueList->next();
    27402747                    }
    27412748                    break;
    27422749                case CSSPropertyBackgroundClip:
    2743                     if (parseBackgroundClip(val, currValue))
     2750                    if (parseBackgroundClip(val, currValue, primitiveValueCache()))
    27442751                        m_valueList->next();
    27452752                    break;
    27462753                case CSSPropertyBackgroundOrigin:
    27472754                    if (val->id == CSSValueBorderBox || val->id == CSSValuePaddingBox || val->id == CSSValueContentBox) {
    2748                         currValue = CSSPrimitiveValue::createIdentifier(val->id);
     2755                        currValue = primitiveValueCache()->createIdentifierValue(val->id);
    27492756                        m_valueList->next();
    27502757                    }
     
    27742781                case CSSPropertyWebkitMaskComposite:
    27752782                    if ((val->id >= CSSValueClear && val->id <= CSSValuePlusLighter) || val->id == CSSValueHighlight) {
    2776                         currValue = CSSPrimitiveValue::createIdentifier(val->id);
     2783                        currValue = primitiveValueCache()->createIdentifierValue(val->id);
    27772784                        m_valueList->next();
    27782785                    }
     
    28412848    CSSParserValue* value = m_valueList->current();
    28422849    if (validUnit(value, FTime, m_strict))
    2843         return CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     2850        return primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
    28442851    return 0;
    28452852}
     
    28492856    CSSParserValue* value = m_valueList->current();
    28502857    if (value->id == CSSValueNormal || value->id == CSSValueAlternate)
    2851         return CSSPrimitiveValue::createIdentifier(value->id);
     2858        return primitiveValueCache()->createIdentifierValue(value->id);
    28522859    return 0;
    28532860}
     
    28572864    CSSParserValue* value = m_valueList->current();
    28582865    if (validUnit(value, FTime | FNonNeg, m_strict))
    2859         return CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     2866        return primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
    28602867    return 0;
    28612868}
     
    28652872    CSSParserValue* value = m_valueList->current();
    28662873    if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id == CSSValueBackwards || value->id == CSSValueBoth)
    2867         return CSSPrimitiveValue::createIdentifier(value->id);
     2874        return primitiveValueCache()->createIdentifierValue(value->id);
    28682875    return 0;
    28692876}
     
    28732880    CSSParserValue* value = m_valueList->current();
    28742881    if (value->id == CSSValueInfinite)
    2875         return CSSPrimitiveValue::createIdentifier(value->id);
     2882        return primitiveValueCache()->createIdentifierValue(value->id);
    28762883    if (validUnit(value, FInteger | FNonNeg, m_strict))
    2877         return CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     2884        return primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
    28782885    return 0;
    28792886}
     
    28842891    if (value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPrimitiveValue::CSS_IDENT) {
    28852892        if (value->id == CSSValueNone || (value->unit == CSSPrimitiveValue::CSS_STRING && equalIgnoringCase(value->string, "none"))) {
    2886             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     2893            return primitiveValueCache()->createIdentifierValue(CSSValueNone);
    28872894        } else {
    2888             return CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_STRING);
     2895            return primitiveValueCache()->createValue(value->string, CSSPrimitiveValue::CSS_STRING);
    28892896        }
    28902897    }
     
    28962903    CSSParserValue* value = m_valueList->current();
    28972904    if (value->id == CSSValueRunning || value->id == CSSValuePaused)
    2898         return CSSPrimitiveValue::createIdentifier(value->id);
     2905        return primitiveValueCache()->createIdentifierValue(value->id);
    28992906    return 0;
    29002907}
     
    29072914    int result = cssPropertyID(value->string);
    29082915    if (result)
    2909         return CSSPrimitiveValue::createIdentifier(result);
     2916        return primitiveValueCache()->createIdentifierValue(result);
    29102917    if (equalIgnoringCase(value->string, "all"))
    2911         return CSSPrimitiveValue::createIdentifier(CSSValueAll);
     2918        return primitiveValueCache()->createIdentifierValue(CSSValueAll);
    29122919    if (equalIgnoringCase(value->string, "none"))
    2913         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     2920        return primitiveValueCache()->createIdentifierValue(CSSValueNone);
    29142921    return 0;
    29152922}
     
    29222929    if (m_valueList->current()) {
    29232930        if (validUnit(m_valueList->current(), FLength, m_strict)) {
    2924             value3 = CSSPrimitiveValue::create(m_valueList->current()->fValue,
     2931            value3 = primitiveValueCache()->createValue(m_valueList->current()->fValue,
    29252932                                             (CSSPrimitiveValue::UnitTypes)m_valueList->current()->unit);
    29262933            m_valueList->next();
     
    29552962    if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut
    29562963        || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || value->id == CSSValueStepEnd)
    2957         return CSSPrimitiveValue::createIdentifier(value->id);
     2964        return primitiveValueCache()->createIdentifierValue(value->id);
    29582965
    29592966    // We must be a function.
     
    31453152        if (m_valueList->next())
    31463153            return false;
    3147         addProperty(propId, CSSPrimitiveValue::createIdentifier(value->id), important);
     3154        addProperty(propId, primitiveValueCache()->createIdentifierValue(value->id), important);
    31483155        return valid;
    31493156    }
     
    32153222        if (numArgs == DASHBOARD_REGION_SHORT_NUM_PARAMETERS || numArgs == (DASHBOARD_REGION_SHORT_NUM_PARAMETERS*2-1)) {
    32163223            // This originally used CSSValueInvalid by accident. It might be more logical to use something else.
    3217             RefPtr<CSSPrimitiveValue> amount = CSSPrimitiveValue::createIdentifier(CSSValueInvalid);
     3224            RefPtr<CSSPrimitiveValue> amount = primitiveValueCache()->createIdentifierValue(CSSValueInvalid);
    32183225
    32193226            region->setTop(amount);
     
    32333240
    32343241                RefPtr<CSSPrimitiveValue> amount = arg->id == CSSValueAuto ?
    3235                     CSSPrimitiveValue::createIdentifier(CSSValueAuto) :
    3236                     CSSPrimitiveValue::create(arg->fValue, (CSSPrimitiveValue::UnitTypes) arg->unit);
     3242                    primitiveValueCache()->createIdentifierValue(CSSValueAuto) :
     3243                    primitiveValueCache()->createValue(arg->fValue, (CSSPrimitiveValue::UnitTypes) arg->unit);
    32373244
    32383245                if (i == 0)
     
    32543261
    32553262    if (valid)
    3256         addProperty(propId, CSSPrimitiveValue::create(firstRegion.release()), important);
     3263        addProperty(propId, primitiveValueCache()->createValue(firstRegion.release()), important);
    32573264
    32583265    return valid;
     
    32723279    if (i->unit != CSSPrimitiveValue::CSS_IDENT)
    32733280        return 0;
    3274     RefPtr<CSSPrimitiveValue> identifier = CSSPrimitiveValue::create(i->string, CSSPrimitiveValue::CSS_STRING);
     3281    RefPtr<CSSPrimitiveValue> identifier = primitiveValueCache()->createValue(i->string, CSSPrimitiveValue::CSS_STRING);
    32753282
    32763283    RefPtr<CSSPrimitiveValue> separator;
    32773284    if (!counters)
    3278         separator = CSSPrimitiveValue::create(String(), CSSPrimitiveValue::CSS_STRING);
     3285        separator = primitiveValueCache()->createValue(String(), CSSPrimitiveValue::CSS_STRING);
    32793286    else {
    32803287        i = args->next();
     
    32863293            return 0;
    32873294
    3288         separator = CSSPrimitiveValue::create(i->string, (CSSPrimitiveValue::UnitTypes) i->unit);
     3295        separator = primitiveValueCache()->createValue(i->string, (CSSPrimitiveValue::UnitTypes) i->unit);
    32893296    }
    32903297
     
    32923299    i = args->next();
    32933300    if (!i) // Make the list style default decimal
    3294         listStyle = CSSPrimitiveValue::create(CSSValueDecimal - CSSValueDisc, CSSPrimitiveValue::CSS_NUMBER);
     3301        listStyle = primitiveValueCache()->createValue(CSSValueDecimal - CSSValueDisc, CSSPrimitiveValue::CSS_NUMBER);
    32953302    else {
    32963303        if (i->unit != CSSParserValue::Operator || i->iValue != ',')
     
    33093316            return 0;
    33103317
    3311         listStyle = CSSPrimitiveValue::create(ls, (CSSPrimitiveValue::UnitTypes) i->unit);
    3312     }
    3313 
    3314     return CSSPrimitiveValue::create(Counter::create(identifier.release(), listStyle.release(), separator.release()));
     3318        listStyle = primitiveValueCache()->createValue(ls, (CSSPrimitiveValue::UnitTypes) i->unit);
     3319    }
     3320
     3321    return primitiveValueCache()->createValue(Counter::create(identifier.release(), listStyle.release(), separator.release()));
    33153322}
    33163323
     
    33353342            break;
    33363343        RefPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ?
    3337             CSSPrimitiveValue::createIdentifier(CSSValueAuto) :
    3338             CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit);
     3344            primitiveValueCache()->createIdentifierValue(CSSValueAuto) :
     3345            primitiveValueCache()->createValue(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit);
    33393346        if (i == 0)
    33403347            rect->setTop(length);
     
    33573364    }
    33583365    if (valid) {
    3359         addProperty(propId, CSSPrimitiveValue::create(rect.release()), important);
     3366        addProperty(propId, primitiveValueCache()->createValue(rect.release()), important);
    33603367        m_valueList->next();
    33613368        return true;
     
    33793386                if (font->style)
    33803387                    return false;
    3381                 font->style = CSSPrimitiveValue::createIdentifier(id);
     3388                font->style = primitiveValueCache()->createIdentifierValue(id);
    33823389            } else if (id == CSSValueSmallCaps) {
    33833390                if (font->variant)
    33843391                    return false;
    3385                 font->variant = CSSPrimitiveValue::createIdentifier(id);
     3392                font->variant = primitiveValueCache()->createIdentifierValue(id);
    33863393            } else if (id >= CSSValueBold && id <= CSSValueLighter) {
    33873394                if (font->weight)
    33883395                    return false;
    3389                 font->weight = CSSPrimitiveValue::createIdentifier(id);
     3396                font->weight = primitiveValueCache()->createIdentifierValue(id);
    33903397            } else {
    33913398                valid = false;
     
    34143421
    34153422            if (val)
    3416                 font->weight = CSSPrimitiveValue::createIdentifier(val);
     3423                font->weight = primitiveValueCache()->createIdentifierValue(val);
    34173424            else
    34183425                valid = false;
     
    34293436    // set undefined values to default
    34303437    if (!font->style)
    3431         font->style = CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     3438        font->style = primitiveValueCache()->createIdentifierValue(CSSValueNormal);
    34323439    if (!font->variant)
    3433         font->variant = CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     3440        font->variant = primitiveValueCache()->createIdentifierValue(CSSValueNormal);
    34343441    if (!font->weight)
    3435         font->weight = CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     3442        font->weight = primitiveValueCache()->createIdentifierValue(CSSValueNormal);
    34363443
    34373444    // now a font size _must_ come
    34383445    // <absolute-size> | <relative-size> | <length> | <percentage> | inherit
    34393446    if (value->id >= CSSValueXxSmall && value->id <= CSSValueLarger)
    3440         font->size = CSSPrimitiveValue::createIdentifier(value->id);
     3447        font->size = primitiveValueCache()->createIdentifierValue(value->id);
    34413448    else if (validUnit(value, FLength | FPercent | FNonNeg, m_strict))
    3442         font->size = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     3449        font->size = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
    34433450    value = m_valueList->next();
    34443451    if (!font->size || !value)
     
    34533460            // default value, nothing to do
    34543461        } else if (validUnit(value, FNumber | FLength | FPercent | FNonNeg, m_strict))
    3455             font->lineHeight = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     3462            font->lineHeight = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
    34563463        else
    34573464            return false;
     
    34623469
    34633470    if (!font->lineHeight)
    3464         font->lineHeight = CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     3471        font->lineHeight = primitiveValueCache()->createIdentifierValue(CSSValueNormal);
    34653472
    34663473    // font family must come now
     
    34923499                currFamily->appendSpaceSeparated(value->string.characters, value->string.length);
    34933500            else if (nextValBreaksFont || !nextValIsFontName)
    3494                 list->append(CSSPrimitiveValue::createIdentifier(value->id));
     3501                list->append(primitiveValueCache()->createIdentifierValue(value->id));
    34953502            else {
    34963503                RefPtr<FontFamilyValue> newFamily = FontFamilyValue::create(value->string);
     
    35453552            expectComma = true;
    35463553            if (val->id == CSSValueNormal || val->id == CSSValueItalic || val->id == CSSValueOblique)
    3547                 parsedValue = CSSPrimitiveValue::createIdentifier(val->id);
     3554                parsedValue = primitiveValueCache()->createIdentifierValue(val->id);
    35483555            else if (val->id == CSSValueAll && !values) {
    35493556                // 'all' is only allowed in @font-face and with no other values. Make a value list to
    35503557                // indicate that we are in the @font-face case.
    35513558                values = CSSValueList::createCommaSeparated();
    3552                 parsedValue = CSSPrimitiveValue::createIdentifier(val->id);
     3559                parsedValue = primitiveValueCache()->createIdentifierValue(val->id);
    35533560            }
    35543561        } else if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
     
    35923599            expectComma = true;
    35933600            if (val->id == CSSValueNormal || val->id == CSSValueSmallCaps)
    3594                 parsedValue = CSSPrimitiveValue::createIdentifier(val->id);
     3601                parsedValue = primitiveValueCache()->createIdentifierValue(val->id);
    35953602            else if (val->id == CSSValueAll && !values) {
    35963603                // 'all' is only allowed in @font-face and with no other values. Make a value list to
    35973604                // indicate that we are in the @font-face case.
    35983605                values = CSSValueList::createCommaSeparated();
    3599                 parsedValue = CSSPrimitiveValue::createIdentifier(val->id);
     3606                parsedValue = primitiveValueCache()->createIdentifierValue(val->id);
    36003607            }
    36013608        } else if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
     
    36403647            if (val->unit == CSSPrimitiveValue::CSS_IDENT) {
    36413648                if (val->id >= CSSValueNormal && val->id <= CSSValue900)
    3642                     parsedValue = CSSPrimitiveValue::createIdentifier(val->id);
     3649                    parsedValue = primitiveValueCache()->createIdentifierValue(val->id);
    36433650                else if (val->id == CSSValueAll && !values) {
    36443651                    // 'all' is only allowed in @font-face and with no other values. Make a value list to
    36453652                    // indicate that we are in the @font-face case.
    36463653                    values = CSSValueList::createCommaSeparated();
    3647                     parsedValue = CSSPrimitiveValue::createIdentifier(val->id);
     3654                    parsedValue = primitiveValueCache()->createIdentifierValue(val->id);
    36483655                }
    36493656            } else if (validUnit(val, FInteger | FNonNeg, false)) {
    36503657                int weight = static_cast<int>(val->fValue);
    36513658                if (!(weight % 100) && weight >= 100 && weight <= 900)
    3652                     parsedValue = CSSPrimitiveValue::createIdentifier(CSSValue100 + weight / 100 - 1);
     3659                    parsedValue = primitiveValueCache()->createIdentifierValue(CSSValue100 + weight / 100 - 1);
    36533660            }
    36543661        } else if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
     
    41414148    if (!parseColorFromValue(value ? value : m_valueList->current(), c))
    41424149        return 0;
    4143     return CSSPrimitiveValue::createColor(c);
     4150    return primitiveValueCache()->createColorValue(c);
    41444151}
    41454152
     
    41994206// without the allowBreak bit being set, then it will clean up all of the objects and destroy them.
    42004207struct ShadowParseContext {
    4201     ShadowParseContext(CSSPropertyID prop)
     4208    ShadowParseContext(CSSPropertyID prop, CSSPrimitiveValueCache* primitiveValueCache)
    42024209        : property(prop)
     4210        , m_primitiveValueCache(primitiveValueCache)
    42034211        , allowX(true)
    42044212        , allowY(false)
     
    42434251    void commitLength(CSSParserValue* v)
    42444252    {
    4245         RefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit);
     4253        RefPtr<CSSPrimitiveValue> val = m_primitiveValueCache->createValue(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit);
    42464254
    42474255        if (allowX) {
     
    42854293    void commitStyle(CSSParserValue* v)
    42864294    {
    4287         style = CSSPrimitiveValue::createIdentifier(v->id);
     4295        style = m_primitiveValueCache->createIdentifierValue(v->id);
    42884296        allowStyle = false;
    42894297        if (allowX)
     
    42974305
    42984306    CSSPropertyID property;
     4307    CSSPrimitiveValueCache* m_primitiveValueCache;
    42994308
    43004309    RefPtr<CSSValueList> values;
     
    43174326bool CSSParser::parseShadow(int propId, bool important)
    43184327{
    4319     ShadowParseContext context(static_cast<CSSPropertyID>(propId));
     4328    ShadowParseContext context(static_cast<CSSPropertyID>(propId), primitiveValueCache());
    43204329    CSSParserValue* val;
    43214330    while ((val = m_valueList->current())) {
     
    43534362                if (!context.allowColor)
    43544363                    return false;
    4355                 parsedColor = CSSPrimitiveValue::createIdentifier(val->id);
     4364                parsedColor = primitiveValueCache()->createIdentifierValue(val->id);
    43564365            }
    43574366
     
    44104419    RefPtr<CSSPrimitiveValue> offset;
    44114420    if (!val)
    4412         offset = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX);
     4421        offset = primitiveValueCache()->createValue(0, CSSPrimitiveValue::CSS_PX);
    44134422    else {
    44144423        if (!validUnit(val, FLength | FPercent, m_strict))
    44154424            return false;
    4416         offset = CSSPrimitiveValue::create(val->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(val->unit));
     4425        offset = primitiveValueCache()->createValue(val->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(val->unit));
    44174426    }
    44184427
     
    44324441
    44334442struct BorderImageParseContext {
    4434     BorderImageParseContext()
    4435     : m_allowBreak(false)
     4443    BorderImageParseContext(CSSPrimitiveValueCache* primitiveValueCache)
     4444    : m_primitiveValueCache(primitiveValueCache)
     4445    , m_allowBreak(false)
    44364446    , m_allowNumber(false)
    44374447    , m_allowSlash(false)
     
    44554465    void commitNumber(CSSParserValue* v)
    44564466    {
    4457         PassRefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit);
     4467        PassRefPtr<CSSPrimitiveValue> val = m_primitiveValueCache->createValue(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit);
    44584468        if (!m_top)
    44594469            m_top = val;
     
    44994509        // We need to clone and repeat values for any omissions.
    45004510        if (!m_right) {
    4501             m_right = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
    4502             m_bottom = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
    4503             m_left = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
     4511            m_right = m_primitiveValueCache->createValue(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
     4512            m_bottom = m_primitiveValueCache->createValue(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
     4513            m_left = m_primitiveValueCache->createValue(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
    45044514        }
    45054515        if (!m_bottom) {
    4506             m_bottom = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
    4507             m_left = CSSPrimitiveValue::create(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
     4516            m_bottom = m_primitiveValueCache->createValue(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
     4517            m_left = m_primitiveValueCache->createValue(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
    45084518        }
    45094519        if (!m_left)
    4510              m_left = CSSPrimitiveValue::create(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
     4520             m_left = m_primitiveValueCache->createValue(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
    45114521
    45124522        // Now build a rect value to hold all four of our primitive values.
     
    45454555        return CSSBorderImageValue::create(m_image, rect.release(), m_horizontalRule, m_verticalRule);
    45464556    }
     4557   
     4558    CSSPrimitiveValueCache* m_primitiveValueCache;
    45474559
    45484560    bool m_allowBreak;
     
    45714583{
    45724584    // Look for an image initially.  If the first value is not a URI, then we're done.
    4573     BorderImageParseContext context;
     4585    BorderImageParseContext context(primitiveValueCache());
    45744586    CSSParserValue* val = m_valueList->current();
    45754587    if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) {
     
    46054617    if (context.allowNumber() && propId != CSSPropertyWebkitBorderImage) {
    46064618        // Allow the slices to be omitted for images that don't fit to a border.  We just set the slices to be 0.
    4607         context.m_top = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_NUMBER);
     4619        context.m_top = primitiveValueCache()->createValue(0, CSSPrimitiveValue::CSS_NUMBER);
    46084620        context.m_allowBreak = true;
    46094621    }
     
    46604672            return false;
    46614673
    4662         RefPtr<CSSPrimitiveValue> radius = CSSPrimitiveValue::create(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit));
     4674        RefPtr<CSSPrimitiveValue> radius = primitiveValueCache()->createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit));
    46634675
    46644676        if (!indexAfterSlash) {
     
    46824694
    46834695    m_implicitShorthand = true;
    4684     addProperty(CSSPropertyBorderTopLeftRadius, CSSPrimitiveValue::create(Pair::create(radii[0][0].release(), radii[1][0].release())), important);
    4685     addProperty(CSSPropertyBorderTopRightRadius, CSSPrimitiveValue::create(Pair::create(radii[0][1].release(), radii[1][1].release())), important);
    4686     addProperty(CSSPropertyBorderBottomRightRadius, CSSPrimitiveValue::create(Pair::create(radii[0][2].release(), radii[1][2].release())), important);
    4687     addProperty(CSSPropertyBorderBottomLeftRadius, CSSPrimitiveValue::create(Pair::create(radii[0][3].release(), radii[1][3].release())), important);
     4696    addProperty(CSSPropertyBorderTopLeftRadius, primitiveValueCache()->createValue(Pair::create(radii[0][0].release(), radii[1][0].release())), important);
     4697    addProperty(CSSPropertyBorderTopRightRadius, primitiveValueCache()->createValue(Pair::create(radii[0][1].release(), radii[1][1].release())), important);
     4698    addProperty(CSSPropertyBorderBottomRightRadius, primitiveValueCache()->createValue(Pair::create(radii[0][2].release(), radii[1][2].release())), important);
     4699    addProperty(CSSPropertyBorderBottomLeftRadius, primitiveValueCache()->createValue(Pair::create(radii[0][3].release(), radii[1][3].release())), important);
    46884700    m_implicitShorthand = false;
    46894701    return true;
     
    47024714            case ID:
    47034715                if (val && val->unit == CSSPrimitiveValue::CSS_IDENT) {
    4704                     counterName = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue::CSS_STRING);
     4716                    counterName = primitiveValueCache()->createValue(val->string, CSSPrimitiveValue::CSS_STRING);
    47054717                    state = VAL;
    47064718                    m_valueList->next();
     
    47154727                }
    47164728
    4717                 list->append(CSSPrimitiveValue::create(Pair::create(counterName.release(),
    4718                     CSSPrimitiveValue::create(i, CSSPrimitiveValue::CSS_NUMBER))));
     4729                list->append(primitiveValueCache()->createValue(Pair::create(counterName.release(),
     4730                    primitiveValueCache()->createValue(i, CSSPrimitiveValue::CSS_NUMBER))));
    47194731                state = ID;
    47204732                continue;
     
    47334745
    47344746// This should go away once we drop support for -webkit-gradient
    4735 static PassRefPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CSSParserValue* a, bool horizontal)
     4747static PassRefPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CSSParserValue* a, bool horizontal, CSSPrimitiveValueCache* primitiveValueCache)
    47364748{
    47374749    RefPtr<CSSPrimitiveValue> result;
     
    47394751        if ((equalIgnoringCase(a->string, "left") && horizontal) ||
    47404752            (equalIgnoringCase(a->string, "top") && !horizontal))
    4741             result = CSSPrimitiveValue::create(0., CSSPrimitiveValue::CSS_PERCENTAGE);
     4753            result = primitiveValueCache->createValue(0., CSSPrimitiveValue::CSS_PERCENTAGE);
    47424754        else if ((equalIgnoringCase(a->string, "right") && horizontal) ||
    47434755                 (equalIgnoringCase(a->string, "bottom") && !horizontal))
    4744             result = CSSPrimitiveValue::create(100., CSSPrimitiveValue::CSS_PERCENTAGE);
     4756            result = primitiveValueCache->createValue(100., CSSPrimitiveValue::CSS_PERCENTAGE);
    47454757        else if (equalIgnoringCase(a->string, "center"))
    4746             result = CSSPrimitiveValue::create(50., CSSPrimitiveValue::CSS_PERCENTAGE);
     4758            result = primitiveValueCache->createValue(50., CSSPrimitiveValue::CSS_PERCENTAGE);
    47474759    } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
    4748         result = CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes)a->unit);
     4760        result = primitiveValueCache->createValue(a->fValue, (CSSPrimitiveValue::UnitTypes)a->unit);
    47494761    return result;
    47504762}
     
    47714783
    47724784        if (equalIgnoringCase(a->function->name, "from("))
    4773             stop.m_position = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_NUMBER);
     4785            stop.m_position = p->primitiveValueCache()->createValue(0, CSSPrimitiveValue::CSS_NUMBER);
    47744786        else
    4775             stop.m_position = CSSPrimitiveValue::create(1, CSSPrimitiveValue::CSS_NUMBER);
     4787            stop.m_position = p->primitiveValueCache()->createValue(1, CSSPrimitiveValue::CSS_NUMBER);
    47764788
    47774789        int id = args->current()->id;
    47784790        if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu)
    4779             stop.m_color = CSSPrimitiveValue::createIdentifier(id);
     4791            stop.m_color = p->primitiveValueCache()->createIdentifierValue(id);
    47804792        else
    47814793            stop.m_color = p->parseColor(args->current());
     
    47914803        CSSParserValue* stopArg = args->current();
    47924804        if (stopArg->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
    4793             stop.m_position = CSSPrimitiveValue::create(stopArg->fValue / 100, CSSPrimitiveValue::CSS_NUMBER);
     4805            stop.m_position = p->primitiveValueCache()->createValue(stopArg->fValue / 100, CSSPrimitiveValue::CSS_NUMBER);
    47944806        else if (stopArg->unit == CSSPrimitiveValue::CSS_NUMBER)
    4795             stop.m_position = CSSPrimitiveValue::create(stopArg->fValue, CSSPrimitiveValue::CSS_NUMBER);
     4807            stop.m_position = p->primitiveValueCache()->createValue(stopArg->fValue, CSSPrimitiveValue::CSS_NUMBER);
    47964808        else
    47974809            return false;
     
    48044816        int id = stopArg->id;
    48054817        if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu)
    4806             stop.m_color = CSSPrimitiveValue::createIdentifier(id);
     4818            stop.m_color = p->primitiveValueCache()->createIdentifierValue(id);
    48074819        else
    48084820            stop.m_color = p->parseColor(stopArg);
     
    48544866    if (!a)
    48554867        return false;
    4856     RefPtr<CSSPrimitiveValue> point = parseDeprecatedGradientPoint(a, true);
     4868    RefPtr<CSSPrimitiveValue> point = parseDeprecatedGradientPoint(a, true, primitiveValueCache());
    48574869    if (!point)
    48584870        return false;
     
    48634875    if (!a)
    48644876        return false;
    4865     point = parseDeprecatedGradientPoint(a, false);
     4877    point = parseDeprecatedGradientPoint(a, false, primitiveValueCache());
    48664878    if (!point)
    48674879        return false;
     
    48784890        if (!a || a->unit != CSSPrimitiveValue::CSS_NUMBER)
    48794891            return false;
    4880         static_cast<CSSRadialGradientValue*>(result.get())->setFirstRadius(CSSPrimitiveValue::create(a->fValue, CSSPrimitiveValue::CSS_NUMBER));
     4892        static_cast<CSSRadialGradientValue*>(result.get())->setFirstRadius(primitiveValueCache()->createValue(a->fValue, CSSPrimitiveValue::CSS_NUMBER));
    48814893
    48824894        // Comma after the first radius.
     
    48914903    if (!a)
    48924904        return false;
    4893     point = parseDeprecatedGradientPoint(a, true);
     4905    point = parseDeprecatedGradientPoint(a, true, primitiveValueCache());
    48944906    if (!point)
    48954907        return false;
     
    49004912    if (!a)
    49014913        return false;
    4902     point = parseDeprecatedGradientPoint(a, false);
     4914    point = parseDeprecatedGradientPoint(a, false, primitiveValueCache());
    49034915    if (!point)
    49044916        return false;
     
    49154927        if (!a || a->unit != CSSPrimitiveValue::CSS_NUMBER)
    49164928            return false;
    4917         static_cast<CSSRadialGradientValue*>(result.get())->setSecondRadius(CSSPrimitiveValue::create(a->fValue, CSSPrimitiveValue::CSS_NUMBER));
     4929        static_cast<CSSRadialGradientValue*>(result.get())->setSecondRadius(primitiveValueCache()->createValue(a->fValue, CSSPrimitiveValue::CSS_NUMBER));
    49184930    }
    49194931
     
    49444956}
    49454957
    4946 static PassRefPtr<CSSPrimitiveValue> valueFromSideKeyword(CSSParserValue* a, bool& isHorizontal)
     4958static PassRefPtr<CSSPrimitiveValue> valueFromSideKeyword(CSSParserValue* a, bool& isHorizontal, CSSPrimitiveValueCache* primitiveValueCache)
    49474959{
    49484960    if (a->unit != CSSPrimitiveValue::CSS_IDENT)
     
    49614973            return 0;
    49624974    }
    4963     return CSSPrimitiveValue::createIdentifier(a->id);
     4975    return primitiveValueCache->createIdentifierValue(a->id);
    49644976}
    49654977
     
    49684980    int id = value->id;
    49694981    if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu)
    4970         return CSSPrimitiveValue::createIdentifier(id);
     4982        return p->primitiveValueCache()->createIdentifierValue(id);
    49714983
    49724984    return p->parseColor(value);
     
    49895001    // Look for angle.
    49905002    if (validUnit(a, FAngle, true)) {
    4991         result->setAngle(CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes)a->unit));
     5003        result->setAngle(primitiveValueCache()->createValue(a->fValue, (CSSPrimitiveValue::UnitTypes)a->unit));
    49925004       
    49935005        a = args->next();
     
    49995011        RefPtr<CSSPrimitiveValue> location;
    50005012        bool isHorizontal = false;
    5001         if ((location = valueFromSideKeyword(a, isHorizontal))) {
     5013        if ((location = valueFromSideKeyword(a, isHorizontal, primitiveValueCache()))) {
    50025014            if (isHorizontal)
    50035015                startX = location;
     
    50075019            a = args->next();
    50085020            if (a) {
    5009                 if ((location = valueFromSideKeyword(a, isHorizontal))) {
     5021                if ((location = valueFromSideKeyword(a, isHorizontal, primitiveValueCache()))) {
    50105022                    if (isHorizontal) {
    50115023                        if (startX)
     
    50265038       
    50275039        if (!startX && !startY)
    5028             startY = CSSPrimitiveValue::createIdentifier(CSSValueTop);
     5040            startY = primitiveValueCache()->createIdentifierValue(CSSValueTop);
    50295041           
    50305042        result->setFirstX(startX.release());
     
    50965108        case CSSValueCircle:
    50975109        case CSSValueEllipse:
    5098             shapeValue = CSSPrimitiveValue::createIdentifier(a->id);
     5110            shapeValue = primitiveValueCache()->createIdentifierValue(a->id);
    50995111            foundValue = true;
    51005112            break;
     
    51055117        case CSSValueContain:
    51065118        case CSSValueCover:
    5107             sizeValue = CSSPrimitiveValue::createIdentifier(a->id);
     5119            sizeValue = primitiveValueCache()->createIdentifierValue(a->id);
    51085120            foundValue = true;
    51095121            break;
     
    51285140    if (!shapeValue && !sizeValue) {
    51295141        if (validUnit(a, FLength | FPercent, m_strict)) {
    5130             horizontalSize = CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit);
     5142            horizontalSize = primitiveValueCache()->createValue(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit);
    51315143            a = args->next();
    51325144            if (!a)
     
    51375149
    51385150        if (validUnit(a, FLength | FPercent, m_strict)) {
    5139             verticalSize = CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit);
     5151            verticalSize = primitiveValueCache()->createValue(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit);
    51405152
    51415153            a = args->next();
     
    51855197        if (a) {
    51865198            if (validUnit(a, FLength | FPercent, m_strict)) {
    5187                 stop.m_position = CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes)a->unit);
     5199                stop.m_position = primitiveValueCache()->createValue(a->fValue, (CSSPrimitiveValue::UnitTypes)a->unit);
    51885200                a = valueList->next();
    51895201            }
     
    54065418
    54075419            // Add the value to the current transform operation.
    5408             transformValue->append(CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit));
     5420            transformValue->append(primitiveValueCache()->createValue(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit));
    54095421
    54105422            a = args->next();
     
    54555467        case CSSPropertyWebkitTransformOriginZ: {
    54565468            if (validUnit(m_valueList->current(), FLength, m_strict))
    5457                 value = CSSPrimitiveValue::create(m_valueList->current()->fValue, (CSSPrimitiveValue::UnitTypes)m_valueList->current()->unit);
     5469                value = primitiveValueCache()->createValue(m_valueList->current()->fValue, (CSSPrimitiveValue::UnitTypes)m_valueList->current()->unit);
    54585470            if (value)
    54595471                m_valueList->next();
     
    55085520            if (fill || shape || (valueListSize != 1 && !inShorthand()))
    55095521                return false;
    5510             addProperty(CSSPropertyWebkitTextEmphasisStyle, CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_STRING), important);
     5522            addProperty(CSSPropertyWebkitTextEmphasisStyle, primitiveValueCache()->createValue(value->string, CSSPrimitiveValue::CSS_STRING), important);
    55115523            m_valueList->next();
    55125524            return true;
     
    55165528            if (fill || shape || (valueListSize != 1 && !inShorthand()))
    55175529                return false;
    5518             addProperty(CSSPropertyWebkitTextEmphasisStyle, CSSPrimitiveValue::createIdentifier(CSSValueNone), important);
     5530            addProperty(CSSPropertyWebkitTextEmphasisStyle, primitiveValueCache()->createIdentifierValue(CSSValueNone), important);
    55195531            m_valueList->next();
    55205532            return true;
     
    55245536            if (fill)
    55255537                return false;
    5526             fill = CSSPrimitiveValue::createIdentifier(value->id);
     5538            fill = primitiveValueCache()->createIdentifierValue(value->id);
    55275539        } else if (value->id == CSSValueDot || value->id == CSSValueCircle || value->id == CSSValueDoubleCircle || value->id == CSSValueTriangle || value->id == CSSValueSesame) {
    55285540            if (shape)
    55295541                return false;
    5530             shape = CSSPrimitiveValue::createIdentifier(value->id);
     5542            shape = primitiveValueCache()->createIdentifierValue(value->id);
    55315543        } else if (!inShorthand())
    55325544            return false;
  • trunk/Source/WebCore/css/CSSParser.h

    r80151 r80463  
    3939    class CSSMutableStyleDeclaration;
    4040    class CSSPrimitiveValue;
     41    class CSSPrimitiveValueCache;
    4142    class CSSProperty;
    4243    class CSSRule;
     
    7172
    7273        Document* document() const;
     74   
     75        CSSPrimitiveValueCache* primitiveValueCache() const { return m_primitiveValueCache.get(); }
    7376
    7477        void addProperty(int propId, PassRefPtr<CSSValue>, bool important);
     
    227230        CSSProperty** m_parsedProperties;
    228231        CSSSelectorList* m_selectorListForParseSelector;
     232        RefPtr<CSSPrimitiveValueCache> m_primitiveValueCache;
    229233        unsigned m_numParsedProperties;
    230234        unsigned m_maxParsedProperties;
     
    263267
    264268    private:
     269        void setStyleSheet(CSSStyleSheet*);
     270       
    265271        void recheckAtKeyword(const UChar* str, int len);
    266272
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r79733 r80463  
    8686    DEFINE_STATIC_LOCAL(CSSTextCache, cache, ());
    8787    return cache;
    88 }
    89 
    90 // A more stylish solution than sharing would be to turn CSSPrimitiveValue (or CSSValues in general) into non-virtual,
    91 // non-refcounted simple type with value semantics. In practice these sharing tricks get similar memory benefits
    92 // with less need for refactoring.
    93 
    94 inline PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::createUncachedIdentifier(int identifier)
    95 {
    96     return adoptRef(new CSSPrimitiveValue(identifier));
    97 }
    98 
    99 inline PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::createUncachedColor(unsigned rgbValue)
    100 {
    101     return adoptRef(new CSSPrimitiveValue(rgbValue));
    102 }
    103 
    104 inline PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::createUncached(double value, UnitTypes type)
    105 {
    106     return adoptRef(new CSSPrimitiveValue(value, type));
    107 }
    108 
    109 PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::createIdentifier(int ident)
    110 {
    111     static RefPtr<CSSPrimitiveValue>* identValueCache = new RefPtr<CSSPrimitiveValue>[numCSSValueKeywords];
    112     if (ident >= 0 && ident < numCSSValueKeywords) {
    113         RefPtr<CSSPrimitiveValue> primitiveValue = identValueCache[ident];
    114         if (!primitiveValue) {
    115             primitiveValue = createUncachedIdentifier(ident);
    116             identValueCache[ident] = primitiveValue;
    117         }
    118         return primitiveValue.release();
    119     }
    120     return createUncachedIdentifier(ident);
    121 }
    122 
    123 PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::createColor(unsigned rgbValue)
    124 {
    125     typedef HashMap<unsigned, RefPtr<CSSPrimitiveValue> > ColorValueCache;
    126     static ColorValueCache* colorValueCache = new ColorValueCache;
    127     // These are the empty and deleted values of the hash table.
    128     if (rgbValue == Color::transparent) {
    129         static CSSPrimitiveValue* colorTransparent = createUncachedColor(Color::transparent).releaseRef();
    130 #if CPU(ARM) && OS(LINUX)
    131          // A workaround for gcc bug on ARM.
    132         if (!colorTransparent)
    133             return 0;
    134 #endif
    135         return colorTransparent;
    136     }
    137     if (rgbValue == Color::white) {
    138         static CSSPrimitiveValue* colorWhite = createUncachedColor(Color::white).releaseRef();
    139 #if CPU(ARM) && OS(LINUX)
    140         // A workaround for gcc bug on ARM.
    141         if (!colorWhite)
    142             return 0;
    143 #endif
    144         return colorWhite;
    145     }
    146     RefPtr<CSSPrimitiveValue> primitiveValue = colorValueCache->get(rgbValue);
    147     if (primitiveValue)
    148         return primitiveValue.release();
    149     primitiveValue = createUncachedColor(rgbValue);
    150     // Just wipe out the cache and start rebuilding when it gets too big.
    151     const int maxColorCacheSize = 512;
    152     if (colorValueCache->size() >= maxColorCacheSize)
    153         colorValueCache->clear();
    154     colorValueCache->add(rgbValue, primitiveValue);
    155    
    156     return primitiveValue.release();
    157 }
    158 
    159 PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::create(double value, UnitTypes type)
    160 {
    161     // Small integers are very common. Try to share them.
    162     const int cachedIntegerCount = 128;
    163     // Other common primitive types have UnitTypes smaller than this.
    164     const int maxCachedUnitType = CSS_PX;
    165     typedef RefPtr<CSSPrimitiveValue>(* IntegerValueCache)[maxCachedUnitType + 1];
    166     static IntegerValueCache integerValueCache = new RefPtr<CSSPrimitiveValue>[cachedIntegerCount][maxCachedUnitType + 1];
    167     if (type <= maxCachedUnitType && value >= 0 && value < cachedIntegerCount) {
    168         int intValue = static_cast<int>(value);
    169         if (value == intValue) {
    170             RefPtr<CSSPrimitiveValue> primitiveValue = integerValueCache[intValue][type];
    171             if (!primitiveValue) {
    172                 primitiveValue = createUncached(value, type);
    173                 integerValueCache[intValue][type] = primitiveValue;
    174             }
    175             return primitiveValue.release();
    176         }
    177     }
    178 
    179     return createUncached(value, type);
    180 }
    181 
    182 PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::create(const String& value, UnitTypes type)
    183 {
    184     return adoptRef(new CSSPrimitiveValue(value, type));
    18588}
    18689
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r79574 r80463  
    111111                                                    type == CSSPrimitiveValue::CSS_REMS; }
    112112
    113     static PassRefPtr<CSSPrimitiveValue> createIdentifier(int ident);
    114     static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue);
    115     static PassRefPtr<CSSPrimitiveValue> create(double value, UnitTypes type);
    116     static PassRefPtr<CSSPrimitiveValue> create(const String& value, UnitTypes type);
     113    static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); }
     114    static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue) { return adoptRef(new CSSPrimitiveValue(rgbValue)); }
     115    static PassRefPtr<CSSPrimitiveValue> create(double value, UnitTypes type) { return adoptRef(new CSSPrimitiveValue(value, type)); }
     116    static PassRefPtr<CSSPrimitiveValue> create(const String& value, UnitTypes type) { return adoptRef(new CSSPrimitiveValue(value, type)); }
    117117   
    118118    template<typename T> static PassRefPtr<CSSPrimitiveValue> create(T value)
  • trunk/Source/WebCore/dom/Document.cpp

    r80412 r80463  
    3434#include "Attribute.h"
    3535#include "CDATASection.h"
     36#include "CSSPrimitiveValueCache.h"
    3637#include "CSSStyleSelector.h"
    3738#include "CSSStyleSheet.h"
     
    16991700}
    17001701
     1702PassRefPtr<CSSPrimitiveValueCache> Document::cssPrimitiveValueCache() const
     1703{
     1704    if (!m_cssPrimitiveValueCache)
     1705        m_cssPrimitiveValueCache = CSSPrimitiveValueCache::create();
     1706    return m_cssPrimitiveValueCache;
     1707}
     1708
    17011709void Document::createStyleSelector()
    17021710{
  • trunk/Source/WebCore/dom/Document.h

    r80150 r80463  
    6161class CanvasRenderingContext;
    6262class CharacterData;
     63class CSSPrimitiveValueCache;
    6364class CSSStyleDeclaration;
    6465class CSSStyleSelector;
     
    435436    virtual bool isFrameSet() const { return false; }
    436437   
     438    PassRefPtr<CSSPrimitiveValueCache> cssPrimitiveValueCache() const;
     439   
    437440    CSSStyleSelector* styleSelectorIfExists() const { return m_styleSelector.get(); }
    438441
     
    11691172    bool m_didCalculateStyleSelector;
    11701173    bool m_hasDirtyStyleSelector;
     1174   
     1175    mutable RefPtr<CSSPrimitiveValueCache> m_cssPrimitiveValueCache;
    11711176
    11721177    Frame* m_frame;
Note: See TracChangeset for help on using the changeset viewer.