Merge from Chromium at DEPS revision r213371

This commit was generated by merge_to_master.py.

Change-Id: I03fae1c1dae6e5de12e56e0a6c3780252291bfae
diff --git a/Source/core/css/CSSCalculationValue.cpp b/Source/core/css/CSSCalculationValue.cpp
index adb1b5f..99b91cf 100644
--- a/Source/core/css/CSSCalculationValue.cpp
+++ b/Source/core/css/CSSCalculationValue.cpp
@@ -178,7 +178,7 @@
     return clampToPermittedRange(m_expression->doubleValue());
 }
 
-double CSSCalcValue::computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+double CSSCalcValue::computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
 {
     return clampToPermittedRange(m_expression->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize));
 }
@@ -223,7 +223,7 @@
         return m_value->isVariableName();
     }
 
-    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
+    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
     {
         switch (m_category) {
         case CalcNumber:
@@ -255,7 +255,7 @@
         return 0;
     }
     
-    virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
     {
         switch (m_category) {
         case CalcLength:
@@ -420,7 +420,7 @@
         return !doubleValue();
     }
 
-    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
+    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
     {
         OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(style, rootStyle, zoom));
         if (!left)
@@ -436,7 +436,7 @@
         return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue());
     }
     
-    virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
     {
         const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
         const double rightValue = m_rightSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
diff --git a/Source/core/css/CSSCalculationValue.h b/Source/core/css/CSSCalculationValue.h
index 5951906..589d72c 100644
--- a/Source/core/css/CSSCalculationValue.h
+++ b/Source/core/css/CSSCalculationValue.h
@@ -66,9 +66,9 @@
 
     virtual ~CSSCalcExpressionNode() = 0;
     virtual bool isZero() const = 0;
-    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle*, RenderStyle* rootStyle, double zoom = 1.0) const = 0;    
+    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0;
     virtual double doubleValue() const = 0;
-    virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
+    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
     virtual String customCssText() const = 0;
     virtual String serializeResolvingVariables(const HashMap<AtomicString, String>&) const = 0;
     virtual bool hasVariableReference() const = 0;
@@ -98,7 +98,7 @@
     static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSSPrimitiveValue>, bool isInteger = false);
     static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSSCalcExpressionNode>, PassRefPtr<CSSCalcExpressionNode>, CalcOperator);
 
-    PassRefPtr<CalculationValue> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom = 1.0) const
+    PassRefPtr<CalculationValue> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom = 1.0) const
     {
         return CalculationValue::create(m_expression->toCalcValue(style, rootStyle, zoom), m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
     }
@@ -106,7 +106,7 @@
     bool isInt() const { return m_expression->isInteger(); }    
     double doubleValue() const;
     bool isNegative() const { return m_expression->doubleValue() < 0; }
-    double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
+    double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
     CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); }
 
     String customCssText() const;
diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp
index 5cce9ab..9007ea3 100644
--- a/Source/core/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/core/css/CSSComputedStyleDeclaration.cpp
@@ -647,7 +647,7 @@
     return zoomAdjustedPixelValueForLength(l, style);
 }
 
-PassRefPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidColor(RenderStyle* style, const Color& color) const
+PassRefPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidColor(RenderStyle* style, const StyleColor& color) const
 {
     // This function does NOT look at visited information, so that computed style doesn't expose that.
     if (!color.isValid())
@@ -655,6 +655,23 @@
     return cssValuePool().createColorValue(color.rgb());
 }
 
+PassRefPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidColor(const RenderObject* renderer, const RenderStyle* style, int colorProperty) const
+{
+    Color color;
+    if (renderer) {
+        if (m_allowVisitedStyle)
+            color = renderer->resolveColor(colorProperty);
+        else
+            color = renderer->resolveColor(style->colorIncludingFallback(colorProperty, false /* visited */));
+    } else {
+        if (m_allowVisitedStyle)
+            color = style->visitedDependentColor(colorProperty).color();
+        else
+            color = style->colorIncludingFallback(colorProperty, false /* visited */).color();
+    }
+    return cssValuePool().createColorValue(color.rgb());
+}
+
 static PassRefPtr<CSSValueList> getBorderRadiusCornerValues(LengthSize radius, const RenderStyle* style, RenderView* renderView)
 {
     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
@@ -911,7 +928,7 @@
             filterValue = CSSFilterValue::create(CSSFilterValue::DropShadowFilterOperation);
             // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
             OwnPtr<ShadowData> shadow = ShadowData::create(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, dropShadowOperation->color());
-            filterValue->append(valueForShadow(shadow.get(), CSSPropertyTextShadow, style));
+            filterValue->append(valueForShadow(renderer, shadow.get(), CSSPropertyTextShadow, style));
             break;
         }
         case FilterOperation::VALIDATED_CUSTOM:
@@ -1257,7 +1274,7 @@
     return style->fontDescription().useFixedDefaultSize();
 }
 
-PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style) const
+PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const RenderObject* renderer, const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style) const
 {
     if (!shadow)
         return cssValuePool().createIdentifierValue(CSSValueNone);
@@ -1269,7 +1286,7 @@
         RefPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(s->blur(), style);
         RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : zoomAdjustedPixelValue(s->spread(), style);
         RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
-        RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(s->color().rgb());
+        RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(renderer ? renderer->resolveColor(s->color()).rgb() : s->color().rgb());
         list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
     }
     return list.release();
@@ -1602,7 +1619,7 @@
             break;
 
         case CSSPropertyBackgroundColor:
-            return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
+            return cssValuePool().createColorValue(renderer->resolveColor(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor()).rgb());
         case CSSPropertyBackgroundImage:
         case CSSPropertyWebkitMaskImage: {
             const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
@@ -1748,13 +1765,13 @@
                 return style->borderImageSource()->cssValue();
             return cssValuePool().createIdentifierValue(CSSValueNone);
         case CSSPropertyBorderTopColor:
-            return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyBorderTopColor);
         case CSSPropertyBorderRightColor:
-            return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyBorderRightColor);
         case CSSPropertyBorderBottomColor:
-            return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyBorderBottomColor);
         case CSSPropertyBorderLeftColor:
-            return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyBorderLeftColor);
         case CSSPropertyBorderTopStyle:
             return cssValuePool().createValue(style->borderTopStyle());
         case CSSPropertyBorderRightStyle:
@@ -1797,7 +1814,7 @@
             return valueForReflection(style->boxReflect(), style.get());
         case CSSPropertyBoxShadow:
         case CSSPropertyWebkitBoxShadow:
-            return valueForShadow(style->boxShadow(), propertyID, style.get());
+            return valueForShadow(renderer, style->boxShadow(), propertyID, style.get());
         case CSSPropertyCaptionSide:
             return cssValuePool().createValue(style->captionSide());
         case CSSPropertyClear:
@@ -1819,7 +1836,7 @@
         case CSSPropertyWebkitColumnProgression:
             return cssValuePool().createValue(style->columnProgression());
         case CSSPropertyWebkitColumnRuleColor:
-            return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyWebkitColumnRuleColor);
         case CSSPropertyWebkitColumnRuleStyle:
             return cssValuePool().createValue(style->columnRuleStyle());
         case CSSPropertyWebkitColumnRuleWidth:
@@ -2098,7 +2115,7 @@
                 return cssValuePool().createIdentifierValue(CSSValueAuto);
             return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyOutlineColor:
-            return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyOutlineColor);
         case CSSPropertyOutlineOffset:
             return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
         case CSSPropertyOutlineStyle:
@@ -2176,9 +2193,9 @@
         case CSSPropertyWebkitTextDecorationsInEffect:
             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
         case CSSPropertyWebkitTextFillColor:
-            return currentColorOrValidColor(style.get(), style->textFillColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyWebkitTextFillColor);
         case CSSPropertyWebkitTextEmphasisColor:
-            return currentColorOrValidColor(style.get(), style->textEmphasisColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyWebkitTextEmphasisColor);
         case CSSPropertyWebkitTextEmphasisPosition:
             return cssValuePool().createValue(style->textEmphasisPosition());
         case CSSPropertyWebkitTextEmphasisStyle:
@@ -2214,7 +2231,7 @@
             return textIndent.release();
         }
         case CSSPropertyTextShadow:
-            return valueForShadow(style->textShadow(), propertyID, style.get());
+            return valueForShadow(renderer, style->textShadow(), propertyID, style.get());
         case CSSPropertyTextRendering:
             return cssValuePool().createValue(style->fontDescription().textRenderingMode());
         case CSSPropertyTextOverflow:
@@ -2224,7 +2241,7 @@
         case CSSPropertyWebkitTextSecurity:
             return cssValuePool().createValue(style->textSecurity());
         case CSSPropertyWebkitTextStrokeColor:
-            return currentColorOrValidColor(style.get(), style->textStrokeColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyWebkitTextStrokeColor);
         case CSSPropertyWebkitTextStrokeWidth:
             return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
         case CSSPropertyTextTransform:
@@ -2470,7 +2487,7 @@
         case CSSPropertyWebkitRtlOrdering:
             return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
         case CSSPropertyWebkitTapHighlightColor:
-            return currentColorOrValidColor(style.get(), style->tapHighlightColor());
+            return currentColorOrValidColor(renderer, style.get(), CSSPropertyWebkitTapHighlightColor);
         case CSSPropertyWebkitUserDrag:
             return cssValuePool().createValue(style->userDrag());
         case CSSPropertyWebkitUserSelect:
diff --git a/Source/core/css/CSSComputedStyleDeclaration.h b/Source/core/css/CSSComputedStyleDeclaration.h
index 2eee153..1f2a35f 100644
--- a/Source/core/css/CSSComputedStyleDeclaration.h
+++ b/Source/core/css/CSSComputedStyleDeclaration.h
@@ -22,6 +22,7 @@
 #define CSSComputedStyleDeclaration_h
 
 #include "core/css/CSSStyleDeclaration.h"
+#include "core/css/StyleColor.h"
 #include "core/rendering/style/RenderStyleConstants.h"
 #include "wtf/HashMap.h"
 #include "wtf/RefPtr.h"
@@ -109,8 +110,9 @@
 
     virtual bool cssPropertyMatches(CSSPropertyID, const CSSValue*) const OVERRIDE;
 
-    PassRefPtr<CSSValue> valueForShadow(const ShadowData*, CSSPropertyID, const RenderStyle*) const;
-    PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const Color&) const;
+    PassRefPtr<CSSValue> valueForShadow(const RenderObject*, const ShadowData*, CSSPropertyID, const RenderStyle*) const;
+    PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const StyleColor&) const;
+    PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(const RenderObject*, const RenderStyle*, int colorProperty) const;
     PassRefPtr<SVGPaint> adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint>, RenderStyle*) const;
 
     PassRefPtr<CSSValue> valueForFilter(const RenderObject*, const RenderStyle*) const;
diff --git a/Source/core/css/CSSFontSelector.cpp b/Source/core/css/CSSFontSelector.cpp
index 857aa47..e8e9c4f 100644
--- a/Source/core/css/CSSFontSelector.cpp
+++ b/Source/core/css/CSSFontSelector.cpp
@@ -340,7 +340,7 @@
         styleResolver->invalidateMatchedPropertiesCache();
     if (!m_document->renderer())
         return;
-    m_document->scheduleForcedStyleRecalc();
+    m_document->setNeedsStyleRecalc();
 }
 
 void CSSFontSelector::fontLoaded()
diff --git a/Source/core/css/CSSGradientValue.cpp b/Source/core/css/CSSGradientValue.cpp
index 7b4e753..4f72ea9 100644
--- a/Source/core/css/CSSGradientValue.cpp
+++ b/Source/core/css/CSSGradientValue.cpp
@@ -105,7 +105,7 @@
     { }
 };
 
-PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(const TextLinkColors& textLinkColors, Color currentColor)
+PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(const TextLinkColors& textLinkColors)
 {
     bool derived = false;
     for (unsigned i = 0; i < m_stops.size(); i++)
@@ -128,7 +128,7 @@
     }
 
     for (unsigned i = 0; i < result->m_stops.size(); i++)
-        result->m_stops[i].m_resolvedColor = textLinkColors.colorFromPrimitiveValue(result->m_stops[i].m_color.get(), currentColor);
+        result->m_stops[i].m_resolvedColor = textLinkColors.colorFromPrimitiveValue(result->m_stops[i].m_color.get());
 
     return result.release();
 }
@@ -149,7 +149,7 @@
             else
                 offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
 
-            gradient->addColorStop(offset, stop.m_resolvedColor);
+            gradient->addColorStop(offset, renderer->resolveColor(stop.m_resolvedColor));
         }
 
         // The back end already sorted the stops.
@@ -174,7 +174,7 @@
     for (size_t i = 0; i < numStops; ++i) {
         const CSSGradientColorStop& stop = m_stops[i];
 
-        stops[i].color = stop.m_resolvedColor;
+        stops[i].color = renderer->resolveColor(stop.m_resolvedColor);
 
         if (stop.m_position) {
             if (stop.m_position->isPercentage())
diff --git a/Source/core/css/CSSGradientValue.h b/Source/core/css/CSSGradientValue.h
index 3393132..eaefe65 100644
--- a/Source/core/css/CSSGradientValue.h
+++ b/Source/core/css/CSSGradientValue.h
@@ -28,6 +28,7 @@
 
 #include "core/css/CSSImageGeneratorValue.h"
 #include "core/css/CSSPrimitiveValue.h"
+#include "core/css/StyleColor.h"
 #include "wtf/RefPtr.h"
 #include "wtf/Vector.h"
 
@@ -51,7 +52,7 @@
     CSSGradientColorStop() : m_colorIsDerivedFromElement(false) { };
     RefPtr<CSSPrimitiveValue> m_position; // percentage or length
     RefPtr<CSSPrimitiveValue> m_color;
-    Color m_resolvedColor;
+    StyleColor m_resolvedColor;
     bool m_colorIsDerivedFromElement;
     bool operator==(const CSSGradientColorStop& other) const
     {
@@ -89,7 +90,7 @@
     bool knownToBeOpaque(const RenderObject*) const;
 
     void loadSubimages(CachedResourceLoader*) { }
-    PassRefPtr<CSSGradientValue> gradientWithStylesResolved(const TextLinkColors&, Color currentColor);
+    PassRefPtr<CSSGradientValue> gradientWithStylesResolved(const TextLinkColors&);
 
 protected:
     CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientType gradientType)
diff --git a/Source/core/css/CSSParser-in.cpp b/Source/core/css/CSSParser-in.cpp
index ef0b3ff..16a4e61 100644
--- a/Source/core/css/CSSParser-in.cpp
+++ b/Source/core/css/CSSParser-in.cpp
@@ -4719,7 +4719,7 @@
         return cssValuePool().createValue(flexValue, CSSPrimitiveValue::CSS_FR);
     }
 
-    if (!validUnit(currentValue, FLength | FPercent))
+    if (!validUnit(currentValue, FNonNeg | FLength | FPercent))
         return 0;
 
     return createPrimitiveNumericValue(currentValue);
@@ -5872,10 +5872,10 @@
         return true;
 
     // Try named colors.
-    Color tc;
-    tc.setNamedColor(name);
-    if (tc.isValid()) {
-        rgb = tc.rgb();
+    StyleColor color;
+    color.setNamedColor(name);
+    if (color.isValid()) {
+        rgb = color.rgb();
         return true;
     }
     return false;
@@ -9988,217 +9988,146 @@
     CharacterType* name = tokenStart<CharacterType>();
     ASSERT(name[0] == '@' && length >= 2);
 
+    // Ignore leading @.
+    ++name;
+    --length;
+
     // charset, font-face, import, media, namespace, page, supports,
     // -webkit-keyframes, and -webkit-mediaquery are not affected by hasEscape.
-    switch (toASCIILowerUnchecked(name[1])) {
-    case 'b':
-        if (hasEscape)
-            return;
-
-        switch (length) {
-        case 12:
-            if (isEqualToCSSIdentifier(name + 2, "ottom-left"))
+    SWITCH(name, length) {
+        CASE("bottom-left") {
+            if (LIKELY(!hasEscape))
                 m_token = BOTTOMLEFT_SYM;
-            return;
-
-        case 13:
-            if (isEqualToCSSIdentifier(name + 2, "ottom-right"))
-                m_token = BOTTOMRIGHT_SYM;
-            return;
-
-        case 14:
-            if (isEqualToCSSIdentifier(name + 2, "ottom-center"))
-                m_token = BOTTOMCENTER_SYM;
-            return;
-
-        case 19:
-            if (isEqualToCSSIdentifier(name + 2, "ottom-left-corner"))
-                m_token = BOTTOMLEFTCORNER_SYM;
-            return;
-
-        case 20:
-            if (isEqualToCSSIdentifier(name + 2, "ottom-right-corner"))
-                m_token = BOTTOMRIGHTCORNER_SYM;
-            return;
         }
-        return;
-
-    case 'c':
-        if (length == 8 && isEqualToCSSIdentifier(name + 2, "harset") && name == dataStart<CharacterType>())
-            m_token = CHARSET_SYM;
-        return;
-
-    case 'f':
-        if (length == 10 && isEqualToCSSIdentifier(name + 2, "ont-face"))
+        CASE("bottom-right") {
+            if (LIKELY(!hasEscape))
+                m_token = BOTTOMRIGHT_SYM;
+        }
+        CASE("bottom-center") {
+            if (LIKELY(!hasEscape))
+                m_token = BOTTOMCENTER_SYM;
+        }
+        CASE("bottom-left-corner") {
+            if (LIKELY(!hasEscape))
+                m_token = BOTTOMLEFTCORNER_SYM;
+        }
+        CASE("bottom-right-corner") {
+            if (LIKELY(!hasEscape))
+                m_token = BOTTOMRIGHTCORNER_SYM;
+        }
+        CASE("charset") {
+            if (name - 1 == dataStart<CharacterType>())
+                m_token = CHARSET_SYM;
+        }
+        CASE("font-face") {
             m_token = FONT_FACE_SYM;
-        return;
-
-    case 'h':
-        if (length == 5 && isEqualToCSSIdentifier(name + 2, "ost"))
+        }
+        CASE("host") {
             m_token = HOST_SYM;
-        return;
-
-    case 'i':
-        if (length == 7 && isEqualToCSSIdentifier(name + 2, "mport")) {
+        }
+        CASE("import") {
             m_parsingMode = MediaQueryMode;
             m_token = IMPORT_SYM;
         }
-        return;
-
-    case 'l':
-        if (hasEscape)
-            return;
-
-        if (length == 9) {
-            if (isEqualToCSSIdentifier(name + 2, "eft-top"))
+        CASE("left-top") {
+            if (LIKELY(!hasEscape))
                 m_token = LEFTTOP_SYM;
-        } else if (length == 12) {
-            // Checking the last character first could further reduce the possibile cases.
-            if (isASCIIAlphaCaselessEqual(name[11], 'e') && isEqualToCSSIdentifier(name + 2, "eft-middl"))
+        }
+        CASE("left-middle") {
+            if (LIKELY(!hasEscape))
                 m_token = LEFTMIDDLE_SYM;
-            else if (isASCIIAlphaCaselessEqual(name[11], 'm') && isEqualToCSSIdentifier(name + 2, "eft-botto"))
+        }
+        CASE("left-bottom") {
+            if (LIKELY(!hasEscape))
                 m_token = LEFTBOTTOM_SYM;
         }
-        return;
-
-    case 'm':
-        if (length == 6 && isEqualToCSSIdentifier(name + 2, "edia")) {
+        CASE("media") {
             m_parsingMode = MediaQueryMode;
             m_token = MEDIA_SYM;
         }
-        return;
-
-    case 'n':
-        if (length == 10 && isEqualToCSSIdentifier(name + 2, "amespace"))
+        CASE("namespace") {
             m_token = NAMESPACE_SYM;
-        return;
-
-    case 'p':
-        if (length == 5 && isEqualToCSSIdentifier(name + 2, "age"))
+        }
+        CASE("page") {
             m_token = PAGE_SYM;
-        return;
-
-    case 'r':
-        if (hasEscape)
-            return;
-
-        if (length == 10) {
-            if (isEqualToCSSIdentifier(name + 2, "ight-top"))
+        }
+        CASE("right-top") {
+            if (LIKELY(!hasEscape))
                 m_token = RIGHTTOP_SYM;
-        } else if (length == 13) {
-            // Checking the last character first could further reduce the possibile cases.
-            if (isASCIIAlphaCaselessEqual(name[12], 'e') && isEqualToCSSIdentifier(name + 2, "ight-middl"))
+        }
+        CASE("right-middle") {
+            if (LIKELY(!hasEscape))
                 m_token = RIGHTMIDDLE_SYM;
-            else if (isASCIIAlphaCaselessEqual(name[12], 'm') && isEqualToCSSIdentifier(name + 2, "ight-botto"))
+        }
+        CASE("right-bottom") {
+            if (LIKELY(!hasEscape))
                 m_token = RIGHTBOTTOM_SYM;
         }
-        return;
-
-    case 's':
-        if (length == 9 && isEqualToCSSIdentifier(name + 2, "upports")) {
+        CASE("supports") {
             m_parsingMode = SupportsMode;
             m_token = SUPPORTS_SYM;
         }
-        return;
-
-    case 't':
-        if (hasEscape)
-            return;
-
-        switch (length) {
-        case 9:
-            if (isEqualToCSSIdentifier(name + 2, "op-left"))
+        CASE("top-left") {
+            if (LIKELY(!hasEscape))
                 m_token = TOPLEFT_SYM;
-            return;
-
-        case 10:
-            if (isEqualToCSSIdentifier(name + 2, "op-right"))
-                m_token = TOPRIGHT_SYM;
-            return;
-
-        case 11:
-            if (isEqualToCSSIdentifier(name + 2, "op-center"))
-                m_token = TOPCENTER_SYM;
-            return;
-
-        case 16:
-            if (isEqualToCSSIdentifier(name + 2, "op-left-corner"))
-                m_token = TOPLEFTCORNER_SYM;
-            return;
-
-        case 17:
-            if (isEqualToCSSIdentifier(name + 2, "op-right-corner"))
-                m_token = TOPRIGHTCORNER_SYM;
-            return;
         }
-        return;
-
-    case 'v':
-        if (length == 9 && isEqualToCSSIdentifier(name + 2, "iewport"))
+        CASE("top-right") {
+            if (LIKELY(!hasEscape))
+                m_token = TOPRIGHT_SYM;
+        }
+        CASE("top-center") {
+            if (LIKELY(!hasEscape))
+                m_token = TOPCENTER_SYM;
+        }
+        CASE("top-left-corner") {
+            if (LIKELY(!hasEscape))
+                m_token = TOPLEFTCORNER_SYM;
+        }
+        CASE("top-right-corner") {
+            if (LIKELY(!hasEscape))
+                m_token = TOPRIGHTCORNER_SYM;
+        }
+        CASE("viewport") {
             m_token = VIEWPORT_RULE_SYM;
-        return;
-
-    case '-':
-        switch (length) {
-        case 15:
-            if (hasEscape)
-                return;
-
-            if (isEqualToCSSIdentifier(name + 2, "internal-rule")) {
+        }
+        CASE("-internal-rule") {
+            if (LIKELY(!hasEscape))
                 m_token = INTERNAL_RULE_SYM;
-                return;
-            }
-
-            if (isASCIIAlphaCaselessEqual(name[14], 'n') && isEqualToCSSIdentifier(name + 2, "webkit-regio")) {
+        }
+        CASE("-webkit-region") {
+            if (LIKELY(!hasEscape))
                 m_token = WEBKIT_REGION_RULE_SYM;
-                return;
-            }
-
-            if (isASCIIAlphaCaselessEqual(name[14], 'r') && isEqualToCSSIdentifier(name + 2, "webkit-filte")) {
+        }
+        CASE("-webkit-filter") {
+            if (LIKELY(!hasEscape))
                 m_token = WEBKIT_FILTER_RULE_SYM;
-                return;
-            }
-            return;
-
-        case 16:
-            if (hasEscape)
-                return;
-
-            // Checking the last character first could further reduce the possibile cases.
-            if (isASCIIAlphaCaselessEqual(name[15], 's') && isEqualToCSSIdentifier(name + 2, "internal-decl"))
+        }
+        CASE("-internal-decls") {
+            if (LIKELY(!hasEscape))
                 m_token = INTERNAL_DECLS_SYM;
-            else if (isASCIIAlphaCaselessEqual(name[15], 'e') && isEqualToCSSIdentifier(name + 2, "internal-valu"))
+        }
+        CASE("-internal-value") {
+            if (LIKELY(!hasEscape))
                 m_token = INTERNAL_VALUE_SYM;
-            return;
-
-        case 18:
-            if (isEqualToCSSIdentifier(name + 2, "webkit-keyframes"))
-                m_token = WEBKIT_KEYFRAMES_SYM;
-            return;
-
-        case 19:
-            if (!hasEscape && isASCIIAlphaCaselessEqual(name[18], 'r') && isEqualToCSSIdentifier(name + 2, "internal-selecto"))
+        }
+        CASE("-webkit-keyframes") {
+            m_token = WEBKIT_KEYFRAMES_SYM;
+        }
+        CASE("-internal-selector") {
+            if (LIKELY(!hasEscape))
                 m_token = INTERNAL_SELECTOR_SYM;
-            return;
-
-        case 20:
-            if (isEqualToCSSIdentifier(name + 2, "internal-medialist")) {
-                m_parsingMode = MediaQueryMode;
-                m_token = INTERNAL_MEDIALIST_SYM;
-            }
-            return;
-
-        case 24:
-            if (!hasEscape && isEqualToCSSIdentifier(name + 2, "internal-keyframe-rule"))
+        }
+        CASE("-internal-medialist") {
+            m_parsingMode = MediaQueryMode;
+            m_token = INTERNAL_MEDIALIST_SYM;
+        }
+        CASE("-internal-keyframe-rule") {
+            if (LIKELY(!hasEscape))
                 m_token = INTERNAL_KEYFRAME_RULE_SYM;
-            return;
-
-        case 29:
-            if (isEqualToCSSIdentifier(name + 2, "internal-supports-condition")) {
-                m_parsingMode = SupportsMode;
-                m_token = INTERNAL_SUPPORTS_CONDITION_SYM;
-            }
-            return;
+        }
+        CASE("-internal-supports-condition") {
+            m_parsingMode = SupportsMode;
+            m_token = INTERNAL_SUPPORTS_CONDITION_SYM;
         }
     }
 }
diff --git a/Source/core/css/CSSPrimitiveValue.cpp b/Source/core/css/CSSPrimitiveValue.cpp
index 4fa70c7..602430b 100644
--- a/Source/core/css/CSSPrimitiveValue.cpp
+++ b/Source/core/css/CSSPrimitiveValue.cpp
@@ -488,42 +488,42 @@
     }
 }
 
-template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> int CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize)
 {
     return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
 }
 
-template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> unsigned CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize)
 {
     return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
 }
 
-template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> Length CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize)
 {
     return Length(clampTo<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize), minValueForCssLength, maxValueForCssLength), Fixed);
 }
 
-template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize)
 {
     return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
 }
 
-template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> unsigned short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize)
 {
     return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
 }
 
-template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> float CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize)
 {
     return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
 }
 
-template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> double CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize)
 {
     return computeLengthDouble(style, rootStyle, multiplier, computingFontSize);
 }
 
-double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize)
 {
     if (m_primitiveUnitType == CSS_CALC)
         // The multiplier and factor is applied to each value in the calc expression individually
@@ -1025,21 +1025,21 @@
                 Color::parseHexColor(m_value.string, rgbColor);
             Color color(rgbColor);
 
-            Vector<LChar> result;
-            result.reserveInitialCapacity(32);
+            StringBuilder result;
+            result.reserveCapacity(32);
             bool colorHasAlpha = color.hasAlpha();
             if (colorHasAlpha)
                 result.append("rgba(", 5);
             else
                 result.append("rgb(", 4);
 
-            appendNumber(result, static_cast<unsigned char>(color.red()));
+            result.appendNumber(static_cast<unsigned char>(color.red()));
             result.append(", ", 2);
 
-            appendNumber(result, static_cast<unsigned char>(color.green()));
+            result.appendNumber(static_cast<unsigned char>(color.green()));
             result.append(", ", 2);
 
-            appendNumber(result, static_cast<unsigned char>(color.blue()));
+            result.appendNumber(static_cast<unsigned char>(color.blue()));
             if (colorHasAlpha) {
                 result.append(", ", 2);
 
@@ -1049,7 +1049,7 @@
             }
 
             result.append(')');
-            text = String::adopt(result);
+            text = result.toString();
             break;
         }
         case CSS_PAIR:
diff --git a/Source/core/css/CSSPrimitiveValue.h b/Source/core/css/CSSPrimitiveValue.h
index 39d9fc6..33fc67d 100644
--- a/Source/core/css/CSSPrimitiveValue.h
+++ b/Source/core/css/CSSPrimitiveValue.h
@@ -253,10 +253,10 @@
      * this is screen/printer dependent, so we probably need a config option for this,
      * and some tool to calibrate.
      */
-    template<typename T> T computeLength(RenderStyle* currStyle, RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false);
+    template<typename T> T computeLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false);
 
     // Converts to a Length, mapping various unit types appropriately.
-    template<int> Length convertToLength(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false);
+    template<int> Length convertToLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false);
 
     // use with care!!!
     void setPrimitiveType(unsigned short type) { m_primitiveUnitType = type; }
@@ -359,7 +359,7 @@
     void init(PassRefPtr<CSSCalcValue>);
     bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const;
 
-    double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, float multiplier, bool computingFontSize);
+    double computeLengthDouble(const RenderStyle* currentStyle, const RenderStyle* rootStyle, float multiplier, bool computingFontSize);
 
     union {
         CSSPropertyID propertyID;
diff --git a/Source/core/css/CSSPrimitiveValueMappings.h b/Source/core/css/CSSPrimitiveValueMappings.h
index 49081b0..d03496d 100644
--- a/Source/core/css/CSSPrimitiveValueMappings.h
+++ b/Source/core/css/CSSPrimitiveValueMappings.h
@@ -4269,7 +4269,7 @@
     FractionConversion = 1 << 4,
 };
 
-template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
+template<int supported> Length CSSPrimitiveValue::convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, double multiplier, bool computingFontSize)
 {
     ASSERT(!hasVariableReference());
     if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!style || !rootStyle))
diff --git a/Source/core/css/CSSSelector.cpp b/Source/core/css/CSSSelector.cpp
index 5abb5e2..c32ec17 100644
--- a/Source/core/css/CSSSelector.cpp
+++ b/Source/core/css/CSSSelector.cpp
@@ -34,6 +34,7 @@
 #include "wtf/HashMap.h"
 #include "wtf/StdLibExtras.h"
 #include "wtf/text/StringBuilder.h"
+#include "wtf/text/StringHash.h"
 
 namespace WebCore {
 
@@ -257,7 +258,7 @@
     return NOPSEUDO;
 }
 
-static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap()
+static HashMap<StringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap()
 {
     DEFINE_STATIC_LOCAL(AtomicString, active, ("active", AtomicString::ConstructFromLiteral));
     DEFINE_STATIC_LOCAL(AtomicString, after, ("after", AtomicString::ConstructFromLiteral));
@@ -337,9 +338,9 @@
     DEFINE_STATIC_LOCAL(AtomicString, scope, ("scope", AtomicString::ConstructFromLiteral));
     DEFINE_STATIC_LOCAL(AtomicString, unresolved, ("unresolved", AtomicString::ConstructFromLiteral));
 
-    static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoType = 0;
+    static HashMap<StringImpl*, CSSSelector::PseudoType>* nameToPseudoType = 0;
     if (!nameToPseudoType) {
-        nameToPseudoType = new HashMap<AtomicStringImpl*, CSSSelector::PseudoType>;
+        nameToPseudoType = new HashMap<StringImpl*, CSSSelector::PseudoType>;
         nameToPseudoType->set(active.impl(), CSSSelector::PseudoActive);
         nameToPseudoType->set(after.impl(), CSSSelector::PseudoAfter);
         nameToPseudoType->set(anyLink.impl(), CSSSelector::PseudoAnyLink);
@@ -425,8 +426,8 @@
 {
     if (name.isNull())
         return PseudoUnknown;
-    HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoType = nameToPseudoTypeMap();
-    HashMap<AtomicStringImpl*, CSSSelector::PseudoType>::iterator slot = nameToPseudoType->find(name.impl());
+    HashMap<StringImpl*, CSSSelector::PseudoType>* nameToPseudoType = nameToPseudoTypeMap();
+    HashMap<StringImpl*, CSSSelector::PseudoType>::iterator slot = nameToPseudoType->find(name.impl());
 
     if (slot != nameToPseudoType->end())
         return slot->value;
@@ -737,7 +738,7 @@
     return m_data.m_rareData->matchNth(count);
 }
 
-CSSSelector::RareData::RareData(PassRefPtr<AtomicStringImpl> value)
+CSSSelector::RareData::RareData(PassRefPtr<StringImpl> value)
     : m_value(value.leakRef())
     , m_a(0)
     , m_b(0)
diff --git a/Source/core/css/CSSSelector.h b/Source/core/css/CSSSelector.h
index 1eafd5f..5aa125a 100644
--- a/Source/core/css/CSSSelector.h
+++ b/Source/core/css/CSSSelector.h
@@ -255,13 +255,13 @@
         CSSSelector& operator=(const CSSSelector&);
 
         struct RareData : public RefCounted<RareData> {
-            static PassRefPtr<RareData> create(PassRefPtr<AtomicStringImpl> value) { return adoptRef(new RareData(value)); }
+            static PassRefPtr<RareData> create(PassRefPtr<StringImpl> value) { return adoptRef(new RareData(value)); }
             ~RareData();
 
             bool parseNth();
             bool matchNth(int count);
 
-            AtomicStringImpl* m_value; // Plain pointer to keep things uniform with the union.
+            StringImpl* m_value; // Plain pointer to keep things uniform with the union.
             int m_a; // Used for :nth-*
             int m_b; // Used for :nth-*
             QualifiedName m_attribute; // used for attribute selector
@@ -269,13 +269,13 @@
             OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :not
         
         private:
-            RareData(PassRefPtr<AtomicStringImpl> value);
+            RareData(PassRefPtr<StringImpl> value);
         };
         void createRareData();
 
         union DataUnion {
             DataUnion() : m_value(0) { }
-            AtomicStringImpl* m_value;
+            StringImpl* m_value;
             QualifiedName::QualifiedNameImpl* m_tagQName;
             RareData* m_rareData;
         } m_data;
@@ -430,8 +430,8 @@
 inline const AtomicString& CSSSelector::value() const
 {
     ASSERT(m_match != Tag);
-    // AtomicString is really just an AtomicStringImpl* so the cast below is safe.
-    // FIXME: Perhaps call sites could be changed to accept AtomicStringImpl?
+    // AtomicString is really just a StringImpl* so the cast below is safe.
+    // FIXME: Perhaps call sites could be changed to accept StringImpl?
     return *reinterpret_cast<const AtomicString*>(m_hasRareData ? &m_data.m_rareData->m_value : &m_data.m_value);
 }
 
diff --git a/Source/core/css/CSSToStyleMap.cpp b/Source/core/css/CSSToStyleMap.cpp
index 2fb8595..43227c9 100644
--- a/Source/core/css/CSSToStyleMap.cpp
+++ b/Source/core/css/CSSToStyleMap.cpp
@@ -58,7 +58,7 @@
     
 PassRefPtr<StyleImage> CSSToStyleMap::styleImage(CSSPropertyID propertyId, CSSValue* value)
 {
-    return m_elementStyleResources.styleImage(m_state.document()->textLinkColors(), m_state.style()->visitedDependentColor(CSSPropertyColor), propertyId, value);
+    return m_elementStyleResources.styleImage(m_state.document()->textLinkColors(), propertyId, value);
 }
 
 void CSSToStyleMap::mapFillAttachment(CSSPropertyID, FillLayer* layer, CSSValue* value) const
diff --git a/Source/core/css/MediaQueryEvaluator.cpp b/Source/core/css/MediaQueryEvaluator.cpp
index bba87c5..900a627 100644
--- a/Source/core/css/MediaQueryEvaluator.cpp
+++ b/Source/core/css/MediaQueryEvaluator.cpp
@@ -58,7 +58,7 @@
 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix };
 
 typedef bool (*EvalFunc)(CSSValue*, RenderStyle*, Frame*, MediaFeaturePrefix);
-typedef HashMap<AtomicStringImpl*, EvalFunc> FunctionMap;
+typedef HashMap<StringImpl*, EvalFunc> FunctionMap;
 static FunctionMap* gFunctionMap;
 
 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult)
diff --git a/Source/core/css/RuleFeature.cpp b/Source/core/css/RuleFeature.cpp
index 6e30432..927f248 100644
--- a/Source/core/css/RuleFeature.cpp
+++ b/Source/core/css/RuleFeature.cpp
@@ -56,14 +56,14 @@
 
 void RuleFeatureSet::add(const RuleFeatureSet& other)
 {
-    HashSet<AtomicStringImpl*>::const_iterator end = other.idsInRules.end();
-    for (HashSet<AtomicStringImpl*>::const_iterator it = other.idsInRules.begin(); it != end; ++it)
+    HashSet<AtomicString>::const_iterator end = other.idsInRules.end();
+    for (HashSet<AtomicString>::const_iterator it = other.idsInRules.begin(); it != end; ++it)
         idsInRules.add(*it);
     end = other.classesInRules.end();
-    for (HashSet<AtomicStringImpl*>::const_iterator it = other.classesInRules.begin(); it != end; ++it)
+    for (HashSet<AtomicString>::const_iterator it = other.classesInRules.begin(); it != end; ++it)
         classesInRules.add(*it);
     end = other.attrsInRules.end();
-    for (HashSet<AtomicStringImpl*>::const_iterator it = other.attrsInRules.begin(); it != end; ++it)
+    for (HashSet<AtomicString>::const_iterator it = other.attrsInRules.begin(); it != end; ++it)
         attrsInRules.add(*it);
     siblingRules.append(other.siblingRules);
     uncommonAttributeRules.append(other.uncommonAttributeRules);
diff --git a/Source/core/css/RuleFeature.h b/Source/core/css/RuleFeature.h
index 6e18fbb..ed7f0d7 100644
--- a/Source/core/css/RuleFeature.h
+++ b/Source/core/css/RuleFeature.h
@@ -24,7 +24,7 @@
 
 #include "wtf/Forward.h"
 #include "wtf/HashSet.h"
-#include "wtf/text/AtomicString.h"
+#include "wtf/text/AtomicStringHash.h"
 
 namespace WebCore {
 
@@ -59,27 +59,27 @@
     bool usesFirstLineRules() const { return m_usesFirstLineRules; }
     bool usesBeforeAfterRules() const { return m_usesBeforeAfterRules; }
 
-    inline bool hasSelectorForAttribute(const AtomicString &attributeName) const
+    inline bool hasSelectorForAttribute(const AtomicString& attributeName) const
     {
         ASSERT(!attributeName.isEmpty());
-        return attrsInRules.contains(attributeName.impl());
+        return attrsInRules.contains(attributeName);
     }
 
     inline bool hasSelectorForClass(const AtomicString& classValue) const
     {
         ASSERT(!classValue.isEmpty());
-        return classesInRules.contains(classValue.impl());
+        return classesInRules.contains(classValue);
     }
 
     inline bool hasSelectorForId(const AtomicString& idValue) const
     {
         ASSERT(!idValue.isEmpty());
-        return idsInRules.contains(idValue.impl());
+        return idsInRules.contains(idValue);
     }
 
-    HashSet<AtomicStringImpl*> idsInRules;
-    HashSet<AtomicStringImpl*> classesInRules;
-    HashSet<AtomicStringImpl*> attrsInRules;
+    HashSet<AtomicString> idsInRules;
+    HashSet<AtomicString> classesInRules;
+    HashSet<AtomicString> attrsInRules;
     Vector<RuleFeature> siblingRules;
     Vector<RuleFeature> uncommonAttributeRules;
 private:
diff --git a/Source/core/css/RuleSet.cpp b/Source/core/css/RuleSet.cpp
index 85b4302..71e89a8 100644
--- a/Source/core/css/RuleSet.cpp
+++ b/Source/core/css/RuleSet.cpp
@@ -241,7 +241,7 @@
         features.uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));
 }
     
-void RuleSet::addToRuleSet(AtomicStringImpl* key, PendingRuleMap& map, const RuleData& ruleData)
+void RuleSet::addToRuleSet(StringImpl* key, PendingRuleMap& map, const RuleData& ruleData)
 {
     if (!key)
         return;
diff --git a/Source/core/css/RuleSet.h b/Source/core/css/RuleSet.h
index 75bc421..69f2b27 100644
--- a/Source/core/css/RuleSet.h
+++ b/Source/core/css/RuleSet.h
@@ -108,10 +108,10 @@
 
     const RuleFeatureSet& features() const { return m_features; }
 
-    const RuleData* idRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_idRules.get(key); }
-    const RuleData* classRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_classRules.get(key); }
-    const RuleData* tagRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_tagRules.get(key); }
-    const RuleData* shadowPseudoElementRules(AtomicStringImpl* key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.get(key); }
+    const RuleData* idRules(StringImpl* key) const { ASSERT(!m_pendingRules); return m_idRules.get(key); }
+    const RuleData* classRules(StringImpl* key) const { ASSERT(!m_pendingRules); return m_classRules.get(key); }
+    const RuleData* tagRules(StringImpl* key) const { ASSERT(!m_pendingRules); return m_tagRules.get(key); }
+    const RuleData* shadowPseudoElementRules(StringImpl* key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.get(key); }
     const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRules); return &m_linkPseudoClassRules; }
     const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); return &m_cuePseudoRules; }
     const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRules); return &m_focusPseudoClassRules; }
@@ -139,15 +139,15 @@
     Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets;
 
 private:
-    typedef HashMap<AtomicStringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap;
-    typedef HashMap<AtomicStringImpl*, OwnPtr<RuleData> > CompactRuleMap;
+    typedef HashMap<StringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap;
+    typedef HashMap<StringImpl*, OwnPtr<RuleData> > CompactRuleMap;
 
     RuleSet()
         : m_ruleCount(0)
     {
     }
 
-    void addToRuleSet(AtomicStringImpl* key, PendingRuleMap&, const RuleData&);
+    void addToRuleSet(StringImpl* key, PendingRuleMap&, const RuleData&);
     void addPageRule(StyleRulePage*);
     void addViewportRule(StyleRuleViewport*);
     void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin);
diff --git a/Source/core/css/SVGCSSComputedStyleDeclaration.cpp b/Source/core/css/SVGCSSComputedStyleDeclaration.cpp
index fd03b7c..1dabadf 100644
--- a/Source/core/css/SVGCSSComputedStyleDeclaration.cpp
+++ b/Source/core/css/SVGCSSComputedStyleDeclaration.cpp
@@ -62,8 +62,11 @@
 PassRefPtr<SVGPaint> CSSComputedStyleDeclaration::adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint> newPaint, RenderStyle* style) const
 {
     RefPtr<SVGPaint> paint = newPaint;
-    if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR)
-        paint->setColor(style->color());
+    if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR) {
+        // SVG handles currentColor itself, style->color() is guaranteed not to be currentColor.
+        ASSERT(!style->color().isCurrentColor());
+        paint->setColor(style->color().color());
+    }
     return paint.release();
 }
 
@@ -190,7 +193,7 @@
             return 0;
         }
         case CSSPropertyWebkitSvgShadow:
-            return valueForShadow(svgStyle->shadow(), propertyID, style);
+            return valueForShadow(node->renderer(), svgStyle->shadow(), propertyID, style);
         case CSSPropertyVectorEffect:
             return CSSPrimitiveValue::create(svgStyle->vectorEffect());
         case CSSPropertyMaskType:
diff --git a/Source/core/css/SelectorChecker.h b/Source/core/css/SelectorChecker.h
index c1f7fd1..bab408e 100644
--- a/Source/core/css/SelectorChecker.h
+++ b/Source/core/css/SelectorChecker.h
@@ -100,7 +100,7 @@
     static bool tagMatches(const Element*, const QualifiedName&);
     static bool isCommonPseudoClassSelector(const CSSSelector*);
     static bool matchesFocusPseudoClass(const Element*);
-    static bool checkExactAttribute(const Element*, const QualifiedName& selectorAttributeName, const AtomicStringImpl* value);
+    static bool checkExactAttribute(const Element*, const QualifiedName& selectorAttributeName, const StringImpl* value);
 
     enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited };
     static unsigned determineLinkMatchType(const CSSSelector*);
@@ -137,7 +137,7 @@
     return namespaceURI == starAtom || namespaceURI == element->namespaceURI();
 }
 
-inline bool SelectorChecker::checkExactAttribute(const Element* element, const QualifiedName& selectorAttributeName, const AtomicStringImpl* value)
+inline bool SelectorChecker::checkExactAttribute(const Element* element, const QualifiedName& selectorAttributeName, const StringImpl* value)
 {
     if (!element->hasAttributesWithoutUpdate())
         return false;
diff --git a/Source/core/css/StyleColor.cpp b/Source/core/css/StyleColor.cpp
new file mode 100644
index 0000000..b40673a
--- /dev/null
+++ b/Source/core/css/StyleColor.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "core/css/StyleColor.h"
+
+#include "core/platform/HashTools.h"
+#include "wtf/text/WTFString.h"
+
+using namespace std;
+
+namespace WebCore {
+
+StyleColor::StyleColor(const String& name)
+{
+    if (name[0] == '#') {
+        RGBA32 rgba;
+        if (name.is8Bit())
+            m_valid = Color::parseHexColor(name.characters8() + 1, name.length() - 1, rgba);
+        else
+            m_valid = Color::parseHexColor(name.characters16() + 1, name.length() - 1, rgba);
+        m_color = rgba;
+    } else {
+        setNamedColor(name);
+    }
+}
+
+StyleColor::StyleColor(const char* name)
+{
+    if (name[0] == '#') {
+        RGBA32 rgba;
+        m_valid = Color::parseHexColor(&name[1], rgba);
+        m_color = rgba;
+    } else {
+        const NamedColor* foundColor = findColor(name, strlen(name));
+        m_color = foundColor ? foundColor->ARGBValue : 0;
+        m_valid = foundColor;
+    }
+}
+
+static inline const NamedColor* findNamedColor(const String& name)
+{
+    char buffer[64]; // easily big enough for the longest color name
+    unsigned length = name.length();
+    if (length > sizeof(buffer) - 1)
+        return 0;
+    for (unsigned i = 0; i < length; ++i) {
+        UChar c = name[i];
+        if (!c || c > 0x7F)
+            return 0;
+        buffer[i] = toASCIILower(static_cast<char>(c));
+    }
+    buffer[length] = '\0';
+    return findColor(buffer, length);
+}
+
+void StyleColor::setNamedColor(const String& name)
+{
+    const NamedColor* foundColor = findNamedColor(name);
+    m_color = foundColor ? foundColor->ARGBValue : 0;
+    m_valid = foundColor;
+}
+
+} // namespace WebCore
diff --git a/Source/core/css/StyleColor.h b/Source/core/css/StyleColor.h
index eb893e4..41c9f97 100644
--- a/Source/core/css/StyleColor.h
+++ b/Source/core/css/StyleColor.h
@@ -43,11 +43,11 @@
         : m_color()
         , m_valid(false)
         , m_currentColor(false) { }
-    StyleColor(Color color)
+    StyleColor(RGBA32 color)
         : m_color(color)
         , m_valid(true)
         , m_currentColor(false) { }
-    StyleColor(RGBA32 color, bool valid = true, bool currentColor = false)
+    StyleColor(Color color, bool valid = true, bool currentColor = false)
         : m_color(color)
         , m_valid(valid)
         , m_currentColor(currentColor) { }
@@ -63,12 +63,15 @@
         : m_color(other.m_color)
         , m_valid(other.m_valid)
         , m_currentColor(other.m_currentColor) { }
+    explicit StyleColor(const String&);
+    explicit StyleColor(const char*);
 
     Color color() const { return m_color; }
     bool isValid() const { return m_valid; }
     bool isCurrentColor() const { return m_currentColor; }
     bool hasAlpha() const { return m_color.hasAlpha(); }
 
+    void setNamedColor(const String&);
     void setRGB(int r, int g, int b)
     {
         m_color.setRGB(r, g, b);
diff --git a/Source/core/css/StyleInvalidationAnalysis.cpp b/Source/core/css/StyleInvalidationAnalysis.cpp
index 47ce49a..2577372 100644
--- a/Source/core/css/StyleInvalidationAnalysis.cpp
+++ b/Source/core/css/StyleInvalidationAnalysis.cpp
@@ -44,7 +44,7 @@
         analyzeStyleSheet(sheets[i]);
 }
 
-static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes)
+static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet<StringImpl*>& idScopes, HashSet<StringImpl*>& classScopes)
 {
     for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) {
         const CSSSelector* scopeSelector = 0;
@@ -141,7 +141,7 @@
     }
 }
 
-static bool elementMatchesSelectorScopes(const Element* element, const HashSet<AtomicStringImpl*>& idScopes, const HashSet<AtomicStringImpl*>& classScopes)
+static bool elementMatchesSelectorScopes(const Element* element, const HashSet<StringImpl*>& idScopes, const HashSet<StringImpl*>& classScopes)
 {
     if (!idScopes.isEmpty() && element->hasID() && idScopes.contains(element->idForStyleResolution().impl()))
         return true;
diff --git a/Source/core/css/StyleInvalidationAnalysis.h b/Source/core/css/StyleInvalidationAnalysis.h
index 18dad9f..e58f37a 100644
--- a/Source/core/css/StyleInvalidationAnalysis.h
+++ b/Source/core/css/StyleInvalidationAnalysis.h
@@ -28,7 +28,7 @@
 
 #include "wtf/HashSet.h"
 #include "wtf/Vector.h"
-#include "wtf/text/AtomicStringImpl.h"
+#include "wtf/text/StringImpl.h"
 
 namespace WebCore {
 
@@ -48,8 +48,8 @@
     void analyzeStyleSheet(StyleSheetContents*);
 
     bool m_dirtiesAllStyle;
-    HashSet<AtomicStringImpl*> m_idScopes;
-    HashSet<AtomicStringImpl*> m_classScopes;
+    HashSet<StringImpl*> m_idScopes;
+    HashSet<StringImpl*> m_classScopes;
     Vector<Node*, 8> m_scopingNodes;
 };
 
diff --git a/Source/core/css/makegrammar.pl b/Source/core/css/makegrammar.pl
index 4e0452e..eb47022 100644
--- a/Source/core/css/makegrammar.pl
+++ b/Source/core/css/makegrammar.pl
@@ -26,70 +26,33 @@
 use Getopt::Long;
 
 my $outputDir = ".";
-my $extraDefines = "";
-my $symbolsPrefix = "";
-my $preprocessor = "";
-my $preprocessOnly = 0;
-my $bison = "bison";
 
 GetOptions(
     'outputDir=s' => \$outputDir,
-    'extraDefines=s' => \$extraDefines,
-    'bison=s' => \$bison,
-    'preprocessor=s' => \$preprocessor,
-    'preprocessOnly' => \$preprocessOnly,
-    'symbolsPrefix=s' => \$symbolsPrefix
 );
 
 my $grammarFilePath = $ARGV[0];
 my $grammarIncludesFilePath = @ARGV > 0 ? $ARGV[1] : "";
 
-if (!length($symbolsPrefix) && !$preprocessOnly) {
-    die "Need a symbols prefix to give to bison (e.g. cssyy, xpathyy)";
-}
-
 my ($filename, $basePath, $suffix) = fileparse($grammarFilePath, (".y", ".y.in"));
 
-if ($suffix eq ".y.in") {
-    my $grammarFileOutPath = File::Spec->join($outputDir, "$filename.y");
-    if (!$grammarIncludesFilePath) {
-        $grammarIncludesFilePath = "${basePath}${filename}.y.includes";
-    }
-
-    open GRAMMAR, ">$grammarFileOutPath" or die;
-    open INCLUDES, "<$grammarIncludesFilePath" or die;
-
-    require preprocessor;
-
-    while (<INCLUDES>) {
-        print GRAMMAR;
-    }
-    print GRAMMAR join("", applyPreprocessor($grammarFilePath, $extraDefines, $preprocessor));
-    close GRAMMAR;
-
-    $grammarFilePath = $grammarFileOutPath;
-
-    exit if $preprocessOnly;
+my $grammarFileOutPath = File::Spec->join($outputDir, "$filename.y");
+if (!$grammarIncludesFilePath) {
+    $grammarIncludesFilePath = "${basePath}${filename}.y.includes";
 }
 
-my $fileBase = File::Spec->join($outputDir, $filename);
-system("$bison -d -p $symbolsPrefix $grammarFilePath -o $fileBase.cpp");
+open GRAMMAR, ">$grammarFileOutPath" or die;
+open INCLUDES, "<$grammarIncludesFilePath" or die;
 
-open HEADER, ">$fileBase.h" or die;
-print HEADER << "EOF";
-#ifndef CSSGRAMMAR_H
-#define CSSGRAMMAR_H
-EOF
-
-open HPP, "<$fileBase.cpp.h" or open HPP, "<$fileBase.hpp" or die;
-while (<HPP>) {
-    print HEADER;
+while (<INCLUDES>) {
+    print GRAMMAR;
 }
-close HPP;
 
-print HEADER "#endif\n";
-close HEADER;
+open GRAMMARFILE, "<$grammarFilePath" or die;
+while (<GRAMMARFILE>) {
+    print GRAMMAR;
+}
 
-unlink("$fileBase.cpp.h");
-unlink("$fileBase.hpp");
+close GRAMMAR;
 
+$grammarFilePath = $grammarFileOutPath;
diff --git a/Source/core/css/mathml.css b/Source/core/css/mathml.css
deleted file mode 100644
index 98bfe93..0000000
--- a/Source/core/css/mathml.css
+++ /dev/null
@@ -1,242 +0,0 @@
-@namespace "http://www.w3.org/1998/Math/MathML";
-
-math {
-    -webkit-line-box-contain: glyphs replaced;
-    line-height: 0;
-}
-mtext {
-    line-height: 1.0;
-}
-
-/* Keep font-family and other defaults here consistent with http://mxr.mozilla.org/mozilla-central/source/layout/mathml/mathml.css and feedback from www-math. */
-math, mfenced > * {
-    font-family: MathJax_Main, STIXGeneral, "DejaVu Serif", Cambria, "Cambria Math", Times, serif;
-}
-mo, mfenced {
-    font-family: MathJax_Main, STIXGeneral, STIXSizeOneSym, "DejaVu Sans", "DejaVu Serif", Cambria, "Cambria Math",
-        "Lucida Sans Unicode", "Arial Unicode MS", "Lucida Grande", OpenSymbol, "Standard Symbols L", sans-serif;
-}
-
-math {
-    display: -webkit-inline-flex !important;
-    padding-left: 1px;
-    padding-right: 1px;
-}
-
-math[display="block"] {
-    display: -webkit-flex !important;
-    -webkit-justify-content: center;
-    page-break-inside: avoid;
-    /* -webkit-margin-before: 1em; -- FIXME: Ask www-math for a default MathML stylesheet, including this (or margin-top). */
-    -webkit-margin-after: 1em;
-}
-
-mo, mrow, mfenced, mfrac, msub, msup, msubsup, munder, mover, munderover, msqrt, mroot {
-    display: -webkit-inline-flex !important;
-}
-
-msup {
-    -webkit-align-items: flex-start;
-}
-
-msub {
-    -webkit-align-items: flex-end;
-}
-
-math, mrow, mfenced, msqrt, mroot {
-    -webkit-align-items: baseline;
-}
-msqrt > * { /* This rule is needed because of <msqrt>'s anonymous <mrow>. */
-    -webkit-align-self: baseline;
-}
-
-mo, mfrac, munder, mover, munderover {
-    -webkit-flex-direction: column;
-}
-
-munder, mover, munderover {
-    -webkit-align-items: center;
-}
-
-mfrac > * {
-    -webkit-align-self: center;
-}
-mfrac[numalign="left"] > :first-child {
-    -webkit-align-self: flex-start;
-}
-mfrac[numalign="right"] > :first-child {
-    -webkit-align-self: flex-end;
-}
-mfrac[denomalign="left"] > :last-child {
-    -webkit-align-self: flex-start;
-}
-mfrac[denomalign="right"] > :last-child {
-    -webkit-align-self: flex-end;
-}
-mfrac > :first-child {
-    -webkit-margin-after: 0.2em;
-}
-mfrac > :last-child {
-    -webkit-margin-before: 0.2em;
-}
-mfrac {
-    -webkit-margin-start: 1px;
-    -webkit-margin-end: 1px;
-}
-
-msubsup > :last-child, mover > :last-child, munderover > :last-child {
-    -webkit-order: -1;
-}
-
-msub > * + *, msup > * + *, msubsup > * + *, munder > * + *, mover > * + *, munderover > * + * {
-    font-size: 0.75em; /* FIXME: MathML standard is 0.71em */
-}
-
-mi {
-    font-style: italic;
-    -webkit-padding-end: 0.1em;
-}
-msub > mi:first-child, msubsup > mi:first-child {
-    -webkit-padding-end: 0;
-}
-msubsup > mi:first-child + * + * {
-    -webkit-margin-start: 0.14em; /* This is larger than 0.1em because the child's font-size is smaller than the <msubsup>'s. */
-}
-
-/* FIXME: For a RenderMathMLOperator's margin-start and margin-end, or for a MathML "embellished operator", check the operator's lspace and rspace attributes,
-   and the MathML operator dictionary. */
-math > mo, mrow > mo, msqrt > mo, mtd > mo {
-    -webkit-margin-start: 0.2em;
-    -webkit-margin-end: 0.2em;
-}
-math > mo:first-child, mrow > mo:first-child, msqrt > mo:first-child, mtd > mo:first-child,
-math > mo:last-child, mrow > mo:last-child, msqrt > mo:last-child, mtd > mo:last-child {
-    -webkit-margin-start: 0.1em;
-    -webkit-margin-end: 0.1em;
-}
-
-mroot {
-    position: relative;
-}
-mroot > * + * {
-    font-size: 0.75em;
-    position: absolute;
-    left: 0;
-    top: 0;
-    padding-right: 0.4em;
-    padding-left: 0.2em;
-    padding-bottom: 0.35em;
-}
-
-math[mathvariant="normal"], mstyle[mathvariant="normal"], mo[mathvariant="normal"], mn[mathvariant="normal"], mi[mathvariant="normal"], mtext[mathvariant="normal"], mspace[mathvariant="normal"], ms[mathvariant="normal"] {
-    font-style: normal;
-    font-weight: normal;
-}
-
-math[mathvariant="bold"], mstyle[mathvariant="bold"], mo[mathvariant="bold"], mn[mathvariant="bold"], mi[mathvariant="bold"], mtext[mathvariant="bold"], mspace[mathvariant="bold"], ms[mathvariant="bold"] {
-    font-style: normal;
-    font-weight: bold;
-}
-
-math[mathvariant="italic"], mstyle[mathvariant="italic"], mo[mathvariant="italic"], mn[mathvariant="italic"], mi[mathvariant="italic"], mtext[mathvariant="italic"], mspace[mathvariant="italic"], ms[mathvariant="italic"] {
-    font-style: italic;
-    font-weight: normal;
-}
-
-math[mathvariant="bold-italic"], mstyle[mathvariant="bold-italic"], mo[mathvariant="bold-italic"], mn[mathvariant="bold-italic"], mi[mathvariant="bold-italic"], mtext[mathvariant="bold-italic"], mspace[mathvariant="bold-italic"], ms[mathvariant="bold-italic"] {
-    font-weight: bold;
-    font-style: italic;
-}
-
-math[mathsize="small"], mstyle[mathsize="small"], mo[mathsize="small"], mn[mathsize="small"], mi[mathsize="small"], mtext[mathsize="small"], mspace[mathsize="small"], ms[mathsize="small"] {
-    font-size: 0.75em;
-}
-
-math[mathsize="normal"], mstyle[mathsize="normal"], mo[mathsize="normal"], mn[mathsize="normal"], mi[mathsize="normal"], mtext[mathsize="normal"], mspace[mathsize="normal"], ms[mathsize="normal"] {
-    font-size: 1em;
-}
-
-math[mathsize="big"], mstyle[mathsize="big"], mo[mathsize="big"], mn[mathsize="big"], mi[mathsize="big"], mtext[mathsize="big"], mspace[mathsize="big"], ms[mathsize="big"] {
-    font-size: 1.5em;
-}
- 
-annotation, annotation-xml {
-    display: none;
-}
-
-mphantom {
-    visibility: hidden;
-}
-
-merror {
-    outline: solid thin red;
-    font-weight: bold;
-    font-family: sans-serif;
-    background-color: lightYellow;
-}
-
-mtable {
-    display: inline-table;
-    text-align: center;
-}
-
-mtr {
-    display: table-row;
-}
-
-mtd {
-    display: table-cell;
-    padding: 0.5ex;
-}
-
-mtable[columnalign="left"], mtr[columnalign="left"], mtd[columnalign="left"] {
-    text-align: left;
-}
-
-mtable[columnalign="right"], mtr[columnalign="right"], mtd[columnalign="right"] {
-    text-align: right;
-}
-
-mtable[rowalign="top"] mtd, mtable mtr[rowalign="top"] mtd, mtable mtr mtd[rowalign="top"] {
-    vertical-align: top;
-}
-
-mtable[rowalign="bottom"] mtd, mtable mtr[rowalign="bottom"] mtd, mtable mtr mtd[rowalign="bottom"] {
-    vertical-align: bottom;
-}
-
-mtable[rowalign="center"] mtd, mtable mtr[rowalign="center"] mtd, mtable mtr mtd[rowalign="center"] {
-    vertical-align: middle;
-}
-
-mtable[frame="solid"] {
-    border: solid thin;
-}
-
-mtable[frame="dashed"] {
-    border: dashed thin;
-}
-
-mtable[rowlines="solid"], mtable[rowlines="dashed"], mtable[columnlines="solid"], mtable[columnlines="dashed"] {
-    border-collapse: collapse;
-}
-
-mtable[rowlines="solid"] > mtr + mtr {
-    border-top: solid thin;
-}
-
-mtable[rowlines="dashed"] > mtr + mtr {
-    border-top: dashed thin;
-}
-
-mtable[columnlines="solid"] > mtr > mtd + mtd {
-    border-left: solid thin;
-}
-
-mtable[columnlines="dashed"] > mtr > mtd + mtd {
-    border-left: dashed thin;
-}
-
-mspace[linebreak="newline"] {
-    display: block;
-}
diff --git a/Source/core/css/resolver/ElementStyleResources.cpp b/Source/core/css/resolver/ElementStyleResources.cpp
index f99919a..ab9b0c3 100644
--- a/Source/core/css/resolver/ElementStyleResources.cpp
+++ b/Source/core/css/resolver/ElementStyleResources.cpp
@@ -38,14 +38,14 @@
 {
 }
 
-PassRefPtr<StyleImage> ElementStyleResources::styleImage(const TextLinkColors& textLinkColors, Color currentColor, CSSPropertyID property, CSSValue* value)
+PassRefPtr<StyleImage> ElementStyleResources::styleImage(const TextLinkColors& textLinkColors, CSSPropertyID property, CSSValue* value)
 {
     if (value->isImageValue())
         return cachedOrPendingFromValue(property, toCSSImageValue(value));
 
     if (value->isImageGeneratorValue()) {
         if (value->isGradientValue())
-            return generatedOrPendingFromValue(property, static_cast<CSSGradientValue*>(value)->gradientWithStylesResolved(textLinkColors, currentColor).get());
+            return generatedOrPendingFromValue(property, static_cast<CSSGradientValue*>(value)->gradientWithStylesResolved(textLinkColors).get());
         return generatedOrPendingFromValue(property, static_cast<CSSImageGeneratorValue*>(value));
     }
 
diff --git a/Source/core/css/resolver/ElementStyleResources.h b/Source/core/css/resolver/ElementStyleResources.h
index 08aaede..a296abb 100644
--- a/Source/core/css/resolver/ElementStyleResources.h
+++ b/Source/core/css/resolver/ElementStyleResources.h
@@ -53,7 +53,7 @@
 public:
     ElementStyleResources();
 
-    PassRefPtr<StyleImage> styleImage(const TextLinkColors&, Color currentColor, CSSPropertyID, CSSValue*);
+    PassRefPtr<StyleImage> styleImage(const TextLinkColors&, CSSPropertyID, CSSValue*);
 
     PassRefPtr<StyleImage> generatedOrPendingFromValue(CSSPropertyID, CSSImageGeneratorValue*);
     PassRefPtr<StyleImage> cachedOrPendingFromValue(CSSPropertyID, CSSImageValue*);
diff --git a/Source/core/css/resolver/FilterOperationResolver.cpp b/Source/core/css/resolver/FilterOperationResolver.cpp
index 9a155d9..5a80c3e 100644
--- a/Source/core/css/resolver/FilterOperationResolver.cpp
+++ b/Source/core/css/resolver/FilterOperationResolver.cpp
@@ -50,12 +50,11 @@
 
 namespace WebCore {
 
-static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
+static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
 {
     return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(style, rootStyle, multiplier) : Length(Undefined);
 }
 
-
 static FilterOperation::OperationType filterOperationForType(CSSFilterValue::FilterOperationType type)
 {
     switch (type) {
@@ -361,7 +360,7 @@
 }
 
 
-bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, FilterOperations& outOperations, StyleCustomFilterProgramCache* customFilterProgramCache, StyleResolverState& state)
+bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const RenderStyle* style, const RenderStyle* rootStyle, FilterOperations& outOperations, StyleCustomFilterProgramCache* customFilterProgramCache, StyleResolverState& state)
 {
     ASSERT(outOperations.isEmpty());
 
@@ -494,11 +493,11 @@
             ShadowValue* item = static_cast<ShadowValue*>(cssValue);
             IntPoint location(item->x->computeLength<int>(style, rootStyle, zoomFactor), item->y->computeLength<int>(style, rootStyle, zoomFactor));
             int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, zoomFactor) : 0;
-            Color color;
+            StyleColor shadowColor;
             if (item->color)
-                color = state.document()->textLinkColors().colorFromPrimitiveValue(item->color.get(), state.style()->visitedDependentColor(CSSPropertyColor));
+                shadowColor = state.document()->textLinkColors().colorFromPrimitiveValue(item->color.get());
 
-            operations.operations().append(DropShadowFilterOperation::create(location, blur, color.isValid() ? color : Color::transparent, operationType));
+            operations.operations().append(DropShadowFilterOperation::create(location, blur, shadowColor.isValid() ? shadowColor.color() : Color::transparent, operationType));
             break;
         }
         case CSSFilterValue::UnknownFilterOperation:
diff --git a/Source/core/css/resolver/FilterOperationResolver.h b/Source/core/css/resolver/FilterOperationResolver.h
index cd4d817..9b929bb 100644
--- a/Source/core/css/resolver/FilterOperationResolver.h
+++ b/Source/core/css/resolver/FilterOperationResolver.h
@@ -35,7 +35,7 @@
 private:
     FilterOperationResolver();
 public:
-    static bool createFilterOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, FilterOperations& outOperations, StyleCustomFilterProgramCache*, StyleResolverState&);
+    static bool createFilterOperations(CSSValue* inValue, const RenderStyle* inStyle, const RenderStyle* rootStyle, FilterOperations& outOperations, StyleCustomFilterProgramCache*, StyleResolverState&);
 };
 
 } // namespace WebCore
diff --git a/Source/core/css/resolver/MatchedPropertiesCache.cpp b/Source/core/css/resolver/MatchedPropertiesCache.cpp
index d39d131..1b0946d 100644
--- a/Source/core/css/resolver/MatchedPropertiesCache.cpp
+++ b/Source/core/css/resolver/MatchedPropertiesCache.cpp
@@ -125,8 +125,6 @@
         return false;
     if (style->writingMode() != RenderStyle::initialWritingMode())
         return false;
-    if (style->hasCurrentColor())
-        return false;
     // The cache assumes static knowledge about which properties are inherited.
     if (parentStyle->hasExplicitlyInheritedProperties())
         return false;
diff --git a/Source/core/css/resolver/ScopedStyleResolver.cpp b/Source/core/css/resolver/ScopedStyleResolver.cpp
index 40a437a..6a1b9f1 100644
--- a/Source/core/css/resolver/ScopedStyleResolver.cpp
+++ b/Source/core/css/resolver/ScopedStyleResolver.cpp
@@ -305,7 +305,7 @@
     return false;
 }
 
-const StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(const AtomicStringImpl* animationName)
+const StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(const StringImpl* animationName)
 {
     if (m_keyframesRuleMap.isEmpty())
         return 0;
@@ -349,7 +349,7 @@
     // by using the flag.
     ShadowRoot* shadowRoot = shadow->youngestShadowRoot();
     for (; shadowRoot; shadowRoot = shadowRoot->olderShadowRoot())
-        if (!ScopeContentDistribution::hasShadowElement(shadowRoot))
+        if (!shadowRoot->containsShadowElements())
             break;
     // All shadow roots have <shadow>.
     if (!shadowRoot)
diff --git a/Source/core/css/resolver/ScopedStyleResolver.h b/Source/core/css/resolver/ScopedStyleResolver.h
index 57d503e..f63034d 100644
--- a/Source/core/css/resolver/ScopedStyleResolver.h
+++ b/Source/core/css/resolver/ScopedStyleResolver.h
@@ -63,7 +63,7 @@
 
 public:
     bool checkRegionStyle(Element*);
-    const StyleRuleKeyframes* keyframeStylesForAnimation(const AtomicStringImpl* animationName);
+    const StyleRuleKeyframes* keyframeStylesForAnimation(const StringImpl* animationName);
     void addKeyframeStyle(PassRefPtr<StyleRuleKeyframes>);
 
     void matchHostRules(ElementRuleCollector&, bool includeEmptyRules);
@@ -89,7 +89,7 @@
     OwnPtr<RuleSet> m_authorStyle;
     HashMap<const ShadowRoot*, OwnPtr<RuleSet> > m_atHostRules;
 
-    typedef HashMap<const AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
+    typedef HashMap<const StringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
     KeyframesRuleMap m_keyframesRuleMap;
 };
 
diff --git a/Source/core/css/resolver/SharedStyleFinder.cpp b/Source/core/css/resolver/SharedStyleFinder.cpp
index 074596b..6b11c4b 100644
--- a/Source/core/css/resolver/SharedStyleFinder.cpp
+++ b/Source/core/css/resolver/SharedStyleFinder.cpp
@@ -31,7 +31,6 @@
 
 #include "HTMLNames.h"
 #include "XMLNames.h"
-#include "core/css/RuleFeature.h"
 #include "core/css/resolver/StyleResolver.h"
 #include "core/css/resolver/StyleResolverState.h"
 #include "core/dom/ContainerNode.h"
@@ -319,7 +318,7 @@
 }
 #endif
 
-RenderStyle* SharedStyleFinder::locateSharedStyle(const ElementResolveContext& context)
+RenderStyle* SharedStyleFinder::locateSharedStyle(const ElementResolveContext& context, RenderStyle* newStyle)
 {
     STYLE_STATS_ADD_SEARCH();
     if (!context.element() || !context.element()->isStyledElement())
@@ -394,10 +393,10 @@
         return 0;
 
     // Can't share if sibling rules apply. This is checked at the end as it should rarely fail.
-    if (m_styleResolver->styleSharingCandidateMatchesRuleSet(context, m_siblingRuleSet))
+    if (m_styleResolver->styleSharingCandidateMatchesRuleSet(context, newStyle, m_siblingRuleSet))
         return 0;
     // Can't share if attribute rules apply.
-    if (m_styleResolver->styleSharingCandidateMatchesRuleSet(context, m_uncommonAttributeRuleSet))
+    if (m_styleResolver->styleSharingCandidateMatchesRuleSet(context, newStyle, m_uncommonAttributeRuleSet))
         return 0;
     // Tracking child index requires unique style for each node. This may get set by the sibling rule match above.
     if (parentElementPreventsSharing(context.element()->parentElement()))
diff --git a/Source/core/css/resolver/SharedStyleFinder.h b/Source/core/css/resolver/SharedStyleFinder.h
index 590cac4..7734c36 100644
--- a/Source/core/css/resolver/SharedStyleFinder.h
+++ b/Source/core/css/resolver/SharedStyleFinder.h
@@ -48,7 +48,7 @@
     { }
 
     // FIXME: It is not necessarily safe to call this method more than once.
-    RenderStyle* locateSharedStyle(const ElementResolveContext&);
+    RenderStyle* locateSharedStyle(const ElementResolveContext&, RenderStyle* newStyle);
 
 private:
     Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const;
diff --git a/Source/core/css/resolver/StyleBuilderCustom.cpp b/Source/core/css/resolver/StyleBuilderCustom.cpp
index c05f8a1..26562a9 100644
--- a/Source/core/css/resolver/StyleBuilderCustom.cpp
+++ b/Source/core/css/resolver/StyleBuilderCustom.cpp
@@ -1009,11 +1009,11 @@
     return true;
 }
 
-static Color colorFromSVGColorCSSValue(SVGColor* svgColor, const Color& fgColor)
+static Color colorFromSVGColorCSSValue(SVGColor* svgColor, const StyleColor& fgColor)
 {
     Color color;
     if (svgColor->colorType() == SVGColor::SVG_COLORTYPE_CURRENTCOLOR)
-        color = fgColor;
+        color = fgColor.color();
     else
         color = svgColor->color();
     return color;
@@ -1079,7 +1079,7 @@
                 CSSValue* item = i.value();
                 if (item->isImageGeneratorValue()) {
                     if (item->isGradientValue())
-                        state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(state.document()->textLinkColors(), state.style()->color()).get()), didSet);
+                        state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(state.document()->textLinkColors()).get()), didSet);
                     else
                         state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet);
                     didSet = true;
@@ -1259,9 +1259,9 @@
             int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0;
             int spread = item->spread ? item->spread->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0;
             ShadowStyle shadowStyle = item->style && item->style->getValueID() == CSSValueInset ? Inset : Normal;
-            Color color;
+            StyleColor color;
             if (item->color)
-                color = state.document()->textLinkColors().colorFromPrimitiveValue(item->color.get(), state.style()->visitedDependentColor(CSSPropertyColor));
+                color = state.document()->textLinkColors().colorFromPrimitiveValue(item->color.get());
             else if (state.style())
                 color = state.style()->color();
 
@@ -1379,7 +1379,7 @@
         if (!primitiveValue)
             break;
 
-        Color col = state.document()->textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->visitedDependentColor(CSSPropertyColor));
+        StyleColor col = state.document()->textLinkColors().colorFromPrimitiveValue(primitiveValue);
         state.style()->setTapHighlightColor(col);
         return;
     }
@@ -1419,7 +1419,7 @@
     {
         CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode());
         ASSERT(newId != id);
-        return styleResolver->applyProperty(newId, value);
+        return styleResolver->applyProperty(state, newId, value);
     }
     case CSSPropertyFontStretch:
     case CSSPropertyPage:
@@ -2190,9 +2190,9 @@
         IntPoint location(item->x->computeLength<int>(state.style(), state.rootElementStyle()),
             item->y->computeLength<int>(state.style(), state.rootElementStyle()));
         int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle()) : 0;
-        Color color;
+        StyleColor color;
         if (item->color)
-            color = state.document()->textLinkColors().colorFromPrimitiveValue(item->color.get(), state.style()->visitedDependentColor(CSSPropertyColor));
+            color = state.document()->textLinkColors().colorFromPrimitiveValue(item->color.get());
 
         // -webkit-svg-shadow does should not have a spread or style
         ASSERT(!item->spread);
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index e27626d..d72f3c0 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -35,6 +35,7 @@
 #include "StylePropertyShorthand.h"
 #include "core/animation/AnimatableValue.h"
 #include "core/animation/Animation.h"
+#include "core/animation/DocumentTimeline.h"
 #include "core/css/CSSCalculationValue.h"
 #include "core/css/CSSDefaultStyleSheets.h"
 #include "core/css/CSSFontSelector.h"
@@ -105,7 +106,6 @@
     , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles)
     , m_fontSelector(CSSFontSelector::create(document))
     , m_viewportStyleResolver(ViewportStyleResolver::create(document))
-    , m_state(0)
     , m_styleResourceLoader(document->cachedResourceLoader())
 {
     Element* root = document->documentElement();
@@ -312,14 +312,14 @@
     collector.setCanUseFastReject(previousCanUseFastReject);
 }
 
-void StyleResolver::matchHostRules(ScopedStyleResolver* resolver, ElementRuleCollector& collector, bool includeEmptyRules)
+void StyleResolver::matchHostRules(Element* element, ScopedStyleResolver* resolver, ElementRuleCollector& collector, bool includeEmptyRules)
 {
-    if (m_state->element() != resolver->scopingNode())
+    if (element != resolver->scopingNode())
         return;
     resolver->matchHostRules(collector, includeEmptyRules);
 }
 
-void StyleResolver::matchScopedAuthorRules(ElementRuleCollector& collector, bool includeEmptyRules)
+void StyleResolver::matchScopedAuthorRules(Element* element, ElementRuleCollector& collector, bool includeEmptyRules)
 {
     // fast path
     if (m_styleTree.hasOnlyScopedResolverForDocument()) {
@@ -328,20 +328,20 @@
     }
 
     Vector<ScopedStyleResolver*, 8> stack;
-    m_styleTree.resolveScopedStyles(m_state->element(), stack);
+    m_styleTree.resolveScopedStyles(element, stack);
     if (stack.isEmpty())
         return;
 
-    bool applyAuthorStyles = m_state->element()->treeScope()->applyAuthorStyles();
+    bool applyAuthorStyles = element->treeScope()->applyAuthorStyles();
     for (int i = stack.size() - 1; i >= 0; --i)
         stack.at(i)->matchAuthorRules(collector, includeEmptyRules, applyAuthorStyles);
 
-    matchHostRules(stack.first(), collector, includeEmptyRules);
+    matchHostRules(element, stack.first(), collector, includeEmptyRules);
 }
 
-void StyleResolver::matchAuthorRules(ElementRuleCollector& collector, bool includeEmptyRules)
+void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& collector, bool includeEmptyRules)
 {
-    matchScopedAuthorRules(collector, includeEmptyRules);
+    matchScopedAuthorRules(element, collector, includeEmptyRules);
     matchShadowDistributedRules(collector, includeEmptyRules);
 }
 
@@ -395,7 +395,7 @@
     collector.sortAndTransferMatchedRules();
 }
 
-void StyleResolver::matchAllRules(ElementRuleCollector& collector, bool matchAuthorAndUserStyles, bool includeSMILProperties)
+void StyleResolver::matchAllRules(StyleResolverState& state, ElementRuleCollector& collector, bool matchAuthorAndUserStyles, bool includeSMILProperties)
 {
     matchUARules(collector);
 
@@ -404,17 +404,17 @@
         matchUserRules(collector, false);
 
     // Now check author rules, beginning first with presentational attributes mapped from HTML.
-    if (m_state->element()->isStyledElement()) {
-        collector.addElementStyleProperties(m_state->element()->presentationAttributeStyle());
+    if (state.element()->isStyledElement()) {
+        collector.addElementStyleProperties(state.element()->presentationAttributeStyle());
 
         // Now we check additional mapped declarations.
         // Tables and table cells share an additional mapped rule that must be applied
         // after all attributes, since their mapped style depends on the values of multiple attributes.
-        collector.addElementStyleProperties(m_state->element()->additionalPresentationAttributeStyle());
+        collector.addElementStyleProperties(state.element()->additionalPresentationAttributeStyle());
 
-        if (m_state->element()->isHTMLElement()) {
+        if (state.element()->isHTMLElement()) {
             bool isAuto;
-            TextDirection textDirection = toHTMLElement(m_state->element())->directionalityIfhasDirAutoAttribute(isAuto);
+            TextDirection textDirection = toHTMLElement(state.element())->directionalityIfhasDirAutoAttribute(isAuto);
             if (isAuto)
                 collector.matchedResult().addMatchedProperties(textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration());
         }
@@ -422,33 +422,33 @@
 
     // Check the rules in author sheets next.
     if (matchAuthorAndUserStyles)
-        matchAuthorRules(collector, false);
+        matchAuthorRules(state.element(), collector, false);
 
-    if (m_state->element()->isStyledElement()) {
+    if (state.element()->isStyledElement()) {
         // Now check our inline style attribute.
-        if (matchAuthorAndUserStyles && m_state->element()->inlineStyle()) {
+        if (matchAuthorAndUserStyles && state.element()->inlineStyle()) {
             // Inline style is immutable as long as there is no CSSOM wrapper.
             // FIXME: Media control shadow trees seem to have problems with caching.
-            bool isInlineStyleCacheable = !m_state->element()->inlineStyle()->isMutable() && !m_state->element()->isInShadowTree();
+            bool isInlineStyleCacheable = !state.element()->inlineStyle()->isMutable() && !state.element()->isInShadowTree();
             // FIXME: Constify.
-            collector.addElementStyleProperties(m_state->element()->inlineStyle(), isInlineStyleCacheable);
+            collector.addElementStyleProperties(state.element()->inlineStyle(), isInlineStyleCacheable);
         }
 
         // Now check SMIL animation override style.
-        if (includeSMILProperties && matchAuthorAndUserStyles && m_state->element()->isSVGElement())
-            collector.addElementStyleProperties(toSVGElement(m_state->element())->animatedSMILStyleProperties(), false /* isCacheable */);
+        if (includeSMILProperties && matchAuthorAndUserStyles && state.element()->isSVGElement())
+            collector.addElementStyleProperties(toSVGElement(state.element())->animatedSMILStyleProperties(), false /* isCacheable */);
 
-        if (m_state->element()->hasActiveAnimations())
+        if (state.element()->hasActiveAnimations())
             collector.matchedResult().isCacheable = false;
     }
 }
 
-bool StyleResolver::styleSharingCandidateMatchesRuleSet(const ElementResolveContext& context, RuleSet* ruleSet)
+bool StyleResolver::styleSharingCandidateMatchesRuleSet(const ElementResolveContext& context, RenderStyle* style, RuleSet* ruleSet)
 {
     if (!ruleSet)
         return false;
 
-    ElementRuleCollector collector(context, m_selectorFilter, m_state->style(), m_inspectorCSSOMWrappers);
+    ElementRuleCollector collector(context, m_selectorFilter, style, m_inspectorCSSOMWrappers);
     return collector.hasAnyMatchingRules(ruleSet);
 }
 
@@ -557,11 +557,11 @@
 
     if (element == document()->documentElement())
         resetDirectionAndWritingModeOnDocument(document());
-    StyleResolverState state(&m_state, document(), element, defaultParent, regionForStyling);
+    StyleResolverState state(document(), element, defaultParent, regionForStyling);
 
     if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint() && state.parentStyle()) {
         SharedStyleFinder styleFinder(m_features, m_siblingRuleSet.get(), m_uncommonAttributeRuleSet.get(), this);
-        RefPtr<RenderStyle> sharedStyle = styleFinder.locateSharedStyle(state.elementContext());
+        RefPtr<RenderStyle> sharedStyle = styleFinder.locateSharedStyle(state.elementContext(), state.style());
         if (sharedStyle)
             return sharedStyle.release();
     }
@@ -609,12 +609,12 @@
         if (matchingBehavior == MatchOnlyUserAgentRules)
             matchUARules(collector);
         else
-            matchAllRules(collector, m_matchAuthorAndUserStyles, matchingBehavior != MatchAllRulesExcludingSMIL);
+            matchAllRules(state, collector, m_matchAuthorAndUserStyles, matchingBehavior != MatchAllRulesExcludingSMIL);
 
-        applyMatchedProperties(collector.matchedResult(), element);
+        applyMatchedProperties(state, collector.matchedResult(), element);
     }
     {
-        StyleAdjuster adjuster(m_state->cachedUAStyle(), m_document->inQuirksMode());
+        StyleAdjuster adjuster(state.cachedUAStyle(), m_document->inQuirksMode());
         adjuster.adjustRenderStyle(state.style(), state.parentStyle(), element);
     }
     document()->didAccessStyleResolver();
@@ -634,7 +634,7 @@
 
     if (e == document()->documentElement())
         resetDirectionAndWritingModeOnDocument(document());
-    StyleResolverState state(&m_state, document(), e);
+    StyleResolverState state(document(), e);
 
     MatchResult result;
     if (keyframe->properties())
@@ -653,24 +653,24 @@
     bool inheritedOnly = false;
     if (keyframe->properties()) {
         // FIXME: Can't keyframes contain variables?
-        applyMatchedProperties<AnimationProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
-        applyMatchedProperties<HighPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
+        applyMatchedProperties<AnimationProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
+        applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
     }
 
     // If our font got dirtied, go ahead and update it now.
-    updateFont();
+    updateFont(state);
 
     // Line-height is set when we are sure we decided on the font-size
     if (state.lineHeightValue())
-        applyProperty(CSSPropertyLineHeight, state.lineHeightValue());
+        applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue());
 
     // Now do rest of the properties.
     if (keyframe->properties())
-        applyMatchedProperties<LowPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
+        applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
 
     // If our font got dirtied by one of the non-essential font props,
     // go ahead and update it a second time.
-    updateFont();
+    updateFont(state);
 
     // Start loading resources referenced by this style.
     m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyleResources());
@@ -692,7 +692,7 @@
     return state.takeStyle();
 }
 
-const StyleRuleKeyframes* StyleResolver::matchScopedKeyframesRule(Element* e, const AtomicStringImpl* animationName)
+const StyleRuleKeyframes* StyleResolver::matchScopedKeyframesRule(Element* e, const StringImpl* animationName)
 {
     if (m_styleTree.hasOnlyScopedResolverForDocument())
         return m_styleTree.scopedStyleResolverForDocument()->keyframeStylesForAnimation(animationName);
@@ -775,7 +775,7 @@
 
     if (e == document()->documentElement())
         resetDirectionAndWritingModeOnDocument(document());
-    StyleResolverState state(&m_state, document(), e, parentStyle);
+    StyleResolverState state(document(), e, parentStyle);
 
     if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
         state.setStyle(RenderStyle::create());
@@ -798,7 +798,7 @@
         matchUARules(collector);
         if (m_matchAuthorAndUserStyles) {
             matchUserRules(collector, false);
-            matchAuthorRules(collector, false);
+            matchAuthorRules(state.element(), collector, false);
         }
 
         if (collector.matchedResult().matchedProperties.isEmpty())
@@ -806,10 +806,10 @@
 
         state.style()->setStyleType(pseudoStyleRequest.pseudoId);
 
-        applyMatchedProperties(collector.matchedResult(), e);
+        applyMatchedProperties(state, collector.matchedResult(), e);
     }
     {
-        StyleAdjuster adjuster(m_state->cachedUAStyle(), m_document->inQuirksMode());
+        StyleAdjuster adjuster(state.cachedUAStyle(), m_document->inQuirksMode());
         // FIXME: Passing 0 as the Element* introduces a lot of complexity
         // in the adjustRenderStyle code.
         adjuster.adjustRenderStyle(state.style(), state.parentStyle(), 0);
@@ -827,7 +827,7 @@
 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
 {
     resetDirectionAndWritingModeOnDocument(document());
-    StyleResolverState state(&m_state, document(), document()->documentElement()); // m_rootElementStyle will be set to the document style.
+    StyleResolverState state(document(), document()->documentElement()); // m_rootElementStyle will be set to the document style.
 
     state.setStyle(RenderStyle::create());
     state.style()->inheritFrom(state.rootElementStyle());
@@ -846,17 +846,17 @@
     bool inheritedOnly = false;
 
     MatchResult& result = collector.matchedResult();
-    applyMatchedProperties<VariableDefinitions>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
-    applyMatchedProperties<HighPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
+    applyMatchedProperties<VariableDefinitions>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
+    applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
 
     // If our font got dirtied, go ahead and update it now.
-    updateFont();
+    updateFont(state);
 
     // Line-height is set when we are sure we decided on the font-size.
     if (state.lineHeightValue())
-        applyProperty(CSSPropertyLineHeight, state.lineHeightValue());
+        applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue());
 
-    applyMatchedProperties<LowPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
+    applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
 
     // Start loading resources referenced by this style.
     m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyleResources());
@@ -894,7 +894,7 @@
 
 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
 {
-    StyleResolverState state(0, document(), 0);
+    StyleResolverState state(document(), 0);
     state.setStyle(RenderStyle::create());
     state.fontBuilder().initForStyleResolve(document(), state.style(), state.useSVGZoomRules());
     state.style()->setLineHeight(RenderStyle::initialLineHeight());
@@ -935,9 +935,9 @@
     return false;
 }
 
-void StyleResolver::updateFont()
+void StyleResolver::updateFont(StyleResolverState& state)
 {
-    m_state->fontBuilder().createFont(m_fontSelector, m_state->parentStyle(), m_state->style());
+    state.fontBuilder().createFont(m_fontSelector, state.parentStyle(), state.style());
 }
 
 PassRefPtr<CSSRuleList> StyleResolver::styleRulesForElement(Element* e, unsigned rulesToInclude)
@@ -952,9 +952,9 @@
 
     if (e == document()->documentElement())
         resetDirectionAndWritingModeOnDocument(document());
-    StyleResolverState state(&m_state, document(), e);
+    StyleResolverState state(document(), e);
 
-    ElementRuleCollector collector(m_state->elementContext(), m_selectorFilter, m_state->style(), m_inspectorCSSOMWrappers);
+    ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style(), m_inspectorCSSOMWrappers);
     collector.setMode(SelectorChecker::CollectingRules);
     collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId));
 
@@ -971,7 +971,7 @@
         collector.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules));
 
         // Check the rules in author sheets.
-        matchAuthorRules(collector, rulesToInclude & EmptyCSSRules);
+        matchAuthorRules(state.element(), collector, rulesToInclude & EmptyCSSRules);
     }
 
     return collector.matchedRuleList();
@@ -981,17 +981,17 @@
 // this is mostly boring stuff on how to apply a certain rule to the renderstyle...
 
 template <StyleResolver::StyleApplicationPass pass>
-void StyleResolver::applyAnimatedProperties(const Element* target)
+void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Element* target, const DocumentTimeline* timeline)
 {
     ASSERT(pass != VariableDefinitions);
     ASSERT(pass != AnimationProperties);
-    if (!target->hasActiveAnimations())
+    AnimationStack* animationStack = timeline->animationStack(target);
+    if (!animationStack)
         return;
+    const Vector<Animation*>& animations = animationStack->activeAnimations(target);
 
-    Vector<Animation*>* animations = target->activeAnimations();
-
-    for (size_t i = 0; i < animations->size(); ++i) {
-        RefPtr<Animation> animation = animations->at(i);
+    for (size_t i = 0; i < animations.size(); ++i) {
+        RefPtr<Animation> animation = animations.at(i);
         const AnimationEffect::CompositableValueMap* compositableValues = animation->compositableValues();
         for (AnimationEffect::CompositableValueMap::const_iterator iter = compositableValues->begin(); iter != compositableValues->end(); ++iter) {
             CSSPropertyID property = iter->key;
@@ -999,9 +999,9 @@
                 continue;
             RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue::neutralValue())->toCSSValue();
             if (pass == HighPriorityProperties && property == CSSPropertyLineHeight)
-                m_state->setLineHeightValue(value.get());
+                state.setLineHeightValue(value.get());
             else
-                applyProperty(property, value.get());
+                applyProperty(state, property, value.get());
         }
     }
 }
@@ -1121,9 +1121,9 @@
 }
 
 template <StyleResolver::StyleApplicationPass pass>
-void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
+void StyleResolver::applyProperties(StyleResolverState& state, const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
 {
-    ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state->regionForStyling());
+    ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || state.regionForStyling());
     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule, this);
 
     unsigned propertyCount = properties->propertyCount();
@@ -1147,20 +1147,19 @@
         if (!isPropertyForPass<pass>(property))
             continue;
         if (pass == HighPriorityProperties && property == CSSPropertyLineHeight)
-            m_state->setLineHeightValue(current.value());
+            state.setLineHeightValue(current.value());
         else
-            applyProperty(current.id(), current.value());
+            applyProperty(state, current.id(), current.value());
     }
     InspectorInstrumentation::didProcessRule(cookie);
 }
 
 template <StyleResolver::StyleApplicationPass pass>
-void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly)
+void StyleResolver::applyMatchedProperties(StyleResolverState& state, const MatchResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly)
 {
     if (startIndex == -1)
         return;
 
-    StyleResolverState& state = *m_state;
     if (state.style()->insideLink() != NotInsideLink) {
         for (int i = startIndex; i <= endIndex; ++i) {
             const MatchedProperties& matchedProperties = matchResult.matchedProperties[i];
@@ -1169,7 +1168,7 @@
             state.setApplyPropertyToRegularStyle(linkMatchType & SelectorChecker::MatchLink);
             state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChecker::MatchVisited);
 
-            applyProperties<pass>(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType));
+            applyProperties<pass>(state, matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType));
         }
         state.setApplyPropertyToRegularStyle(true);
         state.setApplyPropertyToVisitedLinkStyle(false);
@@ -1177,7 +1176,7 @@
     }
     for (int i = startIndex; i <= endIndex; ++i) {
         const MatchedProperties& matchedProperties = matchResult.matchedProperties[i];
-        applyProperties<pass>(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType));
+        applyProperties<pass>(state, matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType));
     }
 }
 
@@ -1191,19 +1190,24 @@
     m_matchedPropertiesCache.clear();
 }
 
-void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element* element)
+void StyleResolver::applyMatchedProperties(StyleResolverState& state, const MatchResult& matchResult, const Element* element)
 {
     ASSERT(element);
-    StyleResolverState& state = *m_state;
+    STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH();
+
     unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
     bool applyInheritedOnly = false;
     const CachedMatchedProperties* cachedMatchedProperties = 0;
-    if (cacheHash && (cachedMatchedProperties = m_matchedPropertiesCache.find(cacheHash, *m_state, matchResult))) {
+
+    if (cacheHash && (cachedMatchedProperties = m_matchedPropertiesCache.find(cacheHash, state, matchResult))) {
+        STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT();
         // We can build up the style by copying non-inherited properties from an earlier style object built using the same exact
         // style declarations. We then only need to apply the inherited properties, if any, as their values can depend on the
         // element context. This is fast and saves memory by reusing the style data structures.
         state.style()->copyNonInheritedFrom(cachedMatchedProperties->renderStyle.get());
         if (state.parentStyle()->inheritedDataShared(cachedMatchedProperties->parentRenderStyle.get()) && !isAtShadowBoundary(element)) {
+            STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT_SHARED_INHERITED();
+
             EInsideLink linkStatus = state.style()->insideLink();
             // If the cache item parent style has identical inherited properties to the current parent style then the
             // resulting style will be identical too. We copy the inherited properties over from the cache and are done.
@@ -1217,16 +1221,16 @@
     }
 
     // First apply all variable definitions, as they may be used during application of later properties.
-    applyMatchedProperties<VariableDefinitions>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
-    applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
-    applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
-    applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
+    applyMatchedProperties<VariableDefinitions>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
+    applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
+    applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
+    applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
 
     // Apply animation properties in order to apply animation results and trigger transitions below.
-    applyMatchedProperties<AnimationProperties>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
-    applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
-    applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
-    applyMatchedProperties<AnimationProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
+    applyMatchedProperties<AnimationProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
+    applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
+    applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
+    applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
     // FIXME: animations should be triggered here
 
     // Now we have all of the matched rules in the appropriate order. Walk the rules and apply
@@ -1234,13 +1238,13 @@
     // The order is (1) high-priority not important, (2) high-priority important, (3) normal not important
     // and (4) normal important.
     state.setLineHeightValue(0);
-    applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
+    applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
     // Animation contributions are processed here because CSS Animations are overridable by user !important rules.
     if (RuntimeEnabledFeatures::webAnimationsEnabled())
-        applyAnimatedProperties<HighPriorityProperties>(element);
-    applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
-    applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
-    applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
+        applyAnimatedProperties<HighPriorityProperties>(state, element, element->document()->timeline());
+    applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
+    applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
+    applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
 
     if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effectiveZoom() != state.style()->effectiveZoom()) {
         state.fontBuilder().setFontDirty(true);
@@ -1248,39 +1252,45 @@
     }
 
     // If our font got dirtied, go ahead and update it now.
-    updateFont();
+    updateFont(state);
 
     // Line-height is set when we are sure we decided on the font-size.
     if (state.lineHeightValue())
-        applyProperty(CSSPropertyLineHeight, state.lineHeightValue());
+        applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue());
 
     // Many properties depend on the font. If it changes we just apply all properties.
     if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDescription() != state.style()->fontDescription())
         applyInheritedOnly = false;
 
     // Now do the normal priority UA properties.
-    applyMatchedProperties<LowPriorityProperties>(matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
+    applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
 
     // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle.
     state.cacheUserAgentBorderAndBackground();
 
     // Now do the author and user normal priority properties and all the !important properties.
-    applyMatchedProperties<LowPriorityProperties>(matchResult, false, matchResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
+    applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, matchResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
     if (RuntimeEnabledFeatures::webAnimationsEnabled())
-        applyAnimatedProperties<LowPriorityProperties>(element);
-    applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
-    applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
-    applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
+        applyAnimatedProperties<LowPriorityProperties>(state, element, element->document()->timeline());
+    applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
+    applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
+    applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
 
     // Start loading resources referenced by this style.
     m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyleResources());
 
     ASSERT(!state.fontBuilder().fontDirty());
 
+#ifdef STYLE_STATS
+    if (!cachedMatchedProperties)
+        STYLE_STATS_ADD_MATCHED_PROPERTIES_TO_CACHE();
+#endif
+
     if (cachedMatchedProperties || !cacheHash)
         return;
     if (!MatchedPropertiesCache::isCacheable(state.element(), state.style(), state.parentStyle()))
         return;
+    STYLE_STATS_ADD_MATCHED_PROPERTIES_ENTERED_INTO_CACHE();
     m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHash, matchResult);
 }
 
@@ -1290,7 +1300,7 @@
 
 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count, RenderStyle* style)
 {
-    StyleResolverState state(&m_state, document(), 0, style);
+    StyleResolverState state(document(), 0, style);
     state.setStyle(style);
 
     state.fontBuilder().initForStyleResolve(document(), style, state.useSVGZoomRules());
@@ -1303,12 +1313,12 @@
             switch (properties[i].property) {
             case CSSPropertyFontSize:
             case CSSPropertyLineHeight:
-                updateFont();
+                updateFont(state);
                 break;
             default:
                 break;
             }
-            applyProperty(properties[i].property, properties[i].value);
+            applyProperty(state, properties[i].property, properties[i].value);
         }
     }
 }
@@ -1339,9 +1349,9 @@
     return false;
 }
 
-void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions)
+void StyleResolver::resolveVariables(StyleResolverState& state, CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions)
 {
-    std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*m_state->style()->variables()));
+    std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*state.style()->variables()));
 
     if (knownExpressions.contains(expression))
         return; // cycle detected.
@@ -1356,27 +1366,26 @@
     for (unsigned i = 0; i < resultSet->propertyCount(); i++) {
         StylePropertySet::PropertyReference property = resultSet->propertyAt(i);
         if (property.id() != CSSPropertyVariable && hasVariableReference(property.value())) {
-            resolveVariables(property.id(), property.value(), knownExpressions);
+            resolveVariables(state, property.id(), property.value(), knownExpressions);
         } else {
-            applyProperty(property.id(), property.value());
+            applyProperty(state, property.id(), property.value());
             // All properties become dependent on their parent style when they use variables.
-            m_state->style()->setHasExplicitlyInheritedProperties();
+            state.style()->setHasExplicitlyInheritedProperties();
         }
     }
 }
 
-void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
+void StyleResolver::applyProperty(StyleResolverState& state, CSSPropertyID id, CSSValue* value)
 {
     if (id != CSSPropertyVariable && hasVariableReference(value)) {
         Vector<std::pair<CSSPropertyID, String> > knownExpressions;
-        resolveVariables(id, value, knownExpressions);
+        resolveVariables(state, id, value, knownExpressions);
         return;
     }
 
     // CSS variables don't resolve shorthands at parsing time, so this should be *after* handling variables.
     ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wasn't expanded at parsing time", id);
 
-    StyleResolverState& state = *m_state;
     bool isInherit = state.parentNode() && value->isInheritedValue();
     bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue());
 
@@ -1388,10 +1397,6 @@
         return;
     }
 
-    CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value) : 0;
-    if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor)
-        state.style()->setHasCurrentColor();
-
     if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
         state.parentStyle()->setHasExplicitlyInheritedProperties();
 
@@ -1429,26 +1434,34 @@
 #ifdef STYLE_STATS
 StyleSharingStats StyleResolver::m_styleSharingStats;
 
-static void printStyleStats(unsigned searches, unsigned elementsEligibleForSharing, unsigned stylesShared, unsigned searchFoundSiblingForSharing, unsigned searchesMissedSharing)
+static void printStyleStats(unsigned searches, unsigned elementsEligibleForSharing, unsigned stylesShared, unsigned searchFoundSiblingForSharing, unsigned searchesMissedSharing,
+    unsigned matchedPropertiesSearches, unsigned matchedPropertiesHit, unsigned matchedPropertiesSharedInheritedHit, unsigned matchedPropertiesToCache, unsigned matchedPropertiesEnteredIntoCache)
 {
     double percentOfElementsSharingStyle = (stylesShared * 100.0) / searches;
     double percentOfNodesEligibleForSharing = (elementsEligibleForSharing * 100.0) / searches;
     double percentOfEligibleSharingRelativesFound = (searchFoundSiblingForSharing * 100.0) / searches;
+    double percentOfMatchedPropertiesHit = (matchedPropertiesHit * 100.0) / matchedPropertiesSearches;
+    double percentOfMatchedPropertiesSharedInheritedHit = (matchedPropertiesSharedInheritedHit * 100.0) / matchedPropertiesSearches;
+    double percentOfMatchedPropertiesEnteredIntoCache = (matchedPropertiesEnteredIntoCache * 100.0) / matchedPropertiesToCache;
 
     fprintf(stderr, "%u elements checked, %u were eligible for style sharing (%.2f%%).\n", searches, elementsEligibleForSharing, percentOfNodesEligibleForSharing);
     fprintf(stderr, "%u elements were found to share with, %u were possible (%.2f%%).\n", searchFoundSiblingForSharing, searchesMissedSharing + searchFoundSiblingForSharing, percentOfEligibleSharingRelativesFound);
     fprintf(stderr, "%u styles were actually shared once sibling and attribute rules were considered (%.2f%%).\n", stylesShared, percentOfElementsSharingStyle);
-
+    fprintf(stderr, "%u/%u (%.2f%%) matched property lookups hit the cache.\n", matchedPropertiesHit, matchedPropertiesSearches, percentOfMatchedPropertiesHit);
+    fprintf(stderr, "%u/%u (%.2f%%) matched property lookups hit the cache and shared inherited data.\n", matchedPropertiesSharedInheritedHit, matchedPropertiesSearches, percentOfMatchedPropertiesSharedInheritedHit);
+    fprintf(stderr, "%u/%u (%.2f%%) matched properties were cacheable\n", matchedPropertiesEnteredIntoCache, matchedPropertiesToCache, percentOfMatchedPropertiesEnteredIntoCache);
 }
 
 void StyleSharingStats::printStats() const
 {
     fprintf(stderr, "--------------------------------------------------------------------------------\n");
     fprintf(stderr, "This recalc style:\n");
-    printStyleStats(m_searches, m_elementsEligibleForSharing, m_stylesShared, m_searchFoundSiblingForSharing, m_searchesMissedSharing);
+    printStyleStats(m_searches, m_elementsEligibleForSharing, m_stylesShared, m_searchFoundSiblingForSharing, m_searchesMissedSharing,
+        m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedPropertiesSharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCache);
 
     fprintf(stderr, "Total:\n");
-    printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalStylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing);
+    printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalStylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing,
+        m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMatchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatchedPropertiesEnteredIntoCache);
     fprintf(stderr, "--------------------------------------------------------------------------------\n");
 }
 #endif
diff --git a/Source/core/css/resolver/StyleResolver.h b/Source/core/css/resolver/StyleResolver.h
index dc2f017..386594e 100644
--- a/Source/core/css/resolver/StyleResolver.h
+++ b/Source/core/css/resolver/StyleResolver.h
@@ -49,6 +49,7 @@
 class CSSValue;
 class ContainerNode;
 class Document;
+class DocumentTimeline;
 class Element;
 class ElementRuleCollector;
 class KeyframeList;
@@ -91,10 +92,17 @@
     void addStyleShared() { ++m_stylesShared; ++m_totalStylesShared; }
     void addSearchFoundSiblingForSharing() { ++m_searchFoundSiblingForSharing; ++m_totalSearchFoundSiblingForSharing; }
     void addSearchMissedSharing() { ++m_searchesMissedSharing; ++m_totalSearchesMissedSharing; }
+    void addMatchedPropertiesSearch() { ++m_matchedPropertiesSearches; ++m_totalMatchedPropertiesSearches; }
+    void addMatchedPropertiesHit() { ++m_matchedPropertiesHit; ++m_totalMatchedPropertiesHit; }
+    void addMatchedPropertiesHitSharedInherited() { ++m_matchedPropertiesSharedInheritedHit; ++m_totalMatchedPropertiesSharedInheritedHit; }
+    void addMatchedPropertiesToCache() { ++m_matchedPropertiesToCache; ++m_totalMatchedPropertiesToCache; }
+    void addMatchedPropertiesEnteredIntoCache() { ++m_matchedPropertiesEnteredIntoCache; ++m_totalMatchedPropertiesEnteredIntoCache; }
 
     void clear()
     {
-        m_searches = m_elementsEligibleForSharing = m_stylesShared = m_searchesMissedSharing = m_searchFoundSiblingForSharing = 0;
+        m_searches = m_elementsEligibleForSharing = m_stylesShared = m_searchesMissedSharing = m_searchFoundSiblingForSharing =
+            m_matchedPropertiesSearches = m_matchedPropertiesHit = m_matchedPropertiesSharedInheritedHit = m_matchedPropertiesToCache =
+            m_matchedPropertiesEnteredIntoCache = 0;
     }
 
     void printStats() const;
@@ -104,12 +112,22 @@
     unsigned m_stylesShared;
     unsigned m_searchFoundSiblingForSharing;
     unsigned m_searchesMissedSharing;
+    unsigned m_matchedPropertiesSearches;
+    unsigned m_matchedPropertiesHit;
+    unsigned m_matchedPropertiesSharedInheritedHit;
+    unsigned m_matchedPropertiesToCache;
+    unsigned m_matchedPropertiesEnteredIntoCache;
 
     unsigned m_totalSearches;
     unsigned m_totalElementsEligibleForSharing;
     unsigned m_totalStylesShared;
     unsigned m_totalSearchFoundSiblingForSharing;
     unsigned m_totalSearchesMissedSharing;
+    unsigned m_totalMatchedPropertiesSearches;
+    unsigned m_totalMatchedPropertiesHit;
+    unsigned m_totalMatchedPropertiesSharedInheritedHit;
+    unsigned m_totalMatchedPropertiesToCache;
+    unsigned m_totalMatchedPropertiesEnteredIntoCache;
 };
 
 #define STYLE_STATS_ADD_SEARCH() StyleResolver::styleSharingStats().addSearch();
@@ -119,6 +137,11 @@
 #define STYLE_STATS_ADD_SEARCH_MISSED_SHARING() StyleResolver::styleSharingStats().addSearchMissedSharing();
 #define STYLE_STATS_PRINT() StyleResolver::styleSharingStats().printStats();
 #define STYLE_STATS_CLEAR() StyleResolver::styleSharingStats().clear();
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH() StyleResolver::styleSharingStats().addMatchedPropertiesSearch();
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT() StyleResolver::styleSharingStats().addMatchedPropertiesHit();
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT_SHARED_INHERITED() StyleResolver::styleSharingStats().addMatchedPropertiesHitSharedInherited();
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_TO_CACHE() StyleResolver::styleSharingStats().addMatchedPropertiesToCache();
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_ENTERED_INTO_CACHE() StyleResolver::styleSharingStats().addMatchedPropertiesEnteredIntoCache();
 #else
 #define STYLE_STATS_ADD_SEARCH() (void(0));
 #define STYLE_STATS_ADD_ELEMENT_ELIGIBLE_FOR_SHARING() (void(0));
@@ -127,6 +150,11 @@
 #define STYLE_STATS_ADD_SEARCH_MISSED_SHARING() (void(0));
 #define STYLE_STATS_PRINT() (void(0));
 #define STYLE_STATS_CLEAR() (void(0));
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH() (void(0));
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT() (void(0));
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_HIT_SHARED_INHERITED() (void(0));
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_TO_CACHE() (void(0));
+#define STYLE_STATS_ADD_MATCHED_PROPERTIES_ENTERED_INTO_CACHE() (void(0));
 #endif
 
 // FIXME: Move to separate file.
@@ -210,9 +238,9 @@
     }
 
     // FIXME: Used by SharingStyleFinder, but should be removed.
-    bool styleSharingCandidateMatchesRuleSet(const ElementResolveContext&, RuleSet*);
+    bool styleSharingCandidateMatchesRuleSet(const ElementResolveContext&, RenderStyle*, RuleSet*);
 
-    const StyleRuleKeyframes* matchScopedKeyframesRule(Element*, const AtomicStringImpl* animationName);
+    const StyleRuleKeyframes* matchScopedKeyframesRule(Element*, const StringImpl* animationName);
     PassRefPtr<RenderStyle> styleForKeyframe(Element*, const RenderStyle*, const StyleKeyframe*, KeyframeValue&);
 
     // These methods will give back the set of rules that matched for a given element (or a pseudo-element).
@@ -264,21 +292,21 @@
 #endif
 private:
     // FIXME: This should probably go away, folded into FontBuilder.
-    void updateFont();
+    void updateFont(StyleResolverState&);
 
     void matchUARules(ElementRuleCollector&, RuleSet*);
-    void matchAuthorRules(ElementRuleCollector&, bool includeEmptyRules);
+    void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRules);
     void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRules);
-    void matchHostRules(ScopedStyleResolver*, ElementRuleCollector&, bool includeEmptyRules);
-    void matchScopedAuthorRules(ElementRuleCollector&, bool includeEmptyRules);
-    void matchAllRules(ElementRuleCollector&, bool matchAuthorAndUserStyles, bool includeSMILProperties);
+    void matchHostRules(Element*, ScopedStyleResolver*, ElementRuleCollector&, bool includeEmptyRules);
+    void matchScopedAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRules);
+    void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool matchAuthorAndUserStyles, bool includeSMILProperties);
     void matchUARules(ElementRuleCollector&);
     void matchUserRules(ElementRuleCollector&, bool includeEmptyRules);
     void collectFeatures();
 
     bool fastRejectSelector(const RuleData&) const;
 
-    void applyMatchedProperties(const MatchResult&, const Element*);
+    void applyMatchedProperties(StyleResolverState&, const MatchResult&, const Element*);
 
     enum StyleApplicationPass {
         VariableDefinitions,
@@ -289,12 +317,12 @@
     template <StyleResolver::StyleApplicationPass pass>
     static inline bool isPropertyForPass(CSSPropertyID);
     template <StyleApplicationPass pass>
-    void applyMatchedProperties(const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly);
+    void applyMatchedProperties(StyleResolverState&, const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly);
     template <StyleApplicationPass pass>
-    void applyProperties(const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = PropertyWhitelistNone);
+    void applyProperties(StyleResolverState&, const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = PropertyWhitelistNone);
     template <StyleApplicationPass pass>
-    void applyAnimatedProperties(const Element* target);
-    void resolveVariables(CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions);
+    void applyAnimatedProperties(StyleResolverState&, const Element*, const DocumentTimeline*);
+    void resolveVariables(StyleResolverState&, CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions);
     void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPage, const String& pageName);
     void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vector<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName);
     void collectViewportRules();
@@ -308,14 +336,14 @@
     DocumentRuleSets m_ruleSets;
 
     // FIXME: This likely belongs on RuleSet.
-    typedef HashMap<AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
+    typedef HashMap<StringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
     KeyframesRuleMap m_keyframesRuleMap;
 
     static RenderStyle* s_styleNotYetAvailable;
 
     void cacheBorderAndBackground();
 
-    void applyProperty(CSSPropertyID, CSSValue*);
+    void applyProperty(StyleResolverState&, CSSPropertyID, CSSValue*);
 
     MatchedPropertiesCache m_matchedPropertiesCache;
 
@@ -340,7 +368,6 @@
 
     InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
 
-    StyleResolverState* m_state;
     StyleResourceLoader m_styleResourceLoader;
 
 #ifdef STYLE_STATS
diff --git a/Source/core/css/resolver/StyleResolverState.cpp b/Source/core/css/resolver/StyleResolverState.cpp
index 4b5d25f..19f3029 100644
--- a/Source/core/css/resolver/StyleResolverState.cpp
+++ b/Source/core/css/resolver/StyleResolverState.cpp
@@ -47,16 +47,13 @@
     m_rootElementStyle = documentElement && element != documentElement ? documentElement->renderStyle() : documentStyle;
 }
 
-StyleResolverState::StyleResolverState(StyleResolverState** thisPointer, const Document* newDocument, Element* newElement, RenderStyle* parentStyle, RenderRegion* regionForStyling)
+StyleResolverState::StyleResolverState(const Document* newDocument, Element* newElement, RenderStyle* parentStyle, RenderRegion* regionForStyling)
     : m_regionForStyling(0)
     , m_applyPropertyToRegularStyle(true)
     , m_applyPropertyToVisitedLinkStyle(false)
     , m_lineHeightValue(0)
     , m_styleMap(*this, m_elementStyleResources)
-    , m_thisPointer(thisPointer)
 {
-    if (m_thisPointer)
-        *m_thisPointer = this;
     ASSERT(!element() || document() == newDocument);
     if (newElement)
         m_elementContext = ElementResolveContext(newElement);
@@ -87,8 +84,6 @@
 
 StyleResolverState::~StyleResolverState()
 {
-    if (m_thisPointer)
-        *m_thisPointer = 0;
     m_elementContext = ElementResolveContext();
     m_style = 0;
     m_parentStyle = 0;
diff --git a/Source/core/css/resolver/StyleResolverState.h b/Source/core/css/resolver/StyleResolverState.h
index 0740fb7..3a911bb 100644
--- a/Source/core/css/resolver/StyleResolverState.h
+++ b/Source/core/css/resolver/StyleResolverState.h
@@ -75,7 +75,7 @@
 class StyleResolverState {
 WTF_MAKE_NONCOPYABLE(StyleResolverState);
 public:
-    StyleResolverState(StyleResolverState**, const Document*, Element*, RenderStyle* parentStyle = 0, RenderRegion* regionForStyling = 0);
+    StyleResolverState(const Document*, Element*, RenderStyle* parentStyle = 0, RenderRegion* regionForStyling = 0);
     ~StyleResolverState();
 
     // These are all just pass-through methods to ElementResolveContext.
@@ -122,7 +122,7 @@
     // sites are extremely verbose.
     PassRefPtr<StyleImage> styleImage(CSSPropertyID propertyId, CSSValue* value)
     {
-        return m_elementStyleResources.styleImage(document()->textLinkColors(), style()->visitedDependentColor(CSSPropertyColor), propertyId, value);
+        return m_elementStyleResources.styleImage(document()->textLinkColors(), propertyId, value);
     }
 
     FontBuilder& fontBuilder() { return m_fontBuilder; }
@@ -179,8 +179,6 @@
     // CSSToStyleMap is a pure-logic class and only contains
     // a back-pointer to this object.
     CSSToStyleMap m_styleMap;
-
-    StyleResolverState** m_thisPointer;
 };
 
 } // namespace WebCore
diff --git a/Source/core/css/resolver/TransformBuilder.cpp b/Source/core/css/resolver/TransformBuilder.cpp
index bad03c4..84fe3a8 100644
--- a/Source/core/css/resolver/TransformBuilder.cpp
+++ b/Source/core/css/resolver/TransformBuilder.cpp
@@ -51,7 +51,7 @@
 {
 }
 
-static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
+static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
 {
     return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(style, rootStyle, multiplier) : Length(Undefined);
 }
@@ -85,7 +85,7 @@
     return TransformOperation::NONE;
 }
 
-bool TransformBuilder::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations)
+bool TransformBuilder::createTransformOperations(CSSValue* inValue, const RenderStyle* style, const RenderStyle* rootStyle, TransformOperations& outOperations)
 {
     if (!inValue || !inValue->isValueList()) {
         outOperations.clear();
diff --git a/Source/core/css/resolver/TransformBuilder.h b/Source/core/css/resolver/TransformBuilder.h
index 5e5d111..d582465 100644
--- a/Source/core/css/resolver/TransformBuilder.h
+++ b/Source/core/css/resolver/TransformBuilder.h
@@ -45,7 +45,7 @@
     TransformBuilder();
     ~TransformBuilder();
 
-    static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations);
+    static bool createTransformOperations(CSSValue* inValue, const RenderStyle* inStyle, const RenderStyle* rootStyle, TransformOperations& outOperations);
 };
 
 } // namespace WebCore